From 76de5cf496b0b4cedf7f970f576da407db65bc25 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 29 Jan 2026 11:48:44 +0000 Subject: [PATCH 1/2] fix: remove explicit proxy settings to use transparent gateway --- ecosystem.config.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ecosystem.config.js b/ecosystem.config.js index 3130135..2dceac1 100644 --- a/ecosystem.config.js +++ b/ecosystem.config.js @@ -6,13 +6,17 @@ module.exports = { args: "-m uvicorn backend.app.main:app --host 0.0.0.0 --port 8000", cwd: "./", env: { - PYTHONPATH: "./backend" + PYTHONPATH: "./backend", + // HTTP_PROXY: "http://192.168.3.91:7893", + // HTTPS_PROXY: "http://192.168.3.91:7893", + // http_proxy: "http://192.168.3.91:7893", + // https_proxy: "http://192.168.3.91:7893" } }, { name: "datafetch-frontend", script: "npm", - args: "run dev", // 生产环境建议改为 "start" 并先运行 npm run build + args: "run dev", cwd: "./frontend", env: { NODE_ENV: "development" From 1a04e924827f81fab7ceb4c9923eb2b597def1d7 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 29 Jan 2026 11:49:48 +0000 Subject: [PATCH 2/2] update: backend logic changes --- backend/app/api/chat_routes.py | 14 +++++++++----- backend/app/services/analysis_service.py | 13 +++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/backend/app/api/chat_routes.py b/backend/app/api/chat_routes.py index b640446..68de157 100644 --- a/backend/app/api/chat_routes.py +++ b/backend/app/api/chat_routes.py @@ -58,11 +58,15 @@ async def chat_with_ai(request: ChatRequest, background_tasks: BackgroundTasks = tools.append(types.Tool(google_search=types.GoogleSearch())) final_system_prompt += "\n\n[SYSTEM INSTRUCTION] You have access to Google Search. You MUST use it to verify any data or find the latest information before answering. Do not rely solely on your internal knowledge." - config = types.GenerateContentConfig( - tools=tools if tools else None, - temperature=0.1, - system_instruction=final_system_prompt - ) + # Build config - only set system_instruction if it has content + config_params = { + "tools": tools if tools else None, + "temperature": 0.1 + } + if final_system_prompt and final_system_prompt.strip(): + config_params["system_instruction"] = final_system_prompt + + config = types.GenerateContentConfig(**config_params) start_time = time.time() diff --git a/backend/app/services/analysis_service.py b/backend/app/services/analysis_service.py index e711ca1..1cd254b 100644 --- a/backend/app/services/analysis_service.py +++ b/backend/app/services/analysis_service.py @@ -22,6 +22,19 @@ def get_genai_client() -> genai.Client: api_key = os.getenv('GEMINI_API_KEY') if not api_key: raise ValueError("GEMINI_API_KEY environment variable is not set") + + # Configure httpx proxy globally by monkey-patching + import httpx + proxy_url = os.getenv('https_proxy') or os.getenv('HTTPS_PROXY') + if proxy_url: + # Monkey-patch httpx to use proxy with SSL verification disabled + original_init = httpx.Client.__init__ + def patched_init(self, **kwargs): + kwargs.setdefault('proxy', proxy_url) + kwargs.setdefault('verify', False) + return original_init(self, **kwargs) + httpx.Client.__init__ = patched_init + _client = genai.Client(api_key=api_key) return _client