Skip to content

How to extract metadata from create_retriever_tool? #1055

Answered by hwchase17
Louva1 asked this question in Q&A
Discussion options

You must be logged in to vote

The retriever tool is a pretty simple around a retriever that:

  1. Calls the retriever with the input
  2. Gets back documents
  3. formats those documents into a string

The retriever is turned into a tool here:

retriever_tool = create_retriever_tool(
    retriever,
    "retrieve_blog_posts",
    "Search and return information about Lilian Weng blog posts on LLM agents, prompt engineering, and adversarial attacks on LLMs.",
)

It is in step 3 where this formatting is happening. The simplest solution is probably to NOT use the off-the-shelf create_retriever_tool and instead write your own tool (add call the raw retriever inside there, get back raw documents with metadata, and do whatever you want there)

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@Louva1
Comment options

@a143416
Comment options

@a143416
Comment options

@gopidon
Comment options

Answer selected by Louva1
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants