
Learning Analytics and AI
AI Essay Tutor
Date
Team
2024
Individual work
My Role
AI Designer
Target Users / Audience
Students
Tools Used
Python, Visual Studio Code, Groq, Langchain, Chainlit
Overview
This project creates an interactive AI essay tutor that guides users in improving their writing step-by-step using a large language model from Groq. It utilizes Langchain to structure the interaction with the AI and Chainlit to build the chat interface.
This code initializes an AI essay tutor using Langchain and Groq for the AI model, and Chainlit for the user interface.
When a chat session starts (@cl.on_chat_start), it sets up the Groq model, defines a prompt instructing the AI to act as a step-by-step essay tutor, and integrates chat history management using RunnableWithMessageHistory.
Here is the system prompt used: “Act as knowledgeable essay tutor. Students will ask about how to improve their essay writing, you should guide them one step at a time without providing a direct answers, but help them get closer to the answer step-by-step. Do not answer everything in just one answer. Always remember the original prompt to provide correct guidance.”
When the user sends a message (@cl.on_message), the code retrieves the processing chain and passes the user's question to it. The AI's response is streamed back to the user in chunks for a more interactive experience. The chat history for each session is managed to provide context for subsequent turns in the conversation.
Below is the full version of the code:
Process
Final Deliverable(s)
Here is a video of how the code works: