From 26c0ac6b0f46e438716add26fe895fe3758e6d9e Mon Sep 17 00:00:00 2001 From: Simatwa Date: Mon, 25 Dec 2023 17:10:58 +0300 Subject: [PATCH] Issue prompt from last copied text --- WebChatGPT/console.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/WebChatGPT/console.py b/WebChatGPT/console.py index f673256..bb227a0 100644 --- a/WebChatGPT/console.py +++ b/WebChatGPT/console.py @@ -242,11 +242,13 @@ def do_h(self, text): ├────┼────────────────────────┼─────────────────────────────────────┤ │ 14 │ set_theme │ Set theme for displaying codes │ ├────┼────────────────────────┼─────────────────────────────────────┤ -│ 15 │ ./ │ Run system command │ +│ 15 │ from_copied │ Use last copied text as prompt │ ├────┼────────────────────────┼─────────────────────────────────────┤ -│ 16 │ │ Interact with ChatGPT │ +│ 16 │ ./ │ Run system command │ ├────┼────────────────────────┼─────────────────────────────────────┤ -│ 17 │ exit │ Quits Program │ +│ 17 │ │ Interact with ChatGPT │ +├────┼────────────────────────┼─────────────────────────────────────┤ +│ 18 │ exit │ Quit Program │ ╘════╧════════════════════════╧═════════════════════════════════════╛ Submit any bug at : {__repo__}/issues/new @@ -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"""