Skip to content

Commit

Permalink
Update prompt in json_no_schema snippet (#210)
Browse files Browse the repository at this point in the history
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"}]`
  • Loading branch information
pcoet authored Sep 12, 2024
1 parent 1aa0515 commit 2ec7e23
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion genai/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<Recipe>`
resp, err := model.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 4 additions & 1 deletion genai/internal/samples/docs-snippets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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<Recipe>`
resp, err := model.GenerateContent(ctx, genai.Text(prompt))
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 2ec7e23

Please sign in to comment.