-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Bug Description
When using Claude format requests (/v1/messages) through the Ollama channel (with model alias), the SSE response format is incorrect.
Expected Behavior
Claude SSE format with event: and data: lines:
event: message_start
data: {"type":"message_start","message":{...}}
event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"..."}}
Actual Behavior
OpenAI SSE format (only data: lines):
data: {"id":"...","object":"chat.completion.chunk","created":...,"model":"...","choices":[...]}
Root Cause
The ollamaStreamHandler function in /relay/channel/ollama/stream.go does not check info.RelayFormat. It always returns OpenAI format SSE responses regardless of the request format.
Affected Code
File: /relay/channel/ollama/stream.go
Function: ollamaStreamHandler (lines 66-181)
The function uses helper.StringData() directly instead of checking info.RelayFormat and using the appropriate format handler like openai.HandleStreamFormat().
Similar Issues in Other Channels
The following channels may have the same issue (not checking RelayFormat):
cloudflarexaicoherezhipubaidutencentcozedify
Proposed Fix
Modify ollamaStreamHandler to use openai.HandleStreamFormat() and openai.HandleFinalResponse() which already implement proper format switching based on info.RelayFormat.