Issue Description :
While utilizing the ChatGoogleGenerativeAI
class, I encountered a TypeError
indicating that the object GenerateContentResponse
cannot be used within an await
expression.
Steps to Reproduce:
- Initialize the
ChatGoogleGenerativeAI
class with the appropriate parameters, including the model and API key. - Attempt to call an asynchronous method, such as
ainvoke
, on the instance. - Observe the
TypeError
indicating thatGenerateContentResponse
cannot be used in anawait
expression.
ERROR [agent] ❌ Result failed 1/3 times:
object GenerateContentResponse can't be used in 'await' expression
Note : I am using this class with the browser-use Agent class to perform a task. Can anyone help me with this, Please refer the below code for reference.
async def script_validation():
task = (
‘Important : I am UI Automation tester validating the tasks’
‘Open website https://www.google.co.in/’
)
gemini_api_key = os.environ[“GEMINI_API_KEY”]
llm = ChatGoogleGenerativeAI(model=‘gemini-2.0-flash’, api_key=SecretStr(gemini_api_key), transport=“rest”)
agent = Agent(task=task, llm=llm, use_vision=True)
result = await agent.run()
asyncio.run(script_validation())
Can anyone please help ?