farukkr commited on
Commit
3af7a47
·
verified ·
1 Parent(s): 80ed887

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -18,18 +18,25 @@ def upload_file(file):
18
  pdf_file_path = file.name
19
  with open(pdf_file_path, 'rb') as pdf_file:
20
  pdf_binary_data = pdf_file.read()
 
 
21
 
22
- params = {'filename': pdf_file_path}
23
  headers = {
24
  'Content-Type': 'application/pdf'
25
  }
26
- response = requests.post(API_URL, data=pdf_binary_data, headers=headers, params=params)
 
 
 
 
 
27
  if response.status_code == 200:
28
  print("File successfully uploaded")
29
  else:
30
  print(f"Failed to upload file. Status code: {response.status_code}, Response: {response.text}")
31
 
32
 
 
33
  chat = gr.ChatInterface(
34
  get_answer,
35
  chatbot=gr.Chatbot(height=700),
 
18
  pdf_file_path = file.name
19
  with open(pdf_file_path, 'rb') as pdf_file:
20
  pdf_binary_data = pdf_file.read()
21
+
22
+ API_ENDPOINT = "https://jj78yliqd7.execute-api.eu-central-1.amazonaws.com/dev/chatbot"
23
 
 
24
  headers = {
25
  'Content-Type': 'application/pdf'
26
  }
27
+
28
+ pdf_file_path = pdf_file_path.replace("\\", "/").split("/")[-1]
29
+
30
+ params = {'filename': pdf_file_path}
31
+
32
+ response = requests.post(API_ENDPOINT, data=pdf_binary_data, headers=headers, params=params)
33
  if response.status_code == 200:
34
  print("File successfully uploaded")
35
  else:
36
  print(f"Failed to upload file. Status code: {response.status_code}, Response: {response.text}")
37
 
38
 
39
+
40
  chat = gr.ChatInterface(
41
  get_answer,
42
  chatbot=gr.Chatbot(height=700),