From 681699a1214753e1a9670ae6fbb2bbdd80dee392 Mon Sep 17 00:00:00 2001 From: taiyi747 <63543716+taiyi747@users.noreply.github.com> Date: Mon, 1 May 2023 11:38:20 +0800 Subject: Create pywebio-gui --- gui/pywebio-gui | 1 + 1 file changed, 1 insertion(+) create mode 100644 gui/pywebio-gui (limited to 'gui/pywebio-gui') diff --git a/gui/pywebio-gui b/gui/pywebio-gui new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/gui/pywebio-gui @@ -0,0 +1 @@ + -- cgit v1.2.3 From 9a51577622496803935a081da6962dd2b75b32bd Mon Sep 17 00:00:00 2001 From: taiyi747 <63543716+taiyi747@users.noreply.github.com> Date: Mon, 1 May 2023 11:38:36 +0800 Subject: Delete pywebio-gui --- gui/pywebio-gui | 1 - 1 file changed, 1 deletion(-) delete mode 100644 gui/pywebio-gui (limited to 'gui/pywebio-gui') diff --git a/gui/pywebio-gui b/gui/pywebio-gui deleted file mode 100644 index 8b137891..00000000 --- a/gui/pywebio-gui +++ /dev/null @@ -1 +0,0 @@ - -- cgit v1.2.3 From 53c4b0d9c5917ecbf70803aa4e14314453b972f2 Mon Sep 17 00:00:00 2001 From: taiyi747 <63543716+taiyi747@users.noreply.github.com> Date: Mon, 1 May 2023 11:39:19 +0800 Subject: Create README.md --- gui/pywebio-gui/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 gui/pywebio-gui/README.md (limited to 'gui/pywebio-gui') diff --git a/gui/pywebio-gui/README.md b/gui/pywebio-gui/README.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/gui/pywebio-gui/README.md @@ -0,0 +1 @@ + -- cgit v1.2.3 From 03dc49a5a9519fd6368bee2ea4f29f998eefc7af Mon Sep 17 00:00:00 2001 From: taiyi747 <63543716+taiyi747@users.noreply.github.com> Date: Mon, 1 May 2023 11:40:36 +0800 Subject: GUI with PyWebIO --- gui/pywebio-gui/pywebio-usesless.py | 58 +++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 gui/pywebio-gui/pywebio-usesless.py (limited to 'gui/pywebio-gui') diff --git a/gui/pywebio-gui/pywebio-usesless.py b/gui/pywebio-gui/pywebio-usesless.py new file mode 100644 index 00000000..86a31e03 --- /dev/null +++ b/gui/pywebio-gui/pywebio-usesless.py @@ -0,0 +1,58 @@ +import usesless,time +from pywebio import start_server,config +from pywebio.input import * +from pywebio.output import * +from pywebio.session import local +message_id = "" +def status(): + try: + req = usesless.Completion.create(prompt="hello", parentMessageId=message_id) + print(f"Answer: {req['text']}") + put_success(f"Answer: {req['text']}",scope="body") + except: + put_error("Program Error",scope="body") + +def ask(prompt): + req = usesless.Completion.create(prompt=prompt, parentMessageId=local.message_id) + rp=req['text'] + local.message_id=req["id"] + print("AI:\n"+rp) + local.conversation.extend([ + {"role": "user", "content": prompt}, + {"role": "assistant", "content": rp} + ]) + print(local.conversation) + return rp + +def msg(): + while True: + text= input_group("You:",[textarea('You:',name='text',rows=3, placeholder='请输入问题')]) + if not(bool(text)): + break + if not(bool(text["text"])): + continue + time.sleep(0.5) + put_code("You:"+text["text"],scope="body") + print("Question:"+text["text"]) + with use_scope('foot'): + put_loading(color="info") + rp= ask(text["text"]) + clear(scope="foot") + time.sleep(0.5) + put_markdown("Bot:\n"+rp,scope="body") + time.sleep(0.7) + +@config(title="AIchat",theme="dark") +def main(): + put_scope("heads") + with use_scope('heads'): + put_html("