Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docker integration #1

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3-alpine

WORKDIR /app
COPY ./requirements.txt /app
COPY ./src/* /app

RUN pip3 install -r requirements.txt

ENV PORT=5500
EXPOSE "$PORT/tcp"

#ENTRYPOINT nginx && uwsgi --ini /app/params.ini -w FreeGPT4_Server
#shell form necessary
SHELL ["python3","/app/FreeGPT4_Server.py"]
ENTRYPOINT ["python3","/app/FreeGPT4_Server.py"]
CMD ["--cookie-file","/cookies.json"]
30 changes: 24 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,37 @@ FreeGPT4-WEB-API is a python server that allows you to have a self-hosted GPT-4

- Python 3
- Flask
- EdgeGPT

- `cookies.json` (see [this guide](https://github.com/acheong08/EdgeGPT#getting-authentication-required) for its creation), this file is mandatory for the script to function.
## Manual Installation
To install the required libraries, you can use the following command:

`pip3 install Flask EdgeGPT`

`pip3 install Flask`

## Usage
### Usage

To run the server, use the following command:

`python3 FreeGPT4_Server.py --cookie-file ../cookies.json`
`python3 FreeGPT4_Server.py --cookie-file /path/to/your/cookies.json`
## Docker Installation

It's possible to install the docker image of this API by running this command:

`docker container run -v /path/to/your/cookies.json:/cookies.json:ro -p YOUR_PORT:5500 d0ckmg/free-gpt4-web-api`

or alternatively, you can use a docker-compose file:

**docker-compose.yml**

```yaml
version: "3.9"
services:
api:
image: "d0ckmg/free-gpt4-web-api:latest"
ports:
- "YOUR_PORT:5500"
volumes:
- /path/to/your/cookies.json:/cookies.json:ro
```

This will start the server and allow you to access the GPT-4 WEB API.

Expand Down
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3.9"
services:
api:
image: "d0ckmg/free-gpt4-web-api:latest"
ports:
- "5500:5500"
volumes:
- ./cookies.json:/cookies.json

3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
EdgeGPT
flask
aiohttp
flask[async]
aiohttp
4 changes: 2 additions & 2 deletions src/FreeGPT4_Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from flask import Flask, request
app = Flask(__name__)

ADDRESS = socket.gethostbyname(socket.getfqdn())
#ADDRESS = socket.gethostbyname(socket.getfqdn())
#ADDRESS = "192.168.1.X" # Edit if needed, uncomment to use

@app.route('/')
Expand Down Expand Up @@ -97,4 +97,4 @@ async def index() -> None:
)

#Starts the server, change the port if needed
app.run(host=ADDRESS, port=5005, debug=False)
app.run("0.0.0.0", port=5500, debug=False)
Binary file added src/__pycache__/EdgeGPT.cpython-311.pyc
Binary file not shown.