Skip to content

Commit

Permalink
fix: update prompt suggestions UI (#535)
Browse files Browse the repository at this point in the history
* update prompt suggestions

* fixes
  • Loading branch information
paulclindo authored Nov 13, 2024
1 parent 3461936 commit 39259c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,13 @@ function ConversationEmptyFooter() {
chatForm.setValue('message', promptSelected?.prompt ?? '');
}, [chatForm, promptSelected]);

useEffect(() => {
chatConfigForm.setValue(
'stream',
promptSelected?.isToolNeeded ? false : DEFAULT_CHAT_CONFIG.stream,
);
}, [chatConfigForm, chatForm, promptSelected]);

useEffect(() => {
if (isWorkflowSelectedAndFilesPresent) {
chatForm.setValue(
Expand Down
38 changes: 27 additions & 11 deletions apps/shinkai-desktop/src/pages/chat/empty-message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,33 +117,49 @@ const EmptyMessage = () => {
{[
{
text: 'Search in Perplexity',
prompt:
'Can you search in Perplexity? If you need more information, ask me a follow up question.',
prompt: 'Search in Perplexity for: ',
isToolNeeded: true,
},
{
text: 'Summarize a Youtube video',
prompt:
'Can you help me summarize a youtube video? If you need more information, ask me a follow up question.',
prompt: 'Summarize a Youtube video: ',
isToolNeeded: true,
},
{
text: 'Tell me about the Roman Empire',
prompt: 'Tell me about the Roman Empire',
},
].map((suggestion) => (
<Badge
className="cursor-pointer justify-between bg-gray-300 py-2 text-left font-normal normal-case text-gray-50 transition-colors hover:bg-gray-200"
key={suggestion.text}
onClick={() =>
onCreateJob(suggestion.prompt, suggestion.isToolNeeded)
}
onClick={() => {
setPromptSelected({
name: '',
prompt: suggestion.prompt,
is_enabled: true,
is_favorite: false,
is_system: true,
version: '1',
isToolNeeded: suggestion.isToolNeeded,
});
const element = document.querySelector(
'#chat-input',
) as HTMLDivElement;
if (element) {
element?.focus?.();
}
}}
variant="outline"
>
{suggestion.text}
<ArrowUpRight className="ml-2 h-3.5 w-3.5" />
</Badge>
))}
<Badge
className="cursor-pointer justify-between text-balance bg-gray-300 py-2 text-left font-normal normal-case text-gray-50 transition-colors hover:bg-gray-200"
onClick={() => onCreateJob('Tell me about the Roman Empire')}
variant="outline"
>
Tell me about the Roman Empire
<ArrowUpRight className="ml-2 h-3.5 w-3.5" />
</Badge>
</div>

<div className="mt-4">
Expand Down
1 change: 1 addition & 0 deletions libs/shinkai-message-ts/src/api/tools/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export type Prompt = {
version: string;
is_favorite: boolean;
embedding?: string;
isToolNeeded?: boolean;
};
export type GetAllPromptsResponse = Prompt[];
export type SearchPromptsResponse = Prompt[];
Expand Down

0 comments on commit 39259c8

Please sign in to comment.