From e4819949211c84a87e56e906bdeae4523854f061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A6Ltorio?= Date: Fri, 18 Oct 2024 13:05:13 +0200 Subject: [PATCH] update build process for updating models --- package.json | 2 +- src/version.json | 4 ++-- utils/initModels.ts | 35 ++++++++++++++++++----------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 416b0ea..188fe06 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dev_server_port": 3000 }, "scripts": { - "build": "webpack --mode production", + "build": "npm run getGroqModels && npx webpack --mode production", "build:dev": "webpack --mode development", "dev-server": "webpack serve --mode development", "getGroqModels": "node --import 'data:text/javascript,import { register } from \"node:module\"; import { pathToFileURL } from \"node:url\"; register(\"ts-node/esm\", pathToFileURL(\"./\"));' ./utils/initModels.ts", diff --git a/src/version.json b/src/version.json index d70cf59..4c83072 100644 --- a/src/version.json +++ b/src/version.json @@ -1,4 +1,4 @@ { - "commit": "4898c7691148c2e8db14fd3e02c7da7a8cca6480", - "date": "2024-10-18 11:55:58 +0200" + "commit": "67e1a29e85e238537e12dca4d54ccdb2ba8897d4", + "date": "2024-10-18 12:51:46 +0200" } \ No newline at end of file diff --git a/utils/initModels.ts b/utils/initModels.ts index a348564..2c49aba 100644 --- a/utils/initModels.ts +++ b/utils/initModels.ts @@ -19,21 +19,22 @@ function normalizeModelName(name: string): string { ")"; return retString.trim(); } - -const groqModels = getAIModels(groqProvider, apiKey, "llama"); -groqModels.then((models) => { - models = models.map((model) => { - model.name = normalizeModelName(model.name); - return model; - }); - const newConfig = { ...config }; - // replace the models for the Groq provider - newConfig.providers = newConfig.providers.map((provider: AIProvider) => { - if (provider.name === "Groq") { - provider.models = models; - } - return provider; +if (apiKey !== "") { + const groqModels = getAIModels(groqProvider, apiKey, "llama"); + groqModels.then((models) => { + models = models.map((model) => { + model.name = normalizeModelName(model.name); + return model; + }); + const newConfig = { ...config }; + // replace the models for the Groq provider + newConfig.providers = newConfig.providers.map((provider: AIProvider) => { + if (provider.name === "Groq") { + provider.models = models; + } + return provider; + }); + //console.log(JSON.stringify(newConfig, null, 2)); + writeFileSync("./src/config.json", JSON.stringify(newConfig, null, 2)); }); - //console.log(JSON.stringify(newConfig, null, 2)); - writeFileSync("./src/config.json", JSON.stringify(newConfig, null, 2)); -}); +}