somratpro Claude Sonnet 4.6 commited on
Commit
28f94e0
Β·
1 Parent(s): d89d9d5

fix: silence noisy backend logs + fix gemini key field name

Browse files

- Fix API_KEY_FIELD google→google_api_key (was gemini_api_key):
eliminates 4x UserWarning per LLM call from langchain-google-genai
- Remove duplicate GEMINI_API_KEY export (keep only GOOGLE_API_KEY):
eliminates "Both GOOGLE_API_KEY and GEMINI_API_KEY are set" warning
- Add uvicorn log-config: suppress INFO noise from google_genai,
httpx, primp, ddgs loggers (silence AFC/retry/response spam)
- Suppress pydantic UserWarnings via PYTHONWARNINGS
- nginx: access_log off for /health (suppress keepalive ping noise)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (2) hide show
  1. nginx.conf +1 -0
  2. start.sh +38 -2
nginx.conf CHANGED
@@ -86,6 +86,7 @@ http {
86
 
87
  # ── Health check ──────────────────────────────────────────
88
  location = /health {
 
89
  proxy_pass http://127.0.0.1:8001/health;
90
  proxy_http_version 1.1;
91
  proxy_set_header Host $host;
 
86
 
87
  # ── Health check ──────────────────────────────────────────
88
  location = /health {
89
+ access_log off;
90
  proxy_pass http://127.0.0.1:8001/health;
91
  proxy_http_version 1.1;
92
  proxy_set_header Host $host;
start.sh CHANGED
@@ -116,10 +116,9 @@ case "$LLM_PROVIDER" in
116
  SUPPORTS_THINKING="true"
117
  ;;
118
  google|gemini)
119
- export GEMINI_API_KEY="${GEMINI_API_KEY:-$LLM_API_KEY}"
120
  export GOOGLE_API_KEY="${GOOGLE_API_KEY:-$LLM_API_KEY}"
121
  LANGCHAIN_CLASS="langchain_google_genai:ChatGoogleGenerativeAI"
122
- API_KEY_FIELD="gemini_api_key"
123
  LLM_MODEL_NAME="${LLM_MODEL_NAME:-$LLM_PROVIDER}"
124
  SUPPORTS_THINKING="true"
125
  ;;
@@ -377,16 +376,53 @@ nginx -t 2>/dev/null && nginx || {
377
  exit 1
378
  }
379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
380
  # ── Start backend (uvicorn) ───────────────────────────────────────
381
  echo "Starting DeerFlow backend on port $BACKEND_PORT..."
382
  (
383
  cd "$APP_DIR/backend" && \
384
  PYTHONPATH=. \
 
385
  uv run --no-sync \
386
  uvicorn app.gateway.app:app \
387
  --host 127.0.0.1 \
388
  --port "$BACKEND_PORT" \
389
  --workers 1 \
 
390
  2>&1 | tee -a "$DATA_DIR/logs/backend.log"
391
  ) &
392
  BACKEND_PID=$!
 
116
  SUPPORTS_THINKING="true"
117
  ;;
118
  google|gemini)
 
119
  export GOOGLE_API_KEY="${GOOGLE_API_KEY:-$LLM_API_KEY}"
120
  LANGCHAIN_CLASS="langchain_google_genai:ChatGoogleGenerativeAI"
121
+ API_KEY_FIELD="google_api_key"
122
  LLM_MODEL_NAME="${LLM_MODEL_NAME:-$LLM_PROVIDER}"
123
  SUPPORTS_THINKING="true"
124
  ;;
 
376
  exit 1
377
  }
378
 
379
+ # ── Logging config: silence per-request noise ────────────────────
380
+ cat > /tmp/logging-config.json << 'LOGEOF'
381
+ {
382
+ "version": 1,
383
+ "disable_existing_loggers": false,
384
+ "formatters": {
385
+ "default": {
386
+ "()": "uvicorn.logging.DefaultFormatter",
387
+ "fmt": "%(levelprefix)s %(message)s",
388
+ "use_colors": null
389
+ },
390
+ "access": {
391
+ "()": "uvicorn.logging.AccessFormatter",
392
+ "fmt": "%(levelprefix)s %(client_addr)s - \"%(request_line)s\" %(status_code)s"
393
+ }
394
+ },
395
+ "handlers": {
396
+ "default": {"formatter": "default", "class": "logging.StreamHandler", "stream": "ext://sys.stdout"},
397
+ "access": {"formatter": "access", "class": "logging.StreamHandler", "stream": "ext://sys.stdout"}
398
+ },
399
+ "loggers": {
400
+ "uvicorn": {"handlers": ["default"], "level": "INFO", "propagate": false},
401
+ "uvicorn.error": {"level": "INFO"},
402
+ "uvicorn.access": {"handlers": ["access"], "level": "INFO", "propagate": false},
403
+ "google_genai": {"level": "WARNING"},
404
+ "google_genai.models": {"level": "WARNING"},
405
+ "google_genai._api_client": {"level": "WARNING"},
406
+ "httpx": {"level": "WARNING"},
407
+ "primp": {"level": "WARNING"},
408
+ "ddgs": {"level": "WARNING"}
409
+ },
410
+ "root": {"level": "INFO", "handlers": ["default"]}
411
+ }
412
+ LOGEOF
413
+
414
  # ── Start backend (uvicorn) ───────────────────────────────────────
415
  echo "Starting DeerFlow backend on port $BACKEND_PORT..."
416
  (
417
  cd "$APP_DIR/backend" && \
418
  PYTHONPATH=. \
419
+ PYTHONWARNINGS="ignore::UserWarning:pydantic" \
420
  uv run --no-sync \
421
  uvicorn app.gateway.app:app \
422
  --host 127.0.0.1 \
423
  --port "$BACKEND_PORT" \
424
  --workers 1 \
425
+ --log-config /tmp/logging-config.json \
426
  2>&1 | tee -a "$DATA_DIR/logs/backend.log"
427
  ) &
428
  BACKEND_PID=$!