sharsh02 commited on
Commit
a461cd7
1 Parent(s): be7bad2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -346,22 +346,23 @@ def generate_final_response(prompt, history):
346
  print("Final Ticker: ", ticker)
347
  print("Getting into raw_news()")
348
  try:
349
- context_file, ticker_stats, ticker_financials, reports, news_link = raw_news(prompt, chat_completion_params["todays_news_flag"], ticker)
 
 
350
  print(f"Generating response for **{prompt}**")
351
  env = Environment(loader=FileSystemLoader("templates/"), autoescape=True)
352
  # env.globals['include'] = lambda filename: env.loader.get_source(env, filename)[0]
353
  template = env.get_template("system_prompt.txt")
354
- for response_type in ["Response-1"]:
355
- content = template.render(todays_date=todays_date,ticker_financials=ticker_financials,response_type=response_type,chat_completion_params=chat_completion_params,context_file=context_file,question=question,ticker=ticker, ticker_stats = ticker_stats, reports=reports, news_link=news_link)
356
- print(content)
357
- output=""
358
- try:
359
- stream = client.text_generation(content, **generate_kwargs, stream=True, details=True, return_full_text=True)
360
- for response in stream:
361
- output += response.token.text
362
- yield output
363
- except StopAsyncIteration:
364
- yield "Sorry, could you provide more details to clarify your query"
365
  except:
366
  yield "Sorry, your query couldn't be processed. Retry with correct name of stock"
367
  except:
 
346
  print("Final Ticker: ", ticker)
347
  print("Getting into raw_news()")
348
  try:
349
+ if not chat_completion_params['generic_query']:
350
+ context_file, ticker_stats, ticker_financials, reports, news_link = raw_news(prompt, chat_completion_params["todays_news_flag"], ticker)
351
+
352
  print(f"Generating response for **{prompt}**")
353
  env = Environment(loader=FileSystemLoader("templates/"), autoescape=True)
354
  # env.globals['include'] = lambda filename: env.loader.get_source(env, filename)[0]
355
  template = env.get_template("system_prompt.txt")
356
+ content = template.render(todays_date=todays_date,ticker_financials=ticker_financials or None,response_type="Response-1",chat_completion_params=chat_completion_params,context_file=context_file or None,question=question,ticker=ticker, ticker_stats = ticker_stats or None, reports=reports or None, news_link=news_link or None)
357
+ print(content)
358
+ output=""
359
+ try:
360
+ stream = client.text_generation(content, **generate_kwargs, stream=True, details=True, return_full_text=True)
361
+ for response in stream:
362
+ output += response.token.text
363
+ yield output
364
+ except StopAsyncIteration:
365
+ yield "Sorry, could you provide more details to clarify your query"
 
366
  except:
367
  yield "Sorry, your query couldn't be processed. Retry with correct name of stock"
368
  except: