Skip to content

Commit

Permalink
feat: Add internal search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
n4ze3m committed Sep 6, 2024
1 parent c4daf3f commit 7bdefc7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "app",
"private": true,
"version": "1.10.1",
"version": "1.11.0",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
1 change: 1 addition & 0 deletions app/ui/src/hooks/useSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const useSettings = () => {
const response = await api.get("/user/info");
return response.data as {
isRegistrationAllowed: boolean;

};
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dialoqbase",
"version": "1.10.1",
"version": "1.11.0",
"description": "Create chatbots with ease",
"scripts": {
"ui:dev": "pnpm run --filter ui dev",
Expand Down
2 changes: 2 additions & 0 deletions server/prisma/migrations/q_14_7/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "DialoqbaseSettings" ADD COLUMN "internalSearchEnabled" BOOLEAN DEFAULT false;
1 change: 1 addition & 0 deletions server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ model DialoqbaseSettings {
dynamicallyFetchOllamaModels Boolean? @default(false)
hideDefaultModels Boolean? @default(false)
internetSearchEnabled Boolean? @default(false)
internalSearchEnabled Boolean? @default(false)
defaultChatModel String @default("gpt-3.5-turbo-dbase")
defaultEmbeddingModel String @default("dialoqbase_eb_text-embedding-ada-002")
ollamaURL String? @default("http://host.docker.internal:11434")
Expand Down
36 changes: 3 additions & 33 deletions server/src/handlers/api/v1/bot/bot/get.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@ import { FastifyReply, FastifyRequest } from "fastify";
import { GetBotRequestById, GetDatasourceByBotId } from "./types";
import { getSettings } from "../../../../../utils/common";
import { getAllOllamaModels } from "../../../../../utils/ollama";
const preprocessSearchTerms = (searchTerm: string) => {
const tsquerySpecialChars = /[()|&:*!]/g
const search = searchTerm
.trim()
.replace(tsquerySpecialChars, ' ')
.split(/\s+/)
.join(' | ')
return search
}

export const getBotByIdEmbeddingsHandler = async (
request: FastifyRequest<GetBotRequestById>,
reply: FastifyReply
Expand Down Expand Up @@ -77,18 +69,7 @@ export const getDatasourceByBotId = async (
OR: search
? [
{
content: {
search: preprocessSearchTerms(search),
},
},
{
document: {
some: {
content: {
search: preprocessSearchTerms(search),
},
},
},
content: search,
},
]
: undefined,
Expand All @@ -111,18 +92,7 @@ export const getDatasourceByBotId = async (
OR: search
? [
{
content: {
search: preprocessSearchTerms(search),
},
},
{
document: {
some: {
content: {
search: preprocessSearchTerms(search),
},
},
},
content: search,
},
]
: undefined,
Expand Down

0 comments on commit 7bdefc7

Please sign in to comment.