knowledge

package
v0.0.0-...-9bc178f Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KnowledgeAliyun Aliyun Bailian Knowledge Base
	KnowledgeAliyun = "aliyun"
	// KnowledgeQdrant Qdrant Vector Database
	KnowledgeQdrant = "qdrant"
)

Variables

View Source
var ErrUnsupportedKnowledgeProvider = errors.New("unsupported knowledge provider")

Functions

This section is empty.

Types

type AliyunOptions

type AliyunOptions struct{}

type DeleteOptions

type DeleteOptions struct {
	Namespace string
}

type Embedder

type Embedder interface {
	Embed(ctx context.Context, inputs []string) ([][]float64, error)
}

type FactoryOptions

type FactoryOptions struct {
	Qdrant *QdrantOptions
	Aliyun *AliyunOptions
}

type GetOptions

type GetOptions struct {
	Namespace string
}

type KnowledgeHandler

type KnowledgeHandler interface {
	Provider() string

	Upsert(ctx context.Context, records []Record, options *UpsertOptions) error

	Query(ctx context.Context, text string, options *QueryOptions) ([]QueryResult, error)

	Get(ctx context.Context, ids []string, options *GetOptions) ([]Record, error)

	List(ctx context.Context, options *ListOptions) (*ListResult, error)

	Delete(ctx context.Context, ids []string, options *DeleteOptions) error
}

func New

func New(provider string, opts *FactoryOptions) (KnowledgeHandler, error)

type KnowledgeProvider

type KnowledgeProvider string

KnowledgeProvider common provider type

func (KnowledgeProvider) ToString

func (kp KnowledgeProvider) ToString() string

ToString toString for llm

type ListOptions

type ListOptions struct {
	Namespace string
	Limit     int
	Offset    string
	Filters   map[string]any
}

type ListResult

type ListResult struct {
	Records    []Record
	NextOffset string
}

type NvidiaEmbedClient

type NvidiaEmbedClient struct {
	BaseURL    string
	APIKey     string
	Model      string
	HTTPClient *http.Client
}

func (*NvidiaEmbedClient) Embed

func (c *NvidiaEmbedClient) Embed(ctx context.Context, inputs []string) ([][]float64, error)

type QdrantHandler

type QdrantHandler struct {
	BaseURL    string
	APIKey     string
	Collection string
	HTTPClient *http.Client
	Embedder   Embedder
}

func (*QdrantHandler) Delete

func (qh *QdrantHandler) Delete(ctx context.Context, ids []string, options *DeleteOptions) error

func (*QdrantHandler) Get

func (qh *QdrantHandler) Get(ctx context.Context, ids []string, options *GetOptions) ([]Record, error)

func (*QdrantHandler) List

func (qh *QdrantHandler) List(ctx context.Context, options *ListOptions) (*ListResult, error)

func (*QdrantHandler) Provider

func (qh *QdrantHandler) Provider() string

func (*QdrantHandler) Query

func (qh *QdrantHandler) Query(ctx context.Context, text string, options *QueryOptions) ([]QueryResult, error)

func (*QdrantHandler) Upsert

func (qh *QdrantHandler) Upsert(ctx context.Context, records []Record, options *UpsertOptions) error

type QdrantOptions

type QdrantOptions struct {
	BaseURL    string
	APIKey     string
	Collection string
	HTTPClient *http.Client
	Embedder   Embedder
}

type QueryOptions

type QueryOptions struct {
	Namespace string
	TopK      int
	Filters   map[string]any
}

type QueryResult

type QueryResult struct {
	Record Record
	Score  float64
}

type Record

type Record struct {
	ID        string
	Source    string
	Title     string
	Content   string
	Tags      []string
	Metadata  map[string]any
	CreatedAt time.Time
	UpdatedAt time.Time
}

type RerankResult

type RerankResult struct {
	Index int
	Score float64
}

type SiliconFlowRerankClient

type SiliconFlowRerankClient struct {
	BaseURL    string
	APIKey     string
	Model      string
	HTTPClient *http.Client
}

func (*SiliconFlowRerankClient) Rerank

func (c *SiliconFlowRerankClient) Rerank(ctx context.Context, query string, documents []string, topN int) ([]RerankResult, error)

type UpsertOptions

type UpsertOptions struct {
	Namespace string
	Overwrite bool
}

Jump to

Keyboard shortcuts

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