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

Gemini sometimes returns a list index error while streaming #1055

Open
chug2k opened this issue Jul 16, 2024 · 3 comments
Open

Gemini sometimes returns a list index error while streaming #1055

chug2k opened this issue Jul 16, 2024 · 3 comments

Comments

@chug2k
Copy link

chug2k commented Jul 16, 2024

My code:

    for delta in assistant.run(task, stream=True):

Stack trace inside assistant.py:

  File "<redacted>/lib/python3.10/site-packages/phi/assistant/assistant.py", line 890, in _run
    for response_chunk in self.llm.response_stream(messages=llm_messages):
  File "<redacted>/lib/python3.10/site-packages/phi/llm/gemini/gemini.py", line 260, in response_stream
    _part_dict = response_parts[0].to_dict()
IndexError: list index out of range
@ysolanky
Copy link
Contributor

Hello @chug2k! Could you please share some debug logs by setting debug_mode=True parameter in the Assistant? This will help us isolate the issue

@chug2k
Copy link
Author

chug2k commented Jul 17, 2024

it's hard to repro 100%, I assume it has to do with Google doing something weird, perhaps sending back an empty response during a stream. I don't understand how response_parts could have length of 0, and it seems to happen during the middle of the stream. Would it be too n00by to just have a little check there to skip things if response_parts is of length 0?

@ysolanky
Copy link
Contributor

@chug2k you're right. response_parts should never be 0 and Gemini docs do not specify any case in which it could be 0. I am going to try to replicate this issue and get back to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants