HuyDN commited on
Commit
6dfcb9a
1 Parent(s): c381b14

Phase2/HuyDN: edit Dockerfile

Browse files
.gitignore CHANGED
@@ -5,3 +5,4 @@ credentials/
5
  data/CV
6
  data/JD
7
  data/QUESTION
 
 
5
  data/CV
6
  data/JD
7
  data/QUESTION
8
+ !.gitkeep
app/modules/crud_cvs/models/crud_cvs.py CHANGED
@@ -16,6 +16,12 @@ def remove_file_cvs(file_url):
16
  blob.delete()
17
  return True
18
 
 
 
 
 
 
 
19
  def get_all_cvs():
20
  # Get all documents from the collection
21
  docs = firebase_db.collection("cvs").stream()
 
16
  blob.delete()
17
  return True
18
 
19
+ def download_file_cvs(file_url):
20
+ # download file from firebase storage using "gs://" link
21
+ blob = firebase_bucket.blob(file_url.split(f"gs://{firebase_bucket.name}/")[1])
22
+ # download file and return string in file
23
+ return blob.download_as_text()
24
+
25
  def get_all_cvs():
26
  # Get all documents from the collection
27
  docs = firebase_db.collection("cvs").stream()
app/modules/crud_jds/models/crud_jds.py CHANGED
@@ -17,6 +17,12 @@ def remove_file_jds(file_url):
17
  blob.delete()
18
  return True
19
 
 
 
 
 
 
 
20
  def get_all_jds():
21
  # Get all documents from the collection
22
  docs = firebase_db.collection("jds").stream()
 
17
  blob.delete()
18
  return True
19
 
20
+ def download_file_jds(file_url):
21
+ # download file from firebase storage using "gs://" link
22
+ blob = firebase_bucket.blob(file_url.split(f"gs://{firebase_bucket.name}/")[1])
23
+ # download file and return string in file
24
+ return blob.download_as_text()
25
+
26
  def get_all_jds():
27
  # Get all documents from the collection
28
  docs = firebase_db.collection("jds").stream()
app/modules/matching_cv/__init__.py CHANGED
@@ -3,7 +3,7 @@ import docx
3
  from fastapi import APIRouter
4
  from app.modules.matching_cv.models.match_cv_jd_model import Match_JD_CV_Model
5
 
6
- from app.modules.matching_cv.models.matching_cv_logic import result_matching_cv_jd, load_jd_from_id
7
 
8
  cvmatching_router = APIRouter(prefix="/cvmatching", tags=["cvmatching"])
9
 
@@ -13,24 +13,23 @@ async def index():
13
 
14
  @cvmatching_router.post("/matching")
15
  # only upload .pdf or .docx file
16
- async def matching_cv_jd(
17
- jd_upload: Match_JD_CV_Model.jd = Match_JD_CV_Model.jd_default,
18
- cv_upload: Match_JD_CV_Model.cv = Match_JD_CV_Model.cv_default):
19
  try:
20
- # take jd_upload and cv_upload type file
21
- jd_upload_type = jd_upload.filename.split(".")[-1]
22
- cv_upload_type = cv_upload.filename.split(".")[-1]
23
- if jd_upload_type in ["txt"] and cv_upload_type in ["pdf", "docx"]:
24
- jd_text = jd_upload.file.read().decode("utf-8")
25
- if cv_upload_type == "docx":
26
- cv_text = docx.Document(cv_upload.file).paragraphs
27
- cv_text = "\n".join([i.text for i in cv_text])
28
- elif cv_upload_type == "pdf":
29
- return {"message": "This feature is not available yet"}
30
- # check matching cv and jd
31
- result = result_matching_cv_jd(cv_text, jd_text)
32
- return {"result": result}
33
- else:
34
- return {"message": "Please upload only .txt for JD. And .pdf or .docx file for CV"}
 
35
  except Exception as e:
36
  return {"Error": str(e)}
 
3
  from fastapi import APIRouter
4
  from app.modules.matching_cv.models.match_cv_jd_model import Match_JD_CV_Model
5
 
6
+ from app.modules.matching_cv.models.matching_cv_logic import result_matching_cv_jd
7
 
8
  cvmatching_router = APIRouter(prefix="/cvmatching", tags=["cvmatching"])
9
 
 
13
 
14
  @cvmatching_router.post("/matching")
15
  # only upload .pdf or .docx file
