44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
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
|
||
}
|