package tools import ( "context" "time" "github.com/cloudwego/eino/components/tool" "github.com/cloudwego/eino/components/tool/utils" ) type OrderLog struct { OrderID string `json:"order_id"` Timestamp time.Time `json:"timestamp"` Level string `json:"level"` Message string `json:"message"` } type OrderLogQueryInput struct { OrderID string `json:"order_id" jsonschema:"description=订单ID"` } func NewOrderLogQueryTool() tool.InvokableTool { t, err := utils.InferTool("query_order_logs", "查询订单处理日志,返回日志数组。", orderLogQuery) if err != nil { panic(err) } return t } func orderLogQuery(ctx context.Context, in *OrderLogQueryInput) ([]*OrderLog, error) { logs := []*OrderLog{ {OrderID: in.OrderID, Timestamp: time.Now().Add(-5 * time.Minute), Level: "INFO", Message: "订单已创建"}, {OrderID: in.OrderID, Timestamp: time.Now().Add(-4 * time.Minute), Level: "INFO", Message: "支付完成"}, {OrderID: in.OrderID, Timestamp: time.Now().Add(-3 * time.Minute), Level: "INFO", Message: "仓库打包"}, {OrderID: in.OrderID, Timestamp: time.Now().Add(-2 * time.Minute), Level: "WARN", Message: "快递延迟,重新调度"}, {OrderID: in.OrderID, Timestamp: time.Now().Add(-1 * time.Minute), Level: "INFO", Message: "发货完成"}, } return logs, nil }