mirror of
https://github.com/Yidadaa/ChatGPT-Next-Web.git
synced 2025-08-08 20:32:46 +08:00
fix: #2303 should select custom models
This commit is contained in:
@@ -57,6 +57,7 @@ export type ChatConfigStore = ChatConfig & {
|
||||
reset: () => void;
|
||||
update: (updater: (config: ChatConfig) => void) => void;
|
||||
mergeModels: (newModels: LLMModel[]) => void;
|
||||
allModels: () => LLMModel[];
|
||||
};
|
||||
|
||||
export type ModelConfig = ChatConfig["modelConfig"];
|
||||
@@ -74,16 +75,9 @@ export function limitNumber(
|
||||
return Math.min(max, Math.max(min, x));
|
||||
}
|
||||
|
||||
export function limitModel(name: string) {
|
||||
const allModels = useAppConfig.getState().models;
|
||||
return allModels.some((m) => m.name === name && m.available)
|
||||
? name
|
||||
: "gpt-3.5-turbo";
|
||||
}
|
||||
|
||||
export const ModalConfigValidator = {
|
||||
model(x: string) {
|
||||
return limitModel(x) as ModelType;
|
||||
return x as ModelType;
|
||||
},
|
||||
max_tokens(x: number) {
|
||||
return limitNumber(x, 0, 32000, 2000);
|
||||
@@ -139,6 +133,15 @@ export const useAppConfig = create<ChatConfigStore>()(
|
||||
models: Object.values(modelMap),
|
||||
}));
|
||||
},
|
||||
|
||||
allModels() {
|
||||
const customModels = get()
|
||||
.customModels.split(",")
|
||||
.map((m) => ({ name: m, available: true }));
|
||||
|
||||
const models = get().models.concat(customModels);
|
||||
return models;
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: StoreKey.Config,
|
||||
|
Reference in New Issue
Block a user