Spaces:
Running
Running
Update app.py
Browse files
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 |
-
|
|
|
|
|
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 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
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:
|