rag

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package rag is RAG implementations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

func WithChunker

func WithChunker(chunker embedder.Chunker) Option

func WithContextGenerator

func WithContextGenerator(fn func(string, []vectordb.Record) string) Option

func WithEmbedder

func WithEmbedder(e embedder.Embedder) Option

func WithName

func WithName(name string) Option

func WithSearchOptions

func WithSearchOptions(opts ...vectordb.SearchOption) Option

func WithVectorDB

func WithVectorDB(v vectordb.Engine) Option

type Options

type Options struct {
	// contains filtered or unexported fields
}

type RAG

type RAG[O schema.Schema] struct {
	Options
	// contains filtered or unexported fields
}

func NewRAG

func NewRAG[O schema.Schema](agent agents.TypeableAgent[schema.String, O], opts ...Option) *RAG[O]

func (*RAG[O]) AddDocuments

func (r *RAG[O]) AddDocuments(ctx context.Context, collectionName string, docs ...document.Document) (*components.LLMUsage, error)

func (*RAG[O]) Name

func (r *RAG[O]) Name() string

func (*RAG[O]) Run

func (r *RAG[O]) Run(ctx context.Context, query *schema.String, output *O, llmResp *components.LLMResponse) error

func (*RAG[O]) RunAnonymous

func (r *RAG[O]) RunAnonymous(ctx context.Context, query any, llmResp *components.LLMResponse) (any, error)

func (*RAG[O]) Search

func (r *RAG[O]) Search(ctx context.Context, query string, opts ...vectordb.SearchOption) ([]vectordb.Record, *components.LLMUsage, error)

func (*RAG[O]) SetSearchOptions

func (r *RAG[O]) SetSearchOptions(opts ...vectordb.SearchOption)

func (*RAG[O]) Stream

func (r *RAG[O]) Stream(ctx context.Context, query *schema.String) (<-chan string, agents.MergeResponse, error)

func (*RAG[O]) StreamAnonymous

func (r *RAG[O]) StreamAnonymous(ctx context.Context, query any) (<-chan string, agents.MergeResponse, error)

Jump to

Keyboard shortcuts

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