fix: add summarise

feat/topic-chat
Arik Chakma 1 week ago
parent 60c8569a42
commit d50e29a9fd
  1. 23
      src/components/TopicDetail/TopicDetailAI.tsx

@ -231,16 +231,21 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
const testMyKnowledgePrompt = const testMyKnowledgePrompt =
'Act as an interviewer and test my understanding of this topic'; 'Act as an interviewer and test my understanding of this topic';
const summarizePrompt = 'Summarize this topic in no more than two sentences';
const predefinedMessages = useMemo( const predefinedMessages = useMemo(
() => [ () => [
{ {
label: 'Explain this topic like I am a 5 years old', label: 'Explain like I am five',
message: 'Explain this topic like I am a 5 years old', message: 'Explain this topic like I am a 5 years old',
}, },
{ {
label: 'Test my Knowledge', label: 'Test my Knowledge',
message: testMyKnowledgePrompt, message: testMyKnowledgePrompt,
}, },
{
label: 'Summarize in 2 sentences',
message: summarizePrompt,
},
], ],
[], [],
); );
@ -377,16 +382,21 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
const isTextMyKnowledgePrompt = const isTextMyKnowledgePrompt =
chat.role === 'user' && chat.role === 'user' &&
chat.content === testMyKnowledgePrompt; chat.content === testMyKnowledgePrompt;
const isTextSummarizePrompt =
chat.role === 'user' && chat.content === summarizePrompt;
let content = chat.content;
if (isTextMyKnowledgePrompt) {
content = 'Starting Interview';
} else if (isTextSummarizePrompt) {
content = 'Summarize in 2 sentences';
}
return ( return (
<Fragment key={`chat-${index}`}> <Fragment key={`chat-${index}`}>
<AIChatCard <AIChatCard
role={chat.role} role={chat.role}
content={ content={content}
isTextMyKnowledgePrompt
? 'Starting Interview'
: chat.content
}
html={chat.html} html={chat.html}
/> />
</Fragment> </Fragment>
@ -462,6 +472,7 @@ export function TopicDetailAI(props: TopicDetailAIProps) {
autoFocus={true} autoFocus={true}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey) { if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
handleChatSubmit(); handleChatSubmit();
} }
}} }}

Loading…
Cancel
Save