service

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCRAGEvaluator

func NewCRAGEvaluator(llm core.Client, opts ...CRAGEvaluatorOption) *cragEvaluator

NewCRAGEvaluator creates a new CRAG evaluator.

Required: llm. Optional (via options): WithCRAGPromptTemplate, WithCRAGLogger, WithCRAGCollector.

func NewEntityExtractor

func NewEntityExtractor(llm core.Client, opts ...EntityExtractorOption) *entityExtractor

NewEntityExtractor creates a new entity extractor.

Required: llm. Optional (via options): WithEntityExtractionPromptTemplate, WithEntityExtractorLogger, WithEntityExtractorCollector.

func NewGenerator

func NewGenerator(llm core.Client, opts ...GeneratorOption) *generator

NewGenerator creates a new generator.

Required: llm. Optional (via options): WithPromptTemplate, WithGeneratorLogger, WithGeneratorCollector.

func NewIntentRouter

func NewIntentRouter(llm core.Client, opts ...IntentRouterOption) *intentRouter

NewIntentRouter creates a new intent router.

Required: llm. Optional (via options): WithIntentPromptTemplate, WithDefaultIntent, WithMinConfidence, WithIntentRouterLogger, WithIntentRouterCollector.

func NewQueryDecomposer

func NewQueryDecomposer(llm core.Client, opts ...QueryDecomposerOption) *queryDecomposer

NewQueryDecomposer creates a new query decomposer.

Required: llm. Optional (via options): WithDecompositionPromptTemplate, WithMaxSubQueries, WithQueryDecomposerLogger, WithQueryDecomposerCollector.

func NewRAGEvaluator

func NewRAGEvaluator(llm core.Client, opts ...RAGEvaluatorOption) *ragEvaluator

NewRAGEvaluator creates a new RAG evaluator.

Required: llm. Optional (via options): WithRAGEvaluationPromptTemplates, WithRAGEvaluatorLogger, WithRAGEvaluatorCollector.

func NewRetriever

func NewRetriever(vectorStore abstraction.VectorStore, embedder embedding.Provider, opts ...RetrieverOption) *retriever

NewRetriever creates a new retriever.

Required: vectorStore, embedder. Optional (via options): WithTopK (default 5), WithRetrieverLogger, WithRetrieverCollector.

Types

type CRAGEvaluatorOption

type CRAGEvaluatorOption func(*cragEvaluator)

CRAGEvaluatorOption configures a cragEvaluator instance.

func WithCRAGCollector

func WithCRAGCollector(collector observability.Collector) CRAGEvaluatorOption

WithCRAGCollector sets an observability collector.

func WithCRAGLogger

func WithCRAGLogger(logger logging.Logger) CRAGEvaluatorOption

WithCRAGLogger sets a structured logger.

func WithCRAGPromptTemplate

func WithCRAGPromptTemplate(tmpl string) CRAGEvaluatorOption

WithCRAGPromptTemplate overrides the default evaluation prompt.

type CacheCheckResult

type CacheCheckResult struct {
	Hit    bool
	Answer string
}

CacheCheckResult holds the result of a cache check.

type EntityExtractorOption

type EntityExtractorOption func(*entityExtractor)

EntityExtractorOption configures an entityExtractor instance.

func WithEntityExtractionPromptTemplate

func WithEntityExtractionPromptTemplate(tmpl string) EntityExtractorOption

WithEntityExtractionPromptTemplate overrides the default extraction prompt.

func WithEntityExtractorCollector

func WithEntityExtractorCollector(collector observability.Collector) EntityExtractorOption

WithEntityExtractorCollector sets an observability collector.

func WithEntityExtractorLogger

func WithEntityExtractorLogger(logger logging.Logger) EntityExtractorOption

WithEntityExtractorLogger sets a structured logger.

type GeneratorOption

type GeneratorOption func(*generator)

GeneratorOption configures a generator instance.

func WithGeneratorCollector

func WithGeneratorCollector(collector observability.Collector) GeneratorOption

WithGeneratorCollector sets an observability collector.

func WithGeneratorLogger

func WithGeneratorLogger(logger logging.Logger) GeneratorOption

WithGeneratorLogger sets a structured logger.

func WithPromptTemplate

func WithPromptTemplate(tmpl string) GeneratorOption

WithPromptTemplate overrides the default generation prompt.

type IntentRouterOption

type IntentRouterOption func(*intentRouter)

IntentRouterOption configures an intentRouter instance.

func WithDefaultIntent

