diff --git a/app/frontend/src/api/modelsDeployedApis.ts b/app/frontend/src/api/modelsDeployedApis.ts index 81f38a88..f37e436c 100644 --- a/app/frontend/src/api/modelsDeployedApis.ts +++ b/app/frontend/src/api/modelsDeployedApis.ts @@ -163,7 +163,8 @@ export const handleChatUI = ( ): void => { console.log(`ChatUI button clicked for model: ${modelID}`); console.log(`Opening Chat UI for model: ${modelName}`); - customToast.success(`Chat UI for model ${modelID} (${modelName}) opened.`); + // customToast.success(`Chat UI for model:${modelName} opened.`); + customToast.success(`Chat UI page opened!`); navigate("/chat-ui", { state: { containerID: modelID, modelName: modelName }, diff --git a/app/frontend/src/components/ChatComponent.tsx b/app/frontend/src/components/ChatComponent.tsx index feaf1b39..f50bef4d 100644 --- a/app/frontend/src/components/ChatComponent.tsx +++ b/app/frontend/src/components/ChatComponent.tsx @@ -3,17 +3,10 @@ import React, { useEffect, useState, useRef } from "react"; import { Card } from "./ui/card"; import { Button } from "./ui/button"; -import { ScrollArea } from "./ui/scroll-area"; +import * as ScrollArea from "@radix-ui/react-scroll-area"; import { useLocation } from "react-router-dom"; import { Spinner } from "./ui/spinner"; -import { - MessageCircle, - Smile, - CloudSun, - Lightbulb, - User, - ChevronDown, -} from "lucide-react"; +import { User, ChevronDown } from "lucide-react"; import { Textarea } from "./ui/textarea"; import logo from "../assets/tt_logo.svg"; import { @@ -32,6 +25,7 @@ import { DropdownMenuTrigger, } from "./ui/dropdown-menu"; import { fetchModels } from "../api/modelsDeployedApis"; +import ChatExamples from "./ChatExamples"; import axios from "axios"; import { Select, @@ -83,7 +77,7 @@ const ChatComponent: React.FC = () => { const [modelID, setModelID] = useState(null); const [modelName, setModelName] = useState(null); const [isStreaming, setIsStreaming] = useState(false); - const scrollAreaRef = useRef(null); + const viewportRef = useRef(null); const bottomRef = useRef(null); const [isScrollButtonVisible, setIsScrollButtonVisible] = useState(false); const [modelsDeployed, setModelsDeployed] = useState([]); @@ -107,20 +101,19 @@ const ChatComponent: React.FC = () => { }, [location.state]); const scrollToBottom = () => { - if (bottomRef.current) { - bottomRef.current.scrollIntoView({ behavior: "smooth" }); + if (viewportRef.current) { + viewportRef.current.scrollTo({ + top: viewportRef.current.scrollHeight, + behavior: "smooth", + }); } }; - useEffect(() => { - scrollToBottom(); - }, [chatHistory]); - const handleScroll = () => { - if (scrollAreaRef.current) { + if (viewportRef.current) { const isAtBottom = - scrollAreaRef.current.scrollHeight - scrollAreaRef.current.scrollTop <= - scrollAreaRef.current.clientHeight + 1; + viewportRef.current.scrollHeight - viewportRef.current.scrollTop <= + viewportRef.current.clientHeight + 1; setIsScrollButtonVisible(!isAtBottom); } }; @@ -197,7 +190,6 @@ const ChatComponent: React.FC = () => { ]; } }); - scrollToBottom(); } } } @@ -319,113 +311,70 @@ const ChatComponent: React.FC = () => {
- { - const dataSource = ragDataSources.find((rds: RagDataSource) => { - return rds.name == v; - }); - if (dataSource) { - setRagDatasource(dataSource); - } - }} - activeCollection={ragDatasource} - /> + { + const dataSource = ragDataSources.find((rds: RagDataSource) => { + return rds.name == v; + }); + if (dataSource) { + setRagDatasource(dataSource); + } + }} + activeCollection={ragDatasource} + /> {chatHistory.length === 0 && ( -
- Tenstorrent Logo -

- Start a conversation with LLM Studio Chat... -

-
-
- setTextInput("Hello, how are you today?")} - > - - - Hello, how are you today? - - - setTextInput("Can you tell me a joke?")} - > - - - Can you tell me a joke? - - - setTextInput("What's the weather like?")} - > - - - What's the weather like? - - - setTextInput("Tell me a fun fact.")} - > - - - Tell me a fun fact. - - -
-
-
+ )} {chatHistory.length > 0 && (
- - {chatHistory.map((message, index) => ( -
-
-
- {message.sender === "user" ? ( - - ) : ( - Tenstorrent Logo - )} -
-
+ + + {chatHistory.map((message, index) => (
- {message.text} +
+
+ {message.sender === "user" ? ( + + ) : ( + Tenstorrent Logo + )} +
+
+
+ {message.text} +
-
- ))} -
- + ))} +
+ + + + + {isScrollButtonVisible && (