summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2023-11-12 01:57:00 +0100
committerGitHub <noreply@github.com>2023-11-12 01:57:00 +0100
commit9d222e83343bd41dfcdfff789619a66b3b60d1ef (patch)
treeb46042f6d997a623de18cf0816bb4e3102a81af1
parentMerge pull request #1236 from hlohaus/pi (diff)
parentImprove readme (diff)
downloadgpt4free-9d222e83343bd41dfcdfff789619a66b3b60d1ef.tar
gpt4free-9d222e83343bd41dfcdfff789619a66b3b60d1ef.tar.gz
gpt4free-9d222e83343bd41dfcdfff789619a66b3b60d1ef.tar.bz2
gpt4free-9d222e83343bd41dfcdfff789619a66b3b60d1ef.tar.lz
gpt4free-9d222e83343bd41dfcdfff789619a66b3b60d1ef.tar.xz
gpt4free-9d222e83343bd41dfcdfff789619a66b3b60d1ef.tar.zst
gpt4free-9d222e83343bd41dfcdfff789619a66b3b60d1ef.zip
-rw-r--r--README.md106
1 files changed, 56 insertions, 50 deletions
diff --git a/README.md b/README.md
index 5b05bd01..dbe9f4e5 100644
--- a/README.md
+++ b/README.md
@@ -14,11 +14,12 @@ new discord server: [discord.gg/XfybzPXPH5](https://discord.gg/XfybzPXPH5)
pip install -U g4f
```
-## New features
-* Telegram Channel: [t.me/g4f_channel](https://telegram.me/g4f_channel)
-* 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)
+## 🆕 What's New
-## Table of Contents
+- Join our Telegram Channel: [t.me/g4f_channel](https://telegram.me/g4f_channel)
+- 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)
@@ -39,7 +40,7 @@ pip install -U g4f
- [Star History](#star-history)
- [License](#license)
-## Getting Started
+## 🛠ī¸ Getting Started
#### Prerequisites:
@@ -142,22 +143,23 @@ 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`.
-## Usage
+## 💡 Usage
### The `g4f` Package
#### ChatCompletion
-```py
+
+```python
import g4f
-g4f.debug.logging = True # enable logging
-g4f.check_version = False # Disable automatic version checking
-print(g4f.version) # check version
-print(g4f.Provider.Ails.params) # supported args
+g4f.debug.logging = True # Enable logging
+g4f.check_version = False # Disable automatic version checking
+print(g4f.version) # Check version
+print(g4f.Provider.Ails.params) # Supported args
# Automatic selection of provider
-# streamed completion
+# Streamed completion
response = g4f.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[{"role": "user", "content": "Hello"}],
@@ -167,16 +169,18 @@ response = g4f.ChatCompletion.create(
for message in response:
print(message, flush=True, end='')
-# normal response
+# Normal response
response = g4f.ChatCompletion.create(
model=g4f.models.gpt_4,
messages=[{"role": "user", "content": "Hello"}],
-) # alternative model setting
+) # Alternative model setting
print(response)
```
+
##### Completion
-```py
+
+```python
import g4f
allowed_models = [
@@ -189,14 +193,16 @@ allowed_models = [
]
response = g4f.Completion.create(
- model = 'text-davinci-003',
- prompt = 'say this is a test')
+ model='text-davinci-003',
+ prompt='say this is a test'
+)
print(response)
```
-##### Providers:
-```py
+##### Providers
+
+```python
import g4f
from g4f.Provider import (
@@ -224,14 +230,13 @@ for message in response:
print(message)
```
-##### Cookies Required:
+##### Cookies Required
-Cookies are essential for the proper functioning of some service providers.
-It is imperative to maintain an active session, typically achieved by logging into your account.
+Cookies are essential for the proper functioning of some service providers. It is imperative to maintain an active session, typically achieved by logging into your account.
When running the g4f package locally, the package automatically retrieves cookies from your web browser using the `get_cookies` function. However, if you're not running it locally, you'll need to provide the cookies manually by passing them as parameters using the `cookies` parameter.
-```py
+```python
import g4f
from g4f.Provider import (
@@ -242,7 +247,7 @@ from g4f.Provider import (
OpenaiChat,
)
-# Usage:
+# Usage
response = g4f.ChatCompletion.create(
model=g4f.models.default,
messages=[{"role": "user", "content": "Hello"}],
@@ -253,13 +258,13 @@ response = g4f.ChatCompletion.create(
)
```
-##### Async Support:
+##### Async Support
-To enhance speed and overall performance, execute providers asynchronously.
-The total execution time will be determined by the duration of the slowest provider's execution.
+To enhance speed and overall performance, execute providers asynchronously. The total execution time will be determined by the duration of the slowest provider's execution.
-```py
-import g4f, asyncio
+```python
+import g4f
+import asyncio
_providers = [
g4f.Provider.Aichat,
@@ -290,11 +295,11 @@ async def run_all():
asyncio.run(run_all())
```
-##### Proxy and Timeout Support:
+##### Proxy and Timeout Support
All providers support specifying a proxy and increasing timeout in the create functions.
-```py
+```python
import g4f
response = g4f.ChatCompletion.create(
@@ -302,25 +307,27 @@ response = g4f.ChatCompletion.create(
messages=[{"role": "user", "content": "Hello"}],
proxy="http://host:port",
# or socks5://user:pass@host:port
- timeout=120, # in secs
+ timeout=120, # in secs
)
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:
-```py
+#### Run interference API from PyPi package
+
+```python
from g4f.api import run_api
run_api()
```
-#### 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 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 [Hugging Face Tokens](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:
+Run server:
```sh
g4f api
@@ -332,7 +339,7 @@ or
python -m g4f.api
```
-```py
+```python
import openai
# Set your Hugging Face token as the API key if you use embeddings
@@ -359,13 +366,12 @@ def main():
if content is not None:
print(content, end="", flush=True)
-if __name__ == "__main":
+if __name__ == "__main__":
main()
-
```
-## Models
-### gpt-4
+## 🚀 Providers and Models
+### GPT-4
| Website| Provider| gpt-3.5 | gpt-4 | Stream | Async | Status | Auth |
| ------ | ------- | ------- | ----- | --------- | --------- | ------ | ---- |
| [bing.com](https://bing.com/chat) | `g4f.Provider.Bing` | ❌ | ✔ī¸ | ✔ī¸ | ✔ī¸ | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
@@ -378,7 +384,7 @@ if __name__ == "__main":
| [supertest.lockchat.app](http://supertest.lockchat.app) | `g4f.Provider.Lockchat` | ✔ī¸ | ✔ī¸ | ✔ī¸ | ❌ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
| [app.myshell.ai](https://app.myshell.ai/chat) | `g4f.Provider.Myshell` | ✔ī¸ | ✔ī¸ | ✔ī¸ | ✔ī¸ | ![Inactive](https://img.shields.io/badge/Inactive-red) | ❌ |
-### gpt-3.5
+### GPT-3.5
| Website| Provider| gpt-3.5 | Stream | Async | Status | Auth |
| ------ | ------- | ------- | --------- | --------- | ------ | ---- |
@@ -462,7 +468,7 @@ if __name__ == "__main":
| llama13b-v2-chat | Replicate | g4f.Provider.Vercel | [sdk.vercel.ai](https://sdk.vercel.ai/) |
| llama7b-v2-chat | Replicate | g4f.Provider.Vercel | [sdk.vercel.ai](https://sdk.vercel.ai/) |
-## Related gpt4free projects
+## 🔗 Related GPT4Free Projects
<table>
<thead align="center">
@@ -548,7 +554,7 @@ if __name__ == "__main":
</tbody>
</table>
-## Contribute
+## 🤝 Contribute
#### Create Provider with AI Tool
@@ -613,13 +619,13 @@ for message in response:
print(message, flush=True, end='')
```
-## Contributors
+## 🙌 Contributors
A list of the contributors is available [here](https://github.com/xtekky/gpt4free/graphs/contributors)
The [`Vercel.py`](https://github.com/xtekky/gpt4free/blob/main/g4f/Provider/Vercel.py) file contains code from [vercel-llm-api](https://github.com/ading2210/vercel-llm-api) by [@ading2210](https://github.com/ading2210), which is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)
Top 1 Contributor: [@hlohaus](https://github.com/hlohaus)
-## Copyright
+## Šī¸ Copyright
This program is licensed under the [GNU GPL v3](https://www.gnu.org/licenses/gpl-3.0.txt)
@@ -640,13 +646,13 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
```
-## Star History
+## ⭐ Star History
<a href="https://github.com/xtekky/gpt4free/stargazers">
<img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=xtekky/gpt4free&type=Date">
</a>
-## License
+## 📄 License
<table>
<tr>