Skip to content

Commit de00d54

Browse files
committed
Consolidates api providers into a common base
1 parent ef940c1 commit de00d54

10 files changed

+548
-1850
lines changed

src/ai/aiProviderService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export interface AIModel<
3636
> {
3737
readonly id: Model;
3838
readonly name: string;
39-
readonly maxTokens: number;
39+
readonly maxTokens: { input: number; output: number };
4040
readonly provider: {
4141
id: Provider;
4242
name: string;
@@ -580,11 +580,11 @@ async function confirmAIProviderToS<Provider extends AIProviders>(
580580

581581
export function getMaxCharacters(model: AIModel, outputLength: number): number {
582582
const tokensPerCharacter = 3.1;
583-
const max = model.maxTokens * tokensPerCharacter - outputLength / tokensPerCharacter;
583+
const max = model.maxTokens.input * tokensPerCharacter - outputLength / tokensPerCharacter;
584584
return Math.floor(max - max * 0.1);
585585
}
586586

587-
export async function getApiKey(
587+
export async function getOrPromptApiKey(
588588
storage: Storage,
589589
provider: { id: AIProviders; name: string; validator: (value: string) => boolean; url: string },
590590
): Promise<string | undefined> {

0 commit comments

Comments
 (0)