From a099f8e296c8e4a7de4b6257102b97e0d5f75e3c Mon Sep 17 00:00:00 2001 From: Weves Date: Thu, 14 Dec 2023 23:05:08 -0800 Subject: [PATCH] Rework header a bit + remove assumption of all personas having a prompt --- .../versions/b156fa702355_chat_reworked.py | 1 - web/src/app/admin/personas/PersonaEditor.tsx | 6 +++--- web/src/app/chat/Chat.tsx | 1 - web/src/components/Header.tsx | 15 ++++++++------- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/backend/alembic/versions/b156fa702355_chat_reworked.py b/backend/alembic/versions/b156fa702355_chat_reworked.py index 7e69926b4..05e5fe56a 100644 --- a/backend/alembic/versions/b156fa702355_chat_reworked.py +++ b/backend/alembic/versions/b156fa702355_chat_reworked.py @@ -40,7 +40,6 @@ def upgrade() -> None: # This is irrecoverable, whatever op.execute("DELETE FROM chat_feedback") op.execute("DELETE FROM document_retrieval_feedback") - op.execute("DELETE FROM persona") op.create_table( "search_doc", diff --git a/web/src/app/admin/personas/PersonaEditor.tsx b/web/src/app/admin/personas/PersonaEditor.tsx index 193e32bcb..a7b979e2d 100644 --- a/web/src/app/admin/personas/PersonaEditor.tsx +++ b/web/src/app/admin/personas/PersonaEditor.tsx @@ -67,10 +67,10 @@ export function PersonaEditor({ const existingPrompt = existingPersona?.prompts[0] ?? null; useEffect(() => { - if (isUpdate) { + if (isUpdate && existingPrompt) { triggerFinalPromptUpdate( - existingPrompt!.system_prompt, - existingPrompt!.task_prompt, + existingPrompt.system_prompt, + existingPrompt.task_prompt, existingPersona.num_chunks === 0 ); } diff --git a/web/src/app/chat/Chat.tsx b/web/src/app/chat/Chat.tsx index 6b0449c36..ca7e26498 100644 --- a/web/src/app/chat/Chat.tsx +++ b/web/src/app/chat/Chat.tsx @@ -35,7 +35,6 @@ import { buildFilters } from "@/lib/search/utils"; import { QA, SearchTypeSelector } from "./modifiers/SearchTypeSelector"; import { SelectedDocuments } from "./modifiers/SelectedDocuments"; import { usePopup } from "@/components/admin/connectors/Popup"; -import { useSWRConfig } from "swr"; const MAX_INPUT_HEIGHT = 200; diff --git a/web/src/components/Header.tsx b/web/src/components/Header.tsx index f521a84bb..a4a04244d 100644 --- a/web/src/components/Header.tsx +++ b/web/src/components/Header.tsx @@ -2,13 +2,13 @@ import { User } from "@/lib/types"; import { logout } from "@/lib/user"; -import { UserCircle } from "@phosphor-icons/react"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/navigation"; import React, { useEffect, useRef, useState } from "react"; import { CustomDropdown, DefaultDropdownElement } from "./Dropdown"; import { FiMessageSquare, FiSearch } from "react-icons/fi"; +import { usePathname } from "next/navigation"; interface HeaderProps { user: User | null; @@ -16,6 +16,7 @@ interface HeaderProps { export const Header: React.FC = ({ user }) => { const router = useRouter(); + const pathname = usePathname(); const [dropdownOpen, setDropdownOpen] = useState(false); const dropdownRef = useRef(null); @@ -68,21 +69,21 @@ export const Header: React.FC = ({ user }) => { -
-
+
+
-

Search

+

Search

-
+
-

Chat

+

Chat