Spaces:
Runtime error
Runtime error
gpravin1308
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import pandas as pd
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
# Function to load Excel sheets and extract first column data from valid sheets
|
5 |
def load_excel_sheets(file_path):
|
@@ -51,7 +52,7 @@ def prompt_generator_interface(file_path, main_sheet_name):
|
|
51 |
if 'Resources' in valid_sheets:
|
52 |
valid_sheets['Resources'] = valid_sheets.pop('Resources')
|
53 |
|
54 |
-
# Gradio interface
|
55 |
with gr.Blocks() as interface:
|
56 |
gr.Markdown("# 📝 Witness Prompt Generator\nSelect an item from each sheet to generate a combined prompt.")
|
57 |
|
@@ -62,16 +63,18 @@ def prompt_generator_interface(file_path, main_sheet_name):
|
|
62 |
with gr.Row():
|
63 |
for sheet_name in valid_sheets:
|
64 |
with gr.Column():
|
65 |
-
dropdown
|
|
|
66 |
dropdowns_and_weights.append(dropdown)
|
67 |
|
68 |
# If the sheet is not in the no_weight_sheets, add a weight input
|
69 |
if sheet_name not in no_weight_sheets:
|
|
|
70 |
weight_input = gr.Textbox(label=f"{sheet_name} Weight", placeholder="Enter weight (optional)", interactive=True)
|
71 |
dropdowns_and_weights.append(weight_input)
|
72 |
|
73 |
-
#
|
74 |
-
submit_button =
|
75 |
|
76 |
# Textbox to display the combined prompt
|
77 |
combined_output = gr.Textbox(label="Combined Prompt", placeholder="Your combined prompt will appear here...")
|
|
|
1 |
import pandas as pd
|
2 |
import gradio as gr
|
3 |
+
from ui_components import CustomDropdown, CustomButton # Example: Replace with actual component names
|
4 |
|
5 |
# Function to load Excel sheets and extract first column data from valid sheets
|
6 |
def load_excel_sheets(file_path):
|
|
|
52 |
if 'Resources' in valid_sheets:
|
53 |
valid_sheets['Resources'] = valid_sheets.pop('Resources')
|
54 |
|
55 |
+
# Gradio interface using custom UI components
|
56 |
with gr.Blocks() as interface:
|
57 |
gr.Markdown("# 📝 Witness Prompt Generator\nSelect an item from each sheet to generate a combined prompt.")
|
58 |
|
|
|
63 |
with gr.Row():
|
64 |
for sheet_name in valid_sheets:
|
65 |
with gr.Column():
|
66 |
+
# Using the custom dropdown from ui_components.py
|
67 |
+
dropdown = CustomDropdown(choices=valid_sheets[sheet_name], label=sheet_name, interactive=True)
|
68 |
dropdowns_and_weights.append(dropdown)
|
69 |
|
70 |
# If the sheet is not in the no_weight_sheets, add a weight input
|
71 |
if sheet_name not in no_weight_sheets:
|
72 |
+
# Custom weight input
|
73 |
weight_input = gr.Textbox(label=f"{sheet_name} Weight", placeholder="Enter weight (optional)", interactive=True)
|
74 |
dropdowns_and_weights.append(weight_input)
|
75 |
|
76 |
+
# Using a custom button for submission
|
77 |
+
submit_button = CustomButton("Generate Combined Prompt")
|
78 |
|
79 |
# Textbox to display the combined prompt
|
80 |
combined_output = gr.Textbox(label="Combined Prompt", placeholder="Your combined prompt will appear here...")
|