Educhain
A Python package for generating educational content using Generative AI
Install / Use
/learn @satvik314/EduchainREADME
<p align="center">
<img src="https://github.com/Shubhwithai/educhain/blob/main/images/educhain%20final%20logo.svg" alt="Educhain Logo" width="800" height="400">
</p>
<div align="center">
</div>
Educhain 🎓🔗
Educhain is a powerful Python package that leverages Generative AI to create engaging and personalized educational content. From generating multiple-choice questions to crafting comprehensive lesson plans with 8 pedagogical approaches, Educhain makes it easy to apply AI in various educational scenarios with sound educational theory.
🚀 Features
<details> <summary>📝 Generate Multiple Choice Questions (MCQs)</summary>from educhain import Educhain
client = Educhain()
# Basic MCQ generation
mcq = client.qna_engine.generate_questions(
topic="Solar System",
num=3,
question_type="Multiple Choice"
)
# Advanced MCQ with custom parameters
advanced_mcq = client.qna_engine.generate_questions(
topic="Solar System",
num=3,
question_type="Multiple Choice",
difficulty_level="Hard",
custom_instructions="Include recent discoveries"
)
print(mcq.model_dump_json()) # View in JSON format , For Dictionary format use mcq.model_dump()
</details>
<details>
<summary>📊 Create Lesson Plans </summary>
from educhain import Educhain
client = Educhain()
# Basic lesson plan
lesson = client.content_engine.generate_lesson_plan(
topic="Photosynthesis"
)
# Advanced lesson plan with specific parameters
detailed_lesson = client.content_engine.generate_lesson_plan(
topic="Photosynthesis",
duration="60 minutes",
grade_level="High School",
learning_objectives=["Understanding the process", "Identifying key components"]
)
print(lesson.model_dump_json()) # View in JSON format , For Dictionary format use lesson.model_dump()
</details>
<details>
<summary>🔄 Support for Various LLM Models</summary>
from educhain import Educhain, LLMConfig
from langchain_google_genai import ChatGoogleGenerativeAI
from langchain_openai import ChatOpenAI
# Using Gemini
gemini_model = ChatGoogleGenerativeAI(
model="gemini-2.0-flash",
google_api_key="YOUR_GOOGLE_API_KEY"
)
gemini_config = LLMConfig(custom_model=gemini_model)
gemini_client = Educhain(gemini_config)
# Using GPT-4
gpt4_model = ChatOpenAI(
model_name="gpt-4.1",
openai_api_key="YOUR_OPENAI_API_KEY"
)
gpt4_config = LLMConfig(custom_model=gpt4_model)
gpt4_client = Educhain(gpt4_config)
</details>
<details>
<summary>📁 Export Questions to Different Formats</summary>
from educhain import Educhain
client = Educhain()
questions = client.qna_engine.generate_questions(topic="Climate Change", num=5)
# Export to JSON
questions.json("climate_questions.json")
# Export to PDF
questions.to_pdf("climate_questions.pdf")
# Export to CSV
questions.to_csv("climate_questions.csv")
</details>
<details>
<summary>🎨 Customizable Prompt Templates</summary>
from educhain import Educhain
client = Educhain()
# Custom template for questions
custom_template = """
Generate {num} {question_type} questions about {topic}.
Ensure the questions are:
- At {difficulty_level} level
- Focus on {learning_objective}
- Include practical examples
- {custom_instructions}
"""
questions = client.qna_engine.generate_questions(
topic="Machine Learning",
num=3,
question_type="Multiple Choice",
difficulty_level="Intermediate",
learning_objective="Understanding Neural Networks",
custom_instructions="Include recent developments",
prompt_template=custom_template
)
</details>
<details>
<summary>📚 Generate Questions from Files</summary>
from educhain import Educhain
client = Educhain()
# From URL
url_questions = client.qna_engine.generate_questions_from_data(
source="https://example.com/article",
source_type="url",
num=3
)
# From PDF
pdf_questions = client.qna_engine.generate_questions_from_data(
source="path/to/document.pdf",
source_type="pdf",
num=3
)
# From Text File
text_questions = client.qna_engine.generate_questions_from_data(
source="path/to/content.txt",
source_type="text",
num=3
)
</details>
<details>
<summary>📹 Generate Questions from YouTube Videos <img src="images/new.png" width="30" height="30" alt="New" background-color: transparent> </summary>
from educhain import Educhain
client = Educhain()
# Basic usage - Generate 3 MCQs from a YouTube video
questions = client.qna_engine.generate_questions_from_youtube(
url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
num=3
)
print(questions.model_dump_json())
# Generate questions preserving original language
preserved_questions = client.qna_engine.generate_questions_from_youtube(
url="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
num=2,
target_language='hi',
preserve_original_language=True # Keeps original language
)
</details>
<details>
<summary>🥽 Generate Questions from Images <img src="images/new.png" width="30" height="30" alt="New" background-color: transparent> </summary>
from educhain import Educhain
client = Educhain() #Default is 4o-mini (make sure to use a multimodal LLM!)
question = client.qna_engine.solve_doubt(
image_source="path-to-your-image",
prompt="Explain the diagram in detail",
detail_level = "High"
)
print(question)
</details>
<details>
<summary>🥽 Generate Visual Questions <img src="images/new.png" width="30" height="30" alt="New" background-color: transparent> </summary>
from langchain_google_genai import ChatGoogleGenerativeAI
from educhain import Educhain, LLMConfig
gemini_flash = ChatGoogleGenerativeAI(model="gemini-2.0-flash", google_api_key=GOOGLE_API_KEY)
flash_config = LLMConfig(custom_model=gemini_flash)
client = Educhain(flash_config)
ques = client.qna_engine.generate_visual_questions(
topic="GMAT Statistics", num=10 )
print(ques.model_dump_json())
</details>
<details>
<summary>🎓 Generate Pedagogy-Based Content <img src="images/new.png" width="30" height="30" alt="New" background-color: transparent> </summary>
from educhain import Educhain, LLMConfig
client = Educhain()
# Bloom's Taxonomy - All cognitive levels
blooms_content = client.content_engine.generate_pedagogy_content(
topic="Data Science Fundamentals",
pedagogy="blooms_taxonomy",
target_level="All levels", # or specific: "Remember", "Understand", "Apply", "Analyze", "Evaluate", "Create"
grade_level="University",
custom_instructions="Include Python programming and statistical concepts"
)
# Socratic Questioning - Strategic questioning for critical thinking
socratic_content = client.content_engine.generate_pedagogy_content(
topic="Climate Change Solutions",
pedagogy="socratic_questioning",
depth_level="Intermediate", # "Basic", "Intermediate", "Advanced"
student_level="High School", # "Elementary", "Middle School", "High School", "University"
custom_instructions="Encourage analysis of multiple perspectives and evidence"
)
# Project-Based Learning - Comprehensive project design
project_content = client.content_engine.generate_pedagogy_content(
topic="Documentary Filmmaking",
pedagogy="project_based_learning",
team_size="2-3 students", # "Individual", "2-3 students", "4-5 students", "Large group"
project_duration="2 weeks", # "1 week", "2 weeks", "4-6 weeks", "Full semester"
industry_focus="Media Production", # "General", "Technology", "Healthcare", "Arts", etc.
custom_instructions="Focus on social justice themes and community impact"
)
# Flipped Classroom - Pre-class study with in-class activities
flipped_content = client.content_engine.generate_pedagogy_content(
topic="Machine Learning Algorithms",
pedagogy="flipped_classroom",
class_duration="40 minutes", # "30 minutes", "50 minutes", "90 minutes"
prep_time="30 minutes", # "15-30 minutes", "30-45 minutes", "45-60 minutes"
technology_level="Low", # "Low", "Moderate", "High"
custom_instructions="Include coding exercises and peer programming"
)
# Inquiry-Based Learning - Student-driven exploration
inquiry_content = client.content_engine.generate_pedagogy_content(
topic="Impact of Social Media on Democracy",
pedagogy="inquiry_based_learning",
inquiry_type="Guided", # "Guided", "Open", "Structured"
investigation_scope="Moderate", # "Narrow", "Moderate", "Broad"
student_autonomy="Balanced", # "Low", "Balanced", "High"
custom_instructions="Use primary sources and contemporary case studies"
)
# Constructivist - Experience-based learning
constructivist_content = client.content_engine.generate_pedagogy_content(
topic="Statistical Analysis",
pedagogy="constructivist",
prior_knowledge_level="Mixed", # "Beginner", "Mixed", "Advanced"
social_interaction_focus="Moderate", # "Low", "Moderate", "High"
reflection_emphasis="Strong", # "Weak", "Moderate", "Strong"
custom_instructions="Use real datasets and collaborative problem-solving"
)
# Gamification - Game mechanics for motivation
gamified_content = client.content_engine.generate_pedagogy_content(
topic="Japanese Language Fundamentals",
pedagogy="gamification",
game_mechanics="Points, streaks, badges, social challenges", # Customize game elements
competition_level="Low", # "Low", "Moderate", "High"
technology_platform="Mobile App", # "Web-based", "Mobile App", "Classroom", "Mixed
