This document explains how to set up a local development environment for contributing to the g4f (GPT4Free) project. It covers repository cloning, dependency installation, testing, and the contribution workflow.
The following tools and software are required for g4f development:
| Requirement | Version | Purpose |
|---|---|---|
| Python | 3.10+ recommended | Runtime environment for g4f package |
| Git | Latest | Version control |
| pip | Latest | Package installation and management |
Core Dependencies:
The system relies on requests requirements.txt1 aiohttp requirements.txt4 and curl_cffi requirements.txt3 for networking. Cryptographic operations are handled by pycryptodome requirements.txt2 Web search features utilize ddgs (DuckDuckGo Search) requirements.txt20
Sources: requirements.txt1-26 requirements-slim.txt1-24
Clone the g4f repository from GitHub:
The repository contains several key directories relevant to development:
| Directory | Purpose |
|---|---|
g4f/ | Main package source code (models, providers, client). |
g4f/gui/ | Web interface and backend server logic g4f/gui/server/internet.py1-3 |
etc/unittest/ | Location for adding reversed website logic before refactoring CONTRIBUTING.md5 |
etc/tool/ | Utility scripts for repository maintenance etc/tool/contributers.py1-6 |
The project follows a specific pipeline for adding new providers:
./etc/unittest/ for isolated testing CONTRIBUTING.md5g4f provider interface and move it into the core ./g4f package CONTRIBUTING.md6Sources: CONTRIBUTING.md1-8 g4f/gui/server/internet.py1-3 etc/tool/contributers.py1-6
It is recommended to use a Python virtual environment to isolate development dependencies and avoid conflicts with system packages:
The project provides multiple dependency configurations for different development targets:
| File | Purpose |
|---|---|
requirements.txt | Full development dependencies including GUI (flask, fastapi), image processing (pillow), and desktop integration (pystray) requirements.txt1-26 |
requirements-slim.txt | Minimal dependencies for containerized environments, omitting some GUI components but including markitdown for document processing requirements-slim.txt1-24 |
Sources: requirements.txt1-26 requirements-slim.txt1-24 .gitignore10
The following diagram bridges the Natural Language concepts to the Code Entities used during local development and testing.
Entity Mapping: Request to Execution
Sources: g4f/gui/server/internet.py1-3 requirements.txt11-13
The following diagram illustrates the relationship between the development environment's core libraries and the execution flow.
Development Execution Flow
Sources: requirements.txt1-13 g4f/gui/server/internet.py3
The project maintains a .gitignore file to ensure development artifacts are not committed to the repository. Key ignored paths include:
venv/, pyvenv.cfg .gitignore10dist/, build/, g4f.egg-info/ .gitignore2-8generated_media/, har_and_cookies/, models/models.json .gitignore4-15node_modules/, site-packages/ .gitignore5-7Sources: .gitignore1-15
Refresh this wiki