summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md30
-rw-r--r--g4f/Provider/ChatBase.py7
-rw-r--r--g4f/Provider/MyShell.py1
-rw-r--r--g4f/Provider/deprecated/GetGpt.py5
-rw-r--r--g4f/__init__.py2
-rw-r--r--setup.py2
6 files changed, 31 insertions, 16 deletions
diff --git a/README.md b/README.md
index e2b882b5..9e1ff694 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,11 @@
![248433934-7886223b-c1d1-4260-82aa-da5741f303bb](https://github.com/xtekky/gpt4free/assets/98614666/ea012c87-76e0-496a-8ac4-e2de090cc6c9)
-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.
-- latest pypi version: [`0.1.7.6`](https://pypi.org/project/g4f/0.1.7.6)
+> **Note**
+> 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**
+> Latest pypi version: [`0.1.7.7`](https://pypi.org/project/g4f/0.1.7.7)
```sh
pip install -U g4f
```
@@ -132,7 +135,8 @@ To stop the Docker containers, simply run:
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
@@ -300,16 +304,16 @@ response = g4f.ChatCompletion.create(
print(f"Result:", response)
```
-### 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:
```py
from g4f.api import run_api
run_api()
```
-#### run interference api from repo:
+#### run interference API from repo:
If you want to use the embedding function, you need to get a Hugging Face token. You can get one at https://huggingface.co/settings/tokens make sure your role is set to write. If you have your token, just use it instead of the OpenAI api-key.
run server:
@@ -327,7 +331,7 @@ python -m g4f.api
```py
import openai
-openai.api_key = "Empty if you don't use embeddings, otherwise your hugginface token"
+openai.api_key = "Empty if you don't use embeddings, otherwise your Hugging Face token"
openai.api_base = "http://localhost:1337/v1"
@@ -539,15 +543,15 @@ Call in your terminal the "create_provider" script:
python etc/tool/create_provider.py
```
1. Enter your name for the new provider.
-2. Copy & Paste a cURL command from your browser developer tools.
+2. Copy and paste a cURL command from your browser developer tools.
3. Let the AI ​​create the provider for you.
4. Customize the provider according to your needs.
#### Create Provider
1. Check out the current [list of potential providers](https://github.com/zukixa/cool-ai-stuff#ai-chat-websites), or find your own provider source!
-2. Create a new file in [g4f/provider](./g4f/provider) with the name of the Provider
-3. Implement a class that extends [BaseProvider](./g4f/provider/base_provider.py).
+2. Create a new file in [g4f/Provider](./g4f/Provider) with the name of the Provider
+3. Implement a class that extends [BaseProvider](./g4f/Provider/base_provider.py).
```py
from __future__ import annotations
@@ -571,9 +575,9 @@ class HogeService(AsyncGeneratorProvider):
yield ""
```
-4. Here, you can adjust the settings, for example if the website does support streaming, set `supports_stream` to `True`...
-5. Write code to request the provider in `create_async_generator` and `yield` the response, _even if_ its a one-time response, do not hesitate to look at other providers for inspiration
-6. Add the Provider Name in [g4f/provider/**init**.py](./g4f/provider/__init__.py)
+4. Here, you can adjust the settings, for example, if the website does support streaming, set `supports_stream` to `True`...
+5. Write code to request the provider in `create_async_generator` and `yield` the response, _even if_ it's a one-time response, do not hesitate to look at other providers for inspiration
+6. Add the Provider Name in [g4f/Provider/**init**.py](./g4f/Provider/__init__.py)
```py
from .HogeService import HogeService
diff --git a/g4f/Provider/ChatBase.py b/g4f/Provider/ChatBase.py
index 0ba511f7..d59717c0 100644
--- a/g4f/Provider/ChatBase.py
+++ b/g4f/Provider/ChatBase.py
@@ -11,6 +11,8 @@ class ChatBase(AsyncGeneratorProvider):
supports_gpt_35_turbo = True
supports_message_history = True
working = True
+ list_incorrect_responses = ["Hmm, I am not sure. Email support@chatbase.co for more info.",
+ "I can only provide support and information about Chatbase"]
@classmethod
async def create_async_generator(
@@ -42,7 +44,12 @@ class ChatBase(AsyncGeneratorProvider):
async with session.post("https://www.chatbase.co/api/fe/chat", json=data, proxy=proxy) as response:
response.raise_for_status()
+ response_data = ""
async for stream in response.content.iter_any():
+ response_data += stream.decode()
+ for incorrect_response in cls.list_incorrect_responses:
+ if incorrect_response in response_data:
+ raise RuntimeError("Incorrect response")
yield stream.decode()
@classmethod
diff --git a/g4f/Provider/MyShell.py b/g4f/Provider/MyShell.py
index fe8604bb..176585ed 100644
--- a/g4f/Provider/MyShell.py
+++ b/g4f/Provider/MyShell.py
@@ -9,6 +9,7 @@ from .helper import format_prompt
class MyShell(AsyncGeneratorProvider):
url = "https://app.myshell.ai/chat"
+ working = True
@classmethod
async def create_async_generator(
diff --git a/g4f/Provider/deprecated/GetGpt.py b/g4f/Provider/deprecated/GetGpt.py
index a5de1d29..0fbb5b87 100644
--- a/g4f/Provider/deprecated/GetGpt.py
+++ b/g4f/Provider/deprecated/GetGpt.py
@@ -5,7 +5,10 @@ import os
import uuid
import requests
-from Crypto.Cipher import AES
+try:
+ from Crypto.Cipher import AES
+except ImportError:
+ from Cryptodome.Cipher import AES
from ...typing import Any, CreateResult
from ..base_provider import BaseProvider
diff --git a/g4f/__init__.py b/g4f/__init__.py
index ca3de3a3..32f4a91b 100644
--- a/g4f/__init__.py
+++ b/g4f/__init__.py
@@ -5,7 +5,7 @@ from .Provider import BaseProvider, RetryProvider
from .typing import Messages, CreateResult, Union, List
from . import debug
-version = '0.1.7.6'
+version = '0.1.7.7'
version_check = True
def check_pypi_version() -> None:
diff --git a/setup.py b/setup.py
index cb451438..cd615b7a 100644
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
with open("requirements.txt") as f:
required = f.read().splitlines()
-VERSION = "0.1.7.6"
+VERSION = "0.1.7.7"
DESCRIPTION = (
"The official gpt4free repository | various collection of powerful language models"
)