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 From 2140fc87cb8615a650711053f0afbbe4b1fd8553 Mon Sep 17 00:00:00 2001 From: mache102 Date: Mon, 1 May 2023 14:43:17 +0800 Subject: Refactor conversation selection --- gui/streamlit_chat_app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gui/streamlit_chat_app.py b/gui/streamlit_chat_app.py index 6abc9caf..50d8c5b9 100644 --- a/gui/streamlit_chat_app.py +++ b/gui/streamlit_chat_app.py @@ -105,7 +105,7 @@ st.sidebar.header("Conversation History") for idx, conversation in enumerate(st.session_state.conversations): if st.sidebar.button(f"Conversation {idx + 1}: {conversation['user_inputs'][0]}", key=f"sidebar_btn_{idx}"): st.session_state['selected_conversation'] = idx - st.session_state['current_conversation'] = st.session_state.conversations[idx] + st.session_state['current_conversation'] = conversation if st.session_state['selected_conversation'] is not None: conversation_to_display = st.session_state.conversations[st.session_state['selected_conversation']] @@ -115,4 +115,4 @@ else: if conversation_to_display['generated_responses']: for i in range(len(conversation_to_display['generated_responses']) - 1, -1, -1): message(conversation_to_display["generated_responses"][i], key=f"display_generated_{i}") - message(conversation_to_display['user_inputs'][i], is_user=True, key=f"display_user_{i}") + message(conversation_to_display['user_inputs'][i], is_user=True, key=f"display_user_{i}") \ No newline at end of file -- cgit v1.2.3 From fe97af4aaf65c792930c30bcbddcf5b8758573ad Mon Sep 17 00:00:00 2001 From: mache102 Date: Mon, 1 May 2023 15:23:40 +0800 Subject: add searchbar --- gui/streamlit_chat_app.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/gui/streamlit_chat_app.py b/gui/streamlit_chat_app.py index 50d8c5b9..c5c960a9 100644 --- a/gui/streamlit_chat_app.py +++ b/gui/streamlit_chat_app.py @@ -1,4 +1,5 @@ import atexit +import Levenshtein import os import sys @@ -64,13 +65,16 @@ if 'input_field_key' not in st.session_state: if 'query_method' not in st.session_state: st.session_state['query_method'] = query +if 'search_query' not in st.session_state: + st.session_state['search_query'] = '' + # Initialize new conversation if 'current_conversation' not in st.session_state or st.session_state['current_conversation'] is None: st.session_state['current_conversation'] = {'user_inputs': [], 'generated_responses': []} input_placeholder = st.empty() user_input = input_placeholder.text_input( - 'You:', value=st.session_state['input_text'], key=f'input_text_{st.session_state["input_field_key"]}' + 'You:', value=st.session_state['input_text'], key=f'input_text_-1'#{st.session_state["input_field_key"]} ) submit_button = st.button("Submit") @@ -80,7 +84,7 @@ if (user_input and user_input != st.session_state['input_text']) or submit_butto escaped_output = output.encode('utf-8').decode('unicode-escape') - st.session_state.current_conversation['user_inputs'].append(user_input) + st.session_state['current_conversation']['user_inputs'].append(user_input) 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'] = '' @@ -99,16 +103,31 @@ st.session_state['query_method'] = st.sidebar.selectbox("Select API:", options=a # Proxy st.session_state['proxy'] = st.sidebar.text_input("Proxy: ") +# Searchbar +search_query = st.sidebar.text_input("Search Conversations:", value=st.session_state.get('search_query', ''), key='search') + +if search_query: + filtered_conversations = [] + for conversation in st.session_state.conversations: + if search_query in conversation['user_inputs'][0]: + filtered_conversations.append(conversation) + + conversations = sorted(filtered_conversations, key=lambda c: Levenshtein.distance(search_query, c['user_inputs'][0])) + sidebar_header = f"Search Results ({len(conversations)})" +else: + conversations = st.session_state.conversations + sidebar_header = "Conversation History" + # Sidebar -st.sidebar.header("Conversation History") +st.sidebar.header(sidebar_header) -for idx, conversation in enumerate(st.session_state.conversations): +for idx, conversation in enumerate(conversations): if st.sidebar.button(f"Conversation {idx + 1}: {conversation['user_inputs'][0]}", key=f"sidebar_btn_{idx}"): st.session_state['selected_conversation'] = idx st.session_state['current_conversation'] = conversation if st.session_state['selected_conversation'] is not None: - conversation_to_display = st.session_state.conversations[st.session_state['selected_conversation']] + conversation_to_display = conversations[st.session_state['selected_conversation']] else: conversation_to_display = st.session_state.current_conversation -- cgit v1.2.3 From 64765476282096493e1f7b72a0f763fc1c3d9d5e Mon Sep 17 00:00:00 2001 From: sagadav Date: Mon, 1 May 2023 14:49:18 +0500 Subject: Typo correction in forefront README --- gpt4free/forefront/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gpt4free/forefront/README.md b/gpt4free/forefront/README.md index 35ba9897..887097ec 100644 --- a/gpt4free/forefront/README.md +++ b/gpt4free/forefront/README.md @@ -6,8 +6,11 @@ from gpt4free import forefront token = forefront.Account.create(logging=False) print(token) # get a response -for response in forefront.StreamingCompletion.create(token=token, - prompt='hello world', model='gpt-4'): - print(response.completion.choices[0].text, end='') +for response in forefront.StreamingCompletion.create( + token=token, + prompt='hello world', + model='gpt-4' +): + print(response.choices[0].text, end='') print("") ``` \ No newline at end of file -- cgit v1.2.3 From b78c6d51afd83b6f79d5b1d122c595aa3c7800fc Mon Sep 17 00:00:00 2001 From: CCXXXI Date: Mon, 1 May 2023 18:59:13 +0800 Subject: docs(readme): remove duplicate website https://chat.forefront.ai is mentioned twice. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 9fd505f2..b2aeedfc 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ Just API's from some language model sites. | [sqlchat.ai](https://sqlchat.ai) | GPT-3.5 | | [bard.google.com](https://bard.google.com) | custom / search | | [bing.com/chat](https://bing.com/chat) | GPT-4/3.5 | -| [chat.forefront.ai/](https://chat.forefront.ai/) | GPT-4/3.5 | ## Best sites -- cgit v1.2.3 From fb054408bf2b15b22c524d9c9556ef0af7ac8ed9 Mon Sep 17 00:00:00 2001 From: sagadav Date: Mon, 1 May 2023 17:53:32 +0500 Subject: theb: multiple messages --- gpt4free/theb/README.md | 9 ++++++--- gpt4free/theb/__init__.py | 14 +++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gpt4free/theb/README.md b/gpt4free/theb/README.md index a4abdf62..a7af9dd8 100644 --- a/gpt4free/theb/README.md +++ b/gpt4free/theb/README.md @@ -5,7 +5,10 @@ from gpt4free import theb # simple streaming completion -for token in theb.Completion.create('hello world'): - print(token, end='', flush=True) -print("") + +while True: + x = input() + for token in theb.Completion.create(x): + print(token, end='', flush=True) + print("") ``` diff --git a/gpt4free/theb/__init__.py b/gpt4free/theb/__init__.py index 75a15068..741de34d 100644 --- a/gpt4free/theb/__init__.py +++ b/gpt4free/theb/__init__.py @@ -17,6 +17,7 @@ class Completion: timer = None message_queue = Queue() stream_completed = False + last_msg_id = None @staticmethod def request(prompt: str, proxy: Optional[str]=None): @@ -28,26 +29,33 @@ class Completion: } proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None - + + options = {} + if Completion.last_msg_id: + options['parentMessageId'] = Completion.last_msg_id + requests.post( 'https://chatbot.theb.ai/api/chat-process', headers=headers, proxies=proxies, content_callback=Completion.handle_stream_response, - json={'prompt': prompt, 'options': {}}, + json={'prompt': prompt, 'options': options}, ) Completion.stream_completed = True @staticmethod def create(prompt: str, proxy: Optional[str]=None) -> Generator[str, None, None]: + Completion.stream_completed = False Thread(target=Completion.request, args=[prompt, proxy]).start() while not Completion.stream_completed or not Completion.message_queue.empty(): try: message = Completion.message_queue.get(timeout=0.01) for message in findall(Completion.regex, message): - yield loads(Completion.part1 + message + Completion.part2)['delta'] + message_json = loads(Completion.part1 + message + Completion.part2) + Completion.last_msg_id = message_json['id'] + yield message_json['delta'] except Empty: pass -- cgit v1.2.3 From 4b86f5012077e218ae296d81f1305ab0931ec2cc Mon Sep 17 00:00:00 2001 From: Raju Komati Date: Mon, 1 May 2023 19:56:33 +0530 Subject: added method for deleting poe account --- gpt4free/quora/__init__.py | 23 +++++++++++----------- gpt4free/quora/api.py | 6 ++++++ ...ntButton_deleteAccountMutation_Mutation.graphql | 1 + 3 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 gpt4free/quora/graphql/SettingsDeleteAccountButton_deleteAccountMutation_Mutation.graphql diff --git a/gpt4free/quora/__init__.py b/gpt4free/quora/__init__.py index afbfb68d..56dd7b24 100644 --- a/gpt4free/quora/__init__.py +++ b/gpt4free/quora/__init__.py @@ -285,6 +285,11 @@ class Account: cookies = open(Path(__file__).resolve().parent / 'cookies.txt', 'r').read().splitlines() return choice(cookies) + @staticmethod + def delete_account(token: str, proxy: Optional[str] = None): + client = PoeClient(token, proxy=proxy) + client.delete_account() + class StreamingCompletion: @staticmethod @@ -293,11 +298,11 @@ class StreamingCompletion: custom_model: bool = None, prompt: str = 'hello world', token: str = '', - proxy: Optional[str] = None + proxy: Optional[str] = None, ) -> Generator[PoeResponse, None, None]: _model = MODELS[model] if not custom_model else custom_model - proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else False + proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False client = PoeClient(token) client.proxy = proxies @@ -333,7 +338,7 @@ class Completion: custom_model: str = None, prompt: str = 'hello world', token: str = '', - proxy: Optional[str] = None + proxy: Optional[str] = None, ) -> PoeResponse: _model = MODELS[model] if not custom_model else custom_model @@ -454,14 +459,7 @@ class Poe: response = chunk['text'] return response - def create_bot( - self, - name: str, - /, - prompt: str = '', - base_model: str = 'ChatGPT', - description: str = '', - ) -> None: + def create_bot(self, name: str, /, prompt: str = '', base_model: str = 'ChatGPT', description: str = '') -> None: if base_model not in MODELS: raise RuntimeError('Sorry, the base_model you provided does not exist. Please check and try again.') @@ -475,3 +473,6 @@ class Poe: def list_bots(self) -> list: return list(self.client.bot_names.values()) + + def delete_account(self) -> None: + self.client.delete_account() diff --git a/gpt4free/quora/api.py b/gpt4free/quora/api.py index 897215a8..d388baee 100644 --- a/gpt4free/quora/api.py +++ b/gpt4free/quora/api.py @@ -541,5 +541,11 @@ class Client: self.get_bots() return data + def delete_account(self) -> None: + response = self.send_query('SettingsDeleteAccountButton_deleteAccountMutation_Mutation', {}) + data = response['data']['deleteAccount'] + if 'viewer' not in data: + raise RuntimeError(f'Error occurred while deleting the account, Please try again!') + load_queries() diff --git a/gpt4free/quora/graphql/SettingsDeleteAccountButton_deleteAccountMutation_Mutation.graphql b/gpt4free/quora/graphql/SettingsDeleteAccountButton_deleteAccountMutation_Mutation.graphql new file mode 100644 index 00000000..0af50950 --- /dev/null +++ b/gpt4free/quora/graphql/SettingsDeleteAccountButton_deleteAccountMutation_Mutation.graphql @@ -0,0 +1 @@ +mutation SettingsDeleteAccountButton_deleteAccountMutation_Mutation{ deleteAccount { viewer { uid id } }} \ No newline at end of file -- cgit v1.2.3 From 136c4229c2d1c7aab10070934c574f052d3e16d2 Mon Sep 17 00:00:00 2001 From: Raju Komati Date: Mon, 1 May 2023 19:57:44 +0530 Subject: renamed method --- gpt4free/quora/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpt4free/quora/__init__.py b/gpt4free/quora/__init__.py index 56dd7b24..bc17ea5d 100644 --- a/gpt4free/quora/__init__.py +++ b/gpt4free/quora/__init__.py @@ -286,7 +286,7 @@ class Account: return choice(cookies) @staticmethod - def delete_account(token: str, proxy: Optional[str] = None): + def delete(token: str, proxy: Optional[str] = None): client = PoeClient(token, proxy=proxy) client.delete_account() -- cgit v1.2.3 From 1eefa094e3cb4a7cde74ece82a5f8215150ef7c4 Mon Sep 17 00:00:00 2001 From: Raju Komati Date: Mon, 1 May 2023 20:02:44 +0530 Subject: updated quora readme --- gpt4free/quora/README.md | 9 +++++++++ testing/poe_test.py | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/gpt4free/quora/README.md b/gpt4free/quora/README.md index 9c652c59..88fd0093 100644 --- a/gpt4free/quora/README.md +++ b/gpt4free/quora/README.md @@ -65,4 +65,13 @@ poe.chat('who won the football world cup most?') # new bot creation poe.create_bot('new_bot_name', prompt='You are new test bot', base_model='gpt-3.5-turbo') +# delete account +poe.delete_account() +``` + +### Deleting the Poe Account +```python +from gpt4free import quora + +quora.Account.delete(token='') ``` diff --git a/testing/poe_test.py b/testing/poe_test.py index 22d95f5f..6edc030c 100644 --- a/testing/poe_test.py +++ b/testing/poe_test.py @@ -1,6 +1,6 @@ from time import sleep -from gpt4free import quora +from gpt4free import quora token = quora.Account.create(proxy=None, logging=True) print('token', token) @@ -9,3 +9,5 @@ sleep(2) for response in quora.StreamingCompletion.create(model='ChatGPT', prompt='hello world', token=token): print(response.text, flush=True) + +quora.Account.delete(token) -- cgit v1.2.3 From 05494ebbb1436db8028d1e6e8189c550dc9ddf03 Mon Sep 17 00:00:00 2001 From: Raju Komati Date: Mon, 1 May 2023 20:04:45 +0530 Subject: refactored code --- gpt4free/__init__.py | 7 +++---- gpt4free/forefront/__init__.py | 16 ++++++---------- gpt4free/forefront/typing.py | 3 ++- gpt4free/quora/backup-mail.py | 30 +++++++++++++++++++----------- gpt4free/theb/__init__.py | 4 ++-- gpt4free/usesless/__init__.py | 9 +++++---- gpt4free/you/__init__.py | 4 ++-- testing/theb_test.py | 2 +- testing/useless_test.py | 6 ++---- 9 files changed, 42 insertions(+), 39 deletions(-) diff --git a/gpt4free/__init__.py b/gpt4free/__init__.py index b4742b64..6df778e3 100644 --- a/gpt4free/__init__.py +++ b/gpt4free/__init__.py @@ -4,8 +4,8 @@ from gpt4free import cocalc from gpt4free import forefront from gpt4free import quora from gpt4free import theb -from gpt4free import you from gpt4free import usesless +from gpt4free import you class Provider(Enum): @@ -24,7 +24,6 @@ class Completion: @staticmethod def create(provider: Provider, prompt: str, **kwargs) -> str: - """ Invokes the given provider with given prompt and addition arguments and returns the string response @@ -47,10 +46,10 @@ class Completion: return Completion.__useless_service(prompt, **kwargs) else: raise Exception('Provider not exist, Please try again') - + @staticmethod def __useless_service(prompt: str, **kwargs) -> str: - return usesless.Completion.create(prompt = prompt, **kwargs) + return usesless.Completion.create(prompt=prompt, **kwargs) @staticmethod def __you_service(prompt: str, **kwargs) -> str: diff --git a/gpt4free/forefront/__init__.py b/gpt4free/forefront/__init__.py index 969b33b8..4d679a14 100644 --- a/gpt4free/forefront/__init__.py +++ b/gpt4free/forefront/__init__.py @@ -5,8 +5,8 @@ from typing import Generator, Optional from uuid import uuid4 from fake_useragent import UserAgent -from requests import post from pymailtm import MailTm, Message +from requests import post from tls_client import Session from .typing import ForeFrontResponse @@ -43,10 +43,7 @@ class Account: response = client.post( f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4', - data={ - 'strategy': 'email_link', - 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify' - }, + data={'strategy': 'email_link', 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'}, ) if logging: @@ -93,14 +90,14 @@ class StreamingCompletion: action_type='new', default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default model='gpt-4', - proxy=None + proxy=None, ) -> Generator[ForeFrontResponse, None, None]: if not token: raise Exception('Token is required!') if not chat_id: chat_id = str(uuid4()) - proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else None + proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None headers = { 'authority': 'chat-server.tenant-forefront-default.knative.chi.coreweave.com', @@ -168,7 +165,7 @@ class Completion: action_type='new', default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default model='gpt-4', - proxy=None + proxy=None, ) -> ForeFrontResponse: text = '' final_response = None @@ -179,7 +176,7 @@ class Completion: action_type=action_type, default_persona=default_persona, model=model, - proxy=proxy + proxy=proxy, ): if response: final_response = response @@ -191,4 +188,3 @@ class Completion: raise Exception('Unable to get the response, Please try again') return final_response - \ No newline at end of file diff --git a/gpt4free/forefront/typing.py b/gpt4free/forefront/typing.py index a9025419..23e90903 100644 --- a/gpt4free/forefront/typing.py +++ b/gpt4free/forefront/typing.py @@ -1,4 +1,5 @@ from typing import Any, List + from pydantic import BaseModel @@ -22,4 +23,4 @@ class ForeFrontResponse(BaseModel): model: str choices: List[Choice] usage: Usage - text: str \ No newline at end of file + text: str diff --git a/gpt4free/quora/backup-mail.py b/gpt4free/quora/backup-mail.py index 0a2a5e94..25d526d7 100644 --- a/gpt4free/quora/backup-mail.py +++ b/gpt4free/quora/backup-mail.py @@ -1,7 +1,10 @@ -from requests import Session -from time import sleep from json import loads from re import findall +from time import sleep + +from requests import Session + + class Mail: def __init__(self) -> None: self.client = Session() @@ -9,29 +12,34 @@ class Mail: self.cookies = {'acceptcookie': 'true'} self.cookies["ci_session"] = self.client.cookies.get_dict()["ci_session"] self.email = None + def get_mail(self): - respone=self.client.post("https://etempmail.com/getEmailAddress") - #cookies + respone = self.client.post("https://etempmail.com/getEmailAddress") + # cookies self.cookies["lisansimo"] = eval(respone.text)["recover_key"] self.email = eval(respone.text)["address"] return self.email + def get_message(self): print("Waiting for message...") while True: sleep(5) - respone=self.client.post("https://etempmail.com/getInbox") - mail_token=loads(respone.text) + respone = self.client.post("https://etempmail.com/getInbox") + mail_token = loads(respone.text) print(self.client.cookies.get_dict()) if len(mail_token) == 1: break - - params = {'id': '1',} - self.mail_context = self.client.post("https://etempmail.com/getInbox",params=params) + + params = { + 'id': '1', + } + self.mail_context = self.client.post("https://etempmail.com/getInbox", params=params) self.mail_context = eval(self.mail_context.text)[0]["body"] return self.mail_context - #,cookies=self.cookies + + # ,cookies=self.cookies def get_verification_code(self): message = self.mail_context code = findall(r';">(\d{6,7})', message)[0] print(f"Verification code: {code}") - return code \ No newline at end of file + return code diff --git a/gpt4free/theb/__init__.py b/gpt4free/theb/__init__.py index 75a15068..c696387e 100644 --- a/gpt4free/theb/__init__.py +++ b/gpt4free/theb/__init__.py @@ -19,7 +19,7 @@ class Completion: stream_completed = False @staticmethod - def request(prompt: str, proxy: Optional[str]=None): + def request(prompt: str, proxy: Optional[str] = None): headers = { 'authority': 'chatbot.theb.ai', 'content-type': 'application/json', @@ -40,7 +40,7 @@ class Completion: Completion.stream_completed = True @staticmethod - def create(prompt: str, proxy: Optional[str]=None) -> Generator[str, None, None]: + def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]: Thread(target=Completion.request, args=[prompt, proxy]).start() while not Completion.stream_completed or not Completion.message_queue.empty(): diff --git a/gpt4free/usesless/__init__.py b/gpt4free/usesless/__init__.py index 6029009d..40e99938 100644 --- a/gpt4free/usesless/__init__.py +++ b/gpt4free/usesless/__init__.py @@ -1,6 +1,7 @@ -import requests import json +import requests + class Completion: headers = { @@ -24,7 +25,7 @@ class Completion: model: str = "gpt-3.5-turbo", ): print(parentMessageId, prompt) - + json_data = { "openaiKey": "", "prompt": prompt, @@ -42,14 +43,14 @@ class Completion: url = "https://ai.usesless.com/api/chat-process" request = requests.post(url, headers=Completion.headers, json=json_data) content = request.content - + response = Completion.__response_to_json(content) return response @classmethod def __response_to_json(cls, text) -> dict: text = str(text.decode("utf-8")) - + split_text = text.rsplit("\n", 1)[1] to_json = json.loads(split_text) return to_json diff --git a/gpt4free/you/__init__.py b/gpt4free/you/__init__.py index d084a842..da22d05e 100644 --- a/gpt4free/you/__init__.py +++ b/gpt4free/you/__init__.py @@ -30,12 +30,12 @@ class Completion: include_links: bool = False, detailed: bool = False, debug: bool = False, - proxy: Optional[str] = None + proxy: Optional[str] = None, ) -> PoeResponse: if chat is None: chat = [] - proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else {} + proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else {} client = Session(client_identifier='chrome_108') client.headers = Completion.__get_headers() diff --git a/testing/theb_test.py b/testing/theb_test.py index 0fd2ec8b..5fa80908 100644 --- a/testing/theb_test.py +++ b/testing/theb_test.py @@ -2,4 +2,4 @@ from gpt4free import theb for token in theb.Completion.create('hello world'): print(token, end='', flush=True) - print('asdsos') \ No newline at end of file + print('asdsos') diff --git a/testing/useless_test.py b/testing/useless_test.py index 9b613aac..47c92386 100644 --- a/testing/useless_test.py +++ b/testing/useless_test.py @@ -11,7 +11,6 @@ while True: print(f"Answer: {req['text']}") message_id = req["id"] - import gpt4free message_id = "" @@ -20,8 +19,7 @@ while True: if prompt == "!stop": break - req = gpt4free.Completion.create(provider = gpt4free.Provider.UseLess, - prompt=prompt, parentMessageId=message_id) + req = gpt4free.Completion.create(provider=gpt4free.Provider.UseLess, prompt=prompt, parentMessageId=message_id) print(f"Answer: {req['text']}") - message_id = req["id"] \ No newline at end of file + message_id = req["id"] -- cgit v1.2.3 From 55f2a3365141055db3a1b529d4c8c3b365f4eb2e Mon Sep 17 00:00:00 2001 From: xiangsx <1984871009@qq.com> Date: Mon, 1 May 2023 22:47:25 +0800 Subject: Remove duplicate docker-compose.yml --- README.md | 6 +----- docker-compose.yaml | 12 +++++++++--- docker-compose.yml | 12 ------------ 3 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 docker-compose.yml diff --git a/README.md b/README.md index 9fd505f2..75b62a8c 100644 --- a/README.md +++ b/README.md @@ -127,17 +127,13 @@ Run ``` docker run -p 8501:8501 gpt4free:latest ``` -Another way - docker-compose (no docker build/run needed) -``` -docker-compose up -d -``` ## Deploy using docker-compose Run the following: ``` -docker-compose up -d +docker-compose up --build -d ``` ## ChatGPT clone diff --git a/docker-compose.yaml b/docker-compose.yaml index 3afd6cdf..c9cc7d8f 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,8 +2,14 @@ version: "3.9" services: gpt4free: - build: - context: . + build: + context: ./ dockerfile: Dockerfile + container_name: dc_gpt4free + environment: + # - http_proxy=http://127.0.0.1:1080 + # - https_proxy=http://127.0.0.1:1080 + image: img_gpt4free ports: - - "8501:8501" + - 8501:8501 + restart: always \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index e8e7119b..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: '3.8' - -services: - gpt4: - build: - context: . - dockerfile: Dockerfile - image: gpt4free:latest - container_name: gpt4 - ports: - - 8501:8501 - restart: unless-stopped -- cgit v1.2.3 From 6604b3a0453b2fceb64cfbbf2a8f130f77a20b61 Mon Sep 17 00:00:00 2001 From: xiangsx <1984871009@qq.com> Date: Mon, 1 May 2023 22:49:34 +0800 Subject: =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index c9cc7d8f..09bf4605 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -7,8 +7,8 @@ services: dockerfile: Dockerfile container_name: dc_gpt4free environment: - # - http_proxy=http://127.0.0.1:1080 - # - https_proxy=http://127.0.0.1:1080 + - http_proxy=http://127.0.0.1:1080 + - https_proxy=http://127.0.0.1:1080 image: img_gpt4free ports: - 8501:8501 -- cgit v1.2.3 From 7d72cf6a15f748cb7fefacad86078bd8f8ae6ba3 Mon Sep 17 00:00:00 2001 From: xiangsx <1984871009@qq.com> Date: Mon, 1 May 2023 22:50:17 +0800 Subject: Add proxy config --- docker-compose.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 09bf4605..8098f359 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -6,9 +6,9 @@ services: context: ./ dockerfile: Dockerfile container_name: dc_gpt4free - environment: - - http_proxy=http://127.0.0.1:1080 - - https_proxy=http://127.0.0.1:1080 + # environment: + # - http_proxy=http://127.0.0.1:1080 # modify this for your proxy + # - https_proxy=http://127.0.0.1:1080 # modify this for your proxy image: img_gpt4free ports: - 8501:8501 -- cgit v1.2.3 From 4853e4bfad5c3d6a32b8f309f0a2e54e0d35fe3d Mon Sep 17 00:00:00 2001 From: mache102 Date: Mon, 1 May 2023 22:57:20 +0800 Subject: fix index display for search --- gui/streamlit_chat_app.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gui/streamlit_chat_app.py b/gui/streamlit_chat_app.py index c5c960a9..f80afa80 100644 --- a/gui/streamlit_chat_app.py +++ b/gui/streamlit_chat_app.py @@ -108,20 +108,24 @@ search_query = st.sidebar.text_input("Search Conversations:", value=st.session_s if search_query: filtered_conversations = [] - for conversation in st.session_state.conversations: + indices = [] + for idx, conversation in enumerate(st.session_state.conversations): if search_query in conversation['user_inputs'][0]: filtered_conversations.append(conversation) + indices.append(idx) + + filtered_conversations = list(zip(indices, filtered_conversations)) + conversations = sorted(filtered_conversations, key=lambda x: Levenshtein.distance(search_query, x[1]['user_inputs'][0])) - conversations = sorted(filtered_conversations, key=lambda c: Levenshtein.distance(search_query, c['user_inputs'][0])) sidebar_header = f"Search Results ({len(conversations)})" else: - conversations = st.session_state.conversations + conversations = enumerate(st.session_state.conversations) sidebar_header = "Conversation History" # Sidebar st.sidebar.header(sidebar_header) -for idx, conversation in enumerate(conversations): +for idx, conversation in conversations: if st.sidebar.button(f"Conversation {idx + 1}: {conversation['user_inputs'][0]}", key=f"sidebar_btn_{idx}"): st.session_state['selected_conversation'] = idx st.session_state['current_conversation'] = conversation -- cgit v1.2.3 From c079dfef8a8a787a316d88c2549d4b6499a570dc Mon Sep 17 00:00:00 2001 From: Mishal <91066601+mishalhossin@users.noreply.github.com> Date: Mon, 1 May 2023 21:27:57 +0600 Subject: Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9fd505f2..88733c23 100644 --- a/README.md +++ b/README.md @@ -32,11 +32,11 @@ Just API's from some language model sites. Pull Requests - ChatGpt Discord Bot - Stars - Forks - Issues - Pull Requests + ChatGpt Discord Bot + Stars + Forks + Issues + Pull Requests -- cgit v1.2.3 From 2ceffaca52a4699a083d0101a1a95c2af3fc0716 Mon Sep 17 00:00:00 2001 From: Marijn Koesen Date: Mon, 1 May 2023 18:09:21 +0200 Subject: Fix docker build instructions As the Dockerfile was moved we need to update the path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fd505f2..dc11765b 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ then run: Build ``` -docker build -t gpt4free:latest -f Docker/Dockerfile . +docker build -t gpt4free:latest . ``` Run -- cgit v1.2.3 From 611a565092e5ca22d76f6d2c9481a2f89031ea2f Mon Sep 17 00:00:00 2001 From: Hexye <65314629+HexyeDEV@users.noreply.github.com> Date: Mon, 1 May 2023 19:24:01 +0200 Subject: add italygpt.it --- README.md | 1 + gpt4free/italygpt/README.md | 18 ++++++++++++++++++ gpt4free/italygpt/__init__.py | 28 ++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 gpt4free/italygpt/README.md create mode 100644 gpt4free/italygpt/__init__.py diff --git a/README.md b/README.md index 9fd505f2..42f2e007 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Just API's from some language model sites. | [bard.google.com](https://bard.google.com) | custom / search | | [bing.com/chat](https://bing.com/chat) | GPT-4/3.5 | | [chat.forefront.ai/](https://chat.forefront.ai/) | GPT-4/3.5 | +| [italygpt.it](https://italygpt.it) | GPT-3.5 | ## Best sites diff --git a/gpt4free/italygpt/README.md b/gpt4free/italygpt/README.md new file mode 100644 index 00000000..984eff3a --- /dev/null +++ b/gpt4free/italygpt/README.md @@ -0,0 +1,18 @@ +### Example: `italygpt` + +```python +# create an instance +from gpt4free import italygpt +italygpt = italygpt.Completion() + +# initialize api +italygpt.init() + +# get an answer +italygpt.create(prompt="What is the meaning of life?") +print(italygpt.answer) # html formatted + +# keep the old conversation +italygpt.create(prompt="Are you a human?", messages=italygpt.messages) +print(italygpt.answer) +``` \ No newline at end of file diff --git a/gpt4free/italygpt/__init__.py b/gpt4free/italygpt/__init__.py new file mode 100644 index 00000000..27a965f1 --- /dev/null +++ b/gpt4free/italygpt/__init__.py @@ -0,0 +1,28 @@ +import requests, time, ast, json +from bs4 import BeautifulSoup +from hashlib import sha256 + +class Completion: + # answer is returned with html formatting + next_id = None + messages = [] + answer = None + + def init(self): + r = requests.get("https://italygpt.it") + soup = BeautifulSoup(r.text, "html.parser") + self.next_id = soup.find("input", {"name": "next_id"})["value"] + + def create(self, prompt: str, messages: list = []): + try: + r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).json() + except: + r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).text + if "too many requests" in r.lower(): + # rate limit is 17 requests per 1 minute + time.sleep(20) + return self.create(prompt, messages) + self.next_id = r["next_id"] + self.messages = ast.literal_eval(r["raw_messages"]) + self.answer = r["response"] + return self \ No newline at end of file -- cgit v1.2.3 From 0735ce5baaa6c270fe2583042aa1a1761738f087 Mon Sep 17 00:00:00 2001 From: TotoB12 <91705868+TotoB12@users.noreply.github.com> Date: Mon, 1 May 2023 13:26:49 -0400 Subject: Update README.md changed the link of example gui app --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4968662b..39bada36 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ docker-compose up --build -d ## ChatGPT clone > currently implementing new features and trying to scale it, please be patient it may be unstable -> https://chat.chatbot.sex/chat +> https://chat.g4f.ai/chat > This site was developed by me and includes **gpt-4/3.5**, **internet access** and **gpt-jailbreak's** like DAN > run locally here: https://github.com/xtekky/chatgpt-clone -- cgit v1.2.3 From 3f49f18e070216d73030385cf45a602a7e172a44 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Mon, 1 May 2023 18:39:59 +0100 Subject: Update FUNDING.yml --- .github/FUNDING.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c1240682..696be746 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,13 +1,3 @@ -# These are supported funding model platforms - github: [onlp] patreon: xtekky -open_collective: # Replace with a single Open Collective username ko_fi: xtekky -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: tekky -issuehunt: xtekky -otechie: # Replace with a single Otechie username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] -- cgit v1.2.3 From 1379ec96b98fccc4f89b598149ac9bf4671c3fad Mon Sep 17 00:00:00 2001 From: Vokturz Date: Mon, 1 May 2023 15:44:58 -0400 Subject: added option to remove conversations --- gui/streamlit_chat_app.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/gui/streamlit_chat_app.py b/gui/streamlit_chat_app.py index 99e8428c..af3969e6 100644 --- a/gui/streamlit_chat_app.py +++ b/gui/streamlit_chat_app.py @@ -38,6 +38,17 @@ def save_conversations(conversations, current_conversation): os.replace(temp_conversations_file, conversations_file) +def delete_conversation(conversations, current_conversation): + for idx, conversation in enumerate(conversations): + conversations[idx] = current_conversation + break + conversations.remove(current_conversation) + + temp_conversations_file = "temp_" + conversations_file + with open(temp_conversations_file, "wb") as f: + pickle.dump(conversations, f) + + os.replace(temp_conversations_file, conversations_file) def exit_handler(): print("Exiting, saving data...") @@ -118,17 +129,22 @@ if search_query: sidebar_header = f"Search Results ({len(conversations)})" else: - conversations = enumerate(st.session_state.conversations) + conversations = st.session_state.conversations sidebar_header = "Conversation History" # Sidebar st.sidebar.header(sidebar_header) - -for idx, conversation in conversations: - if st.sidebar.button(f"Conversation {idx + 1}: {conversation['user_inputs'][0]}", key=f"sidebar_btn_{idx}"): +sidebar_col1, sidebar_col2 = st.sidebar.columns([5,1]) +for idx, conversation in enumerate(conversations): + if sidebar_col1.button(f"Conversation {idx + 1}: {conversation['user_inputs'][0]}", key=f"sidebar_btn_{idx}"): st.session_state['selected_conversation'] = idx st.session_state['current_conversation'] = conversation - + if sidebar_col2.button('🗑️', key=f"sidebar_btn_delete_{idx}"): + if st.session_state['selected_conversation'] == idx: + st.session_state['selected_conversation'] = None + st.session_state['current_conversation'] = {'user_inputs': [], 'generated_responses': []} + delete_conversation(conversations, conversation) + st.experimental_rerun() if st.session_state['selected_conversation'] is not None: conversation_to_display = conversations[st.session_state['selected_conversation']] else: -- cgit v1.2.3 From ac09fc80d4a6de9ae0339f1fc432fa0fc6074d17 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Mon, 1 May 2023 21:21:45 +0100 Subject: Update README.md --- README.md | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 39bada36..51446780 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,19 @@ gpt4free logo + +## Legal Notice + +This repository uses third-party APIs and is _not_ associated with or endorsed by the API providers. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security. + +Please note the following: + +1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them. + +2. **Responsibility**: The author of this repository is _not_ responsible for any consequences arising from the use or misuse of this repository or the content provided by the third-party APIs and any damage or losses caused by users' actions. + +3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. + + + Just API's from some language model sites.

