mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-09-27 21:56:38 +08:00
only used desired model providers
This commit is contained in:
parent
ac7b720b5b
commit
ef7674bcf4
@ -1,16 +1,34 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo } from "react";
|
||||||
import { useAccessStore, useAppConfig } from "../store";
|
import { useAccessStore, useAppConfig } from "../store";
|
||||||
import { collectModelsWithDefaultModel } from "./model";
|
import { collectModelsWithDefaultModel } from "./model";
|
||||||
|
import { ServiceProvider } from "../constant";
|
||||||
|
|
||||||
|
// Define the allowed providers
|
||||||
|
const allowedProviders = [
|
||||||
|
ServiceProvider.OpenAI,
|
||||||
|
ServiceProvider.Google,
|
||||||
|
ServiceProvider.Anthropic,
|
||||||
|
];
|
||||||
|
|
||||||
export function useAllModels() {
|
export function useAllModels() {
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
const configStore = useAppConfig();
|
const configStore = useAppConfig();
|
||||||
const models = useMemo(() => {
|
const models = useMemo(() => {
|
||||||
return collectModelsWithDefaultModel(
|
// First, collect all models including custom ones
|
||||||
|
const allModels = collectModelsWithDefaultModel(
|
||||||
configStore.models,
|
configStore.models,
|
||||||
[configStore.customModels, accessStore.customModels].join(","),
|
[configStore.customModels, accessStore.customModels].join(","),
|
||||||
accessStore.defaultModel,
|
accessStore.defaultModel,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Then, filter the collected models based on the allowed providers
|
||||||
|
return allModels.filter(
|
||||||
|
(model) =>
|
||||||
|
model.provider &&
|
||||||
|
allowedProviders.includes(
|
||||||
|
model.provider.providerName as ServiceProvider,
|
||||||
|
),
|
||||||
|
);
|
||||||
}, [
|
}, [
|
||||||
accessStore.customModels,
|
accessStore.customModels,
|
||||||
accessStore.defaultModel,
|
accessStore.defaultModel,
|
||||||
|
Loading…
Reference in New Issue
Block a user