Meet Patel commited on
Commit
8bcd82c
·
1 Parent(s): 9666b2a

feat: added perplexity model

Browse files
.env.example CHANGED
@@ -70,6 +70,11 @@ LMSTUDIO_API_BASE_URL=
70
  # You only need this environment variable set if you want to use xAI models
71
  XAI_API_KEY=
72
 
 
 
 
 
 
73
  # Include this environment variable if you want more logging for debugging locally
74
  VITE_LOG_LEVEL=debug
75
 
 
70
  # You only need this environment variable set if you want to use xAI models
71
  XAI_API_KEY=
72
 
73
+ # Get your Perplexity API Key here -
74
+ # https://www.perplexity.ai/settings/api
75
+ # You only need this environment variable set if you want to use Perplexity models
76
+ PERPLEXITY_API_KEY=
77
+
78
  # Include this environment variable if you want more logging for debugging locally
79
  VITE_LOG_LEVEL=debug
80
 
app/commit.json CHANGED
@@ -1 +1 @@
1
- { "commit": "55094392cf4c5bc607aff796680ad50236a4cf20" }
 
1
+ { "commit": "9666b2ab67d25345542722ab9d870b36ad06252e" }
app/lib/.server/llm/api-key.ts CHANGED
@@ -39,6 +39,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string, userApiKeys?: Re
39
  return env.TOGETHER_API_KEY || cloudflareEnv.TOGETHER_API_KEY;
40
  case 'xAI':
41
  return env.XAI_API_KEY || cloudflareEnv.XAI_API_KEY;
 
 
42
  case 'Cohere':
43
  return env.COHERE_API_KEY;
44
  case 'AzureOpenAI':
 
39
  return env.TOGETHER_API_KEY || cloudflareEnv.TOGETHER_API_KEY;
40
  case 'xAI':
41
  return env.XAI_API_KEY || cloudflareEnv.XAI_API_KEY;
42
+ case 'Perplexity':
43
+ return env.PERPLEXITY_API_KEY || cloudflareEnv.PERPLEXITY_API_KEY;
44
  case 'Cohere':
45
  return env.COHERE_API_KEY;
46
  case 'AzureOpenAI':
app/lib/.server/llm/model.ts CHANGED
@@ -128,6 +128,15 @@ export function getXAIModel(apiKey: OptionalApiKey, model: string) {
128
  return openai(model);
129
  }
130
 
 
 
 
 
 
 
 
 
 
131
  export function getModel(
132
  provider: string,
133
  model: string,
@@ -170,6 +179,8 @@ export function getModel(
170
  return getXAIModel(apiKey, model);
171
  case 'Cohere':
172
  return getCohereAIModel(apiKey, model);
 
 
173
  default:
174
  return getOllamaModel(baseURL, model);
175
  }
 
128
  return openai(model);
129
  }
130
 
131
+ export function getPerplexityModel(apiKey: OptionalApiKey, model: string) {
132
+ const perplexity = createOpenAI({
133
+ baseURL: 'https://api.perplexity.ai/',
134
+ apiKey,
135
+ });
136
+
137
+ return perplexity(model);
138
+ }
139
+
140
  export function getModel(
141
  provider: string,
142
  model: string,
 
179
  return getXAIModel(apiKey, model);
180
  case 'Cohere':
181
  return getCohereAIModel(apiKey, model);
182
+ case 'Perplexity':
183
+ return getPerplexityModel(apiKey, model);
184
  default:
185
  return getOllamaModel(baseURL, model);
186
  }
app/utils/constants.ts CHANGED
@@ -292,6 +292,30 @@ const PROVIDER_LIST: ProviderInfo[] = [
292
  ],
293
  getApiKeyLink: 'https://api.together.xyz/settings/api-keys',
294
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  ];
296
 
297
  export const DEFAULT_PROVIDER = PROVIDER_LIST[0];
 
292
  ],
293
  getApiKeyLink: 'https://api.together.xyz/settings/api-keys',
294
  },
295
+ {
296
+ name: 'Perplexity',
297
+ staticModels: [
298
+ {
299
+ name: 'llama-3.1-sonar-small-128k-online',
300
+ label: 'Sonar Small Online',
301
+ provider: 'Perplexity',
302
+ maxTokenAllowed: 8192,
303
+ },
304
+ {
305
+ name: 'llama-3.1-sonar-large-128k-online',
306
+ label: 'Sonar Large Online',
307
+ provider: 'Perplexity',
308
+ maxTokenAllowed: 8192,
309
+ },
310
+ {
311
+ name: 'llama-3.1-sonar-huge-128k-online',
312
+ label: 'Sonar Huge Online',
313
+ provider: 'Perplexity',
314
+ maxTokenAllowed: 8192,
315
+ },
316
+ ],
317
+ getApiKeyLink: 'https://www.perplexity.ai/settings/api',
318
+ },
319
  ];
320
 
321
  export const DEFAULT_PROVIDER = PROVIDER_LIST[0];
worker-configuration.d.ts CHANGED
@@ -14,4 +14,5 @@ interface Env {
14
  GOOGLE_GENERATIVE_AI_API_KEY: string;
15
  MISTRAL_API_KEY: string;
16
  XAI_API_KEY: string;
 
17
  }
 
14
  GOOGLE_GENERATIVE_AI_API_KEY: string;
15
  MISTRAL_API_KEY: string;
16
  XAI_API_KEY: string;
17
+ PERPLEXITY_API_KEY: string;
18
  }