From 76c7be3172f880932926a59e704e14a5f1f15067 Mon Sep 17 00:00:00 2001 From: abc <98614666+xtekky@users.noreply.github.com> Date: Sun, 16 Jul 2023 19:27:01 +0100 Subject: minor fixes ails, chatgptai ... --- README.md | 4 ++-- g4f/Provider/Providers/Ails.py | 2 +- g4f/Provider/Providers/BingHuan.py | 1 - g4f/Provider/Providers/ChatgptAi.py | 3 +-- g4f/Provider/__init__.py | 3 ++- testing/test.py | 13 +++++++++++++ 6 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 testing/test.py diff --git a/README.md b/README.md index bae7c896..0aac7d2d 100644 --- a/README.md +++ b/README.md @@ -158,10 +158,10 @@ for token in chat_completion: | [chat9.yqcloud.top](https://chat9.yqcloud.top/) | `g4f.Provider.Yqcloud` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [theb.ai](https://theb.ai) | `g4f.Provider.Theb` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [play.vercel.ai](https://play.vercel.ai) | `g4f.Provider.Vercel` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | -| [forefront.com](https://forefront.com) | `g4f.Provider.Forefront` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | +| [forefront.com](https://forefront.com) | `g4f.Provider.Forefront` | ✔️ | ❌ | ✔️ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [deepai.org](https://deepai.org) | `g4f.Provider.DeepAi` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chat.getgpt.world](https://chat.getgpt.world/) | `g4f.Provider.GetGpt` | ✔️ | ❌ | ✔️ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | -| [chatgptlogin.ac](https://chatgptlogin.ac) | `g4f.Provider.ChatgptLogin` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | +| [chatgptlogin.ac](https://chatgptlogin.ac) | `g4f.Provider.ChatgptLogin` | ✔️ | ❌ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ | | [chat-gpt.org](https://chat-gpt.org/chat) | `g4f.Provider.Aichat` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [chat.acytoo.com](https://chat.acytoo.com) | `g4f.Provider.Acytoo` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | | [aitianhu.com](https://aitianhu.com) | `g4f.Provider.AItianhu` | ✔️ | ❌ | ❌ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ | diff --git a/g4f/Provider/Providers/Ails.py b/g4f/Provider/Providers/Ails.py index 1a14b2e9..54d9e066 100644 --- a/g4f/Provider/Providers/Ails.py +++ b/g4f/Provider/Providers/Ails.py @@ -45,7 +45,7 @@ def _create_completion(model: str, messages: list, temperature: float = 0.6, str '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', 'authorization': 'Bearer free', 'client-id': str(uuid.uuid4()), - 'client-v': '0.1.217', + 'client-v': '0.1.249', 'content-type': 'application/json', 'origin': 'https://ai.ls', 'referer': 'https://ai.ls/', diff --git a/g4f/Provider/Providers/BingHuan.py b/g4f/Provider/Providers/BingHuan.py index 7344a342..9703e0f1 100644 --- a/g4f/Provider/Providers/BingHuan.py +++ b/g4f/Provider/Providers/BingHuan.py @@ -19,7 +19,6 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs): for line in iter(p.stdout.readline, b''): yield line.decode('cp1252') - params = f'g4f.Providers.{os.path.basename(__file__)[:-3]} supports: ' + \ diff --git a/g4f/Provider/Providers/ChatgptAi.py b/g4f/Provider/Providers/ChatgptAi.py index 00d4cf6f..929ec216 100644 --- a/g4f/Provider/Providers/ChatgptAi.py +++ b/g4f/Provider/Providers/ChatgptAi.py @@ -13,8 +13,7 @@ def _create_completion(model: str, messages: list, stream: bool, **kwargs): chat += '%s: %s\n' % (message['role'], message['content']) chat += 'assistant: ' - response = requests.get('https://chatgpt.ai/gpt-4/') - + response = requests.get('https://chatgpt.ai/') nonce, post_id, _, bot_id = re.findall(r'data-nonce="(.*)"\n data-post-id="(.*)"\n data-url="(.*)"\n data-bot-id="(.*)"\n data-width', response.text)[0] headers = { diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py index e8fbf617..8488cec1 100644 --- a/g4f/Provider/__init__.py +++ b/g4f/Provider/__init__.py @@ -21,7 +21,8 @@ from .Providers import ( DFEHub, AiService, BingHuan, - Wewordle + Wewordle, + ChatgptAi, ) Palm = Bard diff --git a/testing/test.py b/testing/test.py new file mode 100644 index 00000000..727b92ac --- /dev/null +++ b/testing/test.py @@ -0,0 +1,13 @@ +import g4f + +# Set with provider +stream = False +response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.ChatgptLogin, messages=[ + {"role": "user", "content": "hello"}], stream=stream) + +if stream: + for message in response: + print(message) +else: + print(response) + -- cgit v1.2.3