Loading repository data…
Loading repository data…
codezelaca / repository
A student-friendly example of an agentic AI workflow built with Python and LangGraph
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
This project is a student-friendly example of an agentic AI workflow built with Python and LangGraph.
It is not a production hospital system and it should not be used for real medical decisions. The hospital theme is used only because it makes the agentic AI concepts easy to understand: task classification, tool usage, validation, retry logic, risk checks, confidence scoring, and human-in-the-loop review.
The main goal is to help students understand how an AI system can do more than simply answer a question. Instead of acting like a basic chatbot, this project shows how an AI agent can move through a controlled workflow and make decisions step by step.
By studying and running this project, students should understand:
The final version of the project follows this flow:
User Query
->
Classifier
->
Risk Checker
->
Tool Router
->
Tool Executor
->
Responder
->
Validator
->
Retry if validation fails
->
Confidence Checker
->
Final Response or Human Review
In the code, this workflow is built in:
app/graph.py
A normal chatbot usually does this:
User asks question -> LLM gives answer
This project does something closer to agentic AI:
User asks question
-> system classifies the request
-> system checks risk
-> system decides whether a tool is needed
-> system executes the tool
-> system generates an answer
-> system validates the answer
-> system retries if needed
-> system checks confidence
-> system sends to human review when needed
The important lesson is that the LLM is only one part of the system. The workflow around the LLM makes the application more controlled, explainable, and easier to improve.
app/
main.py # Command-line entry point
graph.py # LangGraph workflow definition
state.py # Shared AgentState model
llm/
client.py # Gemini API client wrapper
nodes/
classifier.py # Classifies the user request
risk_checker.py # Detects high-risk queries
tool_router.py # Chooses retrieval, web search, or no tool
tool_executor.py # Runs the selected tool
responder.py # Creates the response using tool output
validator.py # Checks response/tool quality
confidence_checker.py # Calculates a simple confidence score
human_review.py # Asks for human approval when needed
hitl_action.py # Simulates the human-in-the-loop action
tools/
retrieval_tool.py # Reads local hospital policy data
web_search_tool.py # Uses Tavily search for web information
data/
hospital_policies.txt # Simple hospital policy knowledge base
Project_detail_doc/
week_1_agentic_ai_theory_deep_dive.md
hospital_agentic_ai_week__foundation_docs.md
Hospital support agentic ai project.docx
stateExample.py # Small state example used during learning
requirements.txt # Python dependencies
Some files still contain comments from the earlier learning weeks. That is intentional: the project was developed as a 3-week teaching plan, and the comments help students see how the workflow grew over time.
Students first learn the difference between a chatbot and an agentic workflow.
Concepts covered:
Related files:
app/state.py
app/nodes/classifier.py
app/nodes/responder.py
app/graph.py
Students then learn why agents need tools and why tool results must be checked.
Concepts covered:
Related files:
app/nodes/tool_router.py
app/nodes/tool_executor.py
app/tools/retrieval_tool.py
app/tools/web_search_tool.py
app/nodes/validator.py
Finally, students learn responsible routing for higher-risk situations.
Concepts covered:
Related files:
app/nodes/risk_checker.py
app/nodes/confidence_checker.py
app/nodes/human_review.py
app/nodes/hitl_action.py
The shared state is defined in app/state.py.
Each node receives the same AgentState, updates part of it, and returns it to the graph.
Important state fields include:
user_query # Original user question
request_type # faq, emergency, or medical_info
selected_tool # retrieval, web_search, or none
tool_result # Output from the selected tool
response # Generated answer
validation_passed # True or False
retry_count # Number of failed validation attempts
risk_level # low or high
confidence_score # Simple score from 0 to 100
requires_human_review # True when human review is needed
human_decision # Human approval decision
escalation_action # Simulated action after review
This is one of the most important concepts in the project. State is how the workflow remembers what happened at each step.
The retrieval tool reads from:
app/data/hospital_policies.txt
It is useful for questions such as:
What are the hospital visiting hours?
What documents are needed for admission?
Can family members visit the ICU?
How can I book an appointment?
The web search tool uses Tavily search through:
app/tools/web_search_tool.py
It is useful for general medical information questions such as:
What are common dengue symptoms?
What are common diabetes symptoms?
The responder is instructed not to provide a diagnosis. It should only use the tool result and keep the answer short.
python -m venv .venv
On Windows PowerShell:
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
The current code also imports Tavily:
from tavily import TavilyClient
If Tavily is not already installed in your environment, install it with:
pip install tavily-python
.env fileCreate a .env file in the project root:
GEMINI_API_KEY=your_gemini_api_key_here
TAVILY_API_KEY=your_tavily_api_key_here
GEMINI_API_KEY is required for the LLM calls.
TAVILY_API_KEY is required when the agent chooses the web search tool.
From the project root, run:
python -m app.main
Then enter a query when prompted.
Example:
Enter your query: What are the visiting hours?
The program prints the internal workflow result:
Request Type
Risk Level
Tool Used
Confidence Score
Validation Passed
Retry Count
Human Review Required
Response
This output is useful for learning because students can see what the agent decided at each stage.
Try these examples:
What are the hospital visiting hours?
Expected idea:
What documents do I need for admission?
Expected idea:
What are dengue symptoms?
Expected idea:
I have chest pain and cannot breathe
Expected idea:
For a high-risk query, the system prints:
HUMAN REVIEW REQUIRED
Then it asks:
Approve emergency escalation? (yes/no):
This is a teaching simulation. It shows how a system can pause and ask a human before taking an important action.
Validation happens in:
app/nodes/validator.py
The validator checks:
If validation fails, the graph retries the response generation.
The retry limit is defined in:
app/graph.py
MAX_RETRIES = 2
If validation still fails after the retry limit, the graph routes to human review.
Confidence is calculated in:
app/nodes/confidence_checker.py
The current version uses a simple teaching rule:
This creates a score out of 100.
If confidence is below 70, the graph routes to human review.
This is intentionally simple so students can understand the concept before building more advanced scoring.
This project is only for learning agentic AI concepts.
It does not:
For real medical concerns, users should contact qualified medical professionals or emergency services.
Students can build similar projects by changing the domain and tools.
Example project ideas:
Possible improvements:
This project demonstrates the main deliverables from the 3-week training plan:
Run the project:
python -m app.main
Main workflow:
app/graph.py
Shared state:
app/state.py
Local hospital data:
app/data/hospital_policies.txt
Start reading from:
app/main.py
Then follow the graph in:
app/graph.py