mirror of
https://github.com/stackblitz/bolt.new
synced 2025-02-06 04:48:04 +00:00
Cohere support added
This commit is contained in:
parent
9c657b962b
commit
d41a0ac2c2
@ -49,6 +49,10 @@ OPENAI_LIKE_API_KEY=
|
|||||||
# You only need this environment variable set if you want to use Mistral models
|
# You only need this environment variable set if you want to use Mistral models
|
||||||
MISTRAL_API_KEY=
|
MISTRAL_API_KEY=
|
||||||
|
|
||||||
|
# Get the Cohere Api key by following these instructions -
|
||||||
|
# https://dashboard.cohere.com/api-keys
|
||||||
|
# You only need this environment variable set if you want to use Cohere models
|
||||||
|
COHERE_API_KEY=
|
||||||
|
|
||||||
# Get LMStudio Base URL from LM Studio Developer Console
|
# Get LMStudio Base URL from LM Studio Developer Console
|
||||||
# Make sure to enable CORS
|
# Make sure to enable CORS
|
||||||
|
@ -39,7 +39,7 @@ https://thinktank.ottomator.ai
|
|||||||
- ⬜ Azure Open AI API Integration
|
- ⬜ Azure Open AI API Integration
|
||||||
- ⬜ Perplexity Integration
|
- ⬜ Perplexity Integration
|
||||||
- ⬜ Vertex AI Integration
|
- ⬜ Vertex AI Integration
|
||||||
- ⬜ Cohere Integration
|
- ✅ Cohere Integration
|
||||||
- ⬜ Deploy directly to Vercel/Netlify/other similar platforms
|
- ⬜ Deploy directly to Vercel/Netlify/other similar platforms
|
||||||
- ⬜ Prompt caching
|
- ⬜ Prompt caching
|
||||||
- ⬜ Better prompt enhancing
|
- ⬜ Better prompt enhancing
|
||||||
|
@ -35,6 +35,8 @@ export function getAPIKey(cloudflareEnv: Env, provider: string, userApiKeys?: Re
|
|||||||
return env.OPENAI_LIKE_API_KEY || cloudflareEnv.OPENAI_LIKE_API_KEY;
|
return env.OPENAI_LIKE_API_KEY || cloudflareEnv.OPENAI_LIKE_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 "Cohere":
|
||||||
|
return env.COHERE_API_KEY;
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// see https://docs.anthropic.com/en/docs/about-claude/models
|
// see https://docs.anthropic.com/en/docs/about-claude/models
|
||||||
export const MAX_TOKENS = 8000;
|
export const MAX_TOKENS = 4096;
|
||||||
|
|
||||||
// limits the number of model responses that can be returned in a single request
|
// limits the number of model responses that can be returned in a single request
|
||||||
export const MAX_RESPONSE_SEGMENTS = 2;
|
export const MAX_RESPONSE_SEGMENTS = 2;
|
||||||
|
@ -7,6 +7,7 @@ import { createGoogleGenerativeAI } from '@ai-sdk/google';
|
|||||||
import { ollama } from 'ollama-ai-provider';
|
import { ollama } from 'ollama-ai-provider';
|
||||||
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
|
||||||
import { createMistral } from '@ai-sdk/mistral';
|
import { createMistral } from '@ai-sdk/mistral';
|
||||||
|
import { createCohere } from '@ai-sdk/cohere'
|
||||||
|
|
||||||
export function getAnthropicModel(apiKey: string, model: string) {
|
export function getAnthropicModel(apiKey: string, model: string) {
|
||||||
const anthropic = createAnthropic({
|
const anthropic = createAnthropic({
|
||||||
@ -23,6 +24,15 @@ export function getOpenAILikeModel(baseURL:string,apiKey: string, model: string)
|
|||||||
|
|
||||||
return openai(model);
|
return openai(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getCohereAIModel(apiKey:string, model: string){
|
||||||
|
const cohere = createCohere({
|
||||||
|
apiKey,
|
||||||
|
});
|
||||||
|
|
||||||
|
return cohere(model);
|
||||||
|
}
|
||||||
|
|
||||||
export function getOpenAIModel(apiKey: string, model: string) {
|
export function getOpenAIModel(apiKey: string, model: string) {
|
||||||
const openai = createOpenAI({
|
const openai = createOpenAI({
|
||||||
apiKey,
|
apiKey,
|
||||||
@ -108,6 +118,8 @@ export function getXAIModel(apiKey: string, model: string) {
|
|||||||
|
|
||||||
return openai(model);
|
return openai(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function getModel(provider: string, model: string, env: Env, apiKeys?: Record<string, string>) {
|
export function getModel(provider: string, model: string, env: Env, apiKeys?: Record<string, string>) {
|
||||||
const apiKey = getAPIKey(env, provider, apiKeys);
|
const apiKey = getAPIKey(env, provider, apiKeys);
|
||||||
const baseURL = getBaseURL(env, provider);
|
const baseURL = getBaseURL(env, provider);
|
||||||
@ -135,6 +147,8 @@ export function getModel(provider: string, model: string, env: Env, apiKeys?: Re
|
|||||||
return getLMStudioModel(baseURL, model);
|
return getLMStudioModel(baseURL, model);
|
||||||
case 'xAI':
|
case 'xAI':
|
||||||
return getXAIModel(apiKey, model);
|
return getXAIModel(apiKey, model);
|
||||||
|
case 'Cohere':
|
||||||
|
return getCohereAIModel(apiKey, model);
|
||||||
default:
|
default:
|
||||||
return getOllamaModel(baseURL, model);
|
return getOllamaModel(baseURL, model);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,22 @@ const PROVIDER_LIST: ProviderInfo[] = [
|
|||||||
staticModels: [],
|
staticModels: [],
|
||||||
getDynamicModels: getOpenAILikeModels
|
getDynamicModels: getOpenAILikeModels
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'Cohere',
|
||||||
|
staticModels: [
|
||||||
|
{ name: 'command-r-plus-08-2024', label: 'Command R plus Latest', provider: 'Cohere' },
|
||||||
|
{ name: 'command-r-08-2024', label: 'Command R Latest', provider: 'Cohere' },
|
||||||
|
{ name: 'command-r-plus', label: 'Command R plus', provider: 'Cohere' },
|
||||||
|
{ name: 'command-r', label: 'Command R', provider: 'Cohere' },
|
||||||
|
{ name: 'command', label: 'Command', provider: 'Cohere' },
|
||||||
|
{ name: 'command-nightly', label: 'Command Nightly', provider: 'Cohere' },
|
||||||
|
{ name: 'command-light', label: 'Command Light', provider: 'Cohere' },
|
||||||
|
{ name: 'command-light-nightly', label: 'Command Light Nightly', provider: 'Cohere' },
|
||||||
|
{ name: 'c4ai-aya-expanse-8b', label: 'c4AI Aya Expanse 8b', provider: 'Cohere' },
|
||||||
|
{ name: 'c4ai-aya-expanse-32b', label: 'c4AI Aya Expanse 32b', provider: 'Cohere' },
|
||||||
|
],
|
||||||
|
getApiKeyLink: 'https://dashboard.cohere.com/api-keys'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'OpenRouter',
|
name: 'OpenRouter',
|
||||||
staticModels: [
|
staticModels: [
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/anthropic": "^0.0.39",
|
"@ai-sdk/anthropic": "^0.0.39",
|
||||||
|
"@ai-sdk/cohere": "^1.0.1",
|
||||||
"@ai-sdk/google": "^0.0.52",
|
"@ai-sdk/google": "^0.0.52",
|
||||||
"@ai-sdk/mistral": "^0.0.43",
|
"@ai-sdk/mistral": "^0.0.43",
|
||||||
"@ai-sdk/openai": "^0.0.66",
|
"@ai-sdk/openai": "^0.0.66",
|
||||||
|
@ -14,6 +14,9 @@ importers:
|
|||||||
'@ai-sdk/anthropic':
|
'@ai-sdk/anthropic':
|
||||||
specifier: ^0.0.39
|
specifier: ^0.0.39
|
||||||
version: 0.0.39(zod@3.23.8)
|
version: 0.0.39(zod@3.23.8)
|
||||||
|
'@ai-sdk/cohere':
|
||||||
|
specifier: ^1.0.1
|
||||||
|
version: 1.0.1(zod@3.23.8)
|
||||||
'@ai-sdk/google':
|
'@ai-sdk/google':
|
||||||
specifier: ^0.0.52
|
specifier: ^0.0.52
|
||||||
version: 0.0.52(zod@3.23.8)
|
version: 0.0.52(zod@3.23.8)
|
||||||
@ -279,6 +282,12 @@ packages:
|
|||||||
peerDependencies:
|
peerDependencies:
|
||||||
zod: ^3.0.0
|
zod: ^3.0.0
|
||||||
|
|
||||||
|
'@ai-sdk/cohere@1.0.1':
|
||||||
|
resolution: {integrity: sha512-xLaSYl/hs9EqfpvT9PvqZrDWjJPQPZBd0iT32T6812vN6kwuEQ6sSgQvqHWczIqxeej2GNRgMQwDL6Lh0L5pZw==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
peerDependencies:
|
||||||
|
zod: ^3.0.0
|
||||||
|
|
||||||
'@ai-sdk/google@0.0.52':
|
'@ai-sdk/google@0.0.52':
|
||||||
resolution: {integrity: sha512-bfsA/1Ae0SQ6NfLwWKs5SU4MBwlzJjVhK6bTVBicYFjUxg9liK/W76P1Tq/qK9OlrODACz3i1STOIWsFPpIOuQ==}
|
resolution: {integrity: sha512-bfsA/1Ae0SQ6NfLwWKs5SU4MBwlzJjVhK6bTVBicYFjUxg9liK/W76P1Tq/qK9OlrODACz3i1STOIWsFPpIOuQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
@ -324,6 +333,15 @@ packages:
|
|||||||
zod:
|
zod:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@ai-sdk/provider-utils@2.0.1':
|
||||||
|
resolution: {integrity: sha512-TNg7rPhRtETB2Z9F0JpOvpGii9Fs8EWM8nYy1jEkvSXkrPJ6b/9zVnDdaJsmLFDyrMbOsPJlkblYtmYEQou36w==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
peerDependencies:
|
||||||
|
zod: ^3.0.0
|
||||||
|
peerDependenciesMeta:
|
||||||
|
zod:
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@ai-sdk/provider@0.0.12':
|
'@ai-sdk/provider@0.0.12':
|
||||||
resolution: {integrity: sha512-oOwPQD8i2Ynpn22cur4sk26FW3mSy6t6/X/K1Ay2yGBKYiSpRyLfObhOrZEGsXDx+3euKy4nEZ193R36NM+tpQ==}
|
resolution: {integrity: sha512-oOwPQD8i2Ynpn22cur4sk26FW3mSy6t6/X/K1Ay2yGBKYiSpRyLfObhOrZEGsXDx+3euKy4nEZ193R36NM+tpQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
@ -336,6 +354,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-XMsNGJdGO+L0cxhhegtqZ8+T6nn4EoShS819OvCgI2kLbYTIvk0GWFGD0AXJmxkxs3DrpsJxKAFukFR7bvTkgQ==}
|
resolution: {integrity: sha512-XMsNGJdGO+L0cxhhegtqZ8+T6nn4EoShS819OvCgI2kLbYTIvk0GWFGD0AXJmxkxs3DrpsJxKAFukFR7bvTkgQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
|
'@ai-sdk/provider@1.0.0':
|
||||||
|
resolution: {integrity: sha512-Sj29AzooJ7SYvhPd+AAWt/E7j63E9+AzRnoMHUaJPRYzOd/WDrVNxxv85prF9gDcQ7XPVlSk9j6oAZV9/DXYpA==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
|
||||||
'@ai-sdk/react@0.0.62':
|
'@ai-sdk/react@0.0.62':
|
||||||
resolution: {integrity: sha512-1asDpxgmeHWL0/EZPCLENxfOHT+0jce0z/zasRhascodm2S6f6/KZn5doLG9jdmarcb+GjMjFmmwyOVXz3W1xg==}
|
resolution: {integrity: sha512-1asDpxgmeHWL0/EZPCLENxfOHT+0jce0z/zasRhascodm2S6f6/KZn5doLG9jdmarcb+GjMjFmmwyOVXz3W1xg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
@ -3033,6 +3055,10 @@ packages:
|
|||||||
resolution: {integrity: sha512-v0eOBUbiaFojBu2s2NPBfYUoRR9GjcDNvCXVaqEf5vVfpIAh9f8RCo4vXTP8c63QRKCFwoLpMpTdPwwhEKVgzA==}
|
resolution: {integrity: sha512-v0eOBUbiaFojBu2s2NPBfYUoRR9GjcDNvCXVaqEf5vVfpIAh9f8RCo4vXTP8c63QRKCFwoLpMpTdPwwhEKVgzA==}
|
||||||
engines: {node: '>=14.18'}
|
engines: {node: '>=14.18'}
|
||||||
|
|
||||||
|
eventsource-parser@3.0.0:
|
||||||
|
resolution: {integrity: sha512-T1C0XCUimhxVQzW4zFipdx0SficT651NnkR0ZSH3yQwh+mFMdLfgjABVi4YtMTtaL4s168593DaoaRLMqryavA==}
|
||||||
|
engines: {node: '>=18.0.0'}
|
||||||
|
|
||||||
evp_bytestokey@1.0.3:
|
evp_bytestokey@1.0.3:
|
||||||
resolution: {integrity: sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==}
|
resolution: {integrity: sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==}
|
||||||
|
|
||||||
@ -5687,6 +5713,12 @@ snapshots:
|
|||||||
'@ai-sdk/provider-utils': 1.0.9(zod@3.23.8)
|
'@ai-sdk/provider-utils': 1.0.9(zod@3.23.8)
|
||||||
zod: 3.23.8
|
zod: 3.23.8
|
||||||
|
|
||||||
|
'@ai-sdk/cohere@1.0.1(zod@3.23.8)':
|
||||||
|
dependencies:
|
||||||
|
'@ai-sdk/provider': 1.0.0
|
||||||
|
'@ai-sdk/provider-utils': 2.0.1(zod@3.23.8)
|
||||||
|
zod: 3.23.8
|
||||||
|
|
||||||
'@ai-sdk/google@0.0.52(zod@3.23.8)':
|
'@ai-sdk/google@0.0.52(zod@3.23.8)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@ai-sdk/provider': 0.0.24
|
'@ai-sdk/provider': 0.0.24
|
||||||
@ -5733,6 +5765,15 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
zod: 3.23.8
|
zod: 3.23.8
|
||||||
|
|
||||||
|
'@ai-sdk/provider-utils@2.0.1(zod@3.23.8)':
|
||||||
|
dependencies:
|
||||||
|
'@ai-sdk/provider': 1.0.0
|
||||||
|
eventsource-parser: 3.0.0
|
||||||
|
nanoid: 3.3.7
|
||||||
|
secure-json-parse: 2.7.0
|
||||||
|
optionalDependencies:
|
||||||
|
zod: 3.23.8
|
||||||
|
|
||||||
'@ai-sdk/provider@0.0.12':
|
'@ai-sdk/provider@0.0.12':
|
||||||
dependencies:
|
dependencies:
|
||||||
json-schema: 0.4.0
|
json-schema: 0.4.0
|
||||||
@ -5745,6 +5786,10 @@ snapshots:
|
|||||||
dependencies:
|
dependencies:
|
||||||
json-schema: 0.4.0
|
json-schema: 0.4.0
|
||||||
|
|
||||||
|
'@ai-sdk/provider@1.0.0':
|
||||||
|
dependencies:
|
||||||
|
json-schema: 0.4.0
|
||||||
|
|
||||||
'@ai-sdk/react@0.0.62(react@18.3.1)(zod@3.23.8)':
|
'@ai-sdk/react@0.0.62(react@18.3.1)(zod@3.23.8)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@ai-sdk/provider-utils': 1.0.20(zod@3.23.8)
|
'@ai-sdk/provider-utils': 1.0.20(zod@3.23.8)
|
||||||
@ -8751,6 +8796,8 @@ snapshots:
|
|||||||
|
|
||||||
eventsource-parser@1.1.2: {}
|
eventsource-parser@1.1.2: {}
|
||||||
|
|
||||||
|
eventsource-parser@3.0.0: {}
|
||||||
|
|
||||||
evp_bytestokey@1.0.3:
|
evp_bytestokey@1.0.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
md5.js: 1.3.5
|
md5.js: 1.3.5
|
||||||
|
Loading…
Reference in New Issue
Block a user