Join our discord.gg/gpt4free Discord community! gpt4free Discord

@@ -142,18 +157,6 @@ docker-compose up --build -d > This site was developed by me and includes **gpt-4/3.5**, **internet access** and **gpt-jailbreak's** like DAN > run locally here: https://github.com/xtekky/chatgpt-clone -## Legal Notice - -This repository uses third-party APIs and is _not_ associated with or endorsed by the API providers. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security. - -Please note the following: - -1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them. - -2. **Responsibility**: The author of this repository is _not_ responsible for any consequences arising from the use or misuse of this repository or the content provided by the third-party APIs and any damage or losses caused by users' actions. - -3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. - ## Copyright: This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt) -- cgit v1.2.3 From cb17cc7fe41440c920082722ca6e5bf0bd3d75e8 Mon Sep 17 00:00:00 2001 From: wuyuesong <1377030423@qq.com> Date: Tue, 2 May 2023 13:37:41 +0800 Subject: add Levenshtein in requirements.txt for gui/streamlit_chat_app.py --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 62e92d56..bc46bc70 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,3 +12,4 @@ twocaptcha https://github.com/AI-Yash/st-chat/archive/refs/pull/24/head.zip pydantic pymailtm +Levenshtein -- cgit v1.2.3 From f4d476371b110debc7467988b63f14fecb4facd9 Mon Sep 17 00:00:00 2001 From: Marvin <115476150+Fubge@users.noreply.github.com> Date: Tue, 2 May 2023 10:14:04 +0200 Subject: docs: Update README.md / fix typo Fixed small capitalization typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 51446780..8210b6c9 100644 --- a/README.md +++ b/README.md @@ -152,10 +152,10 @@ docker-compose up --build -d ## ChatGPT clone -> currently implementing new features and trying to scale it, please be patient it may be unstable +> Currently implementing new features and trying to scale it, please be patient it may be unstable > https://chat.g4f.ai/chat > This site was developed by me and includes **gpt-4/3.5**, **internet access** and **gpt-jailbreak's** like DAN -> run locally here: https://github.com/xtekky/chatgpt-clone +> Run locally here: https://github.com/xtekky/chatgpt-clone ## Copyright: -- cgit v1.2.3 From 9a52ab80cf86e5663c31f333b2a7d47c3f0169d5 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Tue, 2 May 2023 09:37:44 +0100 Subject: Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 8210b6c9..46744ce7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Legal Notice -This repository uses third-party APIs and is _not_ associated with or endorsed by the API providers. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security. +This repository is _not_ associated with or endorsed by providers of the API's contained in this github repository. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security, or have their site taken down. Please note the following: @@ -13,7 +13,6 @@ Please note the following: 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. - Just API's from some language model sites.

