marvelai-org / marvel-ai-backend

This is the Marvel Teaching Assistant ai repo.
MIT License
17 stars 85 forks source link

Epic 7.7.1: Syllabus Generator. Squad: Rex-Hunters #91

Closed Dim314159 closed 2 months ago

Dim314159 commented 3 months ago

Description and formatting

We created syllabus generator located features/syllabus

We used tool ID "4". from api/tools_config.json:

    "4": {
        "path": "features.syllabus.core",
        "metadata_file": "metadata.json"
    }

Here is the configuration of our input in the features/syllabus/metadata.json:

{
    "inputs": [
        {
            "label": "Grade level",
            "name": "grade_level",
            "type": "text"
        },
        {
            "label": "Course Title",
            "name": "course_title",
            "type": "text"
        },
        {
            "label": "Course Description",
            "name": "course_description",
            "type": "text"
        },
        {
            "label": "Objectives/Topics covered",
            "name": "objectives_topics",
            "type": "text"
        },
        {
            "label": "Required Materials",
            "name": "required_materials",
            "type": "text"
        },
        {
            "label": "Time duration",
            "name": "num_weeks",
            "type": "text"
        },
        {
            "label": "Course Outline",
            "name": "course_outline",
            "type": "text"
        },
        {
            "label": "Grading Policy",
            "name": "grading_policy",
            "type": "text"
        },
        {
            "label": "Class Policy",
            "name": "class_policy",
            "type": "text"
        },
        {
            "label": "Additional Customization",
            "name": "customization",
            "type": "text"
        }
    ]
}

So our request body may look like (See the "Testing" section):

{
    "user": {
        "id": "string",
        "fullName": "string",
        "email": "string"
    },
    "type": "tool",
    "tool_data": {
        "tool_id": 4,
        "inputs": [
            {
                "name": "grade_level",
                "value": "University"
            },
            {
                "name": "course_title",
                "value": "Introduction to Quantum Mechanics"
            },
            {
                "name": "course_description",
                "value": "An introductory course in quantum mechanics, covering fundamental principles and applications."
            },
            {
                "name": "objectives_topics",
                "value": "Topics covering historical background, wave-particle duality, Schrödinger equation, and quantum computing."
            },
            {
                "name": "required_materials",
                "value": "Textbook, scientific calculator, lab notebook, and access to quantum simulation software."
            },
            {
                "name": "num_weeks",
                "value": "16"
            },
            {
                "name": "course_outline",
                "value": "Details based on the objectives."
            },
            {
                "name": "grading_policy",
                "value": "Grades based on exams, homework, lab reports, and participation."
            },
            {
                "name": "class_policy",
                "value": "Attendance, timely submission of assignments, active participation, and academic integrity are required."
            },
            {
                "name": "customization",
                "value": "Extra credits."
            }
        ]
    }
}

The result will be the a dictionary with keys: course_title course_description objectives_topics required_materials course_outline grading_policy class_policy

Code structure

in features/syllabus/tools.py we created: class SyllabusBuilder with method:

class Syllabus with methods:

For the response formatting we used format instructions.

prompt = PromptTemplate(
            template=self.prompt_template,
            input_variables=["context"],
            partial_variables={"format_instructions": self.parser.get_format_instructions()}
        )

We used pydantic class for parsing and validation:

class SyllabusFormat(BaseModel):
    course_title: str = Field(description = 'title of the course')
    course_description: str = Field(description = 'description of the course')
    objectives_topics: str = Field(description = 'topics covered and objectives of the course')
    required_materials: str = Field(description = 'materials required for the course')
    course_outline: str = Field(description = 'outline of the course')
    grading_policy: str = Field(description = 'graiding policy of the course')
    class_policy: str = Field(description = 'class policy of the course')

Testing

We tested worksheet generator for different inputs.

Example output based on request body mentioned above:

course_title: Introduction to Quantum Mechanics

course_description: This course provides an introduction to the fundamental principles of quantum mechanics, covering both theoretical concepts and practical applications. Students will gain an understanding of wave-particle duality, the Schrödinger equation, quantum entanglement, and quantum computing.

objectives_topics: Objectives:

Topics:

required_materials: * Textbook: Griffiths, D.J. (2018). Introduction to Quantum Mechanics (3rd ed.). Cambridge University Press.

course_outline: Week 1: Introduction to quantum mechanics

Week 2: The Schrödinger equation

Week 3: Applications of the Schrödinger equation

Week 4: Quantum entanglement

Week 5: Quantum computing

Weeks 6-16: Advanced topics in quantum mechanics

grading_policy: Grading:

class_policy: Class Policy:

huzaifakhan04 commented 2 months ago

@Dim314159 Some changes are still needed. Please make the necessary updates and inform me once you're finished.