summary and sentiment analysis

This commit is contained in:
Dobromir Popov 2024-01-08 19:18:37 +02:00
parent 17d7316ef9
commit d7b19fbb14
3 changed files with 40 additions and 13 deletions

View File

@ -200,23 +200,25 @@ from agents.webagent import run_web_agent, save_data
async def run_web_agent_and_process_result(topic, folder): async def run_web_agent_and_process_result(topic, folder):
news_data = run_web_agent(topic, folder) news_data = run_web_agent(topic, folder)
# summary = summarize_data(news_data)
print(f"[{datetime.now()}] Doing summarisation and sentiment analysis with an AI model.")
# with open(os.path.join(folder, "summary_log.txt"), 'a') as log_file:
# log_file.write(f"{datetime.now()}: {summary}\n")
# Process the result immediately after obtaining it
user_message = f"Summarize these news and make sentiment analysis on each news and one overall: {news_data}" user_message = f"Summarize these news and make sentiment analysis on each news and one overall: {news_data}"
print(f"[{datetime.now()}] Doing sentiment analysis with AI model.")
start = time.time() start = time.time()
query_result = await query_llm(user_message, "openhermes") query_result = await query_llm(user_message, "openhermes")
print(f"[{datetime.now()}] AI call returned in {time.time() - start} seconds.") print(f"[{datetime.now()}] AI call returned in {time.time() - start} seconds.")
news_data["summary"] = query_result news_data["summary"] = query_result
user_message = "do sentiment analysis on theese news and report overall sentiment for the day from 1 to 100. Here's the current news articles: {news_data}"
start = time.time()
query_result = await query_llm(user_message, "openhermes")
print(f"[{datetime.now()}] AI call returned in {time.time() - start} seconds.")
news_data["sentimen"] = query_result
save_data(news_data, folder) save_data(news_data, folder)
with open(os.path.join(folder, "summary_log.txt"), 'a') as log_file: with open(os.path.join(folder, "summary_log.txt"), 'a') as log_file:
log_file.write(f"{datetime.now()}: {query_result}\n") log_file.write(f"\n\n\n{datetime.now()}: {query_result}\n")
# Process the query_result as needed # Process the query_result as needed
@ -227,7 +229,7 @@ async def async_main():
while True: while True:
await run_web_agent_and_process_result(topic=topic, folder=folder) await run_web_agent_and_process_result(topic=topic, folder=folder)
await asyncio.sleep(interval * 60) # Convert hours to seconds await asyncio.sleep(interval * 3600) # Convert hours to seconds
if __name__ == '__main__': if __name__ == '__main__':
asyncio.run(async_main()) asyncio.run(async_main())

View File

@ -205,8 +205,4 @@ def summarize_data(data):
def run_web_agent(topic, folder): def run_web_agent(topic, folder):
print(f"[{datetime.now()}] Running web agent for topic: {topic}") print(f"[{datetime.now()}] Running web agent for topic: {topic}")
news_data = search_news(topic) news_data = search_news(topic)
# save_data(news_data, folder)
# summary = summarize_data(news_data)
# with open(os.path.join(folder, "summary_log.txt"), 'a') as log_file:
# log_file.write(f"{datetime.now()}: {summary}\n")
return news_data return news_data

View File

@ -0,0 +1,29 @@
2024-01-08 19:03:20.959400: Here are the headlines from the past day that you may find interesting:
1. "Tesla (TSLA), BYD Will Stay Ahead of Volkswagen (VW) For Years To Come"
2. "Elon Musk's Drug Use Is the Latest Headache for Tesla's Board"
3. "Tesla FSD beta v12 could see wider release later this month"
4. "Could this be our first look at the updated Tesla Model Y?"
5. "Cleantech News — #1 In EV, Solar, Wind, Tesla News"
6. "Tesla Stock Price | TSLA Stock Quote, News, and History | Markets Insider"
7. "Tesla, SpaceX execs worried about Musk's illicit drug use: report"
8. "Tesla driver dead after crashing into Uber in downtown Houston"
These headlines cover a range of topics related to Tesla, from the company's positioning against competitors like BYD and Volkswagen to concerns around Elon Musk's personal habits and their impact on Tesla's image. There are also updates on the progress of Tesla's Full Self-Driving Beta v12 and the updated Model Y, as well as news on Tesla stock prices and a tragic accident involving a Tesla driver.
2024-01-08 19:10:28.420392: 2. CleanTechnica: GM Inches Out Ford In EV Sales In 2023 — Charts
According to the article, General Motors (GM) was the leader of the US EV market among legacy automakers for several years and has now edged out Ford in EV sales in 2023. The article cites data from EV Sales Blog, which shows that GM sold a total of 471,196 electric vehicles in the United States last year, while Ford sold a total of 458,875 electric vehicles during the same period. This represents an increase of 68% and 39%, respectively, compared to their EV sales in 2022. Additionally, GM's EV market share was 18.4%, while Ford's was 17.7%. The article also notes that Tesla, which is not a legacy automaker, sold a total of 463,701 electric vehicles in the US last year, giving it a market share of 16.9%.
The data suggests that GM has managed to maintain its position as the leader in EV sales among legacy automakers despite increased competition from Ford and other players in the market. However, it is worth noting that Tesla still holds a significant market share in the US EV market, even though it is not considered a legacy automaker.
3. InvestorsObserver: XING Mobility Debuts Next Generation Immersion Cooling Battery, the Game Changer for Electric Vehicles & Utility Power
XING Mobility, a Taiwanese company, has debuted its next-generation immersion cooling battery, which it claims could be a game changer for electric vehicles and utility power. The company's Cell-to-Pack architecture enables higher energy density, better safety, and lower costs compared to conventional batteries. Additionally, the high-volume XM25 system has been unveiled, along with groundbreaking safety test results.
The debut of this new technology could potentially revolutionize the EV industry by providing a safer, more efficient, and cost-effective battery solution. However, it is not clear when or if this technology will be commercialized and made available to the market.
4. GlobeNewswire: Bragar Eagel & Squire, P.C. Reminds Investors That Class Action Lawsuits Have Been Filed Against Mercury Systems, and onsemi and Encourages Investors to Contact the Firm
Bragar Eagel & Squire, P.C., a shareholder rights law firm, is reminding investors that class actions have been commenced against Mercury Systems, Inc. (NASDAQ: MRCY) and ON Semiconductor Corporation (NASDAQ: ON). The firm encourages investors to contact them if they suffered losses while holding shares of these companies between specified dates.
The lawsuits allege that the companies made false and/or misleading statements and/or failed to disclose important information about their financial condition, business operations, and prospects. Investors who purchased shares of these companies during the class period may be eligible for compensation if it is determined that the companies violated securities laws. However, it is not clear what potential outcome or settlement may result from these lawsuits.