Add gpt4free API for Hugging Face
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Dockerfile +11 -0
- gpt4free/.gitattributes +2 -0
- gpt4free/.github/FUNDING.yml +3 -0
- gpt4free/.github/ISSUE_TEMPLATE/default_issue.md +37 -0
- gpt4free/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- gpt4free/.github/copilot-instructions.md +137 -0
- gpt4free/.github/workflows/build-packages.yml +485 -0
- gpt4free/.github/workflows/close-inactive-issues.yml +31 -0
- gpt4free/.github/workflows/copilot.yml +57 -0
- gpt4free/.github/workflows/publish-to-pypi.yml +51 -0
- gpt4free/.github/workflows/unittest.yml +47 -0
- gpt4free/.gitignore +48 -0
- gpt4free/CODE_OF_CONDUCT.md +128 -0
- gpt4free/CONTRIBUTING.md +8 -0
- gpt4free/LEGAL_NOTICE.md +55 -0
- gpt4free/LICENSE +674 -0
- gpt4free/MANIFEST.in +1 -0
- gpt4free/README.md +489 -0
- gpt4free/SECURITY.md +4 -0
- gpt4free/docker-compose-slim.yml +15 -0
- gpt4free/docker-compose.yml +17 -0
- gpt4free/docker/Dockerfile +55 -0
- gpt4free/docker/Dockerfile-armv7 +71 -0
- gpt4free/docker/Dockerfile-slim +39 -0
- gpt4free/docker/start.sh +2 -0
- gpt4free/docker/supervisor-api.conf +12 -0
- gpt4free/docker/supervisor.conf +50 -0
- gpt4free/docker/update.sh +24 -0
- gpt4free/docs/README.md +1 -0
- gpt4free/docs/aarch64-compatibility.md +72 -0
- gpt4free/docs/arm64-build-plan.md +64 -0
- gpt4free/docs/build-workflow.md +108 -0
- gpt4free/docs/reasoning-standardization.md +65 -0
- gpt4free/etc/examples/api_completions_copilot.py +55 -0
- gpt4free/etc/examples/api_generations_image.py +11 -0
- gpt4free/etc/examples/audio.py +28 -0
- gpt4free/etc/examples/messages.py +33 -0
- gpt4free/etc/examples/messages_stream.py +25 -0
- gpt4free/etc/examples/openaichat.py +23 -0
- gpt4free/etc/examples/text_completions_demo_async.py +17 -0
- gpt4free/etc/examples/text_completions_demo_sync.py +13 -0
- gpt4free/etc/examples/text_completions_streaming.py +49 -0
- gpt4free/etc/examples/video.py +19 -0
- gpt4free/etc/examples/vision_images.py +33 -0
- gpt4free/etc/examples/vision_images_reka.py +27 -0
- gpt4free/etc/testing/_providers.py +61 -0
- gpt4free/etc/testing/log_time.py +21 -0
- gpt4free/etc/testing/test_all.py +57 -0
- gpt4free/etc/testing/test_api.py +27 -0
- gpt4free/etc/testing/test_async.py +31 -0
Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10-slim
|
2 |
+
|
3 |
+
WORKDIR /app
|
4 |
+
|
5 |
+
COPY ./gpt4free /app
|
6 |
+
|
7 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
8 |
+
|
9 |
+
EXPOSE 8080
|
10 |
+
|
11 |
+
CMD ["python", "-m", "g4f.api"]
|
gpt4free/.gitattributes
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
# Auto detect text files and perform LF normalization
|
2 |
+
* text=auto
|
gpt4free/.github/FUNDING.yml
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
ko_fi: xtekky
|
2 |
+
github: [xtekky, hlohaus]
|
3 |
+
patreon: xtekky
|
gpt4free/.github/ISSUE_TEMPLATE/default_issue.md
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Bug Report
|
3 |
+
about: Report issues with specific models/providers
|
4 |
+
title: '[Bug] '
|
5 |
+
labels: bug
|
6 |
+
assignees: hlohaus
|
7 |
+
---
|
8 |
+
|
9 |
+
**Before submitting**
|
10 |
+
☑️ I checked [Known Issues](https://github.com/xtekky/gpt4free#known-issues)
|
11 |
+
☑️ I searched existing issues
|
12 |
+
|
13 |
+
**Configuration**
|
14 |
+
*(Required)*
|
15 |
+
- Model:**
|
16 |
+
- Provider:**
|
17 |
+
- Interface:** (CLI/API/Web UI/Other)
|
18 |
+
|
19 |
+
**Bug description**
|
20 |
+
Clear steps to reproduce:
|
21 |
+
1. Exact command/file used:
|
22 |
+
`python ...`
|
23 |
+
2. Environment location:
|
24 |
+
(e.g., `Germany` - Cloudflare restrictions may apply)
|
25 |
+
3. Observed behavior vs expected:
|
26 |
+
|
27 |
+
**Environment**
|
28 |
+
- Python version: `python --version`
|
29 |
+
- OS: (Windows 11/Ubuntu 22.04/macOS Ventura)
|
30 |
+
- Relevant dependencies: `pip freeze | grep -E 'g4f|requests'`
|
31 |
+
|
32 |
+
**Screenshots/Logs**
|
33 |
+
Copy&Paste terminal output or error logs here
|
34 |
+
|
35 |
+
|
36 |
+
**Additional context**
|
37 |
+
Proxy/VPN usage? Special config? Other providers working?
|
gpt4free/.github/ISSUE_TEMPLATE/feature_request.md
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Feature request
|
3 |
+
about: Suggest an idea for this project
|
4 |
+
title: ''
|
5 |
+
labels: ''
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
**Is your feature request related to a problem? Please describe.**
|
11 |
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12 |
+
|
13 |
+
**Describe the solution you'd like**
|
14 |
+
A clear and concise description of what you want to happen.
|
15 |
+
|
16 |
+
**Describe alternatives you've considered**
|
17 |
+
A clear and concise description of any alternative solutions or features you've considered.
|
18 |
+
|
19 |
+
**Additional context**
|
20 |
+
Add any other context or screenshots about the feature request here.
|
gpt4free/.github/copilot-instructions.md
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# gpt4free - Python Library for AI Provider Access
|
2 |
+
|
3 |
+
gpt4free is a Python 3.10+ library that provides unified access to 108+ AI providers for text generation, image generation, audio processing, and video generation. It offers a CLI, API server with web GUI, and Python library interface.
|
4 |
+
|
5 |
+
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
|
6 |
+
|
7 |
+
## Working Effectively
|
8 |
+
|
9 |
+
### Bootstrap and Install Dependencies
|
10 |
+
- Install Python 3.10+ (3.12 recommended): Project requires Python 3.10 or higher
|
11 |
+
- Clone repository: `git clone https://github.com/xtekky/gpt4free.git && cd gpt4free`
|
12 |
+
- Install minimal requirements: `pip install -r requirements-min.txt` -- takes 30-60 seconds. NEVER CANCEL.
|
13 |
+
- Install full requirements: `pip install -r requirements.txt` -- takes 2-5 minutes. NEVER CANCEL. Set timeout to 600+ seconds.
|
14 |
+
- Remove nodriver (CI requirement): `pip uninstall -y nodriver`
|
15 |
+
- Install in editable mode: `pip install -e .` -- takes 30 seconds. NEVER CANCEL.
|
16 |
+
|
17 |
+
### Testing and Validation
|
18 |
+
- Run unit tests: `python -m etc.unittest` -- takes 3-5 seconds. NEVER CANCEL.
|
19 |
+
- Expected results: ~41 tests, 1-2 failures expected (network isolation), 5-8 skipped tests
|
20 |
+
- Time unit tests: `time python -m etc.unittest` for precise timing
|
21 |
+
- Individual test scripts available in `etc/testing/` but may have outdated model references
|
22 |
+
|
23 |
+
### Running the Application
|
24 |
+
- **CLI Help**: `g4f --help` or `python -m g4f --help`
|
25 |
+
- **Client CLI**: `g4f client --help` for interactive text generation
|
26 |
+
- **API Server**: `python -m g4f --port 8080` -- starts FastAPI server with web GUI on http://localhost:8080
|
27 |
+
- **API Server Only**: `python -m g4f.cli api --port 8080`
|
28 |
+
- **Python Library**:
|
29 |
+
```python
|
30 |
+
from g4f.client import Client
|
31 |
+
client = Client()
|
32 |
+
response = client.chat.completions.create(model="gpt-4o", messages=[{"role": "user", "content": "Hello"}])
|
33 |
+
print(response.choices[0].message.content)
|
34 |
+
```
|
35 |
+
|
36 |
+
## Validation Scenarios
|
37 |
+
|
38 |
+
Always test these scenarios after making changes:
|
39 |
+
|
40 |
+
### Basic Functionality Test
|
41 |
+
1. **Import Test**: `python -c "from g4f.client import Client; client = Client(); print('Success')"`
|
42 |
+
2. **CLI Test**: `g4f --help` should show available commands without errors
|
43 |
+
3. **Unit Tests**: `python -m etc.unittest` should complete without hanging
|
44 |
+
4. **API Server Test**: Start server `python -m g4f --port 8080`, then `curl -I http://localhost:8080` should return 200 OK
|
45 |
+
|
46 |
+
### Manual Validation Requirements
|
47 |
+
- ALWAYS test complete user workflows, not just imports
|
48 |
+
- Test both CLI and Python library interfaces when making provider changes
|
49 |
+
- Test API server startup and basic HTTP response
|
50 |
+
- Verify no new import errors or dependency conflicts
|
51 |
+
|
52 |
+
## Critical Timing and Build Information
|
53 |
+
|
54 |
+
- **NEVER CANCEL** long-running operations. Builds may take several minutes.
|
55 |
+
- **Requirements Installation**:
|
56 |
+
- Minimal (`requirements-min.txt`): 30-60 seconds. Set timeout to 120+ seconds.
|
57 |
+
- Full (`requirements.txt`): 2-5 minutes. Set timeout to 600+ seconds.
|
58 |
+
- **Unit Tests**: 3-5 seconds. Set timeout to 30+ seconds.
|
59 |
+
- **Package Installation**: 30-60 seconds. Set timeout to 120+ seconds.
|
60 |
+
- **Warning**: `pydub` will show ffmpeg warning - this is expected and harmless
|
61 |
+
|
62 |
+
## Key Development Info
|
63 |
+
|
64 |
+
### Project Structure
|
65 |
+
- `g4f/` - Main library code
|
66 |
+
- `Provider/` - AI provider implementations (108+ providers)
|
67 |
+
- `client/` - Client interfaces
|
68 |
+
- `api/` - FastAPI server implementation
|
69 |
+
- `gui/` - Web GUI components
|
70 |
+
- `cli/` - Command line interfaces
|
71 |
+
- `etc/` - Testing and development tools
|
72 |
+
- `unittest/` - Unit test suite
|
73 |
+
- `testing/` - Integration tests (may have outdated references)
|
74 |
+
- `examples/` - Usage examples
|
75 |
+
- `docs/` - Documentation
|
76 |
+
- `docker/` - Docker configuration files
|
77 |
+
|
78 |
+
### Provider System
|
79 |
+
- 108+ AI providers supported including OpenAI, Anthropic, Google, Meta, etc.
|
80 |
+
- Each provider in `g4f/Provider/` directory
|
81 |
+
- Working providers listed in CLI help: `g4f --help`
|
82 |
+
- Test provider availability: Network-dependent, many may fail in isolated environments
|
83 |
+
|
84 |
+
### Common Commands Reference
|
85 |
+
```bash
|
86 |
+
# Development workflow
|
87 |
+
git clone https://github.com/xtekky/gpt4free.git
|
88 |
+
cd gpt4free
|
89 |
+
pip install -r requirements-min.txt # Basic deps
|
90 |
+
pip install -r requirements.txt # Full deps
|
91 |
+
pip uninstall -y nodriver # CI requirement
|
92 |
+
pip install -e . # Editable install
|
93 |
+
python -m etc.unittest # Run tests
|
94 |
+
|
95 |
+
# Usage examples
|
96 |
+
g4f client "Hello world" # CLI chat
|
97 |
+
python -m g4f --port 8080 # Start server
|
98 |
+
python etc/examples/messages.py # Example script
|
99 |
+
```
|
100 |
+
|
101 |
+
### Installation Alternatives
|
102 |
+
- **PyPI**: `pip install -U g4f[all]` (external, not for development)
|
103 |
+
- **Docker**: Use provided docker-compose.yml for containerized deployment
|
104 |
+
- **Partial installs**: See https://github.com/gpt4free/g4f.dev/tree/main/docs for component-specific installs
|
105 |
+
|
106 |
+
### Known Issues and Workarounds
|
107 |
+
- **ffmpeg warning**: Expected from pydub library, does not affect functionality
|
108 |
+
- **Network timeouts**: Expected for many providers in isolated environments
|
109 |
+
- **Model availability**: Provider-dependent, some models may not be accessible
|
110 |
+
- **nodriver removal**: Required for CI compatibility, remove after full install
|
111 |
+
|
112 |
+
## Development Guidelines
|
113 |
+
|
114 |
+
### Making Changes
|
115 |
+
- Always run unit tests before and after changes: `python -m etc.unittest`
|
116 |
+
- Test both minimal and full installations when adding dependencies
|
117 |
+
- Validate CLI commands work: `g4f --help`, `g4f client --help`
|
118 |
+
- Test Python import: `python -c "import g4f; print('OK')"`
|
119 |
+
- For provider changes, test basic client creation and simple completions
|
120 |
+
|
121 |
+
### Before Committing
|
122 |
+
- Run full test suite: `python -m etc.unittest`
|
123 |
+
- Verify no new dependency conflicts
|
124 |
+
- Test installation from scratch in clean environment when possible
|
125 |
+
- Ensure backwards compatibility with Python 3.10+
|
126 |
+
|
127 |
+
### Timeout Guidelines
|
128 |
+
- Use 600+ second timeouts for `pip install -r requirements.txt`
|
129 |
+
- Use 120+ second timeouts for basic pip installations
|
130 |
+
- Use 30+ second timeouts for unit tests
|
131 |
+
- NEVER use default timeouts for package installations - they will fail
|
132 |
+
|
133 |
+
### Entry Points
|
134 |
+
- **CLI Binary**: `g4f` (installed via setuptools entry_points)
|
135 |
+
- **Module**: `python -m g4f`
|
136 |
+
- **Client Module**: `python -m g4f.client`
|
137 |
+
- **Python Import**: `import g4f` or `from g4f.client import Client`
|
gpt4free/.github/workflows/build-packages.yml
ADDED
@@ -0,0 +1,485 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Build All Packages
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
tags:
|
6 |
+
- '*'
|
7 |
+
workflow_dispatch:
|
8 |
+
inputs:
|
9 |
+
version:
|
10 |
+
description: 'Version to build (leave empty for auto)'
|
11 |
+
required: false
|
12 |
+
type: string
|
13 |
+
|
14 |
+
jobs:
|
15 |
+
prepare:
|
16 |
+
runs-on: ubuntu-latest
|
17 |
+
outputs:
|
18 |
+
version: ${{ steps.version.outputs.version }}
|
19 |
+
is_release: ${{ steps.version.outputs.is_release }}
|
20 |
+
steps:
|
21 |
+
- uses: actions/checkout@v4
|
22 |
+
- name: Determine version
|
23 |
+
id: version
|
24 |
+
run: |
|
25 |
+
if [[ "${{ github.ref }}" =~ ^refs/tags/ ]]; then
|
26 |
+
G4F_VERSION="${{ github.ref_name }}"
|
27 |
+
IS_RELEASE="true"
|
28 |
+
elif [[ -n "${{ inputs.version }}" ]]; then
|
29 |
+
G4F_VERSION="${{ inputs.version }}"
|
30 |
+
IS_RELEASE="false"
|
31 |
+
else
|
32 |
+
G4F_VERSION="0.0.0-dev"
|
33 |
+
IS_RELEASE="false"
|
34 |
+
fi
|
35 |
+
echo "version=${G4F_VERSION}" >> $GITHUB_OUTPUT
|
36 |
+
echo "is_release=${IS_RELEASE}" >> $GITHUB_OUTPUT
|
37 |
+
echo "Building version: ${G4F_VERSION}"
|
38 |
+
|
39 |
+
# PyPI Package
|
40 |
+
build-pypi:
|
41 |
+
runs-on: ubuntu-latest
|
42 |
+
needs: prepare
|
43 |
+
steps:
|
44 |
+
- uses: actions/checkout@v4
|
45 |
+
- name: Set up Python
|
46 |
+
uses: actions/setup-python@v5
|
47 |
+
with:
|
48 |
+
python-version: "3.x"
|
49 |
+
- name: Install build tools
|
50 |
+
run: |
|
51 |
+
python -m pip install --upgrade pip
|
52 |
+
python -m pip install build twine
|
53 |
+
- name: Build package
|
54 |
+
env:
|
55 |
+
G4F_VERSION: ${{ needs.prepare.outputs.version }}
|
56 |
+
run: python -m build
|
57 |
+
- name: Verify package
|
58 |
+
run: |
|
59 |
+
python -m twine check dist/*
|
60 |
+
ls -la dist/
|
61 |
+
- name: Upload PyPI artifacts
|
62 |
+
uses: actions/upload-artifact@v4
|
63 |
+
with:
|
64 |
+
name: pypi-package
|
65 |
+
path: dist/
|
66 |
+
|
67 |
+
# Windows Executables
|
68 |
+
build-windows-exe:
|
69 |
+
runs-on: windows-latest
|
70 |
+
needs: prepare
|
71 |
+
strategy:
|
72 |
+
matrix:
|
73 |
+
include:
|
74 |
+
- architecture: x64
|
75 |
+
runner-arch: x86_64
|
76 |
+
# Note: ARM64 cross-compilation on Windows requires additional setup
|
77 |
+
# Keeping architecture in matrix for future expansion
|
78 |
+
steps:
|
79 |
+
- uses: actions/checkout@v4
|
80 |
+
- name: Set up Python
|
81 |
+
uses: actions/setup-python@v5
|
82 |
+
with:
|
83 |
+
python-version: "3.11"
|
84 |
+
- name: Install dependencies
|
85 |
+
run: |
|
86 |
+
python -m pip install --upgrade pip
|
87 |
+
pip install -r requirements.txt
|
88 |
+
pip install nuitka
|
89 |
+
pip install -e .
|
90 |
+
- name: Write g4f_cli.py
|
91 |
+
shell: pwsh
|
92 |
+
run: |
|
93 |
+
@"
|
94 |
+
#!/usr/bin/env python3
|
95 |
+
"""
|
96 |
+
Entry point for g4f CLI executable builds
|
97 |
+
"""
|
98 |
+
|
99 |
+
import g4f.debug
|
100 |
+
g4f.debug.version_check = False
|
101 |
+
g4f.debug.version = "${{ needs.prepare.outputs.version }}"
|
102 |
+
|
103 |
+
if __name__ == "__main__":
|
104 |
+
from g4f.cli import main
|
105 |
+
main()
|
106 |
+
"@ | Set-Content -Path g4f_cli.py -Encoding utf8
|
107 |
+
- name: Build Windows executable with Nuitka
|
108 |
+
env:
|
109 |
+
G4F_VERSION: ${{ needs.prepare.outputs.version }}
|
110 |
+
PLATFORM: windows
|
111 |
+
ARCHITECTURE: ${{ matrix.runner-arch }}
|
112 |
+
shell: bash
|
113 |
+
run: |
|
114 |
+
chmod +x scripts/build-nuitka.sh
|
115 |
+
./scripts/build-nuitka.sh
|
116 |
+
- name: Zip Windows executable folder
|
117 |
+
shell: pwsh
|
118 |
+
run: |
|
119 |
+
$architecture = "${{ matrix.architecture }}"
|
120 |
+
$version = "${{ needs.prepare.outputs.version }}"
|
121 |
+
$exeName = "g4f-windows-${version}-${architecture}.exe"
|
122 |
+
if (Test-Path "dist\${exeName}") {
|
123 |
+
Compress-Archive "dist\${exeName}" "dist\g4f-windows-${version}-${architecture}.zip"
|
124 |
+
}
|
125 |
+
- name: Upload Windows zip archive
|
126 |
+
uses: actions/upload-artifact@v4
|
127 |
+
with:
|
128 |
+
name: windows-exe-${{ matrix.architecture }}
|
129 |
+
path: dist/g4f-windows-*.zip
|
130 |
+
|
131 |
+
# Linux Executables
|
132 |
+
build-linux-exe:
|
133 |
+
runs-on: ${{ matrix.runner }}
|
134 |
+
needs: prepare
|
135 |
+
strategy:
|
136 |
+
matrix:
|
137 |
+
include:
|
138 |
+
- architecture: x64
|
139 |
+
runner: ubuntu-latest
|
140 |
+
runner-arch: x86_64
|
141 |
+
- architecture: arm64
|
142 |
+
runner: ubuntu-24.04-arm
|
143 |
+
runner-arch: aarch64
|
144 |
+
steps:
|
145 |
+
- uses: actions/checkout@v4
|
146 |
+
- name: Set up Python
|
147 |
+
uses: actions/setup-python@v5
|
148 |
+
with:
|
149 |
+
python-version: "3.11"
|
150 |
+
- name: Install dependencies
|
151 |
+
run: |
|
152 |
+
python -m pip install --upgrade pip
|
153 |
+
pip install -r requirements.txt
|
154 |
+
pip install nuitka
|
155 |
+
pip install -e .
|
156 |
+
- name: Write g4f_cli.py
|
157 |
+
run: |
|
158 |
+
cat > g4f_cli.py << EOF
|
159 |
+
#!/usr/bin/env python3
|
160 |
+
"""
|
161 |
+
Entry point for g4f CLI executable builds
|
162 |
+
"""
|
163 |
+
|
164 |
+
import g4f.debug
|
165 |
+
g4f.debug.version_check = False
|
166 |
+
g4f.debug.version = "${{ needs.prepare.outputs.version }}"
|
167 |
+
|
168 |
+
if __name__ == "__main__":
|
169 |
+
from g4f.cli import main
|
170 |
+
main()
|
171 |
+
EOF
|
172 |
+
- name: Build Linux executable with Nuitka
|
173 |
+
env:
|
174 |
+
G4F_VERSION: ${{ needs.prepare.outputs.version }}
|
175 |
+
PLATFORM: linux
|
176 |
+
ARCHITECTURE: ${{ matrix.runner-arch }}
|
177 |
+
run: |
|
178 |
+
chmod +x scripts/build-nuitka.sh
|
179 |
+
./scripts/build-nuitka.sh
|
180 |
+
- name: Upload Linux executable
|
181 |
+
uses: actions/upload-artifact@v4
|
182 |
+
with:
|
183 |
+
name: linux-exe-${{ matrix.architecture }}
|
184 |
+
path: dist/g4f-linux-*
|
185 |
+
|
186 |
+
# macOS Executables
|
187 |
+
build-macos-exe:
|
188 |
+
runs-on: macos-latest
|
189 |
+
needs: prepare
|
190 |
+
strategy:
|
191 |
+
matrix:
|
192 |
+
include:
|
193 |
+
- architecture: x64
|
194 |
+
runner-arch: x86_64
|
195 |
+
- architecture: arm64
|
196 |
+
runner-arch: arm64
|
197 |
+
steps:
|
198 |
+
- uses: actions/checkout@v4
|
199 |
+
- name: Set up Python
|
200 |
+
uses: actions/setup-python@v5
|
201 |
+
with:
|
202 |
+
python-version: "3.11"
|
203 |
+
- name: Install dependencies
|
204 |
+
run: |
|
205 |
+
python -m pip install --upgrade pip
|
206 |
+
pip install -r requirements.txt
|
207 |
+
pip install nuitka
|
208 |
+
pip install -e .
|
209 |
+
- name: Write g4f_cli.py
|
210 |
+
run: |
|
211 |
+
cat > g4f_cli.py << EOF
|
212 |
+
#!/usr/bin/env python3
|
213 |
+
"""
|
214 |
+
Entry point for g4f CLI executable builds
|
215 |
+
"""
|
216 |
+
|
217 |
+
import g4f.debug
|
218 |
+
g4f.debug.version_check = False
|
219 |
+
g4f.debug.version = "${{ needs.prepare.outputs.version }}"
|
220 |
+
|
221 |
+
if __name__ == "__main__":
|
222 |
+
from g4f.cli import main
|
223 |
+
main()
|
224 |
+
EOF
|
225 |
+
- name: Build macOS executable with Nuitka
|
226 |
+
env:
|
227 |
+
G4F_VERSION: ${{ needs.prepare.outputs.version }}
|
228 |
+
PLATFORM: darwin
|
229 |
+
ARCHITECTURE: ${{ matrix.runner-arch }}
|
230 |
+
run: |
|
231 |
+
chmod +x scripts/build-nuitka.sh
|
232 |
+
./scripts/build-nuitka.sh
|
233 |
+
- name: Upload macOS executable
|
234 |
+
uses: actions/upload-artifact@v4
|
235 |
+
with:
|
236 |
+
name: macos-exe-${{ matrix.architecture }}
|
237 |
+
path: dist/g4f-macos-*
|
238 |
+
|
239 |
+
# Docker Images
|
240 |
+
build-docker:
|
241 |
+
runs-on: ubuntu-latest
|
242 |
+
needs: prepare
|
243 |
+
if: needs.prepare.outputs.is_release == 'true'
|
244 |
+
steps:
|
245 |
+
- name: Checkout repository
|
246 |
+
uses: actions/checkout@v4
|
247 |
+
- name: Set up QEMU
|
248 |
+
uses: docker/setup-qemu-action@v3
|
249 |
+
- name: Set up Docker Buildx
|
250 |
+
uses: docker/setup-buildx-action@v3
|
251 |
+
- name: Get metadata for Docker
|
252 |
+
id: metadata
|
253 |
+
uses: docker/metadata-action@v5
|
254 |
+
with:
|
255 |
+
images: |
|
256 |
+
hlohaus789/g4f
|
257 |
+
- name: Log in to Docker Hub
|
258 |
+
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
259 |
+
with:
|
260 |
+
username: ${{ secrets.DOCKER_USERNAME }}
|
261 |
+
password: ${{ secrets.DOCKER_PASSWORD }}
|
262 |
+
- name: Build and push armv7 image
|
263 |
+
uses: docker/build-push-action@v5
|
264 |
+
with:
|
265 |
+
context: .
|
266 |
+
file: docker/Dockerfile-armv7
|
267 |
+
platforms: linux/arm/v7
|
268 |
+
push: true
|
269 |
+
tags: |
|
270 |
+
hlohaus789/g4f:latest-armv7
|
271 |
+
hlohaus789/g4f:${{ needs.prepare.outputs.version }}-armv7
|
272 |
+
labels: ${{ steps.metadata.outputs.labels }}
|
273 |
+
build-args: |
|
274 |
+
G4F_VERSION=${{ needs.prepare.outputs.version }}
|
275 |
+
- name: Build and push slim images
|
276 |
+
uses: docker/build-push-action@v5
|
277 |
+
with:
|
278 |
+
context: .
|
279 |
+
file: docker/Dockerfile-slim
|
280 |
+
platforms: linux/amd64,linux/arm64
|
281 |
+
push: true
|
282 |
+
tags: |
|
283 |
+
hlohaus789/g4f:latest-slim
|
284 |
+
hlohaus789/g4f:${{ needs.prepare.outputs.version }}-slim
|
285 |
+
labels: ${{ steps.metadata.outputs.labels }}
|
286 |
+
build-args: |
|
287 |
+
G4F_VERSION=${{ needs.prepare.outputs.version }}
|
288 |
+
- name: Build and push image
|
289 |
+
uses: docker/build-push-action@v5
|
290 |
+
with:
|
291 |
+
context: .
|
292 |
+
file: docker/Dockerfile
|
293 |
+
platforms: linux/amd64
|
294 |
+
push: true
|
295 |
+
tags: ${{ steps.metadata.outputs.tags }}
|
296 |
+
labels: ${{ steps.metadata.outputs.labels }}
|
297 |
+
build-args: |
|
298 |
+
G4F_VERSION=${{ needs.prepare.outputs.version }}
|
299 |
+
|
300 |
+
# Debian Packages
|
301 |
+
# build-debian:
|
302 |
+
# runs-on: ubuntu-latest
|
303 |
+
# needs: prepare
|
304 |
+
# strategy:
|
305 |
+
# matrix:
|
306 |
+
# architecture: [amd64, arm64, armhf]
|
307 |
+
# steps:
|
308 |
+
# - uses: actions/checkout@v4
|
309 |
+
# - name: Set up Python
|
310 |
+
# uses: actions/setup-python@v5
|
311 |
+
# with:
|
312 |
+
# python-version: "3.x"
|
313 |
+
# - name: Install build dependencies
|
314 |
+
# run: |
|
315 |
+
# sudo apt-get update
|
316 |
+
# sudo apt-get install -y dpkg-dev build-essential python3-setuptools
|
317 |
+
# python3 -m pip install --upgrade pip
|
318 |
+
# pip3 install -r requirements-min.txt
|
319 |
+
# pip3 install -e .
|
320 |
+
# - name: Build Debian package
|
321 |
+
# env:
|
322 |
+
# G4F_VERSION: ${{ needs.prepare.outputs.version }}
|
323 |
+
# ARCH: ${{ matrix.architecture }}
|
324 |
+
# run: |
|
325 |
+
# chmod +x scripts/build-deb.sh
|
326 |
+
# ./scripts/build-deb.sh
|
327 |
+
# - name: Upload Debian package
|
328 |
+
# uses: actions/upload-artifact@v4
|
329 |
+
# with:
|
330 |
+
# name: debian-${{ matrix.architecture }}
|
331 |
+
# path: g4f-*-${{ matrix.architecture }}.deb
|
332 |
+
|
333 |
+
# WinGet Package Manifest
|
334 |
+
create-winget-manifest:
|
335 |
+
runs-on: ubuntu-latest
|
336 |
+
needs: [prepare, build-windows-exe]
|
337 |
+
if: needs.prepare.outputs.is_release == 'true'
|
338 |
+
steps:
|
339 |
+
- uses: actions/checkout@v4
|
340 |
+
- name: Download Windows executable zip (x64)
|
341 |
+
uses: actions/download-artifact@v4
|
342 |
+
with:
|
343 |
+
name: windows-exe-x64
|
344 |
+
path: ./artifacts/x64
|
345 |
+
- name: Calculate hash and size of ZIP
|
346 |
+
id: hash
|
347 |
+
run: |
|
348 |
+
HASH_X64=$(sha256sum ./artifacts/x64/g4f-windows-*-x64.zip | cut -d' ' -f1)
|
349 |
+
echo "hash_x64=${HASH_X64}" >> $GITHUB_OUTPUT
|
350 |
+
SIZE_X64=$(stat -c%s ./artifacts/x64/g4f-windows-*-x64.zip)
|
351 |
+
echo "size_x64=${SIZE_X64}" >> $GITHUB_OUTPUT
|
352 |
+
- name: Create WinGet manifest
|
353 |
+
run: |
|
354 |
+
mkdir -p winget/manifests/g/g4f/${{ needs.prepare.outputs.version }}
|
355 |
+
|
356 |
+
# Version manifest
|
357 |
+
cat > winget/manifests/g/g4f/${{ needs.prepare.outputs.version }}/g4f.yaml << EOF
|
358 |
+
PackageIdentifier: g4f
|
359 |
+
PackageVersion: ${{ needs.prepare.outputs.version }}
|
360 |
+
DefaultLocale: en-US
|
361 |
+
ManifestType: version
|
362 |
+
ManifestVersion: 1.4.0
|
363 |
+
EOF
|
364 |
+
|
365 |
+
# Installer manifest
|
366 |
+
cat > winget/manifests/g/g4f/${{ needs.prepare.outputs.version }}/g4f.installer.yaml << EOF
|
367 |
+
PackageIdentifier: g4f
|
368 |
+
PackageVersion: ${{ needs.prepare.outputs.version }}
|
369 |
+
Installers:
|
370 |
+
- Architecture: x64
|
371 |
+
InstallerType: zip
|
372 |
+
NestedInstallerType: portable
|
373 |
+
NestedInstallerFiles:
|
374 |
+
- RelativeFilePath: g4f-windows-${{ needs.prepare.outputs.version }}-x64.exe
|
375 |
+
PortableCommandAlias: g4f
|
376 |
+
InstallerUrl: https://github.com/xtekky/gpt4free/releases/download/${{ needs.prepare.outputs.version }}/g4f-windows-${{ needs.prepare.outputs.version }}-x64.zip
|
377 |
+
InstallerSha256: ${{ steps.hash.outputs.hash_x64 }}
|
378 |
+
ManifestType: installer
|
379 |
+
ManifestVersion: 1.4.0
|
380 |
+
EOF
|
381 |
+
|
382 |
+
# Locale manifest
|
383 |
+
cat > winget/manifests/g/g4f/${{ needs.prepare.outputs.version }}/g4f.locale.en-US.yaml << EOF
|
384 |
+
PackageIdentifier: g4f
|
385 |
+
PackageVersion: ${{ needs.prepare.outputs.version }}
|
386 |
+
PackageLocale: en-US
|
387 |
+
Publisher: GPT4Free
|
388 |
+
PublisherUrl: https://github.com/xtekky/gpt4free
|
389 |
+
PackageName: g4f
|
390 |
+
PackageUrl: https://github.com/xtekky/gpt4free
|
391 |
+
License: GPL-3.0
|
392 |
+
LicenseUrl: https://github.com/xtekky/gpt4free/blob/main/LICENSE
|
393 |
+
ShortDescription: The official gpt4free repository
|
394 |
+
Description: Various collection of powerful language models
|
395 |
+
Tags:
|
396 |
+
- ai
|
397 |
+
- gpt
|
398 |
+
- chatgpt
|
399 |
+
- openai
|
400 |
+
- free
|
401 |
+
- client
|
402 |
+
ManifestType: defaultLocale
|
403 |
+
ManifestVersion: 1.4.0
|
404 |
+
EOF
|
405 |
+
- name: Upload WinGet manifest
|
406 |
+
uses: actions/upload-artifact@v4
|
407 |
+
with:
|
408 |
+
name: winget-manifest
|
409 |
+
path: winget/
|
410 |
+
|
411 |
+
# Release Creation
|
412 |
+
create-release:
|
413 |
+
runs-on: ubuntu-latest
|
414 |
+
needs: [prepare, build-pypi, build-windows-exe, build-linux-exe, build-macos-exe, create-winget-manifest]
|
415 |
+
if: needs.prepare.outputs.is_release == 'true'
|
416 |
+
permissions:
|
417 |
+
contents: write
|
418 |
+
steps:
|
419 |
+
- uses: actions/checkout@v4
|
420 |
+
- name: Download all artifacts
|
421 |
+
uses: actions/download-artifact@v4
|
422 |
+
with:
|
423 |
+
path: ./artifacts
|
424 |
+
- name: Display artifact structure
|
425 |
+
run: |
|
426 |
+
echo "Downloaded artifacts:"
|
427 |
+
find ./artifacts -type f -name "*" | sort
|
428 |
+
- name: Create Release with Assets
|
429 |
+
uses: softprops/action-gh-release@v2
|
430 |
+
with:
|
431 |
+
tag_name: ${{ needs.prepare.outputs.version }}
|
432 |
+
name: Release ${{ needs.prepare.outputs.version }}
|
433 |
+
body: |
|
434 |
+
## g4f ${{ needs.prepare.outputs.version }}
|
435 |
+
|
436 |
+
### Download Options
|
437 |
+
|
438 |
+
**Python Package:**
|
439 |
+
- PyPI: `pip install g4f==${{ needs.prepare.outputs.version }}`
|
440 |
+
|
441 |
+
**Executables:**
|
442 |
+
- Windows x64: `g4f-windows-${{ needs.prepare.outputs.version }}-x64.zip`
|
443 |
+
- Linux x64: `g4f-linux-${{ needs.prepare.outputs.version }}-x64`
|
444 |
+
- Linux ARM64: `g4f-linux-${{ needs.prepare.outputs.version }}-arm64`
|
445 |
+
- macOS x64: `g4f-macos-${{ needs.prepare.outputs.version }}-x64`
|
446 |
+
- macOS ARM64: `g4f-macos-${{ needs.prepare.outputs.version }}-arm64`
|
447 |
+
|
448 |
+
**System Packages:**
|
449 |
+
- WinGet: `winget install g4f` (after manifest approval)
|
450 |
+
|
451 |
+
**Docker:**
|
452 |
+
- `docker pull hlohaus789/g4f:${{ needs.prepare.outputs.version }}`
|
453 |
+
- `docker pull hlohaus789/g4f:${{ needs.prepare.outputs.version }}-slim`
|
454 |
+
draft: false
|
455 |
+
prerelease: false
|
456 |
+
files: |
|
457 |
+
./artifacts/pypi-package/*
|
458 |
+
./artifacts/windows-exe-x64/*
|
459 |
+
./artifacts/linux-exe-x64/*
|
460 |
+
./artifacts/linux-exe-arm64/*
|
461 |
+
./artifacts/macos-exe-x64/*
|
462 |
+
./artifacts/macos-exe-arm64/*
|
463 |
+
./artifacts/debian-amd64/*
|
464 |
+
./artifacts/debian-arm64/*
|
465 |
+
./artifacts/debian-armhf/*
|
466 |
+
token: ${{ secrets.GITHUB_TOKEN }}
|
467 |
+
|
468 |
+
# Publish to PyPI (only for releases)
|
469 |
+
# publish-pypi:
|
470 |
+
# runs-on: ubuntu-latest
|
471 |
+
# needs: [prepare, build-pypi, create-release]
|
472 |
+
# if: needs.prepare.outputs.is_release == 'true'
|
473 |
+
# environment:
|
474 |
+
# name: pypi
|
475 |
+
# url: https://pypi.org/p/g4f
|
476 |
+
# permissions:
|
477 |
+
# id-token: write
|
478 |
+
# steps:
|
479 |
+
# - name: Download PyPI artifacts
|
480 |
+
# uses: actions/download-artifact@v4
|
481 |
+
# with:
|
482 |
+
# name: pypi-package
|
483 |
+
# path: dist/
|
484 |
+
# - name: Publish to PyPI
|
485 |
+
# uses: pypa/gh-action-pypi-publish@release/v1
|
gpt4free/.github/workflows/close-inactive-issues.yml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Close inactive issues
|
2 |
+
|
3 |
+
on:
|
4 |
+
schedule:
|
5 |
+
- cron: "5 0 * * *"
|
6 |
+
|
7 |
+
jobs:
|
8 |
+
close-issues:
|
9 |
+
runs-on: ubuntu-latest
|
10 |
+
permissions:
|
11 |
+
issues: write
|
12 |
+
pull-requests: write
|
13 |
+
steps:
|
14 |
+
- uses: actions/stale@v5
|
15 |
+
with:
|
16 |
+
days-before-issue-stale: 7
|
17 |
+
days-before-issue-close: 7
|
18 |
+
|
19 |
+
days-before-pr-stale: 7
|
20 |
+
days-before-pr-close: 7
|
21 |
+
|
22 |
+
stale-issue-label: "stale"
|
23 |
+
stale-pr-label: "stale"
|
24 |
+
|
25 |
+
stale-issue-message: "Bumping this issue because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again."
|
26 |
+
close-issue-message: "Closing due to inactivity."
|
27 |
+
|
28 |
+
stale-pr-message: "Bumping this pull request because it has been open for 7 days with no activity. Closing automatically in 7 days unless it becomes active again."
|
29 |
+
close-pr-message: "Closing due to inactivity."
|
30 |
+
|
31 |
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
gpt4free/.github/workflows/copilot.yml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: AI Code Reviewer
|
2 |
+
|
3 |
+
on:
|
4 |
+
workflow_run:
|
5 |
+
workflows: ["Unittest"]
|
6 |
+
types:
|
7 |
+
- completed
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
review:
|
11 |
+
runs-on: ubuntu-latest
|
12 |
+
permissions:
|
13 |
+
contents: read
|
14 |
+
pull-requests: write
|
15 |
+
steps:
|
16 |
+
- name: Checkout Repo
|
17 |
+
uses: actions/checkout@v3
|
18 |
+
- name: 'Download artifact'
|
19 |
+
uses: actions/github-script@v6
|
20 |
+
with:
|
21 |
+
script: |
|
22 |
+
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
|
23 |
+
owner: context.repo.owner,
|
24 |
+
repo: context.repo.repo,
|
25 |
+
run_id: context.payload.workflow_run.id,
|
26 |
+
});
|
27 |
+
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
|
28 |
+
return artifact.name == "pr_number"
|
29 |
+
})[0];
|
30 |
+
if (matchArtifact) {
|
31 |
+
core.setOutput("hasArtifact", "true");
|
32 |
+
let download = await github.rest.actions.downloadArtifact({
|
33 |
+
owner: context.repo.owner,
|
34 |
+
repo: context.repo.repo,
|
35 |
+
artifact_id: matchArtifact.id,
|
36 |
+
archive_format: 'zip',
|
37 |
+
});
|
38 |
+
let fs = require('fs');
|
39 |
+
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
|
40 |
+
}
|
41 |
+
- name: 'Unzip artifact'
|
42 |
+
if: ${{ hashFiles('pr_number.zip') != '' }}
|
43 |
+
run: unzip pr_number.zip
|
44 |
+
- name: Setup Python
|
45 |
+
uses: actions/setup-python@v4
|
46 |
+
with:
|
47 |
+
python-version: "3.x"
|
48 |
+
cache: 'pip'
|
49 |
+
- name: Install Requirements
|
50 |
+
run: |
|
51 |
+
pip install -r requirements.txt
|
52 |
+
pip install PyGithub
|
53 |
+
- name: AI Code Review
|
54 |
+
env:
|
55 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
56 |
+
GITHUB_REPOSITORY: ${{ github.repository }}
|
57 |
+
run: python -m etc.tool.copilot
|
gpt4free/.github/workflows/publish-to-pypi.yml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Publish Python 🐍 distribution 📦 to PyPI
|
2 |
+
|
3 |
+
on: push
|
4 |
+
|
5 |
+
env:
|
6 |
+
G4F_VERSION: ${{ github.ref_name }}
|
7 |
+
|
8 |
+
jobs:
|
9 |
+
build:
|
10 |
+
name: Build distribution 📦
|
11 |
+
if: github.repository == 'xtekky/gpt4free' && startsWith(github.ref, 'refs/tags/')
|
12 |
+
runs-on: ubuntu-latest
|
13 |
+
steps:
|
14 |
+
- uses: actions/checkout@v4
|
15 |
+
- name: Set up Python
|
16 |
+
uses: actions/setup-python@v4
|
17 |
+
with:
|
18 |
+
python-version: "3.x"
|
19 |
+
- name: Install pypa/build
|
20 |
+
run: >-
|
21 |
+
python3 -m
|
22 |
+
pip install
|
23 |
+
build
|
24 |
+
--user
|
25 |
+
- name: Build a binary wheel and a source tarball
|
26 |
+
run: python3 -m build
|
27 |
+
- name: Store the distribution packages
|
28 |
+
uses: actions/upload-artifact@v4
|
29 |
+
with:
|
30 |
+
name: python-package-distributions
|
31 |
+
path: dist/
|
32 |
+
|
33 |
+
publish-to-pypi:
|
34 |
+
name: >-
|
35 |
+
Publish distribution on PyPI 🐍
|
36 |
+
needs:
|
37 |
+
- build
|
38 |
+
runs-on: ubuntu-latest
|
39 |
+
environment:
|
40 |
+
name: pypi
|
41 |
+
url: https://pypi.org/p/g4f
|
42 |
+
permissions:
|
43 |
+
id-token: write
|
44 |
+
steps:
|
45 |
+
- name: Download all the dists
|
46 |
+
uses: actions/download-artifact@v4
|
47 |
+
with:
|
48 |
+
name: python-package-distributions
|
49 |
+
path: dist/
|
50 |
+
- name: Publish distribution 📦 to PyPI
|
51 |
+
uses: pypa/gh-action-pypi-publish@release/v1
|
gpt4free/.github/workflows/unittest.yml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Unittest
|
2 |
+
|
3 |
+
on:
|
4 |
+
pull_request:
|
5 |
+
types:
|
6 |
+
- opened
|
7 |
+
- synchronize
|
8 |
+
push:
|
9 |
+
branches:
|
10 |
+
- 'main'
|
11 |
+
|
12 |
+
jobs:
|
13 |
+
build:
|
14 |
+
name: Build unittest
|
15 |
+
runs-on: ubuntu-latest
|
16 |
+
steps:
|
17 |
+
- uses: actions/checkout@v4
|
18 |
+
- name: Set up Python 3.8
|
19 |
+
uses: actions/setup-python@v4
|
20 |
+
with:
|
21 |
+
python-version: "3.8"
|
22 |
+
cache: 'pip'
|
23 |
+
- name: Install min requirements
|
24 |
+
run: pip install -r requirements-min.txt
|
25 |
+
- name: Run tests
|
26 |
+
run: python -m etc.unittest
|
27 |
+
- name: Set up Python 3.12
|
28 |
+
uses: actions/setup-python@v4
|
29 |
+
with:
|
30 |
+
python-version: "3.12"
|
31 |
+
cache: 'pip'
|
32 |
+
- name: Install requirements
|
33 |
+
run: |
|
34 |
+
pip install -r requirements.txt
|
35 |
+
pip uninstall -y nodriver
|
36 |
+
- name: Run tests
|
37 |
+
run: python -m etc.unittest
|
38 |
+
- name: Save PR number
|
39 |
+
env:
|
40 |
+
PR_NUMBER: ${{ github.event.number }}
|
41 |
+
run: |
|
42 |
+
mkdir -p ./pr
|
43 |
+
echo $PR_NUMBER > ./pr/pr_number
|
44 |
+
- uses: actions/upload-artifact@v4
|
45 |
+
with:
|
46 |
+
name: pr_number
|
47 |
+
path: pr/
|
gpt4free/.gitignore
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Default ignored files
|
2 |
+
/shelf/
|
3 |
+
/workspace.xml
|
4 |
+
# Editor-based HTTP Client requests
|
5 |
+
/httpRequests/
|
6 |
+
# Datasource local storage ignored files
|
7 |
+
/dataSources/
|
8 |
+
/dataSources.local.xml
|
9 |
+
|
10 |
+
# Ignore local python virtual environment
|
11 |
+
venv/
|
12 |
+
|
13 |
+
# Ignore streamlit_chat_app.py conversations pickle
|
14 |
+
conversations.pkl
|
15 |
+
*.pkl
|
16 |
+
.idea/
|
17 |
+
**/__pycache__/
|
18 |
+
__pycache__/
|
19 |
+
|
20 |
+
*.log
|
21 |
+
*.pyc
|
22 |
+
*.egg-info/
|
23 |
+
*.egg
|
24 |
+
*.egg-info
|
25 |
+
.DS_Store
|
26 |
+
*~
|
27 |
+
*.gguf
|
28 |
+
.buildozer
|
29 |
+
har_and_cookies
|
30 |
+
node_modules
|
31 |
+
models
|
32 |
+
projects/windows/g4f
|
33 |
+
generated_images/
|
34 |
+
generated_media/
|
35 |
+
projects/windows/
|
36 |
+
|
37 |
+
*.bak
|
38 |
+
*.backup
|
39 |
+
.env
|
40 |
+
g4f.dev/
|
41 |
+
|
42 |
+
# Build artifacts
|
43 |
+
build/
|
44 |
+
dist/
|
45 |
+
*.spec
|
46 |
+
pyproject.toml.bak
|
47 |
+
debian/
|
48 |
+
winget/
|
gpt4free/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributor Covenant Code of Conduct
|
2 |
+
|
3 |
+
## Our Pledge
|
4 |
+
|
5 |
+
We as members, contributors, and leaders pledge to make participation in our
|
6 |
+
community a harassment-free experience for everyone, regardless of age, body
|
7 |
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8 |
+
identity and expression, level of experience, education, socio-economic status,
|
9 |
+
nationality, personal appearance, race, religion, or sexual identity
|
10 |
+
and orientation.
|
11 |
+
|
12 |
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13 |
+
diverse, inclusive, and healthy community.
|
14 |
+
|
15 |
+
## Our Standards
|
16 |
+
|
17 |
+
Examples of behavior that contributes to a positive environment for our
|
18 |
+
community include:
|
19 |
+
|
20 |
+
* Demonstrating empathy and kindness toward other people
|
21 |
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22 |
+
* Giving and gracefully accepting constructive feedback
|
23 |
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24 |
+
and learning from the experience
|
25 |
+
* Focusing on what is best not just for us as individuals, but for the
|
26 |
+
overall community
|
27 |
+
|
28 |
+
Examples of unacceptable behavior include:
|
29 |
+
|
30 |
+
* The use of sexualized language or imagery, and sexual attention or
|
31 |
+
advances of any kind
|
32 |
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33 |
+
* Public or private harassment
|
34 |
+
* Publishing others' private information, such as a physical or email
|
35 |
+
address, without their explicit permission
|
36 |
+
* Other conduct which could reasonably be considered inappropriate in a
|
37 |
+
professional setting
|
38 |
+
|
39 |
+
## Enforcement Responsibilities
|
40 |
+
|
41 |
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42 |
+
acceptable behavior and will take appropriate and fair corrective action in
|
43 |
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44 |
+
or harmful.
|
45 |
+
|
46 |
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47 |
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48 |
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49 |
+
decisions when appropriate.
|
50 |
+
|
51 |
+
## Scope
|
52 |
+
|
53 |
+
This Code of Conduct applies within all community spaces, and also applies when
|
54 |
+
an individual is officially representing the community in public spaces.
|
55 |
+
Examples of representing our community include using an official e-mail address,
|
56 |
+
posting via an official social media account, or acting as an appointed
|
57 |
+
representative at an online or offline event.
|
58 |
+
|
59 |
+
## Enforcement
|
60 |
+
|
61 |
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62 |
+
reported to the community leaders responsible for enforcement at
|
63 |
+
https://t.me/xtekky.
|
64 |
+
All complaints will be reviewed and investigated promptly and fairly.
|
65 |
+
|
66 |
+
All community leaders are obligated to respect the privacy and security of the
|
67 |
+
reporter of any incident.
|
68 |
+
|
69 |
+
## Enforcement Guidelines
|
70 |
+
|
71 |
+
Community leaders will follow these Community Impact Guidelines in determining
|
72 |
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73 |
+
|
74 |
+
### 1. Correction
|
75 |
+
|
76 |
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77 |
+
unprofessional or unwelcome in the community.
|
78 |
+
|
79 |
+
**Consequence**: A private, written warning from community leaders, providing
|
80 |
+
clarity around the nature of the violation and an explanation of why the
|
81 |
+
behavior was inappropriate. A public apology may be requested.
|
82 |
+
|
83 |
+
### 2. Warning
|
84 |
+
|
85 |
+
**Community Impact**: A violation through a single incident or series
|
86 |
+
of actions.
|
87 |
+
|
88 |
+
**Consequence**: A warning with consequences for continued behavior. No
|
89 |
+
interaction with the people involved, including unsolicited interaction with
|
90 |
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91 |
+
includes avoiding interactions in community spaces as well as external channels
|
92 |
+
like social media. Violating these terms may lead to a temporary or
|
93 |
+
permanent ban.
|
94 |
+
|
95 |
+
### 3. Temporary Ban
|
96 |
+
|
97 |
+
**Community Impact**: A serious violation of community standards, including
|
98 |
+
sustained inappropriate behavior.
|
99 |
+
|
100 |
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101 |
+
communication with the community for a specified period of time. No public or
|
102 |
+
private interaction with the people involved, including unsolicited interaction
|
103 |
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104 |
+
Violating these terms may lead to a permanent ban.
|
105 |
+
|
106 |
+
### 4. Permanent Ban
|
107 |
+
|
108 |
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109 |
+
standards, including sustained inappropriate behavior, harassment of an
|
110 |
+
individual, or aggression toward or disparagement of classes of individuals.
|
111 |
+
|
112 |
+
**Consequence**: A permanent ban from any sort of public interaction within
|
113 |
+
the community.
|
114 |
+
|
115 |
+
## Attribution
|
116 |
+
|
117 |
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118 |
+
version 2.0, available at
|
119 |
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
120 |
+
|
121 |
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
122 |
+
enforcement ladder](https://github.com/mozilla/diversity).
|
123 |
+
|
124 |
+
[homepage]: https://www.contributor-covenant.org
|
125 |
+
|
126 |
+
For answers to common questions about this code of conduct, see the FAQ at
|
127 |
+
https://www.contributor-covenant.org/faq. Translations are available at
|
128 |
+
https://www.contributor-covenant.org/translations.
|
gpt4free/CONTRIBUTING.md
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<img alt="gpt4free logo" src="https://user-images.githubusercontent.com/98614666/233799515-1a7cb6a3-b17f-42c4-956d-8d2a0664466f.png">
|
2 |
+
|
3 |
+
### Please, follow these steps to contribute:
|
4 |
+
1. Reverse a website from this list: [sites-to-reverse](https://github.com/xtekky/gpt4free/issues/40)
|
5 |
+
2. Add it to [./etc/unittest/](https://github.com/xtekky/gpt4free/tree/main/etc/unittest/)
|
6 |
+
3. Refactor it and add it to [./g4f](https://github.com/xtekky/gpt4free/tree/main/g4f)
|
7 |
+
|
8 |
+
### We will be grateful to see you as a contributor!
|
gpt4free/LEGAL_NOTICE.md
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Legal Notice
|
2 |
+
|
3 |
+
This repository is **not associated with or endorsed** by the providers of the APIs contained herein. This project is intended **for educational purposes only**. It is a personal project aimed at learning and exploration. Owners of any included sites or services may contact me to improve their security or request the removal of their content from this repository.
|
4 |
+
|
5 |
+
### **Affiliation Disclaimer**
|
6 |
+
|
7 |
+
This repository is not associated with or endorsed by any of the API providers mentioned herein. All trademarks, API services, and other intellectual property referenced are the property of their respective owners. No claim of ownership or affiliation is made by this project.
|
8 |
+
|
9 |
+
### **Liability Limitation**
|
10 |
+
|
11 |
+
Under no circumstances shall the author of this repository be liable for any direct, indirect, incidental, special, consequential, or punitive damages—including but not limited to loss of profits, data, or use—arising out of or in connection with the repository. This limitation applies regardless of whether such damages were foreseeable or whether the author was advised of the possibility of such damages.
|
12 |
+
|
13 |
+
### **No Warranties**
|
14 |
+
|
15 |
+
This repository is provided on an "as is" and "as available" basis without any warranties of any kind, express or implied. This includes, but is not limited to, implied warranties of merchantability, fitness for a particular purpose, and non-infringement.
|
16 |
+
|
17 |
+
### **User Responsibility**
|
18 |
+
|
19 |
+
Users assume all risks associated with the use of this repository. They are solely responsible for any damage or loss—including financial loss—that results from the use or misuse of the repository and its contents.
|
20 |
+
|
21 |
+
### **Legal Compliance**
|
22 |
+
|
23 |
+
Users are responsible for ensuring that their use of the repository and its contents complies with all applicable local, state, national, and international laws and regulations.
|
24 |
+
|
25 |
+
### **Indemnification**
|
26 |
+
|
27 |
+
Users agree to indemnify, defend, and hold harmless the author from any claims, liabilities, damages, losses, or expenses—including legal fees—arising out of or in any way connected with their use of this repository, violation of these terms, or infringement of any intellectual property or other rights of any person or entity.
|
28 |
+
|
29 |
+
### **No Endorsement**
|
30 |
+
|
31 |
+
The inclusion of third-party content does not imply endorsement or recommendation of such content by the author.
|
32 |
+
|
33 |
+
### **Governing Law and Jurisdiction**
|
34 |
+
|
35 |
+
Any disputes arising out of or related to the use of this repository shall be governed by the laws of the author's jurisdiction, without regard to conflict of law principles.
|
36 |
+
|
37 |
+
### **Severability**
|
38 |
+
|
39 |
+
If any provision of this notice is found to be unlawful, void, or unenforceable, that provision shall be deemed severable from this notice and shall not affect the validity and enforceability of the remaining provisions.
|
40 |
+
|
41 |
+
### **Acknowledgment of Understanding**
|
42 |
+
|
43 |
+
By using this repository, users acknowledge that they have read, understood, and agree to be bound by these terms.
|
44 |
+
|
45 |
+
### **Updates and Changes**
|
46 |
+
|
47 |
+
The author reserves the right to modify, update, or remove any content, information, or features in this repository at any time without prior notice. Users are responsible for regularly reviewing the content and any changes made to this repository.
|
48 |
+
|
49 |
+
### **Unforeseen Consequences**
|
50 |
+
|
51 |
+
The author is not responsible for any consequences, damages, or losses arising from the use or misuse of this repository or the content provided by third-party APIs. Users are solely responsible for their actions and any repercussions that may follow.
|
52 |
+
|
53 |
+
### **Educational Purpose**
|
54 |
+
|
55 |
+
This project and its content are provided strictly for educational purposes. Users acknowledge that they are using the APIs and models at their own risk and agree to comply with all applicable laws and regulations.
|
gpt4free/LICENSE
ADDED
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
+
your programs, too.
|
21 |
+
|
22 |
+
When we speak of free software, we are referring to freedom, not
|
23 |
+
price. Our General Public Licenses are designed to make sure that you
|
24 |
+
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
+
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
+
|
34 |
+
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
+
|
68 |
+
The precise terms and conditions for copying, distribution and
|
69 |
+
modification follow.
|
70 |
+
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
+
this License.
|
486 |
+
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
+
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
567 |
+
be similar in spirit to the present version, but may differ in detail to
|
568 |
+
address new problems or concerns.
|
569 |
+
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
+
|
621 |
+
END OF TERMS AND CONDITIONS
|
622 |
+
|
623 |
+
How to Apply These Terms to Your New Programs
|
624 |
+
|
625 |
+
If you develop a new program, and you want it to be of the greatest
|
626 |
+
possible use to the public, the best way to achieve this is to make it
|
627 |
+
free software which everyone can redistribute and change under these terms.
|
628 |
+
|
629 |
+
To do so, attach the following notices to the program. It is safest
|
630 |
+
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
633 |
+
|
634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
635 |
+
Copyright (C) <year> <name of author>
|
636 |
+
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
+
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
+
(at your option) any later version.
|
641 |
+
|
642 |
+
This program is distributed in the hope that it will be useful,
|
643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
+
GNU General Public License for more details.
|
646 |
+
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
649 |
+
|
650 |
+
Also add information on how to contact you by electronic and paper mail.
|
651 |
+
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
+
|
655 |
+
<program> Copyright (C) <year> <name of author>
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
+
This is free software, and you are welcome to redistribute it
|
658 |
+
under certain conditions; type `show c' for details.
|
659 |
+
|
660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<https://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
gpt4free/MANIFEST.in
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
recursive-include g4f/Provider/har *
|
gpt4free/README.md
ADDED
@@ -0,0 +1,489 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# GPT4Free (g4f)
|
2 |
+
|
3 |
+
[](https://pypi.org/project/g4f) [](https://hub.docker.com/r/hlohaus789/g4f) [](https://www.gnu.org/licenses/gpl-3.0.txt)
|
4 |
+
|
5 |
+
<p align="center">
|
6 |
+
<img src="https://github.com/user-attachments/assets/7f60c240-00fa-4c37-bf7f-ae5cc20906a1" alt="GPT4Free logo" height="200" />
|
7 |
+
</p>
|
8 |
+
|
9 |
+
<p align="center">
|
10 |
+
<span style="background: linear-gradient(45deg, #12c2e9, #c471ed, #f64f59); -webkit-background-clip: text; -webkit-text-fill-color: transparent;">
|
11 |
+
<strong>Created by <a href="https://github.com/xtekky">@xtekky</a>,<br> maintained by <a href="https://github.com/hlohaus">@hlohaus</a></strong>
|
12 |
+
</span>
|
13 |
+
</p>
|
14 |
+
<p align="center">
|
15 |
+
<span>Support the project on</span>
|
16 |
+
<a href="https://github.com/sponsors/hlohaus" target="_blank" rel="noopener noreferrer">
|
17 |
+
GitHub Sponsors
|
18 |
+
</a>
|
19 |
+
❤️
|
20 |
+
</p>
|
21 |
+
<p align="center">
|
22 |
+
Live demo & docs: https://g4f.dev | Documentation: https://g4f.dev/docs
|
23 |
+
</p>
|
24 |
+
|
25 |
+
---
|
26 |
+
|
27 |
+
GPT4Free (g4f) is a community-driven project that aggregates multiple accessible providers and interfaces to make working with modern LLMs and media-generation models easier and more flexible. GPT4Free aims to offer multi-provider support, local GUI, OpenAI-compatible REST APIs, and convenient Python and JavaScript clients — all under a community-first license.
|
28 |
+
|
29 |
+
This README is a consolidated, improved, and complete guide to installing, running, and contributing to GPT4Free.
|
30 |
+
|
31 |
+
Table of contents
|
32 |
+
- [What’s included](#whats-included)
|
33 |
+
- [Quick links](#quick-links)
|
34 |
+
- [Requirements & compatibility](#requirements--compatibility)
|
35 |
+
- [Installation](#installation)
|
36 |
+
- [Docker (recommended)](#docker-recommended)
|
37 |
+
- [Slim Docker image](#slim-docker-image)
|
38 |
+
- [Windows (.exe)](#windows-exe)
|
39 |
+
- [Python (pip / from source / partial installs)](#python-pip--from-source--partial-installs)
|
40 |
+
- [Running the app](#running-the-app)
|
41 |
+
- [GUI (web client)](#gui-web-client)
|
42 |
+
- [FastAPI / Interference API](#fastapi--interference-api)
|
43 |
+
- [CLI](#cli)
|
44 |
+
- [Optional provider login (desktop in container)](#optional-provider-login-desktop-in-container)
|
45 |
+
- [Using the Python client](#using-the-python-client)
|
46 |
+
- [Synchronous text example](#synchronous-text-example)
|
47 |
+
- [Image generation example](#image-generation-example)
|
48 |
+
- [Async client example](#async-client-example)
|
49 |
+
- [Using GPT4Free.js (browser JS client)](#using-gpt4freejs-browser-js-client)
|
50 |
+
- [Providers & models (overview)](#providers--models-overview)
|
51 |
+
- [Local inference & media](#local-inference--media)
|
52 |
+
- [Configuration & customization](#configuration--customization)
|
53 |
+
- [Running on smartphone](#running-on-smartphone)
|
54 |
+
- [Interference API (OpenAI‑compatible)](#interference-api-openai-compatible)
|
55 |
+
- [Examples & common patterns](#examples--common-patterns)
|
56 |
+
- [Contributing](#contributing)
|
57 |
+
- [How to create a new provider](#how-to-create-a-new-provider)
|
58 |
+
- [How AI can help you write code](#how-ai-can-help-you-write-code)
|
59 |
+
- [Security, privacy & takedown policy](#security-privacy--takedown-policy)
|
60 |
+
- [Credits, contributors & attribution](#credits-contributors--attribution)
|
61 |
+
- [Powered-by highlights](#powered-by-highlights)
|
62 |
+
- [Changelog & releases](#changelog--releases)
|
63 |
+
- [Manifesto / Project principles](#manifesto--project-principles)
|
64 |
+
- [License](#license)
|
65 |
+
- [Contact & sponsorship](#contact--sponsorship)
|
66 |
+
- [Appendix: Quick commands & examples](#appendix-quick-commands--examples)
|
67 |
+
|
68 |
+
---
|
69 |
+
|
70 |
+
## What’s included
|
71 |
+
- Python client library and async client.
|
72 |
+
- Optional local web GUI.
|
73 |
+
- FastAPI-based OpenAI-compatible API (Interference API).
|
74 |
+
- Official browser JS client (g4f.dev distribution).
|
75 |
+
- Docker images (full and slim).
|
76 |
+
- Multi-provider adapters (LLMs, media providers, local inference backends).
|
77 |
+
- Tooling for image/audio/video generation and media persistence.
|
78 |
+
|
79 |
+
---
|
80 |
+
|
81 |
+
## Quick links
|
82 |
+
- Website & docs: https://g4f.dev | https://g4f.dev/docs
|
83 |
+
- PyPI: https://pypi.org/project/g4f
|
84 |
+
- Docker image: https://hub.docker.com/r/hlohaus789/g4f
|
85 |
+
- Releases: https://github.com/xtekky/gpt4free/releases
|
86 |
+
- Issues: https://github.com/xtekky/gpt4free/issues
|
87 |
+
- Community: Telegram (https://telegram.me/g4f_channel) · Discord News (https://discord.gg/5E39JUWUFa) · Discord Support (https://discord.gg/qXA4Wf4Fsm)
|
88 |
+
|
89 |
+
---
|
90 |
+
|
91 |
+
## Requirements & compatibility
|
92 |
+
- Python 3.10+ recommended.
|
93 |
+
- Google Chrome/Chromium for providers using browser automation.
|
94 |
+
- Docker for containerized deployment.
|
95 |
+
- Works on x86_64 and arm64 (slim image supports both).
|
96 |
+
- Some provider adapters may require platform-specific tooling (Chrome/Chromium, etc.). Check provider docs for details.
|
97 |
+
|
98 |
+
---
|
99 |
+
|
100 |
+
## Installation
|
101 |
+
|
102 |
+
### Docker (recommended)
|
103 |
+
1. Install Docker: https://docs.docker.com/get-docker/
|
104 |
+
2. Create persistent directories:
|
105 |
+
- Example (Linux/macOS):
|
106 |
+
```bash
|
107 |
+
mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_media
|
108 |
+
sudo chown -R 1200:1201 ${PWD}/har_and_cookies ${PWD}/generated_media
|
109 |
+
```
|
110 |
+
3. Pull image:
|
111 |
+
```bash
|
112 |
+
docker pull hlohaus789/g4f
|
113 |
+
```
|
114 |
+
4. Run container:
|
115 |
+
```bash
|
116 |
+
docker run -p 8080:8080 -p 7900:7900 \
|
117 |
+
--shm-size="2g" \
|
118 |
+
-v ${PWD}/har_and_cookies:/app/har_and_cookies \
|
119 |
+
-v ${PWD}/generated_media:/app/generated_media \
|
120 |
+
hlohaus789/g4f:latest
|
121 |
+
```
|
122 |
+
Notes:
|
123 |
+
- Port 8080 serves GUI/API; 7900 can expose a VNC-like desktop for provider logins (optional).
|
124 |
+
- Increase --shm-size for heavier browser automation tasks.
|
125 |
+
|
126 |
+
### Slim Docker image (x64 & arm64)
|
127 |
+
```bash
|
128 |
+
mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_media
|
129 |
+
chown -R 1000:1000 ${PWD}/har_and_cookies ${PWD}/generated_media
|
130 |
+
|
131 |
+
docker run \
|
132 |
+
-p 1337:8080 -p 8080:8080 \
|
133 |
+
-v ${PWD}/har_and_cookies:/app/har_and_cookies \
|
134 |
+
-v ${PWD}/generated_media:/app/generated_media \
|
135 |
+
hlohaus789/g4f:latest-slim
|
136 |
+
```
|
137 |
+
Notes:
|
138 |
+
- The slim image can update the g4f package on startup and installs additional dependencies as needed.
|
139 |
+
- In this example, the Interference API is mapped to 1337.
|
140 |
+
|
141 |
+
### Windows Guide (.exe)
|
142 |
+
1. Download the release artifact `g4f.exe.zip` from:
|
143 |
+
https://github.com/xtekky/gpt4free/releases/latest
|
144 |
+
2. Unzip and run `g4f.exe`.
|
145 |
+
3. Open GUI at: http://localhost:8080/chat/
|
146 |
+
4. If Windows Firewall blocks access, allow the application.
|
147 |
+
|
148 |
+
### Python Installation (pip / from source / partial installs)
|
149 |
+
|
150 |
+
Prerequisites:
|
151 |
+
- Python 3.10+ (https://www.python.org/downloads/)
|
152 |
+
- Chrome/Chromium for some providers.
|
153 |
+
|
154 |
+
Install from PyPI (recommended):
|
155 |
+
```bash
|
156 |
+
pip install -U g4f[all]
|
157 |
+
```
|
158 |
+
|
159 |
+
Partial installs
|
160 |
+
- To install only specific functionality, use optional extras groups. See docs/requirements.md in the project docs.
|
161 |
+
|
162 |
+
Install from source:
|
163 |
+
```bash
|
164 |
+
git clone https://github.com/xtekky/gpt4free.git
|
165 |
+
cd gpt4free
|
166 |
+
pip install -r requirements.txt
|
167 |
+
pip install -e .
|
168 |
+
```
|
169 |
+
|
170 |
+
Notes:
|
171 |
+
- Some features require Chrome/Chromium or other tools; follow provider-specific docs.
|
172 |
+
|
173 |
+
---
|
174 |
+
|
175 |
+
## Running the app
|
176 |
+
|
177 |
+
### GUI (web client)
|
178 |
+
- Run via Python:
|
179 |
+
```python
|
180 |
+
from g4f.gui import run_gui
|
181 |
+
run_gui()
|
182 |
+
```
|
183 |
+
- Or via CLI:
|
184 |
+
```bash
|
185 |
+
python -m g4f.cli gui --port 8080 --debug
|
186 |
+
```
|
187 |
+
- Open: http://localhost:8080/chat/
|
188 |
+
|
189 |
+
### FastAPI / Interference API
|
190 |
+
- Start FastAPI server:
|
191 |
+
```bash
|
192 |
+
python -m g4f --port 8080 --debug
|
193 |
+
```
|
194 |
+
- If using slim docker mapping, Interference API may be available at `http://localhost:1337/v1`
|
195 |
+
- Swagger UI: `http://localhost:1337/docs`
|
196 |
+
|
197 |
+
### CLI
|
198 |
+
- Start GUI server:
|
199 |
+
```bash
|
200 |
+
python -m g4f.cli gui --port 8080 --debug
|
201 |
+
```
|
202 |
+
|
203 |
+
### Optional provider login (desktop within container)
|
204 |
+
- Accessible at:
|
205 |
+
```
|
206 |
+
http://localhost:7900/?autoconnect=1&resize=scale&password=secret
|
207 |
+
```
|
208 |
+
- Useful for logging into web-based providers to obtain cookies/HAR files.
|
209 |
+
|
210 |
+
---
|
211 |
+
|
212 |
+
## Using the Python client
|
213 |
+
|
214 |
+
Install:
|
215 |
+
```bash
|
216 |
+
pip install -U g4f[all]
|
217 |
+
```
|
218 |
+
|
219 |
+
Synchronous text example:
|
220 |
+
```python
|
221 |
+
from g4f.client import Client
|
222 |
+
|
223 |
+
client = Client()
|
224 |
+
response = client.chat.completions.create(
|
225 |
+
model="gpt-4o-mini",
|
226 |
+
messages=[{"role": "user", "content": "Hello, how are you?"}],
|
227 |
+
web_search=False
|
228 |
+
)
|
229 |
+
print(response.choices[0].message.content)
|
230 |
+
```
|
231 |
+
Expected:
|
232 |
+
```
|
233 |
+
Hello! How can I assist you today?
|
234 |
+
```
|
235 |
+
|
236 |
+
Image generation example:
|
237 |
+
```python
|
238 |
+
from g4f.client import Client
|
239 |
+
|
240 |
+
client = Client()
|
241 |
+
response = client.images.generate(
|
242 |
+
model="flux",
|
243 |
+
prompt="a white siamese cat",
|
244 |
+
response_format="url"
|
245 |
+
)
|
246 |
+
print(f"Generated image URL: {response.data[0].url}")
|
247 |
+
```
|
248 |
+
|
249 |
+
Async client example:
|
250 |
+
```python
|
251 |
+
from g4f.async_client import AsyncClient
|
252 |
+
import asyncio
|
253 |
+
|
254 |
+
async def main():
|
255 |
+
client = AsyncClient()
|
256 |
+
response = await client.chat.completions.create(
|
257 |
+
model="gpt-4o-mini",
|
258 |
+
messages=[{"role": "user", "content": "Explain quantum computing briefly"}],
|
259 |
+
)
|
260 |
+
print(response.choices[0].message.content)
|
261 |
+
|
262 |
+
asyncio.run(main())
|
263 |
+
```
|
264 |
+
|
265 |
+
Notes:
|
266 |
+
- See the full API reference for streaming, tool-calling patterns, and advanced options: https://g4f.dev/docs/client
|
267 |
+
|
268 |
+
---
|
269 |
+
|
270 |
+
## Using GPT4Free.js (browser JS client)
|
271 |
+
Use the official JS client in the browser—no backend required.
|
272 |
+
|
273 |
+
Example:
|
274 |
+
```html
|
275 |
+
<script type="module">
|
276 |
+
import Client from 'https://g4f.dev/dist/js/client.js';
|
277 |
+
|
278 |
+
const client = new Client();
|
279 |
+
const result = await client.chat.completions.create({
|
280 |
+
model: 'gpt-4.1', // Or "gpt-4o", "deepseek-v3", etc.
|
281 |
+
messages: [{ role: 'user', content: 'Explain quantum computing' }]
|
282 |
+
});
|
283 |
+
console.log(result.choices[0].message.content);
|
284 |
+
</script>
|
285 |
+
```
|
286 |
+
|
287 |
+
Notes:
|
288 |
+
- The JS client is distributed via the g4f.dev CDN for easy usage. Review CORS considerations and usage limits.
|
289 |
+
|
290 |
+
---
|
291 |
+
|
292 |
+
## Providers & models (overview)
|
293 |
+
- GPT4Free integrates many providers including (but not limited to) OpenAI-compatible endpoints, PerplexityLabs, Gemini, MetaAI, Pollinations (media), and local inference backends.
|
294 |
+
- Model availability and behavior depend on provider capabilities. See the providers doc for current, supported provider/model lists: https://g4f.dev/docs/providers-and-models
|
295 |
+
|
296 |
+
Provider requirements may include:
|
297 |
+
- API keys or tokens (for authenticated providers)
|
298 |
+
- Browser cookies / HAR files for providers scraped via browser automation
|
299 |
+
- Chrome/Chromium or headless browser tooling
|
300 |
+
- Local model binaries and runtime (for local inference)
|
301 |
+
|
302 |
+
---
|
303 |
+
|
304 |
+
## Local inference & media
|
305 |
+
- GPT4Free supports local inference backends. See [docs/local.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/local.md) for supported runtimes and hardware guidance.
|
306 |
+
- Media generation (image, audio, video) is supported through providers (e.g., Pollinations). See [docs/media.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/media.md) for formats, options, and sample usage.
|
307 |
+
|
308 |
+
---
|
309 |
+
|
310 |
+
## Configuration & customization
|
311 |
+
- Configure via environment variables, CLI flags, or config files. See [docs/config.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/config.md).
|
312 |
+
- To reduce install size, use partial requirement groups. See [docs/requirements.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/requirements.md).
|
313 |
+
- Provider selection: learn how to set defaults and override per-request at [docs/selecting_a_provider.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/selecting_a_provider.md).
|
314 |
+
- Persistence: HAR files, cookies, and generated media persist in mapped directories (e.g., har_and_cookies, generated_media).
|
315 |
+
|
316 |
+
---
|
317 |
+
|
318 |
+
## Running on smartphone
|
319 |
+
- The web GUI is responsive and can be accessed from a phone by visiting your host IP:8080 or via a tunnel. See [docs/guides/phone.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/guides/phone.md).
|
320 |
+
|
321 |
+
---
|
322 |
+
|
323 |
+
## Interference API (OpenAI‑compatible)
|
324 |
+
- The Interference API enables OpenAI-like workflows routed through GPT4Free provider selection.
|
325 |
+
- Docs: [docs/interference-api.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/interference-api.md)
|
326 |
+
- Default endpoint (example slim docker): `http://localhost:1337/v1`
|
327 |
+
- Swagger UI: `http://localhost:1337/docs`
|
328 |
+
|
329 |
+
---
|
330 |
+
|
331 |
+
## Examples & common patterns
|
332 |
+
- Streaming completions, stopping criteria, system messages, and tool-calling patterns are documented in:
|
333 |
+
- [docs/client.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/client.md)
|
334 |
+
- [docs/async_client.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/async_client.md)
|
335 |
+
- [docs/requests.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/requests.md)
|
336 |
+
- Integrations (LangChain, PydanticAI): [docs/pydantic_ai.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/pydantic_ai.md)
|
337 |
+
- Legacy examples: [docs/legacy.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/legacy.md)
|
338 |
+
|
339 |
+
---
|
340 |
+
|
341 |
+
## Contributing
|
342 |
+
Contributions are welcome — new providers, features, docs, and fixes are appreciated.
|
343 |
+
|
344 |
+
How to contribute:
|
345 |
+
1. Fork the repository.
|
346 |
+
2. Create a branch for your change.
|
347 |
+
3. Run tests and linters.
|
348 |
+
4. Open a Pull Request with a clear description and tests/examples if applicable.
|
349 |
+
|
350 |
+
Repository: https://github.com/xtekky/gpt4free
|
351 |
+
|
352 |
+
### How to create a new provider
|
353 |
+
- Read the guide: [docs/guides/create_provider.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/guides/create_provider.md)
|
354 |
+
- Typical steps:
|
355 |
+
- Implement a provider adapter in `g4f/Provider/`
|
356 |
+
- Add configuration and dependency notes
|
357 |
+
- Include tests and usage examples
|
358 |
+
- Respect third‑party code licenses and attribute appropriately
|
359 |
+
|
360 |
+
### How AI can help you write code
|
361 |
+
- See: [docs/guides/help_me.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/guides/help_me.md) for prompt templates and workflows to accelerate development.
|
362 |
+
|
363 |
+
---
|
364 |
+
|
365 |
+
## Security, privacy & takedown policy
|
366 |
+
- Do not store or share sensitive credentials. Use per-provider recommended security practices.
|
367 |
+
- If your site appears in the project’s links and you want it removed, send proof of ownership to takedown@g4f.ai and it will be removed promptly.
|
368 |
+
- For production, secure the server with HTTPS, authentication, and firewall rules. Limit access to provider credentials and cookie/HAR storage.
|
369 |
+
|
370 |
+
---
|
371 |
+
|
372 |
+
## Credits, contributors & attribution
|
373 |
+
- Core creators: [@xtekky](https://github.com/xtekky) (original), maintained by [@hlohaus](https://github.com/hlohaus).
|
374 |
+
- Full contributor graph: https://github.com/xtekky/gpt4free/graphs/contributors
|
375 |
+
- Notable code inputs and attributions:
|
376 |
+
- `har_file.py` — input from [xqdoo00o/ChatGPT-to-API](https://github.com/xqdoo00o/ChatGPT-to-API)
|
377 |
+
- `PerplexityLabs.py` — input from [nathanrchn/perplexityai](https://github.com/nathanrchn/perplexityai)
|
378 |
+
- `Gemini.py` — input from [dsdanielpark/Gemini-API](https://github.com/dsdanielpark/Gemini-API) and [HanaokaYuzu/Gemini-API](https://github.com/HanaokaYuzu/Gemini-API)
|
379 |
+
- `MetaAI.py` — inspired by [meta-ai-api by Strvm](https://github.com/Strvm/meta-ai-api)
|
380 |
+
- `proofofwork.py` — input from [missuo/FreeGPT35](https://github.com/missuo/FreeGPT35)
|
381 |
+
|
382 |
+
Many more contributors are acknowledged in the repository.
|
383 |
+
|
384 |
+
---
|
385 |
+
|
386 |
+
## Powered-by highlights
|
387 |
+
- Pollinations AI — generative media: https://github.com/pollinations/pollinations
|
388 |
+
- MoneyPrinter V2 — example project using GPT4Free: https://github.com/FujiwaraChoki/MoneyPrinterV2
|
389 |
+
- For a full list of projects and sites using GPT4Free, see: [docs/powered-by.md](https://github.com/gpt4free/g4f.dev/blob/main/docs/powered-by.md)
|
390 |
+
|
391 |
+
---
|
392 |
+
|
393 |
+
## Changelog & releases
|
394 |
+
- Releases and full changelog: https://github.com/xtekky/gpt4free/releases
|
395 |
+
- Subscribe to Discord/Telegram for announcements.
|
396 |
+
|
397 |
+
---
|
398 |
+
|
399 |
+
## Manifesto / Project principles
|
400 |
+
GPT4Free is guided by community principles:
|
401 |
+
1. Open access to AI tooling and models.
|
402 |
+
2. Collaboration across providers and projects.
|
403 |
+
3. Opposition to monopolistic, closed systems that restrict creativity.
|
404 |
+
4. Community-centered development and broad access to AI technologies.
|
405 |
+
5. Promote innovation, creativity, and accessibility.
|
406 |
+
|
407 |
+
https://g4f.dev/manifest
|
408 |
+
|
409 |
+
---
|
410 |
+
|
411 |
+
## License
|
412 |
+
This program is licensed under the GNU General Public License v3.0 (GPLv3). See the full license: https://www.gnu.org/licenses/gpl-3.0.txt
|
413 |
+
|
414 |
+
Summary:
|
415 |
+
- You may redistribute and/or modify under the terms of GPLv3.
|
416 |
+
- The program is provided WITHOUT ANY WARRANTY.
|
417 |
+
|
418 |
+
Copyright notice
|
419 |
+
```
|
420 |
+
xtekky/gpt4free: Copyright (C) 2025 xtekky
|
421 |
+
|
422 |
+
This program is free software: you can redistribute it and/or modify
|
423 |
+
it under the terms of the GNU General Public License as published by
|
424 |
+
the Free Software Foundation, either version 3 of the License, or
|
425 |
+
(at your option) any later version.
|
426 |
+
|
427 |
+
This program is distributed in the hope that it will be useful,
|
428 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
429 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
430 |
+
GNU General Public License for more details.
|
431 |
+
```
|
432 |
+
|
433 |
+
---
|
434 |
+
|
435 |
+
## Contact & sponsorship
|
436 |
+
- Maintainers: https://github.com/hlohaus
|
437 |
+
- Sponsorship: https://github.com/sponsors/hlohaus
|
438 |
+
- Issues & feature requests: https://github.com/xtekky/gpt4free/issues
|
439 |
+
- Takedown requests: takedown@g4f.ai
|
440 |
+
|
441 |
+
---
|
442 |
+
|
443 |
+
## Appendix: Quick commands & examples
|
444 |
+
|
445 |
+
Install (pip):
|
446 |
+
```bash
|
447 |
+
pip install -U g4f[all]
|
448 |
+
```
|
449 |
+
|
450 |
+
Run GUI (Python):
|
451 |
+
```bash
|
452 |
+
python -m g4f.cli gui --port 8080 --debug
|
453 |
+
# or
|
454 |
+
python -c "from g4f.gui import run_gui; run_gui()"
|
455 |
+
```
|
456 |
+
|
457 |
+
Docker (full):
|
458 |
+
```bash
|
459 |
+
docker pull hlohaus789/g4f
|
460 |
+
docker run -p 8080:8080 -p 7900:7900 \
|
461 |
+
--shm-size="2g" \
|
462 |
+
-v ${PWD}/har_and_cookies:/app/har_and_cookies \
|
463 |
+
-v ${PWD}/generated_media:/app/generated_media \
|
464 |
+
hlohaus789/g4f:latest
|
465 |
+
```
|
466 |
+
|
467 |
+
Docker (slim):
|
468 |
+
```bash
|
469 |
+
docker run -p 1337:8080 -p 8080:8080 \
|
470 |
+
-v ${PWD}/har_and_cookies:/app/har_and_cookies \
|
471 |
+
-v ${PWD}/generated_media:/app/generated_media \
|
472 |
+
hlohaus789/g4f:latest-slim
|
473 |
+
```
|
474 |
+
|
475 |
+
Python usage patterns:
|
476 |
+
- `client.chat.completions.create(...)`
|
477 |
+
- `client.images.generate(...)`
|
478 |
+
- Async variants via `AsyncClient`
|
479 |
+
|
480 |
+
Docs & deeper reading
|
481 |
+
- Full docs: https://g4f.dev/docs
|
482 |
+
- Client API docs: https://g4f.dev/docs/client
|
483 |
+
- Async client docs: https://g4f.dev/docs/async_client
|
484 |
+
- Provider guides: https://g4f.dev/docs/guides
|
485 |
+
- Local inference: https://g4f.dev/docs/local
|
486 |
+
|
487 |
+
---
|
488 |
+
|
489 |
+
Thank you for using and contributing to GPT4Free — together we make powerful AI tooling accessible, flexible, and community-driven.
|
gpt4free/SECURITY.md
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Reporting a Vulnerability
|
2 |
+
|
3 |
+
Reporting a Vulnerability
|
4 |
+
Please report (suspected) security vulnerabilities to https://t.me/xtekky. You will receive a response within 48 hours. If the issue is confirmed, we will release a patch as soon as possible depending on complexity but historically within a few days.
|
gpt4free/docker-compose-slim.yml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
g4f-slim:
|
5 |
+
container_name: g4f-slim
|
6 |
+
image: hlohaus789/g4f:latest-slim
|
7 |
+
build:
|
8 |
+
context: .
|
9 |
+
dockerfile: docker/Dockerfile-slim
|
10 |
+
volumes:
|
11 |
+
- ./generated_media:/app/generated_media
|
12 |
+
- ./har_and_cookies:/app/har_and_cookies
|
13 |
+
ports:
|
14 |
+
- '8080:8080'
|
15 |
+
- '1337:8080'
|
gpt4free/docker-compose.yml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3'
|
2 |
+
|
3 |
+
services:
|
4 |
+
gpt4free:
|
5 |
+
image: hlohaus789/g4f:latest
|
6 |
+
shm_size: 2gb
|
7 |
+
build:
|
8 |
+
context: .
|
9 |
+
dockerfile: docker/Dockerfile
|
10 |
+
volumes:
|
11 |
+
- .:/app
|
12 |
+
ports:
|
13 |
+
- '8080:8080'
|
14 |
+
- '1337:8080'
|
15 |
+
- '7900:7900'
|
16 |
+
environment:
|
17 |
+
- OLLAMA_HOST=host.docker.internal
|
gpt4free/docker/Dockerfile
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM selenium/node-chrome
|
2 |
+
|
3 |
+
ARG G4F_VERSION
|
4 |
+
ENV G4F_VERSION $G4F_VERSION
|
5 |
+
|
6 |
+
ENV SE_SCREEN_WIDTH 1850
|
7 |
+
ENV G4F_DIR /app
|
8 |
+
ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=secret
|
9 |
+
|
10 |
+
USER root
|
11 |
+
|
12 |
+
# If docker compose, install git
|
13 |
+
RUN if [ "$G4F_VERSION" = "" ] ; then \
|
14 |
+
apt-get -qqy update && \
|
15 |
+
apt-get -qqy install git \
|
16 |
+
; fi
|
17 |
+
|
18 |
+
# Install Python3, pip, remove OpenJDK 11, clean up
|
19 |
+
RUN apt-get -qqy update \
|
20 |
+
&& apt-get -qqy upgrade \
|
21 |
+
&& apt-get -qyy autoremove \
|
22 |
+
&& apt-get -qqy install python3 python-is-python3 pip ffmpeg flac libavcodec-extra \
|
23 |
+
&& apt-get -qyy remove openjdk-11-jre-headless \
|
24 |
+
&& apt-get -qyy autoremove \
|
25 |
+
&& apt-get -qyy clean \
|
26 |
+
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
27 |
+
|
28 |
+
# Update entrypoint
|
29 |
+
COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
|
30 |
+
COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
|
31 |
+
|
32 |
+
# Change background image
|
33 |
+
COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
|
34 |
+
|
35 |
+
# Add user, fix permissions
|
36 |
+
RUN chown "${SEL_UID}:${SEL_GID}" $HOME/.local /opt/venv/share
|
37 |
+
|
38 |
+
# Switch user
|
39 |
+
USER $SEL_UID
|
40 |
+
|
41 |
+
# Set the working directory in the container.
|
42 |
+
WORKDIR $G4F_DIR
|
43 |
+
|
44 |
+
# Copy the project's requirements file into the container.
|
45 |
+
COPY requirements.txt $G4F_DIR
|
46 |
+
|
47 |
+
# Upgrade pip for the latest features and install the project's Python dependencies.
|
48 |
+
RUN pip install --break-system-packages --upgrade pip \
|
49 |
+
&& pip install --break-system-packages -r requirements.txt
|
50 |
+
|
51 |
+
# Copy the entire package into the container.
|
52 |
+
ADD --chown=$SEL_UID:$SEL_GID g4f $G4F_DIR/g4f
|
53 |
+
|
54 |
+
# Expose ports
|
55 |
+
EXPOSE 8080 7900
|
gpt4free/docker/Dockerfile-armv7
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:slim-bookworm
|
2 |
+
|
3 |
+
ARG G4F_VERSION
|
4 |
+
ARG G4F_USER=g4f
|
5 |
+
ARG G4F_USER_ID=1000
|
6 |
+
ARG PYDANTIC_VERSION=1.8.1
|
7 |
+
|
8 |
+
ENV G4F_VERSION $G4F_VERSION
|
9 |
+
ENV G4F_USER $G4F_USER
|
10 |
+
ENV G4F_USER_ID $G4F_USER_ID
|
11 |
+
ENV G4F_DIR /app
|
12 |
+
|
13 |
+
RUN apt-get update && apt-get upgrade -y \
|
14 |
+
&& apt-get install -y git curl \
|
15 |
+
&& apt-get install --quiet --yes --no-install-recommends \
|
16 |
+
build-essential libffi-dev zlib1g-dev libjpeg-dev libssl-dev pkg-config \
|
17 |
+
# Add user and user group
|
18 |
+
&& groupadd -g $G4F_USER_ID $G4F_USER \
|
19 |
+
&& useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
|
20 |
+
&& mkdir -p /var/log/supervisor \
|
21 |
+
&& chown "${G4F_USER_ID}:${G4F_USER_ID}" /var/log/supervisor \
|
22 |
+
&& echo "${G4F_USER}:${G4F_USER}" | chpasswd \
|
23 |
+
&& python -m pip install --upgrade pip
|
24 |
+
|
25 |
+
USER $G4F_USER_ID
|
26 |
+
WORKDIR $G4F_DIR
|
27 |
+
|
28 |
+
ENV HOME /home/$G4F_USER
|
29 |
+
ENV PATH "${HOME}/.local/bin:${HOME}/.cargo/bin:${PATH}"
|
30 |
+
|
31 |
+
# Install rust toolchain
|
32 |
+
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
|
33 |
+
|
34 |
+
# Create app dir and copy the project's requirements file into it
|
35 |
+
RUN mkdir -p $G4F_DIR
|
36 |
+
COPY requirements-min.txt $G4F_DIR
|
37 |
+
COPY requirements-slim.txt $G4F_DIR
|
38 |
+
|
39 |
+
# Upgrade pip for the latest features and install the project's Python dependencies.
|
40 |
+
RUN pip install --no-cache-dir -r requirements-min.txt \
|
41 |
+
&& pip install --no-cache-dir --no-binary setuptools \
|
42 |
+
Cython==0.29.22 \
|
43 |
+
setuptools \
|
44 |
+
# Install PyDantic
|
45 |
+
&& pip install \
|
46 |
+
-vvv \
|
47 |
+
--no-cache-dir \
|
48 |
+
--no-binary :all: \
|
49 |
+
--global-option=build_ext \
|
50 |
+
--global-option=-j8 \
|
51 |
+
pydantic==${PYDANTIC_VERSION}
|
52 |
+
RUN cat requirements-slim.txt | xargs -n 1 timeout 5m pip install --no-cache-dir || true
|
53 |
+
|
54 |
+
# Remove build packages
|
55 |
+
RUN pip uninstall --yes \
|
56 |
+
Cython \
|
57 |
+
setuptools
|
58 |
+
|
59 |
+
USER root
|
60 |
+
|
61 |
+
# Clean up build deps
|
62 |
+
RUN rm --recursive --force "${HOME}/.rustup"
|
63 |
+
RUN apt-get purge --auto-remove --yes \
|
64 |
+
build-essential \
|
65 |
+
&& apt-get clean \
|
66 |
+
&& rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
67 |
+
|
68 |
+
USER $G4F_USER_ID
|
69 |
+
|
70 |
+
# Copy the entire package into the container.
|
71 |
+
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
gpt4free/docker/Dockerfile-slim
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:slim-bookworm
|
2 |
+
|
3 |
+
ARG G4F_VERSION
|
4 |
+
ARG G4F_LIVE=true
|
5 |
+
ARG G4F_USER=g4f
|
6 |
+
ARG G4F_USER_ID=1000
|
7 |
+
|
8 |
+
ENV G4F_VERSION $G4F_VERSION
|
9 |
+
ENV G4F_LIVE $G4F_LIVE
|
10 |
+
ENV G4F_USER $G4F_USER
|
11 |
+
ENV G4F_USER_ID $G4F_USER_ID
|
12 |
+
ENV G4F_DIR /app
|
13 |
+
|
14 |
+
RUN apt-get update && apt-get upgrade -y \
|
15 |
+
&& apt-get install -y git cron ffmpeg flac \
|
16 |
+
# Add user and user group
|
17 |
+
&& groupadd -g $G4F_USER_ID $G4F_USER \
|
18 |
+
&& useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
|
19 |
+
&& echo "${G4F_USER}:${G4F_USER}" | chpasswd \
|
20 |
+
&& python -m pip install --upgrade pip \
|
21 |
+
&& apt-get clean \
|
22 |
+
&& rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
23 |
+
|
24 |
+
RUN mkdir -p $G4F_DIR
|
25 |
+
RUN chown "${G4F_USER_ID}:${G4F_USER_ID}" $G4F_DIR
|
26 |
+
|
27 |
+
USER $G4F_USER_ID
|
28 |
+
WORKDIR $G4F_DIR
|
29 |
+
|
30 |
+
ENV HOME /home/$G4F_USER
|
31 |
+
ENV PATH "${HOME}/.local/bin:${PATH}"
|
32 |
+
|
33 |
+
RUN git clone https://github.com/xtekky/gpt4free.git $G4F_DIR \
|
34 |
+
&& pip install --no-cache-dir -r requirements-slim.txt
|
35 |
+
RUN git clone https://github.com/hlohaus/deepseek4free.git \
|
36 |
+
&& cd deepseek4free && git checkout 21Feb \
|
37 |
+
&& pip install --no-cache-dir . && cd .. && rm -rf deepseek4free
|
38 |
+
|
39 |
+
CMD python -m etc.tool.update && docker/update.sh & docker/start.sh
|
gpt4free/docker/start.sh
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
python -m g4f --port 8080 --debug --reload
|
gpt4free/docker/supervisor-api.conf
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[program:g4f-api]
|
2 |
+
priority=15
|
3 |
+
command=python -m g4f api --port 8080 --debug
|
4 |
+
directory=/app
|
5 |
+
stopasgroup=true
|
6 |
+
autostart=true
|
7 |
+
autorestart=true
|
8 |
+
|
9 |
+
;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
|
10 |
+
redirect_stderr=true
|
11 |
+
stdout_logfile=/dev/stdout
|
12 |
+
stdout_logfile_maxbytes=0
|
gpt4free/docker/supervisor.conf
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[program:xvfb]
|
2 |
+
priority=0
|
3 |
+
command=/opt/bin/start-xvfb.sh
|
4 |
+
autostart=true
|
5 |
+
autorestart=true
|
6 |
+
|
7 |
+
;Logs
|
8 |
+
redirect_stderr=false
|
9 |
+
stdout_logfile=/var/log/supervisor/xvfb-stdout.log
|
10 |
+
stderr_logfile=/var/log/supervisor/xvfb-stderr.log
|
11 |
+
stdout_logfile_maxbytes=50MB
|
12 |
+
stderr_logfile_maxbytes=50MB
|
13 |
+
stdout_logfile_backups=5
|
14 |
+
stderr_logfile_backups=5
|
15 |
+
stdout_capture_maxbytes=50MB
|
16 |
+
stderr_capture_maxbytes=50MB
|
17 |
+
|
18 |
+
[program:vnc]
|
19 |
+
priority=5
|
20 |
+
command=/opt/bin/start-vnc.sh
|
21 |
+
autostart=true
|
22 |
+
autorestart=true
|
23 |
+
|
24 |
+
;Logs
|
25 |
+
redirect_stderr=false
|
26 |
+
stdout_logfile=/var/log/supervisor/vnc-stdout.log
|
27 |
+
stderr_logfile=/var/log/supervisor/vnc-stderr.log
|
28 |
+
stdout_logfile_maxbytes=50MB
|
29 |
+
stderr_logfile_maxbytes=50MB
|
30 |
+
stdout_logfile_backups=5
|
31 |
+
stderr_logfile_backups=5
|
32 |
+
stdout_capture_maxbytes=50MB
|
33 |
+
stderr_capture_maxbytes=50MB
|
34 |
+
|
35 |
+
[program:novnc]
|
36 |
+
priority=10
|
37 |
+
command=/opt/bin/start-novnc.sh
|
38 |
+
autostart=true
|
39 |
+
autorestart=true
|
40 |
+
|
41 |
+
;Logs
|
42 |
+
redirect_stderr=false
|
43 |
+
stdout_logfile=/var/log/supervisor/novnc-stdout.log
|
44 |
+
stderr_logfile=/var/log/supervisor/novnc-stderr.log
|
45 |
+
stdout_logfile_maxbytes=50MB
|
46 |
+
stderr_logfile_maxbytes=50MB
|
47 |
+
stdout_logfile_backups=5
|
48 |
+
stderr_logfile_backups=5
|
49 |
+
stdout_capture_maxbytes=50MB
|
50 |
+
stderr_capture_maxbytes=50MB
|
gpt4free/docker/update.sh
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash
|
2 |
+
trap break INT
|
3 |
+
for (( c=0; c<=1000000; c++ ))
|
4 |
+
do
|
5 |
+
echo "UPDATE: a$c"
|
6 |
+
git pull origin main
|
7 |
+
sleep 120
|
8 |
+
echo "UPDATE: b$c"
|
9 |
+
git pull origin main
|
10 |
+
sleep 120
|
11 |
+
echo "UPDATE: c$c"
|
12 |
+
git pull origin main
|
13 |
+
sleep 120
|
14 |
+
echo "UPDATE: d$c"
|
15 |
+
git pull origin main
|
16 |
+
sleep 120
|
17 |
+
echo "UPDATE: #$c"
|
18 |
+
git pull origin main
|
19 |
+
sleep 120
|
20 |
+
done
|
21 |
+
echo "STOPPED."
|
22 |
+
trap - INT
|
23 |
+
sleep 1
|
24 |
+
echo "END."
|
gpt4free/docs/README.md
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Link to [Documentation](https://github.com/gpt4free/gpt4free.github.io)
|
gpt4free/docs/aarch64-compatibility.md
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# aarch64 (ARM64) Compatibility
|
2 |
+
|
3 |
+
This document describes the compatibility status and known issues for g4f on aarch64 (ARM64) systems.
|
4 |
+
|
5 |
+
## Issue Resolution
|
6 |
+
|
7 |
+
**Fixed in this release:** The "Illegal instruction (core dumped)" error that occurred when importing g4f on aarch64 systems has been resolved.
|
8 |
+
|
9 |
+
### Problem
|
10 |
+
Previously, g4f would crash with "Illegal instruction (core dumped)" on ARM64 systems (such as Apple Silicon Macs, Raspberry Pi, AWS Graviton instances, etc.) due to compiled dependencies with architecture-specific optimizations.
|
11 |
+
|
12 |
+
### Solution
|
13 |
+
The library now includes proper error handling for architecture-incompatible dependencies:
|
14 |
+
- Safe import mechanisms prevent crashes when compiled libraries are unavailable
|
15 |
+
- Graceful fallbacks to alternative implementations when possible
|
16 |
+
- Clear error messages when specific features require unavailable dependencies
|
17 |
+
|
18 |
+
## Compatibility Status
|
19 |
+
|
20 |
+
### ✅ Working Features
|
21 |
+
- Basic client functionality (`from g4f.client import Client`)
|
22 |
+
- CLI commands (`g4f --help`, `g4f client --help`)
|
23 |
+
- Providers that use standard HTTP libraries
|
24 |
+
- Most text generation functionality
|
25 |
+
|
26 |
+
### ⚠️ Limited Features
|
27 |
+
Some advanced features may have reduced functionality on aarch64:
|
28 |
+
- Providers requiring `curl_cffi` will fall back to `aiohttp`
|
29 |
+
- Browser automation features may not be available
|
30 |
+
- Some performance optimizations may not be active
|
31 |
+
|
32 |
+
### 📋 Requirements
|
33 |
+
For full functionality on aarch64, ensure you have:
|
34 |
+
```bash
|
35 |
+
# Basic requirements (should work on all architectures)
|
36 |
+
pip install -r requirements-min.txt
|
37 |
+
|
38 |
+
# Full requirements (some packages may need compilation on aarch64)
|
39 |
+
pip install -r requirements.txt
|
40 |
+
```
|
41 |
+
|
42 |
+
## Testing Your Installation
|
43 |
+
|
44 |
+
You can verify your installation works correctly:
|
45 |
+
|
46 |
+
```python
|
47 |
+
# Test basic import
|
48 |
+
from g4f.client import Client
|
49 |
+
client = Client()
|
50 |
+
print("✓ g4f imported successfully")
|
51 |
+
|
52 |
+
# Test CLI
|
53 |
+
import subprocess
|
54 |
+
result = subprocess.run(['g4f', '--help'], capture_output=True)
|
55 |
+
print("✓ CLI works" if result.returncode == 0 else "✗ CLI issues")
|
56 |
+
```
|
57 |
+
|
58 |
+
## Known Issues
|
59 |
+
|
60 |
+
1. **Performance**: Some providers may have reduced performance due to fallback implementations
|
61 |
+
2. **Browser Features**: nodriver and webview functionality may not be available
|
62 |
+
3. **Image Processing**: Some image-related features may have compatibility issues
|
63 |
+
|
64 |
+
## Getting Help
|
65 |
+
|
66 |
+
If you encounter issues on aarch64:
|
67 |
+
1. First try with minimal requirements: `pip install -r requirements-min.txt`
|
68 |
+
2. Check if the issue persists with basic functionality
|
69 |
+
3. Report architecture-specific issues with your system details:
|
70 |
+
- Architecture: `uname -m`
|
71 |
+
- OS: `uname -a`
|
72 |
+
- Python version: `python --version`
|
gpt4free/docs/arm64-build-plan.md
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Future ARM64 Build Enhancement Plan
|
2 |
+
|
3 |
+
This document outlines the plan for adding comprehensive ARM64 support to the g4f build system.
|
4 |
+
|
5 |
+
## Current Status
|
6 |
+
|
7 |
+
- **macOS ARM64**: ✅ Supported (native runners)
|
8 |
+
- **Linux ARM64**: ⏳ Requires ARM64 runners or cross-compilation
|
9 |
+
- **Windows ARM64**: ⏳ Requires ARM64 runners or cross-compilation
|
10 |
+
|
11 |
+
## Implementation Plan for ARM64 Support
|
12 |
+
|
13 |
+
### Phase 1: Linux ARM64 (Future Enhancement)
|
14 |
+
```yaml
|
15 |
+
# Add to .github/workflows/build-packages.yml
|
16 |
+
build-linux-exe:
|
17 |
+
strategy:
|
18 |
+
matrix:
|
19 |
+
include:
|
20 |
+
- architecture: x64
|
21 |
+
runner: ubuntu-latest
|
22 |
+
runner-arch: x86_64
|
23 |
+
- architecture: arm64
|
24 |
+
runner: buildjet-4vcpu-ubuntu-2204-arm # ARM64 runners
|
25 |
+
runner-arch: aarch64
|
26 |
+
```
|
27 |
+
|
28 |
+
### Phase 2: Windows ARM64 (Future Enhancement)
|
29 |
+
```yaml
|
30 |
+
build-windows-exe:
|
31 |
+
strategy:
|
32 |
+
matrix:
|
33 |
+
include:
|
34 |
+
- architecture: x64
|
35 |
+
runner: windows-latest
|
36 |
+
runner-arch: x86_64
|
37 |
+
- architecture: arm64
|
38 |
+
runner: windows-latest-arm64 # When available
|
39 |
+
runner-arch: arm64
|
40 |
+
```
|
41 |
+
|
42 |
+
### Phase 3: Cross-compilation Support
|
43 |
+
For environments without native ARM64 runners:
|
44 |
+
- Use Docker with QEMU emulation
|
45 |
+
- Configure Nuitka for cross-compilation
|
46 |
+
- Test compatibility and performance
|
47 |
+
|
48 |
+
## Benefits of ARM64 Support
|
49 |
+
|
50 |
+
1. **Performance**: Native ARM64 binaries run faster on ARM64 hardware
|
51 |
+
2. **Compatibility**: Better support for Apple Silicon Macs and ARM64 Linux systems
|
52 |
+
3. **Future-proofing**: ARM64 adoption is increasing across all platforms
|
53 |
+
|
54 |
+
## Testing Requirements
|
55 |
+
|
56 |
+
- Verify ARM64 binaries work on actual ARM64 hardware
|
57 |
+
- Test performance compared to x64 binaries on ARM64 systems
|
58 |
+
- Ensure compatibility with all g4f features
|
59 |
+
|
60 |
+
## Notes
|
61 |
+
|
62 |
+
- This is marked as a future enhancement because it requires ARM64 runners or cross-compilation setup
|
63 |
+
- Current implementation provides a solid foundation for easy expansion
|
64 |
+
- The build matrix is designed to accommodate additional architectures
|
gpt4free/docs/build-workflow.md
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Build Workflow Documentation
|
2 |
+
|
3 |
+
This document explains the comprehensive build workflow for g4f that creates packages for multiple platforms and package managers.
|
4 |
+
|
5 |
+
## Workflow Overview
|
6 |
+
|
7 |
+
The `.github/workflows/build-packages.yml` workflow automatically builds multiple package formats when a version tag is pushed to the repository.
|
8 |
+
|
9 |
+
### Supported Package Formats
|
10 |
+
|
11 |
+
1. **PyPI Package** - Python wheel and source distribution
|
12 |
+
2. **Windows Executable** - Standalone .exe file built with Nuitka
|
13 |
+
3. **Linux Executable** - Standalone binary for Linux systems built with Nuitka
|
14 |
+
4. **macOS Executable** - Standalone binary for macOS systems built with Nuitka (x64 and ARM64)
|
15 |
+
5. **Debian Packages** - .deb files for Ubuntu/Debian (amd64, arm64, armhf)
|
16 |
+
6. **WinGet Package** - Windows Package Manager manifest
|
17 |
+
7. **Docker Images** - Multi-architecture container images
|
18 |
+
|
19 |
+
### Triggering a Build
|
20 |
+
|
21 |
+
To trigger a build, push a version tag to the repository:
|
22 |
+
|
23 |
+
```bash
|
24 |
+
git tag v1.2.3
|
25 |
+
git push origin v1.2.3
|
26 |
+
```
|
27 |
+
|
28 |
+
The workflow will:
|
29 |
+
1. Detect the tag and extract the version
|
30 |
+
2. Build all package formats in parallel
|
31 |
+
3. Create a GitHub release with all artifacts
|
32 |
+
4. Publish to PyPI (for releases)
|
33 |
+
5. Generate WinGet manifest for Windows Package Manager
|
34 |
+
|
35 |
+
### Manual Build Triggering
|
36 |
+
|
37 |
+
You can also manually trigger builds using the workflow_dispatch event:
|
38 |
+
|
39 |
+
1. Go to the "Actions" tab in GitHub
|
40 |
+
2. Select "Build All Packages" workflow
|
41 |
+
3. Click "Run workflow"
|
42 |
+
4. Optionally specify a version number
|
43 |
+
|
44 |
+
### Package Locations
|
45 |
+
|
46 |
+
After a successful build, packages are available:
|
47 |
+
|
48 |
+
- **GitHub Releases**: All executables and packages as release assets
|
49 |
+
- Python packages (wheel and source distribution)
|
50 |
+
- Standalone executables for Windows, Linux, and macOS
|
51 |
+
- Debian packages for AMD64, ARM64, and ARMv7 architectures
|
52 |
+
- WinGet manifest files
|
53 |
+
- **PyPI**: `pip install g4f`
|
54 |
+
- **Docker Hub**: `docker pull hlohaus789/g4f:latest`
|
55 |
+
- **WinGet**: `winget install g4f` (after manifest approval)
|
56 |
+
|
57 |
+
### Build Requirements
|
58 |
+
|
59 |
+
The workflow handles all dependencies automatically, but for local development:
|
60 |
+
|
61 |
+
- Python 3.10+
|
62 |
+
- Nuitka for executables (replaces PyInstaller)
|
63 |
+
- Docker for container builds
|
64 |
+
- dpkg-deb for Debian packages
|
65 |
+
|
66 |
+
### Customizing Builds
|
67 |
+
|
68 |
+
Key files for customization:
|
69 |
+
|
70 |
+
- `g4f_cli.py` - Entry point for executable builds
|
71 |
+
- `scripts/build-nuitka.sh` - Nuitka build script for all platforms
|
72 |
+
- `scripts/build-deb.sh` - Debian package build script
|
73 |
+
- `winget/manifests/` - WinGet package manifest templates
|
74 |
+
- `.github/workflows/build-packages.yml` - Main workflow configuration
|
75 |
+
|
76 |
+
### Version Handling
|
77 |
+
|
78 |
+
The workflow supports multiple version sources:
|
79 |
+
1. Git tags (preferred for releases)
|
80 |
+
2. Environment variable `G4F_VERSION`
|
81 |
+
3. Manual input in workflow dispatch
|
82 |
+
|
83 |
+
Version must follow [PEP 440](https://peps.python.org/pep-0440/) format for PyPI compatibility.
|
84 |
+
|
85 |
+
### Troubleshooting
|
86 |
+
|
87 |
+
Common issues and solutions:
|
88 |
+
|
89 |
+
1. **Build fails**: Check Python version compatibility and dependencies
|
90 |
+
2. **Version errors**: Ensure version follows PEP 440 format
|
91 |
+
3. **Missing artifacts**: Check if all build jobs completed successfully
|
92 |
+
4. **Docker push fails**: Verify Docker Hub credentials are set in repository secrets
|
93 |
+
|
94 |
+
### Security Notes
|
95 |
+
|
96 |
+
The workflow uses secure practices:
|
97 |
+
- Trusted action versions
|
98 |
+
- Environment isolation
|
99 |
+
- Secret management for credentials
|
100 |
+
- No hardcoded sensitive data
|
101 |
+
|
102 |
+
### Contributing
|
103 |
+
|
104 |
+
To improve the build system:
|
105 |
+
1. Test changes locally first
|
106 |
+
2. Update documentation
|
107 |
+
3. Consider backward compatibility
|
108 |
+
4. Test with multiple Python versions
|
gpt4free/docs/reasoning-standardization.md
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Reasoning Field Standardization
|
2 |
+
|
3 |
+
## Issue
|
4 |
+
DeepSeek uses `"reasoning_content"` field while OpenAI uses `"reasoning"` field in their chat completion streaming responses. This inconsistency caused confusion about what field name to use in the g4f Interference API.
|
5 |
+
|
6 |
+
## Decision
|
7 |
+
**Standardized on OpenAI's `"reasoning"` field format for API output while maintaining input compatibility.**
|
8 |
+
|
9 |
+
## Rationale
|
10 |
+
1. **OpenAI Compatibility**: OpenAI is the de facto standard for chat completion APIs
|
11 |
+
2. **Ecosystem Compatibility**: Most tools and libraries expect OpenAI format
|
12 |
+
3. **Consistency**: Provides a unified output format regardless of the underlying provider
|
13 |
+
4. **Backward Compatibility**: Input parsing continues to accept both formats
|
14 |
+
|
15 |
+
## Implementation
|
16 |
+
|
17 |
+
### Input Format Support (Unchanged)
|
18 |
+
The system continues to accept both input formats in `OpenaiTemplate.py`:
|
19 |
+
```python
|
20 |
+
reasoning_content = choice.get("delta", {}).get("reasoning_content", choice.get("delta", {}).get("reasoning"))
|
21 |
+
```
|
22 |
+
|
23 |
+
### Output Format Standardization (Changed)
|
24 |
+
- **Streaming Delta**: Uses `reasoning` field (OpenAI format)
|
25 |
+
- **Non-streaming Message**: Uses `reasoning` field (OpenAI format)
|
26 |
+
- **API Responses**: Should use standard OpenAI streaming format
|
27 |
+
|
28 |
+
### Example Output Formats
|
29 |
+
|
30 |
+
#### Streaming Response (OpenAI Compatible)
|
31 |
+
```json
|
32 |
+
{
|
33 |
+
"id": "chatcmpl-example",
|
34 |
+
"object": "chat.completion.chunk",
|
35 |
+
"choices": [{
|
36 |
+
"index": 0,
|
37 |
+
"delta": {
|
38 |
+
"role": "assistant",
|
39 |
+
"reasoning": "I need to think about this step by step..."
|
40 |
+
},
|
41 |
+
"finish_reason": null
|
42 |
+
}]
|
43 |
+
}
|
44 |
+
```
|
45 |
+
|
46 |
+
#### Non-streaming Response
|
47 |
+
```json
|
48 |
+
{
|
49 |
+
"choices": [{
|
50 |
+
"message": {
|
51 |
+
"role": "assistant",
|
52 |
+
"content": "Here's my answer",
|
53 |
+
"reasoning": "My reasoning process was..."
|
54 |
+
}
|
55 |
+
}]
|
56 |
+
}
|
57 |
+
```
|
58 |
+
|
59 |
+
## Files Changed
|
60 |
+
- `g4f/client/stubs.py`: Updated to use `reasoning` field instead of `reasoning_content`
|
61 |
+
|
62 |
+
## Testing
|
63 |
+
- Added comprehensive tests for format standardization
|
64 |
+
- Verified input compatibility with both OpenAI and DeepSeek formats
|
65 |
+
- Confirmed no regressions in existing functionality
|
gpt4free/etc/examples/api_completions_copilot.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
import json
|
3 |
+
import uuid
|
4 |
+
|
5 |
+
url = "http://localhost:1337/v1/chat/completions"
|
6 |
+
conversation_id = str(uuid.uuid4())
|
7 |
+
body = {
|
8 |
+
"model": "",
|
9 |
+
"provider": "Copilot",
|
10 |
+
"stream": True,
|
11 |
+
"messages": [
|
12 |
+
{"role": "user", "content": "Hello, i am Heiner. How are you?"}
|
13 |
+
],
|
14 |
+
"conversation_id": conversation_id
|
15 |
+
}
|
16 |
+
response = requests.post(url, json=body, stream=True)
|
17 |
+
response.raise_for_status()
|
18 |
+
for line in response.iter_lines():
|
19 |
+
if line.startswith(b"data: "):
|
20 |
+
try:
|
21 |
+
json_data = json.loads(line[6:])
|
22 |
+
if json_data.get("error"):
|
23 |
+
print(json_data)
|
24 |
+
break
|
25 |
+
content = json_data.get("choices", [{"delta": {}}])[0]["delta"].get("content", "")
|
26 |
+
if content:
|
27 |
+
print(content, end="")
|
28 |
+
except json.JSONDecodeError:
|
29 |
+
pass
|
30 |
+
print()
|
31 |
+
print()
|
32 |
+
print()
|
33 |
+
body = {
|
34 |
+
"model": "",
|
35 |
+
"provider": "Copilot",
|
36 |
+
"stream": True,
|
37 |
+
"messages": [
|
38 |
+
{"role": "user", "content": "Tell me somethings about my name"}
|
39 |
+
],
|
40 |
+
"conversation_id": conversation_id
|
41 |
+
}
|
42 |
+
response = requests.post(url, json=body, stream=True)
|
43 |
+
response.raise_for_status()
|
44 |
+
for line in response.iter_lines():
|
45 |
+
if line.startswith(b"data: "):
|
46 |
+
try:
|
47 |
+
json_data = json.loads(line[6:])
|
48 |
+
if json_data.get("error"):
|
49 |
+
print(json_data)
|
50 |
+
break
|
51 |
+
content = json_data.get("choices", [{"delta": {}}])[0]["delta"].get("content", "")
|
52 |
+
if content:
|
53 |
+
print(content, end="")
|
54 |
+
except json.JSONDecodeError:
|
55 |
+
pass
|
gpt4free/etc/examples/api_generations_image.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
url = "http://localhost:1337/v1/images/generations"
|
3 |
+
body = {
|
4 |
+
"model": "flux",
|
5 |
+
"prompt": "hello world user",
|
6 |
+
"response_format": None,
|
7 |
+
#"response_format": "url",
|
8 |
+
#"response_format": "b64_json",
|
9 |
+
}
|
10 |
+
data = requests.post(url, json=body, stream=True).json()
|
11 |
+
print(data)
|
gpt4free/etc/examples/audio.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
from g4f.client import AsyncClient
|
3 |
+
import g4f.Provider
|
4 |
+
import g4f.models
|
5 |
+
|
6 |
+
async def main():
|
7 |
+
client = AsyncClient(provider=g4f.Provider.PollinationsAI)
|
8 |
+
|
9 |
+
# Generate audio with PollinationsAI
|
10 |
+
response = await client.chat.completions.create(
|
11 |
+
model="openai-audio",
|
12 |
+
messages=[{"role": "user", "content": "Say good day to the world"}],
|
13 |
+
audio={ "voice": "alloy", "format": "mp3" },
|
14 |
+
)
|
15 |
+
response.choices[0].message.save("alloy.mp3")
|
16 |
+
|
17 |
+
# Transcribe a audio file
|
18 |
+
with open("audio.wav", "rb") as audio_file:
|
19 |
+
response = await client.chat.completions.create(
|
20 |
+
messages="Transcribe this audio",
|
21 |
+
provider=g4f.Provider.Microsoft_Phi_4,
|
22 |
+
media=[[audio_file, "audio.wav"]],
|
23 |
+
modalities=["text"],
|
24 |
+
)
|
25 |
+
print(response.choices[0].message.content)
|
26 |
+
|
27 |
+
if __name__ == "__main__":
|
28 |
+
asyncio.run(main())
|
gpt4free/etc/examples/messages.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from g4f.client import Client
|
2 |
+
|
3 |
+
class ConversationHandler:
|
4 |
+
def __init__(self, model="gpt-4"):
|
5 |
+
self.client = Client()
|
6 |
+
self.model = model
|
7 |
+
self.conversation_history = []
|
8 |
+
|
9 |
+
def add_user_message(self, content):
|
10 |
+
self.conversation_history.append({
|
11 |
+
"role": "user",
|
12 |
+
"content": content
|
13 |
+
})
|
14 |
+
|
15 |
+
def get_response(self):
|
16 |
+
response = self.client.chat.completions.create(
|
17 |
+
model=self.model,
|
18 |
+
messages=self.conversation_history
|
19 |
+
)
|
20 |
+
assistant_message = {
|
21 |
+
"role": response.choices[0].message.role,
|
22 |
+
"content": response.choices[0].message.content
|
23 |
+
}
|
24 |
+
self.conversation_history.append(assistant_message)
|
25 |
+
return assistant_message["content"]
|
26 |
+
|
27 |
+
# Usage example
|
28 |
+
conversation = ConversationHandler()
|
29 |
+
conversation.add_user_message("Hello!")
|
30 |
+
print("Assistant:", conversation.get_response())
|
31 |
+
|
32 |
+
conversation.add_user_message("How are you?")
|
33 |
+
print("Assistant:", conversation.get_response())
|
gpt4free/etc/examples/messages_stream.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
from g4f.client import AsyncClient
|
3 |
+
|
4 |
+
async def main():
|
5 |
+
client = AsyncClient()
|
6 |
+
|
7 |
+
stream = client.chat.completions.create(
|
8 |
+
model="gpt-4",
|
9 |
+
messages=[{"role": "user", "content": "Say hello there!"}],
|
10 |
+
stream=True,
|
11 |
+
)
|
12 |
+
|
13 |
+
accumulated_text = ""
|
14 |
+
try:
|
15 |
+
async for chunk in stream:
|
16 |
+
if chunk.choices and chunk.choices[0].delta.content:
|
17 |
+
content = chunk.choices[0].delta.content
|
18 |
+
accumulated_text += content
|
19 |
+
print(content, end="", flush=True)
|
20 |
+
except Exception as e:
|
21 |
+
print(f"\nError occurred: {e}")
|
22 |
+
finally:
|
23 |
+
print("\n\nFinal accumulated text:", accumulated_text)
|
24 |
+
|
25 |
+
asyncio.run(main())
|
gpt4free/etc/examples/openaichat.py
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from g4f.client import Client
|
2 |
+
from g4f.Provider import OpenaiChat, RetryProvider
|
3 |
+
|
4 |
+
# compatible countries: https://pastebin.com/UK0gT9cn
|
5 |
+
client = Client(
|
6 |
+
proxies = {
|
7 |
+
'http': 'http://username:password@host:port', # MUST BE WORKING OPENAI COUNTRY PROXY ex: USA
|
8 |
+
'https': 'http://username:password@host:port' # MUST BE WORKING OPENAI COUNTRY PROXY ex: USA
|
9 |
+
},
|
10 |
+
provider = RetryProvider([OpenaiChat],
|
11 |
+
single_provider_retry=True, max_retries=5)
|
12 |
+
)
|
13 |
+
|
14 |
+
messages = [
|
15 |
+
{'role': 'user', 'content': 'Hello'}
|
16 |
+
]
|
17 |
+
|
18 |
+
response = client.chat.completions.create(model='gpt-3.5-turbo',
|
19 |
+
messages=messages,
|
20 |
+
stream=True)
|
21 |
+
|
22 |
+
for message in response:
|
23 |
+
print(message.choices[0].delta.content or "")
|
gpt4free/etc/examples/text_completions_demo_async.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
from g4f.client import AsyncClient
|
3 |
+
|
4 |
+
async def main():
|
5 |
+
client = AsyncClient()
|
6 |
+
|
7 |
+
response = await client.chat.completions.create(
|
8 |
+
model="gpt-4o",
|
9 |
+
messages=[
|
10 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
11 |
+
{"role": "user", "content": "how does a court case get to the Supreme Court?"}
|
12 |
+
]
|
13 |
+
)
|
14 |
+
|
15 |
+
print(response.choices[0].message.content)
|
16 |
+
|
17 |
+
asyncio.run(main())
|
gpt4free/etc/examples/text_completions_demo_sync.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from g4f.client import Client
|
2 |
+
|
3 |
+
client = Client()
|
4 |
+
|
5 |
+
response = client.chat.completions.create(
|
6 |
+
model="gpt-4o",
|
7 |
+
messages=[
|
8 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
9 |
+
{"role": "user", "content": "how does a court case get to the Supreme Court?"}
|
10 |
+
],
|
11 |
+
)
|
12 |
+
|
13 |
+
print(response.choices[0].message.content)
|
gpt4free/etc/examples/text_completions_streaming.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
from g4f.client import Client, AsyncClient
|
3 |
+
|
4 |
+
question = """
|
5 |
+
Hey! How can I recursively list all files in a directory in Python?
|
6 |
+
"""
|
7 |
+
|
8 |
+
# Synchronous streaming function
|
9 |
+
def sync_stream():
|
10 |
+
client = Client()
|
11 |
+
stream = client.chat.completions.create(
|
12 |
+
model="gpt-4",
|
13 |
+
messages=[
|
14 |
+
{"role": "user", "content": question}
|
15 |
+
],
|
16 |
+
stream=True,
|
17 |
+
)
|
18 |
+
|
19 |
+
for chunk in stream:
|
20 |
+
if chunk.choices[0].delta.content:
|
21 |
+
print(chunk.choices[0].delta.content or "", end="")
|
22 |
+
|
23 |
+
# Asynchronous streaming function
|
24 |
+
async def async_stream():
|
25 |
+
client = AsyncClient()
|
26 |
+
stream = client.chat.completions.create(
|
27 |
+
model="gpt-4",
|
28 |
+
messages=[
|
29 |
+
{"role": "user", "content": question}
|
30 |
+
],
|
31 |
+
stream=True,
|
32 |
+
)
|
33 |
+
|
34 |
+
async for chunk in stream:
|
35 |
+
if chunk.choices and chunk.choices[0].delta.content:
|
36 |
+
print(chunk.choices[0].delta.content, end="")
|
37 |
+
|
38 |
+
# Main function to run both streams
|
39 |
+
def main():
|
40 |
+
print("Synchronous Stream:")
|
41 |
+
sync_stream()
|
42 |
+
print("\n\nAsynchronous Stream:")
|
43 |
+
asyncio.run(async_stream())
|
44 |
+
|
45 |
+
if __name__ == "__main__":
|
46 |
+
try:
|
47 |
+
main()
|
48 |
+
except Exception as e:
|
49 |
+
print(f"An error occurred: {str(e)}")
|
gpt4free/etc/examples/video.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import g4f.Provider
|
2 |
+
from g4f.client import Client
|
3 |
+
|
4 |
+
client = Client(
|
5 |
+
provider=g4f.Provider.HuggingFaceMedia,
|
6 |
+
api_key="hf_***" # Your API key here
|
7 |
+
)
|
8 |
+
|
9 |
+
video_models = client.models.get_video()
|
10 |
+
|
11 |
+
print(video_models)
|
12 |
+
|
13 |
+
result = client.media.generate(
|
14 |
+
model=video_models[0],
|
15 |
+
prompt="G4F AI technology is the best in the world.",
|
16 |
+
response_format="url"
|
17 |
+
)
|
18 |
+
|
19 |
+
print(result.data[0].url)
|
gpt4free/etc/examples/vision_images.py
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import g4f
|
2 |
+
import requests
|
3 |
+
|
4 |
+
from g4f.client import Client
|
5 |
+
|
6 |
+
client = Client()
|
7 |
+
|
8 |
+
# Processing remote image
|
9 |
+
remote_image = requests.get("https://raw.githubusercontent.com/xtekky/gpt4free/refs/heads/main/docs/images/cat.jpeg", stream=True).content
|
10 |
+
response_remote = client.chat.completions.create(
|
11 |
+
model=g4f.models.default_vision,
|
12 |
+
messages=[
|
13 |
+
{"role": "user", "content": "What are on this image?"}
|
14 |
+
],
|
15 |
+
image=remote_image
|
16 |
+
)
|
17 |
+
print("Response for remote image:")
|
18 |
+
print(response_remote.choices[0].message.content)
|
19 |
+
|
20 |
+
print("\n" + "-"*50 + "\n") # Separator
|
21 |
+
|
22 |
+
# Processing local image
|
23 |
+
local_image = open("docs/images/cat.jpeg", "rb")
|
24 |
+
response_local = client.chat.completions.create(
|
25 |
+
model=g4f.models.default_vision,
|
26 |
+
messages=[
|
27 |
+
{"role": "user", "content": "What are on this image?"}
|
28 |
+
],
|
29 |
+
image=local_image
|
30 |
+
)
|
31 |
+
print("Response for local image:")
|
32 |
+
print(response_local.choices[0].message.content)
|
33 |
+
local_image.close() # Close file after use
|
gpt4free/etc/examples/vision_images_reka.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Image Chat with Reca
|
2 |
+
# !! YOU NEED COOKIES / BE LOGGED IN TO chat.reka.ai
|
3 |
+
# download an image and save it as test.png in the same folder
|
4 |
+
|
5 |
+
from g4f.client import Client
|
6 |
+
from g4f.Provider import Reka
|
7 |
+
|
8 |
+
client = Client(
|
9 |
+
provider = Reka # Optional if you set model name to reka-core
|
10 |
+
)
|
11 |
+
|
12 |
+
completion = client.chat.completions.create(
|
13 |
+
model = "reka-core",
|
14 |
+
messages = [
|
15 |
+
{
|
16 |
+
"role": "user",
|
17 |
+
"content": "What can you see in the image ?"
|
18 |
+
}
|
19 |
+
],
|
20 |
+
stream = True,
|
21 |
+
image = open("docs/images/cat.jpeg", "rb") # open("path", "rb"), do not use .read(), etc. it must be a file object
|
22 |
+
)
|
23 |
+
|
24 |
+
for message in completion:
|
25 |
+
print(message.choices[0].delta.content or "")
|
26 |
+
|
27 |
+
# >>> In the image there is ...
|
gpt4free/etc/testing/_providers.py
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from pathlib import Path
|
3 |
+
from colorama import Fore, Style
|
4 |
+
|
5 |
+
sys.path.append(str(Path(__file__).parent.parent))
|
6 |
+
|
7 |
+
from g4f import Provider, ProviderType, models
|
8 |
+
from g4f.Provider import __providers__
|
9 |
+
|
10 |
+
|
11 |
+
def main():
|
12 |
+
providers = get_providers()
|
13 |
+
failed_providers = []
|
14 |
+
|
15 |
+
for provider in providers:
|
16 |
+
if provider.needs_auth:
|
17 |
+
continue
|
18 |
+
print("Provider:", provider.__name__)
|
19 |
+
result = test(provider)
|
20 |
+
print("Result:", result)
|
21 |
+
if provider.working and not result:
|
22 |
+
failed_providers.append(provider)
|
23 |
+
print()
|
24 |
+
|
25 |
+
if failed_providers:
|
26 |
+
print(f"{Fore.RED + Style.BRIGHT}Failed providers:{Style.RESET_ALL}")
|
27 |
+
for _provider in failed_providers:
|
28 |
+
print(f"{Fore.RED}{_provider.__name__}")
|
29 |
+
else:
|
30 |
+
print(f"{Fore.GREEN + Style.BRIGHT}All providers are working")
|
31 |
+
|
32 |
+
|
33 |
+
def get_providers() -> list[ProviderType]:
|
34 |
+
return [
|
35 |
+
provider
|
36 |
+
for provider in __providers__
|
37 |
+
if provider.__name__ not in dir(Provider.deprecated)
|
38 |
+
and provider.url is not None
|
39 |
+
]
|
40 |
+
|
41 |
+
def create_response(provider: ProviderType) -> str:
|
42 |
+
response = provider.create_completion(
|
43 |
+
model=models.default.name,
|
44 |
+
messages=[{"role": "user", "content": "Hello, who are you? Answer in detail much as possible."}],
|
45 |
+
stream=False,
|
46 |
+
)
|
47 |
+
return "".join(response)
|
48 |
+
|
49 |
+
def test(provider: ProviderType) -> bool:
|
50 |
+
try:
|
51 |
+
response = create_response(provider)
|
52 |
+
assert type(response) is str
|
53 |
+
assert len(response) > 0
|
54 |
+
return response
|
55 |
+
except Exception:
|
56 |
+
return False
|
57 |
+
|
58 |
+
|
59 |
+
if __name__ == "__main__":
|
60 |
+
main()
|
61 |
+
|
gpt4free/etc/testing/log_time.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from time import time
|
2 |
+
|
3 |
+
|
4 |
+
async def log_time_async(method: callable, **kwargs):
|
5 |
+
start = time()
|
6 |
+
result = await method(**kwargs)
|
7 |
+
secs = f"{round(time() - start, 2)} secs"
|
8 |
+
return " ".join([result, secs]) if result else secs
|
9 |
+
|
10 |
+
|
11 |
+
def log_time_yield(method: callable, **kwargs):
|
12 |
+
start = time()
|
13 |
+
result = yield from method(**kwargs)
|
14 |
+
yield f" {round(time() - start, 2)} secs"
|
15 |
+
|
16 |
+
|
17 |
+
def log_time(method: callable, **kwargs):
|
18 |
+
start = time()
|
19 |
+
result = method(**kwargs)
|
20 |
+
secs = f"{round(time() - start, 2)} secs"
|
21 |
+
return " ".join([result, secs]) if result else secs
|
gpt4free/etc/testing/test_all.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import asyncio
|
2 |
+
import sys
|
3 |
+
from pathlib import Path
|
4 |
+
sys.path.append(str(Path(__file__).parent.parent.parent))
|
5 |
+
|
6 |
+
import g4f
|
7 |
+
|
8 |
+
|
9 |
+
async def test(model: g4f.Model):
|
10 |
+
try:
|
11 |
+
try:
|
12 |
+
for response in g4f.ChatCompletion.create(
|
13 |
+
model=model,
|
14 |
+
messages=[{"role": "user", "content": "write a poem about a tree"}],
|
15 |
+
temperature=0.1,
|
16 |
+
stream=True
|
17 |
+
):
|
18 |
+
print(response, end="")
|
19 |
+
|
20 |
+
print()
|
21 |
+
except:
|
22 |
+
for response in await g4f.ChatCompletion.create_async(
|
23 |
+
model=model,
|
24 |
+
messages=[{"role": "user", "content": "write a poem about a tree"}],
|
25 |
+
temperature=0.1,
|
26 |
+
stream=True
|
27 |
+
):
|
28 |
+
print(response, end="")
|
29 |
+
|
30 |
+
print()
|
31 |
+
|
32 |
+
return True
|
33 |
+
except Exception as e:
|
34 |
+
print(model.name, "not working:", e)
|
35 |
+
print(e.__traceback__.tb_next)
|
36 |
+
return False
|
37 |
+
|
38 |
+
|
39 |
+
async def start_test():
|
40 |
+
models_to_test = [
|
41 |
+
# GPT-3.5
|
42 |
+
g4f.models.gpt_35_turbo,
|
43 |
+
|
44 |
+
# GPT-4
|
45 |
+
g4f.models.gpt_4,
|
46 |
+
]
|
47 |
+
|
48 |
+
models_working = []
|
49 |
+
|
50 |
+
for model in models_to_test:
|
51 |
+
if await test(model):
|
52 |
+
models_working.append(model.name)
|
53 |
+
|
54 |
+
print("working models:", models_working)
|
55 |
+
|
56 |
+
|
57 |
+
asyncio.run(start_test())
|
gpt4free/etc/testing/test_api.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import openai
|
2 |
+
|
3 |
+
# Set your Hugging Face token as the API key if you use embeddings
|
4 |
+
# If you don't use embeddings, leave it empty
|
5 |
+
openai.api_key = "YOUR_HUGGING_FACE_TOKEN" # Replace with your actual token
|
6 |
+
|
7 |
+
# Set the API base URL if needed, e.g., for a local development environment
|
8 |
+
openai.api_base = "http://localhost:1337/v1"
|
9 |
+
|
10 |
+
def main():
|
11 |
+
response = openai.ChatCompletion.create(
|
12 |
+
model="gpt-3.5-turbo",
|
13 |
+
messages=[{"role": "user", "content": "write a poem about a tree"}],
|
14 |
+
stream=True,
|
15 |
+
)
|
16 |
+
if isinstance(response, dict):
|
17 |
+
# Not streaming
|
18 |
+
print(response.choices[0].message.content)
|
19 |
+
else:
|
20 |
+
# Streaming
|
21 |
+
for token in response:
|
22 |
+
content = token["choices"][0]["delta"].get("content")
|
23 |
+
if content is not None:
|
24 |
+
print(content, end="", flush=True)
|
25 |
+
|
26 |
+
if __name__ == "__main__":
|
27 |
+
main()
|
gpt4free/etc/testing/test_async.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import sys
|
2 |
+
from pathlib import Path
|
3 |
+
import asyncio
|
4 |
+
|
5 |
+
sys.path.append(str(Path(__file__).parent.parent))
|
6 |
+
sys.path.append(str(Path(__file__).parent.parent.parent))
|
7 |
+
|
8 |
+
import g4f
|
9 |
+
from testing._providers import get_providers
|
10 |
+
from testing.log_time import log_time_async
|
11 |
+
|
12 |
+
async def create_async(provider):
|
13 |
+
try:
|
14 |
+
response = await log_time_async(
|
15 |
+
provider.create_async,
|
16 |
+
model=g4f.models.default.name,
|
17 |
+
messages=[{"role": "user", "content": "Hello, are you GPT 3.5?"}]
|
18 |
+
)
|
19 |
+
print(f"{provider.__name__}:", response)
|
20 |
+
except Exception as e:
|
21 |
+
print(f"{provider.__name__}: {e.__class__.__name__}: {e}")
|
22 |
+
|
23 |
+
async def run_async():
|
24 |
+
responses: list = [
|
25 |
+
create_async(provider)
|
26 |
+
for provider in get_providers()
|
27 |
+
if provider.working
|
28 |
+
]
|
29 |
+
await asyncio.gather(*responses)
|
30 |
+
|
31 |
+
print("Total:", asyncio.run(log_time_async(run_async)))
|