新增 OCI 客户端超时设置,支持连接和读取超时配置
All checks were successful
Build and Push OCI GenAI Gateway Docker Image / docker-build-push (push) Successful in 35s

This commit is contained in:
2025-12-09 20:10:14 +08:00
parent 1ba999bf4f
commit 0840f35408
3 changed files with 10 additions and 1 deletions

View File

@@ -29,6 +29,13 @@ OCI_CONFIG_PROFILE=DEFAULT
# Authentication type: api_key or instance_principal # Authentication type: api_key or instance_principal
OCI_AUTH_TYPE=api_key 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 # Optional: Direct endpoint for dedicated models
# GENAI_ENDPOINT=https://your-dedicated-endpoint # GENAI_ENDPOINT=https://your-dedicated-endpoint

View File

@@ -41,6 +41,8 @@ class Settings(BaseSettings):
oci_config_file: str = "~/.oci/config" oci_config_file: str = "~/.oci/config"
oci_config_profile: str = "DEFAULT" # 支持多个profile用逗号分隔例如DEFAULT,CHICAGO,ASHBURN oci_config_profile: str = "DEFAULT" # 支持多个profile用逗号分隔例如DEFAULT,CHICAGO,ASHBURN
oci_auth_type: str = "api_key" # api_key or instance_principal 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 Service Settings
genai_endpoint: Optional[str] = None genai_endpoint: Optional[str] = None

View File

@@ -170,7 +170,7 @@ class OCIGenAIClient:
config=config, config=config,
service_endpoint=inference_endpoint, service_endpoint=inference_endpoint,
retry_strategy=oci.retry.NoneRetryStrategy(), retry_strategy=oci.retry.NoneRetryStrategy(),
timeout=(10, 240) timeout=(self.settings.oci_connect_timeout, self.settings.oci_read_timeout)
) )
return client return client