avastmick/google-generative-ai-rs

stream output miss first text

Closed this issue · 7 comments

use the code:
GeminiClient::for_each_async(json_stream, move |response: GeminiResponse| async move {
println!(
"{}",
response.candidates[0].content.parts[0]
.text
.clone()
.unwrap()
.as_str()
);
})
output miss first text:

P60`7 }F73I$N)NO__3{KU8

this is the aistudio output:

K1E32A_ 0}4MZ_N_{`Y8SWW

try a lot of example ,the problem continue

Thanks, I'll investigate when I get time over the weekend.

Hi, @xmlandroid, I cannot replicate this in any way. I always see all of the response from the API.

So I can help you further, can you give more techical details on your usage? Please include:

  • version of crate
  • whether the 'beta' features are enabled
  • whether this is using the open API or using Vertex
  • A more comprehensive listing of the code you are using to fetch/process the response.

I find the problem is when I use serde_json::from_value convert the Value to GeminiResponse the first chunk will return Err not Ok

other chunk is ok,just the first Gemini return struct is different ,convert the value to GeminiResponse get Err

By the way, do you have any examples of conversations with pictures?