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

ChatGoogle doesn't work with streaming tools #2

Open
cpsievert opened this issue Oct 29, 2024 · 0 comments
Open

ChatGoogle doesn't work with streaming tools #2

cpsievert opened this issue Oct 29, 2024 · 0 comments

Comments

@cpsievert
Copy link
Collaborator

This seems like a current limitation in Google Gemini itself -- see google-gemini/generative-ai-python#446

from chatlas import ChatGoogle, ToolDef

chat = ChatGoogle(system_prompt="Be very terse, not even punctuation.")
chat.register_tool(
    ToolDef(lambda: "2024-01-01", name="get_date", description="Gets the current date")
)

chat.chat("What's the current date in YMD format?", stream=True)
Traceback (most recent call last):
  File "/Users/cpsievert/github/chatlas/sandbox/assert_google.py", line 19, in <module>
    chat.chat(
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 235, in chat
    self._chat_emit(user_turn(*args), stream=stream, kwargs=kwargs)
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 351, in _chat_emit
    for part in response:
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 387, in _chat_impl
    for chunk in self._submit_turns(user_turn_result, stream, kwargs=kwargs):
  File "/Users/cpsievert/github/chatlas/chatlas/_chat.py", line 424, in _submit_turns
    text = self.provider.stream_text(chunk)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/cpsievert/github/chatlas/chatlas/_google.py", line 201, in stream_text
    return chunk.text
           ^^^^^^^^^^
  File "/Users/cpsievert/github/chatlas/.venv/lib/python3.12/site-packages/google/generativeai/types/generation_types.py", line 536, in text
    part_type = protos.Part.pb(part).whichOneof("data")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: whichOneof. Did you mean: 'WhichOneof'?
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

1 participant