Update worker_runpod.py
Browse files- worker_runpod.py +26 -16
worker_runpod.py
CHANGED
@@ -156,22 +156,32 @@ def generate(input):
|
|
156 |
discord_token = os.getenv('com_camenduru_discord_token')
|
157 |
job_id = values['job_id']
|
158 |
del values['job_id']
|
159 |
-
default_filename = os.path.basename(result[0])
|
160 |
-
with open(result[0], "rb") as file:
|
161 |
-
|
162 |
-
for path in result[1]:
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
|
167 |
-
response = requests.post(
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
)
|
173 |
-
response.raise_for_status()
|
174 |
-
result_urls = [attachment['url'] for attachment in response.json()['attachments']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
notify_payload = {"jobId": job_id, "result": str(result_urls), "status": "DONE"}
|
176 |
web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
|
177 |
web_notify_token = os.getenv('com_camenduru_web_notify_token')
|
|
|
156 |
discord_token = os.getenv('com_camenduru_discord_token')
|
157 |
job_id = values['job_id']
|
158 |
del values['job_id']
|
159 |
+
# default_filename = os.path.basename(result[0])
|
160 |
+
# with open(result[0], "rb") as file:
|
161 |
+
# files = {default_filename: file.read()}
|
162 |
+
# for path in result[1]:
|
163 |
+
# filename = os.path.basename(path)
|
164 |
+
# with open(path, "rb") as file:
|
165 |
+
# files[filename] = file.read()
|
166 |
+
# payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
|
167 |
+
# response = requests.post(
|
168 |
+
# f"https://discord.com/api/v9/channels/{discord_channel}/messages",
|
169 |
+
# data=payload,
|
170 |
+
# headers={"Authorization": f"Bot {discord_token}"},
|
171 |
+
# files=files
|
172 |
+
# )
|
173 |
+
# response.raise_for_status()
|
174 |
+
# result_urls = [attachment['url'] for attachment in response.json()['attachments']]
|
175 |
+
with open(result[0], 'rb') as file0:
|
176 |
+
response0 = requests.post("https://upload.tost.ai/api/v1", files={'file': file0})
|
177 |
+
response0.raise_for_status()
|
178 |
+
with open(result[1], 'rb') as file1:
|
179 |
+
response1 = requests.post("https://upload.tost.ai/api/v1", files={'file': file1})
|
180 |
+
response1.raise_for_status()
|
181 |
+
with open(result[2], 'rb') as file2:
|
182 |
+
response2 = requests.post("https://upload.tost.ai/api/v1", files={'file': file2})
|
183 |
+
response2.raise_for_status()
|
184 |
+
result_urls = [response0.text, response1.text, response2.text]
|
185 |
notify_payload = {"jobId": job_id, "result": str(result_urls), "status": "DONE"}
|
186 |
web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
|
187 |
web_notify_token = os.getenv('com_camenduru_web_notify_token')
|