sharsh02 commited on
Commit
368bcfb
1 Parent(s): 8d2d650

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -37
app.py CHANGED
@@ -333,15 +333,6 @@ async def get_google_news(queries):
333
  return results
334
 
335
 
336
-
337
- # Function to extract links starting with 'url ='
338
- async def extract_links_bing(text):
339
- # Regular expression pattern to match links starting with 'url ='
340
- pattern = r"url\s*=\s*\"(https?://[^\"]+)\"
341
- # Find all matches using re.findall
342
- links = re.findall(pattern, text)
343
- return links
344
-
345
  # Function to scrape headings and body from a webpage
346
  async def scrape_webpage(url):
347
  # Fetch the HTML content of the webpage
@@ -403,17 +394,13 @@ async def format_prompt(message, history):
403
 
404
  @time_logger
405
  async def generate_function_call(prompt):
406
- # temperature = float(temperature)
407
- # if temperature < 1e-2:
408
- # temperature = 1e-2
409
- # top_p = float(top_p)
410
 
411
  generate_kwargs = dict(
412
- temperature=0.001,
413
- max_new_tokens=1024,
414
- top_p=0.95,
415
  repetition_penalty=1.0,
416
- do_sample=True,
417
  seed=42,
418
  )
419
 
@@ -425,13 +412,10 @@ async def generate_function_call(prompt):
425
  stream = client.text_generation(content, **generate_kwargs, stream=True, details=True, return_full_text=True)
426
  for response in stream:
427
  output += response.token.text
428
- # logging.info("Raw output from LLM: %s", output)
429
- # logging.info("Datatype: %s", type(output))
430
  pattern = r'\{[^{}]*\}'
431
  # Find all matches
432
  match = re.search(pattern, output)
433
  extracted_string = match.group(0)
434
- # logging.info("Extracted string from response: %s", extracted_string)
435
  output = json.loads(extracted_string)
436
  return output
437
 
@@ -440,13 +424,9 @@ async def count_words(text):
440
  return f"{len(words)} words"
441
 
442
  async def generate_final_response(prompt, history, context_files=[], ticker_stats=[], reports=[], ticker_financials=[], news_link=[], earning_link=[], news_googles=[]):
443
- # temperature = float(temperature)
444
- # if temperature < 1e-2:
445
- # temperature = 1e-2
446
- # top_p = float(top_p)
447
  global display_ticker
448
  logging.info("\n\n\n\nCurrent Value of GLOBAL TICKER: %s",display_ticker)
449
- generate_kwargs = dict(temperature=0.001,max_new_tokens=1024,top_p=0.95,repetition_penalty=1.0,do_sample=True,seed=42)
450
  today = datetime.date.today()
451
  todays_date = today.strftime('%d%B%Y')
452
  question = await format_prompt(prompt, history)
@@ -488,7 +468,6 @@ async def generate_final_response(prompt, history, context_files=[], ticker_stat
488
  logging.info(f"Generating response for **{question}**")
489
  display_ticker = ticker if ticker else [0]
490
  env = Environment(loader=FileSystemLoader("templates/"), autoescape=True)
491
- # env.globals['include'] = lambda filename: env.loader.get_source(env, filename)[0]
492
  template = env.get_template("system_prompt.txt")
493
  content = template.render(todays_date=todays_date,ticker_financials=ticker_financials ,response_type="Response-1",chat_completion_params=chat_completion_params,context_file=context_files, question=question,ticker=ticker, ticker_stats = ticker_stats, reports=reports, news_link=news_link, earnings = earning_link, news_googles=news_googles)
494
  token_size = await count_words(content)
@@ -518,17 +497,7 @@ function refresh() {
518
  }
519
  }
520
  """
521
- # theme = "JohnSmith9982/small_and_pretty"
522
- # theme = "gary109/HaleyCH_Theme"
523
- # theme = "derekzen/stardust"
524
- # theme = "Taithrah/Minimal
525
- # theme = "rottenlittlecreature/Moon_Goblin"
526
- # theme = "xiaobaiyuan/theme_brief"
527
- # theme = "gary109/Emerald_Isle"
528
- # theme = "gradio/seafoam"
529
-
530
- # mychatbot = gr.Chatbot(
531
- # avatar_images=[None, "./agent.png"], bubble_full_width=False, show_label=False, show_copy_button=True, likeable=True, min_width=300)
532
  my_chatbot = gr.Chatbot(
533
  label="Ask Anything",
534
  show_label=True,
 
333
  return results
334
 
335
 
 
 
 
 
 
 
 
 
 
336
  # Function to scrape headings and body from a webpage
337
  async def scrape_webpage(url):
338
  # Fetch the HTML content of the webpage
 
394
 
395
  @time_logger
396
  async def generate_function_call(prompt):
 
 
 
 
397
 
398
  generate_kwargs = dict(
399
+ temperature=0.05,
400
+ max_new_tokens=200,
401
+ top_p=0.99,
402
  repetition_penalty=1.0,
403
+ do_sample=False,
404
  seed=42,
405
  )
406
 
 
412
  stream = client.text_generation(content, **generate_kwargs, stream=True, details=True, return_full_text=True)
413
  for response in stream:
414
  output += response.token.text
 
 
415
  pattern = r'\{[^{}]*\}'
416
  # Find all matches
417
  match = re.search(pattern, output)
418
  extracted_string = match.group(0)
 
419
  output = json.loads(extracted_string)
420
  return output
421
 
 
424
  return f"{len(words)} words"
425
 
426
  async def generate_final_response(prompt, history, context_files=[], ticker_stats=[], reports=[], ticker_financials=[], news_link=[], earning_link=[], news_googles=[]):
 
 
 
 
427
  global display_ticker
428
  logging.info("\n\n\n\nCurrent Value of GLOBAL TICKER: %s",display_ticker)
429
+ generate_kwargs = dict(temperature=0.05,max_new_tokens=2048,top_p=0.99,repetition_penalty=1.0,do_sample=False,seed=42)
430
  today = datetime.date.today()
431
  todays_date = today.strftime('%d%B%Y')
432
  question = await format_prompt(prompt, history)
 
468
  logging.info(f"Generating response for **{question}**")
469
  display_ticker = ticker if ticker else [0]
470
  env = Environment(loader=FileSystemLoader("templates/"), autoescape=True)
 
471
  template = env.get_template("system_prompt.txt")
472
  content = template.render(todays_date=todays_date,ticker_financials=ticker_financials ,response_type="Response-1",chat_completion_params=chat_completion_params,context_file=context_files, question=question,ticker=ticker, ticker_stats = ticker_stats, reports=reports, news_link=news_link, earnings = earning_link, news_googles=news_googles)
473
  token_size = await count_words(content)
 
497
  }
498
  }
499
  """
500
+
 
 
 
 
 
 
 
 
 
 
501
  my_chatbot = gr.Chatbot(
502
  label="Ask Anything",
503
  show_label=True,