Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix: migrate mistral ai provider to have correct base url

Louisbac50b8eefcf
diff --git a/web-app/src/constants/providers.ts b/web-app/src/constants/providers.ts
index d3d806888..630c0efa7 100644
--- a/web-app/src/constants/providers.ts
+++ b/web-app/src/constants/providers.ts
@@ -224,7 +224,7 @@ export const predefinedProviders = [
{
active: true,
api_key: '',
- base_url: 'https://api.mistral.ai',
+ base_url: 'https://api.mistral.ai/v1',
explore_models_url:
'https://docs.mistral.ai/getting-started/models/models_overview/',
provider: 'mistral',
@@ -249,8 +249,8 @@ export const predefinedProviders = [
'The base endpoint to use. See the [Mistral documentation](https://docs.mistral.ai/getting-started/models/models_overview/) for more information.',
controller_type: 'input',
controller_props: {
- placeholder: 'https://api.mistral.ai',
- value: 'https://api.mistral.ai',
+ placeholder: 'https://api.mistral.ai/v1',
+ value: 'https://api.mistral.ai/v1',
},
},
],
diff --git a/web-app/src/hooks/useModelProvider.ts b/web-app/src/hooks/useModelProvider.ts
index b1aa82bc4..3db51514b 100644
--- a/web-app/src/hooks/useModelProvider.ts
+++ b/web-app/src/hooks/useModelProvider.ts
@@ -463,9 +463,40 @@ export const useModelProvider = create<ModelProviderState>()(
}
})
}
+ if (version <= 8 && state?.providers) {
+ state.providers.forEach((provider) => {
+ // Migrate Mistral provider base URL to add /v1
+ if (provider.provider === 'mistral') {
+ if (provider.base_url === 'https://api.mistral.ai') {
+ provider.base_url = 'https://api.mistral.ai/v1'
+ }
+
+ // Update base-url in settings
+ if (provider.settings) {
+ const baseUrlSetting = provider.settings.find(
+ (s) => s.key === 'base-url'
+ )
+ if (
+ baseUrlSetting?.controller_props?.value ===
+ 'https://api.mistral.ai'
+ ) {
+ baseUrlSetting.controller_props.value =
+ 'https://api.mistral.ai/v1'
+ }
+ if (
+ baseUrlSetting?.controller_props?.placeholder ===
+ 'https://api.mistral.ai'
+ ) {
+ baseUrlSetting.controller_props.placeholder =
+ 'https://api.mistral.ai/v1'
+ }
+ }
+ }
+ })
+ }
return state
},
- version: 8,
+ version: 9,
}
)
)