camenduru commited on
Commit
4754693
·
verified ·
1 Parent(s): f7e7ff6

Update worker_runpod.py

Browse files
Files changed (1) hide show
  1. worker_runpod.py +15 -11
worker_runpod.py CHANGED
@@ -97,18 +97,22 @@ def generate(input):
97
  discord_token = os.getenv('com_camenduru_discord_token')
98
  job_id = values['job_id']
99
  del values['job_id']
100
- default_filename = os.path.basename(result)
101
- with open(result, "rb") as file:
102
- files = {default_filename: file.read()}
103
- payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
104
- response = requests.post(
105
- f"https://discord.com/api/v9/channels/{discord_channel}/messages",
106
- data=payload,
107
- headers={"Authorization": f"Bot {discord_token}"},
108
- files=files
109
- )
 
 
 
 
110
  response.raise_for_status()
111
- result_url = response.json()['attachments'][0]['url']
112
  notify_payload = {"jobId": job_id, "result": result_url, "status": "DONE"}
113
  web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
114
  web_notify_token = os.getenv('com_camenduru_web_notify_token')
 
97
  discord_token = os.getenv('com_camenduru_discord_token')
98
  job_id = values['job_id']
99
  del values['job_id']
100
+ # default_filename = os.path.basename(result)
101
+ # with open(result, "rb") as file:
102
+ # files = {default_filename: file.read()}
103
+ # payload = {"content": f"{json.dumps(values)} <@{discord_id}>"}
104
+ # response = requests.post(
105
+ # f"https://discord.com/api/v9/channels/{discord_channel}/messages",
106
+ # data=payload,
107
+ # headers={"Authorization": f"Bot {discord_token}"},
108
+ # files=files
109
+ # )
110
+ # response.raise_for_status()
111
+ # result_url = response.json()['attachments'][0]['url']
112
+ with open(result, 'rb') as file:
113
+ response = requests.post("https://upload.tost.ai/api/v1", files={'file': file})
114
  response.raise_for_status()
115
+ result_url = response.text
116
  notify_payload = {"jobId": job_id, "result": result_url, "status": "DONE"}
117
  web_notify_uri = os.getenv('com_camenduru_web_notify_uri')
118
  web_notify_token = os.getenv('com_camenduru_web_notify_token')