增强Stream消息处理日志:添加接收/处理/panic详细日志
This commit is contained in:
@@ -60,7 +60,7 @@ func getLocalIP() (string, error) {
|
|||||||
}
|
}
|
||||||
func getInstanceAddrByIp(ctx context.Context, ip string, services []gsvc.Service) (addr string) {
|
func getInstanceAddrByIp(ctx context.Context, ip string, services []gsvc.Service) (addr string) {
|
||||||
for _, s := range services {
|
for _, s := range services {
|
||||||
if s.GetEndpoints()[0].Host() == addr {
|
if s.GetEndpoints()[0].Host() == ip {
|
||||||
addr = s.GetEndpoints()[0].String()
|
addr = s.GetEndpoints()[0].String()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gerror"
|
"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返回数组
|
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)
|
return "", gerror.Newf("json Decode failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(response.Data) == 0 {
|
// 先检查code,再检查data
|
||||||
return "", gerror.New("上传文档返回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 {
|
if len(response.Data) == 0 {
|
||||||
return "", gerror.Newf("上传文档失败 (code=%d): %s", response.Code, response.Message)
|
g.Log().Errorf(ctx, "RAGFlow返回data为空, 完整响应: %s", string(respBody))
|
||||||
|
return "", gerror.New("上传文档返回data为空")
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.Data[0].Id, nil
|
return response.Data[0].Id, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user