Spaces:
Runtime error
Runtime error
Update app3.py
Browse files
app3.py
CHANGED
|
@@ -147,6 +147,24 @@ Return only the revised labels, one per line.
|
|
| 147 |
|
| 148 |
return "Labels refined!", csv_str, df.head(10).to_markdown(index=False)
|
| 149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
# === GRADIO UI ===
|
| 151 |
with gr.Blocks(title="Falcon Topic Modeling") as demo:
|
| 152 |
gr.Markdown("# 🎯 Falcon-Powered Topic Modeling")
|
|
@@ -154,9 +172,9 @@ with gr.Blocks(title="Falcon Topic Modeling") as demo:
|
|
| 154 |
|
| 155 |
with gr.Row():
|
| 156 |
with gr.Column():
|
| 157 |
-
upload = gr.File(label="Upload CSV ('text' column)")
|
| 158 |
context = gr.Textbox(label="Context/Instruction", lines=5, value="Group these into common themes.")
|
| 159 |
-
cluster_slider = gr.Slider(2, 20, value=10, label="Number of Topics")
|
| 160 |
run_btn = gr.Button("Run Initial Analysis")
|
| 161 |
|
| 162 |
with gr.Column():
|
|
@@ -171,4 +189,4 @@ with gr.Blocks(title="Falcon Topic Modeling") as demo:
|
|
| 171 |
refine_btn.click(fn=refine_labels, inputs=[feedback], outputs=[status, download, preview])
|
| 172 |
|
| 173 |
if __name__ == "__main__":
|
| 174 |
-
demo.launch()
|
|
|
|
| 147 |
|
| 148 |
return "Labels refined!", csv_str, df.head(10).to_markdown(index=False)
|
| 149 |
|
| 150 |
+
import gradio as gr
|
| 151 |
+
import pandas as pd
|
| 152 |
+
|
| 153 |
+
# === Placeholder Functions (replace with actual logic) ===
|
| 154 |
+
def run_initial_analysis(file, context, n_clusters):
|
| 155 |
+
try:
|
| 156 |
+
df = pd.read_csv(file.name, encoding='latin1')
|
| 157 |
+
preview = df.head(10).to_csv(index=False)
|
| 158 |
+
# Dummy status and download file path (replace with real logic)
|
| 159 |
+
status = f"Successfully processed {len(df)} rows into {n_clusters} topics."
|
| 160 |
+
return status, file, preview
|
| 161 |
+
except Exception as e:
|
| 162 |
+
return f"Error during initial analysis: {e}", None, ""
|
| 163 |
+
|
| 164 |
+
def refine_labels(feedback):
|
| 165 |
+
# Dummy response (replace with real logic)
|
| 166 |
+
return f"Refined using feedback: {feedback}", None, ""
|
| 167 |
+
|
| 168 |
# === GRADIO UI ===
|
| 169 |
with gr.Blocks(title="Falcon Topic Modeling") as demo:
|
| 170 |
gr.Markdown("# 🎯 Falcon-Powered Topic Modeling")
|
|
|
|
| 172 |
|
| 173 |
with gr.Row():
|
| 174 |
with gr.Column():
|
| 175 |
+
upload = gr.File(label="Upload CSV ('text' column)", file_types=[".csv"])
|
| 176 |
context = gr.Textbox(label="Context/Instruction", lines=5, value="Group these into common themes.")
|
| 177 |
+
cluster_slider = gr.Slider(2, 20, value=10, step=1, label="Number of Topics")
|
| 178 |
run_btn = gr.Button("Run Initial Analysis")
|
| 179 |
|
| 180 |
with gr.Column():
|
|
|
|
| 189 |
refine_btn.click(fn=refine_labels, inputs=[feedback], outputs=[status, download, preview])
|
| 190 |
|
| 191 |
if __name__ == "__main__":
|
| 192 |
+
demo.launch()
|