fix: 修复 taskindex 错乱问题
This commit is contained in:
parent
c13c601475
commit
e538f49bea
|
|
@ -2,6 +2,7 @@ package do
|
|||
|
||||
import (
|
||||
"ai_scheduler/internal/config"
|
||||
"ai_scheduler/internal/data/constants"
|
||||
errors "ai_scheduler/internal/data/error"
|
||||
"ai_scheduler/internal/data/impl"
|
||||
"ai_scheduler/internal/data/model"
|
||||
|
|
@ -419,22 +420,11 @@ func (d *Do) getTaskIdByChat(chat []entitys.Response) (taskId int32) {
|
|||
return
|
||||
}
|
||||
|
||||
var irregularTaskToolIndexMap = map[string]string{
|
||||
"zltxProduct": "product_diagnosis",
|
||||
"zltxOrderDetail": "order_diagnosis",
|
||||
"knowledgeBase": "knowledge_qa",
|
||||
"zltxOrderStatistics": "account_statistics",
|
||||
"normalChat": "chat",
|
||||
"zltxOrderAfterSaleSupplier": "after_sale_supplier",
|
||||
"zltxOrderAfterSaleReseller": "after_sale_reseller",
|
||||
"zltxOrderAfterSaleResellerBatch": "after_sale_reseller_batch",
|
||||
"zltxLossRiskSearch": "loss_order_direct",
|
||||
}
|
||||
|
||||
// 解析 taskIndex
|
||||
taskIndex := chat[0].Index
|
||||
|
||||
if _, ok := irregularTaskToolIndexMap[taskIndex]; ok {
|
||||
taskIndex = irregularTaskToolIndexMap[taskIndex]
|
||||
if _, ok := constants.IrregularTaskToolIndexMap[taskIndex]; ok {
|
||||
taskIndex = constants.IrregularTaskToolIndexMap[taskIndex]
|
||||
}
|
||||
|
||||
// 通过 taskIndex 获取 taskId
|
||||
|
|
|
|||
|
|
@ -9,3 +9,16 @@ const (
|
|||
Enable = 1
|
||||
Disable = 2
|
||||
)
|
||||
|
||||
// IrregularTaskToolIndexMap 不规则任务工具索引映射
|
||||
var IrregularTaskToolIndexMap = map[string]string{
|
||||
"zltxProduct": "product_diagnosis",
|
||||
"zltxOrderDetail": "order_diagnosis",
|
||||
"knowledgeBase": "knowledge_qa",
|
||||
"zltxOrderStatistics": "account_statistics",
|
||||
"normalChat": "chat",
|
||||
"zltxOrderAfterSaleSupplier": "after_sale_supplier",
|
||||
"zltxOrderAfterSaleReseller": "after_sale_reseller",
|
||||
"zltxOrderAfterSaleResellerBatch": "after_sale_reseller_batch",
|
||||
"zltxLossRiskSearch": "loss_order_direct",
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func (c *ChatHisQueryResponse) FromModel(chat model.AiChatHi, task model.AiTask)
|
|||
c.TaskID = chat.TaskID
|
||||
c.TaskName = task.Name
|
||||
c.Contents = make([]string, 0)
|
||||
c.TaskIndex = c.parseTaskIndex(task.Index, chat.Ans)
|
||||
c.TaskIndex = c.parseTaskIndex(task.Index)
|
||||
|
||||
// 解析Content
|
||||
if "" != chat.Content {
|
||||
|
|
@ -62,26 +62,18 @@ func (c *ChatHisQueryResponse) FromModel(chat model.AiChatHi, task model.AiTask)
|
|||
}
|
||||
}
|
||||
|
||||
func (c *ChatHisQueryResponse) parseTaskIndex(taskIndex string, ans string) string {
|
||||
if taskIndex != "" {
|
||||
return taskIndex
|
||||
func (c *ChatHisQueryResponse) parseTaskIndex(taskIndex string) string {
|
||||
// 反转 IrregularTaskToolIndexMap
|
||||
reverseMap := make(map[string]string)
|
||||
for k, v := range constants.IrregularTaskToolIndexMap {
|
||||
reverseMap[v] = k
|
||||
}
|
||||
|
||||
if ans == "" {
|
||||
return ""
|
||||
}
|
||||
var resp []Response
|
||||
err := json.Unmarshal([]byte(ans), &resp)
|
||||
if err != nil {
|
||||
log.Println("解析Ans失败 error: ", err)
|
||||
return ""
|
||||
if _, ok := reverseMap[taskIndex]; !ok {
|
||||
return reverseMap[taskIndex]
|
||||
}
|
||||
|
||||
if 0 < len(resp) {
|
||||
return resp[0].Index
|
||||
}
|
||||
|
||||
return ""
|
||||
return taskIndex
|
||||
}
|
||||
|
||||
type UpdateContentRequest struct {
|
||||
|
|
|
|||
Loading…
Reference in New Issue