mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat(codex): 支持compact端点非流式请求,更新请求头与字段清理
- Codex适配器支持compact端点:非流式请求使用application/json Accept头, stream_policy根据compact上下文返回FORCE_NON_STREAM - 更新Codex请求头格式:添加Version/Connection头,header key首字母大写 - 简化include列表处理:normalizer和request_patching统一强制为固定列表 - 清理Codex不支持的字段:truncation、context_management、user - 默认instructions改为空字符串 - 前端用量页面:用户页面使用前端筛选后总数,避免不必要的后端分页请求
This commit is contained in:
@@ -3,6 +3,10 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
from types import SimpleNamespace
|
||||
|
||||
from src.services.provider.adapters.codex.context import (
|
||||
CodexRequestContext,
|
||||
set_codex_request_context,
|
||||
)
|
||||
from src.services.provider.stream_policy import (
|
||||
UpstreamStreamPolicy,
|
||||
enforce_stream_mode_for_upstream,
|
||||
@@ -42,6 +46,19 @@ def test_get_upstream_stream_policy_codex_ignores_force_non_stream_config() -> N
|
||||
assert get_upstream_stream_policy(ep) == UpstreamStreamPolicy.FORCE_STREAM
|
||||
|
||||
|
||||
def test_get_upstream_stream_policy_codex_compact_forces_non_stream() -> None:
|
||||
ep = _DummyEndpoint(
|
||||
api_format="openai:cli",
|
||||
config=None,
|
||||
provider=SimpleNamespace(provider_type="codex"),
|
||||
)
|
||||
try:
|
||||
set_codex_request_context(CodexRequestContext(is_compact=True))
|
||||
assert get_upstream_stream_policy(ep) == UpstreamStreamPolicy.FORCE_NON_STREAM
|
||||
finally:
|
||||
set_codex_request_context(None)
|
||||
|
||||
|
||||
def test_enforce_stream_mode_for_upstream_openai_chat_sets_stream_options_usage() -> None:
|
||||
body = {"stream": False}
|
||||
out = enforce_stream_mode_for_upstream(
|
||||
|
||||
Reference in New Issue
Block a user