From 2ec7e23d0c921b95b2ef733030715a298972724d Mon Sep 17 00:00:00 2001 From: David Huntsperger <5672572+pcoet@users.noreply.github.com> Date: Thu, 12 Sep 2024 07:03:42 -0700 Subject: [PATCH] Update prompt in json_no_schema snippet (#210) Make this match the other language snippets. Tested the change on my machine, and the output is as expected: `[{"recipeName": "Chocolate Chip Cookies"}, {"recipeName": "Peanut Butter Cookies"}, {"recipeName": "Oatmeal Raisin Cookies"}, {"recipeName": "Sugar Cookies"}, {"recipeName": "Snickerdoodles"}]` --- genai/example_test.go | 5 ++++- genai/internal/samples/docs-snippets_test.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/genai/example_test.go b/genai/example_test.go index 184eb7c..cd225b0 100644 --- a/genai/example_test.go +++ b/genai/example_test.go @@ -912,7 +912,10 @@ func ExampleGenerativeModel_jSONNoSchema() { model := client.GenerativeModel("gemini-1.5-pro-latest") // Ask the model to respond with JSON. model.ResponseMIMEType = "application/json" - resp, err := model.GenerateContent(ctx, genai.Text("List a few popular cookie recipes.")) + prompt := `List a few popular cookie recipes using this JSON schema: + Recipe = {'recipeName': string} + Return: Array` + resp, err := model.GenerateContent(ctx, genai.Text(prompt)) if err != nil { log.Fatal(err) } diff --git a/genai/internal/samples/docs-snippets_test.go b/genai/internal/samples/docs-snippets_test.go index 92ee450..4e6a0d1 100644 --- a/genai/internal/samples/docs-snippets_test.go +++ b/genai/internal/samples/docs-snippets_test.go @@ -942,7 +942,10 @@ func ExampleGenerativeModel_jSONNoSchema() { model := client.GenerativeModel("gemini-1.5-pro-latest") // Ask the model to respond with JSON. model.ResponseMIMEType = "application/json" - resp, err := model.GenerateContent(ctx, genai.Text("List a few popular cookie recipes.")) + prompt := `List a few popular cookie recipes using this JSON schema: + Recipe = {'recipeName': string} + Return: Array` + resp, err := model.GenerateContent(ctx, genai.Text(prompt)) if err != nil { log.Fatal(err) }