Spaces:
Runtime error
Runtime error
Commit
·
31f9459
1
Parent(s):
47a5c4c
Update app.py
Browse files
app.py
CHANGED
@@ -49,8 +49,8 @@ import random
|
|
49 |
import replicate
|
50 |
import time
|
51 |
|
52 |
-
openai.api_key = '
|
53 |
-
|
54 |
|
55 |
def generate_prompt(body_type,exterior_color,roof_type,wheels_and_tires):
|
56 |
response = openai.Completion.create(
|
@@ -220,7 +220,8 @@ def crop_image(image,mask):
|
|
220 |
for i in range(1,15):
|
221 |
try:
|
222 |
serpai_op = use_serpapi(url,i)
|
223 |
-
|
|
|
224 |
print(e)
|
225 |
|
226 |
return serpai_op
|
@@ -267,14 +268,14 @@ def shopping_url(product_title,api_key):
|
|
267 |
|
268 |
def upload_img_url(image_path):
|
269 |
API_ENDPOINT = "https://api.imgbb.com/1/upload"
|
270 |
-
|
271 |
|
272 |
with open(image_path, "rb") as image:
|
273 |
image_data_ = b64encode(image.read())
|
274 |
image_data = image_data_.decode('utf-8')
|
275 |
|
276 |
payload = {
|
277 |
-
"key":
|
278 |
"image": image_data
|
279 |
}
|
280 |
# Send the API request
|
|
|
49 |
import replicate
|
50 |
import time
|
51 |
|
52 |
+
openai.api_key = os.environ['OPENAI_API_KEY']
|
53 |
+
|
54 |
|
55 |
def generate_prompt(body_type,exterior_color,roof_type,wheels_and_tires):
|
56 |
response = openai.Completion.create(
|
|
|
220 |
for i in range(1,15):
|
221 |
try:
|
222 |
serpai_op = use_serpapi(url,i)
|
223 |
+
break
|
224 |
+
except Exception as e:
|
225 |
print(e)
|
226 |
|
227 |
return serpai_op
|
|
|
268 |
|
269 |
def upload_img_url(image_path):
|
270 |
API_ENDPOINT = "https://api.imgbb.com/1/upload"
|
271 |
+
|
272 |
|
273 |
with open(image_path, "rb") as image:
|
274 |
image_data_ = b64encode(image.read())
|
275 |
image_data = image_data_.decode('utf-8')
|
276 |
|
277 |
payload = {
|
278 |
+
"key": os.environ['IMGBB_API_KEY'],
|
279 |
"image": image_data
|
280 |
}
|
281 |
# Send the API request
|