Skip to content

Ch.07 - Make dynamic tool selector section more clear and meaningful #10

@JamesCHub

Description

@JamesCHub

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:

  1. "When was Calvin Coolidge born?" (only search will be selected)
  2. "2+2=" (only calculator will be selected)
  3. "How old was the 30th president of the US when he died?" (search will be selected)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions