Infer the active provider and rough capability set using the registry.
(settings: Settings)
| 40 | |
| 41 | |
| 42 | def detect_provider(settings: Settings) -> ProviderInfo: |
| 43 | """Infer the active provider and rough capability set using the registry.""" |
| 44 | if settings.provider == "openai_codex": |
| 45 | return ProviderInfo( |
| 46 | name="openai-codex", |
| 47 | auth_kind="external_oauth", |
| 48 | voice_supported=False, |
| 49 | voice_reason=_VOICE_REASON["openai_codex"], |
| 50 | ) |
| 51 | if settings.provider == "anthropic_claude": |
| 52 | return ProviderInfo( |
| 53 | name="claude-subscription", |
| 54 | auth_kind="external_oauth", |
| 55 | voice_supported=False, |
| 56 | voice_reason=_VOICE_REASON["anthropic_claude"], |
| 57 | ) |
| 58 | if settings.api_format == "copilot": |
| 59 | return ProviderInfo( |
| 60 | name="github_copilot", |
| 61 | auth_kind="oauth_device", |
| 62 | voice_supported=False, |
| 63 | voice_reason=_VOICE_REASON["copilot"], |
| 64 | ) |
| 65 | |
| 66 | spec = detect_provider_from_registry( |
| 67 | model=settings.model, |
| 68 | api_key=settings.api_key or None, |
| 69 | base_url=settings.base_url, |
| 70 | ) |
| 71 | |
| 72 | if spec is not None: |
| 73 | backend = spec.backend_type |
| 74 | return ProviderInfo( |
| 75 | name=spec.name, |
| 76 | auth_kind=_AUTH_KIND.get(backend, "api_key"), |
| 77 | voice_supported=False, |
| 78 | voice_reason=_VOICE_REASON.get(backend, "voice mode is not supported for this provider"), |
| 79 | ) |
| 80 | |
| 81 | # Fallback: use api_format to pick a sensible default |
| 82 | if settings.api_format == "openai": |
| 83 | return ProviderInfo( |
| 84 | name="openai-compatible", |
| 85 | auth_kind="api_key", |
| 86 | voice_supported=False, |
| 87 | voice_reason=_VOICE_REASON["openai_compat"], |
| 88 | ) |
| 89 | return ProviderInfo( |
| 90 | name="anthropic", |
| 91 | auth_kind="api_key", |
| 92 | voice_supported=False, |
| 93 | voice_reason=_VOICE_REASON["anthropic"], |
| 94 | ) |
| 95 | |
| 96 | |
| 97 | def auth_status(settings: Settings) -> str: |
no test coverage detected