-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.py
More file actions
55 lines (47 loc) · 1.75 KB
/
graph.py
File metadata and controls
55 lines (47 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from langgraph.graph import StateGraph, END
from models import GraphState
import services
def get_graph():
"""Builds and compiles the simplified, stateless LangGraph workflow."""
print("Building LangGraph workflow...")
workflow = StateGraph(GraphState)
# --- Define Nodes ---
workflow.add_node("extract_text", services.extract_text)
# Removed load_history node
workflow.add_node("find_relevant_resumes", services.find_relevant_resumes)
workflow.add_node("generate_feedback", services.generate_feedback)
# Removed generate_comparison node
# Removed save_history node
# --- Define Edges ---
workflow.set_entry_point("extract_text")
# Conditional edge after text extraction
workflow.add_conditional_edges(
"extract_text",
services.did_process_fail, # Check for errors
{
"yes": END, # Stop if extraction failed
"no": "find_relevant_resumes" # Continue if extraction succeeded
}
)
# Conditional edge after finding relevant resumes
workflow.add_conditional_edges(
"find_relevant_resumes",
services.did_process_fail, # Check if RAG failed
{
"yes": END, # Stop if RAG failed
"no": "generate_feedback" # Proceed directly to feedback if RAG succeeded
}
)
# Final edge after generating feedback (or if generation fails)
workflow.add_conditional_edges(
"generate_feedback",
services.did_process_fail,
{
"yes": END, # Stop if feedback generation failed
"no": END # End successfully after feedback generation
}
)
# --- Compile the graph ---
app_graph = workflow.compile()
print("LangGraph workflow compiled.")
return app_graph