增强Stream消息处理日志:添加接收/处理/panic详细日志
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// 数据集内文件管理
|
||||
@@ -201,16 +202,23 @@ func (c *Client) UploadDocumentFromText(ctx context.Context, datasetId, content,
|
||||
Data []UploadDocumentRes `json:"data"` // RAGFlow返回数组
|
||||
}
|
||||
|
||||
if err := json.Unmarshal(resp.ReadAll(), &response); err != nil {
|
||||
respBody := resp.ReadAll()
|
||||
g.Log().Debugf(ctx, "RAGFlow上传文档响应: %s", string(respBody))
|
||||
|
||||
if err := json.Unmarshal(respBody, &response); err != nil {
|
||||
g.Log().Errorf(ctx, "解析RAGFlow响应失败: %v, 原始响应: %s", err, string(respBody))
|
||||
return "", gerror.Newf("json Decode failed: %v", err)
|
||||
}
|
||||
|
||||
if len(response.Data) == 0 {
|
||||
return "", gerror.New("上传文档返回data为空")
|
||||
// 先检查code,再检查data
|
||||
if response.Code != 0 {
|
||||
g.Log().Errorf(ctx, "RAGFlow返回错误: code=%d, message=%s", response.Code, response.Message)
|
||||
return "", gerror.Newf("上传文档失败 (code=%d): %s", response.Code, response.Message)
|
||||
}
|
||||
|
||||
if response.Code != 0 {
|
||||
return "", gerror.Newf("上传文档失败 (code=%d): %s", response.Code, response.Message)
|
||||
if len(response.Data) == 0 {
|
||||
g.Log().Errorf(ctx, "RAGFlow返回data为空, 完整响应: %s", string(respBody))
|
||||
return "", gerror.New("上传文档返回data为空")
|
||||
}
|
||||
|
||||
return response.Data[0].Id, nil
|
||||
|
||||
Reference in New Issue
Block a user