From 808d9dad51b8da84d3a630dd906eb66de503f2b4 Mon Sep 17 00:00:00 2001
From: Vidyoot Senthil
Date: Wed, 18 Dec 2024 15:03:11 -0600
Subject: [PATCH] Revert "Merge branch 'main' into
vs/feature-add-video-link-public-page"
This reverts commit cb1251bfe135465dc22f601e185884790fbb60f7, reversing
changes made to db1a735f73e89571d59c2cd399518bb17784d872.
---
clients/search-component/README.md | 3 +-
clients/search-component/package.json | 5 +-
.../src/TrieveModal/Chat/AIInitalMessage.tsx | 2 +-
.../src/TrieveModal/Chat/Carousel.tsx | 39 +-
.../src/TrieveModal/Chat/ChatMode.tsx | 6 +-
.../src/TrieveModal/Search/ProductItem.tsx | 28 +-
.../src/TrieveModal/Search/SearchMode.tsx | 2 +-
.../search-component/src/TrieveModal/Tags.tsx | 6 +-
.../src/TrieveModal/index.css | 71 +-
.../src/TrieveModal/index.tsx | 46 +-
.../src/utils/hooks/chat-context.tsx | 11 +-
.../src/utils/hooks/modal-context.tsx | 3 -
.../src/utils/hooks/setClickTriggers.ts | 29 +-
clients/search-component/tailwind.config.js | 1 -
clients/ts-sdk/openapi.json | 31 -
clients/ts-sdk/package.json | 2 +-
clients/ts-sdk/src/types.gen.ts | 8 -
.../src/components/Layouts/MainLayout.tsx | 20 -
.../pages/tablePages/RAGAnalyticsPage.tsx | 4 -
frontends/dashboard/src/components/Routes.ts | 7 -
.../dataset-settings/TrackingIdUpdater.tsx | 14 +-
.../src/pages/dataset/PublicPageSettings.tsx | 91 +-
.../search/src/components/UploadFile.tsx | 8 +-
frontends/shared/types.ts | 1 -
.../1734399996_add_top_score_for_rag/down.sql | 1 -
.../1734399996_add_top_score_for_rag/up.sql | 1 -
server/src/data/models.rs | 10 +-
server/src/handlers/chunk_handler.rs | 20 +-
server/src/handlers/page_handler.rs | 10 -
server/src/lib.rs | 1 -
server/src/middleware/auth_middleware.rs | 23 +-
server/src/operators/message_operator.rs | 16 +-
server/src/operators/qdrant_operator.rs | 6 +-
server/src/public/navbar.html | 4 +-
server/src/public/page.html | 40 +-
server/src/public/product.html | 11 +-
server/src/public/search-component-code.html | 18 +-
server/src/public/tabs.html | 5 -
server/static/output.css | 55 +-
yarn.lock | 2014 +++++++++--------
40 files changed, 1185 insertions(+), 1488 deletions(-)
delete mode 100644 server/ch_migrations/1734399996_add_top_score_for_rag/down.sql
delete mode 100644 server/ch_migrations/1734399996_add_top_score_for_rag/up.sql
diff --git a/clients/search-component/README.md b/clients/search-component/README.md
index e93c7760b5..bb439ada13 100644
--- a/clients/search-component/README.md
+++ b/clients/search-component/README.md
@@ -99,8 +99,7 @@ declare module "solid-js" {
| problemLink | string (example: "mailto:help@trieve.ai?subject=") | null |
| responsive | boolean | false |
| floatingButtonPosition | "top-left", "top-right", "bottom-left", or "bottom-right" | "bottom-right" |
-| showFloatingButton | boolean | false |
-| buttonTriggers | { selector: "query-selector", mode: "chat" | "search" }[] | [] |
+| showFloatingButton | boolean | false |
### Search Results
diff --git a/clients/search-component/package.json b/clients/search-component/package.json
index ad8652e69a..aa457ee1c4 100644
--- a/clients/search-component/package.json
+++ b/clients/search-component/package.json
@@ -19,7 +19,7 @@
"import": "./dist/vanilla/index.js"
}
},
- "version": "0.2.30",
+ "version": "0.2.26",
"license": "MIT",
"homepage": "https://github.com/devflowinc/trieve/tree/main/clients/search-component",
"scripts": {
@@ -29,7 +29,6 @@
"lint": "eslint",
"build:clean": "rm -rf dist && yarn type:dts && yarn build",
"build": "run-s build:src build:css type:dts",
- "build:watch": "run-p watch:js build:src build:css type:dts",
"build:src": "node ./scripts/build.js",
"type:dts": "tsc --emitDeclarationOnly --declarationMap",
"build:css": "npx postcss src/app.css -o dist/index.css && cp src/styles.d.ts dist/",
@@ -57,7 +56,7 @@
"react-dom": "^18.3.1",
"tailwind": "^4.0.0",
"tailwindcss": "^3.4.11",
- "tailwindcss-scoped-preflight": "^3.4.10",
+ "tailwindcss-scoped-preflight": "^3.4.4",
"typescript": "^5.6.2",
"typescript-eslint": "^8.3.0"
},
diff --git a/clients/search-component/src/TrieveModal/Chat/AIInitalMessage.tsx b/clients/search-component/src/TrieveModal/Chat/AIInitalMessage.tsx
index e60bed62c4..42108d648b 100644
--- a/clients/search-component/src/TrieveModal/Chat/AIInitalMessage.tsx
+++ b/clients/search-component/src/TrieveModal/Chat/AIInitalMessage.tsx
@@ -38,7 +38,7 @@ export const AIInitialMessage = () => {
I'm an AI assistant with access to documentation, help articles, and
other content.
-
+
Ask me anything about{" "}
{
const goToPage = (pageIndex: number) => setCurrentPage(pageIndex);
return (
-
-
+
+
{allProductsCarousel.map((child, index) => (
-
@@ -95,7 +126,7 @@ export const Carousel = ({ children }: { children: React.ReactNode }) => {
))}
{numPages > 1 && (
-
+
-
+
diff --git a/clients/search-component/src/TrieveModal/Search/ProductItem.tsx b/clients/search-component/src/TrieveModal/Search/ProductItem.tsx
index 9901bad8f5..2af0d468e7 100644
--- a/clients/search-component/src/TrieveModal/Search/ProductItem.tsx
+++ b/clients/search-component/src/TrieveModal/Search/ProductItem.tsx
@@ -178,21 +178,21 @@ export const ProductItem = ({
featured_image: { src: string };
title: string;
}[]
- )
- ?.filter((variant) => variant.featured_image?.src)
- ?.map((variant) => (
-
+ ))}
) : null}
>
diff --git a/clients/search-component/src/TrieveModal/Search/SearchMode.tsx b/clients/search-component/src/TrieveModal/Search/SearchMode.tsx
index e6ce54e53c..24dfcb8c6b 100644
--- a/clients/search-component/src/TrieveModal/Search/SearchMode.tsx
+++ b/clients/search-component/src/TrieveModal/Search/SearchMode.tsx
@@ -102,7 +102,7 @@ export const SearchMode = () => {
}, [results]);
return (
-
}>
+
}>
setOpen(false)}
diff --git a/clients/search-component/src/TrieveModal/Tags.tsx b/clients/search-component/src/TrieveModal/Tags.tsx
index 046af61fd1..0e2015c6a3 100644
--- a/clients/search-component/src/TrieveModal/Tags.tsx
+++ b/clients/search-component/src/TrieveModal/Tags.tsx
@@ -29,7 +29,7 @@ export const Tags = () => {
-
to select
+
to select
-
@@ -38,13 +38,13 @@ export const Tags = () => {
- to navigate
+ to navigate
-
- to close
+ to close
))
diff --git a/clients/search-component/src/TrieveModal/index.css b/clients/search-component/src/TrieveModal/index.css
index d2c496fe6e..c30e1c21b0 100644
--- a/clients/search-component/src/TrieveModal/index.css
+++ b/clients/search-component/src/TrieveModal/index.css
@@ -15,7 +15,7 @@
body {
#trieve-search-modal-overlay {
- @apply bg-black/60 w-screen fixed inset-0 h-screen animate-overlayShow backdrop-blur-sm;
+ @apply bg-black/60 w-screen fixed inset-0 h-screen animate-overlayShow backdrop-blur-sm z-[998];
}
.close-icon {
@@ -23,7 +23,7 @@ body {
}
#trieve-search-modal {
- @apply animate-contentShow scroll-smooth fixed top-[calc(40%-30vh)] left-[50%] max-h-[60vh] w-[90vw] sm:max-w-[800px] -translate-x-[50%] rounded-lg shadow-2xl focus:outline-none z-[999] overflow-hidden text-base;
+ @apply animate-contentShow scroll-smooth fixed top-[calc(40%-30vh)] sm:top-[calc(25vh-225px)] left-[50%] max-h-[60vh] w-[90vw] sm:max-w-[800px] -translate-x-[50%] rounded-lg shadow-2xl focus:outline-none z-[999] overflow-hidden text-base;
color: var(--tv-zinc-950);
background-color: var(--tv-zinc-50);
@@ -33,10 +33,6 @@ body {
@apply pl-2 flex gap-2 w-full overflow-x-auto;
}
- .suspense-fallback {
- @apply hidden;
- }
-
::-webkit-scrollbar {
width: 6px;
height: 6px;
@@ -60,7 +56,7 @@ body {
}
&.chat-modal-mobile {
- @apply flex flex-col top-0 sm:top-[calc(40%-30vh)] pt-4 max-h-[100vh] w-full sm:w-[90vw] rounded-none sm:rounded-lg;
+ @apply flex flex-col top-0 sm:top-[calc(25vh-225px)] pt-4 max-h-[100vh] w-full sm:w-[90vw] rounded-none sm:rounded-lg;
.chat-outer-wrapper {
@apply justify-between w-full h-full mt-10 sm:mt-12;
@@ -192,7 +188,7 @@ body {
}
.trieve-footer {
- @apply sticky px-3 items-center bottom-[1px] flex flex-col;
+ @apply sticky px-3 items-center bottom-0 flex flex-col;
background-color: var(--tv-zinc-50);
border-color: var(--tv-zinc-200);
@@ -313,44 +309,6 @@ body {
.additional-image-links {
@apply gap-2 mt-4 mb-4 flex flex-row;
- .carousel-root {
- width: 100%;
- overflow: hidden;
- }
-
- .carousel-scroll {
- display: flex;
- overflow-x: hidden;
- scroll-snap-type: x-mandatory;
- scroll-behavior: smooth;
- width: 100%;
- list-style: none;
- padding: 0;
- margin: 0;
- }
-
- .carousel-item {
- flex: 0 0 auto;
- padding: 1rem;
- scroll-snap-align: start;
- box-sizing: border-box;
- }
-
- .carousel-item-hidden {
- visibility: hidden;
- }
-
- .carousel-item-visibile {
- visibility: visible;
- }
-
- .carousel-controls {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-top: 5px;
- }
-
a {
@apply hover:bg-zinc-200 text-zinc-700 hover:text-zinc-950 rounded px-2 text-xs py-1 line-clamp-2 overflow-ellipsis grid-rows-2 w-fit;
}
@@ -540,12 +498,8 @@ body {
}
}
- .brand-paragraph {
- @apply leading-8;
- }
-
.brand-name {
- @apply text-white px-1.5 py-1 rounded-md font-[500] whitespace-nowrap text-ellipsis;
+ @apply text-white px-1.5 py-1 rounded-md font-[500];
}
}
}
@@ -575,11 +529,7 @@ body {
/* SUGGESTED QUESTIONS */
.system-information-wrapper {
- @apply mb-10;
-
- &.with-group {
- @apply mb-24;
- }
+ @apply mb-8;
p {
@apply mb-6 sm:mb-4;
@@ -689,14 +639,11 @@ body {
}
&:focus {
- border: 1px solid var(--tv-prop-brand-color);
+ border: 1.5px solid var(--tv-prop-brand-color);
+ transform: translateY(-0.1px) scale(1.0006);
}
}
- input.search-input {
- @apply pr-8;
- }
-
input.search-input.ecommerce {
@apply rounded-sm;
}
@@ -798,7 +745,7 @@ body {
}
&.start-chat {
- @apply items-center flex max-w-[calc(90vw)] sm:max-w-none;
+ @apply items-center flex max-w-[calc(90vw-70px)] sm:max-w-none;
h4 {
@apply pl-0 pt-0 max-w-[calc(90vw-120px)] sm:max-w-[400px];
diff --git a/clients/search-component/src/TrieveModal/index.tsx b/clients/search-component/src/TrieveModal/index.tsx
index 7566b8e8db..70ce614cbe 100644
--- a/clients/search-component/src/TrieveModal/index.tsx
+++ b/clients/search-component/src/TrieveModal/index.tsx
@@ -18,45 +18,10 @@ import { FloatingActionButton } from "./FloatingActionButton";
const Modal = () => {
useKeyboardNavigation();
+ setClickTriggers();
const { mode, open, setOpen, setMode, props } = useModalState();
const { askQuestion, chatWithGroup } = useChatState();
- useEffect(() => {
- setClickTriggers(
- setOpen,
- setMode,
- props
- );
- }, []);
-
- useEffect(() => {
- const onViewportResize = () => {
- const viewportHeight = window.visualViewport?.height;
- const trieveSearchModal = document.getElementById("trieve-search-modal");
- if (trieveSearchModal) {
- trieveSearchModal.style.maxHeight = `${viewportHeight}px`;
- }
-
- const chatOuterWrapper = document.querySelector(
- ".chat-outer-wrapper"
- );
- if (chatOuterWrapper) {
- (chatOuterWrapper as HTMLElement).style.maxHeight =
- `calc(${viewportHeight}px - 100px)`;
- }
- if (chatOuterWrapper) {
- chatOuterWrapper.scrollTop =
- chatOuterWrapper.scrollHeight;
- }
- };
-
- window.addEventListener("resize", onViewportResize);
-
- return () => {
- window.removeEventListener("resize", onViewportResize);
- };
- }, [open]);
-
useEffect(() => {
const script = document.createElement("script");
script.src =
@@ -112,7 +77,7 @@ const Modal = () => {
document.documentElement.style.setProperty(
"--tv-prop-brand-font-family",
props.brandFontFamily ??
- `Maven Pro, ui-sans-serif, system-ui, sans-serif,
+ `Maven Pro, ui-sans-serif, system-ui, sans-serif,
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"`
);
}, [props.brandColor, props.brandFontFamily]);
@@ -134,13 +99,12 @@ const Modal = () => {
setOpen(false);
}}
id="trieve-search-modal-overlay"
- style={{ zIndex: props.zIndex ?? 1000 }}
>
{props.allowSwitchingModes &&
}
{
isDoneReading.current = false;
-
- if (!currentGroup && group) {
- chatWithGroup(group);
- setCurrentGroup(group);
- }
-
setMessages((m) => [
...m,
[
@@ -280,6 +274,11 @@ function ChatProvider({ children }: { children: React.ReactNode }) {
],
]);
+ if (!currentGroup && group) {
+ chatWithGroup(group);
+ setCurrentGroup(group);
+ }
+
if (!currentTopic && !currentGroup && !group) {
await createTopic({ question: question || currentQuestion });
} else {
diff --git a/clients/search-component/src/utils/hooks/modal-context.tsx b/clients/search-component/src/utils/hooks/modal-context.tsx
index 39beb6502c..70190a108b 100644
--- a/clients/search-component/src/utils/hooks/modal-context.tsx
+++ b/clients/search-component/src/utils/hooks/modal-context.tsx
@@ -79,9 +79,7 @@ export type ModalProps = {
buttonTriggers?: {
selector: string;
mode: SearchModes;
- removeListeners?: boolean;
}[];
- zIndex?: number;
showFloatingButton?: boolean;
floatingButtonPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
};
@@ -112,7 +110,6 @@ const defaultProps = {
openLinksInNewTab: false,
currencyPosition: "before" as currencyPosition,
responsive: false,
- zIndex: 1000,
debounceMs: 0,
show: true,
position: "bottom-right" as
diff --git a/clients/search-component/src/utils/hooks/setClickTriggers.ts b/clients/search-component/src/utils/hooks/setClickTriggers.ts
index d63434549c..2cd040dba8 100644
--- a/clients/search-component/src/utils/hooks/setClickTriggers.ts
+++ b/clients/search-component/src/utils/hooks/setClickTriggers.ts
@@ -1,32 +1,11 @@
import { startTransition } from "react";
-import { ModalProps, SearchModes } from "./modal-context";
+import { useModalState } from "./modal-context";
-export const setClickTriggers = (
- setOpen: (open: boolean) => void,
- setMode: React.Dispatch
>,
- props: ModalProps
-) => {
- const removeAllClickListeners = (selector: string): Element | null => {
- const element: Element | null = document.querySelector(selector);
- if (!element) return null;
- // Vue click attributes
- element.removeAttribute("@click.prevent");
- element.removeAttribute("@click");
- // @ts-expect-error Property 'href' does not exist on type 'Element'. [2339]
- element.href = "#";
-
- const newElement = element.cloneNode(true);
- element?.parentNode?.replaceChild(newElement, element);
- return newElement as unknown as Element;
- }
+export const setClickTriggers = () => {
+ const { setOpen, setMode, props } = useModalState();
props.buttonTriggers?.forEach((trigger) => {
- let element: Element | null = document.querySelector(trigger.selector);
- if (trigger.removeListeners ?? true) {
- element = removeAllClickListeners(trigger.selector);
- console.log("Removed click listeners from", trigger.selector);
- }
-
+ const element = document.querySelector(trigger.selector);
if (element) {
element.addEventListener("click", () => {
startTransition(() => {
diff --git a/clients/search-component/tailwind.config.js b/clients/search-component/tailwind.config.js
index 1542a46765..edf8a02fb5 100644
--- a/clients/search-component/tailwind.config.js
+++ b/clients/search-component/tailwind.config.js
@@ -17,7 +17,6 @@ export default {
"#trieve-search-component",
"#trieve-search-modal",
"#trieve-search-modal-overlay",
- "#open-trieve-modal"
],
{
rootStyles: true,
diff --git a/clients/ts-sdk/openapi.json b/clients/ts-sdk/openapi.json
index 060b29a421..a361546528 100644
--- a/clients/ts-sdk/openapi.json
+++ b/clients/ts-sdk/openapi.json
@@ -6967,25 +6967,6 @@
}
}
},
- "ButtonTrigger": {
- "type": "object",
- "required": [
- "selector",
- "mode"
- ],
- "properties": {
- "mode": {
- "type": "string"
- },
- "removeTriggers": {
- "type": "boolean",
- "nullable": true
- },
- "selector": {
- "type": "string"
- }
- }
- },
"CTRAnalytics": {
"oneOf": [
{
@@ -12295,13 +12276,6 @@
"type": "string",
"nullable": true
},
- "buttonTriggers": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/ButtonTrigger"
- },
- "nullable": true
- },
"chat": {
"type": "boolean",
"nullable": true
@@ -12451,11 +12425,6 @@
"useGroupSearch": {
"type": "boolean",
"nullable": true
- },
- "zIndex": {
- "type": "integer",
- "format": "int32",
- "nullable": true
}
}
},
diff --git a/clients/ts-sdk/package.json b/clients/ts-sdk/package.json
index 8a07aeeb70..8553d7af4a 100644
--- a/clients/ts-sdk/package.json
+++ b/clients/ts-sdk/package.json
@@ -6,7 +6,7 @@
"files": [
"dist"
],
- "version": "0.0.45",
+ "version": "0.0.44",
"license": "MIT",
"scripts": {
"lint": "eslint 'src/**/*.ts'",
diff --git a/clients/ts-sdk/src/types.gen.ts b/clients/ts-sdk/src/types.gen.ts
index 4da65f5c7e..873629405c 100644
--- a/clients/ts-sdk/src/types.gen.ts
+++ b/clients/ts-sdk/src/types.gen.ts
@@ -130,12 +130,6 @@ export type BulkDeleteChunkPayload = {
filter: ChunkFilter;
};
-export type ButtonTrigger = {
- mode: string;
- removeTriggers?: (boolean) | null;
- selector: string;
-};
-
export type CTRAnalytics = {
filter?: ((SearchAnalyticsFilter) | null);
type: 'search_ctr_metrics';
@@ -2051,7 +2045,6 @@ export type PublicPageParameters = {
brandFontFamily?: (string) | null;
brandLogoImgSrcUrl?: (string) | null;
brandName?: (string) | null;
- buttonTriggers?: Array | null;
chat?: (boolean) | null;
creatorLinkedInUrl?: (string) | null;
creatorName?: (string) | null;
@@ -2082,7 +2075,6 @@ export type PublicPageParameters = {
type?: (string) | null;
useGroupSearch?: (boolean) | null;
videoLink?: (string) | null;
- zIndex?: (number) | null;
};
export type PublicPageSearchOptions = {
diff --git a/frontends/chat/src/components/Layouts/MainLayout.tsx b/frontends/chat/src/components/Layouts/MainLayout.tsx
index 69f9a05a97..02f8e2c7f8 100644
--- a/frontends/chat/src/components/Layouts/MainLayout.tsx
+++ b/frontends/chat/src/components/Layouts/MainLayout.tsx
@@ -85,9 +85,6 @@ const MainLayout = (props: LayoutProps) => {
null,
);
- const [highlightResults, setHighlightResults] = createSignal(
- null,
- );
const [streamCompletionsFirst, setStreamCompletionsFirst] = createSignal<
boolean | null
>(null);
@@ -247,9 +244,6 @@ const MainLayout = (props: LayoutProps) => {
use_group_search: useGroupSearch(),
search_type: searchType(),
context_options: contextOptions(),
- highlight_options: {
- highlight_results: highlightResults(),
- },
}),
signal: completionAbortController().signal,
});
@@ -458,20 +452,6 @@ const MainLayout = (props: LayoutProps) => {
tabIndex={0}
>
-
-
- {
- setHighlightResults(e.target.checked);
- }}
- />
-
-
-
-
- }
- />
-
-
{
- return `${trigger.selector},${trigger.mode}`;
- }) ?? []
- }
- onChange={(e) => {
- setExtraParams(
- "buttonTriggers",
- e.map((trigger) => {
- const [selector, mode, replace] = trigger.split(",");
- if (replace) {
- return {
- selector,
- mode,
- removeTriggers: replace === "true",
- };
- }
- return {
- selector,
- mode,
- removeTriggers: false,
- };
- }),
- );
- }}
- addLabel="Add Trigger"
- addClass="text-sm"
- inputClass="block w-full rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6"
- />
-
+
@@ -787,54 +746,6 @@ const PublicPageControls = () => {
options={["search", "chat"]}
/>
-
-
-
-
- }
- />
-
-
-
-
-
-
-
- }
- />
-
-
{
- setExtraParams(
- "zIndex",
- parseInt(e.currentTarget.value),
- );
- }}
- class="block w-full rounded border border-neutral-300 px-3 py-1.5 shadow-sm placeholder:text-neutral-400 focus:outline-magenta-500 sm:text-sm sm:leading-6"
- />
-
diff --git a/frontends/search/src/components/UploadFile.tsx b/frontends/search/src/components/UploadFile.tsx
index 11922acd38..5d6f5570a2 100644
--- a/frontends/search/src/components/UploadFile.tsx
+++ b/frontends/search/src/components/UploadFile.tsx
@@ -148,7 +148,7 @@ export const UploadFile = () => {
{
link: link() === "" ? undefined : link(),
tag_set:
- tagSet().split(",").length > 0 ? tagSet().split(",") : undefined,
+ tagSet().split(",").length > 0 ? undefined : tagSet().split(","),
split_delimiters: splitDelimiters(),
target_splits_per_chunk: targetSplitsPerChunk(),
rebalance_chunks: rebalanceChunks(),
@@ -168,9 +168,9 @@ export const UploadFile = () => {
let base64File = await toBase64(file);
base64File = base64File
.split(",")[1]
- .replace(/\+/g, "-")
- .replace(/\//g, "_")
- .replace(/=+$/, "");
+ .replace(/\+/g, "-") // Convert '+' to '-'
+ .replace(/\//g, "_") // Convert '/' to '_'
+ .replace(/=+$/, ""); // Remove ending '='
const requestBody: RequestBody = {
...requestBodyTemplate,
base64_file: base64File,
diff --git a/frontends/shared/types.ts b/frontends/shared/types.ts
index 6d63a44a82..88fc11650f 100644
--- a/frontends/shared/types.ts
+++ b/frontends/shared/types.ts
@@ -638,7 +638,6 @@ export interface RagQueryEvent {
note?: string;
rating: number;
};
- top_score: number;
hallucination_score?: number;
detected_hallucinations?: string[];
}
diff --git a/server/ch_migrations/1734399996_add_top_score_for_rag/down.sql b/server/ch_migrations/1734399996_add_top_score_for_rag/down.sql
deleted file mode 100644
index 1168fb8ca0..0000000000
--- a/server/ch_migrations/1734399996_add_top_score_for_rag/down.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE rag_queries DROP COLUMN IF EXISTS top_score;
\ No newline at end of file
diff --git a/server/ch_migrations/1734399996_add_top_score_for_rag/up.sql b/server/ch_migrations/1734399996_add_top_score_for_rag/up.sql
deleted file mode 100644
index 4548dee243..0000000000
--- a/server/ch_migrations/1734399996_add_top_score_for_rag/up.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE rag_queries ADD COLUMN IF NOT EXISTS top_score INT DEFAULT 0;
\ No newline at end of file
diff --git a/server/src/data/models.rs b/server/src/data/models.rs
index a8e88c26ea..94a9ea6774 100644
--- a/server/src/data/models.rs
+++ b/server/src/data/models.rs
@@ -3153,9 +3153,6 @@ impl DatasetConfigurationDTO {
show_floating_button: page_parameters_self
.show_floating_button
.or(page_parameters_curr.show_floating_button),
- button_triggers: page_parameters_self
- .button_triggers
- .or(page_parameters_curr.button_triggers),
debounce_ms: page_parameters_self
.debounce_ms
.or(page_parameters_curr.debounce_ms),
@@ -3195,9 +3192,6 @@ impl DatasetConfigurationDTO {
brand_font_family: page_parameters_self
.brand_font_family
.or(page_parameters_curr.brand_font_family),
- z_index: page_parameters_self
- .z_index
- .or(page_parameters_curr.z_index),
video_link: page_parameters_self
.video_link
.or(page_parameters_curr.video_link),
@@ -5115,7 +5109,7 @@ impl RagQueryEventClickhouse {
user_message: self.user_message,
search_id: uuid::Uuid::from_bytes(*self.search_id.as_bytes()),
results,
- top_score: self.top_score,
+ top_score: 0.0,
query_rating,
dataset_id: uuid::Uuid::from_bytes(*self.dataset_id.as_bytes()),
llm_response: self.llm_response,
@@ -5137,7 +5131,6 @@ pub struct RagQueryEventClickhouse {
pub search_id: uuid::Uuid,
pub results: Vec
,
pub json_results: Vec,
- pub top_score: f32,
pub query_rating: String,
pub llm_response: String,
#[serde(with = "clickhouse::serde::uuid")]
@@ -5942,7 +5935,6 @@ impl EventTypes {
.collect(),
query_rating: serde_json::to_string(&query_rating).unwrap_or("".to_string()),
llm_response: llm_response.unwrap_or_default(),
- top_score: 0.0,
dataset_id,
created_at: OffsetDateTime::now_utc(),
user_id: user_id.unwrap_or_default(),
diff --git a/server/src/handlers/chunk_handler.rs b/server/src/handlers/chunk_handler.rs
index 4de62429a1..1b9971cbfa 100644
--- a/server/src/handlers/chunk_handler.rs
+++ b/server/src/handlers/chunk_handler.rs
@@ -2466,6 +2466,7 @@ pub async fn generate_off_chunks(
};
let chunk_ids = data.chunk_ids.clone();
+ let prompt = data.prompt.clone();
let stream_response = data.stream_response;
let context_options = data.context_options.clone();
@@ -2476,8 +2477,8 @@ pub async fn generate_off_chunks(
DatasetConfiguration::from_json(dataset_org_plan_sub.dataset.server_configuration);
let base_url = dataset_config.LLM_BASE_URL;
- let rag_prompt = dataset_config.RAG_PROMPT.clone();
- let chosen_model = dataset_config.LLM_DEFAULT_MODEL;
+
+ let default_model = dataset_config.LLM_DEFAULT_MODEL;
let base_url = if base_url.is_empty() {
"https://openrouter.ai/api/v1".into()
@@ -2599,8 +2600,7 @@ pub async fn generate_off_chunks(
let last_prev_message = prev_messages
.last()
- .expect("There needs to be at least 1 prior message")
- .clone();
+ .expect("There needs to be at least 1 prior message");
let mut prev_messages = prev_messages.clone();
@@ -2610,17 +2610,19 @@ pub async fn generate_off_chunks(
.iter()
.for_each(|message| messages.push(ChatMessage::from(message.clone())));
+ let prompt = prompt.unwrap_or("Respond to the question or instruction using the docs and include the doc numbers that you used in square brackets at the end of the sentences that you used the docs for:\n\n".to_string());
+
messages.push(ChatMessage::User {
content: ChatMessageContent::Text(format!(
"{} {}",
- rag_prompt,
+ prompt,
last_prev_message.content.clone()
)),
name: None,
});
let parameters = ChatCompletionParameters {
- model: chosen_model,
+ model: default_model,
stream: stream_response,
messages,
top_p: None,
@@ -2727,8 +2729,7 @@ pub async fn generate_off_chunks(
json.to_string()
})
.collect(),
- top_score: 0.0,
- user_message: format!("{} {}", rag_prompt, last_prev_message.content.clone()),
+ user_message: prompt,
query_rating: String::new(),
rag_type: "chosen_chunks".to_string(),
llm_response: completion_content.clone(),
@@ -2798,8 +2799,7 @@ pub async fn generate_off_chunks(
json.to_string()
})
.collect(),
- top_score: 0.0,
- user_message: format!("{} {}", rag_prompt, last_prev_message.content.clone()),
+ user_message: prompt,
rag_type: "chosen_chunks".to_string(),
query_rating: String::new(),
llm_response: completion,
diff --git a/server/src/handlers/page_handler.rs b/server/src/handlers/page_handler.rs
index 2e9dc8e430..0da4c5556c 100644
--- a/server/src/handlers/page_handler.rs
+++ b/server/src/handlers/page_handler.rs
@@ -136,14 +136,6 @@ pub struct OpenGraphMetadata {
description: Option,
}
-#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, Default)]
-#[serde(rename_all = "camelCase")]
-pub struct ButtonTrigger {
- selector: String,
- mode: String,
- remove_triggers: Option,
-}
-
#[derive(Serialize, Deserialize, Debug, Clone, ToSchema, Default)]
#[serde(rename_all = "camelCase")]
pub struct SingleProductOptions {
@@ -225,8 +217,6 @@ pub struct PublicPageParameters {
#[serde(skip_serializing_if = "Option::is_none")]
pub show_floating_button: Option,
#[serde(skip_serializing_if = "Option::is_none")]
- pub button_triggers: Option>,
- #[serde(skip_serializing_if = "Option::is_none")]
pub debounce_ms: Option,
#[serde(skip_serializing_if = "Option::is_none")]
pub hero_pattern: Option,
diff --git a/server/src/lib.rs b/server/src/lib.rs
index 7c92d751a6..1a7367fbfd 100644
--- a/server/src/lib.rs
+++ b/server/src/lib.rs
@@ -396,7 +396,6 @@ impl Modify for SecurityAddon {
operators::crawl_operator::Metadata,
operators::crawl_operator::Sitemap,
handlers::stripe_handler::CreateSetupCheckoutSessionResPayload,
- handlers::page_handler::ButtonTrigger,
handlers::page_handler::PublicPageSearchOptions,
handlers::page_handler::OpenGraphMetadata,
handlers::page_handler::SingleProductOptions,
diff --git a/server/src/middleware/auth_middleware.rs b/server/src/middleware/auth_middleware.rs
index cafd7383b8..665e127454 100644
--- a/server/src/middleware/auth_middleware.rs
+++ b/server/src/middleware/auth_middleware.rs
@@ -121,29 +121,10 @@ where
}
}
- let curly_matcher =
- regex::Regex::new(r"\{[a-zA-Z0-9_-]+\}").expect("Valid regex");
-
let route = format!("{} {}", req.method(), req.match_info().as_str());
+
if let Some(api_key_scopes) = user_api_key.scopes {
- if !api_key_scopes.is_empty()
- && (api_key_scopes.contains(&Some(route.clone()))
- || api_key_scopes
- .iter()
- .filter_map(|scope| scope.as_ref())
- .any(|scope| {
- let wildcard_scope = curly_matcher
- .replace_all(scope, "[a-zA-Z0-9_-]+")
- .to_string();
- if let Ok(wildcard_scope_regex) =
- regex::Regex::new(&wildcard_scope)
- {
- wildcard_scope_regex.is_match(&route)
- } else {
- false
- }
- }))
- {
+ if !api_key_scopes.is_empty() && api_key_scopes.contains(&Some(route)) {
if let Some(ref mut user) = user {
user.user_orgs.iter_mut().for_each(|org| {
if org.organization_id
diff --git a/server/src/operators/message_operator.rs b/server/src/operators/message_operator.rs
index ce0d834013..4ff9393fbe 100644
--- a/server/src/operators/message_operator.rs
+++ b/server/src/operators/message_operator.rs
@@ -270,7 +270,7 @@ pub async fn get_rag_chunks_query(
pool: web::Data,
redis_pool: web::Data,
event_queue: web::Data,
-) -> Result<(SearchQueryEventClickhouse, Vec), actix_web::Error> {
+) -> Result<(uuid::Uuid, Vec), actix_web::Error> {
let mut query =
if let Some(create_message_query) = create_message_req_payload.search_query.clone() {
create_message_query
@@ -440,7 +440,7 @@ pub async fn get_rag_chunks_query(
.await;
}
Ok((
- clickhouse_search_event,
+ clickhouse_search_event.id,
result_groups
.group_chunks
.into_iter()
@@ -548,7 +548,7 @@ pub async fn get_rag_chunks_query(
.await;
}
Ok((
- clickhouse_search_event,
+ clickhouse_search_event.id,
result_chunks
.score_chunks
.iter()
@@ -679,7 +679,7 @@ pub async fn stream_response(
let rag_prompt = dataset_config.RAG_PROMPT.clone();
let chosen_model = dataset_config.LLM_DEFAULT_MODEL.clone();
- let (search_event, chunk_metadatas) = get_rag_chunks_query(
+ let (search_id, chunk_metadatas) = get_rag_chunks_query(
create_message_req_payload.clone(),
dataset_config.clone(),
dataset.clone(),
@@ -697,7 +697,7 @@ pub async fn stream_response(
Bytes::from(create_message_req_payload.no_result_message.unwrap()),
)]);
return Ok(HttpResponse::Ok()
- .insert_header(("TR-QueryID", search_event.id.to_string()))
+ .insert_header(("TR-QueryID", search_id.to_string()))
.streaming(response_stream));
}
@@ -953,8 +953,7 @@ pub async fn stream_response(
id: query_id,
created_at: time::OffsetDateTime::now_utc(),
dataset_id: dataset.id,
- search_id: search_event.id,
- top_score: search_event.top_score,
+ search_id,
results: vec![],
json_results: chunk_data,
user_message: user_message_query.clone(),
@@ -1050,9 +1049,8 @@ pub async fn stream_response(
let clickhouse_rag_event = RagQueryEventClickhouse {
id: query_id_arb,
created_at: time::OffsetDateTime::now_utc(),
- search_id: search_event.id,
- top_score: search_event.top_score,
dataset_id: dataset.id,
+ search_id,
results: vec![],
json_results: chunk_data,
user_message: user_message_query.clone(),
diff --git a/server/src/operators/qdrant_operator.rs b/server/src/operators/qdrant_operator.rs
index b6ced2d8e9..f8023c8f68 100644
--- a/server/src/operators/qdrant_operator.rs
+++ b/server/src/operators/qdrant_operator.rs
@@ -529,7 +529,11 @@ pub async fn update_qdrant_point_query(
.to_owned()
.iter_list()
.unwrap()
- .filter_map(|id| id.to_string().parse::().ok())
+ .map(|id| {
+ id.to_string()
+ .parse::()
+ .expect("group_id must be a valid uuid")
+ })
.collect::>()
} else {
vec![]
diff --git a/server/src/public/navbar.html b/server/src/public/navbar.html
index c22a584116..9a41de8c8d 100644
--- a/server/src/public/navbar.html
+++ b/server/src/public/navbar.html
@@ -1,6 +1,6 @@