Spaces:
Runtime error
Runtime error
Update worker_runpod.py
Browse files- worker_runpod.py +15 -11
worker_runpod.py
CHANGED
@@ -67,18 +67,22 @@ def generate(input):
|
|
67 |
discord_token = os.getenv('com_camenduru_discord_token')
|
68 |
job_id = values['job_id']
|
69 |
del values['job_id']
|
70 |
-
default_filename = os.path.basename(result)
|
71 |
-
with open(result, "rb") as file:
|
72 |
-
|
73 |
-
payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
|
74 |
-
response = requests.post(
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
)
|
|
|
|
|
|
|
|
|
80 |
response.raise_for_status()
|
81 |
-
result_url = response.
|
82 |
notify_payload = {"jobId": job_id, "result": result_url, "status": "DONE"}
|
83 |
web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
|
84 |
web_notify_token = os.getenv('com_camenduru_web_notify_token')
|
|
|
67 |
discord_token = os.getenv('com_camenduru_discord_token')
|
68 |
job_id = values['job_id']
|
69 |
del values['job_id']
|
70 |
+
# default_filename = os.path.basename(result)
|
71 |
+
# with open(result, "rb") as file:
|
72 |
+
# files = {default_filename: file.read()}
|
73 |
+
# payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
|
74 |
+
# response = requests.post(
|
75 |
+
# f"https://discord.com/api/v9/channels/{discord_channel}/messages",
|
76 |
+
# data=payload,
|
77 |
+
# headers={"Authorization": f"Bot {discord_token}"},
|
78 |
+
# files=files
|
79 |
+
# )
|
80 |
+
# response.raise_for_status()
|
81 |
+
# result_url = response.json()['attachments'][0]['url']
|
82 |
+
with open(result, 'rb') as file:
|
83 |
+
response = requests.post("https://upload.tost.ai/api/v1", files={'file': file})
|
84 |
response.raise_for_status()
|
85 |
+
result_url = response.text
|
86 |
notify_payload = {"jobId": job_id, "result": result_url, "status": "DONE"}
|
87 |
web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
|
88 |
web_notify_token = os.getenv('com_camenduru_web_notify_token')
|