Join our discord.gg/gpt4free Discord community! gpt4free Discord

-- cgit v1.2.3 From bf45b5366cf4c26e21f35f5591cdfd704526f399 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Tue, 2 May 2023 09:40:12 +0100 Subject: Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 46744ce7..93a4d991 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Please note the following: 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. +You agree to these terms by using this repository or any code related to it. I am not reponsible for any copies, forks or reuploads, this is my only account and repo. + Just API's from some language model sites. -- cgit v1.2.3 From 7aab31081c4f592048314b3da83342e463ea16fc Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Tue, 2 May 2023 09:44:36 +0100 Subject: Update README.md --- README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 93a4d991..1f36c2d5 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,25 @@ ## Legal Notice -This repository is _not_ associated with or endorsed by providers of the API's contained in this github repository. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security, or have their site taken down. +This repository is _not_ associated with or endorsed by providers of the APIs contained in this GitHub repository. This project is intended **for educational purposes only**. This is just a little personal project. Sites may contact me to improve their security or request the removal of their site from this repository. Please note the following: -1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them. +1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them nor is it affiliated with or endorsed by any of the providers mentioned. -2. **Responsibility**: The author of this repository is _not_ responsible for any consequences arising from the use or misuse of this repository or the content provided by the third-party APIs and any damage or losses caused by users' actions. +2. **Responsibility**: The author of this repository is _not_ responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by the third-party APIs. Users are solely responsible for their actions and any repercussions that may follow. 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. -You agree to these terms by using this repository or any code related to it. I am not reponsible for any copies, forks or reuploads, this is my only account and repo. +4. **Copyright**: All content in this repository, including but not limited to code, images, and documentation, is the intellectual property of the repository author, unless otherwise stated. Unauthorized copying, distribution, or use of any content in this repository is strictly prohibited without the express written consent of the repository author. +5. **Indemnification**: Users agree to indemnify, defend, and hold harmless the author of this repository from and against any and all claims, liabilities, damages, losses, or expenses, including legal fees and costs, arising out of or in any way connected with their use or misuse of this repository, its content, or related third-party APIs. + +6. **Updates and Changes**: The author reserves the right to modify, update, or remove any content, information, or features in this repository at any time without prior notice. Users are responsible for regularly reviewing the content and any changes made to this repository. + +By using this repository or any code related to it, you agree to these terms. The author is not responsible for any copies, forks, or reuploads made by other users. This is the author's only account and repository. To prevent impersonation or irresponsible actions, you may comply with the GNU GPL license this Repository uses. + +
Just API's from some language model sites. -- cgit v1.2.3 From 2d3447f78c8d0c65b661b1039828c645ded0c6e0 Mon Sep 17 00:00:00 2001 From: TotoB12 <91705868+TotoB12@users.noreply.github.com> Date: Tue, 2 May 2023 09:14:39 -0400 Subject: Update README.md remove unnecessary line break --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 28a77b7e..90c42c33 100644 --- a/README.md +++ b/README.md @@ -133,8 +133,7 @@ pip3 install -r requirements.txt ## To start gpt4free GUI -Move `streamlit_app.py` from `./gui` to the base folder -then run: +Move `streamlit_app.py` from `./gui` to the base folder then run: `streamlit run streamlit_app.py` or `python3 -m streamlit run streamlit_app.py` ## Docker -- cgit v1.2.3 From f6db1426e489e7d79c52edc57133abb6525fe993 Mon Sep 17 00:00:00 2001 From: kondo Date: Wed, 3 May 2023 02:12:37 +0900 Subject: Add function to save Forefront cookies --- gpt4free/forefront/__init__.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/gpt4free/forefront/__init__.py b/gpt4free/forefront/__init__.py index 4d679a14..23978501 100644 --- a/gpt4free/forefront/__init__.py +++ b/gpt4free/forefront/__init__.py @@ -1,3 +1,5 @@ +import os +import pickle from json import loads from re import findall from time import time, sleep @@ -13,8 +15,29 @@ from .typing import ForeFrontResponse class Account: + COOKIES_FILE_NAME = 'cookies.pickle' + @staticmethod - def create(proxy: Optional[str] = None, logging: bool = False): + def login(proxy: Optional[str] = None, logging: bool = False) -> str: + if not os.path.isfile(Account.COOKIES_FILE_NAME): + return Account.create(proxy, logging) + + with open(Account.COOKIES_FILE_NAME, 'rb') as f: + cookies = pickle.load(f) + proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False + + client = Session(client_identifier='chrome110') + client.proxies = proxies + client.cookies.update(cookies) + + if Account.is_cookie_enabled(client): + response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4') + return response.json()['response']['sessions'][0]['last_active_token']['jwt'] + else: + return Account.create(proxy, logging) + + @staticmethod + def create(proxy: Optional[str] = None, logging: bool = False, save_cookies: bool = False) -> str: proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False start = time() @@ -72,6 +95,10 @@ class Account: token = response.json()['response']['sessions'][0]['last_active_token']['jwt'] + if save_cookies: + with open(Account.COOKIES_FILE_NAME, 'wb') as f: + pickle.dump(client.cookies, f) + with open('accounts.txt', 'a') as f: f.write(f'{mail_address}:{token}\n') @@ -80,6 +107,11 @@ class Account: return token + @staticmethod + def is_cookie_enabled(client: Session) -> bool: + response = client.get('https://chat.forefront.ai/') + return 'window.startClerk' in response.text + class StreamingCompletion: @staticmethod -- cgit v1.2.3 From 871e397638eda1d22a7dc1a5dc4c0d51f6b381e1 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Tue, 2 May 2023 19:20:02 +0100 Subject: Update README.md --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 90c42c33..111d25dd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,8 @@ +Due to legal and personal problems, this Repository may have a slower developpement speed in the next 1/2 weeks, I apologise for the inconvenience. I have been dedicating a lot of effort and my little personal/educational project is at the verge of being taken down. + +

