feat(prompt): 添加提示词处理功能与文件安全过滤
This commit is contained in:
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
// PullTaskResult 轮询查询异步任务结果
|
||||
func PullTaskResult(ctx context.Context, body map[string]any, queryConfig map[string]any, headMsg map[string]any) (map[string]any, error) {
|
||||
taskID, err := extractTaskID(body, queryConfig)
|
||||
if err != nil {
|
||||
@@ -40,6 +39,12 @@ func PullTaskResult(ctx context.Context, body map[string]any, queryConfig map[st
|
||||
}
|
||||
statusValues, _ := queryConfig["status_values"].(map[string]any)
|
||||
|
||||
// 失败信息路径
|
||||
errorPath := gconv.String(queryConfig["error_path"])
|
||||
if errorPath == "" {
|
||||
errorPath = "error.message"
|
||||
}
|
||||
|
||||
reqBodyMap := map[string]any{"task_id": taskID}
|
||||
|
||||
for {
|
||||
@@ -70,8 +75,12 @@ func PullTaskResult(ctx context.Context, body map[string]any, queryConfig map[st
|
||||
}
|
||||
|
||||
if matchStatus(statusStr, statusValues["failed"]) {
|
||||
g.Log().Errorf(ctx, "[PullTaskResult] 任务失败 taskID=%s", taskID)
|
||||
return result, fmt.Errorf("任务失败")
|
||||
errMsg := gconv.String(gjson.New(result).Get(errorPath).Val())
|
||||
if errMsg == "" {
|
||||
errMsg = "任务失败"
|
||||
}
|
||||
g.Log().Errorf(ctx, "[PullTaskResult] 任务失败 taskID=%s err=%s", taskID, errMsg)
|
||||
return result, fmt.Errorf("任务失败: %s", errMsg)
|
||||
}
|
||||
|
||||
time.Sleep(time.Duration(interval) * time.Second)
|
||||
|
||||
Reference in New Issue
Block a user