56 lines
2.5 KiB
Go
56 lines
2.5 KiB
Go
package kb
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type Document struct {
|
|
ID, ExternalID, Title, Language, RegionCode, Category, SourceType, SourceURI, SourceHash, Status string
|
|
Content, Question, ShortAnswer, FullAnswer, Source string
|
|
Keywords []string
|
|
Metadata map[string]any
|
|
ValidFrom, ValidTo *time.Time
|
|
Priority int
|
|
}
|
|
|
|
type Chunk struct {
|
|
ID, DocumentID string
|
|
ChunkIndex int
|
|
Language, RegionCode, Title, Content, ContentHash string
|
|
TokenEstimate, CharCount int
|
|
Embedding []float32
|
|
EmbeddingModel, EmbeddingProvider string
|
|
Metadata map[string]any
|
|
}
|
|
|
|
type SearchRequest struct {
|
|
Query, Language, RegionCode, CallID string
|
|
Limit int
|
|
MinScore float64
|
|
IncludeGlobal bool
|
|
CrossLanguageFallback bool
|
|
}
|
|
type Citation struct{ DocumentTitle, SourceURI, ChunkID, RegionCode, Language, Source string }
|
|
type SearchResult struct {
|
|
DocumentID, ChunkID, Title, Content, Language, SourceLanguage, RegionCode, Category, SourceURI string
|
|
Score, VectorScore, KeywordScore float64
|
|
CrossLanguageFallback bool
|
|
Metadata map[string]any
|
|
Citation Citation
|
|
}
|
|
type IngestResult struct {
|
|
DocsSeen, DocsIngested, ChunksCreated, Skipped int
|
|
Errors []string
|
|
}
|
|
type Health struct {
|
|
DBReachable, VectorExtension, MigrationsApplied bool
|
|
Documents, Chunks int
|
|
}
|
|
|
|
type Repository interface {
|
|
Health(ctx context.Context) (Health, error)
|
|
UpsertDocument(ctx context.Context, doc Document, chunks []Chunk) error
|
|
Search(ctx context.Context, req SearchRequest, queryEmbedding []float32) ([]SearchResult, error)
|
|
}
|