CodeMode Agent commited on
Commit ·
4743590
1
Parent(s): 48ca3cd
Deploy CodeMode via Agent
Browse files
app.py
CHANGED
|
@@ -562,8 +562,77 @@ with gr.Blocks(theme=theme, css=css, title="CodeMode - Baseline vs Fine-tuned")
|
|
| 562 |
compare_btn.click(search_comparison, inputs=search_query, outputs=[baseline_results, finetuned_results])
|
| 563 |
|
| 564 |
|
| 565 |
-
# TAB 3:
|
| 566 |
-
with gr.Tab("3.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
gr.Markdown("### Embedding Quality Analysis")
|
| 568 |
gr.Markdown("Analyze the semantic space distribution and diversity of embeddings")
|
| 569 |
|
|
|
|
| 562 |
compare_btn.click(search_comparison, inputs=search_query, outputs=[baseline_results, finetuned_results])
|
| 563 |
|
| 564 |
|
| 565 |
+
# TAB 3: CODE SIMILARITY SEARCH
|
| 566 |
+
with gr.Tab("3. Code Similarity Search"):
|
| 567 |
+
gr.Markdown("### Find Similar Code Snippets")
|
| 568 |
+
gr.Markdown("Paste a code snippet to find similar code in the database")
|
| 569 |
+
|
| 570 |
+
with gr.Row():
|
| 571 |
+
with gr.Column():
|
| 572 |
+
code_input = gr.Code(label="Paste Code Snippet", language="python", lines=10)
|
| 573 |
+
similarity_btn = gr.Button("Find Similar Code", variant="primary")
|
| 574 |
+
|
| 575 |
+
with gr.Column():
|
| 576 |
+
gr.Markdown("#### Search Settings")
|
| 577 |
+
top_k_slider = gr.Slider(minimum=1, maximum=20, value=5, step=1, label="Number of Results")
|
| 578 |
+
model_choice = gr.Radio(["Baseline", "Fine-tuned", "Both"], value="Both", label="Model to Use")
|
| 579 |
+
|
| 580 |
+
gr.Markdown("### Results")
|
| 581 |
+
|
| 582 |
+
with gr.Row():
|
| 583 |
+
with gr.Column():
|
| 584 |
+
gr.Markdown("#### Baseline Results")
|
| 585 |
+
baseline_code_results = gr.Dataframe(
|
| 586 |
+
headers=["File", "Similarity", "Code Snippet"],
|
| 587 |
+
datatype=["str", "str", "str"],
|
| 588 |
+
interactive=False,
|
| 589 |
+
wrap=True,
|
| 590 |
+
value=[["No search yet", "-", "-"]]
|
| 591 |
+
)
|
| 592 |
+
|
| 593 |
+
with gr.Column():
|
| 594 |
+
gr.Markdown("#### Fine-tuned Results")
|
| 595 |
+
finetuned_code_results = gr.Dataframe(
|
| 596 |
+
headers=["File", "Similarity", "Code Snippet"],
|
| 597 |
+
datatype=["str", "str", "str"],
|
| 598 |
+
interactive=False,
|
| 599 |
+
wrap=True,
|
| 600 |
+
value=[["No search yet", "-", "-"]]
|
| 601 |
+
)
|
| 602 |
+
|
| 603 |
+
def search_similar_code(code_snippet, top_k, model_choice):
|
| 604 |
+
if not code_snippet or len(code_snippet.strip()) == 0:
|
| 605 |
+
empty = [["Enter code to search", "-", "-"]]
|
| 606 |
+
return empty, empty
|
| 607 |
+
|
| 608 |
+
baseline_res = []
|
| 609 |
+
finetuned_res = []
|
| 610 |
+
|
| 611 |
+
if model_choice in ["Baseline", "Both"]:
|
| 612 |
+
baseline_res = search_baseline(code_snippet, top_k)
|
| 613 |
+
if not baseline_res:
|
| 614 |
+
baseline_res = [["No results found", "-", "-"]]
|
| 615 |
+
|
| 616 |
+
if model_choice in ["Fine-tuned", "Both"]:
|
| 617 |
+
finetuned_res = search_finetuned(code_snippet, top_k)
|
| 618 |
+
if not finetuned_res:
|
| 619 |
+
finetuned_res = [["No results found", "-", "-"]]
|
| 620 |
+
|
| 621 |
+
if model_choice == "Baseline":
|
| 622 |
+
finetuned_res = [["Not searched", "-", "-"]]
|
| 623 |
+
elif model_choice == "Fine-tuned":
|
| 624 |
+
baseline_res = [["Not searched", "-", "-"]]
|
| 625 |
+
|
| 626 |
+
return baseline_res, finetuned_res
|
| 627 |
+
|
| 628 |
+
similarity_btn.click(
|
| 629 |
+
search_similar_code,
|
| 630 |
+
inputs=[code_input, top_k_slider, model_choice],
|
| 631 |
+
outputs=[baseline_code_results, finetuned_code_results]
|
| 632 |
+
)
|
| 633 |
+
|
| 634 |
+
# TAB 4: DEPLOYMENT MONITORING
|
| 635 |
+
with gr.Tab("4. Deployment Monitoring"):
|
| 636 |
gr.Markdown("### Embedding Quality Analysis")
|
| 637 |
gr.Markdown("Analyze the semantic space distribution and diversity of embeddings")
|
| 638 |
|