Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
|
@@ -70,14 +70,15 @@ def createCampaign(title, details, file_url):
|
|
| 70 |
|
| 71 |
def predict(productURL, screenshots):
|
| 72 |
# Step 1: Get campaign copy from openAI
|
| 73 |
-
response = client.chat.completions.create(
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
)
|
| 80 |
-
campaignCopy = response.choices[0].message.content
|
|
|
|
| 81 |
|
| 82 |
print("Step 1: Complete")
|
| 83 |
|
|
|
|
| 70 |
|
| 71 |
def predict(productURL, screenshots):
|
| 72 |
# Step 1: Get campaign copy from openAI
|
| 73 |
+
# response = client.chat.completions.create(
|
| 74 |
+
# model="gpt-3.5-turbo",
|
| 75 |
+
# messages=[
|
| 76 |
+
# {"role": "system", "content": "You are a professional marketer, extract product information from user input. Output 5 campaign items, each with a title and description."},
|
| 77 |
+
# {"role": "user", "content": productURL}
|
| 78 |
+
# ]
|
| 79 |
+
# )
|
| 80 |
+
# campaignCopy = response.choices[0].message.content
|
| 81 |
+
campaignCopy = "Hello"
|
| 82 |
|
| 83 |
print("Step 1: Complete")
|
| 84 |
|
utils.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import requests
|
|
|
|
| 2 |
|
| 3 |
"""
|
| 4 |
Uploads an image to Placid App and returns the URL of the processed image.
|
|
@@ -15,18 +16,23 @@ api_key = "placid-jza5wyzybmjyf0oe-rponxsufgssdygqk"
|
|
| 15 |
|
| 16 |
def uploadImages(image_files):
|
| 17 |
files = []
|
| 18 |
-
for file_tuple in image_files:
|
| 19 |
file_path = file_tuple[0]
|
| 20 |
-
file_tuple = ('file', (file_path, open(file_path, 'rb'), '
|
| 21 |
files.append(file_tuple)
|
| 22 |
|
| 23 |
url = "https://api.placid.app/api/rest/media"
|
| 24 |
-
headers = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
response = requests.post(url, headers=headers, files=files)
|
|
|
|
| 26 |
|
| 27 |
data = response.json()
|
| 28 |
-
print(data)
|
| 29 |
-
|
| 30 |
file_urls = [item["file_id"] for item in data["media"]]
|
| 31 |
|
|
|
|
|
|
|
| 32 |
return file_urls
|
|
|
|
| 1 |
import requests
|
| 2 |
+
import os
|
| 3 |
|
| 4 |
"""
|
| 5 |
Uploads an image to Placid App and returns the URL of the processed image.
|
|
|
|
| 16 |
|
| 17 |
def uploadImages(image_files):
|
| 18 |
files = []
|
| 19 |
+
for index, file_tuple in enumerate(image_files):
|
| 20 |
file_path = file_tuple[0]
|
| 21 |
+
file_tuple = ('file'+str(index), (file_path, open(file_path, 'rb'), 'image/png'))
|
| 22 |
files.append(file_tuple)
|
| 23 |
|
| 24 |
url = "https://api.placid.app/api/rest/media"
|
| 25 |
+
headers = {
|
| 26 |
+
"Authorization": f"Bearer {api_key}",
|
| 27 |
+
"Content-Type": "multipart/form-data"
|
| 28 |
+
}
|
| 29 |
+
print(files)
|
| 30 |
response = requests.post(url, headers=headers, files=files)
|
| 31 |
+
print(response)
|
| 32 |
|
| 33 |
data = response.json()
|
|
|
|
|
|
|
| 34 |
file_urls = [item["file_id"] for item in data["media"]]
|
| 35 |
|
| 36 |
+
print(data)
|
| 37 |
+
|
| 38 |
return file_urls
|