From 0840f35408dcb0c278c725638cccf4ceca378d00 Mon Sep 17 00:00:00 2001 From: Wang Defa Date: Tue, 9 Dec 2025 20:10:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20OCI=20=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AF=E8=B6=85=E6=97=B6=E8=AE=BE=E7=BD=AE=EF=BC=8C=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E8=BF=9E=E6=8E=A5=E5=92=8C=E8=AF=BB=E5=8F=96=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 7 +++++++ src/core/config.py | 2 ++ src/core/oci_client.py | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 6366707..99764ae 100644 --- a/.env.example +++ b/.env.example @@ -29,6 +29,13 @@ OCI_CONFIG_PROFILE=DEFAULT # Authentication type: api_key or instance_principal OCI_AUTH_TYPE=api_key +# OCI Client Timeout Settings +# Connect timeout: Maximum time (in seconds) to establish connection to OCI API +OCI_CONNECT_TIMEOUT=10 +# Read timeout: Maximum time (in seconds) to wait for OCI API response +# Increase this value for long-running requests (e.g., complex conversations) +OCI_READ_TIMEOUT=360 + # Optional: Direct endpoint for dedicated models # GENAI_ENDPOINT=https://your-dedicated-endpoint diff --git a/src/core/config.py b/src/core/config.py index c9f9107..9106145 100644 --- a/src/core/config.py +++ b/src/core/config.py @@ -41,6 +41,8 @@ class Settings(BaseSettings): oci_config_file: str = "~/.oci/config" oci_config_profile: str = "DEFAULT" # 支持多个profile,用逗号分隔,例如:DEFAULT,CHICAGO,ASHBURN oci_auth_type: str = "api_key" # api_key or instance_principal + oci_connect_timeout: int = 10 # Connection timeout in seconds + oci_read_timeout: int = 360 # Read timeout in seconds (6 minutes) # GenAI Service Settings genai_endpoint: Optional[str] = None diff --git a/src/core/oci_client.py b/src/core/oci_client.py index e56152a..bc1d936 100644 --- a/src/core/oci_client.py +++ b/src/core/oci_client.py @@ -170,7 +170,7 @@ class OCIGenAIClient: config=config, service_endpoint=inference_endpoint, retry_strategy=oci.retry.NoneRetryStrategy(), - timeout=(10, 240) + timeout=(self.settings.oci_connect_timeout, self.settings.oci_read_timeout) ) return client