diff --git a/llm/openai_compatible/chat.go b/llm/openai_compatible/chat.go index 5b6b9dc..4214228 100644 --- a/llm/openai_compatible/chat.go +++ b/llm/openai_compatible/chat.go @@ -14,6 +14,8 @@ import ( "opencatd-open/llm" "os" "strings" + + "github.com/sashabaranov/go-openai" ) // https://learn.microsoft.com/en-us/azure/ai-services/openai/api-version-deprecation#latest-preview-api-releases @@ -130,6 +132,7 @@ func (o *OpenAICompatible) Chat(ctx context.Context, chatReq llm.ChatRequest) (* func (o *OpenAICompatible) StreamChat(ctx context.Context, chatReq llm.ChatRequest) (chan *llm.StreamChatResponse, error) { chatReq.Stream = true + chatReq.StreamOptions = &openai.StreamOptions{IncludeUsage: true} dst, err := utils.StructToMap(chatReq) if err != nil { return nil, err