Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 10 additions & 42 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 38 additions & 7 deletions client/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function ConfidenceBadge({ found, confidence }) {
);
}

function Message({ message, isLatestBotMessage, onRegenerate, onEditPrompt }) {
function Message({ message, isLatestBotMessage, onRegenerate, onEditPrompt, onRelatedQuestion }) {
const isUser = message.role === 'user';
const [vote, setVote] = useState(null);
const [copied, setCopied] = useState(false);
Expand Down Expand Up @@ -111,6 +111,21 @@ function Message({ message, isLatestBotMessage, onRegenerate, onEditPrompt }) {
) : (
<p style={{ whiteSpace: 'pre-wrap' }}>{message.text}</p>
)}

{!isUser && message.relatedQuestions?.length > 0 && (
<div className="relatedQuestions">
<strong>Related Questions:</strong>
<ul>
{message.relatedQuestions.map((question) => (
<li key={question}>
<button type="button" onClick={() => onRelatedQuestion?.(question)}>
{question}
</button>
</li>
))}
</ul>
</div>
)}

{isUser ? (
<div style={{ display: 'flex', alignItems: 'center', gap: '10px', marginTop: '8px' }}>
Expand Down Expand Up @@ -366,6 +381,7 @@ function DefaultChat({ onCreateOrg }) {
answerFound: data.answerFound,
confidence: data.confidence,
sources: data.sources,
relatedQuestions: data.relatedQuestions || [],
timestamp: getTime()
}
]);
Expand All @@ -382,6 +398,7 @@ function DefaultChat({ onCreateOrg }) {
answerFound: false,
confidence: 0,
sources: [],
relatedQuestions: [],
timestamp: getTime()
}
]);
Expand Down Expand Up @@ -423,6 +440,7 @@ function DefaultChat({ onCreateOrg }) {
answerFound: data.answerFound,
confidence: data.confidence,
sources: data.sources,
relatedQuestions: data.relatedQuestions || [],
timestamp: getTime()
}
]);
Expand All @@ -438,6 +456,7 @@ function DefaultChat({ onCreateOrg }) {
answerFound: false,
confidence: 0,
sources: [],
relatedQuestions: [],
timestamp: getTime()
}
]);
Expand All @@ -446,10 +465,9 @@ function DefaultChat({ onCreateOrg }) {
}
}

async function sendMessage(event) {
if (event) event.preventDefault();
const text = input.trim();
if (!text || isLoading || input.length > 500) return;
async function sendQuestion(question) {
const text = String(question || '').trim();
if (!text || isLoading || text.length > 500) return;

setMessages((current) => [...current, { id: crypto.randomUUID(), role: 'user', text, timestamp: getTime() }]);
setInput('');
Expand Down Expand Up @@ -477,6 +495,7 @@ function DefaultChat({ onCreateOrg }) {
answerFound: data.answerFound,
confidence: data.confidence,
sources: data.sources,
relatedQuestions: data.relatedQuestions || [],
timestamp: getTime()
}
]);
Expand All @@ -492,6 +511,7 @@ function DefaultChat({ onCreateOrg }) {
answerFound: false,
confidence: 0,
sources: [],
relatedQuestions: [],
timestamp: getTime()
}
]);
Expand All @@ -500,6 +520,16 @@ function DefaultChat({ onCreateOrg }) {
}
}

async function sendMessage(event) {
if (event) event.preventDefault();
await sendQuestion(input);
}

function sendRelatedQuestion(question) {
setInput(question);
sendQuestion(question);
}

function useQuickPrompt(prompt) {
setInput(prompt);
}
Expand Down Expand Up @@ -583,7 +613,8 @@ function DefaultChat({ onCreateOrg }) {
message={message}
isLatestBotMessage={isLatestBotMessage}
onRegenerate={handleRegenerate}
onEditPrompt={handleEditPrompt}
onEditPrompt={handleEditPrompt}
onRelatedQuestion={sendRelatedQuestion}
/>
);
})}
Expand Down Expand Up @@ -1050,4 +1081,4 @@ function App() {
if (view === 'orgChat') return <OrgChatView orgId={activeOrgId} onBack={() => setView('home')} />;
}

createRoot(document.getElementById('root')).render(<App />);
createRoot(document.getElementById('root')).render(<App />);
Loading