78 lines
2.2 KiB
Go
78 lines
2.2 KiB
Go
package tools_bot
|
||
|
||
import (
|
||
"ai_scheduler/internal/entitys"
|
||
"context"
|
||
"encoding/json"
|
||
"fmt"
|
||
"strings"
|
||
|
||
"github.com/ollama/ollama/api"
|
||
)
|
||
|
||
type AfterSalesSupplierArgs struct {
|
||
OrderNumber string `json:"orderNumber"`
|
||
SerialNumber string `json:"serialNumber"`
|
||
Account string `json:"account"`
|
||
OrderTimeStart int `json:"orderTimeStart"`
|
||
OrderTimeEnd int `json:"orderTimeEnd"`
|
||
}
|
||
|
||
type AfterSalesSupplierList struct {
|
||
AfterSalesSupplierData []*AfterSalesSupplierData `json:"afterSalesSupplierData"`
|
||
}
|
||
|
||
type AfterSalesSupplierData struct {
|
||
OrderNumber string `json:"orderNumber"`
|
||
SerialNumber string `json:"serialNumber"`
|
||
Account string `json:"account"`
|
||
OrderTimeStart int `json:"orderTimeStart"`
|
||
OrderTimeEnd int `json:"orderTimeEnd"`
|
||
}
|
||
|
||
// AfterSalesSupplier 售后供应商
|
||
func (w *BotTool) AfterSalesSupplier(ctx context.Context, requireData *entitys.RequireData) (err error) {
|
||
// 1. 参数提取
|
||
extractResponse, err := w.llm.Generation(ctx, &api.GenerateRequest{
|
||
Model: w.config.Ollama.Model,
|
||
Stream: new(bool),
|
||
System: `
|
||
你是一个内容提取工具,用户会提供上游供应商售后流水/订单相关问题,你需要提取用户咨询的订单/流水信息。
|
||
- 提取的信息有 订单号、流水号、充值账号、订单时间区间
|
||
- 仅返回json: {"orderNumber":"","serialNumber":"","account":"","orderTimeStart":unix时间戳,"orderTimeEnd":unix时间戳}
|
||
- 不要有额外的描述、markdown等
|
||
用户输入:%s
|
||
`,
|
||
Prompt: requireData.Req.Text,
|
||
})
|
||
if err != nil {
|
||
return
|
||
}
|
||
afterSalesSupplierArgs := &AfterSalesSupplierArgs{}
|
||
_ = json.Unmarshal([]byte(extractResponse.Response), afterSalesSupplierArgs)
|
||
|
||
// 流水号为空
|
||
if afterSalesSupplierArgs.SerialNumber == "" {
|
||
// 1.1 通过充值账号查询订单号
|
||
|
||
// 1.2 通过订单号拉取流水号
|
||
|
||
}
|
||
|
||
// 流水号不存在
|
||
if afterSalesSupplierArgs.SerialNumber == "" {
|
||
return fmt.Errorf("serialNumber is required")
|
||
}
|
||
|
||
// 流水号转切片
|
||
serialNumbers := strings.Split(afterSalesSupplierArgs.SerialNumber, ",")
|
||
_ = serialNumbers
|
||
|
||
// 2. 获取流水详情
|
||
// ZltxOrderAfterSaleDetailTool
|
||
|
||
// 3. 组装售后订单详情
|
||
|
||
return nil
|
||
}
|