Skip to content

Commit

Permalink
Fix issue with cursorless list argument to gpt_query (#34)
Browse files Browse the repository at this point in the history
The function did not correctly take in a list of strings as the
argument. Cursorless outputs puts a list of strings when you select a
range. Changed to convert to strings
  • Loading branch information
C-Loftus authored Mar 7, 2024
1 parent f6259b2 commit 68c1537
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion GPT/beta-commands/gpt-function-calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def gpt_function_query(
insert_response: InsertOption = InsertOption.PASTE,
cursorless_destination: Optional[Any] = None,
) -> None:

# Function calling likely to not be supported in local models so better to use OpenAI
url = "https://api.openai.com/v1/chat/completions"

Expand Down
7 changes: 6 additions & 1 deletion GPT/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ def paste_model_confirmation_gui():
actions.user.paste(text_to_confirm)
confirmation_gui.hide()

def gpt_apply_prompt(prompt: str, text_to_process: str) -> str:
def gpt_apply_prompt(prompt: str, text_to_process: str | list[str]) -> str:
"""Apply an arbitrary prompt to arbitrary text"""
text_to_process = (
" ".join(text_to_process)
if isinstance(text_to_process, list)
else text_to_process
)
return gpt_query(prompt, text_to_process)

def gpt_help():
Expand Down

0 comments on commit 68c1537

Please sign in to comment.