Spaces:
Runtime error
Runtime error
Download tasks/create_learning_profile.py from beautiful-code/ai_workflows: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/beautiful-code/ai_workflows/resolve/main/tasks/create_learning_profile.py
- Command line
-
hf download hf://spaces/beautiful-code/ai_workflows/tasks/create_learning_profile.py
-
curl -L -o create_learning_profile.py https://huggingface.co/spaces/beautiful-code/ai_workflows/resolve/main/tasks/create_learning_profile.py
1.31 kB
| import json | |
| import streamlit as st | |
| from crewai import Task | |
| from crewai.tasks.task_output import TaskOutput | |
| from pydantic import BaseModel | |
| from typing import List | |
| from agents.learning_profiler import learning_profiler | |
| class Topic(BaseModel): | |
| name: str | |
| insights: List[str] | |
| class LearningProfile(BaseModel): | |
| topics_of_interests: List[str] | |
| learnings: List[Topic] | |
| def callback_function(output: TaskOutput): | |
| st.markdown("### Learning profile of the user:") | |
| data=json.loads(output.exported_output) | |
| st.markdown(f"**topics_of_interests:** {data['topics_of_interests'][0]}") | |
| st.markdown(f"**learnings:**") | |
| for topic in data['learnings']: | |
| st.markdown(f"*{topic['name']}*:{topic['insights'][0]}") | |
| learning_profile_task = Task( | |
| description=( | |
| "Create a Learning profile of the user based on " | |
| "the following articles and insights he has read in the past: \n" | |
| "{previous_article_insights}" | |
| ), | |
| expected_output=( | |
| "A structured learning profile of the user with his interests, topics he has read about " | |
| "and insights he has captured on the topics." | |
| ), | |
| agent=learning_profiler, | |
| output_json=LearningProfile, | |
| output_file="learning_profile.json", | |
| async_execution=False, | |
| callback=callback_function | |
| ) | |