18c9354095
- 注入数据库、运行时配置、统一响应、文件存储和平台 AI 能力,补充业务读写工具与客户快捷操作契约。 - 移除模块内重复的组织、客户、工单、标签、技能、旧工作流、MCP 和迁移实现,将身份权限与业务主体交由宿主管理。 - 使用 libSQL 重构向量存储,并完善图片消息、访客身份、排队调度、企业微信和支持聊天页面。 - 统一 HTTP、DTO 与 WebSocket 的 snake_case 协议,补齐模块初始化、业务动作和公共载荷等回归测试。
45 lines
1.8 KiB
Go
45 lines
1.8 KiB
Go
package runtime
|
|
|
|
import (
|
|
"context"
|
|
|
|
applicationruntime "code.tczkiot.com/wlw/ai-agent/internal/ai/application/runtime"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/dto/request"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/dto/response"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/enums"
|
|
"code.tczkiot.com/wlw/ai-agent/internal/pkg/errorsx"
|
|
svc "code.tczkiot.com/wlw/ai-agent/internal/services"
|
|
)
|
|
|
|
func init() {
|
|
svc.AgentEvaluationRunHook = RunAgentEvaluation
|
|
}
|
|
|
|
func RunAgentEvaluation(ctx context.Context, req request.RunAgentEvaluationRequest) (*response.AgentEvaluationReportResponse, error) {
|
|
agent := svc.AIAgentService.Get(req.AIAgentID)
|
|
if agent == nil || agent.Status != enums.StatusOk {
|
|
return nil, errorsx.InvalidParamI18n("error.e0007")
|
|
}
|
|
config, err := applicationruntime.ResolveRuntimeAIConfig(ctx, agent.AIConfigID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
cases := make([]applicationruntime.OfflineEvaluationCase, 0, len(req.Cases))
|
|
for _, item := range req.Cases {
|
|
cases = append(cases, applicationruntime.OfflineEvaluationCase{ID: item.ID, Category: item.Category, Message: item.Message, History: item.History, Expect: item.Expect})
|
|
}
|
|
report, err := applicationruntime.NewService().RunOfflineEvaluation(ctx, *agent, *config, cases)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
csv, err := report.CSV()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ret := &response.AgentEvaluationReportResponse{Total: report.Total, Passed: report.Passed, CSV: csv, Results: make([]response.AgentEvaluationResultResponse, 0, len(report.Results))}
|
|
for _, item := range report.Results {
|
|
ret.Results = append(ret.Results, response.AgentEvaluationResultResponse{CaseID: item.CaseID, Category: item.Category, Passed: item.Passed, ReplyText: item.ReplyText, Interrupted: item.Interrupted, Error: item.Error, Finding: item.Finding})
|
|
}
|
|
return ret, nil
|
|
}
|