Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -48,9 +48,15 @@ def chat(message, history=None):
|
|
48 |
if history is None:
|
49 |
history = []
|
50 |
message = message.lower()
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
for tg in data["intents"]:
|
56 |
if tg['tag'] == tag:
|
@@ -58,12 +64,11 @@ def chat(message, history=None):
|
|
58 |
response = random.choice(responses)
|
59 |
break
|
60 |
else:
|
61 |
-
response = "
|
62 |
|
63 |
history.append((message, response))
|
64 |
return history, history
|
65 |
|
66 |
-
|
67 |
chatbot = gr.Chatbot(label="Chat")
|
68 |
css = """
|
69 |
footer {display:none !important}
|
|
|
48 |
if history is None:
|
49 |
history = []
|
50 |
message = message.lower()
|
51 |
+
|
52 |
+
try:
|
53 |
+
results = model.predict([bag_of_words(message, words)])
|
54 |
+
results_index = np.argmax(results)
|
55 |
+
tag = labels[results_index]
|
56 |
+
except Exception as e:
|
57 |
+
response = "I'm sorry, I couldn't understand your message."
|
58 |
+
history.append((message, response))
|
59 |
+
return history, history
|
60 |
|
61 |
for tg in data["intents"]:
|
62 |
if tg['tag'] == tag:
|
|
|
64 |
response = random.choice(responses)
|
65 |
break
|
66 |
else:
|
67 |
+
response = "I'm sorry, I don't have a response for that."
|
68 |
|
69 |
history.append((message, response))
|
70 |
return history, history
|
71 |
|
|
|
72 |
chatbot = gr.Chatbot(label="Chat")
|
73 |
css = """
|
74 |
footer {display:none !important}
|