Skip to content

fix: deepseek-reasoner test failure and missing nginx /api proxy#704

Open
qirobot wants to merge 1 commit into
hsliuping:mainfrom
qirobot:fix/deepseek-reasoner-test
Open

fix: deepseek-reasoner test failure and missing nginx /api proxy#704
qirobot wants to merge 1 commit into
hsliuping:mainfrom
qirobot:fix/deepseek-reasoner-test

Conversation

@qirobot

@qirobot qirobot commented May 4, 2026

Copy link
Copy Markdown

Summary

Two independent fixes hit while bringing up the project via docker compose:

1. deepseek-reasoner 模型测试始终报 "API响应为空"

In app/services/config_service.py::_test_deepseek_api:

  • max_tokens was 50. deepseek-reasoner first emits reasoning_content (思考过程) before the final content. With only 50 tokens the model is still mid-reasoning, so choices[0].message.content comes back empty and the test reports "API响应为空".
  • timeout was 10s, which is also too tight for reasoner — it routinely thinks for 30–90s.

Bumped to max_tokens=2000 and timeout=120. deepseek-chat is unaffected (small response, well under the new cap).

2. Docker 前端登录 405 (Method Not Allowed)

docker/nginx.conf has no /api/ rule, so the SPA's POST /api/auth/login falls through to the static-file location / block. nginx then refuses POST on a static route → 405. Login is impossible until this is fixed.

Added a standard reverse-proxy block:

location /api/ {
    proxy_pass http://backend:8000;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 300s;
    proxy_connect_timeout 60s;
    proxy_send_timeout 300s;
}

The backend hostname matches the service name in docker-compose.yml, so it works out of the box for fresh docker compose up users.

Test plan

  • deepseek-chat 测试仍然通过(回归)
  • deepseek-reasoner 测试通过(之前必失败)
  • 前端 admin / admin123 登录成功(之前 405)
  • 普通后端 API 调用经 nginx 反代正常返回

1. _test_deepseek_api: bump max_tokens 50→2000, timeout 10→120s.
   deepseek-reasoner emits reasoning_content first; the original
   50-token cap leaves message.content empty and the test reports
   "API响应为空"; 10s also routinely cuts off reasoning.

2. _test_google_api: change retired default gemini-2.0-flash-exp to
   gemini-2.5-flash. The -exp model was a temporary preview and now
   404s; gemini-2.0-flash itself is also unavailable to new accounts.

3. _test_anthropic_api: accept model_name; default claude-3-haiku-20240307
   is deprecated and 404s. Use current GA claude-haiku-4-5 when caller
   doesn't pass a model.

4. test_llm_config: route anthropic to _test_anthropic_api. Previously
   anthropic fell through to the OpenAI-compatible /chat/completions
   path, which doesn't exist on api.anthropic.com (the real endpoint
   is /v1/messages with x-api-key + anthropic-version headers).

5. docker/nginx.conf: add `location /api/` proxy to backend:8000.
   Without it, the SPA's POST /api/* hits the static-file location
   and nginx returns 405, so login fails with "status code 405".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@qirobot qirobot force-pushed the fix/deepseek-reasoner-test branch from 84d6f96 to 4cd9420 Compare May 4, 2026 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant