Skip to content

Commit

Permalink
fix(llm-bridge): correct usage in stream response (#901)
Browse files Browse the repository at this point in the history
  • Loading branch information
woorui authored Sep 6, 2024
1 parent 02356ec commit 29fce94
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/bridge/ai/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ func (srv *Service) GetChatCompletions(ctx context.Context, req openai.ChatCompl
if err != nil {
return err
}
if len(streamRes.Choices) == 0 {
continue
}
if streamRes.Usage != nil {
promptUsage = streamRes.Usage.PromptTokens
completionUsage = streamRes.Usage.CompletionTokens
totalUsage = streamRes.Usage.TotalTokens
}
if len(streamRes.Choices) == 0 {
continue
}
if tc := streamRes.Choices[0].Delta.ToolCalls; len(tc) > 0 {
isFunctionCall = true
if j == 0 {
Expand Down Expand Up @@ -697,6 +697,7 @@ func transToolMessage(msgs []openai.ChatCompletionMessage) []ai.ToolMessage {

func recordTTFT(ctx context.Context, tracer trace.Tracer) {
_, span := tracer.Start(ctx, "TTFT")
time.Sleep(time.Millisecond)
span.End()
time.Sleep(time.Millisecond)
}
Expand Down

0 comments on commit 29fce94

Please sign in to comment.