Issue with the function schema

I have had created a notes generator using recursive OpenAI function calling. I am getting the desired output using json.dump but when I am trying to define a structured schema for my code then I am getting none as output. The given code is a smaller version of the code.

Full code ->
https://drive.google.com/drive/folders/18WlyNuaApvzOkFtslJBbyVwJ8IJgcZ_r?usp=sharing

import os
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

client = OpenAI()
import os
from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()

client = OpenAI()

def generate_subjects():
    response = client.chat.completions.create(
        model="gpt-3.5-turbo-16k",
        messages=[
            {"role": "system", "content": "You are a helpful teacher."},
            {"role": "user", "content": "Generate a list of academic subjects typically studied in 8th grade."}
        ],
        max_tokens=100,
        temperature=0.7,
    )
    subjects = response.choices[0].message.content.strip().split('n')
    subjects = [subject.strip() for subject in subjects if subject.strip()]
    return subjects

def generate_chapters(subject):
    prompt = f"Generate a list of chapters for the 8th grade subject: {subject}."
    response = client.chat.completions.create(
        model="gpt-3.5-turbo-16k",
        messages=[
            {"role": "system", "content": "You are a helpful teacher."},
            {"role": "user", "content": prompt}
        ],
        max_tokens=150,
        temperature=0.7,
    )
    chapters = response.choices[0].message.content.strip().split('n')
    chapters = [chapter.strip() for chapter in chapters if chapter.strip()]
    return chapters

# Main function to generate subjects and their chapters
def main():
    subjects = generate_subjects()
    curriculum = {}
    for subject in subjects:
        chapters = generate_chapters(subject)
        curriculum[subject] = chapters
    return curriculum

# Generate the curriculum
curriculum = main()
for subject, chapters in curriculum.items():
    print(f"{subject}:")
    for chapter in chapters:
        print(f"  - {chapter}")

def generate_and_print_curriculum_json():
    curriculum = main()
    curriculum_json = json.dumps(curriculum, indent=4)
    print(curriculum_json)

generate_and_print_curriculum_json()

The Output is ->

