How 098765d/ai_tutor works
KG-RAG AI Tutor is a Streamlit course-question-answering application. Students can upload course PDFs and build an index; for each question, the tutor first checks for a reusable similar answer, then retrieves course chunks and—when KG-RAG mode is selected—expands context through a course knowledge graph before synthesizing an answer. Standard RAG skips graph expansion. The graph also includes configuration, embedding, persistence, and chat export responsibilities. Relationships are grounded in the README or shown source; the data directory is generated at runtime and is not in the supplied tree.
Main entry points: tutor.py Tutor Orchestrator · app.py Streamlit App · embeddings.py Embedding Client · knowledge_graph.py Knowledge Graph
Components 15
Student Interface
- Streamlit App
app.py - Chat Export
src/export.py
Tutoring Workflow
- Configuration
src/config.py - Tutor Orchestrator
src/tutor.py
Course Retrieval
- Course PDFs
pdf - PDF Chunking
src/documents.py - Vector Retrieval
src/vector_store.py - Knowledge Graph
src/knowledge_graph.py - Answer Reuse
src/chat_history.py
Model Services
- Embedding Client
src/embeddings.py - LLM Client
src/llm.py
Other components
- Student
- DeepSeek API
- DashScope Embeddings
- Local MiniLM
Connections 19
- Student → Streamlit App: asks questions
README.md - Streamlit App → Configuration: loads settings
app.py - Streamlit App → Tutor Orchestrator: builds or queries
app.py - Streamlit App → Chat Export: exports messages
app.py - Streamlit App → Course PDFs: saves uploads
app.py - Tutor Orchestrator → Configuration: uses settings
src/tutor.py - Tutor Orchestrator → Course PDFs: indexes materials
README.md - Tutor Orchestrator → PDF Chunking: builds chunks
src/tutor.py - Tutor Orchestrator → Vector Retrieval: builds and searches
src/tutor.py - Tutor Orchestrator → Knowledge Graph: builds and retrieves
src/tutor.py - Tutor Orchestrator → Answer Reuse: checks and saves
src/tutor.py - Tutor Orchestrator → LLM Client: synthesizes answers
src/tutor.py - Vector Retrieval → Embedding Client: embeds queries and chunks
src/vector_store.py - Knowledge Graph → Embedding Client: embeds graph nodes
src/knowledge_graph.py - Knowledge Graph → LLM Client: extracts triples
src/knowledge_graph.py - Answer Reuse → Embedding Client: embeds questions
src/chat_history.py - Embedding Client → DashScope Embeddings: requests embeddings
src/embeddings.py - Embedding Client → Local MiniLM: embeds locally
README.md - LLM Client → DeepSeek API: requests completions
src/llm.py