mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-05 20:46:43 +00:00
Merge pull request #715 from meetpateltech/perplexity-models
feat: added perplexity model
This commit is contained in:
commit
b06f6e3a3e
@ -70,6 +70,11 @@ LMSTUDIO_API_BASE_URL=
|
|||||||
# You only need this environment variable set if you want to use xAI models
|
# You only need this environment variable set if you want to use xAI models
|
||||||
XAI_API_KEY=
|
XAI_API_KEY=
|
||||||
|
|
||||||
|
# Get your Perplexity API Key here -
|
||||||
|
# https://www.perplexity.ai/settings/api
|
||||||
|
# You only need this environment variable set if you want to use Perplexity models
|
||||||
|
PERPLEXITY_API_KEY=
|
||||||
|
|
||||||
# Include this environment variable if you want more logging for debugging locally
|
# Include this environment variable if you want more logging for debugging locally
|
||||||
VITE_LOG_LEVEL=debug
|
VITE_LOG_LEVEL=debug
|
||||||
|
|
||||||
|
@ -39,6 +39,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string, userApiKeys?: Re
|
|||||||
return env.TOGETHER_API_KEY || cloudflareEnv.TOGETHER_API_KEY;
|
return env.TOGETHER_API_KEY || cloudflareEnv.TOGETHER_API_KEY;
|
||||||
case 'xAI':
|
case 'xAI':
|
||||||
return env.XAI_API_KEY || cloudflareEnv.XAI_API_KEY;
|
return env.XAI_API_KEY || cloudflareEnv.XAI_API_KEY;
|
||||||
|
case 'Perplexity':
|
||||||
|
return env.PERPLEXITY_API_KEY || cloudflareEnv.PERPLEXITY_API_KEY;
|
||||||
case 'Cohere':
|
case 'Cohere':
|
||||||
return env.COHERE_API_KEY;
|
return env.COHERE_API_KEY;
|
||||||
case 'AzureOpenAI':
|
case 'AzureOpenAI':
|
||||||
|
@ -128,6 +128,15 @@ export function getXAIModel(apiKey: OptionalApiKey, model: string) {
|
|||||||
return openai(model);
|
return openai(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getPerplexityModel(apiKey: OptionalApiKey, model: string) {
|
||||||
|
const perplexity = createOpenAI({
|
||||||
|
baseURL: 'https://api.perplexity.ai/',
|
||||||
|
apiKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
return perplexity(model);
|
||||||
|
}
|
||||||
|
|
||||||
export function getModel(
|
export function getModel(
|
||||||
provider: string,
|
provider: string,
|
||||||
model: string,
|
model: string,
|
||||||
@ -170,6 +179,8 @@ export function getModel(
|
|||||||
return getXAIModel(apiKey, model);
|
return getXAIModel(apiKey, model);
|
||||||
case 'Cohere':
|
case 'Cohere':
|
||||||
return getCohereAIModel(apiKey, model);
|
return getCohereAIModel(apiKey, model);
|
||||||
|
case 'Perplexity':
|
||||||
|
return getPerplexityModel(apiKey, model);
|
||||||
default:
|
default:
|
||||||
return getOllamaModel(baseURL, model);
|
return getOllamaModel(baseURL, model);
|
||||||
}
|
}
|
||||||
|
@ -293,6 +293,30 @@ const PROVIDER_LIST: ProviderInfo[] = [
|
|||||||
],
|
],
|
||||||
getApiKeyLink: 'https://api.together.xyz/settings/api-keys',
|
getApiKeyLink: 'https://api.together.xyz/settings/api-keys',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Perplexity',
|
||||||
|
staticModels: [
|
||||||
|
{
|
||||||
|
name: 'llama-3.1-sonar-small-128k-online',
|
||||||
|
label: 'Sonar Small Online',
|
||||||
|
provider: 'Perplexity',
|
||||||
|
maxTokenAllowed: 8192,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'llama-3.1-sonar-large-128k-online',
|
||||||
|
label: 'Sonar Large Online',
|
||||||
|
provider: 'Perplexity',
|
||||||
|
maxTokenAllowed: 8192,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'llama-3.1-sonar-huge-128k-online',
|
||||||
|
label: 'Sonar Huge Online',
|
||||||
|
provider: 'Perplexity',
|
||||||
|
maxTokenAllowed: 8192,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
getApiKeyLink: 'https://www.perplexity.ai/settings/api',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
export const DEFAULT_PROVIDER = PROVIDER_LIST[0];
|
export const DEFAULT_PROVIDER = PROVIDER_LIST[0];
|
||||||
|
1
worker-configuration.d.ts
vendored
1
worker-configuration.d.ts
vendored
@ -14,4 +14,5 @@ interface Env {
|
|||||||
GOOGLE_GENERATIVE_AI_API_KEY: string;
|
GOOGLE_GENERATIVE_AI_API_KEY: string;
|
||||||
MISTRAL_API_KEY: string;
|
MISTRAL_API_KEY: string;
|
||||||
XAI_API_KEY: string;
|
XAI_API_KEY: string;
|
||||||
|
PERPLEXITY_API_KEY: string;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user