wodongdong commited on
Commit
ed37209
·
verified ·
1 Parent(s): 31e38d8

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -4
Dockerfile CHANGED
@@ -10,10 +10,18 @@ WORKDIR /app
10
 
11
  RUN uv sync
12
 
13
- # 使用sed命令修改main.py文件
14
- RUN sed -i 's/await gemini_client.init(timeout=300)/await gemini_client.init(timeout=3000)/g' /app/main.py
15
-
16
- # 使用cat命令打印main.py内容到日志(构建时日志)
 
 
 
 
 
 
 
 
17
  RUN cat /app/main.py
18
 
19
  # Command to run the application
 
10
 
11
  RUN uv sync
12
 
13
+ # 修改main.py文件
14
+ RUN sed -i 's/await gemini_client.init(timeout=300)/await gemini_client.init(timeout=5000)/g' /app/main.py
15
+ RUN sed -i 's/response = await gemini_client.generate_content(/response = await gemini_client.generate_content( , timeout=5000)/g' /app/main.py # 调整为实际
16
+ RUN sed -i '/import logging/a\import httpx\nfrom tenacity import retry, stop_after_attempt, wait_exponential' /app/main.py
17
+ RUN sed -i '/async def create_chat_completion(/a\ @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))\n async def safe_generate_content(*args, **kwargs):\n return await gemini_client.generate_content(*args, **kwargs)' /app/main.py
18
+ RUN sed -i 's/response = await gemini_client.generate_content(/response = await safe_generate_content(/g' /app/main.py
19
+ RUN sed -i '/response = await/a\ logger.info("Starting generate_content request with timeout=5000")\n try:' /app/main.py
20
+ RUN sed -i '/response = await/a\ except httpx.ReadTimeout as e:\n logger.error(f"httpx ReadTimeout: {str(e)}")\n except Exception as e:\n logger.error(f"Error: {str(e)}", exc_info=True)' /app/main.py
21
+ # 网络和凭证测试
22
+ RUN curl -I https://generativelanguage.googleapis.com || echo "Network test failed"
23
+ RUN echo "Checking credentials..." && [ -n "$SECURE_1PSID" ] && echo "SECURE_1PSID is set" || echo "SECURE_1PSID is not set"
24
+ # 打印main.py内容以验证
25
  RUN cat /app/main.py
26
 
27
  # Command to run the application