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: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgenticSearchResponse

type AgenticSearchResponse struct {
	SearchResponse

	// SubQueries used in parallel retrieval
	SubQueries []string

	// CRAGEvaluation result
	CRAGEvaluation *retrieval.CRAGEvaluation

	// RAGEvaluation result
	RAGEvaluation *retrieval.RAGEScores

	// ToolExecutions tracks any external tool calls
	ToolExecutions []string
}

AgenticSearchResponse extends SearchResponse with Agentic RAG metadata.

type AgenticSearchService

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

AgenticSearchService orchestrates the complete Agentic RAG search workflow.

This is a thin orchestration layer that coordinates multiple domain interfaces to complete the full Agentic RAG use case.

Business logic lives in infra/* implementations, not here.

func NewAgenticSearchService

NewAgenticSearchService creates a new Agentic search service.

func (*AgenticSearchService) Search

Search executes the complete Agentic RAG workflow.

Workflow: 1. Intent Classification → Determine if RAG is needed 2. Query Decomposition → Break into sub-queries (if complex) 3. Parallel Retrieval → Retrieve chunks for all sub-queries 4. CRAG Evaluation → Assess retrieval quality 5. Answer Generation → Generate response from chunks 6. RAG Evaluation → Assess answer quality

Parameters: - ctx: The context for cancellation and timeouts - req: The search request containing query and configuration

Returns: - *AgenticSearchResponse: Complete response with metadata - error: Any error encountered during the workflow

type CRAGEvaluator

type CRAGEvaluator interface {
	Evaluate(ctx context.Context, query *entity.Query, chunks []*entity.Chunk) (*retrieval.CRAGEvaluation, error)
}

CRAGEvaluator defines the interface for retrieval quality evaluation.

type ChatRequest

type ChatRequest struct {
	// Message is the user's chat message
	Message string

	// UserID identifies the user
	UserID string

	// SessionID tracks the conversation session
	SessionID string

	// History contains previous conversation messages
	History []string
}

ChatRequest is the DTO for chat use case input.

type ChatResponse

type ChatResponse struct {
	// Message is the chatbot's response
	Message string

	// SessionID tracks the conversation session
	SessionID string
}

ChatResponse is the DTO for chat use case output.

type Generator

type Generator interface {
	Generate(ctx context.Context, query *entity.Query, chunks []*entity.Chunk) (*retrieval.GenerationResult, error)
}

Generator defines the interface for answer generation. The return type matches retrieval.Generator.Generate which returns *retrieval.GenerationResult.

type IndexRequest

type IndexRequest struct {
	// Documents to index
	Documents []*entity.Document

	// Collection is the target collection name
	Collection string

	// BatchSize for bulk indexing (default: 100)
	BatchSize int
}

IndexRequest is the DTO for indexing use case input.

type IndexResponse

type IndexResponse struct {
	// TotalDocuments indexed successfully
	TotalDocuments int

	// FailedDocuments count
	FailedDocuments int

	// Errors encountered during indexing
	Errors []string
}

IndexResponse is the DTO for indexing use case output.

type IntentClassifier

type IntentClassifier interface {
	Classify(ctx context.Context, query *entity.Query) (*retrieval.IntentResult, error)
}

IntentClassifier defines the interface for intent classification.

type QueryDecomposer

type QueryDecomposer interface {
	Decompose(ctx context.Context, query *entity.Query) (*retrieval.DecompositionResult, error)
}

QueryDecomposer defines the interface for query decomposition.

type RAGEvaluator

type RAGEvaluator interface {
	Evaluate(ctx context.Context, query, answer, context string) (*retrieval.RAGEScores, error)
}

RAGEvaluator defines the interface for answer quality evaluation.

type Retriever

type Retriever interface {
	Retrieve(ctx context.Context, queries []string, topK int) ([]*retrieval.RetrievalResult, error)
}

Retriever defines the interface for document retrieval. The signature aligns with retrieval.Retriever and infra/service.retriever.

type SearchRequest

type SearchRequest struct {
	// Query is the user's search query
	Query *entity.Query

	// TopK is the number of chunks to retrieve (default: 5)
	TopK int

	// UserID identifies the user making the request
	UserID string

	// SessionID tracks the conversation session
	SessionID string
}

SearchRequest is the DTO for search use case input.

type SearchResponse

type SearchResponse struct {
	// Answer is the generated response
	Answer string

	// Chunks contains the retrieved chunks used in the answer
	Chunks []string

	// Score is the relevance score (0-1)
	Score float32

	// Intent is the classified intent
	Intent retrieval.IntentType

	// SourceDocuments lists the source document IDs
	SourceDocuments []string
}

SearchResponse is the DTO for search use case output.

Jump to

Keyboard shortcuts

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