2026-04-13 20:37:22 +08:00
|
|
|
package runtime
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2026-08-21 00:41:07 +08:00
|
|
|
"code.tczkiot.com/wlw/ai-agent/internal/models"
|
2026-04-13 20:37:22 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Service struct {
|
2026-07-27 23:29:02 +08:00
|
|
|
engine *AgentLoopEngine
|
2026-04-13 20:37:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewService() *Service {
|
2026-07-27 23:29:02 +08:00
|
|
|
return NewServiceWithEngine(NewAgentLoopEngine())
|
2026-04-13 20:37:22 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-27 23:29:02 +08:00
|
|
|
func NewServiceWithEngine(engine *AgentLoopEngine) *Service {
|
|
|
|
|
return &Service{engine: engine}
|
2026-07-25 12:04:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Service) Run(ctx context.Context, req RunInput) (*RunResult, error) {
|
2026-07-27 23:29:02 +08:00
|
|
|
return s.engine.Run(ctx, req)
|
2026-07-25 12:04:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *Service) Resume(ctx context.Context, req ResumeInput) (*RunResult, error) {
|
2026-07-27 23:29:02 +08:00
|
|
|
return s.engine.Resume(ctx, req)
|
2026-04-13 20:37:22 +08:00
|
|
|
}
|
2026-06-23 09:34:08 +08:00
|
|
|
|
2026-07-27 23:29:02 +08:00
|
|
|
func (s *Service) RunOfflineEvaluation(ctx context.Context, agent models.AIAgent, config models.AIConfig, cases []OfflineEvaluationCase) (OfflineEvaluationReport, error) {
|
|
|
|
|
runner := NewOfflineEvaluationRunner(s.engine.Run)
|
|
|
|
|
return runner.Run(ctx, agent, config, cases), nil
|
2026-06-23 22:11:20 +08:00
|
|
|
}
|