fix: chat flow run usage token always returns a value of 0 (#2282)
This commit is contained in:
@ -741,9 +741,6 @@ func (w *ApplicationService) convertToChatFlowRunResponseList(ctx context.Contex
|
||||
spaceID int64
|
||||
executeID int64
|
||||
|
||||
outputCount int32
|
||||
inputCount int32
|
||||
|
||||
intermediateMessage *message.Message
|
||||
|
||||
needRegeneratedMessage = true
|
||||
@ -818,12 +815,16 @@ func (w *ApplicationService) convertToChatFlowRunResponseList(ctx context.Contex
|
||||
BotID: strconv.FormatInt(bizID, 10),
|
||||
Status: vo.Completed,
|
||||
ExecuteID: strconv.FormatInt(executeID, 10),
|
||||
Usage: &vo.Usage{
|
||||
InputTokens: ptr.Of(inputCount),
|
||||
OutputTokens: ptr.Of(outputCount),
|
||||
TokenCount: ptr.Of(outputCount + inputCount),
|
||||
},
|
||||
}
|
||||
|
||||
if msg.StateMessage.Usage != nil {
|
||||
chatDoneEvent.Usage = &vo.Usage{
|
||||
InputTokens: &msg.StateMessage.Usage.InputTokens,
|
||||
OutputTokens: &msg.StateMessage.Usage.OutputTokens,
|
||||
TokenCount: ptr.Of(msg.StateMessage.Usage.OutputTokens + msg.StateMessage.Usage.OutputTokens),
|
||||
}
|
||||
}
|
||||
|
||||
data, err := sonic.MarshalString(chatDoneEvent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -38,9 +38,9 @@ const (
|
||||
)
|
||||
|
||||
type Usage struct {
|
||||
TokenCount *int32 `form:"token_count" json:"token_count,omitempty"`
|
||||
OutputTokens *int32 `form:"output_count" json:"output_count,omitempty"`
|
||||
InputTokens *int32 `form:"input_count" json:"input_count,omitempty"`
|
||||
TokenCount *int64 `form:"token_count" json:"token_count,omitempty"`
|
||||
OutputTokens *int64 `form:"output_count" json:"output_count,omitempty"`
|
||||
InputTokens *int64 `form:"input_count" json:"input_count,omitempty"`
|
||||
}
|
||||
|
||||
type Status string
|
||||
|
||||
Reference in New Issue
Block a user