public class LanguageModelQueryRouter extends Object implements QueryRouter
QueryRouter
that utilizes a ChatLanguageModel
to make a routing decision.
ContentRetriever
provided in the constructor is accompanied by a description which is
provided to the LLM to aid in making a decision on where a Query
should be routed.
DEFAULT_PROMPT_TEMPLATE
and implementation for more details.
promptTemplate
: The prompt template used to ask the LLM for routing decisions.DefaultQueryRouter
Modifier and Type | Field and Description |
---|---|
static PromptTemplate |
DEFAULT_PROMPT_TEMPLATE |
Constructor and Description |
---|
LanguageModelQueryRouter(ChatLanguageModel chatLanguageModel,
Map<ContentRetriever,String> retrieverToDescription) |
LanguageModelQueryRouter(ChatLanguageModel chatLanguageModel,
Map<ContentRetriever,String> retrieverToDescription,
PromptTemplate promptTemplate) |
Modifier and Type | Method and Description |
---|---|
protected Prompt |
createPrompt(Query query) |
protected Collection<ContentRetriever> |
parse(String choices) |
Collection<ContentRetriever> |
route(Query query)
Routes the given
Query to one or multiple ContentRetriever s. |
public static final PromptTemplate DEFAULT_PROMPT_TEMPLATE
public LanguageModelQueryRouter(ChatLanguageModel chatLanguageModel, Map<ContentRetriever,String> retrieverToDescription)
public LanguageModelQueryRouter(ChatLanguageModel chatLanguageModel, Map<ContentRetriever,String> retrieverToDescription, PromptTemplate promptTemplate)
public Collection<ContentRetriever> route(Query query)
QueryRouter
Query
to one or multiple ContentRetriever
s.route
in interface QueryRouter
query
- The Query
to be routed.ContentRetriever
s to which the Query
should be routed.protected Collection<ContentRetriever> parse(String choices)
Copyright © 2024. All rights reserved.