You may join our discord: discord.gg/gpt4free for further updates. gpt4free Discord

+ + gpt4free logo ## Legal Notice @@ -7,7 +12,7 @@ This repository is _not_ associated with or endorsed by providers of the APIs co Please note the following: 1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them nor is it affiliated with or endorsed by any of the providers mentioned. - +< 2. **Responsibility**: The author of this repository is _not_ responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by the third-party APIs. Users are solely responsible for their actions and any repercussions that may follow. 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. @@ -24,7 +29,6 @@ By using this repository or any code related to it, you agree to these terms. Th Just API's from some language model sites. -

Join our discord.gg/gpt4free Discord community! gpt4free Discord

# Related gpt4free projects -- cgit v1.2.3 From d0d1eba26502c1907734d6d2013d9ebedfe8e640 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Tue, 2 May 2023 19:21:18 +0100 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 111d25dd..970b6011 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Due to legal and personal problems, this Repository may have a slower developpement speed in the next 1/2 weeks, I apologise for the inconvenience. I have been dedicating a lot of effort and my little personal/educational project is at the verge of being taken down. +Due to legal and personal issues, the development speed of this Repository may slow down over the next one to two weeks. I apologize for any inconvenience this may cause. I have been putting a lot of effort into this small personal/educational project, and it is now on the verge of being taken down.

