Skip to content

Commit

Permalink
Issue prompt from last copied text
Browse files Browse the repository at this point in the history
  • Loading branch information
Simatwa committed Dec 25, 2023
1 parent 0cb3d4c commit 26c0ac6
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions WebChatGPT/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,13 @@ def do_h(self, text):
├────┼────────────────────────┼─────────────────────────────────────┤
│ 14 │ set_theme │ Set theme for displaying codes │
├────┼────────────────────────┼─────────────────────────────────────┤
│ 15 │ ./<command>Run system command
│ 15 │ from_copiedUse last copied text as prompt
├────┼────────────────────────┼─────────────────────────────────────┤
│ 16 │ <any other> │ Interact with ChatGPT
│ 16 │ ./<command> │ Run system command
├────┼────────────────────────┼─────────────────────────────────────┤
│ 17 │ exit │ Quits Program │
│ 17 │ <any other> │ Interact with ChatGPT │
├────┼────────────────────────┼─────────────────────────────────────┤
│ 18 │ exit │ Quit Program │
╘════╧════════════════════════╧═════════════════════════════════════╛
Submit any bug at : {__repo__}/issues/new
Expand Down Expand Up @@ -496,6 +498,15 @@ def generate_title(self):
return resp["message"]
return "Untitled"

def do_from_copied(self, line):
"""Use last copied text as prompt"""
issued_prompt = (
f"{line}\n{pyperclip.paste()}" if bool(line.strip()) else pyperclip.paste()
)
click.secho(issued_prompt, fg="yellow")
if click.confirm("Do you wish to proceed"):
self.default()

# @busy_bar.run()
def default(self, line):
"""Chat with ChatGPT"""
Expand Down

0 comments on commit 26c0ac6

Please sign in to comment.