Spaces:
Runtime error
Runtime error
File size: 1,310 Bytes
1a74bcb f3f99ec 1a74bcb c232c71 1a74bcb c232c71 1a74bcb f8558a4 f3f99ec 68e1277 f3f99ec c232c71 f3f99ec 68e1277 c232c71 1a74bcb f3f99ec | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | 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
)
|