Spaces:
Sleeping
Sleeping
update
Browse files
app.py
CHANGED
@@ -91,23 +91,12 @@ span.md.svelte-8tpqd2.chatbot.prose p {
|
|
91 |
}
|
92 |
"""
|
93 |
|
94 |
-
# Initialize chat history
|
95 |
-
chat_history = []
|
96 |
-
|
97 |
# Gradio interface setup
|
98 |
with gr.Blocks(css=custom_css) as demo:
|
99 |
with gr.Row():
|
100 |
with gr.Column(scale=1):
|
101 |
gr.Markdown("<h2>My chats</h2>")
|
102 |
-
|
103 |
-
|
104 |
-
def update_history(history_list):
|
105 |
-
history_md = ""
|
106 |
-
for i, (user_msg, bot_msg) in enumerate(history_list):
|
107 |
-
history_md += f"**Chat {i+1}**\n"
|
108 |
-
history_md += f"**You:** {user_msg}\n\n"
|
109 |
-
history_md += f"**Bot:** {bot_msg}\n\n"
|
110 |
-
return history_md
|
111 |
|
112 |
with gr.Column(scale=3):
|
113 |
gr.Markdown("<h1>Ask a question about the EU AI Act</h1>")
|
@@ -130,17 +119,14 @@ with gr.Blocks(css=custom_css) as demo:
|
|
130 |
previous_message = history[-1][0] # Access the previous user message
|
131 |
bot_message = generate_text(previous_message) # Generate response based on previous message
|
132 |
history[-1][1] = bot_message # Update the last bot message
|
|
|
133 |
|
134 |
-
|
135 |
-
|
136 |
-
return history, update_history(chat_history)
|
137 |
-
|
138 |
-
submit_button.click(fn=user, inputs=[msg, chatbot], outputs=[msg, chatbot], queue=False).then(
|
139 |
-
fn=bot, inputs=[chatbot], outputs=[chatbot, history]
|
140 |
)
|
141 |
-
msg.submit(
|
142 |
-
|
143 |
)
|
144 |
-
clear.click(
|
145 |
|
146 |
demo.launch(share=True)
|
|
|
91 |
}
|
92 |
"""
|
93 |
|
|
|
|
|
|
|
94 |
# Gradio interface setup
|
95 |
with gr.Blocks(css=custom_css) as demo:
|
96 |
with gr.Row():
|
97 |
with gr.Column(scale=1):
|
98 |
gr.Markdown("<h2>My chats</h2>")
|
99 |
+
chat_topics = gr.Markdown("<!-- Dynamic content -->")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
with gr.Column(scale=3):
|
102 |
gr.Markdown("<h1>Ask a question about the EU AI Act</h1>")
|
|
|
119 |
previous_message = history[-1][0] # Access the previous user message
|
120 |
bot_message = generate_text(previous_message) # Generate response based on previous message
|
121 |
history[-1][1] = bot_message # Update the last bot message
|
122 |
+
return history
|
123 |
|
124 |
+
submit_button.click(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
125 |
+
bot, chatbot, chatbot
|
|
|
|
|
|
|
|
|
126 |
)
|
127 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
128 |
+
bot, chatbot, chatbot
|
129 |
)
|
130 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
131 |
|
132 |
demo.launch(share=True)
|