Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helper to run a query and select the response #56

Merged
merged 6 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions GPT/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ def paste_model_confirmation_gui():
GuiState.text_to_confirm = ""
confirmation_gui.hide()

def paste_selected(result: str):
jaresty marked this conversation as resolved.
Show resolved Hide resolved
"""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 = (
Expand Down
6 changes: 6 additions & 0 deletions GPT/gpt.talon
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ model clip <user.modelPrompt> [this]$:
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 selected <user.modelPrompt> [this]$:
jaresty marked this conversation as resolved.
Show resolved Hide resolved
text = edit.selected_text()
result = user.gpt_apply_prompt(modelPrompt, text)
user.paste_selected(result)

# Say your prompt directly and the AI will apply it to the selected text
model please <user.text>$:
prompt = user.text
Expand Down