From aff68c2405491e097444288f1d356e63316ceb4a Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Fri, 26 Jan 2024 10:54:55 +0530 Subject: [PATCH 1/9] Update package versions and add new embedding models --- app/ui/package.json | 2 +- package.json | 2 +- server/prisma/seed.ts | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/ui/package.json b/app/ui/package.json index 2a922822..113ec81c 100644 --- a/app/ui/package.json +++ b/app/ui/package.json @@ -1,7 +1,7 @@ { "name": "app", "private": true, - "version": "1.7.1", + "version": "1.7.2", "type": "module", "scripts": { "dev": "vite", diff --git a/package.json b/package.json index 834f0330..57adb2c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dialoqbase", - "version": "1.7.1", + "version": "1.7.2", "description": "Create chatbots with ease", "scripts": { "ui:dev": "pnpm run --filter ui dev", diff --git a/server/prisma/seed.ts b/server/prisma/seed.ts index c97212a1..3cf47251 100644 --- a/server/prisma/seed.ts +++ b/server/prisma/seed.ts @@ -321,6 +321,18 @@ const EMBEDDING_MODELS: { model_type: "embedding", model_provider: "Google", }, + { + model_id: "dialoqbase_eb_text-embedding-3-small", + name: "text-embedding-3-small (OpenAI)", + model_type: "embedding", + model_provider: "OpenAI", + }, + { + model_id: "dialoqbase_eb_text-embedding-3-large", + name: "text-embedding-3-large (OpenAI)", + model_type: "embedding", + model_provider: "OpenAI", + } ]; const newModels = async () => { From 4f9822f220ceacf3b83d1a5c43d1e4334a7a2783 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Fri, 26 Jan 2024 11:13:37 +0530 Subject: [PATCH 2/9] Refactor filtering logic in BotForm and add disabled option for deprecated models --- app/ui/src/components/Common/BotForm.tsx | 12 ++++++++++-- server/src/handlers/api/v1/bot/bot/get.handler.ts | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/ui/src/components/Common/BotForm.tsx b/app/ui/src/components/Common/BotForm.tsx index dfdc4a34..604ce929 100644 --- a/app/ui/src/components/Common/BotForm.tsx +++ b/app/ui/src/components/Common/BotForm.tsx @@ -549,7 +549,10 @@ export const BotForm = ({ - (option?.label ?? "").includes(input) + (option?.label?.toLowerCase() ?? "").includes( + input?.toLowerCase() + ) || + (option?.value?.toLowerCase() ?? "").includes( + input?.toLowerCase() + ) } filterSort={(optionA, optionB) => (optionA?.label ?? "") diff --git a/server/src/handlers/api/v1/bot/bot/get.handler.ts b/server/src/handlers/api/v1/bot/bot/get.handler.ts index 188ae35a..2edcf4ef 100644 --- a/server/src/handlers/api/v1/bot/bot/get.handler.ts +++ b/server/src/handlers/api/v1/bot/bot/get.handler.ts @@ -145,8 +145,13 @@ export const getCreateBotConfigHandler = async ( .filter((model) => model.model_type === "embedding") .map((model) => { return { - label: model.name || model.model_id, + label: `${model.name || model.model_id} ${ + model.model_id === "dialoqbase_eb_dialoqbase-ollama" + ? "(Deprecated)" + : "" + }`, value: model.model_id, + disabled: model.model_id === "dialoqbase_eb_dialoqbase-ollama", }; }); @@ -191,8 +196,13 @@ export const getBotByIdSettingsHandler = async ( .filter((model) => model.model_type === "embedding") .map((model) => { return { - label: model.name || model.model_id, + label: `${model.name || model.model_id} ${ + model.model_id === "dialoqbase_eb_dialoqbase-ollama" + ? "(Deprecated)" + : "" + }`, value: model.model_id, + disabled: model.model_id === "dialoqbase_eb_dialoqbase-ollama", }; }); From 24680b3451a4a6da8f2462cf5277078cd04405d6 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Fri, 26 Jan 2024 11:31:42 +0530 Subject: [PATCH 3/9] Refactor IntegrationGrid component --- .../Bot/Integration/IntegrationCard.tsx | 96 +++++++++++++ .../Bot/Integration/IntegrationGrid.tsx | 136 ++++-------------- 2 files changed, 127 insertions(+), 105 deletions(-) create mode 100644 app/ui/src/components/Bot/Integration/IntegrationCard.tsx diff --git a/app/ui/src/components/Bot/Integration/IntegrationCard.tsx b/app/ui/src/components/Bot/Integration/IntegrationCard.tsx new file mode 100644 index 00000000..0dce046e --- /dev/null +++ b/app/ui/src/components/Bot/Integration/IntegrationCard.tsx @@ -0,0 +1,96 @@ +import React from "react"; +import { useDarkMode } from "../../../hooks/useDarkmode"; +import { Link } from "react-router-dom"; + +type Prosp = { + href?: string; + onClick?: () => void; + logo: string; + name: string; + color: string; + textColor: string; + status?: string; + description: string; +}; + +export const IntegrationCard: React.FC = ({ + href, + onClick, + logo, + name, + color, + textColor, + status, + description, +}) => { + const { mode } = useDarkMode(); + + return !href ? ( +
+ +
+ ) : ( + +
+
+
+ {name} +
+
+
+
+

+ {name} +

+

+ {description} +

+
+
+
+ + ); +}; diff --git a/app/ui/src/components/Bot/Integration/IntegrationGrid.tsx b/app/ui/src/components/Bot/Integration/IntegrationGrid.tsx index d62161a5..3859ca44 100644 --- a/app/ui/src/components/Bot/Integration/IntegrationGrid.tsx +++ b/app/ui/src/components/Bot/Integration/IntegrationGrid.tsx @@ -1,8 +1,8 @@ import { Modal } from "antd"; import React from "react"; import { IntegrationForm } from "./IntegrationForm"; -import { Link, useParams } from "react-router-dom"; -import { useDarkMode } from "../../../hooks/useDarkmode"; +import { useParams } from "react-router-dom"; +import { IntegrationCard } from "./IntegrationCard"; type Props = { data: { @@ -56,7 +56,6 @@ export const IntegrationGrid: React.FC = ({ data }) => { textColor: string; } | null>(); const param = useParams<{ id: string }>(); - const { mode } = useDarkMode(); return (
@@ -72,110 +71,37 @@ export const IntegrationGrid: React.FC = ({ data }) => { {/* GRID */}
{data.map((integration) => ( -
-
{ - setSelectedIntegration(integration); - setOpen(true); - }} - > -
-
- {integration.name} -
-

- {integration.status} -

-
-
-
-
-
-

- {integration.name} -

-

- {integration.description} -

-
-
-
-
+ { + setSelectedIntegration(integration); + setOpen(true); + }} + logo={integration.logo} + name={integration.name} + color={integration.color} + textColor={integration.textColor} + status={integration.status} + description={integration.description} + /> ))} - -
-
-
- HTML -
-
-
-
-

- HTML Embed -

-

- Embed your chatbot on your website or blog using HTML snippet. -

-
-
-
- - - -
-
-
- API -
-
-
-
-

- API -

-

- Customize your integration using our robust API. Connect and - expand the capabilities of your chatbot across platforms. -

-
-
-
- + + +
{/* MODAL */} From 5282f9a3f90886ad834b6612e6f4ec5d42adc30e Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Fri, 26 Jan 2024 11:40:39 +0530 Subject: [PATCH 4/9] Update DashboardGrid layout to support different screen sizes --- app/ui/src/components/Dashboard/DashboardGrid.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ui/src/components/Dashboard/DashboardGrid.tsx b/app/ui/src/components/Dashboard/DashboardGrid.tsx index 0e0740aa..f58decaa 100644 --- a/app/ui/src/components/Dashboard/DashboardGrid.tsx +++ b/app/ui/src/components/Dashboard/DashboardGrid.tsx @@ -28,7 +28,7 @@ export const DashboardGrid = () => { )} {status === "success" && data.length > 0 && ( -
+
{data.map((bot: any) => ( Date: Fri, 26 Jan 2024 17:02:45 +0530 Subject: [PATCH 5/9] Remove unnecessary code and comments --- docs/guide/self-hosting-railway.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/docs/guide/self-hosting-railway.md b/docs/guide/self-hosting-railway.md index 31d2e616..5b43ee68 100644 --- a/docs/guide/self-hosting-railway.md +++ b/docs/guide/self-hosting-railway.md @@ -25,13 +25,12 @@ Just click on the button below to deploy the template on Railway. You need to provide the following environment variables: -- `OPENAI_API_KEY` - `DATABASE_URL` -You can skip the rest of the steps by watching the video below. + - + ### Setting up a Supabase Database @@ -48,28 +47,26 @@ You need to remember the password you provide to the project 😁. #### 2. Copy the URL +:::warning +You must use `Session Mode` instead of `Connection Pool` otherwise the server will not work properly. +::: + Once the project is created, next step is to get the database URL. 1. Click on the cog icon on the left sidebar. 2. Click on the `Database` from project settings sidebar. -3. Scroll down to the `Connection String` section and select the `Node.js` tab. +3. Select `Session Mode` instead of `Connection Pool` and Select `Node.js` as the URL format. 4. Copy the `DATABASE_URL` and replace `[YOUR-PASSWORD]` with the password you provided to the project. 5. Paste the `DATABASE_URL` in the railway environment variables. - That's it! You have successfully setup the database. -### Setting up the OpenAI API Key - -Just copy paste your `OPENAI_API_KEY` in the railway environment variables. - - ### Launch the server After setting up the database and the OpenAI API Key, you can now launch the server by clicking `Deploy` button. This may take a few minutes to deploy the server be patient. \ No newline at end of file From 5efa3009b37c084159d8cfca493f97ff66807e68 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Fri, 26 Jan 2024 17:36:59 +0530 Subject: [PATCH 6/9] Add link to GitHub thread for Railway issues --- docs/guide/self-hosting-railway.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/guide/self-hosting-railway.md b/docs/guide/self-hosting-railway.md index 5b43ee68..0d07170c 100644 --- a/docs/guide/self-hosting-railway.md +++ b/docs/guide/self-hosting-railway.md @@ -6,6 +6,8 @@ Here are the steps to get a Railway instance of the dialoqbase server up and run Dialoqbase use nice amount of memory. So, make sure you add credit limit to your Railway account. ::: +In case any issue related to Railway, you can check out this thread on GitHub: [#203](https://github.com/n4ze3m/dialoqbase/issues/203) + ## Prerequisites From 4bd03c5d889b2dca14ca946c1b2e768b21747c6a Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Fri, 26 Jan 2024 23:15:14 +0530 Subject: [PATCH 7/9] Refactor apiKeyValidaton and apiKeyValidatonMessage functions --- server/src/utils/validate.ts | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/server/src/utils/validate.ts b/server/src/utils/validate.ts index 9bb64f3b..fa708b79 100644 --- a/server/src/utils/validate.ts +++ b/server/src/utils/validate.ts @@ -1,10 +1,15 @@ -export const apiKeyValidaton = (embeddingsType: string) => { - switch (embeddingsType.toLocaleLowerCase()) { +export const apiKeyValidaton = (modelType: string) => { + console.log("apiKeyValidaton", modelType); + switch (modelType.toLocaleLowerCase()) { case "transformer": case "jina": + case "ollama": + case "local": return true; case "jina-api": - return process.env.JINA_API_KEY ? process.env.JINA_API_KEY.length > 0 : false; + return process.env.JINA_API_KEY + ? process.env.JINA_API_KEY.length > 0 + : false; case "supabase": return true; case "google-bison": @@ -41,20 +46,13 @@ export const apiKeyValidaton = (embeddingsType: string) => { return process.env.FIREWORKS_API_KEY ? process.env.FIREWORKS_API_KEY.length > 0 : false; - case "ollama": - return process.env.OLLAMA_EMBEDDING_API_URL && process.env.OLLAMA_EMBEDDING_MODEL - ? process.env.OLLAMA_EMBEDDING_API_URL.length > 0 && process.env.OLLAMA_EMBEDDING_MODEL.length > 0 - : false; - - case "local": - return true; default: return false; } }; -export const apiKeyValidatonMessage = (embeddingsType: string) => { - switch (embeddingsType.toLowerCase()) { +export const apiKeyValidatonMessage = (modelType: string) => { + switch (modelType.toLowerCase()) { case "openai": case "openai-instruct": return "Please add OPENAI_API_KEY to your .env file"; @@ -76,6 +74,6 @@ export const apiKeyValidatonMessage = (embeddingsType: string) => { case "jina-api": return "Please add JINA_API_KEY to your .env file"; default: - return "Unable to validate API key" + return "Unable to validate API key"; } }; From 074e32248d2e6068d0c848a6143459e26a589293 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sat, 27 Jan 2024 00:32:11 +0530 Subject: [PATCH 8/9] Trim model_id in saveEmbedddingModelFromInputedUrlHandler --- server/src/handlers/api/v1/admin/model.handler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/handlers/api/v1/admin/model.handler.ts b/server/src/handlers/api/v1/admin/model.handler.ts index 2864ae41..944679a5 100644 --- a/server/src/handlers/api/v1/admin/model.handler.ts +++ b/server/src/handlers/api/v1/admin/model.handler.ts @@ -324,7 +324,7 @@ export const saveEmbedddingModelFromInputedUrlHandler = async ( await prisma.dialoqbaseModels.create({ data: { name: model_name, - model_id: `dialoqbase_eb_${model_id}`, + model_id: `dialoqbase_eb_${model_id}`.trim(), local_model: true, model_type: "embedding", model_provider: model_provider[api_type], From 9a4c6eb2074d526f7007f3ef74d572a9697652d1 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sat, 27 Jan 2024 00:40:32 +0530 Subject: [PATCH 9/9] Update ollama_url and url in SettingsModelRoot --- app/ui/src/routes/settings/model.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/ui/src/routes/settings/model.tsx b/app/ui/src/routes/settings/model.tsx index 5cc68304..344f7dc0 100644 --- a/app/ui/src/routes/settings/model.tsx +++ b/app/ui/src/routes/settings/model.tsx @@ -439,7 +439,7 @@ export default function SettingsModelRoot() { }} initialValues={{ api_type: "openai", - ollama_url: "http://localhost:11434", + ollama_url: "http://host.docker.internal:11434", }} > {apiType === "openai" && ( @@ -712,6 +712,9 @@ export default function SettingsModelRoot() { }} form={embeddingForm} layout="vertical" + initialValues={{ + url: "http://host.docker.internal:11434", + }} >