Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -66,42 +66,62 @@ def generate_response(selected_question):
|
|
66 |
def update_examples(follow_up_questions):
|
67 |
return gr.Dataframe.update(value=[[q] for q in follow_up_questions])
|
68 |
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
label="Safe Chatbot v1",
|
82 |
-
avatar_images=(None, os.path.join(os.getcwd(), "avatar.png"))
|
83 |
-
)
|
84 |
-
|
85 |
-
with gr.Row():
|
86 |
-
txt = gr.Textbox(scale=4, show_label=False, placeholder="Select Question", container=False, interactive=False) # Adjust based on need
|
87 |
-
btn = gr.Button("Submit")
|
88 |
|
89 |
-
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
|
|
|
|
|
|
|
|
103 |
|
104 |
-
|
105 |
|
106 |
if __name__ == "__main__":
|
107 |
-
demo.launch(share=
|
|
|
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 = """
|
71 |
+
#chat-container {
|
72 |
+
max-width: 400px;
|
73 |
+
margin: auto;
|
74 |
+
border: 1px solid #ccc;
|
75 |
+
border-radius: 20px;
|
76 |
+
overflow: hidden;
|
77 |
+
background: url('https://path-to-your-phone-background-image.png') no-repeat center center;
|
78 |
+
background-size: cover;
|
79 |
+
height: 700px;
|
80 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
#chatbot {
|
83 |
+
height: calc(100% - 50px);
|
84 |
+
overflow-y: auto;
|
85 |
+
}
|
86 |
+
"""
|
87 |
|
88 |
+
with gr.Blocks(css=css) as demo:
|
89 |
+
with gr.Box(elem_id="chat-container"):
|
90 |
+
gr.Markdown(
|
91 |
+
"""
|
92 |
+
# Child safe chatbot project!
|
93 |
+
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.
|
94 |
+
"""
|
95 |
+
)
|
96 |
+
|
97 |
+
chatbot = gr.Chatbot(
|
98 |
+
initialize_chat(),
|
99 |
+
elem_id="chatbot",
|
100 |
+
bubble_full_width=False,
|
101 |
+
label="Safe Chatbot v1",
|
102 |
+
avatar_images=(None, os.path.join(os.getcwd(), "avatar.png"))
|
103 |
+
)
|
104 |
+
|
105 |
+
with gr.Row():
|
106 |
+
txt = gr.Textbox(scale=4, show_label=False, placeholder="Select Question", container=False, interactive=False) # Adjust based on need
|
107 |
+
btn = gr.Button("Submit")
|
108 |
|
109 |
+
examples_df = gr.Dataframe(headers=["Suggested Questions"], datatype="str", interactive=False)
|
110 |
+
|
111 |
+
btn.click(fn=generate_response, inputs=[txt], outputs=[chatbot, examples_df])
|
112 |
+
|
113 |
+
examples = gr.Examples(
|
114 |
+
examples=[
|
115 |
+
["What are the basic requirements to become an airforce pilot?"],
|
116 |
+
["How long does it take to train as an airforce pilot?"],
|
117 |
+
["Can you describe a day in the life of an airforce pilot?"]
|
118 |
+
],
|
119 |
+
inputs=[txt],
|
120 |
+
outputs=[chatbot],
|
121 |
+
label="Select Question"
|
122 |
+
)
|
123 |
|
124 |
+
chatbot.like(print_like_dislike, None, None)
|
125 |
|
126 |
if __name__ == "__main__":
|
127 |
+
demo.launch(share=True)
|