File size: 1,066 Bytes
1832bd5
 
 
 
 
 
 
 
 
 
 
b38b06a
1832bd5
 
 
77a9e5b
1832bd5
 
 
 
 
79aa83b
1832bd5
 
 
 
 
 
7d83c69
77a9e5b
1832bd5
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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("testfile.csv", index=False, mode='a')

# Create a function to plot the data from the CSV file
def plot_data():
    df = pd.read_csv("testfile.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", minimum=0, maximum=100, default=50),
    gr.inputs.Textbox(label="Topic"),
    gr.inputs.Textbox(label="Intervention")
]

# Define the outputs for the Gradio interface
outputs = [
    gr.Plot(plot_data),
    gr.Textbox(label="Data written to testfile.csv")
]

# Create the Gradio interface
interface = gr.Interface(write_csv, inputs, outputs, title="Record Plotter")

# Launch the Gradio interface
interface.launch()