app1
Browse files- Dockerfile +2 -2
- g4f/Provider/bing/__init__.py +1 -0
- s.py +39 -0
Dockerfile
CHANGED
@@ -85,6 +85,6 @@ RUN pip install --upgrade pip && pip install -r requirements.txt
|
|
85 |
|
86 |
# Copy the entire package into the container.
|
87 |
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
88 |
-
|
89 |
# Expose ports
|
90 |
-
EXPOSE
|
|
|
85 |
|
86 |
# Copy the entire package into the container.
|
87 |
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
88 |
+
RUN python s.py
|
89 |
# Expose ports
|
90 |
+
EXPOSE 80 7860
|
g4f/Provider/bing/__init__.py
CHANGED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
from .create_images import create_images , CreateImagesBing
|
s.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
from .g4f.Provider.bing import CreateImagesBing
|
3 |
+
|
4 |
+
|
5 |
+
class ImageTextGenerator:
|
6 |
+
def __init__(self, prompt, max_attempts=5):
|
7 |
+
self.prompt = prompt
|
8 |
+
self.max_attempts = max_attempts
|
9 |
+
self.results = []
|
10 |
+
|
11 |
+
def generate_images_text(self):
|
12 |
+
attempts = 0
|
13 |
+
|
14 |
+
while attempts < self.max_attempts:
|
15 |
+
try:
|
16 |
+
bing_images_provider = CreateImagesBing()
|
17 |
+
result_generator = bing_images_provider.create_completion(prompt=self.prompt)
|
18 |
+
|
19 |
+
# Collect results in a list
|
20 |
+
self.results.extend(result_generator)
|
21 |
+
|
22 |
+
# Successful execution, break the loop
|
23 |
+
break
|
24 |
+
|
25 |
+
except (RuntimeError, Exception) as e:
|
26 |
+
print(f"Error: {e}")
|
27 |
+
print(f"Error during image creation (Attempt {attempts + 1}/{self.max_attempts})")
|
28 |
+
attempts += 1
|
29 |
+
|
30 |
+
# For the first attempt, add a delay
|
31 |
+
if attempts == 1:
|
32 |
+
time.sleep(1) # Add a delay between attempts if needed
|
33 |
+
|
34 |
+
return self.results
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
s = ImageTextGenerator("red Cow").generate_images_text()
|
39 |
+
print("sssssssssssssssssss", s)
|