aita_core.rag — RAG Pipeline
The RAG (Retrieval-Augmented Generation) pipeline handles the complete flow from user query to LLM response.
Pipeline Functions
- aita_core.rag.chat(user_query, chat_history=None, current_week=15)[source]
Full RAG pipeline: retrieve context, build prompt, generate response. Returns (assistant_message, sources, messages).
messagesis the exact prompt that was sent, so a shadow model can be given the identical input.
- aita_core.rag.retrieve(query, k=None, current_week=15)[source]
Retrieve top-k relevant chunks, filtered to only topics covered by current_week.
Homework Injection
When a student asks about “homework”, “hw”, or “assignment”, the system checks if the current week’s homework is already in the retrieved chunks. If not, it scans the full chunk index and injects the first matching chunk at the top of the context. This ensures the LLM always has the relevant homework content when answering homework-related questions.
Week-Aware System Prompt
The system prompt is dynamically built based on the current week:
The prompt includes:
Current week number
Current homework assignment name
List of topics covered so far
List of topics not yet covered
Instructions to redirect questions about future topics