QuantumLearner commited on
Commit
135137f
·
verified ·
1 Parent(s): 45e5414

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -101,6 +101,8 @@ question_prompt = (
101
  "Unless retrievable from the documents, don't ask questions which cannot be compared to previous periods."
102
  )
103
 
 
 
104
  async def send_heartbeat(interval=300):
105
  while True:
106
  await asyncio.sleep(interval) # Send heartbeat every 5 minutes
@@ -123,7 +125,11 @@ async def on_chat_start():
123
  # Cancel the heartbeat once the user provides input
124
  heartbeat_task.cancel()
125
 
126
- # Handle the ticker response
 
 
 
 
127
  ticker_symbol = ticker_response['content'].strip().upper()
128
  if not ticker_symbol:
129
  await cl.Message(content="No valid ticker symbol provided. Please restart and enter a valid ticker symbol.").send()
 
101
  "Unless retrievable from the documents, don't ask questions which cannot be compared to previous periods."
102
  )
103
 
104
+ import asyncio
105
+
106
  async def send_heartbeat(interval=300):
107
  while True:
108
  await asyncio.sleep(interval) # Send heartbeat every 5 minutes
 
125
  # Cancel the heartbeat once the user provides input
126
  heartbeat_task.cancel()
127
 
128
+ # Check if ticker_response is None or doesn't contain 'content'
129
+ if ticker_response is None or 'content' not in ticker_response:
130
+ await cl.Message(content="No input received. Please restart and enter a valid ticker symbol.").send()
131
+ return
132
+
133
  ticker_symbol = ticker_response['content'].strip().upper()
134
  if not ticker_symbol:
135
  await cl.Message(content="No valid ticker symbol provided. Please restart and enter a valid ticker symbol.").send()