microsoft / lida

Automatic Generation of Visualizations and Infographics using Large Language Models
https://microsoft.github.io/lida/
MIT License
2.6k stars 266 forks source link

Access to the code generated to plot #59

Closed teraktor2006 closed 8 months ago

teraktor2006 commented 8 months ago

Hi, Is there any way to get access to the code that lida generate and use to plot?

victordibia commented 8 months ago

Can you share the code you have right now?

In general,


from lida import Manager, llm

lida = Manager(text_gen = llm("openai")) # palm, cohere ..
summary = lida.summarize("data/cars.csv")
goals = lida.goals(summary, n=2) # exploratory data analysis
charts = lida.visualize(summary=summary, goal=goals[0]) # exploratory data analysis 

In the snippet above, charts is an array of objects ChartExecutorResponse which has a code field.

charts[0].code
teraktor2006 commented 8 months ago

Thanks. I am using this demo: https://github.com/AIAnytime/LIDA-Demo-Streamlit-App/blob/main/app.py Another problem that I am facing for some queries is that the charts is empty list []. But interestingly, once it happens it shows the code as log and that code is actually working! I was wondering is this a bug? The problem is that if list is empty then I cannot access that code either with charts[0].code


 textgen_config = TextGenerationConfig(n=1, temperature=0.2, use_cache=True)

 summary = lida.summarize("filename1.csv", summary_method="default", textgen_config=textgen_config)

 user_query = text_area

 charts = lida.visualize(summary=summary, goal=user_query, textgen_config=textgen_config)  ```