From 41785c920c82503143e5461f9d45d29fb9d90bcc Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Tue, 11 Feb 2025 19:36:11 -0800 Subject: [PATCH] set default roles for json as well git push --- core/config/load.ts | 1 + .../components/modelSelection/ModelSelect.tsx | 16 +++++++++------- gui/vite.config.ts | 8 ++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/config/load.ts b/core/config/load.ts index 157ae28ae..c8499dc8b 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -326,6 +326,7 @@ async function intermediateToFinalConfig( ...model.requestOptions, ...config.requestOptions, }; + model.roles = model.roles ?? ["chat"]; // Default to chat role if not specified } if (allowFreeTrial) { diff --git a/gui/src/components/modelSelection/ModelSelect.tsx b/gui/src/components/modelSelection/ModelSelect.tsx index 68f5ea996..efa717a0b 100644 --- a/gui/src/components/modelSelection/ModelSelect.tsx +++ b/gui/src/components/modelSelection/ModelSelect.tsx @@ -235,13 +235,15 @@ function ModelSelect() { useEffect(() => { setOptions( - allModels.map((model) => { - return { - value: model.title, - title: modelSelectTitle(model), - apiKey: model.apiKey, - }; - }), + allModels + .filter((m) => !m.roles || m.roles.includes("chat")) + .map((model) => { + return { + value: model.title, + title: modelSelectTitle(model), + apiKey: model.apiKey, + }; + }), ); }, [allModels]); diff --git a/gui/vite.config.ts b/gui/vite.config.ts index d4c4ba7d7..6c5cd6d75 100644 --- a/gui/vite.config.ts +++ b/gui/vite.config.ts @@ -16,6 +16,14 @@ export default defineConfig({ }, }, }, + server: { + cors: { + origin: "*", + methods: ["GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"], + allowedHeaders: ["*", "Content-Type", "Authorization"], + credentials: true, + }, + }, test: { globals: true, environment: "jsdom",