sharsh02 commited on
Commit
65cd15e
1 Parent(s): c2dcc21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -365,13 +365,14 @@ async def trade_setup():
365
 
366
 
367
  @time_logger
368
- async def get_google_news(queries):
369
  try:
370
  results=[] ## checking
371
  task = []
372
 
373
  async def duckduckgo_search(query):
374
- results = DDGS().news(query, max_results=10, timelimit="w")
 
375
  news = [{f"[{doc['title']}]({doc['url']})": doc['body'] for doc in results}]
376
  return news
377
 
@@ -391,7 +392,7 @@ async def get_google_news(queries):
391
  async def get_duckai_news(queries):
392
 
393
  task = []
394
- results = await get_google_news(queries)
395
  prompt = """#Instruction:
396
  Summarise the impactful points of the news and mention the news link and date of publish at the end if available
397
  #Format:
@@ -444,7 +445,7 @@ async def raw_news(raw_query, subqueries, todays_news_func_call, ticker):
444
  swot_analysis_link = f'https://widgets.trendlyne.com/web-widget/swot-widget/Poppins/{urllib.parse.quote(ticker)}/'
445
  tasks = [get_the_ticker_stat(ticker),
446
  get_the_ticker_news(ticker),
447
- get_google_news(subqueries),
448
  scrape_webpage(swot_analysis_link)]
449
  try:
450
  ticker_stats, ticker_news, google_news, swot_analysis = await asyncio.gather(*tasks)
@@ -555,7 +556,7 @@ def generate_final_response(prompt, history):
555
  news_link.append(asyncio.run(get_duckai_news(subqueries)))
556
  elif chat_completion_params['todays_news_flag'] and len(ticker)>0:
557
  for tick in chat_completion_params["stock_name"]:
558
- news_googles.append(f"Latest News for {tick}\n\n {asyncio.run(get_google_news(subqueries))}")
559
  elif (chat_completion_params['follow_up_query'] and ticker_stats != []) or (display_ticker == ticker and ticker_stats != []):
560
  # logging.info("\n\nAssigned into a followup query\n\n")
561
  chat_completion_params['follow_up_query'] = True
 
365
 
366
 
367
  @time_logger
368
+ async def get_google_news(queries, max_results = 3):
369
  try:
370
  results=[] ## checking
371
  task = []
372
 
373
  async def duckduckgo_search(query):
374
+ query = query + "+blogs"
375
+ results = DDGS().news(query, max_results, timelimit="w")
376
  news = [{f"[{doc['title']}]({doc['url']})": doc['body'] for doc in results}]
377
  return news
378
 
 
392
  async def get_duckai_news(queries):
393
 
394
  task = []
395
+ results = await get_google_news(queries,3)
396
  prompt = """#Instruction:
397
  Summarise the impactful points of the news and mention the news link and date of publish at the end if available
398
  #Format:
 
445
  swot_analysis_link = f'https://widgets.trendlyne.com/web-widget/swot-widget/Poppins/{urllib.parse.quote(ticker)}/'
446
  tasks = [get_the_ticker_stat(ticker),
447
  get_the_ticker_news(ticker),
448
+ get_google_news(subqueries,10),
449
  scrape_webpage(swot_analysis_link)]
450
  try:
451
  ticker_stats, ticker_news, google_news, swot_analysis = await asyncio.gather(*tasks)
 
556
  news_link.append(asyncio.run(get_duckai_news(subqueries)))
557
  elif chat_completion_params['todays_news_flag'] and len(ticker)>0:
558
  for tick in chat_completion_params["stock_name"]:
559
+ news_googles.append(f"Latest News for {tick}\n\n {asyncio.run(get_google_news(subqueries,10))}")
560
  elif (chat_completion_params['follow_up_query'] and ticker_stats != []) or (display_ticker == ticker and ticker_stats != []):
561
  # logging.info("\n\nAssigned into a followup query\n\n")
562
  chat_completion_params['follow_up_query'] = True