-
Notifications
You must be signed in to change notification settings - Fork 318
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
reasoning_engines.ReasoningEngine.create unable to pickle LangchainAgent using a VertexAISearchRetriever retriever tool #3710
Comments
Thank you for filing an issue and sorry for the slow response! Unfortunately this isn't going to work out-of-the-box yet, and you'll have to use a workaround by wrapping the tool into a python function like def search_movie_data(query: str) -> str:
"""Searches and returns information about movies."""
from langchain_google_community import VertexAISearchRetriever
retriever = VertexAISearchRetriever(
project_id=PROJECT_ID,
data_store_id=DATA_STORE_ID,
location_id=LOCATION_ID,
engine_data_type=DATASTORE_TYPE,
max_documents=3,
)
result = str(retriever.invoke(query))
return result
# ...
remote_app = reasoning_engines.ReasoningEngine.create(
reasoning_engines.LangchainAgent(
...
tools=[search_movie_data],
...
),
...,
) You can find an end-to-end example at https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/reasoning-engine/tutorial_vertex_ai_search_rag_agent.ipynb Can you try it and let us know if the workaround works for you in the meantime? |
Found a workaround for this by defining a custom tool with a class:
And then just instantiate with It is based on this: https://python.langchain.com/v0.1/docs/modules/tools/custom_tools/#subclass-basetool |
@yeesian Interestingly, when I move the custom tool class definition to a different script, outside from where the reasoning engine deployment happens, this workaround does not work anymore. |
Sorry for the slow response, this has been addressed upstream in langchain-ai/langchain-google#235 -- you should not have to create a custom tool class definition:
Please feel free to reopen if it did not address the issue |
When I try to use the
ReasoningEngine
to deploy myLangchainAgent
, it fails due to being unable to pickle the Agent. This seems to stem from the tool I am using, as if I remove the tool from the Agent it works fine.Environment details
google-cloud-aiplatform
version: 1.48.0Steps to reproduce
google_discovery_engine_data_store
resource.Code example
Stack trace
The text was updated successfully, but these errors were encountered: