Spaces:
Runtime error
Runtime error
import gradio as gr | |
import pandas as pd | |
import plotly.express as px | |
# Create a function to write the CSV file | |
def write_csv(record_count, topic, intervention): | |
df = pd.DataFrame({ | |
"RecordCount": [record_count], | |
"Topic": [topic], | |
"Intervention": [intervention] | |
}) | |
df.to_csv("records.csv", index=False, mode='a') | |
# Create a function to plot the data from the CSV file | |
def plot_data(): | |
df = pd.read_csv("records.csv") | |
fig = px.scatter(df, x="RecordCount", y="Intervention", color="Topic") | |
return fig | |
# Define the inputs for the Gradio interface | |
inputs = [ | |
gr.inputs.Slider(label="Record Count", min=0, max=100, default=50), | |
gr.inputs.Textbox(label="Topic"), | |
gr.inputs.Textbox(label="Intervention") | |
] | |
# Define the outputs for the Gradio interface | |
outputs = [ | |
gr.outputs.Plotly(plot_data), | |
gr.outputs.Textbox(label="Data written to records.csv") | |
] | |
# Create the Gradio interface | |
interface = gr.Interface(write_csv, inputs, outputs, title="Record Plotter") | |
# Launch the Gradio interface | |
interface.launch() | |