kltn20133118 commited on
Commit
5f0f3a6
·
verified ·
1 Parent(s): f9ffb52

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +75 -68
main.py CHANGED
@@ -1,20 +1,20 @@
1
  from fastapi import FastAPI, HTTPException, Depends, Request
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from fastapi.middleware.trustedhost import TrustedHostMiddleware
4
- from controller import LoginController, FileController, MySQLController, DefaultController, OTPController
5
  import firebase_admin
6
  from controller import ChatController
7
  from firebase_admin import credentials
8
  from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
9
- from service import MySQLService, LoginService, ChatService
10
- from request import RequestMySQL, RequestLogin, RequestDefault
11
  from auth.authentication import decodeJWT
12
  from repository import UserRepository
13
  from auth import authentication
14
  from datetime import datetime, timedelta
15
  from fastapi import Depends, HTTPException, Form, File, UploadFile
16
  from typing import List
17
- from service import FileService, DefaultService, LoginService
18
  from request import RequestFile, RequestChat, RequestDefault
19
  from fastapi import FastAPI, Request, HTTPException
20
  from fastapi.responses import JSONResponse
@@ -41,7 +41,7 @@ app = FastAPI(
41
  }
42
  )
43
  origins = [
44
- "https://kltn20133118-pychatbot.hf.space",
45
  ]
46
 
47
  app.add_middleware(
@@ -71,17 +71,17 @@ class JWTBearer(HTTPBearer):
71
  credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)
72
  if credentials:
73
  if credentials.scheme != "Bearer":
74
- raise HTTPException(status_code=403, detail="Invalid authentication scheme.")
75
  if not self.verify_accesstoken(credentials.credentials):
76
- raise HTTPException(status_code=403, detail="Token does not exist")
77
  if not self.verify_jwt(credentials.credentials):
78
- raise HTTPException(status_code=403, detail="Invalid token or expired token.")
79
  return credentials.credentials
80
  else:
81
  raise HTTPException(status_code=401, detail="Invalid authorization code.")
82
 
83
  def verify_accesstoken(self, jwtoken: str) -> bool:
84
- check = LoginService.check_token_is_valid(jwtoken)
85
  return check
86
 
87
  def verify_jwt(self, jwtoken: str) -> bool:
@@ -94,7 +94,6 @@ class JWTBearer(HTTPBearer):
94
  print(e)
95
  return False
96
 
97
-
98
  def get_current_user_email(credentials: str = Depends(JWTBearer())):
99
  try:
100
  payload = decodeJWT(credentials)
@@ -103,11 +102,11 @@ def get_current_user_email(credentials: str = Depends(JWTBearer())):
103
  return email
104
  except Exception as e:
105
  print(e)
106
- raise HTTPException(status_code=403, detail="Invalid token or expired token.")
107
 
108
 
