Spaces:
Runtime error
Runtime error
Update worker_runpod.py
Browse files- worker_runpod.py +15 -11
worker_runpod.py
CHANGED
@@ -150,18 +150,22 @@ def generate(input):
|
|
150 |
discord_token = os.getenv('com_camenduru_discord_token')
|
151 |
job_id = values['job_id']
|
152 |
del values['job_id']
|
153 |
-
default_filename = os.path.basename(result)
|
154 |
-
with open(result, "rb") as file:
|
155 |
-
|
156 |
-
payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
|
157 |
-
response = requests.post(
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
)
|
|
|
|
|
|
|
|
|
163 |
response.raise_for_status()
|
164 |
-
result_url = response.
|
165 |
notify_payload = {"jobId": job_id, "result": result_url, "status": "DONE"}
|
166 |
web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
|
167 |
web_notify_token = os.getenv('com_camenduru_web_notify_token')
|
|
|
150 |
discord_token = os.getenv('com_camenduru_discord_token')
|
151 |
job_id = values['job_id']
|
152 |
del values['job_id']
|
153 |
+
# default_filename = os.path.basename(result)
|
154 |
+
# with open(result, "rb") as file:
|
155 |
+
# files = {default_filename: file.read()}
|
156 |
+
# payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
|
157 |
+
# response = requests.post(
|
158 |
+
# f"https://discord.com/api/v9/channels/{discord_channel}/messages",
|
159 |
+
# data=payload,
|
160 |
+
# headers={"Authorization": f"Bot {discord_token}"},
|
161 |
+
# files=files
|
162 |
+
# )
|
163 |
+
# response.raise_for_status()
|
164 |
+
# result_url = response.json()['attachments'][0]['url']
|
165 |
+
with open(result, 'rb') as file:
|
166 |
+
response = requests.post("https://upload.tost.ai/api/v1", files={'file': file})
|
167 |
response.raise_for_status()
|
168 |
+
result_url = response.text
|
169 |
notify_payload = {"jobId": job_id, "result": result_url, "status": "DONE"}
|
170 |
web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
|
171 |
web_notify_token = os.getenv('com_camenduru_web_notify_token')
|