-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcd354d
commit c43e0c0
Showing
13 changed files
with
215 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
type ColoredTextProps = { | ||
color: string; | ||
text: string; | ||
className?: string; | ||
}; | ||
|
||
// color should be a valid tailwind class | ||
export const ColoredText = ({ | ||
color, | ||
text, | ||
className = "", | ||
}: ColoredTextProps): JSX.Element => ( | ||
<span className={`${className} ${color}`}>{text}</span> | ||
); |
48 changes: 48 additions & 0 deletions
48
frontend/app/v2/chat/[chatId]/components/ShortCuts/ShortCuts.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { useTranslation } from "react-i18next"; | ||
import { MdKeyboardCommandKey } from "react-icons/md"; | ||
|
||
import { ShortcutItem } from "./components"; | ||
|
||
export const ShortCuts = (): JSX.Element => { | ||
const { t } = useTranslation(["chat"]); | ||
|
||
const shortcuts = [ | ||
{ | ||
content: [ | ||
t("shortcut_select_brain"), | ||
t("shortcut_select_file"), | ||
t("shortcut_choose_prompt"), | ||
], | ||
}, | ||
{ | ||
content: [ | ||
t("shortcut_create_brain"), | ||
t("shortcut_feed_brain"), | ||
t("shortcut_create_prompt"), | ||
], | ||
}, | ||
{ | ||
content: [ | ||
t("shortcut_manage_brains"), | ||
t("shortcut_go_to_user_page"), | ||
t("shortcut_go_to_shortcuts"), | ||
], | ||
}, | ||
]; | ||
|
||
return ( | ||
<div className="flex-1 flex flex-col mt-32 w-full shadow-md dark:shadow-primary/25 hover:shadow-xl transition-shadow rounded-xl overflow-hidden bg-white dark:bg-black border border-black/10 dark:border-white/25 p-4 pt-10"> | ||
<div className="flex items-center justify-center"> | ||
<MdKeyboardCommandKey className="text-4xl mr-2" /> | ||
<span className="font-bold text-2xl">{t("keyboard_shortcuts")}</span> | ||
</div> | ||
<div className="flex-1 flex items-center justify-center"> | ||
<div className="flex flex-row space-x-4"> | ||
{shortcuts.map((shortcut, index) => ( | ||
<ShortcutItem key={index} content={shortcut.content} /> | ||
))} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
15 changes: 15 additions & 0 deletions
15
frontend/app/v2/chat/[chatId]/components/ShortCuts/components/ShortCutItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
type ShortcutItemProps = { | ||
content: string[]; | ||
}; | ||
|
||
export const ShortcutItem = ({ content }: ShortcutItemProps): JSX.Element => { | ||
return ( | ||
<div className="bg-gray-100 rounded-lg p-4 flex-grow"> | ||
{content.map((text, index) => ( | ||
<p className="text-gray-500" key={index}> | ||
{text} | ||
</p> | ||
))} | ||
</div> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
frontend/app/v2/chat/[chatId]/components/ShortCuts/components/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./ShortCutItem"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ShortCuts'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./ColoredText"; | ||
export * from "./ShortCuts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use client"; | ||
|
||
import { useTranslation } from "react-i18next"; | ||
|
||
import { ShortCuts } from "./components"; | ||
|
||
const SelectedChatPage = (): JSX.Element => { | ||
const { t } = useTranslation(["chat"]); | ||
|
||
return ( | ||
<main className="flex flex-col w-full pt-10" data-testid="chat-page"> | ||
<section className="flex flex-col flex-1 items-center w-full h-full min-h-[70vh]"> | ||
<div className="flex flex-col items-center justify-center px-5"> | ||
<h1 className="text-3xl font-bold text-center"> | ||
{t("empty_brain_title_intro")}{" "} | ||
<span className="text-purple-500">{t("brains")}</span> | ||
{" !! "} | ||
<br /> | ||
{t("empty_brain_title_prefix")}{" "} | ||
<span className="text-purple-500">{t("brain")}</span>{" "} | ||
{t("empty_brain_title_suffix")} | ||
</h1> | ||
</div> | ||
|
||
<ShortCuts /> | ||
</section> | ||
</main> | ||
); | ||
}; | ||
|
||
export default SelectedChatPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { UUID } from "crypto"; | ||
|
||
export type ChatQuestion = { | ||
model?: string; | ||
question?: string; | ||
temperature?: number; | ||
max_tokens?: number; | ||
}; | ||
export type ChatHistory = { | ||
chat_id: string; | ||
message_id: string; | ||
user_message: string; | ||
assistant: string; | ||
message_time: string; | ||
}; | ||
|
||
export type ChatEntity = { | ||
chat_id: UUID; | ||
user_id: string; | ||
creation_time: string; | ||
chat_name: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use client"; | ||
import { ReactNode } from "react"; | ||
|
||
import { ChatsList } from "@/app/chat/components"; | ||
import { ChatsProvider } from "@/lib/context/ChatsProvider/chats-provider"; | ||
import { useSupabase } from "@/lib/context/SupabaseProvider"; | ||
import { redirectToLogin } from "@/lib/router/redirectToLogin"; | ||
|
||
interface LayoutProps { | ||
children?: ReactNode; | ||
} | ||
|
||
const Layout = ({ children }: LayoutProps): JSX.Element => { | ||
const { session } = useSupabase(); | ||
if (session === null) { | ||
redirectToLogin(); | ||
} | ||
|
||
return ( | ||
<ChatsProvider> | ||
<div className="relative h-full w-full flex justify-stretch items-stretch"> | ||
<ChatsList /> | ||
{children} | ||
</div> | ||
</ChatsProvider> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
"use client"; | ||
import ChatPage from "./[chatId]/page"; | ||
|
||
export default ChatPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters