Documentation
¶
Overview ¶
Package vector provides vector embedding and search capabilities. Implemented in Phase 04.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EmbedConfig ¶ added in v0.2.0
type EmbedConfig struct {
Provider string // "gemini" (default) | "ollama" | "openai"
GeminiKey string
OllamaURL string // default: http://localhost:11434
OllamaModel string // default: nomic-embed-text
// OpenAI-compatible API settings
OpenAIBaseURL string // e.g. "http://10.1.1.246:8001/v1"
OpenAIEmbedBaseURL string // separate base URL for embeddings (falls back to OpenAIBaseURL)
OpenAIAPIKey string
OpenAIModel string // e.g. "text-embedding-ada-002"
}
EmbedConfig selects and configures the embedding provider.
type Embedder ¶
type Embedder interface {
EmbedBatch(ctx context.Context, texts []string) ([][]float32, error)
EmbedOne(ctx context.Context, text string) ([]float32, error)
Close()
}
Embedder is the interface for embedding text into vectors.
func NewEmbedder ¶
func NewEmbedder(ctx context.Context, cfg EmbedConfig) (Embedder, error)
NewEmbedder returns the Embedder implementation for the configured provider.
type IndexResult ¶
IndexResult summarises an embedding run.
type PgVectorStore ¶
type PgVectorStore struct {
// contains filtered or unexported fields
}
PgVectorStore implements VectorStore using PostgreSQL with pgvector extension.
func NewPgVectorStore ¶
func NewPgVectorStore(pool *pgxpool.Pool) *PgVectorStore
NewPgVectorStore creates a PgVectorStore backed by the given connection pool.
func (*PgVectorStore) Close ¶
func (s *PgVectorStore) Close() error
Close is a no-op — the pool is managed externally.
func (*PgVectorStore) Search ¶
func (s *PgVectorStore) Search(ctx context.Context, vec []float32, limit int, filter map[string]string) ([]SearchResult, error)
Search performs cosine similarity search using pgvector's <=> operator.
func (*PgVectorStore) UpsertPoints ¶
func (s *PgVectorStore) UpsertPoints(ctx context.Context, points []CodePoint) error
UpsertPoints inserts or updates embeddings in the symbol_embeddings table.
type QdrantClient ¶
type QdrantClient struct {
// contains filtered or unexported fields
}
QdrantClient wraps the Qdrant client and implements the VectorStore interface.
func NewQdrantClient ¶
func NewQdrantClient(ctx context.Context, addr string) (*QdrantClient, error)
NewQdrantClient connects to Qdrant at the given URL (HTTP or bare host:port). gRPC default port is 6334.
func (*QdrantClient) Close ¶
func (c *QdrantClient) Close() error
Close releases the Qdrant connection.
func (*QdrantClient) Search ¶
func (c *QdrantClient) Search(ctx context.Context, vector []float32, limit int, filter map[string]string) ([]SearchResult, error)
Search performs a nearest-neighbor search and returns matching results.
func (*QdrantClient) UpsertPoints ¶
func (c *QdrantClient) UpsertPoints(ctx context.Context, points []CodePoint) error
UpsertPoints inserts or updates the given CodePoints in Qdrant.
type SearchResult ¶
type SearchResult struct {
SymbolID int64
Score float32
File string
Kind string
Name string
Line int
Service string
}
SearchResult from vector search.
type Searcher ¶
type Searcher struct {
// contains filtered or unexported fields
}
Searcher performs semantic search using vector embeddings.
func NewSearcher ¶
func NewSearcher(store VectorStore, embedder Embedder) *Searcher
NewSearcher creates a Searcher.
func (*Searcher) Search ¶
func (s *Searcher) Search(ctx context.Context, query string, limit int, serviceFilter string) (string, error)
Search embeds the query and returns formatted nearest-neighbour results. serviceFilter restricts results to a specific service/module; empty means all.
func (*Searcher) SearchStructured ¶
func (s *Searcher) SearchStructured(ctx context.Context, query string, limit int, serviceFilter string) ([]SearchResult, error)
SearchStructured embeds the query and returns structured nearest-neighbour results. This is used by hybrid search for RRF merging.
type VectorIndexer ¶
type VectorIndexer struct {
// contains filtered or unexported fields
}
VectorIndexer fetches symbols from Postgres, embeds them, and upserts into the configured vector store (pgvector or Qdrant).
func NewVectorIndexer ¶
func NewVectorIndexer(pool *pgxpool.Pool, store VectorStore, embedder Embedder) *VectorIndexer
NewVectorIndexer creates a VectorIndexer.
func (*VectorIndexer) IndexRepository ¶
func (vi *VectorIndexer) IndexRepository(ctx context.Context, force bool) (*IndexResult, error)
IndexRepository embeds all (or only new) function/method/interface symbols.
type VectorStore ¶
type VectorStore interface {
// UpsertPoints inserts or updates embeddings.
UpsertPoints(ctx context.Context, points []CodePoint) error
// Search performs nearest-neighbor search and returns matching results.
Search(ctx context.Context, vector []float32, limit int, filter map[string]string) ([]SearchResult, error)
// Close releases resources held by the store.
Close() error
}
VectorStore is the abstraction for vector storage backends. Implementations: PgVectorStore (default), QdrantClient (optional).