-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Description
It appears that langchain-google-genai has not yet released a version beyond 2.0.9. If you need to use a fix related to function calling or schema handling before an official release, you can apply a manual patch. This workaround involves directly modifying the installed package files based on changes made in a recent pull request.
-
Locate the
langchain-google-genai
Installation Path:- Use the command
pip show langchain-google-genai
to determine the installed location of the package. - For example, the output might show a path like
D:\softwares\miniconda\envs\agent\Lib\site-packages\langchain_google_genai
.
- Use the command
-
Navigate to the Installation Directory:
- Open your file explorer or command line and go to the directory obtained in step 1.
-
Modify the
_function_utils.py
File:- Locate the file named
_function_utils.py
within thelangchain_google_genai
directory. - Open
_function_utils.py
with a text editor (like VS Code, Notepad++, etc.). - Find line 318, which likely looks like this:
if properties_item.get("type_") == glm.Type.OBJECT: ... (original code)
- Replace the original code block with the following:
if properties_item.get("type_") == glm.Type.OBJECT: if ( v.get("anyOf") and isinstance(v["anyOf"], list) and isinstance(v["anyOf"][0], dict) ): v = v["anyOf"][0] v_properties = v.get("properties") if v_properties: properties_item["properties"] = _get_properties_from_schema_any( v_properties ) if isinstance(v_properties, dict): properties_item["required"] = [ k for k, v in v_properties.items() if "default" not in v ] else: # Providing dummy type for object without properties properties_item["type_"] = glm.Type.STRING
- Locate the file named
-
Save the Changes:
- Save the modified
_function_utils.py
file.
- Save the modified
refer: https://github.com/langchain-ai/langchain-google/pull/658/files
richard-devbot and igorgomes3
Metadata
Metadata
Assignees
Labels
No labels