Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchProcessor ¶
type BatchProcessor struct {
// contains filtered or unexported fields
}
BatchProcessor handles batch translation with concurrency
func NewBatchProcessor ¶
func NewBatchProcessor(provider provider.AIProvider, reflectionEngine *ReflectionEngine) *BatchProcessor
NewBatchProcessor creates a new batch processor
func (*BatchProcessor) ProcessBatches ¶
func (bp *BatchProcessor) ProcessBatches( ctx context.Context, batches [][]domain.BatchItem, sourceLang, targetLang string, termDict string, terminology *domain.Terminology, terminologyTranslation *domain.TerminologyTranslation, concurrency int, ) (map[string]string, BatchStats, error)
ProcessBatches processes multiple batches with concurrency control
func (*BatchProcessor) SetProgressCallback ¶
func (bp *BatchProcessor) SetProgressCallback(callback BatchProgressCallback)
SetProgressCallback sets the progress callback function
type BatchProgressCallback ¶
type BatchProgressCallback func(event BatchProgressEvent)
BatchProgressCallback is called for batch progress updates
type BatchProgressEvent ¶
type BatchProgressEvent struct {
Type string // "start", "complete", "retry", "error"
BatchIndex int
TotalBatches int
BatchSize int
Concurrency int
Attempt int
MaxAttempts int
Duration time.Duration
Tokens int
Error error
}
BatchProgressEvent represents a batch processing event
type BatchStats ¶
BatchStats contains statistics from batch processing
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is the main translation engine
func NewEngine ¶
func NewEngine( provider provider.AIProvider, termManager *terminology.Manager, ) *Engine
NewEngine creates a new translation engine
func (*Engine) GetBatchProcessor ¶
func (e *Engine) GetBatchProcessor() *BatchProcessor
GetBatchProcessor returns the batch processor for setting callbacks
func (*Engine) GetReflectionEngine ¶
func (e *Engine) GetReflectionEngine() *ReflectionEngine
GetReflectionEngine returns the reflection engine for setting callbacks
func (*Engine) Translate ¶
func (e *Engine) Translate(ctx context.Context, input domain.TranslationInput) (*domain.TranslationResult, error)
Translate performs the complete translation workflow
type ReflectionEngine ¶
type ReflectionEngine struct {
// contains filtered or unexported fields
}
ReflectionEngine implements Agentic reflection mechanism Following Andrew Ng's Translation Agent approach with two-step process: Step 1: Reflect - LLM evaluates translation quality and provides suggestions Step 2: Improve - LLM improves translation based on suggestions Target: 3x API calls (translate → reflect → improve)
func NewReflectionEngine ¶
func NewReflectionEngine(prov provider.AIProvider) *ReflectionEngine
NewReflectionEngine creates a new reflection engine
func (*ReflectionEngine) Reflect ¶
func (r *ReflectionEngine) Reflect(ctx context.Context, input ReflectionInput, progressCallback ReflectionProgressCallback) (*ReflectionResult, error)
Reflect performs Agentic reflection on translations This is the main entry point following Andrew Ng's two-step approach
func (*ReflectionEngine) ShouldReflect ¶
func (r *ReflectionEngine) ShouldReflect(translations map[string]string, terminology *domain.Terminology) bool
ShouldReflect determines if reflection is needed for a batch In Agentic mode, we always reflect to allow LLM to discover quality issues
type ReflectionInput ¶
type ReflectionInput struct {
SourceTexts map[string]string // key -> source text
TranslatedTexts map[string]string // key -> translated text
SourceLang string
TargetLang string
Terminology *domain.Terminology
TerminologyTranslation *domain.TerminologyTranslation
}
ReflectionInput contains input for reflection
type ReflectionProgressCallback ¶
type ReflectionProgressCallback func(event ReflectionProgressEvent)
ReflectionProgressCallback is called for reflection progress updates
type ReflectionProgressEvent ¶
type ReflectionProgressEvent struct {
Type string // "reflecting_start", "reflected_complete", "improving_start", "improved_complete"
Count int // number of texts being processed
Duration time.Duration // time spent (only for complete events)
}
ReflectionProgressEvent represents a reflection event
type ReflectionResult ¶
type ReflectionResult struct {
Suggestions map[string]string // key -> expert suggestions from LLM
ImprovedTexts map[string]string // key -> improved translations
ReflectionNeeded bool
APICallsUsed int // Should be 2 (reflect + improve)
ReflectDuration time.Duration // Time spent on reflection step
ImproveDuration time.Duration // Time spent on improvement step
}
ReflectionResult contains reflection results