feat: enable SSE streaming support in Anthropic handler

- Updated AnthropicHandler to check for streaming configuration before handling SSE transform.
- Modified handleStreaming to use the original request body instead of forcing stream to true.
- Adjusted the transformation logic in AnthropicToBifrost to respect the original stream setting.
- Added logging for SSE streaming configuration in the main application.
This commit is contained in:
Beyhan Ogur
2026-05-11 15:28:56 +03:00
parent f0a4e89e0f
commit c56ae7194c
10 changed files with 193 additions and 21 deletions
+6 -4
View File
@@ -14,10 +14,11 @@
4. `x-api-key``Authorization: Bearer` dönüşümü (Claude Code uyumluluğu)
5. Gerekirse `OPENAI_KEY`'den auto-inject
6. [[BifrostTransform#AnthropicToBifrost|AnthropicToBifrost()]] ile dönüşüm
7. [[ProxyEngine]] ile `OPENAI_BACKEND/v1/chat/completions`'a forward
8. Başarılıysa (200): [[BifrostTransform#BifrostToAnthropic|BifrostToAnthropic()]] → Anthropic format
9. Hata durumunda: raw passthrough
10. DB log (fire-and-forget)
7. Client `stream: true` gönderdiyse ve `STREAMING=true` ise → [[#handleStreaming|SSE streaming]]
8. [[ProxyEngine]] ile `OPENAI_BACKEND/v1/chat/completions`'a forward
9. Başarılıysa (200): [[BifrostTransform#BifrostToAnthropic|BifrostToAnthropic()]] → Anthropic format
10. Hata durumunda: raw passthrough
11. DB log (fire-and-forget)
## Endpoint
@@ -47,3 +48,4 @@ Authorization: Bearer <api-key>
- Geçersiz Anthropic formatı → uyarı log'u + raw passthrough
- Upstream hatası`502 Bad Gateway`
- Yanıt dönüşüm hatası → raw yanıtı forward et
- `STREAMING=false` → client `stream: true` isteği görmezden gelinir, non-streaming yanıt döner
+1
View File
@@ -19,6 +19,7 @@
| `POSTGRES_DSN` / `DATABASE_DSN` | `""` | `PostgresDSN` | PostgreSQL bağlantı DSN (`DB_MODE=pgs` iken) |
| `REQUEST_TIMEOUT_SECONDS` | `30` | `RequestTimeoutSeconds` | Upstream istek zaman aşımı (saniye) |
| `OPENAI_MODEL` | `""` | `OpenAIModel` | Varsayılan model adı (istekte model yoksa enjekte edilir) |
| `STREAMING` | `true` | `Streaming` | SSE streaming yanıtlarını etkinleştir/devre dışı bırak (`true`/`false`) |
## Önemli Detaylar