func WithDefaultIntent(intent retrieval.IntentType) IntentRouterOption

WithDefaultIntent sets the fallback intent when LLM confidence is low.

func WithIntentPromptTemplate

func WithIntentPromptTemplate(tmpl string) IntentRouterOption

WithIntentPromptTemplate overrides the default intent classification prompt.

func WithIntentRouterCollector

func WithIntentRouterCollector(collector observability.Collector) IntentRouterOption

WithIntentRouterCollector sets an observability collector.

func WithIntentRouterLogger

func WithIntentRouterLogger(logger logging.Logger) IntentRouterOption

WithIntentRouterLogger sets a structured logger.

func WithMinConfidence

func WithMinConfidence(v float32) IntentRouterOption

WithMinConfidence sets the minimum confidence threshold.

type QueryDecomposerOption

type QueryDecomposerOption func(*queryDecomposer)

QueryDecomposerOption configures a queryDecomposer instance.

func WithDecompositionPromptTemplate

func WithDecompositionPromptTemplate(tmpl string) QueryDecomposerOption

WithDecompositionPromptTemplate overrides the default decomposition prompt.

func WithMaxSubQueries

func WithMaxSubQueries(max int) QueryDecomposerOption

WithMaxSubQueries sets the maximum number of sub-queries to generate.

func WithQueryDecomposerCollector

func WithQueryDecomposerCollector(collector observability.Collector) QueryDecomposerOption

WithQueryDecomposerCollector sets an observability collector.

func WithQueryDecomposerLogger

func WithQueryDecomposerLogger(logger logging.Logger) QueryDecomposerOption

WithQueryDecomposerLogger sets a structured logger.

type RAGEvaluatorOption

type RAGEvaluatorOption func(*ragEvaluator)

RAGEvaluatorOption configures a ragEvaluator instance.

func WithRAGEvaluationPromptTemplates

func WithRAGEvaluationPromptTemplates(faithfulness, relevance, precision string) RAGEvaluatorOption

WithRAGEvaluationPromptTemplates overrides the default evaluation prompts.

func WithRAGEvaluatorCollector

func WithRAGEvaluatorCollector(collector observability.Collector) RAGEvaluatorOption

WithRAGEvaluatorCollector sets an observability collector.

func WithRAGEvaluatorLogger

func WithRAGEvaluatorLogger(logger logging.Logger) RAGEvaluatorOption

WithRAGEvaluatorLogger sets a structured logger.

type RetrieverOption

type RetrieverOption func(*retriever)

Option configures a retriever instance.

func WithRetrieverCollector

func WithRetrieverCollector(collector observability.Collector) RetrieverOption

WithRetrieverCollector sets an observability collector.

func WithRetrieverLogger

func WithRetrieverLogger(logger logging.Logger) RetrieverOption

WithRetrieverLogger sets a structured logger.

func WithTopK

func WithTopK(k int) RetrieverOption

WithTopK sets the default top-K when the caller passes topK <= 0.

type SemanticCacheOption

type SemanticCacheOption func(*SemanticCacheService)

SemanticCacheOption configures a SemanticCacheService instance.

func WithCacheThreshold

func WithCacheThreshold(threshold float32) SemanticCacheOption

WithCacheThreshold sets the similarity threshold for cache hits.

func WithSemanticCacheCollector

func WithSemanticCacheCollector(collector observability.Collector) SemanticCacheOption

WithSemanticCacheCollector sets an observability collector.

func WithSemanticCacheLogger

func WithSemanticCacheLogger(logger logging.Logger) SemanticCacheOption

WithSemanticCacheLogger sets a structured logger.

type SemanticCacheService

type SemanticCacheService struct {
	// contains filtered or unexported fields
}

SemanticCacheService provides semantic caching functionality.

func NewSemanticCacheService

func NewSemanticCacheService(cache abstraction.SemanticCache, opts ...SemanticCacheOption) *SemanticCacheService

NewSemanticCacheService creates a new semantic cache service.

Required: cache. Optional (via options): WithCacheThreshold (default 0.98), WithSemanticCacheLogger, WithSemanticCacheCollector.

func (*SemanticCacheService) CacheResponse

func (s *SemanticCacheService) CacheResponse(ctx context.Context, query *entity.Query, answer string) error

CacheResponse caches a query-answer pair.

func (*SemanticCacheService) CheckCache

func (s *SemanticCacheService) CheckCache(ctx context.Context, query *entity.Query) (*CacheCheckResult, error)

CheckCache checks if the query has a cached response.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL