diff options
| author | omagdy7 <omar.professional8777@gmail.com> | 2024-02-22 19:12:22 +0200 |
|---|---|---|
| committer | omagdy7 <omar.professional8777@gmail.com> | 2024-02-22 19:12:22 +0200 |
| commit | 481ae0c24785a1798a0445a2a982acce6db7e4f2 (patch) | |
| tree | a196dc99bc09b0ffe6a01a99d45b5efab0bf9e4d /src/components | |
| parent | 4f1971020d43d0958973712212f17bd9d51a1834 (diff) | |
| download | ollama-logseq-481ae0c24785a1798a0445a2a982acce6db7e4f2.tar.xz ollama-logseq-481ae0c24785a1798a0445a2a982acce6db7e4f2.zip | |
Added the ability to Ask in context of the block only instead of the whole page
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/OllamaCommandPallete.tsx | 14 | ||||
| -rw-r--r-- | src/components/PromptAI.tsx | 8 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/components/OllamaCommandPallete.tsx b/src/components/OllamaCommandPallete.tsx index e8e9c42..dabdc9b 100644 --- a/src/components/OllamaCommandPallete.tsx +++ b/src/components/OllamaCommandPallete.tsx @@ -6,7 +6,7 @@ import { CommandItem, CommandList, } from "@/components/ui/command" -import { convertToFlashCardCurrentBlock, DivideTaskIntoSubTasksCurrentBlock, summarize, summarizeBlock } from "@/ollama"; +import { convertToFlashCardCurrentBlock, DivideTaskIntoSubTasksCurrentBlock, summarizePage, summarizeBlock } from "@/ollama"; import { PromptAI } from "./PromptAI"; export function OllamaCommandPallete({ options, theme }: { options: string[], theme: string }) { @@ -20,9 +20,9 @@ export function OllamaCommandPallete({ options, theme }: { options: string[], th logseq.hideMainUI() DivideTaskIntoSubTasksCurrentBlock() break; - case "summarize": + case "summarize page": logseq.hideMainUI() - summarize() + summarizePage() break; case "summarize block": logseq.hideMainUI() @@ -51,12 +51,14 @@ export function OllamaCommandPallete({ options, theme }: { options: string[], th }; }, []); - if (isEnterPressed && (selection !== 'ask ai' && selection !== 'define' && selection !== 'ask with context')) { - return null + const validSelections = ['ask with page context', 'ask with block context', 'ask ai', 'define', 'ask with context']; + + if (isEnterPressed && !validSelections.includes(selection)) { + return null; } return ( - selection === 'ask with context' || selection === 'ask ai' || selection === 'define' ? (<PromptAI theme={theme} type={selection} />) : ( + validSelections.includes(selection) ? (<PromptAI theme={theme} type={selection} />) : ( <Command className={(theme === 'dark' ? "dark dark:bg-gray-900" : "bg-gray-200") + " rounded-lg border shadow-md w-1/2"}> <CommandInput className="ai-input" placeholder="Type a command or search..." /> <CommandList> diff --git a/src/components/PromptAI.tsx b/src/components/PromptAI.tsx index 5fb9942..6b4616d 100644 --- a/src/components/PromptAI.tsx +++ b/src/components/PromptAI.tsx @@ -4,7 +4,7 @@ import { Input } from '@/components/ui/input'; export const PromptAI = ({ type, theme }: { type: string, theme: string }) => { - const placeholder = type === 'ask ai' ? "Prompt..." : "Define..." + const placeholder = type.startsWith('ask') ? "Prompt..." : "Define..." const [inputValue, setInputValue] = useState(''); const [hitEnter, setHitEnter] = useState(false) @@ -15,8 +15,10 @@ export const PromptAI = ({ type, theme }: { type: string, theme: string }) => { askAI(inputValue, "") } else if (type === 'define') { defineWord(inputValue) - } else if (type === 'ask with context') { - askWithContext(inputValue) + } else if (type === 'ask with page context') { + askWithContext(inputValue, 'page') + } else if (type === 'ask with block context') { + askWithContext(inputValue, 'block') } } }, [hitEnter]) |
