peterkros commited on
Commit
1526d48
·
verified ·
1 Parent(s): 1577770

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -17
app.py CHANGED
@@ -61,10 +61,10 @@ def generate_response(selected_question):
61
  chat_history.append(new_response)
62
  follow_up_questions = []
63
 
64
- return chat_history, [[q] for q in follow_up_questions]
65
 
66
- def update_examples(follow_up_questions):
67
- return gr.Dataframe.update(value=[[q] for q in follow_up_questions])
68
 
69
  # CSS for the phone layout and background
70
  css = """
@@ -97,6 +97,7 @@ with gr.Blocks(css=css) as demo:
97
  In the realm of digital communication, the development of an advanced chatbot that incorporates topic modeling represents a significant leap towards enhancing user interaction and maintaining focus during conversations. This innovative chatbot design is specifically engineered to streamline discussions by guiding users to select from a curated list of suggested questions. This approach is crafted to mitigate the risk of diverging into off-topic dialogues, which are common pitfalls in conventional chatbot systems.
98
  """
99
  )
 
100
  with gr.Column(scale=1, elem_id="chat-container"):
101
  chatbot = gr.Chatbot(
102
  initialize_chat(),
@@ -110,20 +111,7 @@ with gr.Blocks(css=css) as demo:
110
  txt = gr.Textbox(scale=4, show_label=False, placeholder="Select Question", container=False, interactive=False) # Adjust based on need
111
  btn = gr.Button("Submit")
112
 
113
- examples_df = gr.Dataframe(headers=["Suggested Questions"], datatype="str", interactive=False)
114
-
115
- btn.click(fn=generate_response, inputs=[txt], outputs=[chatbot, examples_df])
116
-
117
- examples = gr.Examples(
118
- examples=[
119
- ["What are the basic requirements to become an airforce pilot?"],
120
- ["How long does it take to train as an airforce pilot?"],
121
- ["Can you describe a day in the life of an airforce pilot?"]
122
- ],
123
- inputs=[txt],
124
- outputs=[chatbot],
125
- label="Select Question"
126
- )
127
 
128
  chatbot.like(print_like_dislike, None, None)
129
 
 
61
  chat_history.append(new_response)
62
  follow_up_questions = []
63
 
64
+ return chat_history, follow_up_questions
65
 
66
+ def update_suggested_questions(follow_up_questions):
67
+ return gr.Markdown.update(value="\n".join(f"* {q}" for q in follow_up_questions))
68
 
69
  # CSS for the phone layout and background
70
  css = """
 
97
  In the realm of digital communication, the development of an advanced chatbot that incorporates topic modeling represents a significant leap towards enhancing user interaction and maintaining focus during conversations. This innovative chatbot design is specifically engineered to streamline discussions by guiding users to select from a curated list of suggested questions. This approach is crafted to mitigate the risk of diverging into off-topic dialogues, which are common pitfalls in conventional chatbot systems.
98
  """
99
  )
100
+ suggested_questions = gr.Markdown("### Suggested Questions:\n\n* No questions yet.")
101
  with gr.Column(scale=1, elem_id="chat-container"):
102
  chatbot = gr.Chatbot(
103
  initialize_chat(),
 
111
  txt = gr.Textbox(scale=4, show_label=False, placeholder="Select Question", container=False, interactive=False) # Adjust based on need
112
  btn = gr.Button("Submit")
113
 
114
+ btn.click(fn=generate_response, inputs=[txt], outputs=[chatbot, suggested_questions])
 
 
 
 
 
 
 
 
 
 
 
 
 
115
 
116
  chatbot.like(print_like_dislike, None, None)
117