Skip to content

Graph creation using code interpreter using this solution accelerator #600

@clement-lucas

Description

@clement-lucas

Hi,

I am trying to ask the agent in this solution accelerator using code interpreter tool.
I have modified the agent definition as follow to enable code interpreter for the agent ("coding_tools" : true)

########
{
"input_key": "",
"type": "",
"name": "VisualizationAgent",
"deployment_name": "gpt-4.1-mini",
"icon": "",
"system_message": "You are a visualization agent with access to a Python sandbox (“python” tool). When asked to visualize or analyze data, you must: 1- Run Python to load data into pandas and plot with matplotlib. 2- Do not print or return source code. 3- Return only the rendered chart plus a short 1–2 sentence caption. 4- Label axes, add a clear title, avoid subplots unless asked, never use seaborn, and don’t specify colors unless the user requests. 5- If input looks like code or pseudo-code, treat it as instructions to execute in Python (don’t echo it). If you are about to output code, stop and instead run it in Python and return the image.",
"description": "An agent that visualize analyzed data in graph form based on actual data and prediction.",
"use_rag": false,
"use_mcp": false,
"use_bing": false,
"use_reasoning": false,
"index_name": "",
"index_foundry_name": "",
"coding_tools": true
}
############

However, when I asked the agent to generate graph, for example using following prompt, the agent just return the python code to generate the graph into the chat window and not showing the graph itself. Is the code interpreter not being used correctly here?

User Prompt:
Visualize sales trends by region from the following CSV data:
Region,Month,Sales
East,Jan,120
East,Feb,150
West,Jan,80
West,Feb,110

Output from agent looks like this:

import pandas as pd
import matplotlib.pyplot as plt

Create# dataframe Create from dataframe the from CSV the data CSV datadata =data { = { " Region "":Region ["":East ["",East "",East "",East "",West "",West "",West ""], West "], " Month "":Month ["":Jan ["",Jan "",Feb "",Feb "",Jan "",Jan "",Feb ""], Feb "], " Sales "":Sales [":120 [,120 ,150 ,150 ,80 ,80 ,110 ] 110} ] df} =df pd =.Data pdFrame.Data(dataFrame)

(data#)

Pivot# data Pivot for data visualization for visualizationpivot _dfpivot =_df df =.p dfivot.p(indexivot="(indexMonth="",Month columns",=" columnsRegion="",Region values",=" valuesSales="")

Sales#")

Plot# sales Plot trends sales by trends region by regionpivot _dfpivot.plot_df(kind.plot='(kindline='',line marker',=' markero='') oplt') .titleplt('.titleSales(' TrendsSales by Trends Region by ( RegionJan (-FebJan)-Feb') )plt') .xlabelplt('.xlabelMonth('') Monthplt') .ylabelplt('.ylabelSales('') Salesplt') .gridplt(True.grid) (Trueplt) .legendplt(title.legend='(titleRegion='') Regionplt') .tightplt_layout.tight() _layoutplt() .showplt().show()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions