refactor: optimize storage configuration priority and VLM configuration check logic

This commit is contained in:
begoniezhao
2025-08-15 17:22:58 +08:00
committed by lyingbug
parent c97bf0de11
commit 20049d034a
2 changed files with 15 additions and 15 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ class Caption:
self.prompt = """简单凝炼的描述图片的主要内容"""
# Use provided VLM config if available, otherwise fall back to environment variables
if vlm_config:
if vlm_config and vlm_config.get("base_url") and vlm_config.get("model_name"):
self.completion_url = vlm_config.get("base_url", "") + "/chat/completions"
self.model = vlm_config.get("model_name", "")
self.api_key = vlm_config.get("api_key", "")
+14 -14
View File
@@ -203,22 +203,22 @@ class MinioStorage(Storage):
prefer those values to override envs.
"""
try:
endpoint = os.getenv("MINIO_ENDPOINT")
access_key = os.getenv("MINIO_ACCESS_KEY_ID")
secret_key = os.getenv("MINIO_SECRET_ACCESS_KEY")
bucket_name = os.getenv("MINIO_BUCKET_NAME")
use_ssl = os.getenv("MINIO_USE_SSL", "false").lower() == "true"
path_prefix = os.getenv("MINIO_PATH_PREFIX", "").strip().strip("/")
# Attempt to override with new generic storage fields
if self.storage_config:
if self.storage_config and self.storage_config.get("endpoint") and self.storage_config.get("bucket_name"):
storage_config = self.storage_config
# Direct fields
endpoint = storage_config.get("endpoint", endpoint)
bucket_name = storage_config.get("bucket_name", bucket_name)
path_prefix = storage_config.get("path_prefix", path_prefix).strip().strip("/")
access_key = storage_config.get("access_key_id", access_key)
secret_key = storage_config.get("secret_access_key", secret_key)
endpoint = storage_config.get("endpoint")
bucket_name = storage_config.get("bucket_name")
path_prefix = storage_config.get("path_prefix").strip().strip("/")
access_key = storage_config.get("access_key_id")
secret_key = storage_config.get("secret_access_key")
else:
endpoint = os.getenv("MINIO_ENDPOINT")
access_key = os.getenv("MINIO_ACCESS_KEY_ID")
secret_key = os.getenv("MINIO_SECRET_ACCESS_KEY")
bucket_name = os.getenv("MINIO_BUCKET_NAME")
use_ssl = os.getenv("MINIO_USE_SSL", "false").lower() == "true"
path_prefix = os.getenv("MINIO_PATH_PREFIX", "").strip().strip("/")
if not all([endpoint, access_key, secret_key, bucket_name]):
logger.error("Incomplete MinIO configuration, missing required environment variables")