Skip to content

Commit

Permalink
Update quickstart.mdx
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklynlee31 committed Nov 26, 2024
1 parent dee98fc commit 96e8c52
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ the basic components of a Modus app and how to deploy it to Hypermode.
Go to the `index.ts` file and locate the `generateText` function. Modify the function
to only respond like a surfer, like this:
<CodeGroup>
```ts AssemblyScript
export function generateText(text: string): string {
const model = models.getModel<OpenAIChatModel>("text-generator")
Expand All @@ -135,6 +137,32 @@ the basic components of a Modus app and how to deploy it to Hypermode.
}
```
```ts Go
func GenerateText(text string) (string, error) {
model, err := models.GetModel[openai.ChatModel]("text-generator")
if err != nil {
return "", err
}
input, err := model.CreateInput(
openai.NewSystemMessage("You are a helpful assistant. Only respond using surfing analogies and metaphors."),
openai.NewUserMessage(text),
)
if err != nil {
return "", err
}
output, err := model.Invoke(input)
if err != nil {
return "", err
}
return strings.TrimSpace(output.Choices[0].Message.Content), nil
}
```
</CodeGroup>
Save the file and push an update to your Git repo. Hypermode automatically redeploys
whenever you push an update to the target branch in your Git repo. Go back to the Hypermode Console
and run the same query as before. You should see the response now uses surfing analogies!
Expand Down

0 comments on commit 96e8c52

Please sign in to comment.