refactor: simplify Gemini provider initialization using kwargs dict
As suggested by code review, this reduces code duplication and improves maintainability
This commit is contained in:
@@ -98,13 +98,11 @@ class ModelProviderRegistry:
|
|||||||
if not api_key:
|
if not api_key:
|
||||||
return None
|
return None
|
||||||
gemini_base_url = os.getenv("GEMINI_BASE_URL")
|
gemini_base_url = os.getenv("GEMINI_BASE_URL")
|
||||||
|
provider_kwargs = {"api_key": api_key}
|
||||||
if gemini_base_url:
|
if gemini_base_url:
|
||||||
# Initialize with custom endpoint
|
provider_kwargs["base_url"] = gemini_base_url
|
||||||
provider = provider_class(api_key=api_key, base_url=gemini_base_url)
|
|
||||||
logging.info(f"Initialized Gemini provider with custom endpoint: {gemini_base_url}")
|
logging.info(f"Initialized Gemini provider with custom endpoint: {gemini_base_url}")
|
||||||
else:
|
provider = provider_class(**provider_kwargs)
|
||||||
# Use default Google endpoint
|
|
||||||
provider = provider_class(api_key=api_key)
|
|
||||||
else:
|
else:
|
||||||
if not api_key:
|
if not api_key:
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user