Skip to content

Commit

Permalink
fix: prioritize fixed model providers in sorting logic (#14338)
Browse files Browse the repository at this point in the history
  • Loading branch information
WTW0313 authored Feb 25, 2025
1 parent 7a71498 commit ff911d0
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ type Props = {
searchText: string
}

const FixedModelProvider = ['langgenius/openai/openai', 'langgenius/anthropic/anthropic']

const ModelProviderPage = ({ searchText }: Props) => {
const debouncedSearchText = useDebounce(searchText, { wait: 500 })
const { t } = useTranslation()
Expand Down Expand Up @@ -66,6 +68,16 @@ const ModelProviderPage = ({ searchText }: Props) => {
notConfiguredProviders.push(provider)
})

configuredProviders.sort((a, b) => {
if (FixedModelProvider.includes(a.provider) && FixedModelProvider.includes(b.provider))
return FixedModelProvider.indexOf(a.provider) - FixedModelProvider.indexOf(b.provider) > 0 ? 1 : -1
else if (FixedModelProvider.includes(a.provider))
return -1
else if (FixedModelProvider.includes(b.provider))
return 1
return 0
})

return [configuredProviders, notConfiguredProviders]
}, [providers])
const [filteredConfiguredProviders, filteredNotConfiguredProviders] = useMemo(() => {
Expand Down

0 comments on commit ff911d0

Please sign in to comment.