109
- @app.get("/api/v1/mysql/render_chat_history", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
110
- async def override_render_chat(user_id: Optional[str] = Query(None),
111
  current_user_email: str = Depends(get_current_user_email)):
112
  check = support_function.check_value_user_id(user_id, current_user_email)
113
  if check is not True:
@@ -115,8 +114,7 @@ async def override_render_chat(user_id: Optional[str] = Query(None),
115
  request = RequestMySQL.RequestRenderChatHistory(user_id=user_id)
116
  return MySQLService.render_chat_history(request)
117
 
118
-
119
- @app.put("/api/v1/mysql/edit_chat/", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
120
  async def override_edit_chat(request: RequestMySQL.RequestEditNameChat,
121
  current_user_email: str = Depends(get_current_user_email)):
122
  user_id = request.user_id
@@ -131,8 +129,7 @@ async def override_edit_chat(request: RequestMySQL.RequestEditNameChat,
131
  raise HTTPException(status_code=400, detail="name_old field is required.")
132
  return MySQLService.edit_chat(request)
133
 
134
-
135
- @app.delete("/api/v1/mysql/delete_chat/", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
136
  async def override_delete_chat(request: RequestMySQL.RequestDeleteChat,
137
  current_user_email: str = Depends(get_current_user_email)):
138
  user_id = request.user_id
@@ -144,9 +141,20 @@ async def override_delete_chat(request: RequestMySQL.RequestDeleteChat,
144
  raise HTTPException(status_code=400, detail="chat_name field is required.")
145
  return MySQLService.delete_chat(request)
146
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
- @app.get("/api/v1/mysql/load_chat_history", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
149
- async def override_load_chat(chat_id: Optional[str] = Query(None), user_id: Optional[str] = Query(None),
150
  current_user_email: str = Depends(get_current_user_email)):
151
  check = support_function.check_value_user_id(user_id, current_user_email)
152
  if check is not True:
@@ -167,8 +175,8 @@ async def override_load_chat(chat_id: Optional[str] = Query(None), user_id: Opti
167
  return MySQLService.load_chat_history(request)
168
 
169
 
170
- @app.get("/api/v1/default/info_user", dependencies=[Depends(JWTBearer())], tags=["Default"])
171
- async def override_get_user(user_id: str = Query(None), current_user_email: str = Depends(get_current_user_email)):
172
  check = support_function.check_value_user_id(user_id, current_user_email)
173
  if check is not True:
174
  return check
@@ -177,7 +185,7 @@ async def override_get_user(user_id: str = Query(None), current_user_email: str
177
 
178
 
179
  @app.post("/api/v1/users/update_user_info", dependencies=[Depends(JWTBearer())], tags=["User"])
180
- async def override_update_user_info(request: RequestLogin.RequestUpdateUserInfo,
181
  current_user_email: str = Depends(get_current_user_email)):
182
  user_id = request.user_id
183
  check = support_function.check_value_user_id(user_id, current_user_email)
@@ -198,11 +206,11 @@ async def override_update_user_info(request: RequestLogin.RequestUpdateUserInfo,
198
  if photo_url is None or photo_url.strip() == "":
199
  return res.ReponseError(status=400,
200
  data=res.Message(message="photo_url field is required."))
201
- return LoginService.update_user_info(request)
202
 
203
 
204
  @app.put('/api/v1/users/change_password', dependencies=[Depends(JWTBearer())], tags=["User"])
205
- async def override_reset_password_firebase(request: RequestLogin.RequestChangePassword,
206
  current_user_email: str = Depends(get_current_user_email)):
207
  user_id = request.user_id
208
  check = support_function.check_value_user_id(user_id, current_user_email)
@@ -222,10 +230,9 @@ async def override_reset_password_firebase(request: RequestLogin.RequestChangePa
222
  return res.ReponseError(status=400,
223
  data=res.Message(message="confirm_new_password field is required."))
224
 
225
- return LoginService.change_password(request)
226
-
227
 
228
- @app.delete("/api/v1/file/delete_all_file/", dependencies=[Depends(JWTBearer())], tags=["File"])
229
  async def override_delete_folder(request: RequestFile.RequestDeleteAllFile,
230
  current_user_email: str = Depends(get_current_user_email)):
231
  check = support_function.check_value_user_id(request.user_id, current_user_email)
@@ -233,8 +240,7 @@ async def override_delete_folder(request: RequestFile.RequestDeleteAllFile,
233
  return check
234
  return FileService.deleteAllFile(request)
235
 
236
-
237
- @app.delete("/api/v1/file/delete_one_file/", dependencies=[Depends(JWTBearer())], tags=["File"])
238
  async def override_delete_one_file(request: RequestFile.RequestDeleteFile,
239
  current_user_email: str = Depends(get_current_user_email)):
240
  user_id = request.user_id
@@ -248,7 +254,7 @@ async def override_delete_one_file(request: RequestFile.RequestDeleteFile,
248
  return FileService.deleteFile(request)
249
 
250
 
251
- @app.post("/api/v1/file/chatbot/download_folder/", dependencies=[Depends(JWTBearer())], tags=["File"])
252
  async def override_download_folder_from_dropbox(request: RequestFile.RequestDownLoadFolder,
253
  current_user_email: str = Depends(get_current_user_email)):
254
  user_id = request.user_id
@@ -258,7 +264,7 @@ async def override_download_folder_from_dropbox(request: RequestFile.RequestDown
258
  return FileService.download_folder(request)
259
 
260
 
261
- @app.post("/api/v1/file/chatbot/download_files/", dependencies=[Depends(JWTBearer())], tags=["File"])
262
  async def override_download_file_by_id(request: RequestFile.RequestDownLoadFile,
263
  current_user_email: str = Depends(get_current_user_email)):
264
  user_id = request.user_id
@@ -268,7 +274,7 @@ async def override_download_file_by_id(request: RequestFile.RequestDownLoadFile,
268
  return FileService.download_file(request)
269
 
270
 
271
- @app.post("/api/v1/file/upload_files/", dependencies=[Depends(JWTBearer())], tags=["File"])
272
  async def override_upload_files_dropbox(
273
  user_id: str = Form(None),
274
  files: List[UploadFile] = File(None),
@@ -281,7 +287,7 @@ async def override_upload_files_dropbox(
281
  return FileService.upload_files(request)
282
 
283
 
284
- @app.post("/api/v1/chat/chatbot/query/", dependencies=[Depends(JWTBearer())], tags=["Chatbot"])
285
  async def override_handle_query2_upgrade_old(request: Request, user_id: str = Form(None), text_all: str = Form(...),
286
  question: str = Form(None), chat_name: str = Form(None),
287
  current_user_email: str = Depends(get_current_user_email)):
@@ -293,7 +299,7 @@ async def override_handle_query2_upgrade_old(request: Request, user_id: str = Fo
293
  return ChatService.query2_upgrade_old(request)
294
 
295
 
296
- @app.get("/api/v1/chat/chatbot/extract_file/", dependencies=[Depends(JWTBearer())], tags=["Chatbot"])
297
  async def override_extract_file(user_id: str, current_user_email: str = Depends(get_current_user_email)):
298
  check = support_function.check_value_user_id(user_id, current_user_email)
299
  if check is not True:
@@ -302,7 +308,7 @@ async def override_extract_file(user_id: str, current_user_email: str = Depends(
302
  return ChatService.extract_file(request)
303
 
304
 
305
- @app.get("/api/v1/chat/chatbot/generate_question/", dependencies=[Depends(JWTBearer())], tags=["Chatbot"])
306
  async def override_generate_question(user_id: str, current_user_email: str = Depends(get_current_user_email)):
307
  check = support_function.check_value_user_id(user_id, current_user_email)
308
  if check is not True:
@@ -311,7 +317,7 @@ async def override_generate_question(user_id: str, current_user_email: str = Dep
311
  return ChatService.generate_question(request)
312
 
313
 
314
- @app.post("/api/v1/default/upload_image/", dependencies=[Depends(JWTBearer())], tags=["Default"])
315
  async def override_upload_image(user_id: str = Form(None), file: UploadFile = File(...),
316
  current_user_email: str = Depends(get_current_user_email)):
317
  check = support_function.check_value_user_id(user_id, current_user_email)
@@ -320,32 +326,31 @@ async def override_upload_image(user_id: str = Form(None), file: UploadFile = Fi
320
  request = RequestDefault.RequestUpLoadImage(user_id=user_id, files=file)
321
  return DefaultService.upload_image_service(request)
322
 
323
-
324
  app.include_router(MySQLController.router, prefix="/api/v1/mysql")
325
- app.include_router(LoginController.router, prefix="/api/v1/users")
326
  app.include_router(FileController.router, prefix="/api/v1/file")
327
  app.include_router(ChatController.router, prefix="/api/v1/chat")
328
  app.include_router(DefaultController.router, prefix="/api/v1/default")
329
 
330
  routes_to_override = {
331
- "/api/v1/mysql/render_chat_history": {"GET"},
332
- "/api/v1/mysql/load_chat_history": {"GET"},
333
- "/api/v1/mysql/edit_chat/": {"PUT"},
334
- "/api/v1/mysql/delete_chat/": {"DELETE"},
335
  "/api/v1/users/update_user_info": {"POST"},
336
  "/api/v1/users/change_password": {"PUT"},
337
- "/api/v1/file/delete_all_file/": {"DELETE"},
338
- "/api/v1/file/delete_one_file/": {"DELETE"},
339
- "/api/v1/file/chatbot/download_folder/": {"POST"},
340
- "/api/v1/file/chatbot/download_files/": {"POST"},
341
- "/api/v1/file/upload_files/": {"POST"},
342
- "/api/v1/chat/query2_upgrade/": {"POST"},
343
- "/api/v1/chat/chatbot/query/": {"POST"},
344
- "/api/v1/chat/chatbot/extract_file/": {"GET"},
345
- "/api/v1/chat/chatbot/generate_question/": {"GET"},
346
- "/api/v1/default/upload_image/": {"POST"},
347
- "/api/v1/default/info_user": {"GET"}
348
-
349
  }
350
 
351
  app.router.routes = [
@@ -356,36 +361,38 @@ app.router.routes = [
356
  )
357
  ]
358
 
359
- app.add_api_route("/api/v1/mysql/render_chat_history", override_render_chat, methods=["GET"],
360
  dependencies=[Depends(JWTBearer())], tags=["MySQL"])
361
- app.add_api_route("/api/v1/mysql/load_chat_history", override_load_chat, methods=["GET"],
362
  dependencies=[Depends(JWTBearer())], tags=["MySQL"])
363
- app.add_api_route("/api/v1/mysql/edit_chat/", override_edit_chat, methods=["PUT"], dependencies=[Depends(JWTBearer())],
364
  tags=["MySQL"])
365
- app.add_api_route("/api/v1/mysql/delete_chat/", override_delete_chat, methods=["DELETE"],
 
 
366
  dependencies=[Depends(JWTBearer())], tags=["MySQL"])
367
  app.add_api_route("/api/v1/users/update_user_info", override_update_user_info, methods=["POST"],
368
  dependencies=[Depends(JWTBearer())], tags=["User"])
369
  app.add_api_route("/api/v1/users/change_password", override_reset_password_firebase, methods=["PUT"],
370
  dependencies=[Depends(JWTBearer())], tags=["User"])
371
- app.add_api_route("/api/v1/file/delete_all_file/", override_delete_folder, methods=["DELETE"],
372
  dependencies=[Depends(JWTBearer())], tags=["File"])
373
- app.add_api_route("/api/v1/file/delete_one_file/", override_delete_one_file, methods=["DELETE"],
374
  dependencies=[Depends(JWTBearer())], tags=["File"])
375
- app.add_api_route("/api/v1/file/chatbot/download_folder/", override_download_folder_from_dropbox, methods=["POST"],
376
  dependencies=[Depends(JWTBearer())], tags=["File"])
377
- app.add_api_route("/api/v1/file/chatbot/download_files/", override_download_file_by_id, methods=["POST"],
378
  dependencies=[Depends(JWTBearer())], tags=["File"])
379
- app.add_api_route("/api/v1/file/upload_files/", override_upload_files_dropbox, methods=["POST"],
380
  dependencies=[Depends(JWTBearer())], tags=["File"])
381
- app.add_api_route("/api/v1/chat/chatbot/query/", override_handle_query2_upgrade_old, methods=["POST"],
382
  dependencies=[Depends(JWTBearer())], tags=["Chat"])
383
- app.add_api_route("/api/v1/chat/chatbot/extract_file/", override_extract_file, methods=["GET"],
384
  dependencies=[Depends(JWTBearer())], tags=["Chat"])
385
- app.add_api_route("/api/v1/chat/chatbot/generate_question/", override_generate_question, methods=["GET"],
386
  dependencies=[Depends(JWTBearer())], tags=["Chat"])
387
- app.add_api_route("/api/v1/default/upload_image/", override_upload_image, methods=["POST"],
388
  dependencies=[Depends(JWTBearer())], tags=["Default"])
389
- app.add_api_route("/api/v1/default/info_user", override_get_user, methods=["GET"], dependencies=[Depends(JWTBearer())],
390
  tags=["Default"])
391
  app.include_router(OTPController.router, tags=["OTP"], prefix="/api/v1/otp")
 
1
  from fastapi import FastAPI, HTTPException, Depends, Request
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from fastapi.middleware.trustedhost import TrustedHostMiddleware
4
+ from controller import UserController, FileController, MySQLController, DefaultController, OTPController,AuthenticationController
5
  import firebase_admin
6
  from controller import ChatController
7
  from firebase_admin import credentials
8
  from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
9
+ from service import MySQLService, UserService, ChatService
10
+ from request import RequestMySQL, RequestUser, RequestDefault
11
  from auth.authentication import decodeJWT
12
  from repository import UserRepository
13
  from auth import authentication
14
  from datetime import datetime, timedelta
15
  from fastapi import Depends, HTTPException, Form, File, UploadFile
16
  from typing import List
17
+ from service import FileService, DefaultService, UserService,AuthService
18
  from request import RequestFile, RequestChat, RequestDefault
19
  from fastapi import FastAPI, Request, HTTPException
20
  from fastapi.responses import JSONResponse
 
41
  }
42
  )
43
  origins = [
44
+ "http://localhost:8000",
45
  ]
46
 
47
  app.add_middleware(
 
71
  credentials: HTTPAuthorizationCredentials = await super(JWTBearer, self).__call__(request)
72
  if credentials:
73
  if credentials.scheme != "Bearer":
74
+ raise HTTPException(status_code=401, detail="Invalid authentication scheme.")
75
  if not self.verify_accesstoken(credentials.credentials):
76
+ raise HTTPException(status_code=401, detail="Token does not exist")
77
  if not self.verify_jwt(credentials.credentials):
78
+ raise HTTPException(status_code=401, detail="Invalid token or expired token.")
79
  return credentials.credentials
80
  else:
81
  raise HTTPException(status_code=401, detail="Invalid authorization code.")
82
 
83
  def verify_accesstoken(self, jwtoken: str) -> bool:
84
+ check = AuthService.check_token_is_valid(jwtoken)
85
  return check
86
 
87
  def verify_jwt(self, jwtoken: str) -> bool:
 
94
  print(e)
95
  return False
96
 
 
97
  def get_current_user_email(credentials: str = Depends(JWTBearer())):
98
  try:
99
  payload = decodeJWT(credentials)
 
102
  return email
103
  except Exception as e:
104
  print(e)
105
+ raise HTTPException(status_code=401, detail="Invalid token or expired token.")
106
 
107
 
108
+ @app.get("/api/v1/mysql/chat_history/{user_id}", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
109
+ async def override_render_chat(user_id: str,
110
  current_user_email: str = Depends(get_current_user_email)):
111
  check = support_function.check_value_user_id(user_id, current_user_email)
112
  if check is not True:
 
114
  request = RequestMySQL.RequestRenderChatHistory(user_id=user_id)
115
  return MySQLService.render_chat_history(request)
116
 
117
+ @app.put("/api/v1/mysql/edit_chat", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
 
118
  async def override_edit_chat(request: RequestMySQL.RequestEditNameChat,
119
  current_user_email: str = Depends(get_current_user_email)):
120
  user_id = request.user_id
 
129
  raise HTTPException(status_code=400, detail="name_old field is required.")
130
  return MySQLService.edit_chat(request)
131
 
132
+ @app.delete("/api/v1/mysql/chat_history/delete", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
 
133
  async def override_delete_chat(request: RequestMySQL.RequestDeleteChat,
134
  current_user_email: str = Depends(get_current_user_email)):
135
  user_id = request.user_id
 
141
  raise HTTPException(status_code=400, detail="chat_name field is required.")
142
  return MySQLService.delete_chat(request)
143
 
144
+ @app.delete("/api/v1/mysql/detail_chat/delete", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
145
+ async def override_delete_detail_chat_detail(request: RequestMySQL.RequestDeleteDetailChat,
146
+ current_user_email: str = Depends(get_current_user_email)):
147
+ user_id = request.user_id
148
+ check = support_function.check_value_user_id(user_id, current_user_email)
149
+ if check is not True:
150
+ return check
151
+ id_chat_detail = request.id_chat_detail
152
+ if id_chat_detail is None or id_chat_detail.strip() == "":
153
+ raise HTTPException(status_code=400, detail="id_chat_detail field is required.")
154
+ return MySQLService.delete_chat_detail_by_id(request)
155
 
156
+ @app.get("/api/v1/mysql/detail_chat/{user_id}/{chat_id}", dependencies=[Depends(JWTBearer())], tags=["MySQL"])
157
+ async def override_load_chat(chat_id: str, user_id: str,
158
  current_user_email: str = Depends(get_current_user_email)):
159
  check = support_function.check_value_user_id(user_id, current_user_email)
160
  if check is not True:
 
175
  return MySQLService.load_chat_history(request)
176
 
177
 
178
+ @app.get("/api/v1/default/info_user/{user_id}", dependencies=[Depends(JWTBearer())], tags=["Default"])
179
+ async def override_get_user(user_id: str , current_user_email: str = Depends(get_current_user_email)):
180
  check = support_function.check_value_user_id(user_id, current_user_email)
181
  if check is not True:
182
  return check
 
185
 
186
 
187
  @app.post("/api/v1/users/update_user_info", dependencies=[Depends(JWTBearer())], tags=["User"])
188
+ async def override_update_user_info(request: RequestUser.RequestUpdateUserInfo,
189
  current_user_email: str = Depends(get_current_user_email)):
190
  user_id = request.user_id
191
  check = support_function.check_value_user_id(user_id, current_user_email)
 
206
  if photo_url is None or photo_url.strip() == "":
207
  return res.ReponseError(status=400,
208
  data=res.Message(message="photo_url field is required."))
209
+ return UserService.update_user_info(request)
210
 
211
 
212
  @app.put('/api/v1/users/change_password', dependencies=[Depends(JWTBearer())], tags=["User"])
213
+ async def override_reset_password_firebase(request: RequestUser.RequestChangePassword,
214
  current_user_email: str = Depends(get_current_user_email)):
215
  user_id = request.user_id
216
  check = support_function.check_value_user_id(user_id, current_user_email)
 
230
  return res.ReponseError(status=400,
231
  data=res.Message(message="confirm_new_password field is required."))
232
 
233
+ return UserService.change_password(request)
 
234
 
235
+ @app.delete("/api/v1/file/delete", dependencies=[Depends(JWTBearer())], tags=["File"])
236
  async def override_delete_folder(request: RequestFile.RequestDeleteAllFile,
237
  current_user_email: str = Depends(get_current_user_email)):
238
  check = support_function.check_value_user_id(request.user_id, current_user_email)
 
240
  return check
241
  return FileService.deleteAllFile(request)
242
 
243
+ @app.delete("/api/v1/file/delete_file", dependencies=[Depends(JWTBearer())], tags=["File"])
 
244
  async def override_delete_one_file(request: RequestFile.RequestDeleteFile,
245
  current_user_email: str = Depends(get_current_user_email)):
246
  user_id = request.user_id
 
254
  return FileService.deleteFile(request)
255
 
256
 
257
+ @app.post("/api/v1/file/chatbot/download_folder", dependencies=[Depends(JWTBearer())], tags=["File"])
258
  async def override_download_folder_from_dropbox(request: RequestFile.RequestDownLoadFolder,
259
  current_user_email: str = Depends(get_current_user_email)):
260
  user_id = request.user_id
 
264
  return FileService.download_folder(request)
265
 
266
 
267
+ @app.post("/api/v1/file/chatbot/download_files", dependencies=[Depends(JWTBearer())], tags=["File"])
268
  async def override_download_file_by_id(request: RequestFile.RequestDownLoadFile,
269
  current_user_email: str = Depends(get_current_user_email)):
270
  user_id = request.user_id
 
274
  return FileService.download_file(request)
275
 
276
 
277
+ @app.post("/api/v1/file/upload_files", dependencies=[Depends(JWTBearer())], tags=["File"])
278
  async def override_upload_files_dropbox(
279
  user_id: str = Form(None),
280
  files: List[UploadFile] = File(None),
 
287
  return FileService.upload_files(request)
288
 
289
 
290
+ @app.post("/api/v1/chat/chatbot/query", dependencies=[Depends(JWTBearer())], tags=["Chatbot"])
291
  async def override_handle_query2_upgrade_old(request: Request, user_id: str = Form(None), text_all: str = Form(...),
292
  question: str = Form(None), chat_name: str = Form(None),
293
  current_user_email: str = Depends(get_current_user_email)):
 
299
  return ChatService.query2_upgrade_old(request)
300
 
301
 
302
+ @app.get("/api/v1/chat/chatbot/extract_file/{user_id}", dependencies=[Depends(JWTBearer())], tags=["Chatbot"])
303
  async def override_extract_file(user_id: str, current_user_email: str = Depends(get_current_user_email)):
304
  check = support_function.check_value_user_id(user_id, current_user_email)
305
  if check is not True:
 
308
  return ChatService.extract_file(request)
309
 
310
 
311
+ @app.get("/api/v1/chat/chatbot/generate_question/{user_id}", dependencies=[Depends(JWTBearer())], tags=["Chatbot"])
312
  async def override_generate_question(user_id: str, current_user_email: str = Depends(get_current_user_email)):
313
  check = support_function.check_value_user_id(user_id, current_user_email)
314
  if check is not True:
 
317
  return ChatService.generate_question(request)
318
 
319
 
320
+ @app.post("/api/v1/default/upload_images", dependencies=[Depends(JWTBearer())], tags=["Default"])
321
  async def override_upload_image(user_id: str = Form(None), file: UploadFile = File(...),
322
  current_user_email: str = Depends(get_current_user_email)):
323
  check = support_function.check_value_user_id(user_id, current_user_email)
 
326
  request = RequestDefault.RequestUpLoadImage(user_id=user_id, files=file)
327
  return DefaultService.upload_image_service(request)
328
 
329
+ app.include_router(AuthenticationController.router, tags=["Authentication"], prefix="/api/v1/auth")
330
  app.include_router(MySQLController.router, prefix="/api/v1/mysql")
331
+ app.include_router(UserController.router, prefix="/api/v1/users")
332
  app.include_router(FileController.router, prefix="/api/v1/file")
333
  app.include_router(ChatController.router, prefix="/api/v1/chat")
334
  app.include_router(DefaultController.router, prefix="/api/v1/default")
335
 
336
  routes_to_override = {
337
+ "/api/v1/mysql/chat_history/{user_id}": {"GET"},
338
+ "/api/v1/mysql/detail_chat/{user_id}/{chat_id}": {"GET"},
339
+ "/api/v1/mysql/edit_chat": {"PUT"},
340
+ "/api/v1/mysql/chat_history/delete": {"DELETE"},
341
  "/api/v1/users/update_user_info": {"POST"},
342
  "/api/v1/users/change_password": {"PUT"},
343
+ "/api/v1/file/delete": {"DELETE"},
344
+ "/api/v1/file/delete_file": {"DELETE"},
345
+ "/api/v1/file/chatbot/download_folder": {"POST"},
346
+ "/api/v1/file/chatbot/download_files": {"POST"},
347
+ "/api/v1/file/upload_files": {"POST"},
348
+ "/api/v1/chat/chatbot/query": {"POST"},
349
+ "/api/v1/chat/chatbot/extract_file/{user_id}": {"GET"},
350
+ "/api/v1/chat/chatbot/generate_question/{user_id}": {"GET"},
351
+ "/api/v1/default/upload_images": {"POST"},
352
+ "/api/v1/default/info_user/{user_id}": {"GET"},
353
+ "/api/v1/mysql/detail_chat/delete":{"DELETE"}
 
354
  }
355
 
356
  app.router.routes = [
 
361
  )
362
  ]
363
 
364
+ app.add_api_route("/api/v1/mysql/chat_history/{user_id}", override_render_chat, methods=["GET"],
365
  dependencies=[Depends(JWTBearer())], tags=["MySQL"])
366
+ app.add_api_route("/api/v1/mysql/detail_chat/{user_id}/{chat_id}", override_load_chat, methods=["GET"],
367
  dependencies=[Depends(JWTBearer())], tags=["MySQL"])
368
+ app.add_api_route("/api/v1/mysql/edit_chat", override_edit_chat, methods=["PUT"], dependencies=[Depends(JWTBearer())],
369
  tags=["MySQL"])
370
+ app.add_api_route("/api/v1/mysql/chat_history/delete", override_delete_chat, methods=["DELETE"],
371
+ dependencies=[Depends(JWTBearer())], tags=["MySQL"])
372
+ app.add_api_route("/api/v1/mysql/detail_chat/delete", override_delete_detail_chat_detail, methods=["DELETE"],
373
  dependencies=[Depends(JWTBearer())], tags=["MySQL"])
374
  app.add_api_route("/api/v1/users/update_user_info", override_update_user_info, methods=["POST"],
375
  dependencies=[Depends(JWTBearer())], tags=["User"])
376
  app.add_api_route("/api/v1/users/change_password", override_reset_password_firebase, methods=["PUT"],
377
  dependencies=[Depends(JWTBearer())], tags=["User"])
378
+ app.add_api_route("/api/v1/file/delete", override_delete_folder, methods=["DELETE"],
379
  dependencies=[Depends(JWTBearer())], tags=["File"])
380
+ app.add_api_route("/api/v1/file/delete_file", override_delete_one_file, methods=["DELETE"],
381
  dependencies=[Depends(JWTBearer())], tags=["File"])
382
+ app.add_api_route("/api/v1/file/chatbot/download_folder", override_download_folder_from_dropbox, methods=["POST"],
383
  dependencies=[Depends(JWTBearer())], tags=["File"])
384
+ app.add_api_route("/api/v1/file/chatbot/download_files", override_download_file_by_id, methods=["POST"],
385
  dependencies=[Depends(JWTBearer())], tags=["File"])
386
+ app.add_api_route("/api/v1/file/upload_files", override_upload_files_dropbox, methods=["POST"],
387
  dependencies=[Depends(JWTBearer())], tags=["File"])
388
+ app.add_api_route("/api/v1/chat/chatbot/query", override_handle_query2_upgrade_old, methods=["POST"],
389
  dependencies=[Depends(JWTBearer())], tags=["Chat"])
390
+ app.add_api_route("/api/v1/chat/chatbot/extract_file/{user_id}", override_extract_file, methods=["GET"],
391
  dependencies=[Depends(JWTBearer())], tags=["Chat"])
392
+ app.add_api_route("/api/v1/chat/chatbot/generate_question/{user_id}", override_generate_question, methods=["GET"],
393
  dependencies=[Depends(JWTBearer())], tags=["Chat"])
394
+ app.add_api_route("/api/v1/default/upload_images", override_upload_image, methods=["POST"],
395
  dependencies=[Depends(JWTBearer())], tags=["Default"])
396
+ app.add_api_route("/api/v1/default/info_user/{user_id}", override_get_user, methods=["GET"], dependencies=[Depends(JWTBearer())],
397
  tags=["Default"])
398
  app.include_router(OTPController.router, tags=["OTP"], prefix="/api/v1/otp")