mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-03 01:40:21 +08:00
feat: 增强 Gemini 流式响应兼容性,支持 JSON-array 格式解析
- 添加 Gemini JSON-array/chunks 格式的解析支持(兼容非 SSE 返回) - 在上游请求中添加 alt=sse 参数,优先使用 SSE 格式 - 为 OpenAI 客户端统一补齐 [DONE] 流结束标记 - 更新 Gemini finishReason 判断逻辑,采用更宽松的结束判定
This commit is contained in:
@@ -128,6 +128,10 @@ def build_provider_url(
|
||||
# 上游认证始终使用 header 方式,不使用 URL 参数
|
||||
if resolved_format in (APIFormat.GEMINI, APIFormat.GEMINI_CLI):
|
||||
effective_query_params.pop("key", None)
|
||||
# Gemini streamGenerateContent 官方支持 `?alt=sse` 返回 SSE(data: {...})。
|
||||
# 网关侧统一使用 SSE 输出,优先向上游请求 SSE 以减少解析分支;同时保留 JSON-array 兜底解析。
|
||||
if is_stream:
|
||||
effective_query_params.setdefault("alt", "sse")
|
||||
|
||||
# 添加查询参数
|
||||
if effective_query_params:
|
||||
|
||||
Reference in New Issue
Block a user