mirror of
https://github.com/voideditor/void
synced 2026-05-22 17:08:25 +00:00
stuff changed there also
This commit is contained in:
parent
6e39b225b2
commit
b7f764799c
4 changed files with 56 additions and 9 deletions
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -15,7 +15,7 @@
|
|||
"@google/generative-ai": "^0.22.0",
|
||||
"@microsoft/1ds-core-js": "^3.2.13",
|
||||
"@microsoft/1ds-post-js": "^3.2.13",
|
||||
"@mistralai/mistralai": "^1.5.0",
|
||||
"@mistralai/mistralai": "^1.5.1",
|
||||
"@parcel/watcher": "2.5.1",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vscode/deviceid": "^0.1.1",
|
||||
|
|
@ -2540,9 +2540,9 @@
|
|||
"integrity": "sha512-n1VPsljTSkthsAFYdiWfC+DKzK2WwcRp83Y1YAqdX552BstvsDjft9YXppjUzp11BPsapDoO1LDgrDB0XVsfNQ=="
|
||||
},
|
||||
"node_modules/@mistralai/mistralai": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@mistralai/mistralai/-/mistralai-1.5.0.tgz",
|
||||
"integrity": "sha512-AIn8pwAwA/fDvEUvmkt+40zH1ZmfaG3Q7oUWl17GUEC1tU7ZPwYz8Cv9P59lyS1SisHdDSu81oknO7f1ywkz8Q==",
|
||||
"version": "1.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@mistralai/mistralai/-/mistralai-1.5.1.tgz",
|
||||
"integrity": "sha512-Ie0EH4dAO11MEXR5N2kS2cgr+ycTWvqN/yP9bKrtmUEqjdcF4i7DLxtrFMUw5l2dOPhrkX93G4SziFiATPWu2w==",
|
||||
"dependencies": {
|
||||
"zod-to-json-schema": "^3.24.1"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@
|
|||
"@google/generative-ai": "^0.22.0",
|
||||
"@microsoft/1ds-core-js": "^3.2.13",
|
||||
"@microsoft/1ds-post-js": "^3.2.13",
|
||||
"@mistralai/mistralai": "^1.5.0",
|
||||
"@mistralai/mistralai": "^1.5.1",
|
||||
"@parcel/watcher": "2.5.1",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@vscode/deviceid": "^0.1.1",
|
||||
|
|
|
|||
|
|
@ -582,7 +582,7 @@ const openRouterModelOptions_assumingOpenAICompat = {
|
|||
supportsReasoning: false,
|
||||
},
|
||||
'mistralai/codestral-2501': {
|
||||
...openSourceModelOptions_assumingOAICompat.codestral,
|
||||
...openSourceModelOptions_assumingOAICompat['codestral-latest'],
|
||||
contextWindow: 256_000,
|
||||
maxOutputTokens: null,
|
||||
cost: { input: 0.3, output: 0.9 },
|
||||
|
|
|
|||
|
|
@ -8,7 +8,10 @@ import { Ollama } from 'ollama';
|
|||
import OpenAI, { ClientOptions } from 'openai';
|
||||
|
||||
|
||||
|
||||
/* Mistral standalone Fim endpoint */
|
||||
import { MistralCore } from "@mistralai/mistralai/core.js";
|
||||
import { fimComplete } from "@mistralai/mistralai/funcs/fimComplete.js";
|
||||
/* End Mistral standalone Fim endpoint */
|
||||
|
||||
|
||||
import { Model as OpenAIModel } from 'openai/resources/models.js';
|
||||
|
|
@ -118,7 +121,7 @@ const newOpenAICompatibleSDK = ({ settingsOfProvider, providerName, includeInPay
|
|||
}
|
||||
else if (providerName === 'mistral') {
|
||||
const thisConfig = settingsOfProvider[providerName]
|
||||
return new OpenAI({ baseURL: 'https://api.mistral.ai/v1', apiKey: thisConfig.apiKey, ...commonPayloadOpts })
|
||||
return new OpenAI({ baseURL: 'https://api.mistral.ai/v1', apiKey: thisConfig.apiKey })
|
||||
}
|
||||
|
||||
else throw new Error(`Void providerName was invalid: ${providerName}.`)
|
||||
|
|
@ -472,7 +475,51 @@ const sendOllamaFIM = ({ messages: messages_, onFinalMessage, onError, settingsO
|
|||
})
|
||||
}
|
||||
|
||||
const _sendMistralFIM = ({ messages: messages_, onFinalMessage, onError, settingsOfProvider, modelName: modelName_, _setAborter, providerName, aiInstructions }: SendFIMParams_Internal) => {
|
||||
const { modelName, supportsFIM } = getModelCapabilities(providerName, modelName_)
|
||||
if (!supportsFIM) {
|
||||
if (modelName === modelName_)
|
||||
onError({ message: `Model ${modelName} does not support FIM.`, fullError: null })
|
||||
else
|
||||
onError({ message: `Model ${modelName_} (${modelName}) does not support FIM.`, fullError: null })
|
||||
return
|
||||
}
|
||||
const messages = prepareFIMMessage({ messages: messages_, aiInstructions })
|
||||
|
||||
const mistral = new MistralCore({ apiKey: settingsOfProvider.mistral.apiKey })
|
||||
|
||||
// DEBUG : request params
|
||||
console.log('🔍 Sending FIM request with params:', {
|
||||
model: modelName,
|
||||
promptLength: messages.prefix.length,
|
||||
suffixLength: messages.suffix.length,
|
||||
stream: false,
|
||||
maxTokens: messages.maxTokens
|
||||
});
|
||||
|
||||
fimComplete(
|
||||
mistral, {
|
||||
model: modelName,
|
||||
prompt: messages.prefix,
|
||||
suffix: messages.suffix,
|
||||
stream: false,
|
||||
topP: 1,
|
||||
maxTokens: messages.maxTokens,
|
||||
stop: messages.stopTokens
|
||||
},
|
||||
)
|
||||
|
||||
.then(async response => {
|
||||
let content = response?.ok ? response.value.choices?.[0]?.message?.content : '';
|
||||
const fullText = typeof content === 'string' ? content :
|
||||
Array.isArray(content) ? content.map(chunk => chunk.type === 'text' ? chunk.text : '').join('') : '';
|
||||
onFinalMessage({ fullText, fullReasoning: '', anthropicReasoning: null });
|
||||
console.log('✅ Réponse FIM reçue:', fullText);
|
||||
})
|
||||
.catch(error => {
|
||||
onError({ message: error + '', fullError: error });
|
||||
})
|
||||
}
|
||||
|
||||
type CallFnOfProvider = {
|
||||
[providerName in ProviderName]: {
|
||||
|
|
@ -534,7 +581,7 @@ export const sendLLMMessageToProviderImplementation = {
|
|||
list: null,
|
||||
},
|
||||
mistral: {
|
||||
sendChat: (params) => _sendMistralChat(params),
|
||||
sendChat: (params) => _sendOpenAICompatibleChat(params),
|
||||
sendFIM: (params) => _sendMistralFIM(params),
|
||||
list: null,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue