ai-courseware/eino-project/internal/domain/agent/order.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"
)
// NewOrderChatAgent 订单查询 Agent具备订单查询与日志查询工具
func NewOrderChatAgent(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.NewOrderByIDTool(),
},
ExecuteSequentially: false,
},
ReturnDirectly: map[string]bool{
"get_order_by_id": true,
},
}
agent, _ := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
Name: "订单查询智能体",
Description: "支持按订单ID查询订单详情",
Model: chatModel,
ToolsConfig: toolsCfg,
Instruction: `
# 你是订单查询智能体
- 当用户给出订单ID时优先调用 "get_order_by_id" 返回订单详情
- 仅返回订单详情json即可不做多余解释
`,
})
return agent
}