diff --git a/GPT/gpt.py b/GPT/gpt.py index b0001051..19c5a64c 100644 --- a/GPT/gpt.py +++ b/GPT/gpt.py @@ -110,6 +110,14 @@ def paste_model_confirmation_gui(): GuiState.text_to_confirm = "" confirmation_gui.hide() + def paste_and_select(result: str): + """Paste and select the pasted text""" + + actions.user.paste(result) + + for _ in result: + actions.edit.extend_left() + def gpt_apply_prompt(prompt: str, text_to_process: str | list[str]) -> str: """Apply an arbitrary prompt to arbitrary text""" text_to_process = ( diff --git a/GPT/gpt.talon b/GPT/gpt.talon index 8d47c5c9..81e66127 100644 --- a/GPT/gpt.talon +++ b/GPT/gpt.talon @@ -10,11 +10,17 @@ model [this]$: user.paste(result) # Runs a model prompt on the selected text and sets the result to the clipboard -model clip [this]$: +model [this] (then | and) (clip | copy) [it]$: text = edit.selected_text() result = user.gpt_apply_prompt(modelPrompt, text) clip.set_text(result) +# Runs a model prompt on the selected text and sets the selection to the pasted response +model [this] (then | and) select [it]$: + text = edit.selected_text() + result = user.gpt_apply_prompt(modelPrompt, text) + user.paste_and_select(result) + # Say your prompt directly and the AI will apply it to the selected text model please $: prompt = user.text diff --git a/GPT/readme.md b/GPT/readme.md index 5cc395c4..d7813c78 100644 --- a/GPT/readme.md +++ b/GPT/readme.md @@ -6,12 +6,13 @@ Query language models with voice commands. Helpful to automatically generate tex | Command | Description | Example | | ------------------------------------------------------------- | -------------------------------------------------------------------- | --------------------------------------------- | -| `model ask ` | Ask a question to the model | "model ask what is the meaning of life" | | `model ` | Generate text from a prompt and paste it | "model summarize" | -| `model clip ` | Generate text from a prompt and set it on the clipboard | "model clip summarize" | | `model help` | Show the help menu with all the prompts | "model help" | | `model please ` | Say an arbitrary prompt and then apply it | "model please translate this to Japanese" | +| `model ask ` | Ask a question to the model | "model ask what is the meaning of life" | | `model ` | Select with cursorless, apply a prompt, and paste to the destination | "model explain line this after block red air" | +| `model then select it` | Apply a prompt and then select the result | "model format bullets then select it" | +| `model then clip it` | Apply a prompt and return the result in the clipboard | "model explain this then clip it" | ## Help