feat: implement provider deactivation and enhance configuration updates
- Added a new function to deactivate the active provider without deleting credentials, facilitating smoother transitions between different provider types. - Updated the model flow logic to ensure the active provider is correctly set in the configuration, including handling custom endpoints and OAuth providers. - Improved error handling in the CLI to consistently format authentication error messages. - Enhanced the model selection process to reflect the effective provider based on configuration and environment variables.
This commit is contained in:
parent
77a3dda59d
commit
a3d760ff12
3 changed files with 62 additions and 13 deletions
|
|
@ -261,6 +261,18 @@ def clear_provider_auth(provider_id: Optional[str] = None) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def deactivate_provider() -> None:
|
||||
"""
|
||||
Clear active_provider in auth.json without deleting credentials.
|
||||
Used when the user switches to a non-OAuth provider (OpenRouter, custom)
|
||||
so auto-resolution doesn't keep picking the OAuth provider.
|
||||
"""
|
||||
with _auth_store_lock():
|
||||
auth_store = _load_auth_store()
|
||||
auth_store["active_provider"] = None
|
||||
_save_auth_store(auth_store)
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Provider Resolution — picks which provider to use
|
||||
# =============================================================================
|
||||
|
|
@ -799,7 +811,14 @@ def get_auth_status(provider_id: Optional[str] = None) -> Dict[str, Any]:
|
|||
# =============================================================================
|
||||
|
||||
def _update_config_for_provider(provider_id: str, inference_base_url: str) -> Path:
|
||||
"""Update config.yaml to reflect the active provider after login."""
|
||||
"""Update config.yaml and auth.json to reflect the active provider."""
|
||||
# Set active_provider in auth.json so auto-resolution picks this provider
|
||||
with _auth_store_lock():
|
||||
auth_store = _load_auth_store()
|
||||
auth_store["active_provider"] = provider_id
|
||||
_save_auth_store(auth_store)
|
||||
|
||||
# Update config.yaml model section
|
||||
config_path = get_config_path()
|
||||
config_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue