Documentation
¶
Index ¶
- Constants
- type GeneralRetrieverConfig
- type MilvusStore
- func (m *MilvusStore) CollectionExists(ctx context.Context, collectionName string) (bool, error)
- func (m *MilvusStore) ConvertSearchResultsToDocuments(ctx context.Context, columns []column.Column, scores []float32) ([]*schema.Document, error)
- func (m *MilvusStore) CreateCollection(ctx context.Context, collectionName string, dimension int) error
- func (m *MilvusStore) CreateDatabaseIfNotExists(ctx context.Context) error
- func (m *MilvusStore) CreateNL2SQLCollection(ctx context.Context, collectionName string, dimension int) error
- func (m *MilvusStore) DeleteByChunkID(ctx context.Context, collectionName string, chunkID string) error
- func (m *MilvusStore) DeleteByDocumentID(ctx context.Context, collectionName string, documentID string) error
- func (m *MilvusStore) DeleteCollection(ctx context.Context, collectionName string) error
- func (m *MilvusStore) DeleteNL2SQLByDatasourceID(ctx context.Context, collectionName string, datasourceID string) error
- func (m *MilvusStore) GetClient() interface{}
- func (m *MilvusStore) GetMilvusClient() *milvusclient.Client
- func (m *MilvusStore) InsertNL2SQLVectors(ctx context.Context, collectionName string, entities []*NL2SQLEntity, ...) ([]string, error)
- func (m *MilvusStore) InsertVectors(ctx context.Context, collectionName string, chunks []*schema.Document, ...) ([]string, error)
- func (m *MilvusStore) NewMilvusRetriever(ctx context.Context, collectionName string) (Retriever, error)
- func (m *MilvusStore) NewRetriever(ctx context.Context, collectionName string) (Retriever, error)
- func (m *MilvusStore) VectorSearchOnly(ctx context.Context, conf GeneralRetrieverConfig, query string, ...) ([]*schema.Document, error)
- func (m *MilvusStore) VectorSearchOnlyNL2SQL(ctx context.Context, query string, collectionName string, datasourceID string, ...) ([]*schema.Document, error)
- type NL2SQLEntity
- type Option
- type Options
- type PostgresStore
- func (p *PostgresStore) CollectionExists(ctx context.Context, collectionName string) (bool, error)
- func (p *PostgresStore) CreateCollection(ctx context.Context, collectionName string, dimension int) error
- func (p *PostgresStore) CreateDatabaseIfNotExists(ctx context.Context) error
- func (p *PostgresStore) CreateNL2SQLCollection(ctx context.Context, collectionName string, dimension int) error
- func (p *PostgresStore) DeleteByChunkID(ctx context.Context, collectionName string, chunkID string) error
- func (p *PostgresStore) DeleteByDocumentID(ctx context.Context, collectionName string, documentID string) error
- func (p *PostgresStore) DeleteCollection(ctx context.Context, collectionName string) error
- func (p *PostgresStore) DeleteNL2SQLByDatasourceID(ctx context.Context, collectionName string, datasourceID string) error
- func (p *PostgresStore) GetClient() interface{}
- func (p *PostgresStore) InsertNL2SQLVectors(ctx context.Context, collectionName string, entities []*NL2SQLEntity, ...) ([]string, error)
- func (p *PostgresStore) InsertVectors(ctx context.Context, collectionName string, chunks []*schema.Document, ...) ([]string, error)
- func (p *PostgresStore) NewNL2SQLRetriever(ctx context.Context, collectionName string, datasourceID string) (Retriever, error)
- func (p *PostgresStore) NewRetriever(ctx context.Context, collectionName string) (Retriever, error)
- func (p *PostgresStore) VectorSearchOnly(ctx context.Context, conf GeneralRetrieverConfig, query string, ...) ([]*schema.Document, error)
- func (p *PostgresStore) VectorSearchOnlyNL2SQL(ctx context.Context, query string, collectionName string, datasourceID string, ...) ([]*schema.Document, error)
- type Retriever
- type VectorStore
- func GetVectorStore() (VectorStore, error)
- func InitializeMilvusStore(ctx context.Context) (VectorStore, error)
- func InitializePostgresStore(ctx context.Context) (VectorStore, error)
- func NewMilvusStore(config *VectorStoreConfig) (VectorStore, error)
- func NewPostgresStore(config *VectorStoreConfig) (VectorStore, error)
- func NewVectorStore(config *VectorStoreConfig) (VectorStore, error)
- type VectorStoreConfig
- type VectorStoreType
Constants ¶
const ( FieldContent = "text" FieldContentVector = "vector" FieldMetadata = "metadata" KnowledgeId = "knowledge_id" DocumentId = "document_id" )
向量存储字段名常量
const ( NL2SQLFieldEntityType = "entity_type" NL2SQLFieldEntityId = "entity_id" NL2SQLFieldDatasourceId = "datasource_id" NL2SQLFieldText = "text" NL2SQLFieldVector = "vector" NL2SQLFieldMetadata = "metadata" )
NL2SQL向量存储字段名常量
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GeneralRetrieverConfig ¶
type GeneralRetrieverConfig interface {
GetTopK() int
GetScore() float64
GetEnableRewrite() bool
GetRewriteAttempts() int
GetRetrieveMode() string
}
GeneralRetrieverConfig 通用检索配置接口
type MilvusStore ¶
type MilvusStore struct {
// contains filtered or unexported fields
}
MilvusStore Milvus向量数据库实现
func (*MilvusStore) CollectionExists ¶
CollectionExists 检查集合是否存在
func (*MilvusStore) ConvertSearchResultsToDocuments ¶
func (m *MilvusStore) ConvertSearchResultsToDocuments(ctx context.Context, columns []column.Column, scores []float32) ([]*schema.Document, error)
ConvertSearchResultsToDocuments converts Milvus search results to schema.Document
func (*MilvusStore) CreateCollection ¶
func (m *MilvusStore) CreateCollection(ctx context.Context, collectionName string, dimension int) error
CreateCollection 创建集合
func (*MilvusStore) CreateDatabaseIfNotExists ¶
func (m *MilvusStore) CreateDatabaseIfNotExists(ctx context.Context) error
CreateDatabaseIfNotExists 创建数据库
func (*MilvusStore) CreateNL2SQLCollection ¶
func (m *MilvusStore) CreateNL2SQLCollection(ctx context.Context, collectionName string, dimension int) error
CreateNL2SQLCollection 创建NL2SQL专用的集合
func (*MilvusStore) DeleteByChunkID ¶
func (m *MilvusStore) DeleteByChunkID(ctx context.Context, collectionName string, chunkID string) error
DeleteByChunkID 根据chunkID删除单个chunk
func (*MilvusStore) DeleteByDocumentID ¶
func (m *MilvusStore) DeleteByDocumentID(ctx context.Context, collectionName string, documentID string) error
DeleteByDocumentID 根据文档ID删除所有相关chunks
func (*MilvusStore) DeleteCollection ¶
func (m *MilvusStore) DeleteCollection(ctx context.Context, collectionName string) error
DeleteCollection 删除集合
func (*MilvusStore) DeleteNL2SQLByDatasourceID ¶
func (m *MilvusStore) DeleteNL2SQLByDatasourceID(ctx context.Context, collectionName string, datasourceID string) error
DeleteNL2SQLByDatasourceID 根据数据源ID删除所有相关实体
func (*MilvusStore) GetClient ¶
func (m *MilvusStore) GetClient() interface{}
GetClient returns the underlying Milvus client as interface{}
func (*MilvusStore) GetMilvusClient ¶
func (m *MilvusStore) GetMilvusClient() *milvusclient.Client
GetMilvusClient returns the underlying Milvus client with specific type
func (*MilvusStore) InsertNL2SQLVectors ¶
func (m *MilvusStore) InsertNL2SQLVectors(ctx context.Context, collectionName string, entities []*NL2SQLEntity, vectors [][]float32) ([]string, error)
InsertNL2SQLVectors 插入NL2SQL向量数据
func (*MilvusStore) InsertVectors ¶
func (m *MilvusStore) InsertVectors(ctx context.Context, collectionName string, chunks []*schema.Document, vectors [][]float32) ([]string, error)
InsertVectors 插入向量数据
func (*MilvusStore) NewMilvusRetriever ¶
func (m *MilvusStore) NewMilvusRetriever(ctx context.Context, collectionName string) (Retriever, error)
NewMilvusRetriever 创建Milvus检索器实例
func (*MilvusStore) NewRetriever ¶
NewRetriever 创建检索器实例
func (*MilvusStore) VectorSearchOnly ¶
func (m *MilvusStore) VectorSearchOnly(ctx context.Context, conf GeneralRetrieverConfig, query string, knowledgeId string, topK int, score float64) ([]*schema.Document, error)
VectorSearchOnly 仅使用向量检索的通用方法
type NL2SQLEntity ¶
type NL2SQLEntity struct {
ID string `json:"id"`
EntityType string `json:"entity_type"` // table, column, metric, relation
EntityID string `json:"entity_id"` // UUID of the entity
DatasourceID string `json:"datasource_id"` // Datasource ID
Text string `json:"text"` // Text for embedding
MetaData map[string]interface{} `json:"metadata"` // Additional metadata
}
NL2SQLEntity represents a NL2SQL entity for vector storage
type Option ¶
type Option func(*Options)
Option represents a functional option for retriever configuration
func WithFilter ¶
WithFilter sets the filter expression for Milvus
func WithPartition ¶
WithPartition sets the partition for Milvus search
func WithScoreThreshold ¶
WithScoreThreshold sets the minimum score threshold
type Options ¶
Options contains configuration options for retrieval
func GetCommonOptions ¶
GetCommonOptions applies options and returns the resulting configuration
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore PostgreSQL向量数据库实现
func (*PostgresStore) CollectionExists ¶
CollectionExists 检查集合
func (*PostgresStore) CreateCollection ¶
func (p *PostgresStore) CreateCollection(ctx context.Context, collectionName string, dimension int) error
CreateCollection 创建集合
func (*PostgresStore) CreateDatabaseIfNotExists ¶
func (p *PostgresStore) CreateDatabaseIfNotExists(ctx context.Context) error
CreateDatabaseIfNotExists 创建数据库
func (*PostgresStore) CreateNL2SQLCollection ¶
func (p *PostgresStore) CreateNL2SQLCollection(ctx context.Context, collectionName string, dimension int) error
CreateNL2SQLCollection 创建NL2SQL专用的集合
func (*PostgresStore) DeleteByChunkID ¶
func (p *PostgresStore) DeleteByChunkID(ctx context.Context, collectionName string, chunkID string) error
DeleteByChunkID 根据chunkID删除单个chunk
func (*PostgresStore) DeleteByDocumentID ¶
func (p *PostgresStore) DeleteByDocumentID(ctx context.Context, collectionName string, documentID string) error
DeleteByDocumentID 根据文档ID删除所有相关chunks
func (*PostgresStore) DeleteCollection ¶
func (p *PostgresStore) DeleteCollection(ctx context.Context, collectionName string) error
DeleteCollection 删除集合
func (*PostgresStore) DeleteNL2SQLByDatasourceID ¶
func (p *PostgresStore) DeleteNL2SQLByDatasourceID(ctx context.Context, collectionName string, datasourceID string) error
DeleteNL2SQLByDatasourceID 根据数据源ID删除所有相关实体
func (*PostgresStore) GetClient ¶
func (p *PostgresStore) GetClient() interface{}
GetClient 返回底层PostgreSQL连接池
func (*PostgresStore) InsertNL2SQLVectors ¶
func (p *PostgresStore) InsertNL2SQLVectors(ctx context.Context, collectionName string, entities []*NL2SQLEntity, vectors [][]float32) ([]string, error)
InsertNL2SQLVectors 插入NL2SQL向量数据
func (*PostgresStore) InsertVectors ¶
func (p *PostgresStore) InsertVectors(ctx context.Context, collectionName string, chunks []*schema.Document, vectors [][]float32) ([]string, error)
InsertVectors 插入向量数据
func (*PostgresStore) NewNL2SQLRetriever ¶
func (p *PostgresStore) NewNL2SQLRetriever(ctx context.Context, collectionName string, datasourceID string) (Retriever, error)
NewNL2SQLRetriever 创建NL2SQL专用的PostgreSQL检索器实例
func (*PostgresStore) NewRetriever ¶
NewRetriever 创建PostgreSQL检索器实例
func (*PostgresStore) VectorSearchOnly ¶
func (p *PostgresStore) VectorSearchOnly(ctx context.Context, conf GeneralRetrieverConfig, query string, knowledgeId string, topK int, score float64) ([]*schema.Document, error)
VectorSearchOnly 仅使用向量检索的通用方法
type Retriever ¶
type Retriever interface {
// Retrieve performs vector search and returns matching documents
Retrieve(ctx context.Context, query string, opts ...Option) ([]*schema.Document, error)
// GetType returns the type of retriever
GetType() string
// IsCallbacksEnabled returns whether callbacks are enabled
IsCallbacksEnabled() bool
}
Retriever interface for vector search and retrieval operations
type VectorStore ¶
type VectorStore interface {
// CreateCollection 创建集合
CreateCollection(ctx context.Context, collectionName string, dimension int) error
// CollectionExists 检查集合是否存在
CollectionExists(ctx context.Context, collectionName string) (bool, error)
// DeleteCollection 删除集合
DeleteCollection(ctx context.Context, collectionName string) error
// InsertVectors 插入向量数据
InsertVectors(ctx context.Context, collectionName string, chunks []*schema.Document, vectors [][]float32) ([]string, error)
// DeleteByDocumentID 根据文档ID删除所有相关chunks
DeleteByDocumentID(ctx context.Context, collectionName string, documentID string) error
// DeleteByChunkID 根据chunkID删除单个chunk
DeleteByChunkID(ctx context.Context, collectionName string, chunkID string) error
// CreateDatabaseIfNotExists 创建数据库
CreateDatabaseIfNotExists(ctx context.Context) error
// GetClient 获取底层客户端实例
GetClient() interface{}
// NewRetriever 创建检索器实例
NewRetriever(ctx context.Context, collectionName string) (Retriever, error)
// VectorSearchOnly 仅使用向量检索的通用方法
VectorSearchOnly(ctx context.Context, conf GeneralRetrieverConfig, query string, knowledgeId string, topK int, score float64) ([]*schema.Document, error)
// VectorSearchOnlyNL2SQL NL2SQL专用的向量检索方法
VectorSearchOnlyNL2SQL(ctx context.Context, query string, collectionName string, datasourceID string, topK int, score float64) ([]*schema.Document, error)
// CreateNL2SQLCollection 创建NL2SQL专用的集合
CreateNL2SQLCollection(ctx context.Context, collectionName string, dimension int) error
// InsertNL2SQLVectors 插入NL2SQL向量数据
InsertNL2SQLVectors(ctx context.Context, collectionName string, entities []*NL2SQLEntity, vectors [][]float32) ([]string, error)
// DeleteNL2SQLByDatasourceID 根据数据源ID删除所有相关实体
DeleteNL2SQLByDatasourceID(ctx context.Context, collectionName string, datasourceID string) error
}
VectorStore 向量数据库接口
func GetVectorStore ¶
func GetVectorStore() (VectorStore, error)
GetVectorStore returns the singleton vector database client
func InitializeMilvusStore ¶
func InitializeMilvusStore(ctx context.Context) (VectorStore, error)
func InitializePostgresStore ¶
func InitializePostgresStore(ctx context.Context) (VectorStore, error)
InitializePostgresStore 初始化PostgreSQL向量存储
func NewMilvusStore ¶
func NewMilvusStore(config *VectorStoreConfig) (VectorStore, error)
NewMilvusStore 创建Milvus向量存储实例
func NewPostgresStore ¶
func NewPostgresStore(config *VectorStoreConfig) (VectorStore, error)
NewPostgresStore 创建PostgreSQL向量存储实例
func NewVectorStore ¶
func NewVectorStore(config *VectorStoreConfig) (VectorStore, error)
NewVectorStore 根据配置创建向量存储实例
type VectorStoreConfig ¶
type VectorStoreConfig struct {
Type VectorStoreType // 向量数据库类型
Client interface{} // 客户端实例
Database string // 数据库名称
MetricType string // 距离度量类型(如 L2, COSINE, IP)
Extra map[string]string // 额外配置
}
VectorStoreConfig 向量数据库配置
type VectorStoreType ¶
type VectorStoreType string
VectorStoreType 向量数据库类型
const ( VectorStoreTypeMilvus VectorStoreType = "milvus" VectorStoreTypePostgreSQL VectorStoreType = "pgvector" )