Documentation
¶
Index ¶
- func CreateCollectionSnapshot(ctx context.Context, httpAddr, collection string) (string, error)
- func QdrantServerVersion(ctx context.Context, httpAddr string) (string, error)
- func WordCount(s string) int
- type Chunk
- type ChunkConfig
- type CollectionStats
- type Document
- type EmbeddingClient
- type IngestResult
- type Point
- type QdrantClient
- func (q *QdrantClient) Close() error
- func (q *QdrantClient) CollectionStats(ctx context.Context, collection string) (*CollectionStats, error)
- func (q *QdrantClient) EnsureCollection(ctx context.Context, name string, dimensions uint64) error
- func (q *QdrantClient) Search(ctx context.Context, collection string, vector []float32, topK int) ([]SearchResult, error)
- func (q *QdrantClient) Upsert(ctx context.Context, collection string, points []Point) error
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateCollectionSnapshot ¶
CreateCollectionSnapshot triggers a full snapshot of the given collection via the Qdrant HTTP API and returns the snapshot name. The addr should be "host:httpPort" (typically port 6333).
func QdrantServerVersion ¶
QdrantServerVersion queries the Qdrant HTTP root endpoint and returns the reported server version string (e.g. "1.17.1"). The addr should be "host:httpPort" (typically port 6333).
Types ¶
type ChunkConfig ¶
type ChunkConfig struct {
ChunkSize int // approximate max tokens per chunk (default 512)
ChunkOverlap int // tokens of overlap between consecutive chunks (default 64)
}
ChunkConfig controls how documents are split into chunks.
func DefaultChunkConfig ¶
func DefaultChunkConfig() ChunkConfig
DefaultChunkConfig returns sensible defaults.
type CollectionStats ¶
CollectionStats returns the number of points and unique documents in the collection, along with the on-disk storage size in bytes.
type EmbeddingClient ¶
type EmbeddingClient struct {
// contains filtered or unexported fields
}
EmbeddingClient calls an OpenAI-compatible /v1/embeddings endpoint.
func NewEmbeddingClient ¶
func NewEmbeddingClient(endpoint, apiKeyFile, model, docPrompt, queryPrompt string) *EmbeddingClient
NewEmbeddingClient creates an embedding client that reads the API key from a file. docPrompt is prepended to document texts; queryPrompt is prepended to query texts. Leave either empty to send raw text (suitable for OpenAI-hosted models).
func NewEmbeddingClientWithKey ¶
func NewEmbeddingClientWithKey(endpoint, apiKey, model, docPrompt, queryPrompt string) *EmbeddingClient
NewEmbeddingClientWithKey creates an embedding client with an explicit API key. docPrompt is prepended to document texts; queryPrompt is prepended to query texts. Leave either empty to send raw text (suitable for OpenAI-hosted models).
func (*EmbeddingClient) Embed ¶
func (e *EmbeddingClient) Embed(ctx context.Context, texts []string, forQuery bool) ([][]float32, error)
Embed converts texts into embedding vectors. Handles batching automatically. When forQuery is true, queryPrompt is prepended to each text (used for _rag_search); when false, docPrompt is prepended (used for _rag_ingest). When the relevant prompt is empty, texts are sent as-is — this preserves backward compatibility for models that do not need a task prefix (e.g. OpenAI's text-embedding-3-*).
Texts are grouped into batches bounded by maxBatchCharacterLimit and maxBatchChunks, and batches are dispatched concurrently (up to the configured concurrency) so CPU-bound local backends stay saturated. The returned vectors always align 1:1 with the input texts, in input order.
func (*EmbeddingClient) ProbeDimension ¶
func (e *EmbeddingClient) ProbeDimension(ctx context.Context) (int, error)
ProbeDimension embeds a single placeholder string and returns the output vector length. Call once on first use to discover the model's actual embedding dimension rather than requiring users to specify it manually. Uses docPrompt for consistency; the dimension is prompt-independent.
type IngestResult ¶
IngestResult contains counts from an ingestion operation.
func IngestDocuments ¶
func IngestDocuments( ctx context.Context, docs []Document, qdrantAddr string, collection string, dimensions uint64, embedder *EmbeddingClient, chunkCfg ChunkConfig, ) (*IngestResult, error)
IngestDocuments chunks, embeds, and upserts documents into Qdrant. This is the shared pipeline used by both the API handler and the controller. Documents are processed one-by-one to avoid timeouts with local embedding models.
type QdrantClient ¶
type QdrantClient struct {
// contains filtered or unexported fields
}
QdrantClient wraps the official Qdrant Go gRPC client for vector operations.
func NewQdrantClient ¶
func NewQdrantClient(addr string) (*QdrantClient, error)
NewQdrantClient connects to a Qdrant instance at the given address. The address should be in "host:port" format (gRPC port, typically 6334).
func (*QdrantClient) Close ¶
func (q *QdrantClient) Close() error
Close releases the underlying gRPC connection.
func (*QdrantClient) CollectionStats ¶
func (q *QdrantClient) CollectionStats(ctx context.Context, collection string) (*CollectionStats, error)
CollectionStats returns point count, unique document count, and storage size.
func (*QdrantClient) EnsureCollection ¶
EnsureCollection creates a collection if it doesn't already exist.
func (*QdrantClient) Search ¶
func (q *QdrantClient) Search(ctx context.Context, collection string, vector []float32, topK int) ([]SearchResult, error)
Search performs a nearest neighbor search and returns the top-K results.
type SearchResult ¶
SearchResult represents a single search hit with its similarity score.