Documentation
¶
Index ¶
- func GetImplSpecificOptions[T any](base *T, opts ...Option) *T
- type CallbackInput
- type CallbackOutput
- type Option
- func WithDSLInfo(dsl map[string]any) Option
- func WithEmbedding(emb embedding.Embedder) Option
- func WithIndex(index string) Option
- func WithScoreThreshold(threshold float64) Option
- func WithSubIndex(subIndex string) Option
- func WithTopK(topK int) Option
- func WrapImplSpecificOptFn[T any](optFn func(*T)) Option
- type Options
- type Retriever
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetImplSpecificOptions ¶ added in v0.3.6
GetImplSpecificOptions extract the implementation specific options from Option list, optionally providing a base options with default values. e.g.
myOption := &MyOption{
Field1: "default_value",
}
myOption := model.GetImplSpecificOptions(myOption, opts...)
Types ¶
type CallbackInput ¶
type CallbackInput struct {
// Query is the query for the retriever.
Query string
// TopK is the top k for the retriever, which means the top number of documents to retrieve.
TopK int
// Filter is the filter for the retriever.
Filter string
// ScoreThreshold is the score threshold for the retriever, eg 0.5 means the score of the document must be greater than 0.5.
ScoreThreshold *float64
// Extra is the extra information for the retriever.
Extra map[string]any
}
CallbackInput is the input for the retriever callback.
func ConvCallbackInput ¶
func ConvCallbackInput(src callbacks.CallbackInput) *CallbackInput
ConvCallbackInput converts the callback input to the retriever callback input.
type CallbackOutput ¶
type CallbackOutput struct {
// Docs is the documents for the retriever.
Docs []*schema.Document
// Extra is the extra information for the retriever.
Extra map[string]any
}
CallbackOutput is the output for the retriever callback.
func ConvCallbackOutput ¶
func ConvCallbackOutput(src callbacks.CallbackOutput) *CallbackOutput
ConvCallbackOutput converts the callback output to the retriever callback output.
type Option ¶
type Option struct {
// contains filtered or unexported fields
}
Option is the call option for Retriever component.
func WithDSLInfo ¶
WithDSLInfo wraps the dsl info option.
func WithEmbedding ¶
WithEmbedding wraps the embedder option.
func WithScoreThreshold ¶
WithScoreThreshold wraps the score threshold option.
func WithSubIndex ¶
WithSubIndex wraps the sub index option.
func WrapImplSpecificOptFn ¶ added in v0.3.6
WrapImplSpecificOptFn is the option to wrap the implementation specific option function.
type Options ¶
type Options struct {
// Index is the index for the retriever, index in different retriever may be different.
Index *string
// SubIndex is the sub index for the retriever, sub index in different retriever may be different.
SubIndex *string
// TopK is the top k for the retriever, which means the top number of documents to retrieve.
TopK *int
// ScoreThreshold is the score threshold for the retriever, eg 0.5 means the score of the document must be greater than 0.5.
ScoreThreshold *float64
// Embedding is the embedder for the retriever, which is used to embed the query for retrieval .
Embedding embedding.Embedder
// DSLInfo is the dsl info for the retriever, which is used to retrieve the documents from the retriever.
// viking only
DSLInfo map[string]interface{}
}
Options is the options for the retriever.
func GetCommonOptions ¶
GetCommonOptions extract retriever Options from Option list, optionally providing a base Options with default values.
type Retriever ¶
type Retriever interface {
Retrieve(ctx context.Context, query string, opts ...Option) ([]*schema.Document, error)
}
Retriever is the interface for retriever. It is used to retrieve documents from a source.
e.g.
retriever, err := redis.NewRetriever(ctx, &redis.RetrieverConfig{})
if err != nil {...}
docs, err := retriever.Retrieve(ctx, "query") // <= using directly
docs, err := retriever.Retrieve(ctx, "query", retriever.WithTopK(3)) // <= using options
graph := compose.NewGraph[inputType, outputType](compose.RunTypeDAG)
graph.AddRetrieverNode("retriever_node_key", retriever) // <= using in graph