返回提交历史
Modified
.github/workflows/publish-workflow.yaml
+14
-10
Modified
README.md
+2
-2
Modified
g4f/providers/base_provider.py
+15
-24
XFEstudio/gpt4free
Update bulding and publishing docker image for arm64 Fix async_generator can't be used in 'await' expression on Windows
efaf959d
代码差异
3 个文件
+31
-36
@@ -42,7 +42,6 @@ jobs:
42
42
with:
43
43
images: |
44
44
hlohaus789/g4f
45
ghcr.io/${{ github.repository }}
46
45
47
46
- name: Log in to Docker Hub
48
47
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
@@ -50,13 +49,6 @@ jobs:
50
49
username: ${{ secrets.DOCKER_USERNAME }}
51
50
password: ${{ secrets.DOCKER_PASSWORD }}
52
51
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
52
- name: Build and push armv7 image
61
53
uses: docker/build-push-action@v5
62
54
with:
@@ -85,12 +77,24 @@ jobs:
85
77
build-args: |
86
78
G4F_VERSION=${{ github.ref_name }}
87
79
88
- name: Build and push big images
80
- name: Build and push arm64 image
81
uses: docker/build-push-action@v5
82
with:
83
context: .
84
file: docker/Dockerfile-slim
85
platforms: linux/arm64
86
push: true
87
tags: ${{ steps.metadata.outputs.tags }}
88
labels: ${{ steps.metadata.outputs.labels }}
89
build-args: |
90
G4F_VERSION=${{ github.ref_name }}
91
92
- name: Build and push big image
89
93
uses: docker/build-push-action@v5
90
94
with:
91
95
context: .
92
96
file: docker/Dockerfile
93
platforms: linux/amd64,linux/arm64
97
platforms: linux/amd64
94
98
push: true
95
99
tags: ${{ steps.metadata.outputs.tags }}
96
100
labels: ${{ steps.metadata.outputs.labels }}
@@ -98,7 +98,7 @@ Is your site on this repository and you want to take it down? Send an email to t
98
98
99
99
### 🐳 Using Docker
100
100
1. **Install Docker:** [Download and install Docker](https://docs.docker.com/get-docker/).
101
2. **Set Up Directories:** Before running the container, make sure the necessary data directories exist or can be created. For example, you can create and set ownership on these directories by running:
101
2. **Set Up Directories:** Before running the container, make sure the necessary data directories exist or can be created. For example, you can create and set ownership on these directories by running: (Only x64)
102
102
```bash
103
103
mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_images
104
104
sudo chown -R 1200:1201 ${PWD}/har_and_cookies ${PWD}/generated_images
@@ -113,7 +113,7 @@ Is your site on this repository and you want to take it down? Send an email to t
113
113
hlohaus789/g4f:latest
114
114
```
115
115
116
4. **Running the Slim Docker Image:** And use the following commands to run the Slim Docker image. This command also updates the `g4f` package at startup and installs any additional dependencies:
116
4. **Running the Slim Docker Image:** And use the following commands to run the Slim Docker image. This command also updates the `g4f` package at startup and installs any additional dependencies: (x64 and arm64)
117
117
```bash
118
118
mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_images
119
119
chown -R 1000:1000 ${PWD}/har_and_cookies ${PWD}/generated_images
@@ -432,14 +432,11 @@ class AsyncAuthedProvider(AsyncGeneratorProvider):
432
432
yield from to_sync_generator(cls.create_authed(model, messages, auth_result, **kwargs))
433
433
except (MissingAuthError, NoValidHarFileError):
434
434
auth_result = cls.on_auth(**kwargs)
435
try:
436
for chunk in auth_result:
437
if hasattr(chunk, "get_dict"):
438
auth_result = chunk
439
else:
440
yield chunk
441
except TypeError:
442
pass
435
for chunk in auth_result:
436
if hasattr(chunk, "get_dict"):
437
auth_result = chunk
438
else:
439
yield chunk
443
440
yield from to_sync_generator(cls.create_authed(model, messages, auth_result, **kwargs))
444
441
finally:
445
442
if hasattr(auth_result, "get_dict"):
@@ -464,14 +461,11 @@ class AsyncAuthedProvider(AsyncGeneratorProvider):
464
461
auth_result = AuthResult(**json.load(f))
465
462
else:
466
463
auth_result = cls.on_auth_async(**kwargs)
467
if hasattr(auth_result, "_aiter__"):
468
async for chunk in auth_result:
469
if isinstance(chunk, AsyncResult):
470
auth_result = chunk
471
else:
472
yield chunk
473
else:
474
auth_result = await auth_result
464
async for chunk in auth_result:
465
if hasattr(chunk, "get_dict"):
466
auth_result = chunk
467
else:
468
yield chunk
475
469
response = to_async_iterator(cls.create_authed(model, messages, **kwargs, auth_result=auth_result))
476
470
async for chunk in response:
477
471
yield chunk
@@ -479,14 +473,11 @@ class AsyncAuthedProvider(AsyncGeneratorProvider):
479
473
if cache_file.exists():
480
474
cache_file.unlink()
481
475
auth_result = cls.on_auth_async(**kwargs)
482
if hasattr(auth_result, "_aiter__"):
483
async for chunk in auth_result:
484
if isinstance(chunk, AsyncResult):
485
auth_result = chunk
486
else:
487
yield chunk
488
else:
489
auth_result = await auth_result
476
async for chunk in auth_result:
477
if hasattr(chunk, "get_dict"):
478
auth_result = chunk
479
else:
480
yield chunk
490
481
response = to_async_iterator(cls.create_authed(model, messages, **kwargs, auth_result=auth_result))
491
482
async for chunk in response:
492
483
yield chunk