Skip to content

Commit 45a939e

Browse files
committed
add suggestion buttons
1 parent f23ff71 commit 45a939e

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

app/globals.css

+9
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
:root {
66
--text-primary: #FFFFFF;
77
--text-primary-inverse: #090909;
8+
--text-primary-main: #7724AA;
89
--text-secondary: #A6AAAE;
910
--text-secondary-inverse: #494A4D;
1011
--background-bubble-primary: #611C9B;
1112
--background-bubble-secondary: #F7F7F7;
1213
--border-primary: #CED0D2;
14+
--background-soft: #F3E5F5;
1315
--background-start-rgb: 214, 219, 220;
1416
--background-end-rgb: 255, 255, 255;
1517
--text-tertiary: #6B6F73;
@@ -21,10 +23,12 @@
2123
.dark {
2224
--text-primary: #090909;
2325
--text-primary-inverse: #FFFFFF;
26+
--text-primary-main: #9946B9;
2427
--text-secondary: #494A4D;
2528
--text-secondary-inverse: #A6AAAE;
2629
--background-bubble-primary: #BA68C8;
2730
--background-bubble-secondary: #232324;
31+
--background-soft: #200033;
2832
--border-primary: #262626;
2933
--background-start-rgb: 23, 23, 23;
3034
--background-end-rgb: 28, 28, 28;
@@ -193,6 +197,11 @@ body {
193197
}
194198
}
195199

200+
.prompt-button {
201+
background-color: var(--background-soft);
202+
color: var(--text-primary-main);
203+
}
204+
196205
/* Toggle Styles */
197206
.toggle-background {
198207
background-color: var(--background-bubble-primary);

app/page.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
"use client";
22
import {useEffect, useRef, useState} from 'react';
33
import Bubble from '../components/Bubble'
4-
import { useChat } from 'ai/react';
4+
import { useChat, Message } from 'ai/react';
55
import Footer from '../components/Footer';
66
import Configure from '../components/Configure';
7+
import PromptSuggestionRow from '../components/PromptSuggestions/PromptSuggestionsRow';
78
import ThemeButton from '../components/ThemeButton';
89
import useConfiguration from './hooks/useConfiguration';
910

11+
1012
export default function Home() {
11-
const { messages, input, handleInputChange, handleSubmit } = useChat();
13+
const { append, messages, input, handleInputChange, handleSubmit } = useChat();
1214
const { useRag, llm, similarityMetric, setConfiguration } = useConfiguration();
1315

1416
const messagesEndRef = useRef(null);
@@ -26,6 +28,11 @@ export default function Home() {
2628
handleSubmit(e, { options: { body: { useRag, llm, similarityMetric}}});
2729
}
2830

31+
const handlePrompt = (promptText) => {
32+
const msg: Message = { id: crypto.randomUUID(), content: promptText, role: 'user' };
33+
append(msg, { options: { body: { useRag, llm, similarityMetric}}});
34+
};
35+
2936
return (
3037
<>
3138
<main className="flex h-screen flex-col items-center justify-center">
@@ -54,6 +61,9 @@ export default function Home() {
5461
{messages.map((message, index) => <Bubble ref={messagesEndRef} key={`message-${index}`} content={message} />)}
5562
</div>
5663
</div>
64+
{!messages || messages.length === 0 && (
65+
<PromptSuggestionRow onPromptClick={handlePrompt} />
66+
)}
5767
<form className='flex h-[40px] gap-2' onSubmit={handleSend}>
5868
<input onChange={handleInputChange} value={input} className='chatbot-input flex-1 text-sm md:text-base outline-none bg-transparent rounded-md p-2' placeholder='Send a message...' />
5969
<button type="submit" className='chatbot-send-button flex rounded-md items-center justify-center px-2.5 origin:px-3'>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
const PromptSuggestionButton = ({ text, onClick }) => {
3+
return (
4+
<button
5+
onClick={onClick}
6+
className="prompt-button text-sm py-2 px-4 rounded-lg overflow-hidden whitespace-nowrap focus:outline-none focus:shadow-outline"
7+
>
8+
{text}
9+
</button>
10+
);
11+
};
12+
13+
export default PromptSuggestionButton;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import PromptSuggestionButton from "./PromptSuggestionButton";
2+
3+
const PromptSuggestionRow = ({ onPromptClick }) => {
4+
const prompts = [
5+
'How does similarity search work with a Vector DB?',
6+
'What is DataStax Enterprise?',
7+
'How does CassIO work?',
8+
'What are some common FAQs about Astra?',
9+
];
10+
11+
return (
12+
<div className="flex flex-row flex-wrap justify-start items-center py-4 gap-2">
13+
{prompts.map((prompt, index) => (
14+
<PromptSuggestionButton key={`suggestion-${index}`} text={prompt} onClick={() => onPromptClick(prompt)} />
15+
))}
16+
</div>
17+
);
18+
};
19+
20+
export default PromptSuggestionRow;

0 commit comments

Comments
 (0)