From 08f53b336158d0da44ed7c6e0d6ec2d01ab509a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=93=20sanz?= Date: Mon, 1 May 2023 09:10:38 +0800 Subject: Update streamlit_chat_app.py --- gui/streamlit_chat_app.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gui/streamlit_chat_app.py b/gui/streamlit_chat_app.py index 6abc9caf..bca4b954 100644 --- a/gui/streamlit_chat_app.py +++ b/gui/streamlit_chat_app.py @@ -74,7 +74,6 @@ user_input = input_placeholder.text_input( ) submit_button = st.button("Submit") - if (user_input and user_input != st.session_state['input_text']) or submit_button: output = query(user_input, st.session_state['query_method']) @@ -84,6 +83,7 @@ if (user_input and user_input != st.session_state['input_text']) or submit_butto st.session_state.current_conversation['generated_responses'].append(escaped_output) save_conversations(st.session_state.conversations, st.session_state.current_conversation) st.session_state['input_text'] = '' + st.session_state['input_field_key'] += 1 # Increment key value for new widget user_input = input_placeholder.text_input( 'You:', value=st.session_state['input_text'], key=f'input_text_{st.session_state["input_field_key"]}' ) # Clear the input field @@ -92,9 +92,8 @@ if (user_input and user_input != st.session_state['input_text']) or submit_butto if st.sidebar.button("New Conversation"): st.session_state['selected_conversation'] = None st.session_state['current_conversation'] = {'user_inputs': [], 'generated_responses': []} - st.session_state['input_field_key'] += 1 - -st.session_state['query_method'] = st.sidebar.selectbox("Select API:", options=avail_query_methods, index=0) + st.session_state['input_field_key'] += 1 # Increment key value for new widget + st.session_state['query_method'] = st.sidebar.selectbox("Select API:", options=avail_query_methods, index=0) # Proxy st.session_state['proxy'] = st.sidebar.text_input("Proxy: ") -- cgit v1.2.3 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 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 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 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 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("

AI Chat

") + put_scope("body") + put_scope("foot") + status() + local.conversation=[] + local.message_id="" + msg() + +print("Click link to chat page") +start_server(main, port=8099,allowed_origins="*",auto_open_webbrowser=True,debug=True) \ No newline at end of file -- cgit v1.2.3 From 0a40786ee047f3afe29a8b80320fbf905327d839 Mon Sep 17 00:00:00 2001 From: taiyi747 <63543716+taiyi747@users.noreply.github.com> Date: Mon, 1 May 2023 11:46:21 +0800 Subject: Update pywebio-usesless.py --- gui/pywebio-gui/pywebio-usesless.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gui/pywebio-gui/pywebio-usesless.py b/gui/pywebio-gui/pywebio-usesless.py index 86a31e03..c0843be6 100644 --- a/gui/pywebio-gui/pywebio-usesless.py +++ b/gui/pywebio-gui/pywebio-usesless.py @@ -1,4 +1,5 @@ -import usesless,time +from gpt4free import usesless +import time from pywebio import start_server,config from pywebio.input import * from pywebio.output import * @@ -55,4 +56,4 @@ def main(): msg() print("Click link to chat page") -start_server(main, port=8099,allowed_origins="*",auto_open_webbrowser=True,debug=True) \ No newline at end of file +start_server(main, port=8099,allowed_origins="*",auto_open_webbrowser=True,debug=True) -- cgit v1.2.3 From 94f0cbf8bc094b2040759ebfbaf0afc78d89a1af Mon Sep 17 00:00:00 2001 From: taiyi747 <63543716+taiyi747@users.noreply.github.com> Date: Mon, 1 May 2023 12:04:52 +0800 Subject: Update README.md --- gui/pywebio-gui/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gui/pywebio-gui/README.md b/gui/pywebio-gui/README.md index 8b137891..2b99c075 100644 --- a/gui/pywebio-gui/README.md +++ b/gui/pywebio-gui/README.md @@ -1 +1,24 @@ +# GUI with PyWebIO +Simple, fast, and with fewer errors +Only requires +```bash +pip install gpt4free +pip install pywebio +``` +clicking on 'pywebio-usesless.py' will run it +PS: Currently, only 'usesless' is implemented, and the GUI is expected to be updated infrequently, with a focus on stability. + +↓ Here is the introduction in zh-Hans-CN below. + +# 使用pywebio实现的极简GUI +简单,快捷,报错少 +只需要 +```bash +pip install gpt4free +pip install pywebio +``` + +双击pywebio-usesless.py即可运行 + +ps:目前仅实现usesless,这个gui更新频率应该会比较少,目的是追求稳定 -- cgit v1.2.3 From 31298b044abadea12a00d7487e8b93f6bf0bd363 Mon Sep 17 00:00:00 2001 From: taiyi747 <63543716+taiyi747@users.noreply.github.com> Date: Mon, 1 May 2023 12:10:50 +0800 Subject: Update README.md --- gui/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gui/README.md b/gui/README.md index c638c4dc..707fd36d 100644 --- a/gui/README.md +++ b/gui/README.md @@ -2,6 +2,8 @@ This code provides a Graphical User Interface (GUI) for gpt4free. Users can ask questions and get answers from GPT-4 API's, utilizing multiple API implementations. The project contains two different Streamlit applications: `streamlit_app.py` and `streamlit_chat_app.py`. +In addition, a new GUI script specifically implemented using PyWebIO has been added and can be found in the pywebio-gui folder. If there are errors with the Streamlit version, you can try using the PyWebIO version instead + Installation ------------ @@ -69,4 +71,4 @@ There is a bug in `streamlit_chat_app.py` right now that I haven't pinpointed ye License ------- -This project is licensed under the MIT License. \ No newline at end of file +This project is licensed under the MIT License. -- cgit v1.2.3 From 9b69fc60fef7cdcd0bc39220daf1fccba757ac6c Mon Sep 17 00:00:00 2001 From: wengchaoxi Date: Mon, 1 May 2023 12:25:28 +0800 Subject: Add docker image ci support --- .github/workflows/ci.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..21740635 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,37 @@ +name: Build and push `gpt4free` docker image + +on: + workflow_dispatch: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up qemu + uses: docker/setup-qemu-action@v2 + + - name: Set up docker buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to docker hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push docker image + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.ref == 'refs/heads/main' }} + tags: | + ${{ secrets.DOCKER_USERNAME }}/gpt4free:latest -- cgit v1.2.3