Update app.py
Browse files
app.py
CHANGED
@@ -202,6 +202,24 @@ def upload_file_handler(files):
|
|
202 |
return files
|
203 |
return []
|
204 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
# Custom CSS for a sleek design
|
206 |
custom_css = """
|
207 |
.gradio-container {
|
@@ -299,6 +317,14 @@ with gr.Blocks(css=custom_css, title="Data Science Requirements Gathering Agent"
|
|
299 |
bubble_full_width=False,
|
300 |
elem_classes=["chat-container"]
|
301 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
302 |
|
303 |
with gr.Row():
|
304 |
with gr.Column(scale=4):
|
@@ -310,6 +336,10 @@ with gr.Blocks(css=custom_css, title="Data Science Requirements Gathering Agent"
|
|
310 |
)
|
311 |
with gr.Column(scale=1):
|
312 |
send_btn = gr.Button("Send π€", variant="primary", elem_classes=["btn-primary"])
|
|
|
|
|
|
|
|
|
313 |
|
314 |
with gr.Row():
|
315 |
clear_btn = gr.Button("Clear Chat ποΈ", variant="secondary", elem_classes=["btn-secondary"])
|
@@ -377,6 +407,12 @@ with gr.Blocks(css=custom_css, title="Data Science Requirements Gathering Agent"
|
|
377 |
clear_chat,
|
378 |
outputs=[chatbot, chat_history, file_cache]
|
379 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
380 |
|
381 |
file_upload.change(
|
382 |
lambda files: files,
|
|
|
202 |
return files
|
203 |
return []
|
204 |
|
205 |
+
def generate_plan(history, file_cache):
|
206 |
+
"""Generate a plan using the planning prompt and Gemini API"""
|
207 |
+
|
208 |
+
# Build conversation history
|
209 |
+
conversation_history = ""
|
210 |
+
if history:
|
211 |
+
for user_msg, ai_msg in history:
|
212 |
+
conversation_history += f"User: {user_msg}\n"
|
213 |
+
if ai_msg:
|
214 |
+
conversation_history += f"Assistant: {ai_msg}\n"
|
215 |
+
|
216 |
+
# Format the prompt
|
217 |
+
formatted_prompt = hf_query_gen_prompt + "\n\n" + conversation_history
|
218 |
+
|
219 |
+
# Get plan from Gemini
|
220 |
+
plan = generate_with_gemini(formatted_prompt, "Planning with gemini")
|
221 |
+
return plan
|
222 |
+
|
223 |
# Custom CSS for a sleek design
|
224 |
custom_css = """
|
225 |
.gradio-container {
|
|
|
317 |
bubble_full_width=False,
|
318 |
elem_classes=["chat-container"]
|
319 |
)
|
320 |
+
|
321 |
+
plan_output = gr.Textbox(
|
322 |
+
label="Generated Plan",
|
323 |
+
interactive=False,
|
324 |
+
visible=True,
|
325 |
+
lines=10,
|
326 |
+
max_lines=20
|
327 |
+
)
|
328 |
|
329 |
with gr.Row():
|
330 |
with gr.Column(scale=4):
|
|
|
336 |
)
|
337 |
with gr.Column(scale=1):
|
338 |
send_btn = gr.Button("Send π€", variant="primary", elem_classes=["btn-primary"])
|
339 |
+
|
340 |
+
with gr.Column(scale=1):
|
341 |
+
plan_btn = gr.Button("Generate Plan π", variant="secondary", elem_classes=["btn-secondary"])
|
342 |
+
|
343 |
|
344 |
with gr.Row():
|
345 |
clear_btn = gr.Button("Clear Chat ποΈ", variant="secondary", elem_classes=["btn-secondary"])
|
|
|
407 |
clear_chat,
|
408 |
outputs=[chatbot, chat_history, file_cache]
|
409 |
)
|
410 |
+
|
411 |
+
plan_btn.click(
|
412 |
+
generate_plan,
|
413 |
+
inputs=[chat_history, file_cache],
|
414 |
+
outputs=[plan_output]
|
415 |
+
)
|
416 |
|
417 |
file_upload.change(
|
418 |
lambda files: files,
|