DeepLearning101 commited on
Commit
f3c77fe
1 Parent(s): 0233ec6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
app.py CHANGED
@@ -58,10 +58,14 @@ async def upload_file(LLM_URL, LLM_API, file_path, user_id):
58
  mime_type, _ = mimetypes.guess_type(file_path)
59
  with open(file_path, 'rb') as f:
60
  async with aiohttp.ClientSession() as session:
 
 
 
 
61
  async with session.post(
62
  f"{LLM_URL}/files/upload",
63
  headers={"Authorization": f"Bearer {LLM_API}"},
64
- data={"file": (file_path, f, mime_type), "user": user_id}
65
  ) as response:
66
  print("Upload response status code:", response.status) # Debug information
67
  if response.status == 404:
@@ -117,4 +121,4 @@ with gr.Blocks() as iface:
117
  allow_flagging="never"
118
  )
119
 
120
- iface.launch()
 
58
  mime_type, _ = mimetypes.guess_type(file_path)
59
  with open(file_path, 'rb') as f:
60
  async with aiohttp.ClientSession() as session:
61
+ form_data = aiohttp.FormData()
62
+ form_data.add_field('file', f, filename=file_path, content_type=mime_type)
63
+ form_data.add_field('user', user_id)
64
+
65
  async with session.post(
66
  f"{LLM_URL}/files/upload",
67
  headers={"Authorization": f"Bearer {LLM_API}"},
68
+ data=form_data
69
  ) as response:
70
  print("Upload response status code:", response.status) # Debug information
71
  if response.status == 404:
 
121
  allow_flagging="never"
122
  )
123
 
124
+ iface.launch()