camenduru commited on
Commit
6621ccc
·
verified ·
1 Parent(s): 0d67c53

Update worker_runpod.py

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