-
- Pick an answer from these or write it below
-
-
- {activeMessage.possibleAnswers.map((answer) => (
-
- ))}
-
-
setMessage(e.target.value)}
className="w-full bg-transparent text-sm focus:outline-none"
- placeholder="Write your answer here..."
+ placeholder="Or type your own answer..."
autoFocus
onKeyDown={(e) => {
if (e.key === 'Enter' && !e.shiftKey) {
@@ -287,10 +276,14 @@ type QuestionAnswerChatMessageProps = {
role: 'user' | 'assistant';
question?: string;
answer?: string;
+ possibleAnswers?: string[];
+ onAnswerSelect?: (answer: string) => void;
};
function QuestionAnswerChatMessage(props: QuestionAnswerChatMessageProps) {
- const { role, question, answer } = props;
+ const { role, question, answer, possibleAnswers, onAnswerSelect } = props;
+
+ const hasAnswers = possibleAnswers && possibleAnswers.length > 0;
return (
- {role === 'assistant' &&
{question}
}
+ {role === 'assistant' && (
+
+
{question}
+ {hasAnswers && onAnswerSelect && (
+
+
+ {possibleAnswers.map((answer) => (
+
+ ))}
+
+
+ )}
+
+ )}
{role === 'user' &&
{answer}
}
);