Spaces:
Runtime error
Runtime error
File size: 1,855 Bytes
99438f3 0a252c0 76e016c fde343f 8ab30ec 6f77700 2fabb36 99438f3 058b6c6 99438f3 539a9b1 99438f3 13a59ec 99438f3 fd4897e 797592e 146b72c 79c9b04 6f77700 8ab30ec 8a30c60 |
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 39 40 41 42 43 44 45 46 47 48 49 50 |
# Import basis libraries
import pandas as pd
from pandasai import PandasAI
from pandasai.llm.starcoder import Starcoder
import matplotlib.pyplot as plt
import gradio as gr
def plot_chey():
a,b = plt.subplots()
b.xlabel('two rs')
b.title('hada')
return a
title='Plot'
# Define List of Models
models = {"Starcoder": Starcoder}
#@title Select Model to Run
model_to_run = 'Starcoder' #@param [ "Starcoder", "Open-Assistant"]
#print(f"Enter API for {model_to_run} platform")
# Enter API Key
API_KEY = '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'#@param {type:"string"}
df = pd.DataFrame({
"country": ["United States", "United Kingdom", "France", "Germany", "Italy", "Spain", "Canada", "Australia", "Japan", "China"],
"gdp": [21400000, 2940000, 2830000, 3870000, 2160000, 1350000, 1780000, 1320000, 516000, 14000000],
"happiness_index": [7.3, 7.2, 6.5, 7.0, 6.0, 6.3, 7.3, 7.3, 5.9, 5.0]})
# Model Initialisation
llm = models[model_to_run](api_token=API_KEY)
pandas_ai = PandasAI(llm, save_charts =True, conversational=False, verbose=True)
# Enter Prompt related to data or Select from Pre-defined for demo purposes.
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}
response = pandas_ai.run(df, prompt=prompt,
is_conversational_answer=False)
with gr.Blocks(title=title) as demo:
gr.Markdown('''
<div>
<h1 style='text-align: center'>Plot</h1>
</div>
''')
button = gr.Button(value = 'nokku')
button.click(plot_chey(), outputs = gr.Plot())
demo.launch()
|