Warisamm748 commited on
Commit
9e506aa
·
verified ·
1 Parent(s): 8d8f16e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -3
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import streamlit as st
2
  import requests
3
  from bs4 import BeautifulSoup
4
- from langchain.schema import HumanMessage
5
  from langchain_groq import ChatGroq
6
  import json
7
  import os
@@ -147,12 +147,11 @@ def generate_final_sentiment(news_data, sentiment_counts):
147
  - Negative articles: {sentiment_counts['Negative']}
148
  - Neutral articles: {sentiment_counts['Neutral']}
149
 
150
- The following are the summarized key points from the articles: "{combined_summaries}".
151
-
152
  Provide a single, concise summary that integrates the overall sentiment analysis and key news highlights while maintaining a natural flow. Explain its implications for the company's reputation, stock potential, and public perception.
153
 
154
  Respond **ONLY** with a well-structured very concise and short paragraph in plain text, focusing on overall sentiment.
155
  """
 
156
  response = llm.invoke([HumanMessage(content=prompt)], max_tokens=200)
157
  final_sentiment = response if response else "Sentiment analysis summary not available."
158
  return final_sentiment.content
 
1
  import streamlit as st
2
  import requests
3
  from bs4 import BeautifulSoup
4
+ from langchain_core.messages import HumanMessage # แก้ไขตรงนี้
5
  from langchain_groq import ChatGroq
6
  import json
7
  import os
 
147
  - Negative articles: {sentiment_counts['Negative']}
148
  - Neutral articles: {sentiment_counts['Neutral']}
149
 
 
 
150
  Provide a single, concise summary that integrates the overall sentiment analysis and key news highlights while maintaining a natural flow. Explain its implications for the company's reputation, stock potential, and public perception.
151
 
152
  Respond **ONLY** with a well-structured very concise and short paragraph in plain text, focusing on overall sentiment.
153
  """
154
+ # ใช้ HumanMessage จาก langchain_core.messages
155
  response = llm.invoke([HumanMessage(content=prompt)], max_tokens=200)
156
  final_sentiment = response if response else "Sentiment analysis summary not available."
157
  return final_sentiment.content