mirror of
https://github.com/Monadical-SAS/cubbi.git
synced 2025-12-20 12:19:07 +00:00
fix: cubbi configure not working when configuring other provider (#32)
This commit is contained in:
@@ -75,7 +75,11 @@ class ProviderConfigurator:
|
|||||||
# Add existing providers
|
# Add existing providers
|
||||||
for name, config in providers.items():
|
for name, config in providers.items():
|
||||||
provider_type = config.get("type", "unknown")
|
provider_type = config.get("type", "unknown")
|
||||||
choices.append(f"{name} ({provider_type})")
|
base_url = config.get("base_url")
|
||||||
|
if base_url:
|
||||||
|
choices.append(f"{name} ({provider_type}) - {base_url}")
|
||||||
|
else:
|
||||||
|
choices.append(f"{name} ({provider_type})")
|
||||||
|
|
||||||
# Add separator and options
|
# Add separator and options
|
||||||
if choices:
|
if choices:
|
||||||
@@ -93,12 +97,13 @@ class ProviderConfigurator:
|
|||||||
self._add_new_provider()
|
self._add_new_provider()
|
||||||
else:
|
else:
|
||||||
# Extract provider name from the choice
|
# Extract provider name from the choice
|
||||||
# Format: "provider_name (provider_type)"
|
# Format: "provider_name (provider_type)" or "provider_name (provider_type) - base_url"
|
||||||
provider_name = choice.split(" (")[0]
|
provider_name = choice.split(" (")[0]
|
||||||
self._edit_provider(provider_name)
|
self._edit_provider(provider_name)
|
||||||
|
|
||||||
def _add_new_provider(self) -> None:
|
def _add_new_provider(self) -> None:
|
||||||
"""Add a new provider configuration."""
|
"""Add a new provider configuration."""
|
||||||
|
OTHER = "Other (openai compatible)"
|
||||||
# Ask for provider type
|
# Ask for provider type
|
||||||
provider_type = questionary.select(
|
provider_type = questionary.select(
|
||||||
"Select provider type:",
|
"Select provider type:",
|
||||||
@@ -107,7 +112,7 @@ class ProviderConfigurator:
|
|||||||
"OpenAI",
|
"OpenAI",
|
||||||
"Google",
|
"Google",
|
||||||
"OpenRouter",
|
"OpenRouter",
|
||||||
"OpenAI-compatible (custom)",
|
OTHER,
|
||||||
],
|
],
|
||||||
).ask()
|
).ask()
|
||||||
|
|
||||||
@@ -120,13 +125,13 @@ class ProviderConfigurator:
|
|||||||
"OpenAI": "openai",
|
"OpenAI": "openai",
|
||||||
"Google": "google",
|
"Google": "google",
|
||||||
"OpenRouter": "openrouter",
|
"OpenRouter": "openrouter",
|
||||||
"Other (openai compatible)": "openai",
|
OTHER: "openai",
|
||||||
}
|
}
|
||||||
|
|
||||||
internal_type = type_mapping[provider_type]
|
internal_type = type_mapping[provider_type]
|
||||||
|
|
||||||
# Ask for provider name
|
# Ask for provider name
|
||||||
if provider_type == "OpenAI-compatible (custom)":
|
if provider_type == OTHER:
|
||||||
provider_name = questionary.text(
|
provider_name = questionary.text(
|
||||||
"Enter a name for this provider (e.g., 'litellm', 'local-llm'):",
|
"Enter a name for this provider (e.g., 'litellm', 'local-llm'):",
|
||||||
validate=lambda name: len(name.strip()) > 0
|
validate=lambda name: len(name.strip()) > 0
|
||||||
@@ -194,7 +199,7 @@ class ProviderConfigurator:
|
|||||||
return
|
return
|
||||||
|
|
||||||
base_url = None
|
base_url = None
|
||||||
if internal_type == "openai" and provider_type == "OpenAI-compatible (custom)":
|
if internal_type == "openai" and provider_type == OTHER:
|
||||||
base_url = questionary.text(
|
base_url = questionary.text(
|
||||||
"Base URL for API calls:",
|
"Base URL for API calls:",
|
||||||
validate=lambda url: url.startswith("http")
|
validate=lambda url: url.startswith("http")
|
||||||
@@ -268,7 +273,11 @@ class ProviderConfigurator:
|
|||||||
provider_type = provider_config.get("type", "unknown")
|
provider_type = provider_config.get("type", "unknown")
|
||||||
has_key = bool(provider_config.get("api_key"))
|
has_key = bool(provider_config.get("api_key"))
|
||||||
if has_key:
|
if has_key:
|
||||||
choices.append(f"{provider_name} ({provider_type})")
|
base_url = provider_config.get("base_url")
|
||||||
|
if base_url:
|
||||||
|
choices.append(f"{provider_name} ({provider_type}) - {base_url}")
|
||||||
|
else:
|
||||||
|
choices.append(f"{provider_name} ({provider_type})")
|
||||||
|
|
||||||
if not choices:
|
if not choices:
|
||||||
console.print("[yellow]No providers with API keys configured.[/yellow]")
|
console.print("[yellow]No providers with API keys configured.[/yellow]")
|
||||||
@@ -316,8 +325,12 @@ class ProviderConfigurator:
|
|||||||
console.print("\n[bold]Providers[/bold]")
|
console.print("\n[bold]Providers[/bold]")
|
||||||
providers = self.user_config.list_providers()
|
providers = self.user_config.list_providers()
|
||||||
if providers:
|
if providers:
|
||||||
for name in providers.keys():
|
for name, config in providers.items():
|
||||||
console.print(f" - {name}")
|
base_url = config.get("base_url")
|
||||||
|
if base_url:
|
||||||
|
console.print(f" - {name} ({base_url})")
|
||||||
|
else:
|
||||||
|
console.print(f" - {name}")
|
||||||
else:
|
else:
|
||||||
console.print(" (no providers configured)")
|
console.print(" (no providers configured)")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user