{
    "1. English Language Arts": [
        "1. Introduction to English Language Arts",
        "2. Parts of Speech",
        "3. Sentence Structure",
        "4. Reading Comprehension",
        "5. Literature Analysis",
        "6. Writing Skills",
        "7. Vocabulary Development",
        "8. Grammar and Punctuation",
        "9. Poetry Analysis",
        "10. Fiction Writing",
        "11. Non-Fiction Writing",
        "12. Research Skills",
        "13. Public Speaking and Presentation Skills",
        "14. Media Literacy",
        "15. Critical Thinking and Analysis",
        "16. Literary Devices",
        "17. Reading Strategies",
        "18. Literary Genres",
        "19. Reading and Writing for Different Purposes",
        "20. Language and Culture"
    ],
    "2. Mathematics": [
        "1. Number Systems and Operations",
        "2. Fractions, Decimals, and Percentages",
        "3. Algebraic Expressions and Equations",
        "4. Geometry: Lines, Angles, and Shapes",
        "5. Measurement and Data",
        "6. Ratios and Proportional Relationships",
        "7. Statistics and Probability",
        "8. Functions and Graphs",
        "9. Problem Solving and Critical Thinking Skills",
        "10. Review and Test Preparation"
    ],
    "3. Science": [
        "1. Introduction to Science",
        "2. Scientific Method and Inquiry",
        "3. Matter and Its Properties",
        "4. Atomic Structure and the Periodic Table",
        "5. Forces and Motion",
        "6. Energy and Energy Transfer",
        "7. Waves and Sound",
        "8. Light and Optics",
        "9. Earth's Systems and Processes",
        "10. Weather and Climate",
        "11. Ecosystems and Biomes",
        "12. Genetics and Heredity",
        "13. Evolution and Natural Selection",
        "14. Human Body Systems",
        "15. Reproduction and Development",
        "16. Health and Nutrition",
        "17. Environmental Science and Conservation",
        "18. Technology and Engineering in Science"
    ],
    "4. Social Studies": [
        "1. Introduction to Social Studies",
        "2. Geography and Map Skills",
        "3. Ancient Civilizations",
        "4. The Middle Ages",
        "5. The Renaissance and Reformation",
        "6. The Age of Exploration",
        "7. The Industrial Revolution",
        "8. World War I",
        "9. The Roaring Twenties",
        "10. The Great Depression",
        "11. World War II",
        "12. The Cold War",
        "13. Civil Rights Movement",
        "14. Current Events and Global Issues",
        "15. Government and Civics",
        "16. Economics and Personal Finance",
        "17. Environmental Issues",
        "18. Cultural Diversity and Identity",
        "19. Globalization and Interconnectedness",
        "20. Careers in Social Studies"
    ],
    "5. World History": [
        "1. Introduction to World History",
        "2. Early Civilizations: Mesopotamia, Egypt, and Indus Valley",
        "3. Ancient Greece: Democracy and Philosophy",
        "4. The Roman Empire: Rise and Fall",
        "5. The Middle Ages: Feudalism and the Crusades",
        "6. The Renaissance: Rebirth of Art and Learning",
        "7. The Age of Exploration: Discovering the New World",
        "8. The Enlightenment: Ideas that Changed the World",
        "9. The French Revolution: Liberty, Equality, and Fraternity",
        "10. The Industrial Revolution: Transforming Society and Economy",
        "11. Imperialism: European Powers and the Scramble for Africa",
        "12. World War I: The Great War and its Consequences"
    ],
    "6. Physical Education": [
        "1. Introduction to Physical Education",
        "2. Importance of Physical Fitness",
        "3. Warm-up and Stretching Exercises",
        "4. Cardiovascular Fitness Activities",
        "5. Strength and Conditioning Training",
        "6. Flexibility and Mobility Exercises",
        "7. Team Sports: Basketball",
        "8. Team Sports: Soccer",
        "9. Individual Sports: Tennis",
        "10. Individual Sports: Track and Field",
        "11. Health and Nutrition Education",
        "12. Injury Prevention and First Aid",
        "13. Fitness Testing and Goal Setting",
        "14. Game Strategies and Tactics",
        "15. Sportsmanship and Fair Play"
    ],
    "7. Foreign Language (e.g., Spanish, French)": [
        "1. Introduction to the Foreign Language",
        "2. Basic Vocabulary and Phrases",
        "3. Greetings and Introductions",
        "4. Numbers and Counting",
        "5. Colors and Descriptions",
        "6. Family and Relationships",
        "7. Daily Routines and Activities",
        "8. Food and Drinks",
        "9. Asking for Directions",
        "10. Weather and Seasons",
        "11. Clothing and Fashion",
        "12. School and Education",
        "13. Hobbies and Interests",
        "14. Travel and Transportation",
        "15. Holidays and Celebrations",
        "16. Health and Wellness",
        "17. Jobs and Professions",
        "18. Cultural Awareness and Traditions",
        "19. Technology and Social Media",
        "20. Review and Assessment"
    ],
    "8. Computer Science": [
        "1. Introduction to Computer Science",
        "2. History of Computing",
        "3. Hardware and Software Basics",
        "4. Programming Concepts",
        "5. Algorithms and Problem Solving",
        "6. Data Structures",
        "7. Web Development",
        "8. Networking and Internet Basics",
        "9. Cybersecurity",
        "10. Artificial Intelligence and Machine Learning",
        "11. Ethical and Social Issues in Computer Science",
        "12. Careers in Computer Science",
        "13. Practical Applications of Computer Science"
    ],
    "9. Health Education": [
        "Sure! Here is a list of chapters for 8th grade Health Education:",
        "1. Introduction to Health Education",
        "2. Personal Health and Wellness",
        "3. Nutrition and Healthy Eating",
        "4. Physical Fitness and Exercise",
        "5. Mental and Emotional Health",
        "6. Puberty and Reproductive Health",
        "7. Substance Abuse and Addiction",
        "8. Sexual Health and Relationships",
        "9. Disease Prevention and Control",
        "10. First Aid and Emergency Care",
        "11. Safety and Injury Prevention",
        "12. Environmental Health",
        "13. Consumer Health and Advocacy",
        "14. Media Literacy and Health",
        "15. Healthy Relationships and Communication Skills",
        "16. Stress Management and Coping Strategies",
        "17. Goal Setting and Decision Making",
        "18. Health Careers and Future Planning"
    ],
    "10. Art": [
        "1. Introduction to Art",
        "2. Elements of Art",
        "3. Principles of Design",
        "4. Drawing Basics",
        "5. Color Theory",
        "6. Painting Techniques",
        "7. Sculpture and 3D Art",
        "8. Printmaking",
        "9. Photography",
        "10. Art History",
        "11. Famous Artists",
        "12. Art Critique and Analysis",
        "13. Art in Different Cultures",
        "14. Art Movements and Styles",
        "15. Art Careers and Opportunities",
        "16. Art Exhibition and Presentation"
    ],
    "11. Music": [
        "Sure! Here is a list of chapters for an 8th-grade music curriculum:",
        "1. Introduction to Music",
        "2. Elements of Music",
        "3. Music Theory",
        "4. Music Notation",
        "5. Musical Instruments",
        "6. Music Genres",
        "7. Music History",
        "8. Famous Composers",
        "9. Vocal Music",
        "10. Instrumental Music",
        "11. Music Appreciation",
        "12. Music in Different Cultures",
        "13. Music and Technology",
        "14. Music Performance",
        "15. Music Composition",
        "16. Music in Film and Media",
        "17. Music and Society",
        "18. Careers in Music",
        "These chapters cover a wide range of topics in music, providing a comprehensive understanding of the subject for 8th-grade students."
    ],
    "12. Drama": [
        "1. Introduction to Drama",
        "2. Elements of Drama",
        "3. Types of Drama: Comedy",
        "4. Types of Drama: Tragedy",
        "5. Types of Drama: Historical and Political Drama",
        "6. Types of Drama: Musical Theatre",
        "7. Play Analysis: Plot and Structure",
        "8. Play Analysis: Characterization",
        "9. Play Analysis: Themes and Symbolism",
        "10. Play Analysis: Setting and Mood",
        "11. Acting Techniques: Voice and Diction",
        "12. Acting Techniques: Body Language and Movement",
        "13. Acting Techniques: Emotion and Expression",
        "14. Stagecraft: Set Design and Construction",
        "15. Stagecraft: Lighting and Sound Design",
        "16. Stagecraft: Costumes and Props",
        "17. Directing"
    ],
    "13. Technology Education": [
        "Sure! Here is a list of chapters for the 8th-grade subject: Technology Education:",
        "1. Introduction to Technology Education",
        "2. History and Evolution of Technology",
        "3. The Design Process",
        "4. Computer-Aided Design (CAD)",
        "5. Communication and Information Technologies",
        "6. Digital Citizenship and Internet Safety",
        "7. Robotics and Automation",
        "8. Energy and Sustainability",
        "9. Transportation Technologies",
        "10. Manufacturing and Materials",
        "11. Engineering and Construction",
        "12. Biotechnology",
        "13. Emerging Technologies",
        "14. Careers in Technology",
        "15. Ethical and Social Implications of Technology",
        "Please note that the chapter titles may vary depending on the curriculum or textbook used in your specific school or region."
    ],
    "14. Home Economics": [
        "1. Introduction to Home Economics",
        "2. Kitchen Safety and Sanitation",
        "3. Basic Nutrition and Healthy Eating",
        "4. Meal Planning and Food Preparation",
        "5. Understanding Food Labels and Portion Control",
        "6. Exploring Different Cooking Techniques",
        "7. Baking and Pastry Making",
        "8. Introduction to Sewing and Textiles",
        "9. Clothing Care and Maintenance",
        "10. Basic Sewing Skills and Techniques",
        "11. Introduction to Interior Design",
        "12. Furniture and Space Planning",
        "13. Fabric Selection and Color Theory",
        "14. Home Organization and Storage Solutions",
        "15. Budgeting and Financial Management in the Home",
        "16. Sustainable Living and Environmental Awareness",
        "17. Personal Hygiene and Grooming",
        "18. Etiquette and Social"
    ],
    "15. Career Exploration": [
        "1. Introduction to Career Exploration",
        "2. Identifying Your Interests and Passions",
        "3. Exploring Different Career Fields",
        "4. Researching Careers: Job Descriptions and Requirements",
        "5. Understanding the Importance of Skills and Qualifications",
        "6. Exploring Education and Training Options",
        "7. Exploring Career Pathways and Opportunities",
        "8. Networking and Building Professional Relationships",
        "9. Job Shadowing and Internship Opportunities",
        "10. Resume Writing and Interview Skills",
        "11. Developing a Career Action Plan",
        "12. Entrepreneurship and Self-Employment",
        "13. Exploring Non-Traditional Careers",
        "14. Exploring Careers in Science, Technology, Engineering, and Math (STEM)",
        "15. Future Trends in Careers and the World of Work"
    ],
    "16. Civics/Government": [
        "1. Introduction to Civics and Government",
        "2. The Constitution and its Origins",
        "3. The Three Branches of Government",
        "4. Rights and Responsibilities of Citizens",
        "5. The Electoral Process",
        "6. State and Local Government",
        "7. The Role of Political Parties",
        "8. The Judicial Branch and the Supreme Court",
        "9. Civil Liberties and Civil Rights",
        "10. The Role of Media in Government",
        "11. International Relations and Global Citizenship",
        "12. Public Policy and Advocacy",
        "13. Economic Systems and Government",
        "14. Environmental Policy and Sustainability",
        "15. Current Issues in Civics and Government",
        "16. Review and Assessment"
    ],
    "17. Environmental Science": [
        "1. Introduction to Environmental Science",
        "2. Ecosystems and Biodiversity",
        "3. Population Dynamics",
        "4. Natural Resources and Conservation",
        "5. Pollution and Human Impact",
        "6. Climate Change and Global Warming",
        "7. Renewable and Nonrenewable Energy Sources",
        "8. Sustainable Living and Green Technology",
        "9. Environmental Policy and Law",
        "10. Environmental Ethics and Responsibility",
        "11. Environmental Education and Awareness",
        "12. Environmental Careers and Opportunities",
        "13. Environmental Science Research Methods",
        "14. Case Studies in Environmental Science",
        "15. Current Issues in Environmental Science"
    ],
    "18. Geography": [
        "Sure! Here is a list of chapters for the 8th-grade subject of Geography:",
        "1. Introduction to Geography",
        "2. Maps and Map Skills",
        "3. Physical Geography: Landforms and Landscapes",
        "4. Earth's Atmosphere and Weather",
        "5. Climate and Climate Change",
        "6. Human Geography: Population and Migration",
        "7. Economic Geography: Resources and Industries",
        "8. Cultural Geography: Language and Religion",
        "9. Political Geography: Borders and Governments",
        "10. Urban Geography: Cities and Urbanization",
        "11. Environmental Geography: Conservation and Sustainability",
        "12. Regional Geography: North America",
        "13. Regional Geography: South America",
        "14. Regional Geography: Europe",
        "15. Regional Geography: Africa",
        "16. Regional Geography: Asia"
    ],
    "19. Algebra": [
        "1. Introduction to Algebra",
        "2. Variables and Expressions",
        "3. Solving Equations",
        "4. Inequalities",
        "5. Graphing Linear Equations",
        "6. Systems of Equations",
        "7. Exponents and Scientific Notation",
        "8. Polynomials and Factoring",
        "9. Quadratic Equations",
        "10. Rational Numbers and Operations",
        "11. Radical Expressions and Equations",
        "12. Introduction to Functions",
        "13. Linear Functions and Slope",
        "14. Systems of Linear Inequalities",
        "15. Exponential Functions",
        "16. Data Analysis and Statistics",
        "17. Probability and Combinations",
        "18. Geometry and Algebra",
        "19. Review and Test Preparation"
    ],
    "20.": [
        "1. Introduction to Algebra",
        "2. Solving Equations",
        "3. Exponents and Powers",
        "4. Data Analysis and Probability",
        "5. Geometry: Lines and Angles",
        "6. Rational Numbers",
        "7. Functions and Graphs",
        "8. Linear Equations and Inequalities",
        "9. Systems of Equations",
        "10. Polynomials",
        "11. Quadratic Equations",
        "12. Transformations and Symmetry",
        "13. Surface Area and Volume",
        "14. Pythagorean Theorem",
        "15. Similarity and Congruence",
        "16. Probability and Statistics",
        "17. Rational and Irrational Numbers",
        "18. Scientific Notation",
        "19. Exponential Functions",
        "20. Financial Literacy"
    ]
}
functions = [
    {
        "name": "generate_subjects",
        "description": "Generates a list of academic subjects typically studied in 8th grade",
        "parameters": {
            "type": "object",
            "properties": {}
        }
    },
    {
        "name": "generate_chapters",
        "description": "Generates a list of chapters for a given 8th-grade subject",
        "parameters": {
            "type": "object",
            "properties": {
                "subject": {
                    "type": "string",
                    "description": "The subject for which chapters are to be generated, e.g., Mathematics"
                }
            },
            "required": ["subject"]
        }
    },
    {
        "name": "generate_curriculum_json",
        "description": "Generates the entire curriculum for 8th grade in JSON format",
        "parameters": {
            "type": "object",
            "properties": {}
        }
    }
]

def call_openai_function(prompt, function_name, parameters):
    """Give LLM a given prompt and get an answer."""
    completion = client.chat.completions.create(
        model="gpt-3.5-turbo-16k",
        messages=[{"role": "user", "content": prompt}],
        functions=functions,
        function_call={
            "name": function_name,
            "parameters": parameters
        }
    )
    output = completion.choices[0].message.content
    return output

subjects_prompt = "Generate a list of academic subjects typically studied in 8th grade."
chapters_prompt = "Generate a list of chapters for the 8th grade subject: Mathematics."
curriculum_prompt = "Generate the entire curriculum for 8th grade in JSON format."

subjects = call_openai_function(subjects_prompt, "generate_subjects", {})
chapters = call_openai_function(chapters_prompt, "generate_chapters", {"subject": "Mathematics"})
curriculum = call_openai_function(curriculum_prompt, "generate_curriculum_json", {})

print("Subjects:", subjects)
print("Chapters for Mathematics:", chapters)
print("Curriculum:", curriculum)

The output ->

Subjects: None
Chapters for Mathematics: None
Curriculum: None

Please can anyone look into my code and help me to debug it.
Thank You

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật