Fix/content reasoning
* fix: concat * fix: concat * fix: concat sep * fix: concat content & url * fix: opimized * fix: test * fix: test * fix: multi content parse with uri * fix: multi content combine * fix: remove unused func * fix: multi content with content & reasoning content * fix: multi content with content & reasoning content See merge request: !886
This commit is contained in:
@@ -418,11 +418,12 @@ func (c *ConversationApplicationService) parseMultiContent(ctx context.Context,
|
||||
|
||||
resourceUrl, err := c.getUrlByUri(ctx, item.Image.Key)
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to unescape resource url, err is %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logs.CtxErrorf(ctx, "failed to unescape resource url, err is %v", err)
|
||||
if resourceUrl == "" {
|
||||
logs.CtxErrorf(ctx, "failed to unescape resource url, uri is %v", item.Image.Key)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -434,6 +435,7 @@ func (c *ConversationApplicationService) parseMultiContent(ctx context.Context,
|
||||
FileData: []*crossDomainMessage.FileData{
|
||||
{
|
||||
Url: resourceUrl,
|
||||
URI: item.Image.Key,
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -451,6 +453,7 @@ func (c *ConversationApplicationService) parseMultiContent(ctx context.Context,
|
||||
FileData: []*crossDomainMessage.FileData{
|
||||
{
|
||||
Url: resourceUrl,
|
||||
URI: item.File.FileKey,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
@@ -18,10 +18,12 @@ package conversation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
singleAgentEntity "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
@@ -217,7 +219,7 @@ func (c *ConversationApplicationService) buildDomainMsg2VOMessage(ctx context.Co
|
||||
}
|
||||
|
||||
if dm.ContentType == model.ContentTypeMix && dm.DisplayContent != "" {
|
||||
cm.Content = dm.DisplayContent
|
||||
cm.Content = c.buildParseMessageURI(ctx, dm.DisplayContent)
|
||||
}
|
||||
|
||||
if dm.MessageType != model.MessageTypeQuestion {
|
||||
@@ -227,6 +229,46 @@ func (c *ConversationApplicationService) buildDomainMsg2VOMessage(ctx context.Co
|
||||
return cm
|
||||
}
|
||||
|
||||
func (c *ConversationApplicationService) buildParseMessageURI(ctx context.Context, msgContent string) string {
|
||||
|
||||
if msgContent == "" {
|
||||
return msgContent
|
||||
}
|
||||
|
||||
var mc *run.MixContentModel
|
||||
err := json.Unmarshal([]byte(msgContent), &mc)
|
||||
if err != nil {
|
||||
return msgContent
|
||||
}
|
||||
for k, item := range mc.ItemList {
|
||||
switch item.Type {
|
||||
case run.ContentTypeImage:
|
||||
|
||||
url, pErr := c.appContext.ImageX.GetResourceURL(ctx, item.Image.Key)
|
||||
if pErr == nil {
|
||||
mc.ItemList[k].Image.ImageThumb.URL = url.URL
|
||||
mc.ItemList[k].Image.ImageOri.URL = url.URL
|
||||
}
|
||||
|
||||
case run.ContentTypeFile, run.ContentTypeAudio, run.ContentTypeVideo:
|
||||
url, pErr := c.appContext.ImageX.GetResourceURL(ctx, item.File.FileKey)
|
||||
if pErr == nil {
|
||||
mc.ItemList[k].File.FileURL = url.URL
|
||||
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
}
|
||||
}
|
||||
jsonMsg, err := json.Marshal(mc)
|
||||
if err != nil {
|
||||
return msgContent
|
||||
}
|
||||
|
||||
return string(jsonMsg)
|
||||
}
|
||||
|
||||
func buildDExt2ApiExt(extra map[string]string) *message.ExtraInfo {
|
||||
return &message.ExtraInfo{
|
||||
InputTokens: extra["input_tokens"],
|
||||
|
||||
Reference in New Issue
Block a user