Skip to content

Commit

Permalink
add cerebras ai and add pixtral
Browse files Browse the repository at this point in the history
I heard a lot of praise for pixtral over the last few days so i've decided that it needs to be in this. not sure about the coding performance but it won't hurt to have an extra model in the options!
  • Loading branch information
ArulGandhi committed Oct 30, 2024
1 parent 065be0f commit b3cb9d1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,10 @@ OPENAI_LIKE_API_KEY=
# You only need this environment variable set if you want to use Mistral models
MISTRAL_API_KEY=

# Get your Cerebras API Key by following these instructions -
# https://github.com/Cerebras/inference-examples/blob/main/getting-started/README.md
# You only need this environment variable set if you want to use Cerebras models
CEREBRAS_API_KEY=

# Include this environment variable if you want more logging for debugging locally
VITE_LOG_LEVEL=debug
2 changes: 2 additions & 0 deletions app/lib/.server/llm/api-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string) {
return env.MISTRAL_API_KEY || cloudflareEnv.MISTRAL_API_KEY;
case "OpenAILike":
return env.OPENAI_LIKE_API_KEY || cloudflareEnv.OPENAI_LIKE_API_KEY;
case "Cerebras":
return env.CEREBRAS_API_KEY || cloudflareEnv.CEREBRAS_API_KEY;
default:
return "";
}
Expand Down
11 changes: 11 additions & 0 deletions app/lib/.server/llm/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ export function getOpenRouterModel(apiKey: string, model: string) {
return openRouter.chat(model);
}

export function getCerebrasModel(apiKey: string, model: string) {
const openai = createOpenAI({
baseURL: 'https://api.cerebras.ai/v1',
apiKey,
});

return openai(model);
}

export function getModel(provider: string, model: string, env: Env) {
const apiKey = getAPIKey(env, provider);
const baseURL = getBaseURL(env, provider);
Expand All @@ -101,6 +110,8 @@ export function getModel(provider: string, model: string, env: Env) {
return getDeepseekModel(apiKey, model)
case 'Mistral':
return getMistralModel(apiKey, model);
case 'Cerebras':
return getCerebrasModel(apiKey, model);
default:
return getOllamaModel(baseURL, model);
}
Expand Down
3 changes: 3 additions & 0 deletions app/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const staticModels: ModelInfo[] = [
{ name: 'mistral-small-latest', label: 'Mistral Small', provider: 'Mistral' },
{ name: 'codestral-latest', label: 'Codestral', provider: 'Mistral' },
{ name: 'mistral-large-latest', label: 'Mistral Large Latest', provider: 'Mistral' },
{ name: 'pixtral-12b-2409', label: 'Pixtral 12B', provider: 'Mistral' },
{ name: 'llama3.1-8b', label: 'Llama 3.1 8B', provider: 'Cerebras' },
{ name: 'llama3.1-70b', label: 'Llama 3.1 70B', provider: 'Cerebras' },
];

export let MODEL_LIST: ModelInfo[] = [...staticModels];
Expand Down

0 comments on commit b3cb9d1

Please sign in to comment.