Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: String data: stripped from entire content in streamed Gemini responses #8143

Open
lokflam opened this issue Jan 31, 2025 · 0 comments
Labels
bug Something isn't working high priority

Comments

@lokflam
Copy link

lokflam commented Jan 31, 2025

What happened?

When streaming responses from Gemini models, the string data: is unexpectedly removed from the entire content, not just from the SSE message prefix.

Potential cause:

The issue is likely cause by from this line of code, which appears to remove all instances of data: from the streaming chunks:
https://github.com/BerriAI/litellm/blob/v1.59.10/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py#L1434

Steps to reproduce:

  1. Non-streaming response

    from litellm import completion
    import os
    
    response = completion(
        model="vertex_ai/gemini-2.0-flash-exp",
        messages=[{"role": "user", "content": "print `somedata: abc` in yaml"}],
    )
    
    print(response.choices[0].message.content)

    Output

    somedata: abc
  2. Streaming response

    from litellm import completion, stream_chunk_builder
    import os
    
    response = completion(
        model="vertex_ai/gemini-2.0-flash-exp",
        messages=[{"role": "user", "content": "print `somedata: abc` in yaml"}],
        stream=True,
    )
    
    chunks = []
    for chunk in response:
        chunks.append(chunk)
    
    print(stream_chunk_builder(chunks).choices[0].message.content)

    Output

    some abc

Relevant log output

Are you a ML Ops Team?

No

What LiteLLM version are you on ?

v1.59.10

Twitter / LinkedIn details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

2 participants