返回提交历史
Added
Dockerfile
+33
-0
Modified
README.md
+107
-42
Added
docker-compose.yml
+13
-0
XFEstudio/gpt4free
feat(docker): add Docker and Docker Compose support
f300aebf
代码差异
3 个文件
+153
-42
@@ -0,0 +1,33 @@
1
# Use the official lightweight Python image.
2
# https://hub.docker.com/_/python
3
FROM python:3.9-slim
4
5
# Ensure Python outputs everything immediately (useful for real-time logging in Docker).
6
ENV PYTHONUNBUFFERED 1
7
8
# Set the working directory in the container.
9
WORKDIR /app
10
11
# Update the system packages and install system-level dependencies required for compilation.
12
# gcc: Compiler required for some Python packages.
13
# build-essential: Contains necessary tools and libraries for building software.
14
RUN apt-get update && apt-get install -y --no-install-recommends \
15
gcc \
16
build-essential \
17
&& rm -rf /var/lib/apt/lists/*
18
19
# Copy the project's requirements file into the container.
20
COPY requirements.txt /app/
21
22
# Upgrade pip for the latest features and install the project's Python dependencies.
23
RUN pip install --upgrade pip && pip install -r requirements.txt
24
25
# Copy the entire project into the container.
26
# This may include all code, assets, and configuration files required to run the application.
27
COPY . /app/
28
29
# Install additional requirements specific to the interference module/package.
30
RUN pip install -r interference/requirements.txt
31
32
# Define the default command to run the app using Python's module mode.
33
CMD ["python", "-m", "interference.app"]
@@ -1,4 +1,3 @@
1
2
1

3
2
4
3
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, reuploads 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.
@@ -7,54 +6,69 @@ This (quite censored) New Version of gpt4free, was just released so it may conta
7
6
P.S: Docker is for now not available but I would be happy if someone contributes a PR. The g4f GUI will be uploaded soon enough.
8
7
9
8
### New
9
10
10
- pypi package:
11
11
12
```
12
13
pip install -U g4f
13
14
```
14
15
15
16
## Table of Contents:
16
17
18
- [Table of Contents:](#table-of-contents)
17
19
- [Getting Started](#getting-started)
18
+ [Prerequisites](#prerequisites)
19
+ [Setting up the project](#setting-up-the-project)
20
- [Prerequisites:](#prerequisites)
21
- [Setting up the project:](#setting-up-the-project)
22
- [Install using pypi](#install-using-pypi)
23
- [or](#or)
24
- [Setting up with Docker:](#setting-up-with-docker)
20
25
- [Usage](#usage)
21
* [The `g4f` Package](#the-g4f-package)
22
* [interference openai-proxy api](#interference-openai-proxy-api-use-with-openai-python-package)
26
- [The `g4f` Package](#the-g4f-package)
27
- [interference openai-proxy api (use with openai python package)](#interference-openai-proxy-api-use-with-openai-python-package)
23
28
- [Models](#models)
24
* [gpt-3.5 / gpt-4](#gpt-35--gpt-4)
25
* [Other Models](#other-models)
29
- [gpt-3.5 / gpt-4](#gpt-35--gpt-4)
30
- [Other Models](#other-models)
26
31
- [Related gpt4free projects](#related-gpt4free-projects)
27
32
- [Contribute](#contribute)
28
33
- [ChatGPT clone](#chatgpt-clone)
29
- [Copyright](#copyright)
30
- [Copyright Notice](#copyright-notice)
34
- [Copyright:](#copyright)
35
- [Copyright Notice:](#copyright-notice)
31
36
- [Star History](#star-history)
32
37
33
38
## Getting Started
34
39
35
40
#### Prerequisites:
41
36
42
1. [Download and install Python](https://www.python.org/downloads/) (Version 3.x is recommended).
37
43
38
44
#### Setting up the project:
45
39
46
##### Install using pypi
47
40
48
```
41
49
pip install -U g4f
42
50
```
43
51
44
52
##### or
45
53
46
1. Clone the GitHub repository:
54
1. Clone the GitHub repository:
55
47
56
```
48
57
git clone https://github.com/xtekky/gpt4free.git
49
58
```
59
50
60
2. Navigate to the project directory:
61
51
62
```
52
63
cd gpt4free
53
64
```
65
54
66
3. (Recommended) Create a virtual environment to manage Python packages for your project:
67
55
68
```
56
69
python3 -m venv venv
57
70
```
71
58
72
4. Activate the virtual environment:
59
73
- On Windows:
60
74
```
@@ -65,20 +79,66 @@ python3 -m venv venv
65
79
source venv/bin/activate
66
80
```
67
81
5. Install the required Python packages from `requirements.txt`:
82
68
83
```
69
84
pip install -r requirements.txt
70
85
```
71
86
72
87
6. Create a `test.py` file in the root folder and start using the repo, further Instructions are below
88
73
89
```py
74
90
import g4f
75
91
76
92
...
77
93
```
78
94
95
##### Setting up with Docker:
96
97
If you have Docker installed, you can easily set up and run the project without manually installing dependencies.
98
99
1. First, ensure you have both Docker and Docker Compose installed.
100
101
- [Install Docker](https://docs.docker.com/get-docker/)
102
- [Install Docker Compose](https://docs.docker.com/compose/install/)
103
104
2. Clone the GitHub repo:
105
106
```bash
107
git clone https://github.com/xtekky/gpt4free.git
108
```
109
110
3. Navigate to the project directory:
111
112
```bash
113
cd gpt4free
114
```
115
116
4. Build the Docker image:
117
118
```bash
119
docker compose build
120
```
121
122
5. Start the service using Docker Compose:
123
124
```bash
125
docker compose up
126
```
127
128
You server will now be running at `http://localhost:1337`. You can interact with the API or run your tests as you would normally.
129
130
To stop the Docker containers, simply run:
131
132
```bash
133
docker compose down
134
```
135
136
**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`.
137
79
138
## Usage
80
139
81
140
### The `g4f` Package
141
82
142
```py
83
143
import g4f
84
144
@@ -119,6 +179,7 @@ for message in response:
119
179
```
120
180
121
181
providers:
182
122
183
```py
123
184
from g4f.Provider import (
124
185
Acytoo,
@@ -139,14 +200,16 @@ from g4f.Provider import (
139
200
response = g4f.ChatCompletion.create(..., provider=ProviderName)
140
201
```
141
202
142
### interference openai-proxy api (use with openai python package)
203
### interference openai-proxy api (use with openai python package)
143
204
144
205
get requirements:
206
145
207
```sh
146
208
pip install -r interference/requirements.txt
147
209
```
148
210
149
211
run server:
212
150
213
```sh
151
214
python3 -m interference.app
152
215
```
@@ -180,35 +243,36 @@ if __name__ == "__main__":
180
243
main()
181
244
```
182
245
183
## Models
246
## Models
247
184
248
### gpt-3.5 / gpt-4
185
249
186
| Website| Provider| gpt-3.5 | gpt-4 | Streaming | Status | Auth |
187
| ------ | ------- | ------- | ----- | --------- | ------ | ---- |
188
| [www.aitianhu.com](https://www.aitianhu.com/api/chat-process) | g4f.Provider.AItianhu | ✔️ | ❌ | ❌ |  | ❌ |
189
| [chat.acytoo.com](https://chat.acytoo.com/api/completions) | g4f.Provider.Acytoo | ✔️ | ❌ | ❌ |  | ❌ |
190
| [aiservice.vercel.app](https://aiservice.vercel.app/api/chat/answer) | g4f.Provider.AiService | ✔️ | ❌ | ❌ |  | ❌ |
191
| [chat-gpt.org](https://chat-gpt.org/chat) | g4f.Provider.Aichat | ✔️ | ❌ | ❌ |  | ❌ |
192
| [ai.ls](https://ai.ls) | g4f.Provider.Ails | ✔️ | ❌ | ✔️ |  | ❌ |
193
| [bard.google.com](https://bard.google.com) | g4f.Provider.Bard | ❌ | ❌ | ❌ |  | ✔️ |
194
| [bing.com](https://bing.com/chat) | g4f.Provider.Bing | ❌ | ✔️ | ❌ |  | ❌ |
195
| [chatgpt.ai](https://chatgpt.ai/gpt-4/) | g4f.Provider.ChatgptAi | ❌ | ✔️ | ❌ |  | ❌ |
196
| [chatgptlogin.ac](https://chatgptlogin.ac) | g4f.Provider.ChatgptLogin | ✔️ | ❌ | ❌ |  | ❌ |
197
| [deepai.org](https://deepai.org) | g4f.Provider.DeepAi | ✔️ | ❌ | ✔️ |  | ❌ |
198
| [chat.dfehub.com](https://chat.dfehub.com/api/chat) | g4f.Provider.DfeHub | ✔️ | ❌ | ✔️ |  | ❌ |
199
| [free.easychat.work](https://free.easychat.work) | g4f.Provider.EasyChat | ✔️ | ❌ | ✔️ |  | ❌ |
200
| [forefront.com](https://forefront.com) | g4f.Provider.Forefront | ✔️ | ❌ | ✔️ |  | ❌ |
201
| [chat.getgpt.world](https://chat.getgpt.world/) | g4f.Provider.GetGpt | ✔️ | ❌ | ✔️ |  | ❌ |
202
| [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.Provider.H2o | ❌ | ❌ | ✔️ |  | ❌ |
203
| [liaobots.com](https://liaobots.com) | g4f.Provider.Liaobots | ✔️ | ✔️ | ✔️ |  | ✔️ |
204
| [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.Provider.Lockchat | ✔️ | ✔️ | ✔️ |  | ❌ |
205
| [opchatgpts.net](https://opchatgpts.net) | g4f.Provider.Opchatgpts | ✔️ | ❌ | ❌ |  | ❌ |
206
| [backend.raycast.com](https://backend.raycast.com/api/v1/ai/chat_completions) | g4f.Provider.Raycast | ✔️ | ✔️ | ✔️ |  | ✔️ |
207
| [theb.ai](https://theb.ai) | g4f.Provider.Theb | ✔️ | ❌ | ✔️ |  | ❌ |
208
| [play.vercel.ai](https://play.vercel.ai) | g4f.Provider.Vercel | ✔️ | ❌ | ❌ |  | ❌ |
209
| [wewordle.org](https://wewordle.org/gptapi/v1/android/turbo) | g4f.Provider.Wewordle | ✔️ | ❌ | ❌ |  | ❌ |
210
| [you.com](https://you.com) | g4f.Provider.You | ✔️ | ❌ | ❌ |  | ❌ |
211
| [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.Provider.Yqcloud | ✔️ | ❌ | ❌ |  | ❌ |
250
| Website | Provider | gpt-3.5 | gpt-4 | Streaming | Status | Auth |
251
| ----------------------------------------------------------------------------- | ------------------------- | ------- | ----- | --------- | ---------------------------------------------------------- | ---- |
252
| [www.aitianhu.com](https://www.aitianhu.com/api/chat-process) | g4f.Provider.AItianhu | ✔️ | ❌ | ❌ |  | ❌ |
253
| [chat.acytoo.com](https://chat.acytoo.com/api/completions) | g4f.Provider.Acytoo | ✔️ | ❌ | ❌ |  | ❌ |
254
| [aiservice.vercel.app](https://aiservice.vercel.app/api/chat/answer) | g4f.Provider.AiService | ✔️ | ❌ | ❌ |  | ❌ |
255
| [chat-gpt.org](https://chat-gpt.org/chat) | g4f.Provider.Aichat | ✔️ | ❌ | ❌ |  | ❌ |
256
| [ai.ls](https://ai.ls) | g4f.Provider.Ails | ✔️ | ❌ | ✔️ |  | ❌ |
257
| [bard.google.com](https://bard.google.com) | g4f.Provider.Bard | ❌ | ❌ | ❌ |  | ✔️ |
258
| [bing.com](https://bing.com/chat) | g4f.Provider.Bing | ❌ | ✔️ | ❌ |  | ❌ |
259
| [chatgpt.ai](https://chatgpt.ai/gpt-4/) | g4f.Provider.ChatgptAi | ❌ | ✔️ | ❌ |  | ❌ |
260
| [chatgptlogin.ac](https://chatgptlogin.ac) | g4f.Provider.ChatgptLogin | ✔️ | ❌ | ❌ |  | ❌ |
261
| [deepai.org](https://deepai.org) | g4f.Provider.DeepAi | ✔️ | ❌ | ✔️ |  | ❌ |
262
| [chat.dfehub.com](https://chat.dfehub.com/api/chat) | g4f.Provider.DfeHub | ✔️ | ❌ | ✔️ |  | ❌ |
263
| [free.easychat.work](https://free.easychat.work) | g4f.Provider.EasyChat | ✔️ | ❌ | ✔️ |  | ❌ |
264
| [forefront.com](https://forefront.com) | g4f.Provider.Forefront | ✔️ | ❌ | ✔️ |  | ❌ |
265
| [chat.getgpt.world](https://chat.getgpt.world/) | g4f.Provider.GetGpt | ✔️ | ❌ | ✔️ |  | ❌ |
266
| [gpt-gm.h2o.ai](https://gpt-gm.h2o.ai) | g4f.Provider.H2o | ❌ | ❌ | ✔️ |  | ❌ |
267
| [liaobots.com](https://liaobots.com) | g4f.Provider.Liaobots | ✔️ | ✔️ | ✔️ |  | ✔️ |
268
| [supertest.lockchat.app](http://supertest.lockchat.app) | g4f.Provider.Lockchat | ✔️ | ✔️ | ✔️ |  | ❌ |
269
| [opchatgpts.net](https://opchatgpts.net) | g4f.Provider.Opchatgpts | ✔️ | ❌ | ❌ |  | ❌ |
270
| [backend.raycast.com](https://backend.raycast.com/api/v1/ai/chat_completions) | g4f.Provider.Raycast | ✔️ | ✔️ | ✔️ |  | ✔️ |
271
| [theb.ai](https://theb.ai) | g4f.Provider.Theb | ✔️ | ❌ | ✔️ |  | ❌ |
272
| [play.vercel.ai](https://play.vercel.ai) | g4f.Provider.Vercel | ✔️ | ❌ | ❌ |  | ❌ |
273
| [wewordle.org](https://wewordle.org/gptapi/v1/android/turbo) | g4f.Provider.Wewordle | ✔️ | ❌ | ❌ |  | ❌ |
274
| [you.com](https://you.com) | g4f.Provider.You | ✔️ | ❌ | ❌ |  | ❌ |
275
| [chat9.yqcloud.top](https://chat9.yqcloud.top/) | g4f.Provider.Yqcloud | ✔️ | ❌ | ❌ |  | ❌ |
212
276
213
277
### Other Models
214
278
@@ -302,6 +366,7 @@ if __name__ == "__main__":
302
366
## Contribute
303
367
304
368
to add another provider, its very simple:
369
305
370
1. create a new file in [g4f/provider](./g4f/provider) with the name of the Provider
306
371
2. Implement a class that extends [BaseProvider](./g4f/provider/base_provider.py).
307
372
@@ -326,8 +391,8 @@ class HogeService(BaseProvider):
326
391
```
327
392
328
393
3. Here, you can adjust the settings, for example if the website does support streaming, set `working` to `True`...
329
4. Write code to request the provider in `create_completion` and `yield` the response, *even if* its a one-time response, do not hesitate to look at other providers for inspiration
330
5. Add the Provider Name in [g4f/provider/__init__.py](./g4f/provider/__init__.py)
394
4. Write code to request the provider in `create_completion` and `yield` the response, _even if_ its a one-time response, do not hesitate to look at other providers for inspiration
395
5. Add the Provider Name in [g4f/provider/**init**.py](./g4f/provider/__init__.py)
331
396
332
397
```py
333
398
from .base_provider import BaseProvider
@@ -339,6 +404,7 @@ __all__ = [
339
404
```
340
405
341
406
6. You are done !, test the provider by calling it:
407
342
408
```py
343
409
import g4f
344
410
@@ -379,9 +445,8 @@ You should have received a copy of the GNU General Public License
379
445
along with this program. If not, see <https://www.gnu.org/licenses/>.
380
446
```
381
447
382
383
448
## Star History
384
449
385
450
<a href="https://github.com/xtekky/gpt4free/stargazers">
386
451
<img width="500" alt="Star History Chart" src="https://api.star-history.com/svg?repos=xtekky/gpt4free&type=Date">
387
</a>
452
</a>
@@ -0,0 +1,13 @@
1
version: '3'
2
3
services:
4
gpt4free:
5
build:
6
context: .
7
dockerfile: Dockerfile
8
volumes:
9
- .:/app
10
ports:
11
- '1337:1337'
12
environment:
13
- PYTHONUNBUFFERED=1