top of page

Learning Analytics and AI

AI Critical Thinking Activity Creator

Date

Team

2024

Individual work

My Role

AI Designer

Target Users / Audience

Educators

Tools Used

Python, Visual Studio Code, Groq, Chainlit, CrewAI

Overview

This project creates a multi-agent system using CrewAI to generate critical thinking activities for any user-specified topic. It uses a large language model from Groq and the Chainlit framework for the chat interface.

This project creates a multi-agent system using CrewAI to generate critical thinking activities for any user-specified topic. 


When a chat session starts (@cl.on_chat_start), it defines three specialized AI agents: a 'Teacher' to outline key concepts, an 'InstructionalDesigner' to create activities, and an 'Evaluator' to critique them. It then defines a sequence of tasks for these agents: content creation, activity design, evaluation, improvement, and finally, the creation of a class script. These agents and tasks are organized into a 'Crew', which is stored in the user's session. 


The user is then prompted to provide a topic. When the user sends a message (@cl.on_message), the code retrieves the 'Crew' and initiates the task execution with the user's input as the 'topic'. The output from each agent's task is then displayed to the user in the Chainlit interface, attributed to the respective agent.


ree

Below is the full version of the code:

from crewai import Agent, Task, Crew, Process
from langchain_groq.chat_models import ChatGroq 
import chainlit as cl

llm = ChatGroq(model_name="groq/llama3-70b-8192")

@cl.on_chat_start
async def on_chat_start():
    
    # Create a classroom with a teacher and 5 students
    teacher = Agent(
        role='Teacher',
        goal='Facilitate the development of critical thinking skills in students.',
        backstory="""You are an experienced teacher focused on fostering critical thinking in your students.
        Your goal is to encourage inquiry, discussion, and debate, helping students analyze information and form reasoned conclusions.
        You enjoy engaging students with thought-provoking questions and scenarios related to {topic}.""",
        verbose=True,
        allow_delegation=False,
        tools=[],
        llm=llm
    )

    instructional_designer = Agent(
        role='InstructionalDesigner',
        goal='Design activities that promote critical thinking skills in {topic}.',
        backstory="""You are an instructional designer who specializes in creating engaging activities that encourage critical thinking.
        You utilize real-world scenarios, debates, and problem-solving exercises related to {topic} to challenge students' thinking processes.
        """,
        verbose=True,
        allow_delegation=False,
        tools=[],
        llm=llm
    )

    evaluator = Agent(
        role='Evaluator',
        goal='Critique activities to enhance their effectiveness in fostering critical thinking.',
        backstory="""You are knowledgeable in educational theories and critical thinking frameworks.
        You assess activities designed for critical thinking related to {topic} and provide recommendations for improvement to make them more effective and engaging.""",
        verbose=True,
        allow_delegation=False,
        tools=[],
        llm=llm
    )

    content_creation = Task(
        description="Generate a list of key concepts related to critical thinking in {topic}.",
        expected_output="A list of 5 to 10 key concepts or skills.",
        agent=teacher,
    )

    activity_design = Task(
        description="Design engaging activities based on the concepts provided by the teacher to promote critical thinking in {topic}.",
        expected_output="A detailed description of activities aimed at developing critical thinking skills.",
        agent=instructional_designer
    )

    activity_evaluation = Task(
        description="Evaluate the activities designed to ensure they effectively promote critical thinking in {topic} and suggest improvements.",
        expected_output="A list of recommendations for improving the activities.",
        agent=evaluator
    )

    activity_improvement = Task(
        description="Revise the activities based on the evaluator's recommendations to enhance their effectiveness in {topic}.",
        expected_output="An improved set of activities promoting critical thinking.",
        agent=instructional_designer
    )

    class_script_creation = Task(
        description="Convert the improved activities into a structured class script for execution focused on {topic}.",
        expected_output="A class script for conducting activities centered on critical thinking.",
        agent=teacher
    )

    crew = Crew(
        agents=[teacher, instructional_designer, evaluator],
        tasks=[content_creation, activity_design, activity_evaluation, activity_improvement, class_script_creation],
        verbose=True,
        process=Process.sequential,
    )    

    cl.user_session.set('crew', crew)

    await cl.Message(content="Welcome to the critical thinking activity creator. Please mention a topic related to critical thinking you'd like to explore.", author="Crew").send()

@cl.on_message
async def main(message: cl.Message):
  
    crew = cl.user_session.get('crew')
    
    question = message.content
    inputs = {'topic': question}
    crew_output = crew.kickoff(inputs=inputs)
   
    for output in crew_output.tasks_output:
        msg = cl.Message(content=output.raw, author=output.agent)
        await msg.send()
        # Send final message
        await msg.update()


Process

Final Deliverable(s)

Here is a video of how the code works:



Wanna know more about me and my work?
Feel free to contact me!
Screenshot 2023-12-23 at 4.02.09 PM.png
Screenshot 2023-12-23 at 4.02.16 PM.png

© 2024 by Colleen Chung

bottom of page