MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / ProcessStreamResponse

Function ProcessStreamResponse

relay/channel/openai/helper.go:44–59  ·  view source on GitHub ↗
(streamResponse dto.ChatCompletionsStreamResponse, responseTextBuilder *strings.Builder, toolCount *int)

Source from the content-addressed store, hash-verified

42}
43
44func ProcessStreamResponse(streamResponse dto.ChatCompletionsStreamResponse, responseTextBuilder *strings.Builder, toolCount *int) error {
45 for _, choice := range streamResponse.Choices {
46 responseTextBuilder.WriteString(choice.Delta.GetContentString())
47 responseTextBuilder.WriteString(choice.Delta.GetReasoningContent())
48 if choice.Delta.ToolCalls != nil {
49 if len(choice.Delta.ToolCalls) > *toolCount {
50 *toolCount = len(choice.Delta.ToolCalls)
51 }
52 for _, tool := range choice.Delta.ToolCalls {
53 responseTextBuilder.WriteString(tool.Function.Name)
54 responseTextBuilder.WriteString(tool.Function.Arguments)
55 }
56 }
57 }
58 return nil
59}
60
61func processTokens(relayMode int, streamItems []string, responseTextBuilder *strings.Builder, toolCount *int) error {
62 streamResp := "[" + strings.Join(streamItems, ",") + "]"

Callers 2

xAIStreamHandlerFunction · 0.92
processChatCompletionsFunction · 0.85

Calls 2

GetContentStringMethod · 0.80
GetReasoningContentMethod · 0.80

Tested by

no test coverage detected