返回提交历史
Modified
.github/workflows/build-packages.yml
+7
-0
Modified
.gitignore
+1
-1
Modified
docker/Dockerfile
+13
-12
Added
test.py
+43
-0
XFEstudio/gpt4free
Fix build deb
612e1fae
代码差异
4 个文件
+64
-13
@@ -48,6 +48,9 @@ jobs:
48
48
with:
49
49
python-version: "3.x"
50
50
- name: Install build tools
51
run: |
52
python -m pip install --upgrade pip
53
python -m pip install build twine - name: Install build tools
51
54
run: |
52
55
python -m pip install --upgrade pip
53
56
python -m pip install build twine
@@ -165,6 +168,10 @@ jobs:
165
168
run: |
166
169
sudo apt-get update
167
170
sudo apt-get install -y build-essential debhelper dh-python python3-setuptools python3-dev
171
- name: Install build tools
172
run: |
173
python -m pip install --upgrade pip
174
python -m pip install build
168
175
- name: Create Debian package structure
169
176
run: |
170
177
mkdir -p debian/g4f/usr/bin
@@ -45,4 +45,4 @@ dist/
45
45
*.spec
46
46
pyproject.toml.bak
47
47
debian/
48
winget/*
48
winget/
@@ -1,11 +1,11 @@
1
FROM selenium/node-chrome
1
FROM browserless/chrome
2
2
3
3
ARG G4F_VERSION
4
4
ENV G4F_VERSION $G4F_VERSION
5
5
6
ENV SE_SCREEN_WIDTH 1850
6
#ENV SE_SCREEN_WIDTH 1850
7
7
ENV G4F_DIR /app
8
ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=secret
8
#ENV G4F_LOGIN_URL http://localhost:7900/?autoconnect=1&resize=scale&password=secret
9
9
10
10
USER root
11
11
@@ -26,17 +26,17 @@ RUN apt-get -qqy update \
26
26
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
27
27
28
28
# Update entrypoint
29
COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
30
COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
29
#COPY docker/supervisor.conf /etc/supervisor/conf.d/selenium.conf
30
#COPY docker/supervisor-api.conf /etc/supervisor/conf.d/api.conf
31
31
32
32
# Change background image
33
COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
33
#COPY docker/background.png /usr/share/images/fluxbox/ubuntu-light.png
34
34
35
35
# Add user, fix permissions
36
RUN chown "${SEL_UID}:${SEL_GID}" $HOME/.local /opt/venv/share
36
#RUN chown "${SEL_UID}:${SEL_GID}" $HOME/.local /opt/venv/share
37
37
38
38
# Switch user
39
USER $SEL_UID
39
USER $BLESS_USER_ID
40
40
41
41
# Set the working directory in the container.
42
42
WORKDIR $G4F_DIR
@@ -45,11 +45,12 @@ WORKDIR $G4F_DIR
45
45
COPY requirements.txt $G4F_DIR
46
46
47
47
# Upgrade pip for the latest features and install the project's Python dependencies.
48
RUN pip install --break-system-packages --upgrade pip \
49
&& pip install --break-system-packages -r requirements.txt
48
RUN pip install -r requirements.txt
50
49
51
50
# Copy the entire package into the container.
52
ADD --chown=$SEL_UID:$SEL_GID g4f $G4F_DIR/g4f
51
ADD --chown=$BLESS_USER_ID:$BLESS_USER_ID g4f $G4F_DIR/g4f
53
52
54
53
# Expose ports
55
EXPOSE 8080 7900
54
EXPOSE 8080
55
56
CMD ./scripts/start.sh & python3 -m g4f --port=8080 --debug
@@ -0,0 +1,43 @@
1
import asyncio
2
from pathlib import Path
3
from g4f.client import AsyncClient
4
from g4f.Provider import HuggingSpace, Azure
5
from g4f.cookies import read_cookie_files
6
7
# Load cookies and authentication environment variables needed by providers
8
read_cookie_files()
9
10
# Initialize asynchronous client to interact with providers
11
client = AsyncClient()
12
13
# Define an async function that creates an image variation using the HuggingSpace provider
14
async def main_with_hugging_space():
15
# Call create_variation with an image path, provider, model, prompt and desired response format
16
result = await client.images.create_variation(
17
image=Path("g4f.dev/docs/images/strawberry.jpg"), # Path to input image
18
provider=HuggingSpace, # Provider to use
19
model="flux-kontext-dev", # Model name for HuggingSpace
20
prompt="Change color to black and white", # Variation prompt
21
response_format="url" # Return URL to generated image
22
)
23
print(result) # Print the URL or result returned by the provider
24
25
# Define an async function that creates an image variation using the Azure provider
26
async def main_with_azure():
27
result = await client.images.create_variation(
28
image=Path("g4f.dev/docs/images/strawberry.jpg"),
29
provider=Azure,
30
model="flux-kontext",
31
prompt="Add text 'Hello World' in the center",
32
response_format="url"
33
)
34
print(result) # Print the returned URL or response
35
36
# Run the Azure image variation example asynchronously
37
asyncio.run(main_with_azure())
38
39
# Import helper function to get directory used for cookies and related files
40
from g4f.cookies import get_cookies_dir
41
42
# Print the directory currently used for storing cookies
43
print(get_cookies_dir())