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: sorting provider name

Faisal Amir322e915b9d88
diff --git a/web-app/src/containers/DropdownModelProvider.tsx b/web-app/src/containers/DropdownModelProvider.tsx
index d5898d28a..312a4beff 100644
--- a/web-app/src/containers/DropdownModelProvider.tsx
+++ b/web-app/src/containers/DropdownModelProvider.tsx
@@ -338,10 +338,28 @@ const DropdownModelProvider = memo(function DropdownModelProvider({
if (!searchValue) {
// When not searching, show all active providers (even without models)
- providers.forEach((provider) => {
- if (provider.active) {
- groups[provider.provider] = []
- }
+ // Sort: local first, then providers with API keys, then others, alphabetically
+ const activeProviders = providers
+ .filter((p) => p.active)
+ .sort((a, b) => {
+ const aIsLocal = a.provider === 'llamacpp' || a.provider === 'mlx'
+ const bIsLocal = b.provider === 'llamacpp' || b.provider === 'mlx'
+ // Local (llamacpp) first
+ if (aIsLocal && !bIsLocal) return -1
+ if (!aIsLocal && bIsLocal) return 1
+
+ const aHasApiKey = (a.api_key?.length ?? 0) > 0
+ const bHasApiKey = (b.api_key?.length ?? 0) > 0
+ // Providers with API keys filled second
+ if (aHasApiKey && !bHasApiKey) return -1
+ if (!aHasApiKey && bHasApiKey) return 1
+
+ // Sort remaining by provider name
+ return a.provider.localeCompare(b.provider)
+ })
+
+ activeProviders.forEach((provider) => {
+ groups[provider.provider] = []
})
}