fix stream usage
This commit is contained in:
@@ -14,6 +14,8 @@ import (
|
|||||||
"opencatd-open/llm"
|
"opencatd-open/llm"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/sashabaranov/go-openai"
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://learn.microsoft.com/en-us/azure/ai-services/openai/api-version-deprecation#latest-preview-api-releases
|
// 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) {
|
func (o *OpenAICompatible) StreamChat(ctx context.Context, chatReq llm.ChatRequest) (chan *llm.StreamChatResponse, error) {
|
||||||
chatReq.Stream = true
|
chatReq.Stream = true
|
||||||
|
chatReq.StreamOptions = &openai.StreamOptions{IncludeUsage: true}
|
||||||
dst, err := utils.StructToMap(chatReq)
|
dst, err := utils.StructToMap(chatReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Reference in New Issue
Block a user