fix: 修复 taskindex 错乱问题
This commit is contained in:
parent
c13c601475
commit
e538f49bea
|
|
@ -2,6 +2,7 @@ package do
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"ai_scheduler/internal/config"
|
"ai_scheduler/internal/config"
|
||||||
|
"ai_scheduler/internal/data/constants"
|
||||||
errors "ai_scheduler/internal/data/error"
|
errors "ai_scheduler/internal/data/error"
|
||||||
"ai_scheduler/internal/data/impl"
|
"ai_scheduler/internal/data/impl"
|
||||||
"ai_scheduler/internal/data/model"
|
"ai_scheduler/internal/data/model"
|
||||||
|
|
@ -419,22 +420,11 @@ func (d *Do) getTaskIdByChat(chat []entitys.Response) (taskId int32) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var irregularTaskToolIndexMap = map[string]string{
|
// 解析 taskIndex
|
||||||
"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 := chat[0].Index
|
taskIndex := chat[0].Index
|
||||||
|
|
||||||
if _, ok := irregularTaskToolIndexMap[taskIndex]; ok {
|
if _, ok := constants.IrregularTaskToolIndexMap[taskIndex]; ok {
|
||||||
taskIndex = irregularTaskToolIndexMap[taskIndex]
|
taskIndex = constants.IrregularTaskToolIndexMap[taskIndex]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通过 taskIndex 获取 taskId
|
// 通过 taskIndex 获取 taskId
|
||||||
|
|
|
||||||
|
|
@ -9,3 +9,16 @@ const (
|
||||||
Enable = 1
|
Enable = 1
|
||||||
Disable = 2
|
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.TaskID = chat.TaskID
|
||||||
c.TaskName = task.Name
|
c.TaskName = task.Name
|
||||||
c.Contents = make([]string, 0)
|
c.Contents = make([]string, 0)
|
||||||
c.TaskIndex = c.parseTaskIndex(task.Index, chat.Ans)
|
c.TaskIndex = c.parseTaskIndex(task.Index)
|
||||||
|
|
||||||
// 解析Content
|
// 解析Content
|
||||||
if "" != chat.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 {
|
func (c *ChatHisQueryResponse) parseTaskIndex(taskIndex string) string {
|
||||||
if taskIndex != "" {
|
// 反转 IrregularTaskToolIndexMap
|
||||||
return taskIndex
|
reverseMap := make(map[string]string)
|
||||||
|
for k, v := range constants.IrregularTaskToolIndexMap {
|
||||||
|
reverseMap[v] = k
|
||||||
}
|
}
|
||||||
|
|
||||||
if ans == "" {
|
if _, ok := reverseMap[taskIndex]; !ok {
|
||||||
return ""
|
return reverseMap[taskIndex]
|
||||||
}
|
|
||||||
var resp []Response
|
|
||||||
err := json.Unmarshal([]byte(ans), &resp)
|
|
||||||
if err != nil {
|
|
||||||
log.Println("解析Ans失败 error: ", err)
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if 0 < len(resp) {
|
return taskIndex
|
||||||
return resp[0].Index
|
|
||||||
}
|
|
||||||
|
|
||||||
return ""
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpdateContentRequest struct {
|
type UpdateContentRequest struct {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue