Spaces:
Runtime error
Runtime error
File size: 1,736 Bytes
1a74bcb e4fabe5 c232c71 1a74bcb 4ad7a82 60ce749 c232c71 60ce749 f8558a4 60ce749 1a74bcb c232c71 e4fabe5 c232c71 60ce749 c232c71 60ce749 c232c71 60ce749 e4fabe5 | 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 46 47 48 49 50 51 52 53 54 | 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 workflows.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]
)
|