mfoud444 commited on
Commit
79859e3
·
1 Parent(s): c1b48d6

first commit

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.github/FUNDING.yml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ ko_fi: xtekky
2
+ github: [xtekky, hlohaus]
3
+ patreon: xtekky
.github/ISSUE_TEMPLATE/default_issue.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: New Issue
3
+ about: 'Please use this template !!'
4
+ title: ''
5
+ labels: bug
6
+ assignees: xtekky
7
+
8
+ ---
9
+
10
+ **Known Issues** // delete this
11
+ - you.com issue / fix: use proxy, or vpn, your country is probably flagged
12
+ - forefront account creation error / use your own session or wait for fix
13
+
14
+
15
+ **Bug description**
16
+ What did you do, what happened, which file did you try to run, in which directory
17
+ Describe what you did after downloading repo, such as moving to this repo, running this file.
18
+
19
+ ex.
20
+ 1. Go to '...'
21
+ 2. Click on '....'
22
+ 3. Scroll down to '....'
23
+ 4. See error
24
+
25
+ **Screenshots**
26
+ If applicable, add screenshots to help explain your problem.
27
+
28
+ **Environment**
29
+ - python version
30
+ - location ( are you in a cloudfare flagged country ) ?
31
+
32
+ **Additional context**
33
+ Add any other context about the problem here.
.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.
.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 }}
.github/workflows/copilot.yml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ let download = await github.rest.actions.downloadArtifact({
31
+ owner: context.repo.owner,
32
+ repo: context.repo.repo,
33
+ artifact_id: matchArtifact.id,
34
+ archive_format: 'zip',
35
+ });
36
+ let fs = require('fs');
37
+ fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_number.zip`, Buffer.from(download.data));
38
+ - name: 'Unzip artifact'
39
+ run: unzip pr_number.zip
40
+ - name: Setup Python
41
+ uses: actions/setup-python@v4
42
+ with:
43
+ python-version: "3.x"
44
+ cache: 'pip'
45
+ - name: Install Requirements
46
+ run: |
47
+ pip install -r requirements.txt
48
+ pip install PyGithub
49
+ - name: AI Code Review
50
+ env:
51
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52
+ GITHUB_REPOSITORY: ${{ github.repository }}
53
+ run: python -m etc.tool.copilot
.github/workflows/publish-to-pypi.yml ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 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@v3
29
+ with:
30
+ name: python-package-distributions
31
+ path: dist/
32
+
33
+ publish-to-pypi:
34
+ name: >-
35
+ Publish distribution on PyPI 🐍
36
+ if: startsWith(github.ref, 'refs/tags/')
37
+ needs:
38
+ - build
39
+ runs-on: ubuntu-latest
40
+ environment:
41
+ name: pypi
42
+ url: https://pypi.org/p/g4f
43
+ permissions:
44
+ id-token: write
45
+ steps:
46
+ - name: Download all the dists
47
+ uses: actions/download-artifact@v3
48
+ with:
49
+ name: python-package-distributions
50
+ path: dist/
51
+ - name: Publish distribution 📦 to PyPI
52
+ uses: pypa/gh-action-pypi-publish@release/v1
.github/workflows/publish-workflow.yaml ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish Docker image
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '**'
7
+
8
+ jobs:
9
+ openapi:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - name: Set up Python 3.13
14
+ uses: actions/setup-python@v4
15
+ with:
16
+ python-version: "3.13"
17
+ cache: 'pip'
18
+ - name: Install requirements
19
+ run: |
20
+ pip install fastapi uvicorn python-multipart
21
+ pip install -r requirements-min.txt
22
+ - name: Generate openapi.json
23
+ run: |
24
+ python -m etc.tool.openapi
25
+ - uses: actions/upload-artifact@v4
26
+ with:
27
+ name: openapi
28
+ path: openapi.json
29
+ publish:
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Checkout repository
33
+ uses: actions/checkout@v4
34
+ - name: Set up QEMU
35
+ uses: docker/setup-qemu-action@v3
36
+ - name: Set up Docker Buildx
37
+ uses: docker/setup-buildx-action@v3
38
+
39
+ - name: Get metadata for Docker
40
+ id: metadata
41
+ uses: docker/metadata-action@v5
42
+ with:
43
+ images: |
44
+ hlohaus789/g4f
45
+ ghcr.io/${{ github.repository }}
46
+
47
+ - name: Log in to Docker Hub
48
+ uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
49
+ with:
50
+ username: ${{ secrets.DOCKER_USERNAME }}
51
+ password: ${{ secrets.DOCKER_PASSWORD }}
52
+
53
+ - name: Login to GitHub Container Registry
54
+ uses: docker/login-action@v3
55
+ with:
56
+ registry: ghcr.io
57
+ username: ${{ github.repository_owner }}
58
+ password: ${{ secrets.GHCR_PAT }}
59
+
60
+ - name: Build and push armv7 image
61
+ uses: docker/build-push-action@v5
62
+ with:
63
+ context: .
64
+ file: docker/Dockerfile-armv7
65
+ platforms: linux/arm/v7
66
+ push: true
67
+ tags: |
68
+ hlohaus789/g4f:latest-armv7
69
+ hlohaus789/g4f:${{ github.ref_name }}-armv7
70
+ labels: ${{ steps.metadata.outputs.labels }}
71
+ build-args: |
72
+ G4F_VERSION=${{ github.ref_name }}
73
+
74
+ - name: Build and push small images
75
+ uses: docker/build-push-action@v5
76
+ with:
77
+ context: .
78
+ file: docker/Dockerfile-slim
79
+ platforms: linux/amd64,linux/arm64
80
+ push: true
81
+ tags: |
82
+ hlohaus789/g4f:latest-slim
83
+ hlohaus789/g4f:${{ github.ref_name }}-slim
84
+ labels: ${{ steps.metadata.outputs.labels }}
85
+ build-args: |
86
+ G4F_VERSION=${{ github.ref_name }}
87
+
88
+ - name: Build and push big images
89
+ uses: docker/build-push-action@v5
90
+ with:
91
+ context: .
92
+ file: docker/Dockerfile
93
+ platforms: linux/amd64,linux/arm64
94
+ push: true
95
+ tags: ${{ steps.metadata.outputs.tags }}
96
+ labels: ${{ steps.metadata.outputs.labels }}
97
+ build-args: |
98
+ G4F_VERSION=${{ github.ref_name }}
.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/
.gitignore ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
17
+ # Ignore accounts created by api's
18
+ accounts.txt
19
+
20
+ .idea/
21
+ **/__pycache__/
22
+ __pycache__/
23
+
24
+ dist/
25
+ *.log
26
+ *.pyc
27
+ *.egg-info/
28
+ *.egg
29
+ *.egg-info
30
+ build
31
+
32
+ test.py
33
+ update.py
34
+ cookie.json
35
+ notes.txt
36
+ close_issues.py
37
+ xxx.py
38
+ lab.py
39
+ lab.js
40
+ bing.py
41
+ bing2.py
42
+ .DS_Store
43
+ lab/*
44
+ lab
45
+ tstt.py
46
+ providerstest.py
47
+ prv.py
48
+ # Emacs crap
49
+ *~
50
+ x.js
51
+ x.py
52
+ info.txt
53
+ local.py
54
+ *.gguf
55
+ image.py
56
+ .buildozer
57
+ hardir
58
+ har_and_cookies
59
+ node_modules
60
+ models
61
+ projects/windows/g4f
62
+ doc.txt
63
+ dist.py
64
+ x.txt
65
+ bench.py
66
+ to-reverse.txt
67
+ g4f/Provider/OpenaiChat2.py
68
+ generated_images/
.gitpod.yml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ # Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml)
2
+ # and commit this file to your remote git repository to share the goodness with others.
3
+
4
+ # Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart
5
+
6
+ tasks:
7
+ - init: pip install -r requirements.txt
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.
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 [./testing](https://github.com/xtekky/gpt4free/tree/main/testing)
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!
Dockerfile CHANGED
@@ -1,21 +1,89 @@
1
- # Use the base image
2
- FROM hlohaus789/g4f:latest
3
 
4
- # Set working directory
5
- WORKDIR /app
 
 
 
6
 
7
- # Create necessary directories
8
- RUN mkdir -p /app/har_and_cookies /app/generated_images
 
 
9
 
10
- # Set volume mount points
11
- VOLUME ["/app/har_and_cookies", "/app/generated_images"]
 
 
 
 
 
 
 
 
12
 
13
- # Expose the specified ports 8080 1337 7900
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  EXPOSE 7860
15
 
16
- # Increase shared memory size
17
- # Note: The actual shm-size is set at runtime with --shm-size flag
18
- RUN mkdir -p /dev/shm && chmod 777 /dev/shm
19
 
20
- # Default command to run the container
21
- CMD ["sh", "-c", "exec $CMD"]
 
1
+ FROM seleniarm/node-chromium
 
2
 
3
+ ARG G4F_VERSION
4
+ ARG G4F_USER=g4f
5
+ ARG G4F_USER_ID=1000
6
+ ARG G4F_NO_GUI
7
+ ARG G4F_PASS=secret
8
 
9
+ ENV G4F_VERSION $G4F_VERSION
10
+ ENV G4F_USER $G4F_USER
11
+ ENV G4F_USER_ID $G4F_USER_ID
12
+ ENV G4F_NO_GUI $G4F_NO_GUI
13
 
14
+ ENV SE_SCREEN_WIDTH 1850
15
+ ENV PYTHONUNBUFFERED 1
16
+ ENV G4F_DIR /app
17
+ ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=$G4F_PASS
18
+ ENV HOME /home/$G4F_USER
19
+ ENV PATH $PATH:$HOME/.local/bin
20
+ ENV SE_DOWNLOAD_DIR $HOME/Downloads
21
+ ENV SEL_USER $G4F_USER
22
+ ENV SEL_UID $G4F_USER_ID
23
+ ENV SEL_GID $G4F_USER_ID
24
 
25
+ USER root
26
+
27
+ # If docker compose, install git
28
+ RUN if [ "$G4F_VERSION" = "" ] ; then \
29
+ apt-get -qqy update && \
30
+ apt-get -qqy install git \
31
+ ; fi
32
+
33
+ # Install Python3, pip, remove OpenJDK 11, clean up
34
+ RUN apt-get -qqy update \
35
+ && apt-get -qqy install python3 python-is-python3 pip \
36
+ && apt-get -qyy remove openjdk-11-jre-headless \
37
+ && apt-get -qyy autoremove \
38
+ && apt-get -qyy clean \
39
+ && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
40
+
41
+ # Update entrypoint
42
+ COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
43
+ COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
44
+ COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
45
+
46
+ # If no gui
47
+ RUN if [ "$G4F_NO_GUI" ] ; then \
48
+ rm /etc/supervisor/conf.d/gui.conf \
49
+ ; fi
50
+
51
+ # Change background image
52
+ COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
53
+
54
+ # Add user, fix permissions
55
+ RUN groupadd -g $G4F_USER_ID $G4F_USER \
56
+ && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
57
+ && echo "${G4F_USER}:${G4F_PASS}" | chpasswd \
58
+ && mkdir "${SE_DOWNLOAD_DIR}" \
59
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor \
60
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" -R /opt/bin/ /usr/bin/chromedriver /opt/selenium/
61
+
62
+ # Switch user
63
+ USER $G4F_USER_ID
64
+
65
+ # Set VNC password
66
+ RUN mkdir -p ${HOME}/.vnc \
67
+ && x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
68
+
69
+ # Set the working directory in the container.
70
+ WORKDIR $G4F_DIR
71
+
72
+ # Copy the project's requirements file into the container.
73
+ COPY requirements.txt $G4F_DIR
74
+
75
+ # Upgrade pip for the latest features and install the project's Python dependencies.
76
+ RUN pip install --break-system-packages --upgrade pip \
77
+ && pip install --break-system-packages -r requirements.txt \
78
+ && pip install --break-system-packages \
79
+ undetected-chromedriver selenium-wire \
80
+ && pip uninstall -y --break-system-packages \
81
+ pywebview plyer
82
+
83
+ # Copy the entire package into the container.
84
+ ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
85
+
86
+ # Expose ports
87
  EXPOSE 7860
88
 
 
 
 
89
 
 
 
Dockerfile copy ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM seleniarm/node-chromium
2
+
3
+ ARG G4F_VERSION
4
+ ARG G4F_USER=g4f
5
+ ARG G4F_USER_ID=1000
6
+ ARG G4F_NO_GUI
7
+ ARG G4F_PASS=secret
8
+
9
+ ENV G4F_VERSION $G4F_VERSION
10
+ ENV G4F_USER $G4F_USER
11
+ ENV G4F_USER_ID $G4F_USER_ID
12
+ ENV G4F_NO_GUI $G4F_NO_GUI
13
+
14
+ ENV SE_SCREEN_WIDTH 1850
15
+ ENV PYTHONUNBUFFERED 1
16
+ ENV G4F_DIR /app
17
+ ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=$G4F_PASS
18
+ ENV HOME /home/$G4F_USER
19
+ ENV PATH $PATH:$HOME/.local/bin
20
+ ENV SE_DOWNLOAD_DIR $HOME/Downloads
21
+ ENV SEL_USER $G4F_USER
22
+ ENV SEL_UID $G4F_USER_ID
23
+ ENV SEL_GID $G4F_USER_ID
24
+
25
+ USER root
26
+
27
+ # If docker compose, install git
28
+ RUN if [ "$G4F_VERSION" = "" ] ; then \
29
+ apt-get -qqy update && \
30
+ apt-get -qqy install git \
31
+ ; fi
32
+
33
+ # Install Python3, pip, remove OpenJDK 11, clean up
34
+ RUN apt-get -qqy update \
35
+ && apt-get -qqy install python3 python-is-python3 pip \
36
+ && apt-get -qyy remove openjdk-11-jre-headless \
37
+ && apt-get -qyy autoremove \
38
+ && apt-get -qyy clean \
39
+ && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
40
+
41
+ # Update entrypoint
42
+ COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
43
+ COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
44
+ COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
45
+
46
+ # If no gui
47
+ RUN if [ "$G4F_NO_GUI" ] ; then \
48
+ rm /etc/supervisor/conf.d/gui.conf \
49
+ ; fi
50
+
51
+ # Change background image
52
+ COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
53
+
54
+ # Add user, fix permissions
55
+ RUN groupadd -g $G4F_USER_ID $G4F_USER \
56
+ && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
57
+ && echo "${G4F_USER}:${G4F_PASS}" | chpasswd \
58
+ && mkdir "${SE_DOWNLOAD_DIR}" \
59
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor \
60
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" -R /opt/bin/ /usr/bin/chromedriver /opt/selenium/
61
+
62
+ # Switch user
63
+ USER $G4F_USER_ID
64
+
65
+ # Set VNC password
66
+ RUN mkdir -p ${HOME}/.vnc \
67
+ && x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
68
+
69
+ # Set the working directory in the container.
70
+ WORKDIR $G4F_DIR
71
+
72
+ # Copy the project's requirements file into the container.
73
+ COPY requirements.txt $G4F_DIR
74
+
75
+ # Upgrade pip for the latest features and install the project's Python dependencies.
76
+ RUN pip install --break-system-packages --upgrade pip \
77
+ && pip install --break-system-packages -r requirements.txt \
78
+ && pip install --break-system-packages \
79
+ undetected-chromedriver selenium-wire \
80
+ && pip uninstall -y --break-system-packages \
81
+ pywebview plyer
82
+
83
+ # Copy the entire package into the container.
84
+ ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
85
+
86
+ # Expose ports
87
+ EXPOSE 8080 1337
Dockerfile-armv7 ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 \
15
+ && apt-get install --quiet --yes --no-install-recommends \
16
+ build-essential \
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:${PATH}"
30
+
31
+ # Create app dir and copy the project's requirements file into it
32
+ RUN mkdir -p $G4F_DIR
33
+ COPY requirements-min.txt $G4F_DIR
34
+ COPY requirements-slim.txt $G4F_DIR
35
+
36
+ # Upgrade pip for the latest features and install the project's Python dependencies.
37
+ RUN pip install --no-cache-dir -r requirements-min.txt \
38
+ && pip install --no-cache-dir --no-binary setuptools \
39
+ Cython==0.29.22 \
40
+ setuptools \
41
+ # Install PyDantic
42
+ && pip install \
43
+ -vvv \
44
+ --no-cache-dir \
45
+ --no-binary :all: \
46
+ --global-option=build_ext \
47
+ --global-option=-j8 \
48
+ pydantic==${PYDANTIC_VERSION}
49
+ RUN cat requirements-slim.txt | xargs -n 1 pip install --no-cache-dir || true
50
+
51
+ # Remove build packages
52
+ RUN pip uninstall --yes \
53
+ Cython \
54
+ setuptools
55
+
56
+ USER root
57
+
58
+ # Clean up build deps
59
+ RUN apt-get purge --auto-remove --yes \
60
+ build-essential \
61
+ && apt-get clean \
62
+ && rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*
63
+
64
+ USER $G4F_USER_ID
65
+
66
+ # Copy the entire package into the container.
67
+ ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
Dockerfile-slim ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:slim-bookworm
2
+
3
+ ARG G4F_VERSION
4
+ ARG G4F_USER=g4f
5
+ ARG G4F_USER_ID=1000
6
+
7
+ ENV G4F_VERSION $G4F_VERSION
8
+ ENV G4F_USER $G4F_USER
9
+ ENV G4F_USER_ID $G4F_USER_ID
10
+ ENV G4F_DIR /app
11
+
12
+ RUN apt-get update && apt-get upgrade -y \
13
+ && apt-get install -y git \
14
+ # Add user and user group
15
+ && groupadd -g $G4F_USER_ID $G4F_USER \
16
+ && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
17
+ && mkdir -p /var/log/supervisor \
18
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" /var/log/supervisor \
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
+ USER $G4F_USER_ID
25
+ WORKDIR $G4F_DIR
26
+
27
+ ENV HOME /home/$G4F_USER
28
+ ENV PATH "${HOME}/.local/bin:${PATH}"
29
+
30
+ # Create app dir and copy the project's requirements file into it
31
+ RUN mkdir -p $G4F_DIR
32
+ COPY requirements-slim.txt $G4F_DIR
33
+
34
+ # Upgrade pip for the latest features and install the project's Python dependencies.
35
+ RUN pip install --no-cache-dir -r requirements-slim.txt \
36
+ && pip install --no-cache-dir duckduckgo-search>=5.0
37
+
38
+ # Copy the entire package into the container.
39
+ ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
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.
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>.
MANIFEST.in ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ recursive-include g4f/gui/server *
2
+ recursive-include g4f/gui/client *
3
+ recursive-include g4f/Provider/npm *
4
+ recursive-include g4f/Provider/gigachat_crt *
5
+ recursive-include g4f/Provider/you *
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.
background.png ADDED
docker-compose-slim.yml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3'
2
+
3
+ services:
4
+ g4f-gui:
5
+ container_name: g4f-gui
6
+ image: hlohaus789/g4f:slim
7
+ build:
8
+ context: .
9
+ dockerfile: docker/Dockerfile-slim
10
+ command: python -m g4f.cli gui -debug
11
+ volumes:
12
+ - .:/app
13
+ ports:
14
+ - '8080:8080'
15
+ g4f-api:
16
+ container_name: g4f-api
17
+ image: hlohaus789/g4f:slim
18
+ build:
19
+ context: .
20
+ dockerfile: docker/Dockerfile-slim
21
+ command: python -m g4f.cli api
22
+ volumes:
23
+ - .:/app
24
+ ports:
25
+ - '1337:1337'
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:1337'
15
+ - '7900:7900'
16
+ environment:
17
+ - OLLAMA_HOST=host.docker.internal
docker/Dockerfile ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM seleniarm/node-chromium
2
+
3
+ ARG G4F_VERSION
4
+ ARG G4F_USER=g4f
5
+ ARG G4F_USER_ID=1000
6
+ ARG G4F_NO_GUI
7
+ ARG G4F_PASS=secret
8
+
9
+ ENV G4F_VERSION $G4F_VERSION
10
+ ENV G4F_USER $G4F_USER
11
+ ENV G4F_USER_ID $G4F_USER_ID
12
+ ENV G4F_NO_GUI $G4F_NO_GUI
13
+
14
+ ENV SE_SCREEN_WIDTH 1850
15
+ ENV PYTHONUNBUFFERED 1
16
+ ENV G4F_DIR /app
17
+ ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=$G4F_PASS
18
+ ENV HOME /home/$G4F_USER
19
+ ENV PATH $PATH:$HOME/.local/bin
20
+ ENV SE_DOWNLOAD_DIR $HOME/Downloads
21
+ ENV SEL_USER $G4F_USER
22
+ ENV SEL_UID $G4F_USER_ID
23
+ ENV SEL_GID $G4F_USER_ID
24
+
25
+ USER root
26
+
27
+ # If docker compose, install git
28
+ RUN if [ "$G4F_VERSION" = "" ] ; then \
29
+ apt-get -qqy update && \
30
+ apt-get -qqy install git \
31
+ ; fi
32
+
33
+ # Install Python3, pip, remove OpenJDK 11, clean up
34
+ RUN apt-get -qqy update \
35
+ && apt-get -qqy install python3 python-is-python3 pip \
36
+ && apt-get -qyy remove openjdk-11-jre-headless \
37
+ && apt-get -qyy autoremove \
38
+ && apt-get -qyy clean \
39
+ && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
40
+
41
+ # Update entrypoint
42
+ COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
43
+ COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
44
+ COPY docker/supervisor-gui.conf /etc/supervisor/conf.d/gui.conf
45
+
46
+ # If no gui
47
+ RUN if [ "$G4F_NO_GUI" ] ; then \
48
+ rm /etc/supervisor/conf.d/gui.conf \
49
+ ; fi
50
+
51
+ # Change background image
52
+ COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
53
+
54
+ # Add user, fix permissions
55
+ RUN groupadd -g $G4F_USER_ID $G4F_USER \
56
+ && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
57
+ && echo "${G4F_USER}:${G4F_PASS}" | chpasswd \
58
+ && mkdir "${SE_DOWNLOAD_DIR}" \
59
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" $SE_DOWNLOAD_DIR /var/run/supervisor /var/log/supervisor \
60
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" -R /opt/bin/ /usr/bin/chromedriver /opt/selenium/
61
+
62
+ # Switch user
63
+ USER $G4F_USER_ID
64
+
65
+ # Set VNC password
66
+ RUN mkdir -p ${HOME}/.vnc \
67
+ && x11vnc -storepasswd ${G4F_PASS} ${HOME}/.vnc/passwd
68
+
69
+ # Set the working directory in the container.
70
+ WORKDIR $G4F_DIR
71
+
72
+ # Copy the project's requirements file into the container.
73
+ COPY requirements.txt $G4F_DIR
74
+
75
+ # Upgrade pip for the latest features and install the project's Python dependencies.
76
+ RUN pip install --break-system-packages --upgrade pip \
77
+ && pip install --break-system-packages -r requirements.txt \
78
+ && pip install --break-system-packages \
79
+ undetected-chromedriver selenium-wire \
80
+ && pip uninstall -y --break-system-packages \
81
+ pywebview plyer
82
+
83
+ # Copy the entire package into the container.
84
+ ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
85
+
86
+ # Expose ports
87
+ EXPOSE 8080 1337
docker/Dockerfile-armv7 ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 \
15
+ && apt-get install --quiet --yes --no-install-recommends \
16
+ build-essential \
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:${PATH}"
30
+
31
+ # Create app dir and copy the project's requirements file into it
32
+ RUN mkdir -p $G4F_DIR
33
+ COPY requirements-min.txt $G4F_DIR
34
+ COPY requirements-slim.txt $G4F_DIR
35
+
36
+ # Upgrade pip for the latest features and install the project's Python dependencies.
37
+ RUN pip install --no-cache-dir -r requirements-min.txt \
38
+ && pip install --no-cache-dir --no-binary setuptools \
39
+ Cython==0.29.22 \
40
+ setuptools \
41
+ # Install PyDantic
42
+ && pip install \
43
+ -vvv \
44
+ --no-cache-dir \
45
+ --no-binary :all: \
46
+ --global-option=build_ext \
47
+ --global-option=-j8 \
48
+ pydantic==${PYDANTIC_VERSION}
49
+ RUN cat requirements-slim.txt | xargs -n 1 pip install --no-cache-dir || true
50
+
51
+ # Remove build packages
52
+ RUN pip uninstall --yes \
53
+ Cython \
54
+ setuptools
55
+
56
+ USER root
57
+
58
+ # Clean up build deps
59
+ RUN apt-get purge --auto-remove --yes \
60
+ build-essential \
61
+ && apt-get clean \
62
+ && rm --recursive --force /var/lib/apt/lists/* /tmp/* /var/tmp/*
63
+
64
+ USER $G4F_USER_ID
65
+
66
+ # Copy the entire package into the container.
67
+ ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
docker/Dockerfile-slim ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:slim-bookworm
2
+
3
+ ARG G4F_VERSION
4
+ ARG G4F_USER=g4f
5
+ ARG G4F_USER_ID=1000
6
+
7
+ ENV G4F_VERSION $G4F_VERSION
8
+ ENV G4F_USER $G4F_USER
9
+ ENV G4F_USER_ID $G4F_USER_ID
10
+ ENV G4F_DIR /app
11
+
12
+ RUN apt-get update && apt-get upgrade -y \
13
+ && apt-get install -y git \
14
+ # Add user and user group
15
+ && groupadd -g $G4F_USER_ID $G4F_USER \
16
+ && useradd -rm -G sudo -u $G4F_USER_ID -g $G4F_USER_ID $G4F_USER \
17
+ && mkdir -p /var/log/supervisor \
18
+ && chown "${G4F_USER_ID}:${G4F_USER_ID}" /var/log/supervisor \
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
+ USER $G4F_USER_ID
25
+ WORKDIR $G4F_DIR
26
+
27
+ ENV HOME /home/$G4F_USER
28
+ ENV PATH "${HOME}/.local/bin:${PATH}"
29
+
30
+ # Create app dir and copy the project's requirements file into it
31
+ RUN mkdir -p $G4F_DIR
32
+ COPY requirements-slim.txt $G4F_DIR
33
+
34
+ # Upgrade pip for the latest features and install the project's Python dependencies.
35
+ RUN pip install --no-cache-dir -r requirements-slim.txt \
36
+ && pip install --no-cache-dir duckduckgo-search>=5.0
37
+
38
+ # Copy the entire package into the container.
39
+ ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
docker/background.png ADDED
docker/supervisor-api.conf ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [program:g4f-api]
2
+ priority=15
3
+ command=python -m g4f.cli api
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
docker/supervisor-gui.conf ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [program:g4f-gui]
2
+ priority=15
3
+ command=python -m g4f.cli gui -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
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
docs/async_client.md ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # G4F - AsyncClient API Guide
3
+ The G4F AsyncClient API is a powerful asynchronous interface for interacting with various AI models. This guide provides comprehensive information on how to use the API effectively, including setup, usage examples, best practices, and important considerations for optimal performance.
4
+
5
+
6
+ ## Compatibility Note
7
+ The G4F AsyncClient API is designed to be compatible with the OpenAI API, making it easy for developers familiar with OpenAI's interface to transition to G4F.
8
+
9
+ ## Table of Contents
10
+ - [Introduction](#introduction)
11
+ - [Key Features](#key-features)
12
+ - [Getting Started](#getting-started)
13
+ - [Initializing the Client](#initializing-the-client)
14
+ - [Creating Chat Completions](#creating-chat-completions)
15
+ - [Configuration](#configuration)
16
+ - [Usage Examples](#usage-examples)
17
+ - [Text Completions](#text-completions)
18
+ - [Streaming Completions](#streaming-completions)
19
+ - [Using a Vision Model](#using-a-vision-model)
20
+ - [Image Generation](#image-generation)
21
+ - [Concurrent Tasks](#concurrent-tasks-with-asynciogather)
22
+ - [Available Models and Providers](#available-models-and-providers)
23
+ - [Error Handling and Best Practices](#error-handling-and-best-practices)
24
+ - [Rate Limiting and API Usage](#rate-limiting-and-api-usage)
25
+ - [Conclusion](#conclusion)
26
+
27
+
28
+
29
+ ## Introduction
30
+ The G4F AsyncClient API is an asynchronous version of the standard G4F Client API. It offers the same functionality as the synchronous API but with improved performance due to its asynchronous nature. This guide will walk you through the key features and usage of the G4F AsyncClient API.
31
+
32
+
33
+ ## Key Features
34
+ - **Custom Providers**: Use custom providers for enhanced flexibility.
35
+ - **ChatCompletion Interface**: Interact with chat models through the ChatCompletion class.
36
+ - **Streaming Responses**: Get responses iteratively as they are received.
37
+ - **Non-Streaming Responses**: Generate complete responses in a single call.
38
+ - **Image Generation and Vision Models**: Support for image-related tasks.
39
+
40
+
41
+
42
+ ## Getting Started
43
+ ### Initializing the AsyncClient
44
+ **To use the G4F `AsyncClient`, create a new instance:**
45
+ ```python
46
+ from g4f.client import AsyncClient
47
+ from g4f.Provider import OpenaiChat, Gemini
48
+
49
+ client = AsyncClient(
50
+ provider=OpenaiChat,
51
+ image_provider=Gemini,
52
+ # Add other parameters as needed
53
+ )
54
+ ```
55
+
56
+
57
+ ## Creating Chat Completions
58
+ **Here’s an improved example of creating chat completions:**
59
+ ```python
60
+ response = await client.chat.completions.create(
61
+ model="gpt-4o-mini",
62
+ messages=[
63
+ {
64
+ "role": "user",
65
+ "content": "Say this is a test"
66
+ }
67
+ ]
68
+ # Add other parameters as needed
69
+ )
70
+ ```
71
+
72
+ **This example:**
73
+ - Asks a specific question `Say this is a test`
74
+ - Configures various parameters like temperature and max_tokens for more control over the output
75
+ - Disables streaming for a complete response
76
+
77
+ You can adjust these parameters based on your specific needs.
78
+
79
+
80
+ ### Configuration
81
+ **Configure the `AsyncClient` with additional settings:**
82
+ ```python
83
+ client = AsyncClient(
84
+ api_key="your_api_key_here",
85
+ proxies="http://user:pass@host",
86
+ # Add other parameters as needed
87
+ )
88
+ ```
89
+
90
+
91
+
92
+ ## Usage Examples
93
+ ### Text Completions
94
+ **Generate text completions using the ChatCompletions endpoint:**
95
+ ```python
96
+ import asyncio
97
+ from g4f.client import AsyncClient
98
+
99
+ async def main():
100
+ client = AsyncClient()
101
+
102
+ response = await client.chat.completions.create(
103
+ model="gpt-4o-mini",
104
+ messages=[
105
+ {
106
+ "role": "user",
107
+ "content": "Say this is a test"
108
+ }
109
+ ]
110
+ )
111
+
112
+ print(response.choices[0].message.content)
113
+
114
+ asyncio.run(main())
115
+ ```
116
+
117
+
118
+
119
+ ### Streaming Completions
120
+ **Process responses incrementally as they are generated:**
121
+ ```python
122
+ import asyncio
123
+ from g4f.client import AsyncClient
124
+
125
+ async def main():
126
+ client = AsyncClient()
127
+
128
+ stream = client.chat.completions.create(
129
+ model="gpt-4",
130
+ messages=[
131
+ {
132
+ "role": "user",
133
+ "content": "Say this is a test"
134
+ }
135
+ ],
136
+ stream=True,
137
+ )
138
+
139
+ async for chunk in stream:
140
+ if chunk.choices and chunk.choices[0].delta.content:
141
+ print(chunk.choices[0].delta.content, end="")
142
+
143
+ asyncio.run(main())
144
+ ```
145
+
146
+
147
+
148
+ ### Using a Vision Model
149
+ **Analyze an image and generate a description:**
150
+ ```python
151
+ import g4f
152
+ import requests
153
+ import asyncio
154
+ from g4f.client import AsyncClient
155
+
156
+ async def main():
157
+ client = AsyncClient(
158
+ provider=g4f.Provider.CopilotAccount
159
+ )
160
+
161
+ image = requests.get("https://raw.githubusercontent.com/xtekky/gpt4free/refs/heads/main/docs/cat.jpeg", stream=True).raw
162
+
163
+ response = await client.chat.completions.create(
164
+ model=g4f.models.default,
165
+ messages=[
166
+ {
167
+ "role": "user",
168
+ "content": "What's in this image?"
169
+ }
170
+ ],
171
+ image=image
172
+ )
173
+
174
+ print(response.choices[0].message.content)
175
+
176
+ asyncio.run(main())
177
+ ```
178
+
179
+
180
+
181
+ ### Image Generation
182
+ **Generate images using a specified prompt:**
183
+ ```python
184
+ import asyncio
185
+ from g4f.client import AsyncClient
186
+
187
+ async def main():
188
+ client = AsyncClient()
189
+
190
+ response = await client.images.generate(
191
+ prompt="a white siamese cat",
192
+ model="flux"
193
+ )
194
+
195
+ image_url = response.data[0].url
196
+ print(f"Generated image URL: {image_url}")
197
+
198
+ asyncio.run(main())
199
+ ```
200
+
201
+
202
+
203
+ #### Base64 Response Format
204
+ ```python
205
+ import asyncio
206
+ from g4f.client import AsyncClient
207
+
208
+ async def main():
209
+ client = AsyncClient()
210
+
211
+ response = await client.images.generate(
212
+ prompt="a white siamese cat",
213
+ model="flux",
214
+ response_format="b64_json"
215
+ )
216
+
217
+ base64_text = response.data[0].b64_json
218
+ print(base64_text)
219
+
220
+ asyncio.run(main())
221
+ ```
222
+
223
+
224
+
225
+ ### Concurrent Tasks with asyncio.gather
226
+ **Execute multiple tasks concurrently:**
227
+ ```python
228
+ import asyncio
229
+ from g4f.client import AsyncClient
230
+
231
+ async def main():
232
+ client = AsyncClient()
233
+
234
+ task1 = client.chat.completions.create(
235
+ model=None,
236
+ messages=[
237
+ {
238
+ "role": "user",
239
+ "content": "Say this is a test"
240
+ }
241
+ ]
242
+ )
243
+
244
+ task2 = client.images.generate(
245
+ model="flux",
246
+ prompt="a white siamese cat"
247
+ )
248
+
249
+ try:
250
+ chat_response, image_response = await asyncio.gather(task1, task2)
251
+
252
+ print("Chat Response:")
253
+ print(chat_response.choices[0].message.content)
254
+
255
+ print("\nImage Response:")
256
+ print(image_response.data[0].url)
257
+ except Exception as e:
258
+ print(f"An error occurred: {e}")
259
+
260
+ asyncio.run(main())
261
+ ```
262
+
263
+
264
+
265
+ ## Available Models and Providers
266
+ The G4F AsyncClient supports a wide range of AI models and providers, allowing you to choose the best option for your specific use case. **Here's a brief overview of the available models and providers:**
267
+
268
+ ### Models
269
+ - GPT-3.5-Turbo
270
+ - GPT-4o-Mini
271
+ - GPT-4
272
+ - DALL-E 3
273
+ - Gemini
274
+ - Claude (Anthropic)
275
+ - And more...
276
+
277
+
278
+
279
+ ### Providers
280
+ - OpenAI
281
+ - Google (for Gemini)
282
+ - Anthropic
283
+ - Microsoft Copilot
284
+ - Custom providers
285
+
286
+
287
+ **To use a specific model or provider, specify it when creating the client or in the API call:**
288
+ ```python
289
+ client = AsyncClient(provider=g4f.Provider.OpenaiChat)
290
+
291
+ # or
292
+
293
+ response = await client.chat.completions.create(
294
+ model="gpt-4",
295
+ provider=g4f.Provider.Bing,
296
+ messages=[
297
+ {
298
+ "role": "user",
299
+ "content": "Hello, world!"
300
+ }
301
+ ]
302
+ )
303
+ ```
304
+
305
+
306
+
307
+ ## Error Handling and Best Practices
308
+ Implementing proper error handling and following best practices is crucial when working with the G4F AsyncClient API. This ensures your application remains robust and can gracefully handle various scenarios. **Here are some key practices to follow:**
309
+
310
+ 1. **Use try-except blocks to catch and handle exceptions:**
311
+ ```python
312
+ try:
313
+ response = await client.chat.completions.create(
314
+ model="gpt-4o-mini",
315
+ messages=[
316
+ {
317
+ "role": "user",
318
+ "content": "Hello, world!"
319
+ }
320
+ ]
321
+ )
322
+ except Exception as e:
323
+ print(f"An error occurred: {e}")
324
+ ```
325
+
326
+ 2. **Check the response status and handle different scenarios:**
327
+ ```python
328
+ if response.choices:
329
+ print(response.choices[0].message.content)
330
+ else:
331
+ print("No response generated")
332
+ ```
333
+
334
+ 3. **Implement retries for transient errors:**
335
+ ```python
336
+ import asyncio
337
+ from tenacity import retry, stop_after_attempt, wait_exponential
338
+
339
+ @retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))
340
+ async def make_api_call():
341
+ # Your API call here
342
+ pass
343
+ ```
344
+
345
+
346
+
347
+ ## Rate Limiting and API Usage
348
+ When working with the G4F AsyncClient API, it's important to implement rate limiting and monitor your API usage. This helps ensure fair usage, prevents overloading the service, and optimizes your application's performance. Here are some key strategies to consider:
349
+
350
+
351
+ 1. **Implement rate limiting in your application:**
352
+ ```python
353
+ import asyncio
354
+ from aiolimiter import AsyncLimiter
355
+
356
+ rate_limit = AsyncLimiter(max_rate=10, time_period=1) # 10 requests per second
357
+
358
+ async def make_api_call():
359
+ async with rate_limit:
360
+ # Your API call here
361
+ pass
362
+ ```
363
+
364
+
365
+
366
+ 2. **Monitor your API usage and implement logging:**
367
+ ```python
368
+ import logging
369
+
370
+ logging.basicConfig(level=logging.INFO)
371
+ logger = logging.getLogger(__name__)
372
+
373
+ async def make_api_call():
374
+ try:
375
+ response = await client.chat.completions.create(...)
376
+ logger.info(f"API call successful. Tokens used: {response.usage.total_tokens}")
377
+ except Exception as e:
378
+ logger.error(f"API call failed: {e}")
379
+ ```
380
+
381
+
382
+
383
+ 3. **Use caching to reduce API calls for repeated queries:**
384
+ ```python
385
+ from functools import lru_cache
386
+
387
+ @lru_cache(maxsize=100)
388
+ def get_cached_response(query):
389
+ # Your API call here
390
+ pass
391
+ ```
392
+
393
+ ## Conclusion
394
+ The G4F AsyncClient API provides a powerful and flexible way to interact with various AI models asynchronously. By leveraging its features and following best practices, you can build efficient and responsive applications that harness the power of AI for text generation, image analysis, and image creation.
395
+
396
+ Remember to handle errors gracefully, implement rate limiting, and monitor your API usage to ensure optimal performance and reliability in your applications.
397
+
398
+ ---
399
+
400
+ [Return to Home](/)
docs/cat.jpeg ADDED
docs/cat.webp ADDED
docs/client.md ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # G4F Client API Guide
3
+
4
+
5
+ ## Table of Contents
6
+ - [Introduction](#introduction)
7
+ - [Getting Started](#getting-started)
8
+ - [Switching to G4F Client](#switching-to-g4f-client)
9
+ - [Initializing the Client](#initializing-the-client)
10
+ - [Creating Chat Completions](#creating-chat-completions)
11
+ - [Configuration](#configuration)
12
+ - [Usage Examples](#usage-examples)
13
+ - [Text Completions](#text-completions)
14
+ - [Streaming Completions](#streaming-completions)
15
+ - [Image Generation](#image-generation)
16
+ - [Creating Image Variations](#creating-image-variations)
17
+ - [Advanced Usage](#advanced-usage)
18
+ - [Using a List of Providers with RetryProvider](#using-a-list-of-providers-with-retryprovider)
19
+ - [Using GeminiProVision](#using-geminiprovision)
20
+ - [Using a Vision Model](#using-a-vision-model)
21
+ - [Command-line Chat Program](#command-line-chat-program)
22
+
23
+
24
+
25
+ ## Introduction
26
+ Welcome to the G4F Client API, a cutting-edge tool for seamlessly integrating advanced AI capabilities into your Python applications. This guide is designed to facilitate your transition from using the OpenAI client to the G4F Client, offering enhanced features while maintaining compatibility with the existing OpenAI API.
27
+
28
+ ## Getting Started
29
+ ### Switching to G4F Client
30
+ **To begin using the G4F Client, simply update your import statement in your Python code:**
31
+
32
+ **Old Import:**
33
+ ```python
34
+ from openai import OpenAI
35
+ ```
36
+
37
+
38
+
39
+ **New Import:**
40
+ ```python
41
+ from g4f.client import Client as OpenAI
42
+ ```
43
+
44
+
45
+
46
+ The G4F Client preserves the same familiar API interface as OpenAI, ensuring a smooth transition process.
47
+
48
+ ## Initializing the Client
49
+ To utilize the G4F Client, create a new instance. **Below is an example showcasing custom providers:**
50
+ ```python
51
+ from g4f.client import Client
52
+ from g4f.Provider import BingCreateImages, OpenaiChat, Gemini
53
+
54
+ client = Client(
55
+ provider=OpenaiChat,
56
+ image_provider=Gemini,
57
+ # Add any other necessary parameters
58
+ )
59
+ ```
60
+
61
+ ## Creating Chat Completions
62
+ **Here’s an improved example of creating chat completions:**
63
+ ```python
64
+ response = client.chat.completions.create(
65
+ model="gpt-4o-mini",
66
+ messages=[
67
+ {
68
+ "role": "user",
69
+ "content": "Say this is a test"
70
+ }
71
+ ]
72
+ # Add any other necessary parameters
73
+ )
74
+ ```
75
+
76
+ **This example:**
77
+ - Asks a specific question `Say this is a test`
78
+ - Configures various parameters like temperature and max_tokens for more control over the output
79
+ - Disables streaming for a complete response
80
+
81
+ You can adjust these parameters based on your specific needs.
82
+
83
+
84
+ ## Configuration
85
+ **You can set an `api_key` for your provider in the client and define a proxy for all outgoing requests:**
86
+ ```python
87
+ from g4f.client import Client
88
+
89
+ client = Client(
90
+ api_key="your_api_key_here",
91
+ proxies="http://user:pass@host",
92
+ # Add any other necessary parameters
93
+ )
94
+ ```
95
+
96
+
97
+
98
+ ## Usage Examples
99
+ ### Text Completions
100
+ **Generate text completions using the `ChatCompletions` endpoint:**
101
+ ```python
102
+ from g4f.client import Client
103
+
104
+ client = Client()
105
+
106
+ response = client.chat.completions.create(
107
+ model="gpt-4o-mini",
108
+ messages=[
109
+ {
110
+ "role": "user",
111
+ "content": "Say this is a test"
112
+ }
113
+ ]
114
+ # Add any other necessary parameters
115
+ )
116
+
117
+ print(response.choices[0].message.content)
118
+ ```
119
+
120
+
121
+
122
+ ### Streaming Completions
123
+ **Process responses incrementally as they are generated:**
124
+ ```python
125
+ from g4f.client import Client
126
+
127
+ client = Client()
128
+
129
+ stream = client.chat.completions.create(
130
+ model="gpt-4",
131
+ messages=[
132
+ {
133
+ "role": "user",
134
+ "content": "Say this is a test"
135
+ }
136
+ ],
137
+ stream=True,
138
+ )
139
+
140
+ for chunk in stream:
141
+ if chunk.choices[0].delta.content:
142
+ print(chunk.choices[0].delta.content or "", end="")
143
+ ```
144
+
145
+
146
+
147
+ ### Image Generation
148
+ **Generate images using a specified prompt:**
149
+ ```python
150
+ from g4f.client import Client
151
+
152
+ client = Client()
153
+
154
+ response = client.images.generate(
155
+ model="flux",
156
+ prompt="a white siamese cat"
157
+ # Add any other necessary parameters
158
+ )
159
+
160
+ image_url = response.data[0].url
161
+
162
+ print(f"Generated image URL: {image_url}")
163
+ ```
164
+
165
+
166
+ #### Base64 Response Format
167
+ ```python
168
+ from g4f.client import Client
169
+
170
+ client = Client()
171
+
172
+ response = client.images.generate(
173
+ model="flux",
174
+ prompt="a white siamese cat",
175
+ response_format="b64_json"
176
+ )
177
+
178
+ base64_text = response.data[0].b64_json
179
+ print(base64_text)
180
+ ```
181
+
182
+
183
+
184
+ ### Creating Image Variations
185
+ **Create variations of an existing image:**
186
+ ```python
187
+ from g4f.client import Client
188
+
189
+ client = Client()
190
+
191
+ response = client.images.create_variation(
192
+ image=open("cat.jpg", "rb"),
193
+ model="bing"
194
+ # Add any other necessary parameters
195
+ )
196
+
197
+ image_url = response.data[0].url
198
+
199
+ print(f"Generated image URL: {image_url}")
200
+ ```
201
+
202
+
203
+
204
+ ## Advanced Usage
205
+
206
+ ### Using a List of Providers with RetryProvider
207
+ ```python
208
+ from g4f.client import Client
209
+ from g4f.Provider import RetryProvider, Phind, FreeChatgpt, Liaobots
210
+ import g4f.debug
211
+
212
+ g4f.debug.logging = True
213
+ g4f.debug.version_check = False
214
+
215
+ client = Client(
216
+ provider=RetryProvider([Phind, FreeChatgpt, Liaobots], shuffle=False)
217
+ )
218
+
219
+ response = client.chat.completions.create(
220
+ model="",
221
+ messages=[
222
+ {
223
+ "role": "user",
224
+ "content": "Hello"
225
+ }
226
+ ]
227
+ )
228
+
229
+ print(response.choices[0].message.content)
230
+ ```
231
+
232
+
233
+ ### Using GeminiProVision
234
+ ```python
235
+ from g4f.client import Client
236
+ from g4f.Provider.GeminiPro import GeminiPro
237
+
238
+ client = Client(
239
+ api_key="your_api_key_here",
240
+ provider=GeminiPro
241
+ )
242
+
243
+ response = client.chat.completions.create(
244
+ model="gemini-pro-vision",
245
+ messages=[
246
+ {
247
+ "role": "user",
248
+ "content": "What are on this image?"
249
+ }
250
+ ],
251
+ image=open("docs/waterfall.jpeg", "rb")
252
+ )
253
+
254
+ print(response.choices[0].message.content)
255
+ ```
256
+
257
+
258
+ ### Using a Vision Model
259
+ **Analyze an image and generate a description:**
260
+ ```python
261
+ import g4f
262
+ import requests
263
+ from g4f.client import Client
264
+
265
+ image = requests.get("https://raw.githubusercontent.com/xtekky/gpt4free/refs/heads/main/docs/cat.jpeg", stream=True).raw
266
+ # Or: image = open("docs/cat.jpeg", "rb")
267
+
268
+ client = Client(
269
+ provider=CopilotAccount
270
+ )
271
+
272
+ response = client.chat.completions.create(
273
+ model=g4f.models.default,
274
+ messages=[
275
+ {
276
+ "role": "user",
277
+ "content": "What are on this image?"
278
+ }
279
+ ],
280
+ image=image
281
+ # Add any other necessary parameters
282
+ )
283
+
284
+ print(response.choices[0].message.content)
285
+ ```
286
+
287
+
288
+ ## Command-line Chat Program
289
+ **Here's an example of a simple command-line chat program using the G4F Client:**
290
+ ```python
291
+ import g4f
292
+ from g4f.client import Client
293
+
294
+ # Initialize the GPT client with the desired provider
295
+ client = Client()
296
+
297
+ # Initialize an empty conversation history
298
+ messages = []
299
+
300
+ while True:
301
+ # Get user input
302
+ user_input = input("You: ")
303
+
304
+ # Check if the user wants to exit the chat
305
+ if user_input.lower() == "exit":
306
+ print("Exiting chat...")
307
+ break # Exit the loop to end the conversation
308
+
309
+ # Update the conversation history with the user's message
310
+ messages.append({"role": "user", "content": user_input})
311
+
312
+ try:
313
+ # Get GPT's response
314
+ response = client.chat.completions.create(
315
+ messages=messages,
316
+ model=g4f.models.default,
317
+ )
318
+
319
+ # Extract the GPT response and print it
320
+ gpt_response = response.choices[0].message.content
321
+ print(f"Bot: {gpt_response}")
322
+
323
+ # Update the conversation history with GPT's response
324
+ messages.append({"role": "assistant", "content": gpt_response})
325
+
326
+ except Exception as e:
327
+ print(f"An error occurred: {e}")
328
+ ```
329
+
330
+ This guide provides a comprehensive overview of the G4F Client API, demonstrating its versatility in handling various AI tasks, from text generation to image analysis and creation. By leveraging these features, you can build powerful and responsive applications that harness the capabilities of advanced AI models.
331
+
332
+
333
+ ---
334
+ [Return to Home](/)
docs/docker.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # G4F Docker Setup
3
+
4
+ ## Table of Contents
5
+ - [Prerequisites](#prerequisites)
6
+ - [Installation and Setup](#installation-and-setup)
7
+ - [Testing the API](#testing-the-api)
8
+ - [Troubleshooting](#troubleshooting)
9
+ - [Stopping the Service](#stopping-the-service)
10
+
11
+
12
+ ## Prerequisites
13
+ **Before you begin, ensure you have the following installed on your system:**
14
+ - [Docker](https://docs.docker.com/get-docker/)
15
+ - [Docker Compose](https://docs.docker.com/compose/install/)
16
+ - Python 3.7 or higher
17
+ - pip (Python package manager)
18
+
19
+ **Note:** If you encounter issues with Docker, you can run the project directly using Python.
20
+
21
+ ## Installation and Setup
22
+
23
+ ### Docker Method (Recommended)
24
+ 1. **Clone the Repository**
25
+ ```bash
26
+ git clone https://github.com/xtekky/gpt4free.git
27
+ cd gpt4free
28
+ ```
29
+
30
+ 2. **Build and Run with Docker Compose**
31
+
32
+ Pull the latest image and run a container with Google Chrome support:
33
+ ```bash
34
+ docker pull hlohaus789/g4f
35
+ docker-compose up -d
36
+ ```
37
+ Or run the small docker images without Google Chrome:
38
+ ```bash
39
+ docker-compose -f docker-compose-slim.yml up -d
40
+ ```
41
+
42
+ 3. **Access the API or the GUI**
43
+
44
+ The api server will be accessible at `http://localhost:1337`
45
+
46
+ And the gui at this url: `http://localhost:8080`
47
+
48
+ ### Non-Docker Method
49
+ If you encounter issues with Docker, you can run the project directly using Python:
50
+
51
+ 1. **Clone the Repository**
52
+ ```bash
53
+ git clone https://github.com/xtekky/gpt4free.git
54
+ cd gpt4free
55
+ ```
56
+
57
+ 2. **Install Dependencies**
58
+ ```bash
59
+ pip install -r requirements.txt
60
+ ```
61
+
62
+ 3. **Run the Server**
63
+ ```bash
64
+ python -m g4f.api.run
65
+ ```
66
+
67
+ 4. **Access the API or the GUI**
68
+
69
+ The api server will be accessible at `http://localhost:1337`
70
+
71
+ And the gui at this url: `http://localhost:8080`
72
+
73
+
74
+ ## Testing the API
75
+ **You can test the API using curl or by creating a simple Python script:**
76
+ ### Using curl
77
+ ```bash
78
+ curl -X POST -H "Content-Type: application/json" -d '{"prompt": "What is the capital of France?"}' http://localhost:1337/chat/completions
79
+ ```
80
+
81
+ ### Using Python
82
+ **Create a file named `test_g4f.py` with the following content:**
83
+ ```python
84
+ import requests
85
+
86
+ url = "http://localhost:1337/v1/chat/completions"
87
+ body = {
88
+ "model": "gpt-4o-mini",
89
+ "stream": False,
90
+ "messages": [
91
+ {"role": "assistant", "content": "What can you do?"}
92
+ ]
93
+ }
94
+
95
+ json_response = requests.post(url, json=body).json().get('choices', [])
96
+
97
+ for choice in json_response:
98
+ print(choice.get('message', {}).get('content', ''))
99
+ ```
100
+
101
+ **Run the script:**
102
+ ```bash
103
+ python test_g4f.py
104
+ ```
105
+
106
+ ## Troubleshooting
107
+ - If you encounter issues with Docker, try running the project directly using Python as described in the Non-Docker Method.
108
+ - Ensure that you have the necessary permissions to run Docker commands. You might need to use `sudo` or add your user to the `docker` group.
109
+ - If the server doesn't start, check the logs for any error messages and ensure all dependencies are correctly installed.
110
+
111
+ **_For more detailed information on API endpoints and usage, refer to the [G4F API documentation](docs/interference-api.md)._**
112
+
113
+
114
+
115
+ ## Stopping the Service
116
+
117
+ ### Docker Method
118
+ **To stop the Docker containers, use the following command:**
119
+ ```bash
120
+ docker-compose down
121
+ ```
122
+
123
+ ### Non-Docker Method
124
+ If you're running the server directly with Python, you can stop it by pressing Ctrl+C in the terminal where it's running.
125
+
126
+ ---
127
+
128
+ [Return to Home](/)
docs/git.md ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # G4F - Git Installation Guide
3
+
4
+ This guide provides step-by-step instructions for installing G4F from the source code using Git.
5
+
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Prerequisites](#prerequisites)
10
+ 2. [Installation Steps](#installation-steps)
11
+ 1. [Clone the Repository](#1-clone-the-repository)
12
+ 2. [Navigate to the Project Directory](#2-navigate-to-the-project-directory)
13
+ 3. [Set Up a Python Virtual Environment](#3-set-up-a-python-virtual-environment-recommended)
14
+ 4. [Activate the Virtual Environment](#4-activate-the-virtual-environment)
15
+ 5. [Install Dependencies](#5-install-dependencies)
16
+ 6. [Verify Installation](#6-verify-installation)
17
+ 3. [Usage](#usage)
18
+ 4. [Troubleshooting](#troubleshooting)
19
+ 5. [Additional Resources](#additional-resources)
20
+
21
+ ---
22
+
23
+ ## Prerequisites
24
+
25
+ Before you begin, ensure you have the following installed on your system:
26
+ - Git
27
+ - Python 3.7 or higher
28
+ - pip (Python package installer)
29
+
30
+ ## Installation Steps
31
+
32
+ ### 1. Clone the Repository
33
+ **Open your terminal and run the following command to clone the G4F repository:**
34
+ ```bash
35
+ git clone https://github.com/xtekky/gpt4free.git
36
+ ```
37
+
38
+ ### 2. Navigate to the Project Directory
39
+ **Change to the project directory:**
40
+ ```bash
41
+ cd gpt4free
42
+ ```
43
+
44
+ ### 3. Set Up a Python Virtual Environment (Recommended)
45
+ **It's best practice to use a virtual environment to manage project dependencies:**
46
+ ```bash
47
+ python3 -m venv venv
48
+ ```
49
+
50
+ ### 4. Activate the Virtual Environment
51
+ **Activate the virtual environment based on your operating system:**
52
+ - **Windows:**
53
+ ```bash
54
+ .\venv\Scripts\activate
55
+ ```
56
+
57
+ - **macOS and Linux:**
58
+ ```bash
59
+ source venv/bin/activate
60
+ ```
61
+
62
+ ### 5. Install Dependencies
63
+ **You have two options for installing dependencies:**
64
+
65
+ #### Option A: Install Minimum Requirements
66
+ **For a lightweight installation, use:**
67
+ ```bash
68
+ pip install -r requirements-min.txt
69
+ ```
70
+
71
+ #### Option B: Install All Packages
72
+ **For a full installation with all features, use:**
73
+ ```bash
74
+ pip install -r requirements.txt
75
+ ```
76
+
77
+ ### 6. Verify Installation
78
+ You can now create Python scripts and utilize the G4F functionalities. Here's a basic example:
79
+
80
+ **Create a `g4f-test.py` file in the root folder and start using the repository:**
81
+ ```python
82
+ import g4f
83
+ # Your code here
84
+ ```
85
+
86
+ ## Usage
87
+ **After installation, you can start using G4F in your Python scripts. Here's a basic example:**
88
+ ```python
89
+ import g4f
90
+
91
+ # Your G4F code here
92
+ # For example:
93
+ from g4f.client import Client
94
+
95
+ client = Client()
96
+
97
+ response = client.chat.completions.create(
98
+ model="gpt-4o-mini",
99
+ messages=[
100
+ {
101
+ "role": "user",
102
+ "content": "Say this is a test"
103
+ }
104
+ ]
105
+ # Add any other necessary parameters
106
+ )
107
+
108
+ print(response.choices[0].message.content)
109
+ ```
110
+
111
+ ## Troubleshooting
112
+ **If you encounter any issues during installation or usage:**
113
+ 1. Ensure all prerequisites are correctly installed.
114
+ 2. Check that you're in the correct directory and the virtual environment is activated.
115
+ 3. Try reinstalling the dependencies.
116
+ 4. Consult the [G4F documentation](https://github.com/xtekky/gpt4free) for more detailed information.
117
+
118
+ ## Additional Resources
119
+ - [G4F GitHub Repository](https://github.com/xtekky/gpt4free)
120
+ - [Python Virtual Environments Guide](https://docs.python.org/3/tutorial/venv.html)
121
+ - [pip Documentation](https://pip.pypa.io/en/stable/)
122
+
123
+ ---
124
+
125
+ **_For more information or support, please visit the [G4F GitHub Issues page](https://github.com/xtekky/gpt4free/issues)._**
126
+
127
+
128
+ ---
129
+ [Return to Home](/)
docs/guides/create_provider.md ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Create Provider with AI Tool
2
+
3
+ Call in your terminal the `create_provider` script:
4
+ ```bash
5
+ python -m etc.tool.create_provider
6
+ ```
7
+ 1. Enter your name for the new provider.
8
+ 2. Copy and paste the `cURL` command from your browser developer tools.
9
+ 3. Let the AI ​​create the provider for you.
10
+ 4. Customize the provider according to your needs.
11
+
12
+ #### Create Provider
13
+
14
+ 1. Check out the current [list of potential providers](https://github.com/zukixa/cool-ai-stuff#ai-chat-websites), or find your own provider source!
15
+ 2. Create a new file in [g4f/Provider](/g4f/Provider) with the name of the Provider.
16
+ 3. Implement a class that extends [BaseProvider](/g4f/providers/base_provider.py).
17
+
18
+ ```py
19
+ from __future__ import annotations
20
+
21
+ from ..typing import AsyncResult, Messages
22
+ from .base_provider import AsyncGeneratorProvider
23
+
24
+ class HogeService(AsyncGeneratorProvider):
25
+ url = "https://chat-gpt.com"
26
+ working = True
27
+ supports_gpt_35_turbo = True
28
+
29
+ @classmethod
30
+ async def create_async_generator(
31
+ cls,
32
+ model: str,
33
+ messages: Messages,
34
+ proxy: str = None,
35
+ **kwargs
36
+ ) -> AsyncResult:
37
+ yield ""
38
+ ```
39
+
40
+ 4. Here, you can adjust the settings, for example, if the website does support streaming, set `supports_stream` to `True`...
41
+ 5. Write code to request the provider in `create_async_generator` and `yield` the response, _even if_ it's a one-time response, do not hesitate to look at other providers for inspiration.
42
+ 6. Add the Provider Import in [`g4f/Provider/__init__.py`](./g4f/Provider/__init__.py)
43
+
44
+ ```py
45
+ from .HogeService import HogeService
46
+
47
+ __all__ = [
48
+ HogeService,
49
+ ]
50
+ ```
51
+
52
+ 7. You are done !, test the provider by calling it:
53
+
54
+ ```py
55
+ import g4f
56
+
57
+ response = g4f.ChatCompletion.create(model='gpt-3.5-turbo', provider=g4f.Provider.PROVIDERNAME,
58
+ messages=[{"role": "user", "content": "test"}], stream=g4f.Provider.PROVIDERNAME.supports_stream)
59
+
60
+ for message in response:
61
+ print(message, flush=True, end='')
62
+ ```
docs/guides/help_me.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Guide: How can AI help me with writing code?
2
+
3
+ 🤖 Ever dreamt of writing code at lightning speed, effortlessly crafting clean, bug-free functionalities? Welcome to the age of AI-powered coding, where your imagination merges seamlessly with the machine's precision. This guide unveils 4 powerful ways AI can become your secret weapon in the coding world, saving you time, resources, and frustration. 😎
4
+
5
+ - Language Agnostic? No Problem! Rewrite Code with Ease
6
+ - Improving Written Code: Polish Your Code Like a Pro
7
+ - Demystifying the Unreadable: Deobfuscating Unreadable Code
8
+ - Custom Functions: Your AI-Powered Genie in a Bottle
9
+
10
+ So you can streamline your coding process, improve code quality, and enhance productivity.
11
+
12
+ #### 1. Rewriting Code from One Language to Another
13
+ You can leverage AI to translate code from one programming language to another. For instance, you can easily convert JavaScript code to Python using the following approach:
14
+
15
+ **Prompt:**
16
+ ```
17
+ Rewrite this JavaScript code to Python code. Use the aiohttp package:
18
+ ```
19
+ ```javascript
20
+ async function fetch_data(url) {
21
+ const response = await fetch(url);
22
+ const data = await response.json();
23
+ return data;
24
+ }
25
+ ```
26
+
27
+ **AI Response:**
28
+ ```python
29
+ import aiohttp
30
+
31
+ async def fetch_data(url):
32
+ async with aiohttp.ClientSession() as session:
33
+ async with session.get(url) as response:
34
+ data = await response.json()
35
+ return data
36
+ ```
37
+
38
+ #### 2. Improving Written Code
39
+ You can ask the AI to enhance your code by adding comments, docstrings, and type hints for better readability and maintainability.
40
+
41
+ **Example Usage:**
42
+ ```
43
+ Improve this Python code, add Google docstrings and type hints.
44
+ Responses with the complete code and don't use placeholders.
45
+ Keep the comments:
46
+ ```
47
+ ```python
48
+ def calculate_area(radius):
49
+ # Calculate the area of a circle
50
+ return 3.14 * radius ** 2
51
+ ```
52
+
53
+ **AI Response:**
54
+ ```python
55
+ def calculate_area(radius: float) -> float:
56
+ """Calculate the area of a circle.
57
+
58
+ Args:
59
+ radius (float): The radius of the circle.
60
+
61
+ Returns:
62
+ float: The area of the circle.
63
+ """
64
+ return 3.14 * radius ** 2
65
+ ```
66
+
67
+ #### 3. Deobfuscating Unreadable Code
68
+ AI can help in making obfuscated or unreadable code more understandable and maintainable.
69
+
70
+ **Example Usage:**
71
+ ```
72
+ Deobfuscate this JavaScript code. Improve the readability:
73
+ ```
74
+
75
+ ```javascript
76
+ (function() {
77
+ var a = 'Hello', b = 'World';
78
+ console.log(a + ' ' + b);
79
+ })();
80
+ ```
81
+
82
+ **AI Response:**
83
+ ```javascript
84
+ (function() {
85
+ var greeting = 'Hello';
86
+ var subject = 'World';
87
+ console.log(greeting + ' ' + subject);
88
+ })();
89
+ ```
90
+
91
+ #### 4. Writing Custom Functions
92
+ You can also ask the AI to generate custom functions or help you with specific coding issues.
93
+
94
+ **Example Usage:**
95
+ ```
96
+ Write a function that returns the sum of two numbers.
97
+ ```
98
+
99
+ **AI Response:**
100
+ ```python
101
+ def add_numbers(a, b):
102
+ """Add two numbers together."""
103
+ return a + b
104
+ ```
105
+
106
+ These are just a few ways AI can revolutionize your coding experience. As AI technology continues to evolve, the possibilities are endless. So, embrace the future, unlock the power of AI, and watch your coding potential soar! 👷‍♂️
docs/guides/phone.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Guide: Running the G4F GUI on Your Smartphone
2
+
3
+ Running Python applications on your smartphone is possible with specialized apps like Pydroid. This tutorial will walk you through the process using an Android smartphone with Pydroid. Note that the steps may vary slightly for iPhone users due to differences in app names and ownership.
4
+
5
+ <p align="center">
6
+ On the first screenshot is <strong>Pydroid</strong> and on the second is the <strong>Web UI</strong> in a browser
7
+ </p>
8
+
9
+ <p align="center">
10
+ <img src="/docs/guides/phone.png" />
11
+ <img src="/docs/guides/phone2.jpeg" />
12
+ </p>
13
+
14
+ 1. **Install Pydroid from the Google Play Store:**
15
+ - Navigate to the Google Play Store and search for "Pydroid 3 - IDE for Python 3" or use the following link: [Pydroid 3 - IDE for Python 3](https://play.google.com/store/apps/details/Pydroid_3_IDE_for_Python_3).
16
+
17
+ 2. **Install the Pydroid Repository Plugin:**
18
+ - To enhance functionality, install the Pydroid repository plugin. Find it on the Google Play Store or use this link: [Pydroid Repository Plugin](https://play.google.com/store/apps/details?id=ru.iiec.pydroid3.quickinstallrepo).
19
+
20
+ 3. **Adjust App Settings:**
21
+ - In the app settings for Pydroid, disable power-saving mode and ensure that the option to pause when not in use is also disabled. This ensures uninterrupted operation of your Python scripts.
22
+
23
+ 4. **Install Required Packages:**
24
+ - Open Pip within the Pydroid app and install these necessary packages:
25
+ ```
26
+ g4f flask pillow beautifulsoup4
27
+ ```
28
+
29
+ 5. **Create a New Python Script:**
30
+ - Within Pydroid, create a new Python script and input the following content:
31
+ ```python
32
+ from g4f import set_cookies
33
+
34
+ set_cookies(".bing.com", {
35
+ "_U": "cookie value"
36
+ })
37
+
38
+ from g4f.gui import run_gui
39
+
40
+ run_gui("0.0.0.0", 8080, debug=True)
41
+ ```
42
+ Replace `"cookie value"` with your actual cookie value from Bing if you intend to create images using Bing.
43
+
44
+ 6. **Execute the Script:**
45
+ - Run the script by clicking on the play button or selecting the option to execute it.
46
+
47
+ 7. **Access the GUI:**
48
+ - Wait for the server to start, and once it's running, open the GUI using the URL provided in the output. [http://localhost:8080/chat/](http://localhost:8080/chat/)
49
+
50
+ By following these steps, you can successfully run the G4F GUI on your smartphone using Pydroid, allowing you to create and interact with graphical interfaces directly from your device.
docs/guides/phone.png ADDED
docs/guides/phone2.jpeg ADDED
docs/interference-api.md ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # G4F - Interference API Usage Guide
2
+
3
+
4
+ ## Table of Contents
5
+ - [Introduction](#introduction)
6
+ - [Running the Interference API](#running-the-interference-api)
7
+ - [From PyPI Package](#from-pypi-package)
8
+ - [From Repository](#from-repository)
9
+ - [Using the Interference API](#using-the-interference-api)
10
+ - [Basic Usage](#basic-usage)
11
+ - [With OpenAI Library](#with-openai-library)
12
+ - [With Requests Library](#with-requests-library)
13
+ - [Key Points](#key-points)
14
+ - [Conclusion](#conclusion)
15
+
16
+
17
+ ## Introduction
18
+ The G4F Interference API is a powerful tool that allows you to serve other OpenAI integrations using G4F (Gpt4free). It acts as a proxy, translating requests intended for the OpenAI API into requests compatible with G4F providers. This guide will walk you through the process of setting up, running, and using the Interference API effectively.
19
+
20
+
21
+ ## Running the Interference API
22
+ **You can run the Interference API in two ways:** using the PyPI package or from the repository.
23
+
24
+
25
+ ### From PyPI Package
26
+ **To run the Interference API directly from the G4F PyPI package, use the following Python code:**
27
+
28
+ ```python
29
+ from g4f.api import run_api
30
+
31
+ run_api()
32
+ ```
33
+
34
+
35
+ ### From Repository
36
+ **If you prefer to run the Interference API from the cloned repository, you have two options:**
37
+
38
+ 1. **Using the command line:**
39
+ ```bash
40
+ g4f api
41
+ ```
42
+
43
+ 2. **Using Python:**
44
+ ```bash
45
+ python -m g4f.api.run
46
+ ```
47
+
48
+ **Once running, the API will be accessible at:** `http://localhost:1337/v1`
49
+
50
+ **(Advanced) Bind to custom port:**
51
+ ```bash
52
+ python -m g4f.cli api --bind "0.0.0.0:2400"
53
+ ```
54
+
55
+ ## Using the Interference API
56
+
57
+ ### Basic Usage
58
+ **You can interact with the Interference API using curl commands for both text and image generation:**
59
+
60
+ **For text generation:**
61
+ ```bash
62
+ curl -X POST "http://localhost:1337/v1/chat/completions" \
63
+ -H "Content-Type: application/json" \
64
+ -d '{
65
+ "messages": [
66
+ {
67
+ "role": "user",
68
+ "content": "Hello"
69
+ }
70
+ ],
71
+ "model": "gpt-4o-mini"
72
+ }'
73
+ ```
74
+
75
+ **For image generation:**
76
+ 1. **url:**
77
+ ```bash
78
+ curl -X POST "http://localhost:1337/v1/images/generate" \
79
+ -H "Content-Type: application/json" \
80
+ -d '{
81
+ "prompt": "a white siamese cat",
82
+ "model": "flux",
83
+ "response_format": "url"
84
+ }'
85
+ ```
86
+
87
+ 2. **b64_json**
88
+ ```bash
89
+ curl -X POST "http://localhost:1337/v1/images/generate" \
90
+ -H "Content-Type: application/json" \
91
+ -d '{
92
+ "prompt": "a white siamese cat",
93
+ "model": "flux",
94
+ "response_format": "b64_json"
95
+ }'
96
+ ```
97
+
98
+
99
+ ### With OpenAI Library
100
+
101
+ **You can use the Interference API with the OpenAI Python library by changing the `base_url`:**
102
+ ```python
103
+ from openai import OpenAI
104
+
105
+ client = OpenAI(
106
+ api_key="",
107
+ base_url="http://localhost:1337/v1"
108
+ )
109
+
110
+ response = client.chat.completions.create(
111
+ model="gpt-4o-mini",
112
+ messages=[{"role": "user", "content": "Write a poem about a tree"}],
113
+ stream=True,
114
+ )
115
+
116
+ if isinstance(response, dict):
117
+ # Not streaming
118
+ print(response.choices[0].message.content)
119
+ else:
120
+ # Streaming
121
+ for token in response:
122
+ content = token.choices[0].delta.content
123
+ if content is not None:
124
+ print(content, end="", flush=True)
125
+
126
+ ```
127
+
128
+
129
+ ### With Requests Library
130
+
131
+ **You can also send requests directly to the Interference API using the `requests` library:**
132
+ ```python
133
+ import requests
134
+
135
+ url = "http://localhost:1337/v1/chat/completions"
136
+
137
+ body = {
138
+ "model": "gpt-4o-mini",
139
+ "stream": False,
140
+ "messages": [
141
+ {"role": "assistant", "content": "What can you do?"}
142
+ ]
143
+ }
144
+
145
+ json_response = requests.post(url, json=body).json().get('choices', [])
146
+
147
+ for choice in json_response:
148
+ print(choice.get('message', {}).get('content', ''))
149
+
150
+ ```
151
+
152
+ ## Key Points
153
+ - The Interference API translates OpenAI API requests into G4F provider requests.
154
+ - It can be run from either the PyPI package or the cloned repository.
155
+ - The API supports usage with the OpenAI Python library by changing the `base_url`.
156
+ - Direct requests can be sent to the API endpoints using libraries like `requests`.
157
+ - Both text and image generation are supported.
158
+
159
+
160
+ ## Conclusion
161
+ The G4F Interference API provides a seamless way to integrate G4F with existing OpenAI-based applications and tools. By following this guide, you should now be able to set up, run, and use the Interference API effectively. Whether you're using it for text generation, image creation, or as a drop-in replacement for OpenAI in your projects, the Interference API offers flexibility and power for your AI-driven applications.
162
+
163
+
164
+ ---
165
+
166
+ [Return to Home](/)
docs/legacy.md ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### G4F - Legacy API
2
+
3
+ #### ChatCompletion
4
+
5
+ ```python
6
+ import g4f
7
+
8
+ g4f.debug.logging = True # Enable debug logging
9
+ g4f.debug.version_check = False # Disable automatic version checking
10
+ print(g4f.Provider.Bing.params) # Print supported args for Bing
11
+
12
+ # Using automatic a provider for the given model
13
+ ## Streamed completion
14
+ response = g4f.ChatCompletion.create(
15
+ model="gpt-3.5-turbo",
16
+ messages=[{"role": "user", "content": "Hello"}],
17
+ stream=True,
18
+ )
19
+ for message in response:
20
+ print(message, flush=True, end='')
21
+
22
+ ## Normal response
23
+ response = g4f.ChatCompletion.create(
24
+ model=g4f.models.gpt_4,
25
+ messages=[{"role": "user", "content": "Hello"}],
26
+ ) # Alternative model setting
27
+
28
+ print(response)
29
+ ```
30
+
31
+ ##### Completion
32
+
33
+ ```python
34
+ import g4f
35
+
36
+ allowed_models = [
37
+ 'code-davinci-002',
38
+ 'text-ada-001',
39
+ 'text-babbage-001',
40
+ 'text-curie-001',
41
+ 'text-davinci-002',
42
+ 'text-davinci-003'
43
+ ]
44
+
45
+ response = g4f.Completion.create(
46
+ model='text-davinci-003',
47
+ prompt='say this is a test'
48
+ )
49
+
50
+ print(response)
51
+ ```
52
+
53
+ ##### Providers
54
+
55
+ ```python
56
+ import g4f
57
+
58
+ # Print all available providers
59
+ print([
60
+ provider.__name__
61
+ for provider in g4f.Provider.__providers__
62
+ if provider.working
63
+ ])
64
+
65
+ # Execute with a specific provider
66
+ response = g4f.ChatCompletion.create(
67
+ model="gpt-3.5-turbo",
68
+ provider=g4f.Provider.Aichat,
69
+ messages=[{"role": "user", "content": "Hello"}],
70
+ stream=True,
71
+ )
72
+ for message in response:
73
+ print(message)
74
+ ```
75
+
76
+
77
+ ##### Image Upload & Generation
78
+
79
+ Image upload and generation are supported by three main providers:
80
+
81
+ - **Bing & Other GPT-4 Providers:** Utilizes Microsoft's Image Creator.
82
+ - **Google Gemini:** Available for free accounts with IP addresses outside Europe.
83
+ - **OpenaiChat with GPT-4:** Accessible for users with a Plus subscription.
84
+
85
+ ```python
86
+ import g4f
87
+
88
+ # Setting up the request for image creation
89
+ response = g4f.ChatCompletion.create(
90
+ model=g4f.models.default, # Using the default model
91
+ provider=g4f.Provider.Gemini, # Specifying the provider as Gemini
92
+ messages=[{"role": "user", "content": "Create an image like this"}],
93
+ image=open("images/g4f.png", "rb"), # Image input can be a data URI, bytes, PIL Image, or IO object
94
+ image_name="g4f.png" # Optional: specifying the filename
95
+ )
96
+
97
+ # Displaying the response
98
+ print(response)
99
+
100
+ from g4f.image import ImageResponse
101
+
102
+ # Get image links from response
103
+ for chunk in g4f.ChatCompletion.create(
104
+ model=g4f.models.default, # Using the default model
105
+ provider=g4f.Provider.OpenaiChat, # Specifying the provider as OpenaiChat
106
+ messages=[{"role": "user", "content": "Create images with dogs"}],
107
+ access_token="...", # Need a access token from a plus user
108
+ stream=True,
109
+ ignore_stream=True
110
+ ):
111
+ if isinstance(chunk, ImageResponse):
112
+ print(chunk.images) # Print generated image links
113
+ print(chunk.alt) # Print used prompt for image generation
114
+ ```
115
+
116
+ ##### Using Browser
117
+
118
+ Some providers using a browser to bypass the bot protection. They using the selenium webdriver to control the browser. The browser settings and the login data are saved in a custom directory. If the headless mode is enabled, the browser windows are loaded invisibly. For performance reasons, it is recommended to reuse the browser instances and close them yourself at the end:
119
+
120
+ ```python
121
+ import g4f
122
+ from undetected_chromedriver import Chrome, ChromeOptions
123
+ from g4f.Provider import (
124
+ Bard,
125
+ Poe,
126
+ AItianhuSpace,
127
+ MyShell,
128
+ PerplexityAi,
129
+ )
130
+
131
+ options = ChromeOptions()
132
+ options.add_argument("--incognito");
133
+ webdriver = Chrome(options=options, headless=True)
134
+ for idx in range(10):
135
+ response = g4f.ChatCompletion.create(
136
+ model=g4f.models.default,
137
+ provider=g4f.Provider.MyShell,
138
+ messages=[{"role": "user", "content": "Suggest me a name."}],
139
+ webdriver=webdriver
140
+ )
141
+ print(f"{idx}:", response)
142
+ webdriver.quit()
143
+ ```
144
+
145
+ ##### Async Support
146
+
147
+ To enhance speed and overall performance, execute providers asynchronously. The total execution time will be determined by the duration of the slowest provider's execution.
148
+
149
+ ```python
150
+ import g4f
151
+ import asyncio
152
+
153
+ _providers = [
154
+ g4f.Provider.Aichat,
155
+ g4f.Provider.ChatBase,
156
+ g4f.Provider.Bing,
157
+ g4f.Provider.GptGo,
158
+ g4f.Provider.You,
159
+ g4f.Provider.Yqcloud,
160
+ ]
161
+
162
+ async def run_provider(provider: g4f.Provider.BaseProvider):
163
+ try:
164
+ response = await g4f.ChatCompletion.create_async(
165
+ model=g4f.models.default,
166
+ messages=[{"role": "user", "content": "Hello"}],
167
+ provider=provider,
168
+ )
169
+ print(f"{provider.__name__}:", response)
170
+ except Exception as e:
171
+ print(f"{provider.__name__}:", e)
172
+
173
+ async def run_all():
174
+ calls = [
175
+ run_provider(provider) for provider in _providers
176
+ ]
177
+ await asyncio.gather(*calls)
178
+
179
+ asyncio.run(run_all())
180
+ ```
181
+
182
+ ##### Proxy and Timeout Support
183
+
184
+ All providers support specifying a proxy and increasing timeout in the create functions.
185
+
186
+ ```python
187
+ import g4f
188
+
189
+ response = g4f.ChatCompletion.create(
190
+ model=g4f.models.default,
191
+ messages=[{"role": "user", "content": "Hello"}],
192
+ proxy="http://host:port",
193
+ # or socks5://user:pass@host:port
194
+ timeout=120, # in secs
195
+ )
196
+
197
+ print(f"Result:", response)
198
+ ```
199
+
200
+ [Return to Home](/)
docs/local.md ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ### G4F - Local Usage Guide
3
+
4
+
5
+ ### Table of Contents
6
+ 1. [Introduction](#introduction)
7
+ 2. [Required Dependencies](#required-dependencies)
8
+ 3. [Basic Usage Example](#basic-usage-example)
9
+ 4. [Supported Models](#supported-models)
10
+ 5. [Performance Considerations](#performance-considerations)
11
+ 6. [Troubleshooting](#troubleshooting)
12
+
13
+ #### Introduction
14
+ This guide explains how to use g4f to run language models locally. G4F (GPT4Free) allows you to interact with various language models on your local machine, providing a flexible and private solution for natural language processing tasks.
15
+
16
+ ## Usage
17
+
18
+ #### Local inference
19
+ How to use g4f to run language models locally
20
+
21
+ #### Required dependencies
22
+ **Make sure to install the required dependencies by running:**
23
+ ```bash
24
+ pip install g4f[local]
25
+ ```
26
+ or
27
+ ```bash
28
+ pip install -U gpt4all
29
+ ```
30
+
31
+
32
+
33
+ #### Basic usage example
34
+ ```python
35
+ from g4f.local import LocalClient
36
+
37
+ client = LocalClient()
38
+ response = client.chat.completions.create(
39
+ model = 'orca-mini-3b',
40
+ messages = [{"role": "user", "content": "hi"}],
41
+ stream = True
42
+ )
43
+
44
+ for token in response:
45
+ print(token.choices[0].delta.content or "")
46
+ ```
47
+
48
+ Upon first use, there will be a prompt asking you if you wish to download the model. If you respond with `y`, g4f will go ahead and download the model for you.
49
+
50
+ You can also manually place supported models into `./g4f/local/models/`
51
+
52
+
53
+ **You can get a list of the current supported models by running:**
54
+ ```python
55
+ from g4f.local import LocalClient
56
+
57
+ client = LocalClient()
58
+ client.list_models()
59
+ ```
60
+
61
+ ```json
62
+ {
63
+ "mistral-7b": {
64
+ "path": "mistral-7b-openorca.gguf2.Q4_0.gguf",
65
+ "ram": "8",
66
+ "prompt": "<|im_start|>user\n%1<|im_end|>\n<|im_start|>assistant\n",
67
+ "system": "<|im_start|>system\nYou are MistralOrca, a large language model trained by Alignment Lab AI. For multi-step problems, write out your reasoning for each step.\n<|im_end|>"
68
+ },
69
+ "mistral-7b-instruct": {
70
+ "path": "mistral-7b-instruct-v0.1.Q4_0.gguf",
71
+ "ram": "8",
72
+ "prompt": "[INST] %1 [/INST]",
73
+ "system": None
74
+ },
75
+ "gpt4all-falcon": {
76
+ "path": "gpt4all-falcon-newbpe-q4_0.gguf",
77
+ "ram": "8",
78
+ "prompt": "### Instruction:\n%1\n### Response:\n",
79
+ "system": None
80
+ },
81
+ "orca-2": {
82
+ "path": "orca-2-13b.Q4_0.gguf",
83
+ "ram": "16",
84
+ "prompt": None,
85
+ "system": None
86
+ },
87
+ "wizardlm-13b": {
88
+ "path": "wizardlm-13b-v1.2.Q4_0.gguf",
89
+ "ram": "16",
90
+ "prompt": None,
91
+ "system": None
92
+ },
93
+ "nous-hermes-llama2": {
94
+ "path": "nous-hermes-llama2-13b.Q4_0.gguf",
95
+ "ram": "16",
96
+ "prompt": "### Instruction:\n%1\n### Response:\n",
97
+ "system": None
98
+ },
99
+ "gpt4all-13b-snoozy": {
100
+ "path": "gpt4all-13b-snoozy-q4_0.gguf",
101
+ "ram": "16",
102
+ "prompt": None,
103
+ "system": None
104
+ },
105
+ "mpt-7b-chat": {
106
+ "path": "mpt-7b-chat-newbpe-q4_0.gguf",
107
+ "ram": "8",
108
+ "prompt": "<|im_start|>user\n%1<|im_end|>\n<|im_start|>assistant\n",
109
+ "system": "<|im_start|>system\n- You are a helpful assistant chatbot trained by MosaicML.\n- You answer questions.\n- You are excited to be able to help the user, but will refuse to do anything that could be considered harmful to the user.\n- You are more than just an information source, you are also able to write poetry, short stories, and make jokes.<|im_end|>"
110
+ },
111
+ "orca-mini-3b": {
112
+ "path": "orca-mini-3b-gguf2-q4_0.gguf",
113
+ "ram": "4",
114
+ "prompt": "### User:\n%1\n### Response:\n",
115
+ "system": "### System:\nYou are an AI assistant that follows instruction extremely well. Help as much as you can.\n\n"
116
+ },
117
+ "replit-code-3b": {
118
+ "path": "replit-code-v1_5-3b-newbpe-q4_0.gguf",
119
+ "ram": "4",
120
+ "prompt": "%1",
121
+ "system": None
122
+ },
123
+ "starcoder": {
124
+ "path": "starcoder-newbpe-q4_0.gguf",
125
+ "ram": "4",
126
+ "prompt": "%1",
127
+ "system": None
128
+ },
129
+ "rift-coder-7b": {
130
+ "path": "rift-coder-v0-7b-q4_0.gguf",
131
+ "ram": "8",
132
+ "prompt": "%1",
133
+ "system": None
134
+ },
135
+ "all-MiniLM-L6-v2": {
136
+ "path": "all-MiniLM-L6-v2-f16.gguf",
137
+ "ram": "1",
138
+ "prompt": None,
139
+ "system": None
140
+ },
141
+ "mistral-7b-german": {
142
+ "path": "em_german_mistral_v01.Q4_0.gguf",
143
+ "ram": "8",
144
+ "prompt": "USER: %1 ASSISTANT: ",
145
+ "system": "Du bist ein hilfreicher Assistent. "
146
+ }
147
+ }
148
+ ```
149
+
150
+ #### Performance Considerations
151
+ **When running language models locally, consider the following:**
152
+ - RAM requirements vary by model size (see the 'ram' field in the model list).
153
+ - CPU/GPU capabilities affect inference speed.
154
+ - Disk space is needed to store the model files.
155
+
156
+ #### Troubleshooting
157
+ **Common issues and solutions:**
158
+ 1. **Model download fails**: Check your internet connection and try again.
159
+ 2. **Out of memory error**: Choose a smaller model or increase your system's RAM.
160
+ 3. **Slow inference**: Consider using a GPU or a more powerful CPU.
161
+
162
+
163
+
164
+ [Return to Home](/)
docs/providers-and-models.md ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ # G4F - Providers and Models
4
+
5
+ This document provides an overview of various AI providers and models, including text generation, image generation, and vision capabilities. It aims to help users navigate the diverse landscape of AI services and choose the most suitable option for their needs.
6
+
7
+ ## Table of Contents
8
+ - [Providers](#providers)
9
+ - [Models](#models)
10
+ - [Text Models](#text-models)
11
+ - [Image Models](#image-models)
12
+ - [Vision Models](#vision-models)
13
+ - [Providers and vision models](#providers-and-vision-models)
14
+ - [Conclusion and Usage Tips](#conclusion-and-usage-tips)
15
+
16
+ ---
17
+ ## Providers
18
+ | Provider | Text Models | Image Models | Vision Models | Stream | Status | Auth |
19
+ |----------|-------------|--------------|---------------|--------|--------|------|
20
+ |[ai4chat.co](https://www.ai4chat.co)|`g4f.Provider.Ai4Chat`|`gpt-4`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
21
+ |[aichatfree.info](https://aichatfree.info)|`g4f.Provider.AIChatFree`|`gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
22
+ |[api.airforce](https://api.airforce)|`g4f.Provider.Airforce`|`gpt-4o, gpt-4o-mini, gpt-4-turbo, llama-2-7b, llama-3.1-8b, llama-3.1-70b, hermes-2-pro, hermes-2-dpo, phi-2, deepseek-coder, openchat-3.5, openhermes-2.5, lfm-40b, german-7b, zephyr-7b, neural-7b`|`flux, flux-realism', flux-anime, flux-3d, flux-disney, flux-pixel, flux-4o, any-dark, sdxl`|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
23
+ |[aiuncensored.info](https://www.aiuncensored.info)|`g4f.Provider.AIUncensored`|✔|✔|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
24
+ |[allyfy.chat](https://allyfy.chat/)|`g4f.Provider.Allyfy`|`gpt-3.5-turbo`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
25
+ |[bing.com](https://bing.com/chat)|`g4f.Provider.Bing`|`gpt-4`|✔|`gpt-4-vision`|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌+✔|
26
+ |[bing.com/images](https://www.bing.com/images/create)|`g4f.Provider.BingCreateImages`|`❌|✔|❌|❌|![Active](https://img.shields.io/badge/Active-brightgreen)|✔|
27
+ |[blackbox.ai](https://www.blackbox.ai)|`g4f.Provider.Blackbox`|`blackboxai, blackboxai-pro, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b, gpt-4o, gemini-pro, claude-3.5-sonnet`|`flux`|`blackboxai, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b, gpt-4o, gemini-pro`|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
28
+ |[chatgot.one](https://www.chatgot.one/)|`g4f.Provider.ChatGot`|`gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
29
+ |[chatgpt.com](https://chatgpt.com)|`g4f.Provider.ChatGpt`|`?`|`?`|`?`|?|![Unknown](https://img.shields.io/badge/Unknown-grey) |❌|
30
+ |[chatgpt.es](https://chatgpt.es)|`g4f.Provider.ChatGptEs`|`gpt-4o, gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
31
+ |[playground.ai.cloudflare.com](https://playground.ai.cloudflare.com)|`g4f.Provider.Cloudflare`|`gemma-7b, llama-2-7b, llama-3-8b, llama-3.1-8b, llama-3.2-1b, phi-2, qwen-1.5-0-5b, qwen-1.5-8b, qwen-1.5-14b, qwen-1.5-7b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
32
+ |[darkai.foundation/chat](https://darkai.foundation/chat)|`g4f.Provider.DarkAI`|`gpt-4o, gpt-3.5-turbo, llama-3-70b, llama-3-405b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
33
+ |[duckduckgo.com](https://duckduckgo.com/duckchat/v1/chat)|`g4f.Provider.DDG`|`gpt-4o-mini, claude-3-haiku, llama-3.1-70b, mixtral-8x7b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
34
+ |[deepinfra.com](https://deepinfra.com)|`g4f.Provider.DeepInfra`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
35
+ |[deepinfra.com/chat](https://deepinfra.com/chat)|`g4f.Provider.DeepInfraChat`|`llama-3.1-8b, llama-3.1-70b, wizardlm-2-8x22b, qwen-2-72b`|❌|❌|❌|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
36
+ |[deepinfra.com](https://deepinfra.com)|`g4f.Provider.DeepInfraImage`|❌|✔|❌|❌|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
37
+ |[chat10.free2gpt.xyz](chat10.free2gpt.xyz)|`g4f.Provider.Free2GPT`|`mixtral-7b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
38
+ |[freegptsnav.aifree.site](https://freegptsnav.aifree.site)|`g4f.Provider.FreeGpt`|`gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
39
+ |[gemini.google.com](https://gemini.google.com)|`g4f.Provider.Gemini`|✔|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|✔|
40
+ |[ai.google.dev](https://ai.google.dev)|`g4f.Provider.GeminiPro`|✔|❌|✔|?|![Active](https://img.shields.io/badge/Active-brightgreen)|✔|
41
+ |[app.giz.ai](https://app.giz.ai/assistant/)|`g4f.Provider.GizAI`|`gemini-flash`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
42
+ |[developers.sber.ru](https://developers.sber.ru/gigachat)|`g4f.Provider.GigaChat`|✔|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|✔|
43
+ |[console.groq.com/playground](https://console.groq.com/playground)|`g4f.Provider.Groq`|✔|❌|❌|?|![Active](https://img.shields.io/badge/Active-brightgreen)|✔|
44
+ |[huggingface.co/chat](https://huggingface.co/chat)|`g4f.Provider.HuggingChat`|`llama-3.1-70b, command-r-plus, qwen-2-72b, llama-3.2-11b, hermes-3, mistral-nemo, phi-3.5-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
45
+ |[huggingface.co](https://huggingface.co/chat)|`g4f.Provider.HuggingFace`|✔|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
46
+ |[liaobots.work](https://liaobots.work)|`g4f.Provider.Liaobots`|`gpt-3.5-turbo, gpt-4o-mini, gpt-4o, gpt-4-turbo, grok-2, grok-2-mini, claude-3-opus, claude-3-sonnet, claude-3-5-sonnet, claude-3-haiku, claude-2.1, gemini-flash, gemini-pro`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
47
+ |[magickpen.com](https://magickpen.com)|`g4f.Provider.MagickPen`|`gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
48
+ |[meta.ai](https://www.meta.ai)|`g4f.Provider.MetaAI`|✔|✔|?|?|![Active](https://img.shields.io/badge/Active-brightgreen)|✔|
49
+ |[platform.openai.com](https://platform.openai.com/)|`g4f.Provider.Openai`|✔|❌|✔||![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
50
+ |[chatgpt.com](https://chatgpt.com/)|`g4f.Provider.OpenaiChat`|`gpt-4o, gpt-4o-mini, gpt-4`|❌|✔||![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
51
+ |[www.perplexity.ai)](https://www.perplexity.ai)|`g4f.Provider.PerplexityAi`|✔|❌|❌|?|![Disabled](https://img.shields.io/badge/Disabled-red)|❌|
52
+ |[perplexity.ai](https://www.perplexity.ai)|`g4f.Provider.PerplexityApi`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
53
+ |[labs.perplexity.ai](https://labs.perplexity.ai)|`g4f.Provider.PerplexityLabs`|`sonar-online, sonar-chat, llama-3.1-8b, llama-3.1-70b`|❌|❌|?|![Cloudflare](https://img.shields.io/badge/Cloudflare-f48d37)|❌|
54
+ |[pi.ai/talk](https://pi.ai/talk)|`g4f.Provider.Pi`|`pi`|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|❌|
55
+ |[]()|`g4f.Provider.Pizzagpt`|`gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
56
+ |[poe.com](https://poe.com)|`g4f.Provider.Poe`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
57
+ |[app.prodia.com](https://app.prodia.com)|`g4f.Provider.Prodia`|❌|✔|❌|❌|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
58
+ |[raycast.com](https://raycast.com)|`g4f.Provider.Raycast`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
59
+ |[chat.reka.ai](https://chat.reka.ai/)|`g4f.Provider.Reka`|✔|❌|✔|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
60
+ |[replicate.com](https://replicate.com)|`g4f.Provider.Replicate`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
61
+ |[replicate.com](https://replicate.com)|`g4f.Provider.ReplicateHome`|`gemma-2b, llava-13b`|`sd-3, sdxl, playground-v2.5`|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
62
+ |[replicate.com](https://replicate.com)|`g4f.Provider.RubiksAI`|`llama-3.1-70b, gpt-4o-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
63
+ |[talkai.info](https://talkai.info)|`g4f.Provider.TalkAi`|✔|❌|❌|✔|![Disabled](https://img.shields.io/badge/Disabled-red)|❌|
64
+ |[teach-anything.com](https://www.teach-anything.com)|`g4f.Provider.TeachAnything`|`llama-3.1-70b`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
65
+ |[beta.theb.ai](https://beta.theb.ai)|`g4f.Provider.Theb`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
66
+ |[beta.theb.ai](https://beta.theb.ai)|`g4f.Provider.ThebApi`|✔|❌|❌|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
67
+ |[console.upstage.ai/playground/chat](https://console.upstage.ai/playground/chat)|`g4f.Provider.Upstage`|`solar-pro, solar-mini`|❌|❌|✔|![Active](https://img.shields.io/badge/Active-brightgreen)|❌|
68
+ |[whiterabbitneo.com](https://www.whiterabbitneo.com)|`g4f.Provider.WhiteRabbitNeo`|✔|❌|❌|?|![Unknown](https://img.shields.io/badge/Unknown-grey)|✔|
69
+ |[you.com](https://you.com)|`g4f.Provider.You`|✔|✔|✔|✔|![Unknown](https://img.shields.io/badge/Unknown-grey)|❌+✔|
70
+
71
+ ## Models
72
+
73
+ ### Text Models
74
+ | Model | Base Provider | Providers | Website |
75
+ |-------|---------------|-----------|---------|
76
+ |gpt-3.5-turbo|OpenAI|4+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-3-5-turbo)|
77
+ |gpt-4|OpenAI|6+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)|
78
+ |gpt-4-turbo|OpenAI|4+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4-turbo-and-gpt-4)|
79
+ |gpt-4o|OpenAI|7+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o)|
80
+ |gpt-4o-mini|OpenAI|10+ Providers|[platform.openai.com](https://platform.openai.com/docs/models/gpt-4o-mini)|
81
+ |o1|OpenAI|0+ Providers|[platform.openai.com](https://openai.com/index/introducing-openai-o1-preview/)|
82
+ |o1-mini|OpenAI|0+ Providers|[platform.openai.com](https://openai.com/index/openai-o1-mini-advancing-cost-efficient-reasoning/)|
83
+ |llama-2-7b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-2-7b)|
84
+ |llama-2-13b|Meta Llama|1+ Providers|[llama.com](https://www.llama.com/llama2/)|
85
+ |llama-3-8b|Meta Llama|4+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3/)|
86
+ |llama-3-70b|Meta Llama|4+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3/)|
87
+ |llama-3.1-8b|Meta Llama|7+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
88
+ |llama-3.1-70b|Meta Llama|14+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
89
+ |llama-3.1-405b|Meta Llama|5+ Providers|[ai.meta.com](https://ai.meta.com/blog/meta-llama-3-1/)|
90
+ |llama-3.2-1b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Llama-3.2-1B)|
91
+ |llama-3.2-3b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/blog/llama32)|
92
+ |llama-3.2-11b|Meta Llama|3+ Providers|[ai.meta.com](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/)|
93
+ |llama-3.2-90b|Meta Llama|2+ Providers|[ai.meta.com](https://ai.meta.com/blog/llama-3-2-connect-2024-vision-edge-mobile-devices/)|
94
+ |llamaguard-7b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/LlamaGuard-7b)|
95
+ |llamaguard-2-8b|Meta Llama|1+ Providers|[huggingface.co](https://huggingface.co/meta-llama/Meta-Llama-Guard-2-8B)|
96
+ |mistral-7b|Mistral AI|4+ Providers|[mistral.ai](https://mistral.ai/news/announcing-mistral-7b/)|
97
+ |mixtral-8x7b|Mistral AI|6+ Providers|[mistral.ai](https://mistral.ai/news/mixtral-of-experts/)|
98
+ |mixtral-8x22b|Mistral AI|3+ Providers|[mistral.ai](https://mistral.ai/news/mixtral-8x22b/)|
99
+ |mistral-nemo|Mistral AI|2+ Providers|[huggingface.co](https://huggingface.co/mistralai/Mistral-Nemo-Instruct-2407)|
100
+ |mistral-large|Mistral AI|2+ Providers|[mistral.ai](https://mistral.ai/news/mistral-large-2407/)|
101
+ |mixtral-8x7b-dpo|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)|
102
+ |hermes-2-dpo|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO)|
103
+ |hermes-2|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Hermes-2-Pro-Mistral-7B)|
104
+ |yi-34b|NousResearch|1+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Nous-Hermes-2-Yi-34B)|
105
+ |hermes-3|NousResearch|2+ Providers|[huggingface.co](https://huggingface.co/NousResearch/Hermes-3-Llama-3.1-8B)|
106
+ |gemini|Google DeepMind|1+ Providers|[deepmind.google](http://deepmind.google/technologies/gemini/)|
107
+ |gemini-flash|Google DeepMind|4+ Providers|[deepmind.google](https://deepmind.google/technologies/gemini/flash/)|
108
+ |gemini-pro|Google DeepMind|10+ Providers|[deepmind.google](https://deepmind.google/technologies/gemini/pro/)|
109
+ |gemma-2b|Google|5+ Providers|[huggingface.co](https://huggingface.co/google/gemma-2b)|
110
+ |gemma-2b-9b|Google|1+ Providers|[huggingface.co](https://huggingface.co/google/gemma-2-9b)|
111
+ |gemma-2b-27b|Google|2+ Providers|[huggingface.co](https://huggingface.co/google/gemma-2-27b)|
112
+ |gemma-7b|Google|1+ Providers|[huggingface.co](https://huggingface.co/google/gemma-7b)|
113
+ |gemma_2_27b|Google|1+ Providers|[huggingface.co](https://huggingface.co/blog/gemma2)|
114
+ |claude-2.1|Anthropic|1+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-2)|
115
+ |claude-3-haiku|Anthropic|4+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-haiku)|
116
+ |claude-3-sonnet|Anthropic|2+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)|
117
+ |claude-3-opus|Anthropic|2+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-family)|
118
+ |claude-3.5-sonnet|Anthropic|6+ Providers|[anthropic.com](https://www.anthropic.com/news/claude-3-5-sonnet)|
119
+ |blackboxai|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)|
120
+ |blackboxai-pro|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)|
121
+ |yi-1.5-9b|01-ai|1+ Providers|[huggingface.co](https://huggingface.co/01-ai/Yi-1.5-9B)|
122
+ |phi-2|Microsoft|1+ Providers|[huggingface.co](https://huggingface.co/microsoft/phi-2)|
123
+ |phi-3-medium-4k|Microsoft|1+ Providers|[huggingface.co](https://huggingface.co/microsoft/Phi-3-medium-4k-instruct)|
124
+ |phi-3.5-mini|Microsoft|2+ Providers|[huggingface.co](https://huggingface.co/microsoft/Phi-3-medium-4k-instruct)|
125
+ |dbrx-instruct|Databricks|1+ Providers|[huggingface.co](https://huggingface.co/databricks/dbrx-instruct)|
126
+ |command-r-plus|CohereForAI|1+ Providers|[docs.cohere.com](https://docs.cohere.com/docs/command-r-plus)|
127
+ |sparkdesk-v1.1|iFlytek|1+ Providers|[xfyun.cn](https://www.xfyun.cn/doc/spark/Guide.html)|
128
+ |qwen|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen)|
129
+ |qwen-1.5-0.5b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-0.5B)|
130
+ |qwen-1.5-7b|Qwen|2+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-7B)|
131
+ |qwen-1.5-14b|Qwen|3+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-14B)|
132
+ |qwen-1.5-72b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-72B)|
133
+ |qwen-1.5-110b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-110B)|
134
+ |qwen-1.5-1.8b|Qwen|1+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen1.5-1.8B)|
135
+ |qwen-2-72b|Qwen|4+ Providers|[huggingface.co](https://huggingface.co/Qwen/Qwen2-72B)|
136
+ |glm-3-6b|Zhipu AI|1+ Providers|[github.com/THUDM/ChatGLM3](https://github.com/THUDM/ChatGLM3)|
137
+ |glm-4-9B|Zhipu AI|1+ Providers|[github.com/THUDM/GLM-4](https://github.com/THUDM/GLM-4)|
138
+ |solar-1-mini|Upstage|1+ Providers|[upstage.ai/](https://www.upstage.ai/feed/product/solarmini-performance-report)|
139
+ |solar-10-7b|Upstage|1+ Providers|[huggingface.co](https://huggingface.co/upstage/SOLAR-10.7B-Instruct-v1.0)|
140
+ |solar-pro|Upstage|1+ Providers|[huggingface.co](https://huggingface.co/upstage/solar-pro-preview-instruct)|
141
+ |pi|Inflection|1+ Providers|[inflection.ai](https://inflection.ai/blog/inflection-2-5)|
142
+ |deepseek-coder|DeepSeek|1+ Providers|[huggingface.co](https://huggingface.co/deepseek-ai/DeepSeek-Coder-V2-Instruct)|
143
+ |wizardlm-2-7b|WizardLM|1+ Providers|[huggingface.co](https://huggingface.co/dreamgen/WizardLM-2-7B)|
144
+ |wizardlm-2-8x22b|WizardLM|2+ Providers|[huggingface.co](https://huggingface.co/alpindale/WizardLM-2-8x22B)|
145
+ |sh-n-7b|Together|1+ Providers|[huggingface.co](https://huggingface.co/togethercomputer/StripedHyena-Nous-7B)|
146
+ |llava-13b|Yorickvp|1+ Providers|[huggingface.co](https://huggingface.co/liuhaotian/llava-v1.5-13b)|
147
+ |lzlv-70b|Lzlv|1+ Providers|[huggingface.co](https://huggingface.co/lizpreciatior/lzlv_70b_fp16_hf)|
148
+ |openchat-3.5|OpenChat|1+ Providers|[huggingface.co](https://huggingface.co/openchat/openchat_3.5)|
149
+ |openchat-3.6-8b|OpenChat|1+ Providers|[huggingface.co](https://huggingface.co/openchat/openchat-3.6-8b-20240522)|
150
+ |phind-codellama-34b-v2|Phind|1+ Providers|[huggingface.co](https://huggingface.co/Phind/Phind-CodeLlama-34B-v2)|
151
+ |dolphin-2.9.1-llama-3-70b|Cognitive Computations|1+ Providers|[huggingface.co](https://huggingface.co/cognitivecomputations/dolphin-2.9.1-llama-3-70b)|
152
+ |grok-2-mini|x.ai|1+ Providers|[x.ai](https://x.ai/blog/grok-2)|
153
+ |grok-2|x.ai|1+ Providers|[x.ai](https://x.ai/blog/grok-2)|
154
+ |sonar-online|Perplexity AI|2+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
155
+ |sonar-chat|Perplexity AI|1+ Providers|[docs.perplexity.ai](https://docs.perplexity.ai/)|
156
+ |mythomax-l2-13b|Gryphe|1+ Providers|[huggingface.co](https://huggingface.co/Gryphe/MythoMax-L2-13b)|
157
+ |cosmosrp|Gryphe|1+ Providers|[huggingface.co](https://huggingface.co/PawanKrd/CosmosRP-8k)|
158
+ |german-7b|TheBloke|1+ Providers|[huggingface.co](https://huggingface.co/TheBloke/DiscoLM_German_7b_v1-GGUF)|
159
+ |tinyllama-1.1b|TinyLlama|1+ Providers|[huggingface.co](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0)|
160
+ |cybertron-7b|TheBloke|1+ Providers|[huggingface.co](https://huggingface.co/fblgit/una-cybertron-7b-v2-bf16)|
161
+ |openhermes-2.5|Teknium|1+ Providers|[huggingface.co](https://huggingface.co/datasets/teknium/OpenHermes-2.5)|
162
+ |lfm-40b|Liquid|1+ Providers|[liquid.ai](https://www.liquid.ai/liquid-foundation-models)|
163
+ |zephyr-7b|HuggingFaceH4|1+ Providers|[huggingface.co](https://huggingface.co/HuggingFaceH4/zephyr-7b-beta)|
164
+
165
+
166
+ ### Image Models
167
+ | Model | Base Provider | Providers | Website |
168
+ |-------|---------------|-----------|---------|
169
+ |sdxl|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/docs/diffusers/en/using-diffusers/sdxl)|
170
+ |sdxl-lora|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/blog/lcm_lora)|
171
+ |sdxl-turbo|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/stabilityai/sdxl-turbo)|
172
+ |sd-1.5|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/runwayml/stable-diffusion-v1-5)|
173
+ |sd-3|Stability AI|1+ Providers|[huggingface.co](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/stable_diffusion_3)|
174
+ |playground-v2.5|Playground AI|1+ Providers|[huggingface.co](https://huggingface.co/playgroundai/playground-v2.5-1024px-aesthetic)|
175
+ |flux|Black Forest Labs|2+ Providers|[github.com/black-forest-labs/flux](https://github.com/black-forest-labs/flux)|
176
+ |flux-pro|Black Forest Labs|2+ Providers|[github.com/black-forest-labs/flux](https://github.com/black-forest-labs/flux)|
177
+ |flux-realism|Flux AI|2+ Providers|[]()|
178
+ |flux-anime|Flux AI|1+ Providers|[]()|
179
+ |flux-3d|Flux AI|1+ Providers|[]()|
180
+ |flux-disney|Flux AI|1+ Providers|[]()|
181
+ |flux-pixel|Flux AI|1+ Providers|[]()|
182
+ |flux-4o|Flux AI|1+ Providers|[]()|
183
+ |flux-schnell|Black Forest Labs|2+ Providers|[huggingface.co](https://huggingface.co/black-forest-labs/FLUX.1-schnell)|
184
+ |dalle|OpenAI|1+ Providers|[openai.com](https://openai.com/index/dall-e/)|
185
+ |dalle-2|OpenAI|1+ Providers|[openai.com](https://openai.com/index/dall-e-2/)|
186
+ |emi||1+ Providers|[]()|
187
+ |any-dark||1+ Providers|[]()|
188
+ |midjourney|Midjourney|1+ Providers|[docs.midjourney.com](https://docs.midjourney.com/docs/model-versions)|
189
+
190
+ ### Vision Models
191
+ | Model | Base Provider | Providers | Website |
192
+ |-------|---------------|-----------|---------|
193
+ |gpt-4-vision|OpenAI|1+ Providers|[openai.com](https://openai.com/research/gpt-4v-system-card)|
194
+ |gemini-pro-vision|Google DeepMind|1+ Providers | [deepmind.google](https://deepmind.google/technologies/gemini/)|
195
+ |blackboxai|Blackbox AI|1+ Providers|[docs.blackbox.chat](https://docs.blackbox.chat/blackbox-ai-1)|
196
+
197
+ ### Providers and vision models
198
+ | Provider | Base Provider | | Vision Models | Status | Auth |
199
+ |-------|---------------|-----------|---------|---------|---------|
200
+ | `g4f.Provider.Blackbox` | Blackbox AI | | `blackboxai, gemini-flash, llama-3.1-8b, llama-3.1-70b, llama-3.1-405b, gpt-4o, gemini-pro` | ![Active](https://img.shields.io/badge/Active-brightgreen) | ❌ |
201
+
202
+ ## Conclusion and Usage Tips
203
+ This document provides a comprehensive overview of various AI providers and models available for text generation, image generation, and vision tasks. **When choosing a provider or model, consider the following factors:**
204
+ 1. **Availability**: Check the status of the provider to ensure it's currently active and accessible.
205
+ 2. **Model Capabilities**: Different models excel at different tasks. Choose a model that best fits your specific needs, whether it's text generation, image creation, or vision-related tasks.
206
+ 3. **Authentication**: Some providers require authentication, while others don't. Consider this when selecting a provider for your project.
207
+ 4. **Streaming Support**: If real-time responses are important for your application, prioritize providers that offer streaming capabilities.
208
+ 5. **Vision Models**: For tasks requiring image understanding or multimodal interactions, look for providers offering vision models.
209
+
210
+ Remember to stay updated with the latest developments in the AI field, as new models and providers are constantly emerging and evolving.
211
+
212
+ ---
213
+
214
+ [Return to Home](/)
docs/requirements.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### G4F - Additional Requirements
2
+
3
+ #### Introduction
4
+
5
+ You can install requirements partially or completely. So G4F can be used as you wish. You have the following options for this:
6
+
7
+ #### Options
8
+
9
+ Install g4f with all possible dependencies:
10
+ ```
11
+ pip install -U g4f[all]
12
+ ```
13
+ Or install only g4f and the required packages for the OpenaiChat provider:
14
+ ```
15
+ pip install -U g4f[openai]
16
+ ```
17
+ Install required packages for the Interference API:
18
+ ```
19
+ pip install -U g4f[api]
20
+ ```
21
+ Install required packages for the Web UI:
22
+ ```
23
+ pip install -U g4f[gui]
24
+ ```
25
+ Install required packages for uploading / generating images:
26
+ ```
27
+ pip install -U g4f[image]
28
+ ```
29
+ Install required packages for using the webdriver:
30
+ ```
31
+ pip install -U g4f[webdriver]
32
+ ```
33
+ Install required package for proxy support with aiohttp:
34
+ ```
35
+ pip install -U aiohttp_socks
36
+ ```
37
+ Install required package for loading cookies from browser:
38
+ ```
39
+ pip install browser_cookie3
40
+ ```
41
+ Install all packages and uninstall this package for disabling the webdriver:
42
+ ```
43
+ pip uninstall undetected-chromedriver
44
+ ```
45
+
46
+ ---
47
+ [Return to Home](/)
docs/waterfall.jpeg ADDED
docs/webview.md ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### G4F - Webview GUI
2
+
3
+ Open the GUI in a window of your OS. Runs on a local/static/ssl server and use a JavaScript API.
4
+ Supports login into the OpenAI Chat (.har files), Image Upload and streamed Text Generation.
5
+
6
+ Supports all platforms, but only Linux/Windows tested.
7
+
8
+ 1. Install all python requirements with:
9
+
10
+ ```bash
11
+ pip install g4f[webview]
12
+ ```
13
+
14
+ 2. *a)* Follow the **OS specific** steps here:
15
+ [pywebview installation](https://pywebview.flowrl.com/guide/installation.html#dependencies)
16
+
17
+ 2. *b)* **WebView2** on **Windows**: Our application requires the *WebView2 Runtime* to be installed on your system. If you do not have it installed, please download and install it from the [Microsoft Developer Website](https://developer.microsoft.com/en-us/microsoft-edge/webview2/). If you already have *WebView2 Runtime* installed but are encountering issues, navigate to *Installed Windows Apps*, select *WebView2*, and opt for the repair option.
18
+
19
+ 3. Run the app with:
20
+
21
+ ```python
22
+ from g4f.gui.webview import run_webview
23
+ run_webview(debug=True)
24
+ ```
25
+ or execute the following command:
26
+ ```bash
27
+ python -m g4f.gui.webview -debug
28
+ ```
29
+
30
+ [Return to Home](/)
etc/examples/api.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ print(json_data.get("choices", [{"delta": {}}])[0]["delta"].get("content", ""), end="")
26
+ except json.JSONDecodeError:
27
+ pass
28
+ print()
29
+ print()
30
+ print()
31
+ body = {
32
+ "model": "",
33
+ "provider": "Copilot",
34
+ "stream": True,
35
+ "messages": [
36
+ {"role": "user", "content": "Tell me somethings about my name"}
37
+ ],
38
+ "conversation_id": conversation_id
39
+ }
40
+ response = requests.post(url, json=body, stream=True)
41
+ response.raise_for_status()
42
+ for line in response.iter_lines():
43
+ if line.startswith(b"data: "):
44
+ try:
45
+ json_data = json.loads(line[6:])
46
+ if json_data.get("error"):
47
+ print(json_data)
48
+ break
49
+ print(json_data.get("choices", [{"delta": {}}])[0]["delta"].get("content", ""), end="")
50
+ except json.JSONDecodeError:
51
+ pass
etc/examples/image_api.py ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ url = "http://localhost:1337/v1/images/generations"
3
+ body = {
4
+ "model": "dall-e",
5
+ "prompt": "hello world user",
6
+ #"response_format": "b64_json",
7
+ }
8
+ data = requests.post(url, json=body, stream=True).json()
9
+ print(data)