chenkun
chenkun

Reputation: 75

How to query the vector database in LangChain AgentExecutor, invoice before summarizing the 'Final Answer' after all tools have been called?

How to query the vector database in LangChain AgentExecutor, invoice before summarizing the 'Final Answer' after all tools have been called?

LangChain AgentExecutor code:

llm = ChatOpenAI()
tools = [tool_1, tool_2, ...]

prompt = hub.pull("hwchase17/openai-tools-agent")
my_agent = create_openai_tools_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=my_agent, tools=tools, verbose=True)
question = "user's question"
ans = agent_executor.invoke({"input": question})

Querying Vector Database:

docs = vector_store.similarity_search(question)
new_question = f'''
Please answer my question based on my information

My information: ...

My question: ...
'''

Upvotes: 0

Views: 64

Answers (1)

Arindam
Arindam

Reputation: 81

Vector database call -> Put it inside a function. Use Pydantic for schema. Then create a Tool() object using that function. Pass that tool to agent while defining executor.

During execution, agent will pick the tool based on your tool description.

Upvotes: 0

Related Questions