Skip to content

Commit

Permalink
Adding example of EmbedContent
Browse files Browse the repository at this point in the history
  • Loading branch information
eliben committed Dec 13, 2023
1 parent 0a2c82e commit 676dda8
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions genai/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,22 @@ func ExampleChatSession() {
printResponse(res)
}

func ExampleEmbeddingModel_EmbedContent() {
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey("your-API-key"))
if err != nil {
log.Fatal(err)
}
defer client.Close()
em := client.EmbeddingModel("embedding-001")
res, err := em.EmbedContent(ctx, genai.Text("cheddar cheese"))

if err != nil {
panic(err)
}
fmt.Println(res.Embedding.Values)
}

func ExampleClient_ListModels() {
ctx := context.Background()
client, err := genai.NewClient(ctx, option.WithAPIKey("your-API-key"))
Expand Down

0 comments on commit 676dda8

Please sign in to comment.