You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importasynciofrombrowser_useimportAgentfromlibs.genai.langchain_google_genaiimportChatGoogleGenerativeAIasyncdefmain():
agent=Agent(
task="Navigate to https://www.wikipedia.org/ and find the article about 'xAI (company)' and summarize it.",
llm=ChatGoogleGenerativeAI(model="gemini-2.0-flash-exp"),
)
result=awaitagent.run()
print(result)
asyncio.run(main())
We experienced the following error in gemini :
Unexpected error: Invalid argument provided to Gemini: 400 * GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[input_text].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[go_to_url].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[scroll_up].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[extract_content].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[open_tab].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[go_back].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[search_google].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[click_element].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[done].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[switch_tab].properties: should be non-empty for OBJECT type
* GenerateContentRequest.tools[0].function_declarations[0].parameters.properties[action].properties[scroll_down].properties: should be non-empty for OBJECT type
Stacktrace:
Traceback (most recent call last):
File "..\langchain-google\libs\genai\langchain_google_genai\chat_models.py", line 220, in _achat_with_retry
return await generation_method(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "..\langchain-google\.venv\Lib\site-packages\google\ai\generativelanguage_v1beta\services\generative_service\async_client.py", line 406, in generate_content
response = await rpc(
^^^^^^^^^^
File "..\langchain-google\.venv\Lib\site-packages\google\api_core\retry\retry_unary_async.py", line 230, in retry_wrapped_func
return await retry_target(
^^^^^^^^^^^^^^^^^^^
File "..\langchain-google\.venv\Lib\site-packages\google\api_core\retry\retry_unary_async.py", line 160, in retry_target
_retry_error_helper(
File "..\langchain-google\.venv\Lib\site-packages\google\api_core\retry\retry_base.py", line 212, in _retry_error_helper
raise final_exc from source_exc
File "..\langchain-google\.venv\Lib\site-packages\google\api_core\retry\retry_unary_async.py", line 155, in retry_target
return await target()
^^^^^^^^^^^^^^
File "..\langchain-google\.venv\Lib\site-packages\google\api_core\grpc_helpers_async.py", line 88, in __await__
raise exceptions.from_grpc_error(rpc_error) from rpc_error
This happens since gregpr07/browser-use use nested Pydantic structure, and after debugging the problem is in how langchain handles nested Pydantic structured in with_structured_output. Specifically, the issues occurred in _get_properties_from_schema method in libs\genai\langchain_google_genai\_function_utils.py.
The text was updated successfully, but these errors were encountered:
Shahar-Y
changed the title
[BUG] Structured Output doesn't work with advanced schema
[BUG] Nested pydantic structures do not work
Dec 19, 2024
While working with gregpr07/browser-use, @MahlerTom and I tried to use Gemini 2.0 as seen in the example below.
We experienced the following error in gemini :
This happens since gregpr07/browser-use use nested
Pydantic
structure, and after debugging the problem is in how langchain handles nestedPydantic
structured inwith_structured_output
. Specifically, the issues occurred in_get_properties_from_schema
method inlibs\genai\langchain_google_genai\_function_utils.py
.The text was updated successfully, but these errors were encountered: