mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
feat: add ChatGPT Subscription provider (#2876)
* feat: Add ChatGPT Subscription support and related features - Introduced a new provider option for ChatGPT Subscription in the endpoint selection UI. - Implemented OAuth flow for ChatGPT Subscription sign-in, including polling for authorization status. - Updated admin interface to handle ChatGPT Subscription, including disabling API key input and providing user guidance. - Enhanced cost tracking logic to differentiate between subscription and non-subscription endpoints. - Added new slash commands for managing skills, including listing, searching, and invoking skills. - Implemented caching for skill catalog to optimize performance. - Updated tests to cover new ChatGPT Subscription functionality and ensure proper endpoint probing. - Refactored existing code to accommodate new features and improve maintainability. * refactor: share provider device-flow setup - reuse one device-flow backend for Copilot and ChatGPT Subscription - add one frontend device-flow helper for Settings and /setup - put GitHub Copilot back into Add Models, now as a dropdown option - make provider selection just select; clicking Add starts sign-in - stop ChatGPT Subscription setup from opening auth tabs automatically - make /setup copilot and /setup chatgpt-subscription work from chat - show ChatGPT Subscription in the /setup suggestions - show the real error message when setup fails - add focused tests for the shared flow and setup UI * feat(chatgpt-subscription): harden credential lifecycle and streamline auth UX Backend: - Resolve runtime bearer for provider-auth endpoints at probe time via a shared _resolve_probe_key() that delegates to resolve_endpoint_runtime, applied across all probe/refresh call sites. - Skip live completion probes and health pings for discovery-only providers (centralized behind _is_discovery_only_provider) — the Codex/Responses API has no such endpoints, so status is derived from cached models. - Never persist the short lived ChatGPT bearer to the plaintext sessions table; proactively clear any stale bearer left by an earlier code path. - Revoke orphaned ProviderAuthSession credentials when the last endpoint backing them is deleted (_delete_orphaned_provider_auth), surfaced via cleared_provider_auth in the delete response. Frontend (admin.js): - Auto-start the device-auth flow on provider selection so the authorization panel (code + Authorize) shows immediately instead of behind a "Sign in" click. - Remove the redundant top button for device auth providers, move retry into the panel via an inline "Try again". - Drop the self-evident hint text and add an execCommand clipboard fallback so Copy works in non-secure (HTTP/LAN) contexts. * fix: harden chatgpt subscription provider * chore: remove PR media from branch * Fix chatgpt subscription recovery and token handling --------- Co-authored-by: 5p00kyy <admin@5p00ky.dev>
This commit is contained in:
@@ -24,7 +24,7 @@ _sd = types.ModuleType("src.database")
|
||||
_sd.ModelEndpoint = MagicMock()
|
||||
sys.modules.setdefault("src.database", _sd)
|
||||
|
||||
from routes.research_routes import _owned_enabled_endpoint # noqa: E402
|
||||
from routes.research_routes import _owned_enabled_endpoint, _resolve_endpoint_runtime # noqa: E402
|
||||
|
||||
|
||||
class _Predicate:
|
||||
@@ -129,3 +129,29 @@ def test_null_owner_is_legacy_single_user_noop():
|
||||
rows = [_ep("ep-x", "bob"), _ep("ep-y", "alice")]
|
||||
ep = _resolve(rows, None, "ep-x")
|
||||
assert ep is not None and ep.id == "ep-x"
|
||||
|
||||
|
||||
def test_runtime_resolution_uses_provider_auth_for_chatgpt_subscription(monkeypatch):
|
||||
ep = SimpleNamespace(
|
||||
id="ep-chatgpt",
|
||||
owner="alice",
|
||||
base_url="https://chatgpt.com/backend-api/codex",
|
||||
api_key=None,
|
||||
provider_auth_id="auth-1",
|
||||
cached_models='["gpt-5.5"]',
|
||||
hidden_models=None,
|
||||
)
|
||||
|
||||
monkeypatch.setattr(
|
||||
"src.chatgpt_subscription.resolve_runtime_credentials",
|
||||
lambda auth_id, owner=None: {
|
||||
"base_url": "https://chatgpt.com/backend-api/codex",
|
||||
"api_key": "fresh-access-token",
|
||||
},
|
||||
)
|
||||
|
||||
url, model, headers = _resolve_endpoint_runtime(ep, owner="alice", model="")
|
||||
|
||||
assert url == "https://chatgpt.com/backend-api/codex/responses"
|
||||
assert model == "gpt-5.5"
|
||||
assert headers["Authorization"] == "Bearer fresh-access-token"
|
||||
|
||||
Reference in New Issue
Block a user