refactor: optimize storage configuration priority and VLM configuration check logic
This commit is contained in:
@@ -177,7 +177,7 @@ class Caption:
|
|||||||
self.prompt = """简单凝炼的描述图片的主要内容"""
|
self.prompt = """简单凝炼的描述图片的主要内容"""
|
||||||
|
|
||||||
# Use provided VLM config if available, otherwise fall back to environment variables
|
# 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.completion_url = vlm_config.get("base_url", "") + "/chat/completions"
|
||||||
self.model = vlm_config.get("model_name", "")
|
self.model = vlm_config.get("model_name", "")
|
||||||
self.api_key = vlm_config.get("api_key", "")
|
self.api_key = vlm_config.get("api_key", "")
|
||||||
|
|||||||
@@ -203,22 +203,22 @@ class MinioStorage(Storage):
|
|||||||
prefer those values to override envs.
|
prefer those values to override envs.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
endpoint = os.getenv("MINIO_ENDPOINT")
|
if self.storage_config and self.storage_config.get("endpoint") and self.storage_config.get("bucket_name"):
|
||||||
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:
|
|
||||||
storage_config = self.storage_config
|
storage_config = self.storage_config
|
||||||
# Direct fields
|
# Direct fields
|
||||||
endpoint = storage_config.get("endpoint", endpoint)
|
endpoint = storage_config.get("endpoint")
|
||||||
bucket_name = storage_config.get("bucket_name", bucket_name)
|
bucket_name = storage_config.get("bucket_name")
|
||||||
path_prefix = storage_config.get("path_prefix", path_prefix).strip().strip("/")
|
path_prefix = storage_config.get("path_prefix").strip().strip("/")
|
||||||
access_key = storage_config.get("access_key_id", access_key)
|
access_key = storage_config.get("access_key_id")
|
||||||
secret_key = storage_config.get("secret_access_key", secret_key)
|
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]):
|
if not all([endpoint, access_key, secret_key, bucket_name]):
|
||||||
logger.error("Incomplete MinIO configuration, missing required environment variables")
|
logger.error("Incomplete MinIO configuration, missing required environment variables")
|
||||||
|
|||||||
Reference in New Issue
Block a user