Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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.
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. there are `vectorstore` and `fornaxknowledge` can be used as retriever.
e.g.
retriever, err := fornaxknowledge.NewRetriever(ctx, &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