Skip to content

Latest commit

 

History

History
26 lines (20 loc) · 1.54 KB

File metadata and controls

26 lines (20 loc) · 1.54 KB

Implementing Your Own Retriever

If you wish to plug your own retriever and into search agents already implemented in this repo, you may simply create a new searcher class that inherits from BaseSearcher in searcher/searchers/base.py.

For a skeleton searcher class, you may refer to searcher/searchers/custom_searcher.py. This is a placeholder class you can use as a starting point. You have to implement the following methods:

  • __init__: Initialize the searcher from args passed from the command line.
  • parse_args: Parse the arguments your searcher needs from the command line (e.g., parser.add_argument("--my-arg", type=str, default="default_value")).
  • search: Perform a search from a query, and return a list of documents.
  • get_document: Get a complete document by its docid.
  • search_type: Get the type of the searcher.
  • search_description: The prompt to be passed to the LLM describing the search tool.
  • get_document_description: The prompt to be passed to the LLM describing the get_document tool.

Then, for any command described in the docs, you may simply replace the --searcher-type argument with custom, and pass in the arguments your searcher needs.

For example, instead of running:

python search_agent/oss_client.py --model openai/gpt-oss-120b --searcher-type bm25 --index-path indexes/bm25/

you may run:

python search_agent/oss_client.py --model openai/gpt-oss-120b --searcher-type custom --my-arg "my-value"

where my-value is the value you passed to the --my-arg argument in your searcher class.