import json import streamlit as st import utils.settings as settings from crewai import Task from crewai.tasks.task_output import TaskOutput from pydantic import BaseModel from typing import List from agents.learning_curator import learning_curator class SuggestedArticle(BaseModel): title: str url: str reason_for_recommendation: str class SuggestedArticles(BaseModel): articles: List[SuggestedArticle] def callback_function(output: TaskOutput): suggested_articles = json.loads(output.exported_output)['articles'] for article in suggested_articles: settings.articles[article['url']] = article st.markdown("### New Article Suggestion task is executed successfully!") article_suggestion_task = Task( description=( "Find 5 articles from the past 10 days that align with the user's learning interests. " "The articles should provide incremental learning to the user based on their insights." ), expected_output=( "List of article titles along with their links. " ), output_json=SuggestedArticles, output_file="article_suggestions.json", agent=learning_curator, async_execution=False, callback=callback_function, )