retriever

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddReferencesToArgs

func AddReferencesToArgs(args map[string]any, refs []Reference) map[string]any

func GenerateKnowledgebaseRetriever added in v0.2.1

func GenerateKnowledgebaseRetriever(ctx context.Context, cli client.Client, knowledgebaseName, knowledgebaseNamespace string, retrieverConfig apiretriever.CommonRetrieverConfig, args map[string]any) (outArg map[string]any, finish func(), err error)

Types

type Fakeretriever added in v0.2.1

type Fakeretriever struct {
	Name string
	Docs []langchaingoschema.Document
}

func (*Fakeretriever) GetRelevantDocuments added in v0.2.1

func (f *Fakeretriever) GetRelevantDocuments(ctx context.Context, query string) ([]langchaingoschema.Document, error)

type KnowledgeBaseRetriever

type KnowledgeBaseRetriever struct {
	base.BaseNode
	Instance *apiretriever.KnowledgeBaseRetriever
	Finish   func()
}

func NewKnowledgeBaseRetriever

func NewKnowledgeBaseRetriever(baseNode base.BaseNode) *KnowledgeBaseRetriever

func (*KnowledgeBaseRetriever) Cleanup

func (l *KnowledgeBaseRetriever) Cleanup()

func (*KnowledgeBaseRetriever) Init

func (*KnowledgeBaseRetriever) Ready

func (l *KnowledgeBaseRetriever) Ready() (isReady bool, msg string)

func (*KnowledgeBaseRetriever) Run

func (l *KnowledgeBaseRetriever) Run(ctx context.Context, cli client.Client, args map[string]any) (map[string]any, error)

type MultiQueryRetriever added in v0.2.1

type MultiQueryRetriever struct {
	base.BaseNode
	Instance *apiretriever.MultiQueryRetriever
}

func NewMultiQueryRetriever added in v0.2.1

func NewMultiQueryRetriever(baseNode base.BaseNode) *MultiQueryRetriever

func (*MultiQueryRetriever) Init added in v0.2.1

func (l *MultiQueryRetriever) Init(ctx context.Context, cli client.Client, _ map[string]any) error

func (*MultiQueryRetriever) Ready added in v0.2.1

func (l *MultiQueryRetriever) Ready() (isReady bool, msg string)

func (*MultiQueryRetriever) Run added in v0.2.1

func (l *MultiQueryRetriever) Run(ctx context.Context, cli client.Client, args map[string]any) (map[string]any, error)

type Reference

type Reference struct {
	// Question row
	Question string `json:"question" example:"q: 旷工最小计算单位为多少天?"`
	// Answer row
	Answer string `json:"answer" example:"旷工最小计算单位为 0.5 天。"`
	// vector search score
	Score float32 `json:"score" example:"0.34"`
	// the qa file fullpath
	QAFilePath string `json:"qa_file_path" example:"dataset/dataset-playground/v1/qa.csv"`
	// line number in the qa file
	QALineNumber int `json:"qa_line_number" example:"7"`
	// source file name, only file name, not full path
	FileName string `json:"file_name" example:"员工考勤管理制度-2023.pdf"`
	// page number in the source file
	PageNumber int `json:"page_number" example:"1"`
	// related content in the source file or in webpage
	Content string `` /* 144-byte string literal not displayed */
	// Title of the webpage
	Title string `json:"title,omitempty" example:"开始使用 Microsoft 帐户 – Microsoft"`
	// URL of the webpage
	URL string `json:"url,omitempty" example:"https://www.microsoft.com/zh-cn/welcome"`
	// RerankScore
	RerankScore float32        `json:"rerank_score,omitempty" example:"0.58124"`
	Metadata    map[string]any `json:"-"`
}

func ConvertDocuments added in v0.2.1

func ConvertDocuments(ctx context.Context, docs []langchaingoschema.Document, retrieverName string) (newDocs []langchaingoschema.Document, refs []Reference)

func (Reference) SimpleString

func (reference Reference) SimpleString() string

func (Reference) String

func (reference Reference) String() string

type RerankRequestBody added in v0.2.1

type RerankRequestBody struct {
	Query    string   `json:"question"`
	Passages []string `json:"answers"`
}

type RerankRetriever added in v0.2.1

type RerankRetriever struct {
	base.BaseNode
	Instance *apiretriever.RerankRetriever
}

func NewRerankRetriever added in v0.2.1

func NewRerankRetriever(baseNode base.BaseNode) *RerankRetriever

func (*RerankRetriever) Init added in v0.2.1

func (l *RerankRetriever) Init(ctx context.Context, cli client.Client, _ map[string]any) error

func (*RerankRetriever) Ready added in v0.2.1

func (l *RerankRetriever) Ready() (isReady bool, msg string)

func (*RerankRetriever) Run added in v0.2.1

func (l *RerankRetriever) Run(ctx context.Context, cli client.Client, args map[string]any) (map[string]any, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL