mirror of
https://github.com/langchain-ai/learning-langchain.git
synced 2026-07-16 09:14:24 -04:00
Ch.07 - Make dynamic tool selector section more clear and meaningful #5
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JamesCHub on GitHub (Jul 8, 2025).
The book is extremely useful and well-written.
In the section in Chapter 6 entitled "Dealing with Many Tools", we don't add any new tools, and don't limit the retriever, so the point of the section is a bit lost.
But if we simply modify the retriever definition to:
tools_retriever = InMemoryVectorStore.from_documents([Document(tool.description, metadata={"name":tool.name}) for tool in ourTools], embeddingsModel).as_retriever(search_kwargs={"k": 1, "fetch_k": 2})We'll force the agent to choose the best single tool to answer the prompt.
We can then cycle through three prompts: