Download src/backend/tools/notes_generation_tool.py from anas-ahmed/Agentex-Hyper-Personalized-Tutor: direct link, hf CLI and curl.
- Browser
- Download file 6.78 kB
-
https://huggingface.co/spaces/anas-ahmed/Agentex-Hyper-Personalized-Tutor/resolve/main/src/backend/tools/notes_generation_tool.py
- Command line
-
hf download hf://spaces/anas-ahmed/Agentex-Hyper-Personalized-Tutor/src/backend/tools/notes_generation_tool.py
-
curl -L -o notes_generation_tool.py https://huggingface.co/spaces/anas-ahmed/Agentex-Hyper-Personalized-Tutor/resolve/main/src/backend/tools/notes_generation_tool.py
6.78 kB
| """Notes generation tool for creating educational notes.""" | |
| from agents import function_tool | |
| def generate_note_structure( | |
| topic: str, | |
| difficulty_level: str, | |
| include_examples: bool = True, | |
| include_diagrams: bool = False, | |
| ) -> str: | |
| """ | |
| Generate a structured outline for educational notes. | |
| This tool helps create a consistent structure for notes based on difficulty level. | |
| The agent should fill in the content for each section. | |
| Args: | |
| topic: The main topic for the notes | |
| difficulty_level: Education level (primary, high_school, college, undergrad, postgrad) | |
| include_examples: Whether to include example sections | |
| include_diagrams: Whether to include diagram placeholders | |
| Returns: | |
| Markdown outline structure for the notes | |
| """ | |
| # Base structure | |
| structure = [f"# {topic}\n"] | |
| # Difficulty-specific sections | |
| if difficulty_level == "primary": | |
| structure.extend([ | |
| "## What is this?", | |
| "[Simple explanation in 1-2 sentences]\n", | |
| "## How does it work?", | |
| "[Step-by-step explanation with simple words]\n", | |
| ]) | |
| if include_examples: | |
| structure.extend([ | |
| "## Examples from Daily Life", | |
| "[Real-world examples kids can relate to]\n", | |
| ]) | |
| structure.extend([ | |
| "## Key Points to Remember", | |
| "[Bullet points with main ideas]\n", | |
| ]) | |
| elif difficulty_level == "high_school": | |
| structure.extend([ | |
| "## Introduction", | |
| "[Clear definition and context]\n", | |
| "## Main Concepts", | |
| "[Core ideas with explanations]\n", | |
| "## How It Works", | |
| "[Detailed explanation]\n", | |
| ]) | |
| if include_examples: | |
| structure.extend([ | |
| "## Real-World Applications", | |
| "[Practical examples and use cases]\n", | |
| ]) | |
| if include_diagrams: | |
| structure.extend([ | |
| "## Visual Representation", | |
| "[Diagram placeholder]\n", | |
| ]) | |
| structure.extend([ | |
| "## Summary", | |
| "[Key takeaways]\n", | |
| ]) | |
| elif difficulty_level in ["college", "undergrad"]: | |
| structure.extend([ | |
| "## Abstract", | |
| "[Brief overview]\n", | |
| "## Introduction", | |
| "[Background and significance]\n", | |
| "## Theoretical Foundation", | |
| "[Core theories and principles]\n", | |
| "## Detailed Analysis", | |
| "[In-depth explanation]\n", | |
| ]) | |
| if include_examples: | |
| structure.extend([ | |
| "## Examples and Case Studies", | |
| "[Detailed examples]\n", | |
| ]) | |
| if include_diagrams: | |
| structure.extend([ | |
| "## Diagrams and Visualizations", | |
| "[Technical diagrams]\n", | |
| ]) | |
| structure.extend([ | |
| "## Applications", | |
| "[Practical applications]\n", | |
| "## Conclusion", | |
| "[Summary and implications]\n", | |
| ]) | |
| if difficulty_level == "undergrad": | |
| structure.extend([ | |
| "## Further Reading", | |
| "[References and resources]\n", | |
| ]) | |
| elif difficulty_level == "postgrad": | |
| structure.extend([ | |
| "## Abstract", | |
| "[Concise summary of content]\n", | |
| "## Introduction", | |
| "[Context, motivation, and research landscape]\n", | |
| "## Theoretical Framework", | |
| "[Advanced theoretical concepts]\n", | |
| "## Methodological Considerations", | |
| "[Approaches and methodologies]\n", | |
| "## Critical Analysis", | |
| "[Detailed examination and critique]\n", | |
| "## Contemporary Research", | |
| "[Current developments and debates]\n", | |
| ]) | |
| if include_examples: | |
| structure.extend([ | |
| "## Case Studies and Applications", | |
| "[Advanced examples from research]\n", | |
| ]) | |
| if include_diagrams: | |
| structure.extend([ | |
| "## Figures and Models", | |
| "[Complex diagrams and models]\n", | |
| ]) | |
| structure.extend([ | |
| "## Implications and Future Directions", | |
| "[Research implications]\n", | |
| "## References", | |
| "[Scholarly citations]\n", | |
| ]) | |
| else: | |
| # Default college structure | |
| structure.extend([ | |
| "## Introduction", | |
| "## Main Content", | |
| "## Examples", | |
| "## Summary", | |
| ]) | |
| return "\n".join(structure) | |
| def suggest_note_sections( | |
| topic: str, | |
| current_sections: str, | |
| missing_aspects: str = "", | |
| ) -> str: | |
| """ | |
| Suggest additional sections or content to add to notes. | |
| Use this tool when you need to enhance existing notes or identify gaps. | |
| Args: | |
| topic: The topic of the notes | |
| current_sections: List of current section headings (one per line) | |
| missing_aspects: Optional aspects that should be covered | |
| Returns: | |
| Suggestions for additional sections or improvements | |
| """ | |
| suggestions = [] | |
| # Common educational elements to check | |
| common_elements = { | |
| "definition": ["Introduction", "What is", "Overview"], | |
| "examples": ["Examples", "Applications", "Case Studies"], | |
| "diagrams": ["Diagram", "Visual", "Figure", "Chart"], | |
| "summary": ["Summary", "Conclusion", "Key Points"], | |
| "practice": ["Exercises", "Questions", "Problems"], | |
| } | |
| sections_lower = current_sections.lower() | |
| # Check for missing common elements | |
| for element, keywords in common_elements.items(): | |
| if not any(kw.lower() in sections_lower for kw in keywords): | |
| if element == "examples": | |
| suggestions.append("Add 'Examples and Applications' section with real-world use cases") | |
| elif element == "diagrams": | |
| suggestions.append("Add visual diagrams to illustrate complex concepts") | |
| elif element == "summary": | |
| suggestions.append("Add 'Summary' section with key takeaways") | |
| elif element == "practice": | |
| suggestions.append("Consider adding practice questions or exercises") | |
| # Topic-specific suggestions | |
| if missing_aspects: | |
| suggestions.append(f"Consider addressing: {missing_aspects}") | |
| if not suggestions: | |
| return "Notes appear comprehensive. Consider adding:\n- More examples\n- Visual aids\n- Practice problems" | |
| return "\n".join([f"- {s}" for s in suggestions]) | |
| __all__ = ["generate_note_structure", "suggest_note_sections"] | |