You may join our discord: discord.gg/gpt4free for further updates. gpt4free Discord

-- cgit v1.2.3 From 527a66c2af84cda495602ea77dda205e1915c544 Mon Sep 17 00:00:00 2001 From: VitalyArt Date: Tue, 2 May 2023 23:24:48 +0500 Subject: Dockerfile optimization --- .dockerignore | 9 +++++++++ Dockerfile | 27 +++++++++++++++++++-------- 2 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..db8cd761 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +# Development +.dockerignore +.git +.gitignore +.github +.idea + +# Application +venv/ diff --git a/Dockerfile b/Dockerfile index 5ed902fb..45f111c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,29 @@ -FROM python:3.10 +FROM python:3.11 as builder + +WORKDIR /usr/app +ENV PATH="/usr/app/venv/bin:$PATH" RUN apt-get update && apt-get install -y git +RUN mkdir -p /usr/app +RUN python -m venv ./venv + +COPY requirements.txt . -RUN mkdir -p /usr/src/gpt4free -WORKDIR /usr/src/gpt4free +RUN pip install -r requirements.txt # RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ # RUN pip config set global.trusted-host mirrors.aliyun.com -COPY requirements.txt /usr/src/gpt4free/ -RUN pip install --no-cache-dir -r requirements.txt -COPY . /usr/src/gpt4free -RUN cp gui/streamlit_app.py . +FROM python:3.11-alpine -EXPOSE 8501 +WORKDIR /usr/app +ENV PATH="/usr/app/venv/bin:$PATH" + +COPY --from=builder /usr/app/venv ./venv +COPY . . + +RUN cp ./gui/streamlit_app.py . CMD ["streamlit", "run", "streamlit_app.py"] + +EXPOSE 8501 -- cgit v1.2.3 From 68583f46cd8f7b8f60c69fbf178be5e6ab9e6569 Mon Sep 17 00:00:00 2001 From: ZachKLYeh <105150034+ZachKLYeh@users.noreply.github.com> Date: Wed, 3 May 2023 20:55:26 +0800 Subject: Update __init__.py add timeout argument to solve long response message timeout issue --- gpt4free/theb/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gpt4free/theb/__init__.py b/gpt4free/theb/__init__.py index e3a7f783..b162811e 100644 --- a/gpt4free/theb/__init__.py +++ b/gpt4free/theb/__init__.py @@ -40,6 +40,7 @@ class Completion: proxies=proxies, content_callback=Completion.handle_stream_response, json={'prompt': prompt, 'options': options}, + timeout=100000 ) Completion.stream_completed = True -- cgit v1.2.3 From 2ed8ddaf274be2c24f412fd59eabd8dceab3d944 Mon Sep 17 00:00:00 2001 From: kainstan Date: Thu, 4 May 2023 15:09:10 +0800 Subject: Fix numpy c dependency issue --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 45f111c6..297ebbbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM python:3.11 as builder WORKDIR /usr/app ENV PATH="/usr/app/venv/bin:$PATH" -RUN apt-get update && apt-get install -y git +#RUN apt-get update && apt-get install -y git RUN mkdir -p /usr/app RUN python -m venv ./venv @@ -14,7 +14,7 @@ RUN pip install -r requirements.txt # RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ # RUN pip config set global.trusted-host mirrors.aliyun.com -FROM python:3.11-alpine +FROM python:3.11 WORKDIR /usr/app ENV PATH="/usr/app/venv/bin:$PATH" -- cgit v1.2.3 From 1f2f16f02b856832b75f336450a40d0f4c153cf8 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Thu, 4 May 2023 12:42:37 +0100 Subject: Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 970b6011..434af30b 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ This repository is _not_ associated with or endorsed by providers of the APIs co Please note the following: 1. **Disclaimer**: The APIs, services, and trademarks mentioned in this repository belong to their respective owners. This project is _not_ claiming any right over them nor is it affiliated with or endorsed by any of the providers mentioned. -< -2. **Responsibility**: The author of this repository is _not_ responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by the third-party APIs. Users are solely responsible for their actions and any repercussions that may follow. + +2. **Responsibility**: The author of this repository is _not_ responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by the third-party APIs. Users are solely responsible for their actions and any repercussions that may follow. We strongly recommend the users to follow the TOS of the each Website. 3. **Educational Purposes Only**: This repository and its content are provided strictly for educational purposes. By using the information and code provided, users acknowledge that they are using the APIs and models at their own risk and agree to comply with any applicable laws and regulations. -- cgit v1.2.3 From d76747fbf646a971f3c4424d19955651347351b5 Mon Sep 17 00:00:00 2001 From: xiangsx <1984871009@qq.com> Date: Thu, 4 May 2023 22:16:38 +0800 Subject: gpt4free typescript version --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 434af30b..95172f98 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,13 @@ Just API's from some language model sites. Issues Pull Requests + + gpt4free-ts + Stars + Forks + Issues + Pull Requests + ChatGPT-Clone Stars -- cgit v1.2.3 From a23381833365a0dd217587b956f413c9e0a20715 Mon Sep 17 00:00:00 2001 From: Mishal <91066601+mishalhossin@users.noreply.github.com> Date: Thu, 4 May 2023 20:25:51 +0600 Subject: Update __init__.py --- gpt4free/theb/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpt4free/theb/__init__.py b/gpt4free/theb/__init__.py index b162811e..852fe17b 100644 --- a/gpt4free/theb/__init__.py +++ b/gpt4free/theb/__init__.py @@ -65,4 +65,4 @@ class Completion: @staticmethod def handle_stream_response(response): - Completion.message_queue.put(response.decode()) + Completion.message_queue.put(response.decode(errors='replace')) -- cgit v1.2.3 From c60d33c4a000ee6eae2663d08ea963d3e6295011 Mon Sep 17 00:00:00 2001 From: Hamza Date: Thu, 4 May 2023 16:05:45 +0100 Subject: Forefront fixed --- .vscode/settings.json | 4 +++ gpt4free/forefront/__init__.py | 78 +++++++++++++----------------------------- 2 files changed, 27 insertions(+), 55 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..5af1e3ee --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "editor.tabCompletion": "on", + "diffEditor.codeLens": true +} \ No newline at end of file diff --git a/gpt4free/forefront/__init__.py b/gpt4free/forefront/__init__.py index 23978501..a3912fb4 100644 --- a/gpt4free/forefront/__init__.py +++ b/gpt4free/forefront/__init__.py @@ -1,49 +1,26 @@ -import os -import pickle from json import loads +from xtempmail import Email from re import findall +from faker import Faker from time import time, sleep -from typing import Generator, Optional from uuid import uuid4 - from fake_useragent import UserAgent -from pymailtm import MailTm, Message from requests import post from tls_client import Session - from .typing import ForeFrontResponse class Account: - COOKIES_FILE_NAME = 'cookies.pickle' - @staticmethod - def login(proxy: Optional[str] = None, logging: bool = False) -> str: - if not os.path.isfile(Account.COOKIES_FILE_NAME): - return Account.create(proxy, logging) - - with open(Account.COOKIES_FILE_NAME, 'rb') as f: - cookies = pickle.load(f) - proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False - - client = Session(client_identifier='chrome110') - client.proxies = proxies - client.cookies.update(cookies) - - if Account.is_cookie_enabled(client): - response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4') - return response.json()['response']['sessions'][0]['last_active_token']['jwt'] - else: - return Account.create(proxy, logging) - - @staticmethod - def create(proxy: Optional[str] = None, logging: bool = False, save_cookies: bool = False) -> str: + def create(proxy: Optional[str] = None, logging: bool = False): proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else False + faker = Faker() + name = (faker.name().replace(' ', '_')).lower() start = time() - mail_client = MailTm().get_account() - mail_address = mail_client.address + mail_client = Email(name=name) + mail_address = mail_client.email client = Session(client_identifier='chrome110') client.proxies = proxies @@ -66,7 +43,10 @@ class Account: response = client.post( f'https://clerk.forefront.ai/v1/client/sign_ups/{trace_token}/prepare_verification?_clerk_js_version=4.38.4', - data={'strategy': 'email_link', 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify'}, + data={ + 'strategy': 'email_link', + 'redirect_url': 'https://accounts.forefront.ai/sign-up/verify' + }, ) if logging: @@ -74,31 +54,23 @@ class Account: if 'sign_up_attempt' not in response.text: return 'Failed to create account!' - - while True: - sleep(1) - new_message: Message = mail_client.wait_for_message() - if logging: - print(new_message.data['id']) - - verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', new_message.text)[0] - + verification_url = None + new_message = mail_client.get_new_message(5) + for msg in new_message: + verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', msg.text)[0] if verification_url: break - + + if verification_url is None or not verification_url: + raise RuntimeError('Error while obtaining verfication URL!') if logging: print(verification_url) - response = client.get(verification_url) response = client.get('https://clerk.forefront.ai/v1/client?_clerk_js_version=4.38.4') token = response.json()['response']['sessions'][0]['last_active_token']['jwt'] - if save_cookies: - with open(Account.COOKIES_FILE_NAME, 'wb') as f: - pickle.dump(client.cookies, f) - with open('accounts.txt', 'a') as f: f.write(f'{mail_address}:{token}\n') @@ -107,11 +79,6 @@ class Account: return token - @staticmethod - def is_cookie_enabled(client: Session) -> bool: - response = client.get('https://chat.forefront.ai/') - return 'window.startClerk' in response.text - class StreamingCompletion: @staticmethod @@ -122,14 +89,14 @@ class StreamingCompletion: action_type='new', default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default model='gpt-4', - proxy=None, + proxy=None ) -> Generator[ForeFrontResponse, None, None]: if not token: raise Exception('Token is required!') if not chat_id: chat_id = str(uuid4()) - proxies = {'http': 'http://' + proxy, 'https': 'http://' + proxy} if proxy else None + proxies = { 'http': 'http://' + proxy, 'https': 'http://' + proxy } if proxy else None headers = { 'authority': 'chat-server.tenant-forefront-default.knative.chi.coreweave.com', @@ -197,7 +164,7 @@ class Completion: action_type='new', default_persona='607e41fe-95be-497e-8e97-010a59b2e2c0', # default model='gpt-4', - proxy=None, + proxy=None ) -> ForeFrontResponse: text = '' final_response = None @@ -208,7 +175,7 @@ class Completion: action_type=action_type, default_persona=default_persona, model=model, - proxy=proxy, + proxy=proxy ): if response: final_response = response @@ -220,3 +187,4 @@ class Completion: raise Exception('Unable to get the response, Please try again') return final_response + \ No newline at end of file -- cgit v1.2.3 From 64ab4770dd84088d5465edd3a37b69529fa8d372 Mon Sep 17 00:00:00 2001 From: Hamza Date: Thu, 4 May 2023 16:30:34 +0100 Subject: Fixed imports --- gpt4free/forefront/__init__.py | 1 + gpt4free/test.py | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 gpt4free/test.py diff --git a/gpt4free/forefront/__init__.py b/gpt4free/forefront/__init__.py index a3912fb4..dbf1730b 100644 --- a/gpt4free/forefront/__init__.py +++ b/gpt4free/forefront/__init__.py @@ -1,6 +1,7 @@ from json import loads from xtempmail import Email from re import findall +from typing import Optional, Generator from faker import Faker from time import time, sleep from uuid import uuid4 diff --git a/gpt4free/test.py b/gpt4free/test.py new file mode 100644 index 00000000..b2516748 --- /dev/null +++ b/gpt4free/test.py @@ -0,0 +1,4 @@ +import forefront +token = forefront.Account.create() +response = forefront.Completion.create(token=token, prompt='Hello!') +print(response) \ No newline at end of file -- cgit v1.2.3 From 82a3a039290cded2cc1282647f78ebd91d475b46 Mon Sep 17 00:00:00 2001 From: Rory Durrant Date: Thu, 4 May 2023 17:14:18 +0100 Subject: =?UTF-8?q?=F0=9F=94=A8=20update(theb/=5F=5Finit=5F=5F.py):=20add?= =?UTF-8?q?=20get=5Fresponse=20method=20to=20Completion=20class?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The get_response method was added to the Completion class to allow for easier retrieval of the response from the GPT-3 API. This method takes in a prompt and an optional proxy and returns the response as a string. The method uses the create method to generate a generator object and then iterates over it to append each message to a list. Finally, the list is joined into a single string and returned. This allows for non stream usage of theb. --- gpt4free/theb/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gpt4free/theb/__init__.py b/gpt4free/theb/__init__.py index b162811e..4513ea6e 100644 --- a/gpt4free/theb/__init__.py +++ b/gpt4free/theb/__init__.py @@ -46,7 +46,6 @@ class Completion: Completion.stream_completed = True @staticmethod - def create(prompt: str, proxy: Optional[str] = None) -> Generator[str, None, None]: Completion.stream_completed = False @@ -66,3 +65,10 @@ class Completion: @staticmethod def handle_stream_response(response): Completion.message_queue.put(response.decode()) + + @staticmethod + def get_response(prompt: str, proxy: Optional[str] = None) -> str: + response_list = [] + for message in Completion.create(prompt, proxy): + response_list.append(message) + return ''.join(response_list) -- cgit v1.2.3 From 824d7259d030f7c5d35004729eee68a0e4359304 Mon Sep 17 00:00:00 2001 From: "t.me/xtekky" <98614666+xtekky@users.noreply.github.com> Date: Thu, 4 May 2023 17:29:09 +0100 Subject: updates --- gpt4free/italygpt/README.md | 18 ---------- gpt4free/italygpt/__init__.py | 28 --------------- gpt4free/quora/__init__.py | 4 +-- pyproject.toml | 2 +- unfinished/test.py | 8 ----- unfinished/vercelai/__init__.py | 41 ---------------------- unfinished/vercelai/test.js | 33 ------------------ unfinished/vercelai/test.py | 67 ------------------------------------ unfinished/vercelai/token.py | 0 unfinished/vercelai/vercelai_test.py | 5 --- 10 files changed, 3 insertions(+), 203 deletions(-) delete mode 100644 gpt4free/italygpt/README.md delete mode 100644 gpt4free/italygpt/__init__.py delete mode 100644 unfinished/test.py delete mode 100644 unfinished/vercelai/__init__.py delete mode 100644 unfinished/vercelai/test.js delete mode 100644 unfinished/vercelai/test.py delete mode 100644 unfinished/vercelai/token.py delete mode 100644 unfinished/vercelai/vercelai_test.py diff --git a/gpt4free/italygpt/README.md b/gpt4free/italygpt/README.md deleted file mode 100644 index 984eff3a..00000000 --- a/gpt4free/italygpt/README.md +++ /dev/null @@ -1,18 +0,0 @@ -### Example: `italygpt` - -```python -# create an instance -from gpt4free import italygpt -italygpt = italygpt.Completion() - -# initialize api -italygpt.init() - -# get an answer -italygpt.create(prompt="What is the meaning of life?") -print(italygpt.answer) # html formatted - -# keep the old conversation -italygpt.create(prompt="Are you a human?", messages=italygpt.messages) -print(italygpt.answer) -``` \ No newline at end of file diff --git a/gpt4free/italygpt/__init__.py b/gpt4free/italygpt/__init__.py deleted file mode 100644 index 27a965f1..00000000 --- a/gpt4free/italygpt/__init__.py +++ /dev/null @@ -1,28 +0,0 @@ -import requests, time, ast, json -from bs4 import BeautifulSoup -from hashlib import sha256 - -class Completion: - # answer is returned with html formatting - next_id = None - messages = [] - answer = None - - def init(self): - r = requests.get("https://italygpt.it") - soup = BeautifulSoup(r.text, "html.parser") - self.next_id = soup.find("input", {"name": "next_id"})["value"] - - def create(self, prompt: str, messages: list = []): - try: - r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).json() - except: - r = requests.get("https://italygpt.it/question", params={"hash": sha256(self.next_id.encode()).hexdigest(), "prompt": prompt, "raw_messages": json.dumps(messages)}).text - if "too many requests" in r.lower(): - # rate limit is 17 requests per 1 minute - time.sleep(20) - return self.create(prompt, messages) - self.next_id = r["next_id"] - self.messages = ast.literal_eval(r["raw_messages"]) - self.answer = r["response"] - return self \ No newline at end of file diff --git a/gpt4free/quora/__init__.py b/gpt4free/quora/__init__.py index bc17ea5d..5d9e80c1 100644 --- a/gpt4free/quora/__init__.py +++ b/gpt4free/quora/__init__.py @@ -104,8 +104,8 @@ class Model: def create( token: str, model: str = 'gpt-3.5-turbo', # claude-instant - system_prompt: str = 'You are ChatGPT a large language model developed by Openai. Answer as consisely as possible', - description: str = 'gpt-3.5 language model from openai, skidded by poe.com', + system_prompt: str = 'You are ChatGPT a large language model. Answer as consisely as possible', + description: str = 'gpt-3.5 language model', handle: str = None, ) -> ModelResponse: if not handle: diff --git a/pyproject.toml b/pyproject.toml index 83df5dc5..37ec92d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "openai-rev" +name = "gpt4free" version = "0.1.0" description = "" authors = [] diff --git a/unfinished/test.py b/unfinished/test.py deleted file mode 100644 index a5f038c5..00000000 --- a/unfinished/test.py +++ /dev/null @@ -1,8 +0,0 @@ -# asyncio.run(gptbz.test()) - -import requests - -image = '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' - -response = requests.get('https://ocr.holey.cc/ncku?base64_str=%s' % image) # .split('base64,')[1]) -print(response.content) diff --git a/unfinished/vercelai/__init__.py b/unfinished/vercelai/__init__.py deleted file mode 100644 index 1dcb5b39..00000000 --- a/unfinished/vercelai/__init__.py +++ /dev/null @@ -1,41 +0,0 @@ -import requests - -class Completion: - def create(prompt: str, - model: str = 'openai:gpt-3.5-turbo', - temperature: float = 0.7, - max_tokens: int = 200, - top_p: float = 1, - top_k: int = 1, - frequency_penalty: float = 1, - presence_penalty: float = 1, - stopSequences: list = []): - - token = requests.get('https://play.vercel.ai/openai.jpeg', headers={ - 'authority': 'play.vercel.ai', - 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3', - 'referer': 'https://play.vercel.ai/', - 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36'}).text.replace('=','') - - print(token) - - headers = { - 'authority': 'play.vercel.ai', - 'custom-encoding': token, - 'origin': 'https://play.vercel.ai', - 'referer': 'https://play.vercel.ai/', - 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36' - } - - for chunk in requests.post('https://play.vercel.ai/api/generate', headers=headers, stream=True, json={ - 'prompt': prompt, - 'model': model, - 'temperature': temperature, - 'maxTokens': max_tokens, - 'topK': top_p, - 'topP': top_k, - 'frequencyPenalty': frequency_penalty, - 'presencePenalty': presence_penalty, - 'stopSequences': stopSequences}).iter_lines(): - - yield (chunk) \ No newline at end of file diff --git a/unfinished/vercelai/test.js b/unfinished/vercelai/test.js deleted file mode 100644 index 0f822cfd..00000000 --- a/unfinished/vercelai/test.js +++ /dev/null @@ -1,33 +0,0 @@ -(async () => { - - let response = await fetch("https://play.vercel.ai/openai.jpeg", { - "headers": { - "accept": "*/*", - "accept-language": "en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3", - "sec-ch-ua": "\"Chromium\";v=\"112\", \"Google Chrome\";v=\"112\", \"Not:A-Brand\";v=\"99\"", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "\"macOS\"", - "sec-fetch-dest": "empty", - "sec-fetch-mode": "cors", - "sec-fetch-site": "same-origin" - }, - "referrer": "https://play.vercel.ai/", - "referrerPolicy": "strict-origin-when-cross-origin", - "body": null, - "method": "GET", - "mode": "cors", - "credentials": "omit" - }); - - - let data = JSON.parse(atob(await response.text())) - let ret = eval("(".concat(data.c, ")(data.a)")); - - botPreventionToken = btoa(JSON.stringify({ - r: ret, - t: data.t - })) - - console.log(botPreventionToken); - -})() \ No newline at end of file diff --git a/unfinished/vercelai/test.py b/unfinished/vercelai/test.py deleted file mode 100644 index 318e71c3..00000000 --- a/unfinished/vercelai/test.py +++ /dev/null @@ -1,67 +0,0 @@ -import requests -from base64 import b64decode, b64encode -from json import loads -from json import dumps - -headers = { - 'Accept': '*/*', - 'Accept-Language': 'en-GB,en-US;q=0.9,en;q=0.8', - 'Connection': 'keep-alive', - 'Referer': 'https://play.vercel.ai/', - 'Sec-Fetch-Dest': 'empty', - 'Sec-Fetch-Mode': 'cors', - 'Sec-Fetch-Site': 'same-origin', - 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36', - 'sec-ch-ua': '"Chromium";v="110", "Google Chrome";v="110", "Not:A-Brand";v="99"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', -} - -response = requests.get('https://play.vercel.ai/openai.jpeg', headers=headers) - -token_data = loads(b64decode(response.text)) -print(token_data) - -raw_token = { - 'a': token_data['a'] * .1 * .2, - 't': token_data['t'] -} - -print(raw_token) - -new_token = b64encode(dumps(raw_token, separators=(',', ':')).encode()).decode() -print(new_token) - -import requests - -headers = { - 'authority': 'play.vercel.ai', - 'accept': '*/*', - 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3', - 'content-type': 'application/json', - 'custom-encoding': new_token, - 'origin': 'https://play.vercel.ai', - 'referer': 'https://play.vercel.ai/', - 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', - 'sec-fetch-dest': 'empty', - 'sec-fetch-mode': 'cors', - 'sec-fetch-site': 'same-origin', - 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36', -} - -json_data = { - 'prompt': 'hello\n', - 'model': 'openai:gpt-3.5-turbo', - 'temperature': 0.7, - 'maxTokens': 200, - 'topK': 1, - 'topP': 1, - 'frequencyPenalty': 1, - 'presencePenalty': 1, - 'stopSequences': [], -} - -response = requests.post('https://play.vercel.ai/api/generate', headers=headers, json=json_data) -print(response.text) \ No newline at end of file diff --git a/unfinished/vercelai/token.py b/unfinished/vercelai/token.py deleted file mode 100644 index e69de29b..00000000 diff --git a/unfinished/vercelai/vercelai_test.py b/unfinished/vercelai/vercelai_test.py deleted file mode 100644 index 24cbe0bc..00000000 --- a/unfinished/vercelai/vercelai_test.py +++ /dev/null @@ -1,5 +0,0 @@ -import vercelai - -for token in vercelai.Completion.create('summarize the gnu gpl 1.0'): - print(token, end='', flush=True) - -- cgit v1.2.3