Using gpt for data visualization

I looking to generate analytics or basic bi based on user-asking questions and provided data. I’m currently converting the data into a dictionary or df format to send to api. How can I use the GPT-4 (Code Interpreter) API to provide accurate BI responses.

I have one idea is to use the API to generate Matplotlib python code for visualization, but I’m unsure about the response implementation and costing. Any insights or other suggestions ?

1 Like

Hey there and welcome to the community!

Have you by chance tried Advanced Data Analysis through something like ChatGPT first? I think the tool you’re building already exists.

Code interpreter should work much the same way as data analysis. You can actually feed it data while requesting to perform some action on said data (like displaying it as a graph), and it should build & run code that displays your request. At least for Data Analysis. There might be some things you’d have to apply manually if performing on code interpreter, but the principles are much the same.

3 Likes

Hi morning mate,

What I am implying is i know Gpt 4 can produce data visualization on giving data but can it give through api. What I am familiar with is that api can give only textual responses. That’s why I was suggesting is to get back python code based on user questions, data and use it in bot application to generate visual

1 Like

Hi @Macha
Is there any thing you know about this I am still stuck on this.

1 Like

I got it what you want to achieve. I don’t think so it is possible through GPT you can try diiferent llm api.

If you look at the assistants api, it’s got code interpreter built in, and you can generate and download files if that’s what you’re looking for.

https://platform.openai.com/docs/assistants/tools

Hi, I am currently using azure open ai gpt 4 api it comes with code Interpreter, in application code
messages = [
{‘role’: ‘system’, ‘content’: system_message},
{‘role’: ‘user’, ‘content’: f"{user_message}"}
]
response = openai.ChatCompletion.create()
return response.choices[0].message[“content”]

Here what I need is that gpt 4 use code Interpreter and response with basic analytics only then we can display it on the web that.

Did you check the documentation? Assistants and chat completions are two different things, you can’t call the interpreter from chat completions.

Here’s the azure specific docs: How to create Assistants with Azure OpenAI Service - Azure OpenAI | Microsoft Learn

Hi, did you get any solution for this problem. I am also stuck on the same problem. I am using gpt-4 turbo preview but it cannot generate plots or visualizations. Do you find any solution for that