Spaces:
Runtime error
Runtime error
Harshad Bhandwaldar
commited on
Commit
·
8124efd
1
Parent(s):
2612753
model added
Browse files
app.py
CHANGED
@@ -69,10 +69,15 @@ def getResponse(ints, intents_json):
|
|
69 |
return result
|
70 |
|
71 |
|
72 |
-
def chatbot_response(msg):
|
|
|
|
|
|
|
|
|
73 |
ints = predict_class(msg, model)
|
74 |
res = getResponse(ints, intents)
|
75 |
-
|
|
|
76 |
|
77 |
|
78 |
prompt = "Ask anything ..."
|
@@ -85,6 +90,6 @@ with block:
|
|
85 |
message = gr.Textbox(placeholder=prompt)
|
86 |
state = gr.State()
|
87 |
submit = gr.Button("SEND")
|
88 |
-
submit.click(chatbot_response, inputs=message, outputs=[chatbot, state])
|
89 |
|
90 |
block.launch(debug = True)
|
|
|
69 |
return result
|
70 |
|
71 |
|
72 |
+
def chatbot_response(msg, history):
|
73 |
+
history = history or []
|
74 |
+
s = list(sum(history, ()))
|
75 |
+
s.append(input)
|
76 |
+
inp = ' '.join(s)
|
77 |
ints = predict_class(msg, model)
|
78 |
res = getResponse(ints, intents)
|
79 |
+
history.append((input, res))
|
80 |
+
return history, history
|
81 |
|
82 |
|
83 |
prompt = "Ask anything ..."
|
|
|
90 |
message = gr.Textbox(placeholder=prompt)
|
91 |
state = gr.State()
|
92 |
submit = gr.Button("SEND")
|
93 |
+
submit.click(chatbot_response, inputs=[message, state], outputs=[chatbot, state])
|
94 |
|
95 |
block.launch(debug = True)
|