Spaces:
Runtime error
Runtime error
| 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.curiosity_catalyst import curiosity_catalyst | |
| from tools.scrape_website import scrape_tool | |
| from tasks.create_learning_profile import learning_profile_task | |
| from tasks.evaluate_articles import evaluation_task | |
| class PitchedArticle(BaseModel): | |
| title: str | |
| url: str | |
| pitch: str | |
| class PitchedArticles(BaseModel): | |
| articles: List[PitchedArticle] | |
| def callback_function(output: TaskOutput): | |
| evaluated_articles = json.loads(output.exported_output) | |
| st.markdown(evaluated_articles) | |
| for article in evaluated_articles['articles']: | |
| settings.articles[article['url']]['pitch'] = article['pitch'] | |
| st.markdown("### Create Article Pitch is executed successfully!") | |
| article_pitch_task = Task( | |
| description=( | |
| "Create a pitch only for the articles that have been evaluated and no other links. " | |
| "Craft the pitch so to that it teases the article's most intriguing aspects, " | |
| "by posing questions that the article might answer or " | |
| "highlighting surprising facts to pique the user's curiosity " | |
| " to read the article for incremental learning." | |
| ), | |
| expected_output=( | |
| "List of all the artilces that have been evaluated phase along with their url and pitch statement and no other new urls." | |
| ), | |
| output_json=PitchedArticles, | |
| output_file="pitched_articles.json", | |
| tools=[scrape_tool], | |
| agent=curiosity_catalyst, | |
| async_execution=False, | |
| callback=callback_function, | |
| context=[learning_profile_task, evaluation_task] | |
| ) | |