Skip to content

[Provider] Cohere: [OpenAICompatibleModel Chat + tools] #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ const AddProvidersPage = ({ pageIndex, setPageIndex }: { pageIndex: number, setP
className="ml-1 text-xs align-top text-blue-400"
>*</span>
)}
{providerName === 'cohere' && (
<span
data-tooltip-id="void-tooltip-provider-info"
data-tooltip-content="Cohere offers 1000 free messages a month."
data-tooltip-place="right"
className="ml-1 text-xs align-top text-blue-400"
>*</span>
)}
</div>
<div>
<SettingsForProvider providerName={providerName} showProviderTitle={false} showProviderSuggestions={true} />
Expand Down
25 changes: 25 additions & 0 deletions src/vs/workbench/contrib/void/common/modelCapabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const defaultProviderSettings = {
mistral: {
apiKey: '',
},
cohere: {
apiKey: '',
},
lmStudio: {
endpoint: 'http://localhost:1234',
},
Expand Down Expand Up @@ -132,6 +135,9 @@ export const defaultModelsOfProvider = {
'ministral-3b-latest',
'ministral-8b-latest',
],
cohere: [ // https://docs.cohere.com/docs/models
'command-a-03-2025',
],
openAICompatible: [], // fallback
googleVertex: [],
microsoftAzure: [],
Expand Down Expand Up @@ -915,6 +921,24 @@ const mistralSettings: VoidStaticProviderInfo = {
modelOptionsFallback: (modelName) => { return null },
}

// ---------------- COHERE ----------------

const cohereModelOptions = { // https://cohere.com/pricing https://docs.cohere.com/docs/models
'command-a-03-2025': {
contextWindow: 256_000,
reservedOutputTokenSpace: 8_192,
cost: { input: 2.50, output: 10.0 },
supportsFIM: false,
downloadable: { sizeGb: 216 },
supportsSystemMessage: 'system-role',
reasoningCapabilities: false,
},
} as const satisfies { [s: string]: VoidStaticModelInfo }

const cohereSettings: VoidStaticProviderInfo = {
modelOptions: cohereModelOptions,
modelOptionsFallback: (modelName) => { return null },
}

// ---------------- GROQ ----------------
const groqModelOptions = { // https://console.groq.com/docs/models, https://groq.com/pricing/
Expand Down Expand Up @@ -1274,6 +1298,7 @@ const modelSettingsOfProvider: { [providerName in ProviderName]: VoidStaticProvi
ollama: ollamaSettings,
openAICompatible: openaiCompatible,
mistral: mistralSettings,
cohere: cohereSettings,

liteLLM: liteLLMSettings,
lmStudio: lmStudioSettings,
Expand Down
13 changes: 12 additions & 1 deletion src/vs/workbench/contrib/void/common/voidSettingsTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export const displayInfoOfProviderName = (providerName: ProviderName): DisplayIn
else if (providerName === 'mistral') {
return { title: 'Mistral', }
}
else if (providerName === 'cohere') {
return { title: 'Cohere', }
}
else if (providerName === 'googleVertex') {
return { title: 'Google Vertex AI', }
}
Expand All @@ -117,6 +120,7 @@ export const subTextMdOfProviderName = (providerName: ProviderName): string => {
if (providerName === 'groq') return 'Get your [API Key here](https://console.groq.com/keys).'
if (providerName === 'xAI') return 'Get your [API Key here](https://console.x.ai).'
if (providerName === 'mistral') return 'Get your [API Key here](https://console.mistral.ai/api-keys).'
if (providerName === 'cohere') return 'Get your [API Key here](https://dashboard.cohere.com/api-keys).'
if (providerName === 'openAICompatible') return `Use any provider that's OpenAI-compatible (use this for llama.cpp and more).`
if (providerName === 'googleVertex') return 'You must authenticate before using Vertex with Void. Read more about endpoints [here](https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/call-vertex-using-openai-library), and regions [here](https://cloud.google.com/vertex-ai/docs/general/locations#available-regions).'
if (providerName === 'microsoftAzure') return 'Read more about endpoints [here](https://learn.microsoft.com/en-us/rest/api/aifoundry/model-inference/get-chat-completions/get-chat-completions?view=rest-aifoundry-model-inference-2024-05-01-preview&tabs=HTTP), and get your API key [here](https://learn.microsoft.com/en-us/azure/search/search-security-api-keys?tabs=rest-use%2Cportal-find%2Cportal-query#find-existing-keys).'
Expand Down Expand Up @@ -151,7 +155,8 @@ export const displayInfoOfSettingName = (providerName: ProviderName, settingName
providerName === 'mistral' ? 'api-key...' :
providerName === 'googleVertex' ? 'AIzaSy...' :
providerName === 'microsoftAzure' ? 'key-...' :
'',
providerName === 'cohere' ? 'key...' :
'',

isPasswordField: true,
}
Expand Down Expand Up @@ -286,6 +291,12 @@ export const defaultSettingsOfProvider: SettingsOfProvider = {
...modelInfoOfDefaultModelNames(defaultModelsOfProvider.mistral),
_didFillInProviderSettings: undefined,
},
cohere: {
...defaultCustomSettings,
...defaultProviderSettings.cohere,
...modelInfoOfDefaultModelNames(defaultModelsOfProvider.cohere),
_didFillInProviderSettings: undefined,
},
liteLLM: {
...defaultCustomSettings,
...defaultProviderSettings.liteLLM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ const newOpenAICompatibleSDK = async ({ settingsOfProvider, providerName, includ
const thisConfig = settingsOfProvider[providerName]
return new OpenAI({ baseURL: 'https://api.mistral.ai/v1', apiKey: thisConfig.apiKey, ...commonPayloadOpts })
}
else if (providerName === 'cohere') {
const thisConfig = settingsOfProvider[providerName]
return new OpenAI({ baseURL: 'https://api.cohere.com/compatibility/v1', apiKey: thisConfig.apiKey, ...commonPayloadOpts })
}

else throw new Error(`Void providerName was invalid: ${providerName}.`)
}
Expand Down Expand Up @@ -837,6 +841,11 @@ export const sendLLMMessageToProviderImplementation = {
sendFIM: (params) => sendMistralFIM(params),
list: null,
},
cohere: {
sendChat: (params) => _sendOpenAICompatibleChat(params),
sendFIM: (params) => _sendOpenAICompatibleFIM(params),
list: null,
},
ollama: {
sendChat: (params) => _sendOpenAICompatibleChat(params),
sendFIM: sendOllamaFIM,
Expand Down