Skip to content

Commit 93be3ab

Browse files
committed
Update mock_server.py
1 parent 8c84095 commit 93be3ab

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/mock_server.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"deepseek-r1": "deepseek-ai/DeepSeek-R1",
3939
"default": "deepseek-ai/DeepSeek-V3"
4040
}
41+
DUMMY_KEY = "dummy-key"
4142

4243
# --- [Shared State] ---
4344

@@ -117,11 +118,12 @@ class DeepSeekProxy:
117118
def __init__(self, api_key: str, extra_headers: Optional[Dict[str, str]] = None):
118119
# We instantiate a new client per request to ensure isolation of user credentials
119120
logger.debug("Initializing DeepSeekProxy client with headers: %s", extra_headers)
121+
kv = {"api_key": api_key} if api_key != DUMMY_KEY else {}
120122
self.client = AsyncOpenAI(
121-
api_key=api_key,
122123
base_url=SILICON_FLOW_BASE_URL,
123124
timeout=httpx.Timeout(connect=10.0, read=600.0, write=600.0, pool=10.0),
124-
default_headers=extra_headers # 透传 Header
125+
default_headers=extra_headers, # 透传 Header
126+
**kv
125127
)
126128

127129
def _get_mapped_model(self, request_model: str) -> str:
@@ -327,7 +329,7 @@ def epoch_clock():
327329
def _prepare_proxy_and_headers(request: Request, authorization: Optional[str]) -> tuple[DeepSeekProxy, str]:
328330
"""Helper to extract API key, filter headers, and instantiate the proxy."""
329331
request_id = request.headers.get("x-request-id", str(uuid.uuid4()))
330-
api_key = "dummy-key"
332+
api_key = DUMMY_KEY
331333

332334
if SERVER_STATE.is_mock_mode:
333335
api_key = _MOCK_ENV_API_KEY or "mock-key"

0 commit comments

Comments
 (0)