diff --git a/app/client/platforms/openai.ts b/app/client/platforms/openai.ts
index 7e44909e..dfe41300 100644
--- a/app/client/platforms/openai.ts
+++ b/app/client/platforms/openai.ts
@@ -257,12 +257,14 @@ export class ChatGPTApi implements LLMApi {
const chatModels = resJson.data?.filter((m) => m.id.startsWith("gpt-"));
console.log("[Models]", chatModels);
- return (
- chatModels?.map((m) => ({
- name: m.id,
- available: true,
- })) || []
- );
+ if (!chatModels) {
+ return [];
+ }
+
+ return chatModels.map((m) => ({
+ name: m.id,
+ available: true,
+ }));
}
}
export { OpenaiPath };
diff --git a/app/components/model-config.tsx b/app/components/model-config.tsx
index f9d981cd..8e353401 100644
--- a/app/components/model-config.tsx
+++ b/app/components/model-config.tsx
@@ -9,6 +9,10 @@ export function ModelConfigList(props: {
updateConfig: (updater: (config: ModelConfig) => void) => void;
}) {
const config = useAppConfig();
+ const customModels = config.customModels
+ .split(",")
+ .map((m) => ({ name: m, available: true }));
+ const models = config.models.concat(customModels);
return (
<>
@@ -24,8 +28,8 @@ export function ModelConfigList(props: {
);
}}
>
- {config.models.map((v) => (
-
))}
diff --git a/app/components/settings.tsx b/app/components/settings.tsx
index 5980a34e..09251630 100644
--- a/app/components/settings.tsx
+++ b/app/components/settings.tsx
@@ -315,7 +315,6 @@ export function Settings() {
const [showEmojiPicker, setShowEmojiPicker] = useState(false);
const config = useAppConfig();
const updateConfig = config.update;
- const chatStore = useChatStore();
const updateStore = useUpdateStore();
const [checkingUpdate, setCheckingUpdate] = useState(false);
@@ -579,6 +578,38 @@ export function Settings() {
+
+
+
+ updateConfig(
+ (config) =>
+ (config.disablePromptHint = e.currentTarget.checked),
+ )
+ }
+ >
+
+
+
+ }
+ text={Locale.Settings.Prompt.Edit}
+ onClick={() => setShowPromptModal(true)}
+ />
+
+
+
{showAccessCode ? (
) : null}
-
-
- updateConfig(
- (config) =>
- (config.disablePromptHint = e.currentTarget.checked),
+ config.update(
+ (config) => (config.customModels = e.currentTarget.value),
)
}
>
-
-
- }
- text={Locale.Settings.Prompt.Edit}
- onClick={() => setShowPromptModal(true)}
- />
-
diff --git a/app/locales/cn.ts b/app/locales/cn.ts
index c32014be..38fa8e4f 100644
--- a/app/locales/cn.ts
+++ b/app/locales/cn.ts
@@ -220,6 +220,10 @@ const cn = {
Title: "接口地址",
SubTitle: "除默认地址外,必须包含 http(s)://",
},
+ CustomModel: {
+ Title: "自定义模型名",
+ SubTitle: "增加自定义模型可选项,使用英文逗号隔开",
+ },
Model: "模型 (model)",
Temperature: {
Title: "随机性 (temperature)",
diff --git a/app/locales/en.ts b/app/locales/en.ts
index d96b978f..f5d90fd2 100644
--- a/app/locales/en.ts
+++ b/app/locales/en.ts
@@ -222,6 +222,10 @@ const en: LocaleType = {
Title: "Endpoint",
SubTitle: "Custom endpoint must start with http(s)://",
},
+ CustomModel: {
+ Title: "Custom Models",
+ SubTitle: "Add extra model options, separate by comma",
+ },
Model: "Model",
Temperature: {
Title: "Temperature",
diff --git a/app/store/config.ts b/app/store/config.ts
index cf390c74..ff346871 100644
--- a/app/store/config.ts
+++ b/app/store/config.ts
@@ -34,6 +34,7 @@ export const DEFAULT_CONFIG = {
dontShowMaskSplashScreen: false, // dont show splash screen when create chat
hideBuiltinMasks: false, // dont add builtin masks
+ customModels: "",
models: DEFAULT_MODELS as any as LLMModel[],
modelConfig: {
@@ -117,6 +118,10 @@ export const useAppConfig = create()(
},
mergeModels(newModels) {
+ if (!newModels || newModels.length === 0) {
+ return;
+ }
+
const oldModels = get().models;
const modelMap: Record = {};
@@ -137,7 +142,7 @@ export const useAppConfig = create()(
}),
{
name: StoreKey.Config,
- version: 3.4,
+ version: 3.5,
migrate(persistedState, version) {
const state = persistedState as ChatConfig;
@@ -152,6 +157,10 @@ export const useAppConfig = create()(
state.hideBuiltinMasks = false;
}
+ if (version < 3.5) {
+ state.customModels = "claude,claude-100k";
+ }
+
return state as any;
},
},