summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/FUNDING.yml4
-rw-r--r--README.md80
-rw-r--r--g4f/Provider/AiAsk.py2
-rw-r--r--g4f/Provider/Aichat.py4
-rw-r--r--g4f/Provider/Chatgpt4Online.py48
-rw-r--r--g4f/Provider/FreeGpt.py2
-rw-r--r--g4f/Provider/__init__.py5
-rw-r--r--g4f/Provider/deprecated/Acytoo.py (renamed from g4f/Provider/Acytoo.py)4
-rw-r--r--g4f/Provider/deprecated/Aibn.py (renamed from g4f/Provider/Aibn.py)6
-rw-r--r--g4f/Provider/deprecated/Ails.py (renamed from g4f/Provider/Ails.py)4
-rw-r--r--g4f/Provider/deprecated/ChatgptDuo.py (renamed from g4f/Provider/ChatgptDuo.py)4
-rw-r--r--g4f/Provider/deprecated/Cromicle.py (renamed from g4f/Provider/Cromicle.py)6
-rw-r--r--g4f/Provider/deprecated/__init__.py7
-rw-r--r--g4f/Provider/needs_auth/OpenaiChat.py1
-rw-r--r--g4f/__init__.py2
-rw-r--r--g4f/models.py4
16 files changed, 104 insertions, 79 deletions
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 8b137891..e0b12bae 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1 +1,3 @@
-
+ko_fi: xtekky
+github: [xtekky]
+patreon: xtekky
diff --git a/README.md b/README.md
index d80e49a8..058a605b 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,12 @@
-new discord server: [discord.gg/XfybzPXPH5](https://discord.gg/XfybzPXPH5)
-
-<div id="top"></div>
-
![248433934-7886223b-c1d1-4260-82aa-da5741f303bb](https://github.com/xtekky/gpt4free/assets/98614666/ea012c87-76e0-496a-8ac4-e2de090cc6c9)
+<a href='https://ko-fi.com/xtekky' target='_blank'><img height='35' style='border:0px;height:46px;' src='https://az743702.vo.msecnd.net/cdn/kofi3.png?v=0' border='0' alt='Buy Me a Coffee at ko-fi.com' />
-> **Note**
-> By using this repository or any code related to it, you agree to the [legal notice](https://github.com/xtekky/gpt4free/blob/main/LEGAL_NOTICE.md). The author is not responsible for any copies, forks, re-uploads made by other users, or anything else related to GPT4Free. This is the author's only account and repository. To prevent impersonation or irresponsible actions, please comply with the GNU GPL license this Repository uses.
+<div id="top"></div>
+
+> By using this repository or any code related to it, you agree to the [legal notice](LEGAL_NOTICE.md). The author is not responsible for any copies, forks, re-uploads made by other users, or anything else related to GPT4Free. This is the author's only account and repository. To prevent impersonation or irresponsible actions, please comply with the GNU GPL license this Repository uses.
-> **Note**
+> [!Note]
> Latest pypi version: [`0.1.8.2`](https://pypi.org/project/g4f/0.1.8.2)
```sh
pip install -U g4f
@@ -17,28 +15,43 @@ pip install -U g4f
## πŸ†• What's New
- Join our Telegram Channel: [t.me/g4f_channel](https://telegram.me/g4f_channel)
+- Join our Discord Group: [discord.gg/XfybzPXPH5](https://discord.gg/XfybzPXPH5)
- Explore the g4f Documentation (unfinished): [g4f.mintlify.app](https://g4f.mintlify.app) | Contribute to the docs via: [github.com/xtekky/gpt4free-docs](https://github.com/xtekky/gpt4free-docs)
## πŸ“š Table of Contents
-- [Getting Started](#getting-started)
- - [Prerequisites](#prerequisites)
- - [Setting up the project](#setting-up-the-project)
- - [Install using PyPi](#install-using-pypi)
- - [Install using docker](#setting-up-with-docker)
-- [Usage](#usage)
+- [πŸ†• What's New](#-whats-new)
+- [πŸ“š Table of Contents](#-table-of-contents)
+- [πŸ› οΈ Getting Started](#️-getting-started)
+ - [Prerequisites:](#prerequisites)
+ - [Setting up the project:](#setting-up-the-project)
+ - [Install using pypi](#install-using-pypi)
+ - [or](#or)
+ - [Setting up with Docker:](#setting-up-with-docker)
+- [πŸ’‘ Usage](#-usage)
- [The `g4f` Package](#the-g4f-package)
- - [interference openai-proxy api (use with openai python package)](#interference-openai-proxy-api-use-with-openai-python-package)
-- [Providers](#models)
- - [gpt-3.5](#gpt-35)
- - [gpt-4](#gpt-4)
- - [Other Models](#other-models)
-- [Related gpt4free projects](#related-gpt4free-projects)
-- [Contribute](#contribute)
-- [Contributors](#contributors)
-- [Copyright](#copyright)
-- [Star History](#star-history)
-- [License](#license)
+ - [ChatCompletion](#chatcompletion)
+ - [Completion](#completion)
+ - [Providers](#providers)
+ - [Cookies Required](#cookies-required)
+ - [Async Support](#async-support)
+ - [Proxy and Timeout Support](#proxy-and-timeout-support)
+ - [Interference openai-proxy API (Use with openai python package)](#interference-openai-proxy-api-use-with-openai-python-package)
+ - [Run interference API from PyPi package](#run-interference-api-from-pypi-package)
+ - [Run interference API from repo](#run-interference-api-from-repo)
+- [πŸš€ Providers and Models](#-providers-and-models)
+ - [GPT-4](#gpt-4)
+ - [GPT-3.5](#gpt-35)
+ - [Other](#other)
+ - [Models](#models)
+- [πŸ”— Related GPT4Free Projects](#-related-gpt4free-projects)
+- [🀝 Contribute](#-contribute)
+ - [Create Provider with AI Tool](#create-provider-with-ai-tool)
+ - [Create Provider](#create-provider)
+- [πŸ™Œ Contributors](#-contributors)
+- [©️ Copyright](#️-copyright)
+- [⭐ Star History](#-star-history)
+- [πŸ“„ License](#-license)
## πŸ› οΈ Getting Started
@@ -123,13 +136,13 @@ cd gpt4free
4. Build the Docker image:
```bash
-docker compose build
+docker-compose build
```
5. Start the service using Docker Compose:
```bash
-docker compose up
+docker-compose up
```
Your server will now be running at `http://localhost:1337`. You can interact with the API or run your tests as you would normally.
@@ -137,11 +150,11 @@ Your server will now be running at `http://localhost:1337`. You can interact wit
To stop the Docker containers, simply run:
```bash
-docker compose down
+docker-compose down
```
-> **Note**
-> When using Docker, any changes you make to your local files will be reflected in the Docker container thanks to the volume mapping in the `docker-compose.yml` file. If you add or remove dependencies, however, you'll need to rebuild the Docker image using `docker compose build`.
+> [!Note]
+> When using Docker, any changes you make to your local files will be reflected in the Docker container thanks to the volume mapping in the `docker-compose.yml` file. If you add or remove dependencies, however, you'll need to rebuild the Docker image using `docker-compose build`.
## πŸ’‘ Usage
@@ -531,6 +544,13 @@ if __name__ == "__main__":
<td><a href="https://github.com/HexyeDEV/Telegram-Chatbot-Gpt4Free/issues"><img alt="Issues" src="https://img.shields.io/github/issues/HexyeDEV/Telegram-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
<td><a href="https://github.com/HexyeDEV/Telegram-Chatbot-Gpt4Free/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/HexyeDEV/Telegram-Chatbot-Gpt4Free?style=flat-square&labelColor=343b41"/></a></td>
</tr>
+ <tr>
+ <td><a href="https://github.com/Lin-jun-xiang/chatgpt-line-bot"><b>ChatGpt Line Bot</b></a></td>
+ <td><a href="https://github.com/Lin-jun-xiang/chatgpt-line-bot/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/Lin-jun-xiang/chatgpt-line-bot?style=flat-square&labelColor=343b41"/></a></td>
+ <td><a href="https://github.com/Lin-jun-xiang/chatgpt-line-bot/network/members"><img alt="Forks" src="https://img.shields.io/github/forks/Lin-jun-xiang/chatgpt-line-bot?style=flat-square&labelColor=343b41"/></a></td>
+ <td><a href="https://github.com/Lin-jun-xiang/chatgpt-line-bot/issues"><img alt="Issues" src="https://img.shields.io/github/issues/Lin-jun-xiang/chatgpt-line-bot?style=flat-square&labelColor=343b41"/></a></td>
+ <td><a href="https://github.com/Lin-jun-xiang/chatgpt-line-bot/pulls"><img alt="Pull Requests" src="https://img.shields.io/github/issues-pr/Lin-jun-xiang/chatgpt-line-bot?style=flat-square&labelColor=343b41"/></a></td>
+ </tr>
<tr>
<td><a href="https://github.com/Lin-jun-xiang/action-translate-readme"><b>Action Translate Readme</b></a></td>
<td><a href="https://github.com/Lin-jun-xiang/action-translate-readme/stargazers"><img alt="Stars" src="https://img.shields.io/github/stars/Lin-jun-xiang/action-translate-readme?style=flat-square&labelColor=343b41"/></a></td>
@@ -557,7 +577,7 @@ Call in your terminal the "create_provider" script:
python etc/tool/create_provider.py
```
1. Enter your name for the new provider.
-2. Copy and paste the `URL` command from your browser developer tools.
+2. Copy and paste the `cURL` command from your browser developer tools.
3. Let the AI ​​create the provider for you.
4. Customize the provider according to your needs.
diff --git a/g4f/Provider/AiAsk.py b/g4f/Provider/AiAsk.py
index ac123fc9..094ef076 100644
--- a/g4f/Provider/AiAsk.py
+++ b/g4f/Provider/AiAsk.py
@@ -8,7 +8,7 @@ class AiAsk(AsyncGeneratorProvider):
url = "https://e.aiask.me"
supports_message_history = True
supports_gpt_35_turbo = True
- working = True
+ working = False
@classmethod
async def create_async_generator(
diff --git a/g4f/Provider/Aichat.py b/g4f/Provider/Aichat.py
index 77ae4429..41ea9a96 100644
--- a/g4f/Provider/Aichat.py
+++ b/g4f/Provider/Aichat.py
@@ -8,8 +8,8 @@ from .helper import get_cookies
from ..requests import StreamSession
class Aichat(AsyncProvider):
- url = "https://chat-gpt.org/chat"
- working = True
+ url = "https://chat-gpt.org/chat"
+ working = False
supports_gpt_35_turbo = True
@staticmethod
diff --git a/g4f/Provider/Chatgpt4Online.py b/g4f/Provider/Chatgpt4Online.py
index d7509639..57ab9482 100644
--- a/g4f/Provider/Chatgpt4Online.py
+++ b/g4f/Provider/Chatgpt4Online.py
@@ -1,42 +1,44 @@
from __future__ import annotations
-import json
+import re
from aiohttp import ClientSession
-from ..typing import AsyncResult, Messages
-from .base_provider import AsyncGeneratorProvider
+from ..typing import Messages
+from .base_provider import AsyncProvider
+from .helper import format_prompt
-
-class Chatgpt4Online(AsyncGeneratorProvider):
+class Chatgpt4Online(AsyncProvider):
url = "https://chatgpt4online.org"
supports_message_history = True
supports_gpt_35_turbo = True
- working = False
+ working = True
+ _wpnonce = None
@classmethod
- async def create_async_generator(
+ async def create_async(
cls,
model: str,
messages: Messages,
proxy: str = None,
**kwargs
- ) -> AsyncResult:
+ ) -> str:
async with ClientSession() as session:
+ if not cls._wpnonce:
+ async with session.get(f"{cls.url}/", proxy=proxy) as response:
+ response.raise_for_status()
+ response = await response.text()
+ if result := re.search(r'data-nonce="(.*?)"', response):
+ cls._wpnonce = result.group(1)
+ else:
+ raise RuntimeError("No nonce found")
data = {
- "botId": "default",
- "customId": None,
- "session": "N/A",
- "chatId": "",
- "contextId": 58,
- "messages": messages,
- "newMessage": messages[-1]["content"],
- "stream": True
+ "_wpnonce": cls._wpnonce,
+ "post_id": 58,
+ "url": "https://chatgpt4online.org",
+ "action": "wpaicg_chat_shortcode_message",
+ "message": format_prompt(messages),
+ "bot_id": 3405
}
-
- async with session.post(f"{cls.url}/wp-json/mwai-ui/v1/chats/submit", json=data, proxy=proxy) as response:
+ async with session.post(f"{cls.url}/rizq", data=data, proxy=proxy) as response:
response.raise_for_status()
- async for line in response.content:
- if line.startswith(b"data: "):
- line = json.loads(line[6:])
- if line["type"] == "live":
- yield line["data"] \ No newline at end of file
+ return (await response.json())["data"] \ No newline at end of file
diff --git a/g4f/Provider/FreeGpt.py b/g4f/Provider/FreeGpt.py
index a3a26fe6..22c6c9aa 100644
--- a/g4f/Provider/FreeGpt.py
+++ b/g4f/Provider/FreeGpt.py
@@ -12,7 +12,7 @@ domains = [
class FreeGpt(AsyncGeneratorProvider):
url = "https://freegpts1.aifree.site/"
- working = True
+ working = False
supports_message_history = True
supports_gpt_35_turbo = True
diff --git a/g4f/Provider/__init__.py b/g4f/Provider/__init__.py
index a72db45c..70ad9de7 100644
--- a/g4f/Provider/__init__.py
+++ b/g4f/Provider/__init__.py
@@ -1,9 +1,6 @@
from __future__ import annotations
-from .Acytoo import Acytoo
from .AiAsk import AiAsk
-from .Aibn import Aibn
from .Aichat import Aichat
-from .Ails import Ails
from .AItianhu import AItianhu
from .AItianhuSpace import AItianhuSpace
from .Berlin import Berlin
@@ -13,11 +10,9 @@ from .ChatForAi import ChatForAi
from .Chatgpt4Online import Chatgpt4Online
from .ChatgptAi import ChatgptAi
from .ChatgptDemo import ChatgptDemo
-from .ChatgptDuo import ChatgptDuo
from .ChatgptFree import ChatgptFree
from .ChatgptLogin import ChatgptLogin
from .ChatgptX import ChatgptX
-from .Cromicle import Cromicle
from .DeepInfra import DeepInfra
from .FakeGpt import FakeGpt
from .FreeGpt import FreeGpt
diff --git a/g4f/Provider/Acytoo.py b/g4f/Provider/deprecated/Acytoo.py
index 4dee176a..0379fdd6 100644
--- a/g4f/Provider/Acytoo.py
+++ b/g4f/Provider/deprecated/Acytoo.py
@@ -2,8 +2,8 @@ from __future__ import annotations
from aiohttp import ClientSession
-from ..typing import AsyncResult, Messages
-from .base_provider import AsyncGeneratorProvider
+from ...typing import AsyncResult, Messages
+from ..base_provider import AsyncGeneratorProvider
class Acytoo(AsyncGeneratorProvider):
diff --git a/g4f/Provider/Aibn.py b/g4f/Provider/deprecated/Aibn.py
index 1f81a61e..60cef1e4 100644
--- a/g4f/Provider/Aibn.py
+++ b/g4f/Provider/deprecated/Aibn.py
@@ -3,9 +3,9 @@ from __future__ import annotations
import time
import hashlib
-from ..typing import AsyncResult, Messages
-from ..requests import StreamSession
-from .base_provider import AsyncGeneratorProvider
+from ...typing import AsyncResult, Messages
+from ...requests import StreamSession
+from ..base_provider import AsyncGeneratorProvider
class Aibn(AsyncGeneratorProvider):
diff --git a/g4f/Provider/Ails.py b/g4f/Provider/deprecated/Ails.py
index 58010756..93c63a69 100644
--- a/g4f/Provider/Ails.py
+++ b/g4f/Provider/deprecated/Ails.py
@@ -7,8 +7,8 @@ import json
from datetime import datetime
from aiohttp import ClientSession
-from ..typing import SHA256, AsyncResult, Messages
-from .base_provider import AsyncGeneratorProvider
+from ...typing import SHA256, AsyncResult, Messages
+from ..base_provider import AsyncGeneratorProvider
class Ails(AsyncGeneratorProvider):
diff --git a/g4f/Provider/ChatgptDuo.py b/g4f/Provider/deprecated/ChatgptDuo.py
index fef3f856..c77c6a1c 100644
--- a/g4f/Provider/ChatgptDuo.py
+++ b/g4f/Provider/deprecated/ChatgptDuo.py
@@ -1,8 +1,8 @@
from __future__ import annotations
-from ..typing import Messages
+from ...typing import Messages
from curl_cffi.requests import AsyncSession
-from .base_provider import AsyncProvider, format_prompt
+from ..base_provider import AsyncProvider, format_prompt
class ChatgptDuo(AsyncProvider):
diff --git a/g4f/Provider/Cromicle.py b/g4f/Provider/deprecated/Cromicle.py
index 8deb79c1..9f986cb5 100644
--- a/g4f/Provider/Cromicle.py
+++ b/g4f/Provider/deprecated/Cromicle.py
@@ -2,10 +2,10 @@ from __future__ import annotations
from aiohttp import ClientSession
from hashlib import sha256
-from ..typing import AsyncResult, Messages, Dict
+from ...typing import AsyncResult, Messages, Dict
-from .base_provider import AsyncGeneratorProvider
-from .helper import format_prompt
+from ..base_provider import AsyncGeneratorProvider
+from ..helper import format_prompt
class Cromicle(AsyncGeneratorProvider):
diff --git a/g4f/Provider/deprecated/__init__.py b/g4f/Provider/deprecated/__init__.py
index f8e35b37..ca5ac83e 100644
--- a/g4f/Provider/deprecated/__init__.py
+++ b/g4f/Provider/deprecated/__init__.py
@@ -13,4 +13,9 @@ from .FastGpt import FastGpt
from .Aivvm import Aivvm
from .Vitalentum import Vitalentum
from .H2o import H2o
-from .Myshell import Myshell \ No newline at end of file
+from .Myshell import Myshell
+from .Acytoo import Acytoo
+from .Aibn import Aibn
+from .Ails import Ails
+from .ChatgptDuo import ChatgptDuo
+from .Cromicle import Cromicle \ No newline at end of file
diff --git a/g4f/Provider/needs_auth/OpenaiChat.py b/g4f/Provider/needs_auth/OpenaiChat.py
index c0e29dfb..eccf2bd7 100644
--- a/g4f/Provider/needs_auth/OpenaiChat.py
+++ b/g4f/Provider/needs_auth/OpenaiChat.py
@@ -53,6 +53,7 @@ class OpenaiChat(AsyncGeneratorProvider):
"history_and_training_disabled": not auto_continue,
}
conversation_id = None
+ end_turn = False
while not end_turn:
if not auto_continue:
end_turn = True
diff --git a/g4f/__init__.py b/g4f/__init__.py
index c712829c..fd8aa306 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -15,6 +15,8 @@ def check_pypi_version() -> None:
if version != latest_version:
print(f'New pypi version: {latest_version} (current: {version}) | pip install -U g4f')
+ return False
+ return True
except Exception as e:
print(f'Failed to check g4f pypi version: {e}')
diff --git a/g4f/models.py b/g4f/models.py
index 0ce7b886..cdca0e3f 100644
--- a/g4f/models.py
+++ b/g4f/models.py
@@ -15,10 +15,8 @@ from .Provider import (
Berlin,
Llama2,
Vercel,
- Aichat,
GPTalk,
Koala,
- AiAsk,
GptGo,
Phind,
Bard,
@@ -42,7 +40,7 @@ default = Model(
base_provider = "",
best_provider = RetryProvider([
Bing, # Not fully GPT 3 or 4
- AiAsk, Aichat, ChatgptAi, FreeGpt, GptGo, GeekGpt,
+ ChatgptAi, GptGo, GeekGpt,
Phind, You
])
)