diff --git a/modules/ocr_client.py b/modules/ocr_client.py index 03a5d81..3ad7537 100644 --- a/modules/ocr_client.py +++ b/modules/ocr_client.py @@ -5,6 +5,7 @@ import mimetypes from pathlib import Path from typing import Dict, List +import httpx from openai import OpenAI from config import OCR_API_BASE_URL, OCR_API_KEY, OCR_MODEL_ID, OCR_MAX_TOKENS @@ -23,9 +24,12 @@ class OCRClient: if not base_url.endswith("/v1"): base_url = f"{base_url}/v1" + # httpx 0.28 起不再支持 proxies 参数,显式传入 http_client 以避免默认封装报错 + self.http_client = httpx.Client() self.client = OpenAI( api_key=OCR_API_KEY, base_url=base_url, + http_client=self.http_client, ) self.model = OCR_MODEL_ID or "deepseek-ai/DeepSeek-OCR" self.max_tokens = OCR_MAX_TOKENS or 4096 diff --git a/sub_agent/modules/ocr_client.py b/sub_agent/modules/ocr_client.py index 957e5b4..9abe2c7 100644 --- a/sub_agent/modules/ocr_client.py +++ b/sub_agent/modules/ocr_client.py @@ -5,6 +5,7 @@ import mimetypes from pathlib import Path from typing import Dict, List +import httpx from openai import OpenAI from config import OCR_API_BASE_URL, OCR_API_KEY, OCR_MODEL_ID, OCR_MAX_TOKENS @@ -22,9 +23,11 @@ class OCRClient: if not base_url.endswith("/v1"): base_url = f"{base_url}/v1" + self.http_client = httpx.Client() self.client = OpenAI( api_key=OCR_API_KEY, base_url=base_url, + http_client=self.http_client, ) self.model = OCR_MODEL_ID or "deepseek-ai/DeepSeek-OCR" self.max_tokens = OCR_MAX_TOKENS or 4096