diff --git a/src/app/ui/pages/chat/chat.css b/src/app/ui/pages/chat/chat.css index f5991d3e..b099a8db 100644 --- a/src/app/ui/pages/chat/chat.css +++ b/src/app/ui/pages/chat/chat.css @@ -6,7 +6,6 @@ width: 51.25rem; outline: solid white; height: 3.1rem; - margin-right: 1.2rem; border-radius: 2.5rem; padding-left: 1rem; } @@ -52,3 +51,37 @@ margin-right: 2rem; } +/* Add these styles to your existing styles or create a new CSS file */ + +/* Chat container styles */ +.chat-container { + overflow-y:scroll; + max-height: 200px; + width: 46%; + padding: 10px; + display: flex; + flex-direction: column; + } + + /* User message styles */ + .user-message { + background-color: #f58308; + color: #ffffff; + max-width: 70%; + align-self: flex-end; + border-radius: 10px; + padding: 10px; + margin-bottom: 8px; + } + + /* Bot message styles */ + .bot-message { + background-color: #EAEAEA; + color: #333; + max-width: 70%; + align-self: flex-start; + border-radius: 10px; + padding: 10px; + margin-bottom: 8px; + } + diff --git a/src/app/ui/pages/chat/chat.js b/src/app/ui/pages/chat/chat.js index a8faed24..e960ad82 100644 --- a/src/app/ui/pages/chat/chat.js +++ b/src/app/ui/pages/chat/chat.js @@ -1,22 +1,93 @@ "use client" import "./chat.css"; +import { useState } from "react"; import { Grid, IconButton,Avatar,Tooltip,Typography} from "@mui/material"; import { InfoOutlined} from "@material-ui/icons"; import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined"; import Image from "next/image"; import { useRouter } from "next/navigation"; +const dummyData = [ + { + "prompt": "Hii Anudesh", + "output": "Hello! How can I assist you today?" + }, + { + "prompt": "What is a computer?", + "output": "Computer is an electronic device" + }, + { + "prompt": "What is it used for?", + "output": "It is used for computation" + }, + { + "prompt": "Thanks, any additional points?", + "output": "No" + } + ]; -export default function Chat() -{ + +const Chat = () =>{ + + const [inputValue, setInputValue] = useState(''); + const [chatHistory, setChatHistory] = useState([]); + const [showChatContainer, setShowChatContainer] = useState(false); const router = useRouter(); - return( - <> - - -
-
+ const handleButtonClick = () => { + if (inputValue) { + const response = dummyData.find(item => item.prompt === inputValue); + if (response) { + setChatHistory(prev => [...prev, { message: inputValue, isUser: true }, { message: response.output, isUser: false }]); + } else { + setChatHistory(prev => [...prev, { message: inputValue, isUser: true }, { message: "I'm sorry, I don't understand.", isUser: false }]); + } + + setInputValue(''); + setShowChatContainer(true); + } else { + alert('Please provide a prompt.'); + } + }; + + const renderChatHistory = () => { + const chatElements = []; + for (let index = 0; index < chatHistory.length; index++) { + const message = chatHistory[index]; + const isUser = message.isUser; + const boxClassName = isUser ? "box1 flex w-[40vw] py-7 justify-start items-center space-x-6" : "box2 bg-orange-100 flex w-full py-7 justify-center items-center"; + + chatElements.push( +
+ {isUser ? ( + <> +
+ +
+
{message.message}
+ + ) : ( +
+ Bot Avatar +
{message.message}
+
+ )} +
+ ); + } + return chatElements; + }; + + return( + <> +
+
+
router.push("/home") }> +
@@ -30,46 +101,77 @@ export default function Chat() -
- +
-
-
- -
-

Namaste

-

Tell me what’s on your mind or pick a suggestion. I have limitations and won't always get it right, but your

feedback will help me to improve.

-
-
-
-
-

What is Anudesh?

-

data leta hai multilingual(indic), will be used for model training for indic llms, 22, open source - model and data

-
-
-

How can you help?

-

GIF

-
-
-

Why Contribute?

-

Graph

-
-
- -
- - -
+
+ {showChatContainer ? + (<> +
+ +
+

Namaste

+

Tell me what’s on your mind or pick a suggestion. I have limitations and won't always get it right, but your

feedback will help me to improve.

+
+
+
+ {renderChatHistory()} +
+
+ setInputValue(e.target.value)} + /> + + Send Icon + +
+ ): + (<> +
+ +
+

Namaste

+

Tell me what’s on your mind or pick a suggestion. I have limitations and won't always get it right, but your

feedback will help me to improve.

+
+
+
+
+

What is Anudesh?

+

data leta hai multilingual(indic), will be used for model training for indic llms, 22, open source - model and data

+
+
+

How can you help?

+

GIF

+
+
+

Why Contribute?

+

Graph

+
+
+
+ setInputValue(e.target.value)} + /> + + Send Icon + +
+ ) + }
- - - - ) -} + ); +}; + +export default Chat;