refactor: add ModelRegistry.getApiKeyForProvider() for cleaner abstraction
This commit is contained in:
@@ -375,6 +375,13 @@ export class ModelRegistry {
|
|||||||
return this.authStorage.getApiKey(model.provider);
|
return this.authStorage.getApiKey(model.provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get API key for a provider.
|
||||||
|
*/
|
||||||
|
async getApiKeyForProvider(provider: string): Promise<string | undefined> {
|
||||||
|
return this.authStorage.getApiKey(provider);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a model is using OAuth credentials (subscription).
|
* Check if a model is using OAuth credentials (subscription).
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -635,7 +635,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
|||||||
if (!resolvedProvider) {
|
if (!resolvedProvider) {
|
||||||
throw new Error("No model selected");
|
throw new Error("No model selected");
|
||||||
}
|
}
|
||||||
const key = await modelRegistry.authStorage.getApiKey(resolvedProvider);
|
const key = await modelRegistry.getApiKeyForProvider(resolvedProvider);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
throw new Error(`No API key found for provider "${resolvedProvider}"`);
|
throw new Error(`No API key found for provider "${resolvedProvider}"`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user