Gaykar commited on
Commit
7ad07ce
·
1 Parent(s): 308b497

removed errors

Browse files
Files changed (2) hide show
  1. app/graph_trial.py +56 -0
  2. app/main.py +69 -52
app/graph_trial.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from app.graph import graph
3
+ import uuid
4
+
5
+
6
+ jd_text="""Job Title: Backend Developer
7
+
8
+ Company name: CodeForge
9
+ We are hiring a Backend Developer to build scalable APIs and backend systems.
10
+
11
+ Responsibilities:
12
+ - Develop REST APIs using FastAPI
13
+ - Design and manage PostgreSQL databases
14
+ - Implement authentication and authorization systems
15
+ - Optimize performance and scalability
16
+
17
+ Requirements:
18
+ - Strong knowledge of Python
19
+ - Experience with FastAPI or Django
20
+ - Good understanding of SQL and database design
21
+ - Familiarity with Docker
22
+
23
+ Constraints:
24
+ - Location: Pune only
25
+ - Full-time role """
26
+
27
+
28
+ initial_input = {
29
+ "candidate_name": "Chirayu Jain",
30
+ "resume_text": None,
31
+ "job_description": jd_text,
32
+ "file_path": r"C:\Users\ATHARVA\Downloads\my codes\web\AdaptiveEngineService\AI_Engine_Evaluation\Testcases\Testresume\ChirayuResume.pdf",
33
+ "resume_data": None,
34
+ "extraction_error": None,
35
+ "JobDescriptionExtract_data": None,
36
+ "skill_gap_analysis_data": None
37
+
38
+
39
+ }
40
+
41
+
42
+ THREAD_ID = str(uuid.uuid4())
43
+
44
+ config = {"configurable": {"thread_id": THREAD_ID}}
45
+
46
+ # Change THREAD_ID to config
47
+ # final_result = graph.invoke(initial_input, config=config)
48
+
49
+
50
+ # print(final_result)
51
+
52
+
53
+
54
+
55
+
56
+
app/main.py CHANGED
@@ -1,56 +1,73 @@
1
  import os
 
 
 
2
  from app.graph import graph
3
- import uuid
4
-
5
-
6
- jd_text="""Job Title: Backend Developer
7
-
8
- Company name: CodeForge
9
- We are hiring a Backend Developer to build scalable APIs and backend systems.
10
-
11
- Responsibilities:
12
- - Develop REST APIs using FastAPI
13
- - Design and manage PostgreSQL databases
14
- - Implement authentication and authorization systems
15
- - Optimize performance and scalability
16
-
17
- Requirements:
18
- - Strong knowledge of Python
19
- - Experience with FastAPI or Django
20
- - Good understanding of SQL and database design
21
- - Familiarity with Docker
22
-
23
- Constraints:
24
- - Location: Pune only
25
- - Full-time role """
26
-
27
-
28
- initial_input = {
29
- "candidate_name": "Chirayu Jain",
30
- "resume_text": None,
31
- "job_description": jd_text,
32
- "file_path": r"C:\Users\ATHARVA\Downloads\my codes\web\AdaptiveEngineService\AI_Engine_Evaluation\Testcases\Testresume\ChirayuResume.pdf",
33
- "resume_data": None,
34
- "extraction_error": None,
35
- "JobDescriptionExtract_data": None,
36
- "skill_gap_analysis_data": None
37
-
38
-
39
- }
40
-
41
-
42
- THREAD_ID = str(uuid.uuid4())
43
-
44
- config = {"configurable": {"thread_id": THREAD_ID}}
45
-
46
- # Change THREAD_ID to config
47
- final_result = graph.invoke(initial_input, config=config)
48
-
49
-
50
- final_result
51
-
52
-
53
-
54
-
55
 
56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
+ from fastapi import FastAPI, Form, HTTPException
3
+ from fastapi.middleware.cors import CORSMiddleware
4
+ from app.utils.ui_payload_constructor import UIPayload
5
  from app.graph import graph
6
+ from app.utils.cloudinary_utils import get_resume_url
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
 
9
+ app = FastAPI(title="Adaptive Onboarding Engine")
10
+
11
+ app.add_middleware(
12
+ CORSMiddleware,
13
+ allow_origins=["*"],
14
+ allow_methods=["*"],
15
+ allow_headers=["*"],
16
+ )
17
+
18
+
19
+ @app.post("/analyze")
20
+ async def analyze(
21
+ user_id: str = Form(..., description="User ID — used to fetch resume from Cloudinary"),
22
+ job_description: str = Form(..., description="Job description text"),
23
+ ):
24
+ # 1. Fetch PDF URL from Cloudinary using user_id
25
+ try:
26
+ pdf_url = get_resume_url(user_id)
27
+ except FileNotFoundError as e:
28
+ raise HTTPException(status_code=404, detail=str(e))
29
+
30
+ # 2. Build graph state
31
+ initial_input = {
32
+ "candidate_name": None,
33
+ "resume_text": None,
34
+ "file_path": pdf_url,
35
+ "job_description": job_description,
36
+ "resume_data": None,
37
+ "extraction_error": None,
38
+ "JobDescriptionExtract_data": None,
39
+ "skill_gap_analysis_data": None,
40
+ "messages": [],
41
+ "mermaid_code": None,
42
+ "final_roadmap": None,
43
+ }
44
+
45
+ # 3. Run graph — use user_id as thread_id for checkpointer
46
+ config = {"configurable": {"thread_id": user_id}}
47
+
48
+ try:
49
+ final_state = graph.invoke(initial_input, config=config)
50
+
51
+ if final_state.get("extraction_error"):
52
+ raise HTTPException(
53
+ status_code=422,
54
+ detail=f"Extraction failed: {final_state['extraction_error']}"
55
+ )
56
+
57
+ payload = UIPayload.from_state(final_state)
58
+ return payload.to_dict()
59
+
60
+ except HTTPException:
61
+ raise
62
+ except Exception as e:
63
+ raise HTTPException(status_code=500, detail=str(e))
64
+
65
+
66
+ @app.get("/health")
67
+ def health():
68
+ return {"status": "ok", "service": "Adaptive Onboarding Engine"}
69
+
70
+
71
+ if __name__ == "__main__":
72
+ import uvicorn
73
+ uvicorn.run(app, host="127.0.0.1", port=8000)