Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import os
|
|
3 |
import google.generativeai as genai
|
4 |
import logging
|
5 |
import time
|
6 |
-
|
7 |
|
8 |
# Configure Logging
|
9 |
logging.basicConfig(level=logging.ERROR, format='%(asctime)s - %(levelname)s - %(message)s')
|
@@ -28,9 +28,9 @@ custom_css = """
|
|
28 |
}
|
29 |
"""
|
30 |
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
def predict(prompt):
|
35 |
# Create the model
|
36 |
generation_config = {
|
|
|
3 |
import google.generativeai as genai
|
4 |
import logging
|
5 |
import time
|
6 |
+
import backoff
|
7 |
|
8 |
# Configure Logging
|
9 |
logging.basicConfig(level=logging.ERROR, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
28 |
}
|
29 |
"""
|
30 |
|
31 |
+
@backoff.on_exception(backoff.expo,
|
32 |
+
(genai.APIError),
|
33 |
+
max_tries=3) # retry up to 3 times
|
34 |
def predict(prompt):
|
35 |
# Create the model
|
36 |
generation_config = {
|