diff --git a/rss_summarizer/rss_summarizer/Cargo.toml b/rss_summarizer/rss_summarizer/Cargo.toml index d12e114..5064bb1 100644 --- a/rss_summarizer/rss_summarizer/Cargo.toml +++ b/rss_summarizer/rss_summarizer/Cargo.toml @@ -4,11 +4,11 @@ version = "0.1.0" edition = "2021" [dependencies] -rig-core = "0.0.6" +rig-core = "0.7.0" serde = { version = "1.0", features = ["derive"] } schemars = "0.8" tokio = { version = "1.34", features = ["full"] } chrono = { version = "0.4", features = ["serde"] } -reqwest = { version = "0.11", features = ["json"] } +reqwest = { version = "0.12", features = ["json"] } rss = "2.0" regex = "1" \ No newline at end of file diff --git a/rss_summarizer/rss_summarizer/src/main.rs b/rss_summarizer/rss_summarizer/src/main.rs index 639175f..47a02ee 100644 --- a/rss_summarizer/rss_summarizer/src/main.rs +++ b/rss_summarizer/rss_summarizer/src/main.rs @@ -1,13 +1,12 @@ -use rig::providers::openai::Client; -use schemars::{JsonSchema, schema_for}; -use serde::{Deserialize, Serialize}; use chrono::{DateTime, Utc}; +use regex::Regex; use reqwest; +use rig::providers::openai; use rss::Channel; -use tokio::time::{self, Duration}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use std::error::Error; -use regex::Regex; -use std::iter::FromIterator; +use tokio::time::{self, Duration}; #[derive(Debug, Deserialize, Serialize, JsonSchema)] struct SummarizedRssItem { @@ -60,15 +59,17 @@ fn sanitize_string(input: &str) -> String { async fn summarize_rss_feed(channel: Channel) -> Result> { // Initialize the OpenAI client - let openai_client = Client::from_env(); + let openai_client = openai::Client::from_env(); // Create the extractor let extractor = openai_client - .extractor::("gpt-4") - .preamble("You are an AI assistant specialized in summarizing RSS feeds. \ + .extractor::(openai::GPT_4) + .preamble( + "You are an AI assistant specialized in summarizing RSS feeds. \ Your task is to analyze the RSS items, extract the most relevant information, \ and provide concise summaries. For each item, provide a brief summary and a \ - relevance score from 0.0 to 1.0. Also, provide an overall summary of the feed.") + relevance score from 0.0 to 1.0. Also, provide an overall summary of the feed.", + ) .build(); // Convert RSS items to a format suitable for summarization @@ -86,7 +87,9 @@ async fn summarize_rss_feed(channel: Channel) -> Result Result<(), Box> { loop { interval.tick().await; - + match fetch_rss_feed(rss_url).await { - Ok(channel) => { - match summarize_rss_feed(channel).await { - Ok(rss_summary) => { - pretty_print_summary(&rss_summary); - } - Err(e) => eprintln!("Error summarizing RSS feed: {}", e), + Ok(channel) => match summarize_rss_feed(channel).await { + Ok(rss_summary) => { + pretty_print_summary(&rss_summary); } - } + Err(e) => eprintln!("Error summarizing RSS feed: {}", e), + }, Err(e) => eprintln!("Error fetching RSS feed: {}", e), } }