qq1023 commited on
Commit
ed21393
·
1 Parent(s): 8bc195d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -148,17 +148,28 @@ def parse(category, chatbot):
148
  global PARSING_REGEXP
149
 
150
 
151
-
152
- try:
153
- answer = next(chatbot)[1]
154
- except StopIteration:
155
- answer = ""
 
 
 
 
 
 
 
 
 
 
156
 
157
  if category not in Category.__members__:
158
  # Handle the case when an invalid category is provided
159
  answer="test"
160
 
161
  #category = Category[category]
 
162
  chain = categories.category_modules[category].chain
163
  yield {"status": "Parsing response..."}
164
  try:
 
148
  global PARSING_REGEXP
149
 
150
 
151
+ chatbot_responses = []
152
+
153
+ for response in chatbot:
154
+ chatbot_responses.append(response[1])
155
+
156
+ if not chatbot_responses:
157
+ # Handle the case when there are no chatbot responses
158
+ return {"status": "No responses available"}
159
+
160
+ answer = chatbot_responses[-1]
161
+
162
+ # try:
163
+ # answer = next(chatbot)[1]
164
+ # except StopIteration:
165
+ # answer = ""
166
 
167
  if category not in Category.__members__:
168
  # Handle the case when an invalid category is provided
169
  answer="test"
170
 
171
  #category = Category[category]
172
+
173
  chain = categories.category_modules[category].chain
174
  yield {"status": "Parsing response..."}
175
  try: