Unable to call aivoke with transport="rest".
Description of the bug:
When I set transport="rest" in ChatGoogleGenerativeAI, I can't use chain.ainvoke
def get_gemini_pro() -> BaseChatModel:
return ChatGoogleGenerativeAI(model="gemini-1.5-pro-latest",
temperature=0,
convert_system_message_to_human=True,
transport="rest")
async def invokeChain(code):
llm=get_gemini_pro()
chain=descriptionGenTemplate()|llm|CodeoutputStruction()
res= await chain.ainvoke({"code":code})
print(res)
if __name__ == '__main__':
code="""
xxxxxxxxxxxxxxx
"""
asyncio.run(invokeChain(code))
Executing the above code displays the following error:
Traceback (most recent call last):
File "f:\code\pythonProject\Gemini_CWEs\codeExpansion.py", line 93, in <module>
asyncio.run(invokeChain(code))
File "E:\anaconda\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
......
File "C:\Users\kento\AppData\Local\pypoetry\Cache\virtualenvs\gemini-cwes-rly_BX-h-py3.11\Lib\site-packages\google\api_core\grpc_helpers_async.py", line 187, in error_remapped_callable
raise TypeError("Unexpected type of call %s" % type(call))
TypeError: Unexpected type of call <class 'google.ai.generativelanguage_v1beta.types.generative_service.GenerateContentResponse'>
Actual vs expected behavior:
No response
Any other information you'd like to share?
No response
It might be that streaming with transport="rest" is broken.
Edit: No. Rest async streaming is broken.
https://github.com/search?q=repo%3Agoogle-gemini%2Fgenerative-ai-python+%22Unexpected+type+of+call%22&type=issues
Marking this issue as stale since it has been open for 14 days with no activity. This issue will be closed if no further activity occurs.
This issue was closed because it has been inactive for 28 days. Please post a new issue if you need further assistance. Thanks!