mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-09 13:25:11 +00:00
Separate the shorthand of each suggestion card from the prefilled text
This commit is contained in:
@@ -20,7 +20,7 @@ interface StepTwoSuggestionCardProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function StepOneSuggestionCard(data: StepOneSuggestionCardProps) {
|
export function StepOneSuggestionCard(data: StepOneSuggestionCardProps) {
|
||||||
const cardClassName = `${styles.card} md:w-full md:h-fit sm:w-full h-fit md:w-[200px] cursor-pointer md:p-2`;
|
const cardClassName = `${styles.card} md:w-full md:h-fit sm:w-full h-fit md:w-[200px] cursor-pointer md:p-2 animate-fade-in-up`;
|
||||||
const descriptionClassName = `${styles.text} dark:text-white`;
|
const descriptionClassName = `${styles.text} dark:text-white`;
|
||||||
|
|
||||||
const cardContent = (
|
const cardContent = (
|
||||||
@@ -48,7 +48,10 @@ export function StepTwoSuggestionCard(data: StepTwoSuggestionCardProps) {
|
|||||||
<Card className={cardClassName}>
|
<Card className={cardClassName}>
|
||||||
<div className="flex w-full items-center">
|
<div className="flex w-full items-center">
|
||||||
<CardContent className="m-0 p-2 w-full flex flex-row items-center">
|
<CardContent className="m-0 p-2 w-full flex flex-row items-center">
|
||||||
<ArrowRight className="w-6 h-6 text-muted-foreground inline-flex mr-1" />
|
<ArrowRight
|
||||||
|
weight="thin"
|
||||||
|
className="w-6 h-6 text-muted-foreground inline-flex mr-1 text-opacity-40"
|
||||||
|
/>
|
||||||
<CardDescription
|
<CardDescription
|
||||||
className={`sm:line-clamp-2 md:line-clamp-4 break-words whitespace-pre-wrap max-w-full text-sm text-wrap text-black dark:text-white`}
|
className={`sm:line-clamp-2 md:line-clamp-4 break-words whitespace-pre-wrap max-w-full text-sm text-wrap text-black dark:text-white`}
|
||||||
>
|
>
|
||||||
@@ -61,14 +64,14 @@ export function StepTwoSuggestionCard(data: StepTwoSuggestionCardProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function StepOneSuggestionRevertCard(data: StepOneSuggestionRevertCardProps) {
|
export function StepOneSuggestionRevertCard(data: StepOneSuggestionRevertCardProps) {
|
||||||
const cardClassName = `${styles.card} md:w-full md:h-fit sm:w-full h-fit md:w-[200px] cursor-pointer m-2 md:p-2 animate-fade-in-up`;
|
const cardClassName = `${styles.card} md:w-full md:h-fit sm:w-full h-fit md:w-[200px] cursor-pointer m-2 md:p-2 animate-fade-in-up border-none`;
|
||||||
const descriptionClassName = `${styles.text} dark:text-white`;
|
const descriptionClassName = `${styles.text} dark:text-white`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={cardClassName} onClick={data.onClick}>
|
<Card className={cardClassName} onClick={data.onClick}>
|
||||||
<div className="flex w-full">
|
<div className="flex w-full">
|
||||||
<CardContent className="m-0 p-2 w-full flex flex-row">
|
<CardContent className="m-0 p-2 w-full flex flex-row">
|
||||||
<ArrowLeft className="w-4 h-4 text-muted-foreground inline-flex mr-1" />
|
<ArrowLeft className="w-6 h-6 text-muted-foreground inline-flex mr-1" />
|
||||||
{convertSuggestionTitleToIconClass(data.title, data.color.toLowerCase())}
|
{convertSuggestionTitleToIconClass(data.title, data.color.toLowerCase())}
|
||||||
<CardDescription
|
<CardDescription
|
||||||
className={`${descriptionClassName} sm:line-clamp-2 md:line-clamp-4 pt-1 break-words whitespace-pre-wrap max-w-full`}
|
className={`${descriptionClassName} sm:line-clamp-2 md:line-clamp-4 pt-1 break-words whitespace-pre-wrap max-w-full`}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export interface StepOneSuggestion {
|
|||||||
color: string;
|
color: string;
|
||||||
actionTagline: string;
|
actionTagline: string;
|
||||||
focus: ChatInputFocus;
|
focus: ChatInputFocus;
|
||||||
|
intent: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StepTwoSuggestion {
|
export interface StepTwoSuggestion {
|
||||||
@@ -84,90 +85,105 @@ export const stepOneSuggestions: StepOneSuggestion[] = [
|
|||||||
actionTagline: "Summarize text",
|
actionTagline: "Summarize text",
|
||||||
color: suggestionToColorMap[SuggestionType.Document] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Document] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.FILE,
|
focus: ChatInputFocus.FILE,
|
||||||
|
intent: "Summarize this document",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Code,
|
type: SuggestionType.Code,
|
||||||
actionTagline: "Write code",
|
actionTagline: "Write code",
|
||||||
color: suggestionToColorMap[SuggestionType.Code] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Code] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Write a program that",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Learning,
|
type: SuggestionType.Learning,
|
||||||
actionTagline: "Explain concept",
|
actionTagline: "Explain concept",
|
||||||
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Learning] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "I want to understand a concept",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Paint,
|
type: SuggestionType.Paint,
|
||||||
actionTagline: "Create image",
|
actionTagline: "Create image",
|
||||||
color: suggestionToColorMap[SuggestionType.Paint] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Paint] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Paint a picture of",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Travel,
|
type: SuggestionType.Travel,
|
||||||
actionTagline: "Find a place",
|
actionTagline: "Find a place",
|
||||||
color: suggestionToColorMap[SuggestionType.Travel] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Travel] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Find a place that is",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Language,
|
type: SuggestionType.Language,
|
||||||
actionTagline: "Translate text",
|
actionTagline: "Translate text",
|
||||||
color: suggestionToColorMap[SuggestionType.Language] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Language] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Translate this text",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.PopCulture,
|
type: SuggestionType.PopCulture,
|
||||||
actionTagline: "Find a movie",
|
actionTagline: "Explain a trend",
|
||||||
color: suggestionToColorMap[SuggestionType.PopCulture] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.PopCulture] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Tell me more about this phenomenon",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Food,
|
type: SuggestionType.Food,
|
||||||
actionTagline: "Find a recipe",
|
actionTagline: "Find a recipe",
|
||||||
color: suggestionToColorMap[SuggestionType.Food] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Food] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Find a recipe for",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Interviewing,
|
type: SuggestionType.Interviewing,
|
||||||
actionTagline: "Career advice",
|
actionTagline: "Career advice",
|
||||||
color: suggestionToColorMap[SuggestionType.Interviewing] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Interviewing] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Help me prepare for an interview",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Fun,
|
type: SuggestionType.Fun,
|
||||||
actionTagline: "Get creative",
|
actionTagline: "Get creative",
|
||||||
color: suggestionToColorMap[SuggestionType.Fun] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Fun] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Suggest a fun activity",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Finance,
|
type: SuggestionType.Finance,
|
||||||
actionTagline: "Explain money",
|
actionTagline: "Explain money",
|
||||||
color: suggestionToColorMap[SuggestionType.Finance] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Finance] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Help me build mental models for finance",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Math,
|
type: SuggestionType.Math,
|
||||||
actionTagline: "Explain math",
|
actionTagline: "Explain math",
|
||||||
color: suggestionToColorMap[SuggestionType.Math] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Math] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Help me understand the math behind",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Image,
|
type: SuggestionType.Image,
|
||||||
actionTagline: "Explain image",
|
actionTagline: "Explain image",
|
||||||
color: suggestionToColorMap[SuggestionType.Image] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Image] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Explain the significance of this image",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Health,
|
type: SuggestionType.Health,
|
||||||
actionTagline: "Improve health",
|
actionTagline: "Improve health",
|
||||||
color: suggestionToColorMap[SuggestionType.Health] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Health] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Help me improve my health",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: SuggestionType.Home,
|
type: SuggestionType.Home,
|
||||||
actionTagline: "Improve home",
|
actionTagline: "Improve home",
|
||||||
color: suggestionToColorMap[SuggestionType.Home] || DEFAULT_COLOR,
|
color: suggestionToColorMap[SuggestionType.Home] || DEFAULT_COLOR,
|
||||||
focus: ChatInputFocus.MESSAGE,
|
focus: ChatInputFocus.MESSAGE,
|
||||||
|
intent: "Help me improve my home",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -204,13 +204,7 @@ function ChatBodyData(props: ChatBodyDataProps) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function clickStepOneSuggestion(suggestion: StepOneSuggestion) {
|
function clickStepOneSuggestion(suggestion: StepOneSuggestion) {
|
||||||
let message_str = "";
|
setPrefilledMessage(suggestion.intent);
|
||||||
let prompt =
|
|
||||||
suggestion.actionTagline.charAt(0).toLowerCase() + suggestion.actionTagline.slice(1);
|
|
||||||
|
|
||||||
message_str = prompt;
|
|
||||||
|
|
||||||
setPrefilledMessage(message_str);
|
|
||||||
const stepTwoSuggestions = getStepTwoSuggestions(suggestion.type);
|
const stepTwoSuggestions = getStepTwoSuggestions(suggestion.type);
|
||||||
setSelectedStepOneSuggestion(suggestion);
|
setSelectedStepOneSuggestion(suggestion);
|
||||||
setStepTwoSuggestionOptions(stepTwoSuggestions);
|
setStepTwoSuggestionOptions(stepTwoSuggestions);
|
||||||
|
|||||||
Reference in New Issue
Block a user