Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,16 @@ import gradio as gr
|
|
| 2 |
import pandas as pd
|
| 3 |
from utils.dataset_loader import load_dataset
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Function to simulate conversation with model selection
|
| 9 |
def chat_interface(user_input, selected_model, prompt_id=None):
|
|
@@ -34,15 +42,18 @@ with gr.Blocks(css="./static/styles.css") as demo:
|
|
| 34 |
value=models[0],
|
| 35 |
elem_classes="retro-terminal"
|
| 36 |
)
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
prompt_selector = gr.Dropdown(
|
| 39 |
choices=prompt_ids,
|
| 40 |
label="Select Debugging Prompt ID",
|
| 41 |
-
value=prompt_ids[0],
|
| 42 |
elem_classes="retro-terminal"
|
| 43 |
)
|
| 44 |
else:
|
| 45 |
prompt_selector = None
|
|
|
|
| 46 |
with gr.Row():
|
| 47 |
response_box = gr.Textbox(
|
| 48 |
label="Model Response:",
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
from utils.dataset_loader import load_dataset
|
| 4 |
|
| 5 |
+
# Function to safely load dataset
|
| 6 |
+
def load_and_validate_dataset():
|
| 7 |
+
df = load_dataset()
|
| 8 |
+
if df is not None and "prompt_text" in df.columns:
|
| 9 |
+
return df
|
| 10 |
+
else:
|
| 11 |
+
return None
|
| 12 |
+
|
| 13 |
+
# Load dataset with validation
|
| 14 |
+
df = load_and_validate_dataset()
|
| 15 |
|
| 16 |
# Function to simulate conversation with model selection
|
| 17 |
def chat_interface(user_input, selected_model, prompt_id=None):
|
|
|
|
| 42 |
value=models[0],
|
| 43 |
elem_classes="retro-terminal"
|
| 44 |
)
|
| 45 |
+
|
| 46 |
+
# Conditionally display the prompt selector only if dataset is available
|
| 47 |
+
if df is not None:
|
| 48 |
prompt_selector = gr.Dropdown(
|
| 49 |
choices=prompt_ids,
|
| 50 |
label="Select Debugging Prompt ID",
|
| 51 |
+
value=prompt_ids[0] if prompt_ids else None,
|
| 52 |
elem_classes="retro-terminal"
|
| 53 |
)
|
| 54 |
else:
|
| 55 |
prompt_selector = None
|
| 56 |
+
|
| 57 |
with gr.Row():
|
| 58 |
response_box = gr.Textbox(
|
| 59 |
label="Model Response:",
|