添加修改模型请求头

This commit is contained in:
h88782481 2026-03-13 20:25:33 +08:00
parent 406a36af89
commit e726f11bad
9 changed files with 109 additions and 1 deletions

View file

@ -28,6 +28,8 @@ from adapters.responses_cc_adapter import (
from config import Config
from routes.common import (
RouteContext,
apply_body_modifications,
apply_header_modifications,
build_anthropic_target,
build_openai_target,
build_responses_target,
@ -118,6 +120,8 @@ def _handle_openai_backend(ctx: RouteContext, payload: dict[str, Any]):
)
url, headers = build_openai_target(ctx)
payload = apply_body_modifications(payload, ctx.body_modifications)
headers = apply_header_modifications(headers, ctx.header_modifications)
if ctx.is_stream:
return _handle_openai_stream(ctx, payload, url, headers)
@ -208,6 +212,8 @@ def _handle_responses_backend(ctx: RouteContext, payload: dict[str, Any]):
)
url, headers = build_responses_target(ctx)
responses_payload = apply_body_modifications(responses_payload, ctx.body_modifications)
headers = apply_header_modifications(headers, ctx.header_modifications)
if ctx.is_stream:
return _handle_responses_stream(ctx, responses_payload, url, headers)
@ -285,6 +291,8 @@ def _handle_anthropic_backend(ctx: RouteContext, payload: dict[str, Any]):
)
url, headers = build_anthropic_target(ctx)
anthropic_payload = apply_body_modifications(anthropic_payload, ctx.body_modifications)
headers = apply_header_modifications(headers, ctx.header_modifications)
if ctx.is_stream:
return _handle_anthropic_stream(ctx, anthropic_payload, url, headers)