Shreyas94 commited on
Commit
11b62a8
·
verified ·
1 Parent(s): d545310

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -30,14 +30,15 @@ except Exception as e:
30
  # Function to fetch news from Google News RSS feed
31
  def fetch_news(term, num_results=2):
32
  logger.debug(f"Fetching news for term: {term}")
33
- url = f"https://news.google.com/rss/search?q={term}"
 
34
  feed = feedparser.parse(url)
35
  results = []
36
  for entry in feed.entries[:num_results]:
37
  results.append({"link": entry.link, "text": entry.title})
38
  logger.debug(f"Fetched news results: {results}")
39
  return results
40
-
41
  # Function to format the prompt for the language model
42
  def format_prompt(user_prompt, chat_history):
43
  logger.debug(f"Formatting prompt with user prompt: {user_prompt} and chat history: {chat_history}")
 
30
  # Function to fetch news from Google News RSS feed
31
  def fetch_news(term, num_results=2):
32
  logger.debug(f"Fetching news for term: {term}")
33
+ encoded_term = urllib.parse.quote(term)
34
+ url = f"https://news.google.com/rss/search?q={encoded_term}"
35
  feed = feedparser.parse(url)
36
  results = []
37
  for entry in feed.entries[:num_results]:
38
  results.append({"link": entry.link, "text": entry.title})
39
  logger.debug(f"Fetched news results: {results}")
40
  return results
41
+
42
  # Function to format the prompt for the language model
43
  def format_prompt(user_prompt, chat_history):
44
  logger.debug(f"Formatting prompt with user prompt: {user_prompt} and chat history: {chat_history}")