Documentation
¶
Overview ¶
Package milvus 提供基于 Milvus 的消息检索
Package milvus 提供基于 Milvus 的消息存储
Index ¶
- type DocStore
- func (d *DocStore) Close() error
- func (d *DocStore) DeleteCollection(ctx context.Context, collection string) error
- func (d *DocStore) GetDocuments(ctx context.Context, collection string) ([]*schema.Document, error)
- func (d *DocStore) RecallDocuments(ctx context.Context, collection string, query string, topK int) ([]*schema.Document, error)
- func (d *DocStore) SaveDocuments(ctx context.Context, collection string, docs []*schema.Document) error
- type DocStoreConfig
- type EmbeddingFunc
- type IndexItem
- type Retriever
- func (r *Retriever) AddToIndex(ctx context.Context, id string, content string, embedding []float32) error
- func (r *Retriever) Close() error
- func (r *Retriever) IndexReady() bool
- func (r *Retriever) RebuildIndex(ctx context.Context, items []IndexItem) error
- func (r *Retriever) Recall(ctx context.Context, sessionID string, query string, topK int) ([]*schema.Message, error)
- func (r *Retriever) RemoveFromIndex(ctx context.Context, sessionID string) error
- type RetrieverConfig
- type Store
- func (s *Store) ClearSession(ctx context.Context, sessionID string) error
- func (s *Store) Close() error
- func (s *Store) GetClient() client.Client
- func (s *Store) GetSession(ctx context.Context, sessionID string) ([]*schema.Message, error)
- func (s *Store) Save(ctx context.Context, sessionID string, msgs []*schema.Message) error
- type StoreConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DocStore ¶
type DocStore struct {
// contains filtered or unexported fields
}
DocStore 基于 Milvus 的通用文档存储
func NewDocStore ¶
func NewDocStore(config *DocStoreConfig, embedding EmbeddingFunc) (*DocStore, error)
func (*DocStore) DeleteCollection ¶
func (*DocStore) GetDocuments ¶
func (*DocStore) RecallDocuments ¶
type DocStoreConfig ¶
type DocStoreConfig struct {
Addr string
Collection string // Milvus collection 名
VectorDim int
Username string
Password string
DBName string
APIKey string
TLS bool
}
func DefaultDocStoreConfig ¶
func DefaultDocStoreConfig() *DocStoreConfig
type IndexItem ¶
type IndexItem struct {
ID string
SessionID string
Role string
Content string
Timestamp int64
Embedding []float32
}
IndexItem 用于重建索引的数据项
type Retriever ¶
type Retriever struct {
// contains filtered or unexported fields
}
Retriever 基于 Milvus 的检索器
func NewRetriever ¶
func NewRetriever(config *RetrieverConfig, embedding EmbeddingFunc) (*Retriever, error)
func NewRetrieverFromStore ¶
func NewRetrieverFromStore(store *Store, embedding EmbeddingFunc) (*Retriever, error)
NewRetrieverFromStore 从已有 Store 创建 Retriever(共享连接)
func (*Retriever) AddToIndex ¶
func (*Retriever) IndexReady ¶
func (*Retriever) RebuildIndex ¶
type RetrieverConfig ¶
type RetrieverConfig struct {
Addr string // 默认 "localhost:19530"
Collection string // 默认 "pulse_messages"
VectorDim int // 默认 768
// 认证配置(可选)
Username string
Password string
DBName string
APIKey string
TLS bool
}
RetrieverConfig Milvus 检索配置
func DefaultRetrieverConfig ¶
func DefaultRetrieverConfig() *RetrieverConfig
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store 基于 Milvus 的消息持久化存储
func NewStore ¶
func NewStore(config *StoreConfig) (*Store, error)
func NewStoreFromClient ¶
func NewStoreFromClient(c client.Client, config *StoreConfig) (*Store, error)
NewStoreFromClient 从已有 client 创建 Store(与 Retriever 共享连接)
func (*Store) ClearSession ¶
func (*Store) GetSession ¶
type StoreConfig ¶
type StoreConfig struct {
Addr string // 默认 "localhost:19530"
Collection string // 默认 "pulse_messages"
VectorDim int // 默认 768
// 认证配置(可选)
Username string // Milvus 用户名
Password string // Milvus 密码
DBName string // 数据库名
APIKey string // API Key
TLS bool // 启用 TLS
}
StoreConfig Milvus 存储配置
func DefaultStoreConfig ¶
func DefaultStoreConfig() *StoreConfig
Click to show internal directories.
Click to hide internal directories.