16
+ async def matching_cv_jd(id_jd: str, id_cv:str):
 
 
17
  try:
18
+ pass
19
+ # # take jd_upload and cv_upload type file
20
+ # jd_upload_type = jd_upload.filename.split(".")[-1]
21
+ # cv_upload_type = cv_upload.filename.split(".")[-1]
22
+ # if jd_upload_type in ["txt"] and cv_upload_type in ["pdf", "docx"]:
23
+ # jd_text = jd_upload.file.read().decode("utf-8")
24
+ # if cv_upload_type == "docx":
25
+ # cv_text = docx.Document(cv_upload.file).paragraphs
26
+ # cv_text = "\n".join([i.text for i in cv_text])
27
+ # elif cv_upload_type == "pdf":
28
+ # return {"message": "This feature is not available yet"}
29
+ # # check matching cv and jd
30
+ # result = result_matching_cv_jd(cv_text, jd_text)
31
+ # return {"result": result}
32
+ # else:
33
+ # return {"message": "Please upload only .txt for JD. And .pdf or .docx file for CV"}
34
  except Exception as e:
35
  return {"Error": str(e)}
app/modules/matching_cv/models/matching_cv_logic.py CHANGED
@@ -47,6 +47,3 @@ def result_matching_cv_jd(cv_text, jd_text):
47
  result = chain.invoke(chat_message)
48
 
49
  return result
50
-
51
- def load_jd_from_id():
52
- pass
 
47
  result = chain.invoke(chat_message)
48
 
49
  return result
 
 
 
app/modules/question_tests_retrieval/__init__.py CHANGED
@@ -2,8 +2,8 @@ from fastapi import APIRouter, UploadFile, File
2
  from typing import Annotated
3
 
4
  from app.modules.question_tests_retrieval.models.jd2text import jobdes2text
5
- # from app.modules.question_tests_retrieval.models.text2vector import text2vector
6
  from app.modules.question_tests_retrieval.models.question_tests_logic import get_question_tests
 
7
 
8
  qtretrieval_router = APIRouter(prefix="/qtretrieval", tags=["qtretrieval"])
9
 
@@ -11,18 +11,19 @@ qtretrieval_router = APIRouter(prefix="/qtretrieval", tags=["qtretrieval"])
11
  async def index():
12
  return {"message": "Welcome to question retrieval page"}
13
 
14
- @qtretrieval_router.post("/send_jd")
15
  # only upload .txt file
16
- async def send_jd(txt_file: Annotated[UploadFile, File(..., description="The JD file (only .txt file)", media_type=["text/plain"])]):
17
  try:
18
- # read the txt file with format
19
- jobdes = txt_file.file.read().decode("utf-8")
20
- sumaryjd_text = jobdes2text(jobdes)
 
21
  if get_question_tests(sumaryjd_text):
22
  return {"message": "Send JD successfully and get question test successfully",
23
  "sumaryjd_text": sumaryjd_text}
24
  else:
25
  return {"message": "Please upload only .txt file", "error": str(e)}
26
  except Exception as e:
27
- return {"message": "Please upload only .txt file", "error": str(e)}
28
 
 
2
  from typing import Annotated
3
 
4
  from app.modules.question_tests_retrieval.models.jd2text import jobdes2text
 
5
  from app.modules.question_tests_retrieval.models.question_tests_logic import get_question_tests
6
+ from app.modules.crud_jds.models.crud_jds import get_jd_by_id, download_file_jds
7
 
8
  qtretrieval_router = APIRouter(prefix="/qtretrieval", tags=["qtretrieval"])
9
 
 
11
  async def index():
12
  return {"message": "Welcome to question retrieval page"}
13
 
14
+ @qtretrieval_router.post("/send_jd_to_get_question")
15
  # only upload .txt file
16
+ async def send_jd_to_get_question(id_jd: str):
17
  try:
18
+ jd_document = get_jd_by_id(id_jd)
19
+ # download jd file from firebase storage
20
+ jd_file_string = download_file_jds(jd_document["jd_url"])
21
+ sumaryjd_text = jobdes2text(jd_file_string)
22
  if get_question_tests(sumaryjd_text):
23
  return {"message": "Send JD successfully and get question test successfully",
24
  "sumaryjd_text": sumaryjd_text}
25
  else:
26
  return {"message": "Please upload only .txt file", "error": str(e)}
27
  except Exception as e:
28
+ return {"message": "Have error when find JD in database", "error": str(e)}
29