ai-courseware/eino-project/internal/domain/agent/order_log.go

44 lines
1.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package agent
import (
"context"
"eino-project/internal/domain/llm"
"eino-project/internal/domain/tools"
"github.com/cloudwego/eino/adk"
"github.com/cloudwego/eino/components/tool"
"github.com/cloudwego/eino/compose"
)
// NewOrderLogAgent 订单日志 Agent仅绑定日志查询工具
func NewOrderLogAgent(ctx context.Context, models llm.LLM) adk.Agent {
chatModel, err := models.Intent()
if err != nil {
return nil
}
toolsCfg := adk.ToolsConfig{
ToolsNodeConfig: compose.ToolsNodeConfig{
Tools: []tool.BaseTool{
tools.NewOrderLogQueryTool(),
},
ExecuteSequentially: false,
},
ReturnDirectly: map[string]bool{
"query_order_logs": true,
},
}
agent, _ := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
Name: "订单日志智能体",
Description: "查询并返回订单日志",
Model: chatModel,
ToolsConfig: toolsCfg,
Instruction: `
# 你是订单日志查询智能体
- 接收订单ID调用 "query_order_logs" 按时间倒序获取所有日志列表
- 输出日志列表
`,
})
return agent
}