mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 22:04:46 +00:00
Fix slow /model selector by deferring OAuth token refresh
getAvailable() now uses hasAuth() which checks if auth is configured without triggering OAuth token refresh. Refresh happens later when the model is actually used.
This commit is contained in:
parent
1007dca564
commit
17b3a14bfa
3 changed files with 18 additions and 11 deletions
|
|
@ -350,17 +350,11 @@ export class ModelRegistry {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get only models that have valid API keys available.
|
||||
* Get only models that have auth configured.
|
||||
* This is a fast check that doesn't refresh OAuth tokens.
|
||||
*/
|
||||
async getAvailable(): Promise<Model<Api>[]> {
|
||||
const available: Model<Api>[] = [];
|
||||
for (const model of this.models) {
|
||||
const apiKey = await this.authStorage.getApiKey(model.provider);
|
||||
if (apiKey) {
|
||||
available.push(model);
|
||||
}
|
||||
}
|
||||
return available;
|
||||
getAvailable(): Model<Api>[] {
|
||||
return this.models.filter((m) => this.authStorage.hasAuth(m.provider));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue