patti-j commited on
Commit
81eae11
1 Parent(s): 8c3e2f0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -16,23 +16,25 @@ provide it and then gently inquire if they want to talk about it. If you don't k
16
  "Hmm, I'm not sure." Don't try to make up an answer. If the question is not about mental health or resources,
17
  politely inform them that you are tuned to only answer questions about mental health and well being."""
18
 
19
- class ChatWrapper:
20
- def __init__(self):
21
- def __call__(
22
- self, inp: str, history: str, chain
23
- ):
 
24
 
25
  # Execute the chat functionality.
26
- output = chain({"message": inp, "chat_history": history})["response"]
27
- history.append((inp, output))
28
- return history
29
 
30
- chat = ChatWrapper()
31
- chatbot = gr.Chatbot()
32
 
33
  block = gr.Blocks(css=".gradio-container {background-color: lightblue}")
34
 
35
  with block:
 
 
 
36
  gr.HTML("<center><h2>Omdena AI Chatbot For Mental Health and Well Being</h2></center>")
37
 
38
  gr.HTML("WELCOME<br>"
@@ -44,12 +46,13 @@ with block:
44
  message = gr.Textbox(
45
  label="What would you like to talk about?",
46
  type = "text",
47
- )
48
-
 
49
  with gr.Row():
50
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
51
- submit.click(chat, inputs=[message], outputs=[chat])
52
-
53
  gr.Examples(
54
  examples=[
55
  "I feel lonely",
 
16
  "Hmm, I'm not sure." Don't try to make up an answer. If the question is not about mental health or resources,
17
  politely inform them that you are tuned to only answer questions about mental health and well being."""
18
 
19
+ def respond(message, chat_history):
20
+ bot_message = ["How are you?"]
21
+ chat_history.append((message, bot_message))
22
+ return "", chat_history
23
+
24
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
25
 
26
  # Execute the chat functionality.
27
+ # output = chain({"message": inp, "chat_history": history})["response"]
28
+ # history.append((inp, output))
29
+ # return history
30
 
 
 
31
 
32
  block = gr.Blocks(css=".gradio-container {background-color: lightblue}")
33
 
34
  with block:
35
+
36
+ chatbot = gr.Chatbot()
37
+
38
  gr.HTML("<center><h2>Omdena AI Chatbot For Mental Health and Well Being</h2></center>")
39
 
40
  gr.HTML("WELCOME<br>"
 
46
  message = gr.Textbox(
47
  label="What would you like to talk about?",
48
  type = "text",
49
+ )
50
+ message.submit(respond, [msg, chatbot], [msg, chatbot])
51
+
52
  with gr.Row():
53
  submit = gr.Button(value="Send", variant="secondary").style(full_width=False)
54
+ submit.click(lambda: None, None, chatbot, queue=False)
55
+
56
  gr.Examples(
57
  examples=[
58
  "I feel lonely",