Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRetriever ¶
NewRetriever creates a multi-query retriever. multi-query retriever is useful when you want to retrieve documents from multiple retrievers with different queries. eg.
multiRetriever := multiquery.NewRetriever(ctx, &multiquery.Config{})
docs, err := multiRetriever.Retrieve(ctx, "how to build agent with eino")
if err != nil {
...
}
println(docs)
for more info: https://bytedance.larkoffice.com/wiki/G8T2w5bYuigJ4LkMi1ycw6VznAh#A4PqdcJmpoveWcxv8NPc70TanLb
Types ¶
type Config ¶
type Config struct {
// Rewrite
// 1. set the following fields to use llm to generate multi queries
// a. chat model, required
RewriteLLM model.ChatModel
// b. prompt llm to generate multi queries, we provide default template so you can leave this field blank
RewriteTemplate prompt.ChatTemplate
// c. origin query variable of your custom template, it can be empty if you use default template
QueryVar string
// d. parser llm output to queries, split content using "\n" by default
LLMOutputParser func(context.Context, *schema.Message) ([]string, error)
// 2. set RewriteHandler to provide custom query generation logic, possibly without a ChatModel. If this field is set, it takes precedence over other configurations above
RewriteHandler func(ctx context.Context, query string) ([]string, error)
// limit max queries num that Rewrite generates, and excess queries will be truncated, 5 by default
MaxQueriesNum int
// Origin Retriever
OrigRetriever retriever.Retriever
// fusion docs recalled from multi retrievers, remove dup based on document id by default
FusionFunc func(ctx context.Context, docs [][]*schema.Document) ([]*schema.Document, error)
}
Config is the config for multi-query retriever.
Click to show internal directories.
Click to hide internal directories.