Closed neosun100 closed 10 months ago
ctx := context.Background() client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("API_KEY"))) if err != nil { log.Fatal(err) } defer client.Close()
model := client.GenerativeModel("gemini-pro")
iter := model.GenerateContentStream(ctx, genai.Text("Write a story about a magic backpack.")) for { resp, err := iter.Next() if err == iterator.Done { break } if err != nil { log.Fatal(err) }
// print resp }
I see that it has already been supported. It's really a good project.
ctx := context.Background() client, err := genai.NewClient(ctx, option.WithAPIKey(os.Getenv("API_KEY"))) if err != nil { log.Fatal(err) } defer client.Close()
model := client.GenerativeModel("gemini-pro")
iter := model.GenerateContentStream(ctx, genai.Text("Write a story about a magic backpack.")) for { resp, err := iter.Next() if err == iterator.Done { break } if err != nil { log.Fatal(err) }
// print resp }