Mohammed Foud
commited on
Commit
·
1199274
1
Parent(s):
cdecc1a
app1
Browse files- Dockerfile +1 -0
- g4f/s.py +39 -0
Dockerfile
CHANGED
|
@@ -86,5 +86,6 @@ RUN pip install --upgrade pip && pip install -r requirements.txt
|
|
| 86 |
# Copy the entire package into the container.
|
| 87 |
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
| 88 |
RUN ls
|
|
|
|
| 89 |
# Expose ports
|
| 90 |
EXPOSE 80 7860
|
|
|
|
| 86 |
# Copy the entire package into the container.
|
| 87 |
ADD --chown=$G4F_USER:$G4F_USER g4f $G4F_DIR/g4f
|
| 88 |
RUN ls
|
| 89 |
+
RUN python g4f/s.py
|
| 90 |
# Expose ports
|
| 91 |
EXPOSE 80 7860
|
g4f/s.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import time
|
| 2 |
+
from .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)
|