From 96e8c523c1fc043f9fd4272376ae00a4119e4d8c Mon Sep 17 00:00:00 2001 From: Jacklyn Date: Tue, 26 Nov 2024 14:39:40 -0600 Subject: [PATCH 1/5] Update quickstart.mdx --- quickstart.mdx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/quickstart.mdx b/quickstart.mdx index 769cb6d9..7e5d6964 100644 --- a/quickstart.mdx +++ b/quickstart.mdx @@ -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: + + ```ts AssemblyScript export function generateText(text: string): string { const model = models.getModel("text-generator") @@ -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 + } + ``` + + + 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! From ad6e8306c4f062d852714493799725edecba1b03 Mon Sep 17 00:00:00 2001 From: Jacklyn Date: Wed, 27 Nov 2024 13:30:36 -0600 Subject: [PATCH 2/5] Update quickstart.mdx --- quickstart.mdx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/quickstart.mdx b/quickstart.mdx index 7e5d6964..866966d1 100644 --- a/quickstart.mdx +++ b/quickstart.mdx @@ -115,7 +115,10 @@ the basic components of a Modus app and how to deploy it to Hypermode. Our API is responding using language that is more formal than we want. Let's update our `generateText` function to respond using exclusively surfing analogies. - Go to the `index.ts` file and locate the `generateText` function. Modify the function + Open the file that has your `generateText` function. If you are using AssemblyScript, open the `index.ts` file. + If you are using Go, open the `main.go` file. + + After opening the file, locate the `generateText` function. Modify the function to only respond like a surfer, like this: From 8a162917896ac8c0b97c456702e849763c71e490 Mon Sep 17 00:00:00 2001 From: Jacklyn Date: Tue, 3 Dec 2024 10:25:33 -0600 Subject: [PATCH 3/5] change codegroup to tabs --- quickstart.mdx | 83 +++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/quickstart.mdx b/quickstart.mdx index 866966d1..cd77e3ed 100644 --- a/quickstart.mdx +++ b/quickstart.mdx @@ -115,56 +115,55 @@ the basic components of a Modus app and how to deploy it to Hypermode. Our API is responding using language that is more formal than we want. Let's update our `generateText` function to respond using exclusively surfing analogies. - Open the file that has your `generateText` function. If you are using AssemblyScript, open the `index.ts` file. - If you are using Go, open the `main.go` file. - - After opening the file, locate the `generateText` function. Modify the function - to only respond like a surfer, like this: - - - - ```ts AssemblyScript - export function generateText(text: string): string { - const model = models.getModel("text-generator") - - const input = model.createInput([ - new SystemMessage( - "You are a helpful assistant. Only respond using surfing analogies and metaphors.", - ), - new UserMessage(text), - ]) + + + Go to the `main.go` file and locate the `generateText` function. Modify the function to only respond like a surfer, like this: + + ```ts Go + func GenerateText(text string) (string, error) { + model, err := models.GetModel[openai.ChatModel]("text-generator") + if err != nil { + return "", err + } - const output = model.invoke(input) + 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 + } - return output.choices[0].message.content.trim() - } - ``` + output, err := model.Invoke(input) + if err != nil { + return "", err + } - ```ts Go - func GenerateText(text string) (string, error) { - model, err := models.GetModel[openai.ChatModel]("text-generator") - if err != nil { - return "", err + return strings.TrimSpace(output.Choices[0].Message.Content), nil } + ``` + + + Go to the `index.ts` file and locate the `generateText` function. Modify the function to only respond like a surfer, like this: - 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 - } + ```ts AssemblyScript + export function generateText(text: string): string { + const model = models.getModel("text-generator") - output, err := model.Invoke(input) - if err != nil { - return "", err - } + const input = model.createInput([ + new SystemMessage( + "You are a helpful assistant. Only respond using surfing analogies and metaphors.", + ), + new UserMessage(text), + ]) - return strings.TrimSpace(output.Choices[0].Message.Content), nil - } - ``` + const output = model.invoke(input) - + return output.choices[0].message.content.trim() + } + ``` + + 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 From de632fd471e1ebba1ee684945109922f415a7f44 Mon Sep 17 00:00:00 2001 From: Jacklyn Date: Tue, 3 Dec 2024 10:34:45 -0600 Subject: [PATCH 4/5] update ts Co-authored-by: Ryan Fox-Tyler <60440289+ryanfoxtyler@users.noreply.github.com> --- quickstart.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart.mdx b/quickstart.mdx index cd77e3ed..134e0632 100644 --- a/quickstart.mdx +++ b/quickstart.mdx @@ -119,7 +119,7 @@ the basic components of a Modus app and how to deploy it to Hypermode. Go to the `main.go` file and locate the `generateText` function. Modify the function to only respond like a surfer, like this: - ```ts Go + ```ts main.go func GenerateText(text string) (string, error) { model, err := models.GetModel[openai.ChatModel]("text-generator") if err != nil { From 790e23ee07109f82a3bfe98a4e631fab56127663 Mon Sep 17 00:00:00 2001 From: Jacklyn Date: Tue, 3 Dec 2024 10:34:53 -0600 Subject: [PATCH 5/5] Update ts Co-authored-by: Ryan Fox-Tyler <60440289+ryanfoxtyler@users.noreply.github.com> --- quickstart.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quickstart.mdx b/quickstart.mdx index 134e0632..237893a4 100644 --- a/quickstart.mdx +++ b/quickstart.mdx @@ -146,7 +146,7 @@ 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: - ```ts AssemblyScript + ```ts index.ts export function generateText(text: string): string { const model = models.getModel("text-generator")