sxd3125 commited on
Commit
d7dc696
1 Parent(s): c35f02a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -24
app.py CHANGED
@@ -5,13 +5,14 @@ from pandasai.llm.starcoder import Starcoder
5
  import matplotlib.pyplot as plt
6
  import gradio as gr
7
 
8
- def plot_chey():
 
9
  a,b = response.figure, response.axes
10
  return a
11
 
12
  title='Plot'
13
- # Define List of Models
14
 
 
15
  models = {"Starcoder": Starcoder}
16
 
17
  #@title Select Model to Run
@@ -24,35 +25,20 @@ df = pd.DataFrame({
24
  "country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
25
  "gdp": [21400000, 2940000, 2830000, 3870000, 2160000, 1350000, 1780000, 1320000, 516000, 14000000],
26
  "happiness_index": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0]})
 
27
  # Model Initialisation
28
  llm = models[model_to_run](api_token=API_KEY)
29
  pandas_ai = PandasAI(llm, save_charts =True, conversational=False, verbose=True)
 
30
  # Enter Prompt related to data or Select from Pre-defined for demo purposes.
31
  prompt = 'Plot the histogram of countries showing for each the gdp, using different colors for each bar' #@param [ "What is the relation between GDP and Happines Index", "Plot the histogram of countries showing for each the gpd, using different colors for each bar", "GDP of Top 5 Happiest Countries?"] {allow-input: true}
32
  response = pandas_ai.run(df, prompt=prompt,
33
  is_conversational_answer=False)
34
 
35
  heading = 'Pandas AI : Dataframe analytics using text prompt'
36
- with gr.Blocks(title = heading, theme= 'snehilsanyal/scikit-learn') as demo:
37
  gr.Markdown("# {}".format(heading))
38
-
39
-
40
-
41
- button = gr.Button(value = 'submit')
42
- button.click(plot_chey, outputs = gr.Plot())
43
-
44
- demo.launch()
45
- """
46
-
47
- with gr.Blocks(title=title) as demo:
48
- gr.Markdown('''
49
- <div>
50
- <h1 style='text-align: center'>Plot</h1>
51
- </div>
52
- ''')
53
- button = gr.Button(value = 'nokku')
54
-
55
- button.click(plot_chey, outputs = gr.Plot())
56
- demo.launch()
57
- """
58
-
 
5
  import matplotlib.pyplot as plt
6
  import gradio as gr
7
 
8
+ #function to plot
9
+ def plot_response():
10
  a,b = response.figure, response.axes
11
  return a
12
 
13
  title='Plot'
 
14
 
15
+ # Define List of Models
16
  models = {"Starcoder": Starcoder}
17
 
18
  #@title Select Model to Run
 
25
  "country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
26
  "gdp": [21400000, 2940000, 2830000, 3870000, 2160000, 1350000, 1780000, 1320000, 516000, 14000000],
27
  "happiness_index": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0]})
28
+
29
  # Model Initialisation
30
  llm = models[model_to_run](api_token=API_KEY)
31
  pandas_ai = PandasAI(llm, save_charts =True, conversational=False, verbose=True)
32
+
33
  # Enter Prompt related to data or Select from Pre-defined for demo purposes.
34
  prompt = 'Plot the histogram of countries showing for each the gdp, using different colors for each bar' #@param [ "What is the relation between GDP and Happines Index", "Plot the histogram of countries showing for each the gpd, using different colors for each bar", "GDP of Top 5 Happiest Countries?"] {allow-input: true}
35
  response = pandas_ai.run(df, prompt=prompt,
36
  is_conversational_answer=False)
37
 
38
  heading = 'Pandas AI : Dataframe analytics using text prompt'
39
+ with gr.Blocks(title = heading) as demo:
40
  gr.Markdown("# {}".format(heading))
41
+ button = gr.Button(value = 'click to generate plot')
42
+ button.click(plot_response, outputs = gr.Plot())
43
+
44
+ demo.launch()