new
Browse files- app.py +25 -17
- chatbot_page.py +1 -0
app.py
CHANGED
@@ -388,32 +388,39 @@ with gr.Blocks() as demo:
|
|
388 |
combined_txt_results = gr.Textbox(label="Combined Repo Files", lines=20)
|
389 |
llm_output_txt_results = gr.Textbox(label="LLM Analysis Output", lines=10)
|
390 |
back_to_start_btn4 = gr.Button("Back to Start")
|
391 |
-
|
|
|
|
|
|
|
|
|
392 |
batch_btn = gr.Button("Batch Analyze All & Select Top 3", visible=True)
|
393 |
batch_info_txt = gr.Textbox(label="All Repo Analyses", lines=10)
|
394 |
top3_txt = gr.Textbox(label="Top 3 Repo IDs", lines=1)
|
395 |
-
|
|
|
396 |
|
397 |
-
# --- Page
|
398 |
with gr.Column(visible=False) as top3_page:
|
399 |
gr.Markdown("## Top 3 Recommended Repos")
|
400 |
top3_df = gr.Dataframe(headers=["repo id"], datatype=["str"])
|
401 |
back_to_results_btn = gr.Button("Back to Results")
|
402 |
|
403 |
# Navigation logic
|
404 |
-
option_a_btn.click(go_to_input, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, top3_page])
|
405 |
option_b_btn.click(
|
406 |
-
lambda: (gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), [["", CHATBOT_INITIAL_MESSAGE]]),
|
407 |
inputs=None,
|
408 |
-
outputs=[start_page, input_page, chatbot_page, results_page, top3_page, state]
|
409 |
)
|
410 |
-
next_btn.click(go_to_analysis, inputs=None, outputs=[input_page, analysis_page, chatbot_page, results_page, top3_page])
|
411 |
-
back_btn.click(go_to_input, inputs=None, outputs=[input_page, analysis_page, chatbot_page, results_page, top3_page])
|
412 |
-
back_to_start_btn.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, top3_page])
|
413 |
-
back_to_start_btn2.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, top3_page])
|
414 |
-
back_to_start_btn3.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, top3_page])
|
415 |
-
back_to_start_btn4.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, top3_page])
|
416 |
-
|
|
|
|
|
417 |
|
418 |
# Keyword and repo input logic
|
419 |
keyword_btn.click(keyword_search_and_update, inputs=keyword_input, outputs=df_box)
|
@@ -438,19 +445,20 @@ with gr.Blocks() as demo:
|
|
438 |
def go_to_results_from_chatbot(keywords):
|
439 |
# Use the keywords to search and update the CSV, then display the DataFrame
|
440 |
df = use_keywords_to_search_and_update_csv(keywords)
|
441 |
-
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), df
|
442 |
|
443 |
send_btn.click(user_send, inputs=[user_input, state], outputs=[chatbot, state, user_input])
|
444 |
end_btn.click(end_chat, inputs=state, outputs=keywords_output)
|
445 |
go_to_results_btn.click(
|
446 |
go_to_results_from_chatbot,
|
447 |
inputs=keywords_output,
|
448 |
-
outputs=[chatbot_page, input_page, analysis_page, results_page, top3_page, results_df]
|
449 |
)
|
450 |
|
451 |
# Add logic for the new button on results_page
|
452 |
analyze_next_btn.click(show_combined_repo_and_llm, inputs=None, outputs=[combined_txt_results, llm_output_txt_results, results_df])
|
453 |
batch_btn.click(batch_analyze_and_select_top, inputs=None, outputs=[batch_info_txt, top3_txt, df_output])
|
|
|
454 |
|
455 |
def show_top3_page():
|
456 |
# Run batch analysis, get top 3, save to CSV, and return DataFrame
|
@@ -465,8 +473,8 @@ with gr.Blocks() as demo:
|
|
465 |
top3_ids = []
|
466 |
top3_df_data = pd.DataFrame({"repo id": top3_ids})
|
467 |
top3_df_data.to_csv("top3_repos.csv", index=False)
|
468 |
-
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), top3_df_data
|
469 |
|
470 |
-
show_top3_page_btn.click(show_top3_page, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, top3_page, top3_df])
|
471 |
|
472 |
demo.launch()
|
|
|
388 |
combined_txt_results = gr.Textbox(label="Combined Repo Files", lines=20)
|
389 |
llm_output_txt_results = gr.Textbox(label="LLM Analysis Output", lines=10)
|
390 |
back_to_start_btn4 = gr.Button("Back to Start")
|
391 |
+
go_to_batch_btn = gr.Button("Go to Batch Analysis Page", visible=True)
|
392 |
+
|
393 |
+
# --- Page 5: Batch Analysis Page ---
|
394 |
+
with gr.Column(visible=False) as batch_page:
|
395 |
+
gr.Markdown("## Batch Analysis & Top 3 Selection")
|
396 |
batch_btn = gr.Button("Batch Analyze All & Select Top 3", visible=True)
|
397 |
batch_info_txt = gr.Textbox(label="All Repo Analyses", lines=10)
|
398 |
top3_txt = gr.Textbox(label="Top 3 Repo IDs", lines=1)
|
399 |
+
show_top3_chat_btn = gr.Button("Show Top 3 Repo IDs in Chat", visible=True)
|
400 |
+
back_to_results_from_batch_btn = gr.Button("Back to Results")
|
401 |
|
402 |
+
# --- Page 6: Top 3 Repos Page ---
|
403 |
with gr.Column(visible=False) as top3_page:
|
404 |
gr.Markdown("## Top 3 Recommended Repos")
|
405 |
top3_df = gr.Dataframe(headers=["repo id"], datatype=["str"])
|
406 |
back_to_results_btn = gr.Button("Back to Results")
|
407 |
|
408 |
# Navigation logic
|
409 |
+
option_a_btn.click(go_to_input, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
410 |
option_b_btn.click(
|
411 |
+
lambda: (gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), [["", CHATBOT_INITIAL_MESSAGE]]),
|
412 |
inputs=None,
|
413 |
+
outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page, state]
|
414 |
)
|
415 |
+
next_btn.click(go_to_analysis, inputs=None, outputs=[input_page, analysis_page, chatbot_page, results_page, batch_page, top3_page])
|
416 |
+
back_btn.click(go_to_input, inputs=None, outputs=[input_page, analysis_page, chatbot_page, results_page, batch_page, top3_page])
|
417 |
+
back_to_start_btn.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
418 |
+
back_to_start_btn2.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
419 |
+
back_to_start_btn3.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
420 |
+
back_to_start_btn4.click(go_to_start, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
421 |
+
go_to_batch_btn.click(lambda: (gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False)), inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
422 |
+
back_to_results_from_batch_btn.click(lambda: (gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)), inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
423 |
+
back_to_results_btn.click(lambda: (gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False)), inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page])
|
424 |
|
425 |
# Keyword and repo input logic
|
426 |
keyword_btn.click(keyword_search_and_update, inputs=keyword_input, outputs=df_box)
|
|
|
445 |
def go_to_results_from_chatbot(keywords):
|
446 |
# Use the keywords to search and update the CSV, then display the DataFrame
|
447 |
df = use_keywords_to_search_and_update_csv(keywords)
|
448 |
+
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), gr.update(visible=False), gr.update(visible=False), df
|
449 |
|
450 |
send_btn.click(user_send, inputs=[user_input, state], outputs=[chatbot, state, user_input])
|
451 |
end_btn.click(end_chat, inputs=state, outputs=keywords_output)
|
452 |
go_to_results_btn.click(
|
453 |
go_to_results_from_chatbot,
|
454 |
inputs=keywords_output,
|
455 |
+
outputs=[chatbot_page, input_page, analysis_page, results_page, batch_page, top3_page, results_df]
|
456 |
)
|
457 |
|
458 |
# Add logic for the new button on results_page
|
459 |
analyze_next_btn.click(show_combined_repo_and_llm, inputs=None, outputs=[combined_txt_results, llm_output_txt_results, results_df])
|
460 |
batch_btn.click(batch_analyze_and_select_top, inputs=None, outputs=[batch_info_txt, top3_txt, df_output])
|
461 |
+
show_top3_chat_btn.click(batch_analyze_and_select_top_for_chat, inputs=[state], outputs=[state])
|
462 |
|
463 |
def show_top3_page():
|
464 |
# Run batch analysis, get top 3, save to CSV, and return DataFrame
|
|
|
473 |
top3_ids = []
|
474 |
top3_df_data = pd.DataFrame({"repo id": top3_ids})
|
475 |
top3_df_data.to_csv("top3_repos.csv", index=False)
|
476 |
+
return gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=False), gr.update(visible=True), top3_df_data
|
477 |
|
478 |
+
show_top3_page_btn.click(show_top3_page, inputs=None, outputs=[start_page, input_page, chatbot_page, results_page, batch_page, top3_page, top3_df])
|
479 |
|
480 |
demo.launch()
|
chatbot_page.py
CHANGED
@@ -48,6 +48,7 @@ def extract_keywords_from_conversation(history):
|
|
48 |
"You are an expert at helping users find open-source repos on Hugging Face. "
|
49 |
"Given a conversation, extract about 5 keywords that would be most useful for searching Hugging Face repos to find the most relevant results for the user. "
|
50 |
"Return only the keywords as a comma-separated list."
|
|
|
51 |
)
|
52 |
user_prompt = (
|
53 |
"Conversation:\n" + conversation + "\n\nExtract about 5 keywords for Hugging Face repo search."
|
|
|
48 |
"You are an expert at helping users find open-source repos on Hugging Face. "
|
49 |
"Given a conversation, extract about 5 keywords that would be most useful for searching Hugging Face repos to find the most relevant results for the user. "
|
50 |
"Return only the keywords as a comma-separated list."
|
51 |
+
"Use keywords that are specific to the user's use case and features they are looking for."
|
52 |
)
|
53 |
user_prompt = (
|
54 |
"Conversation:\n" + conversation + "\n\nExtract about 5 keywords for Hugging Face repo search."
|