zhu327 / gemini-openai-proxy

A proxy for converting the OpenAI API protocol to the Google Gemini Pro protocol.
MIT License
580 stars 109 forks source link

Please modify to streaming reply mode: model.GenerateContentStream #17

Closed neosun100 closed 10 months ago

neosun100 commented 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 }

neosun100 commented 10 months ago

I see that it has already been supported. It's really a good project.