# Code Interpreter

<iframe width="560" height="315" src="https://www.youtube.com/embed/7awkSGqW1iE" title="YouTube video player" frameborder="0" allowfullscreen></iframe>

<iframe width="560" height="315" src="https://www.youtube.com/embed/8gidWuxYszo" title="YouTube video player" frameborder="0" allowfullscreen></iframe>

---

## Description

The Code Interpreter tool lets the agent run Python code in-chat and display the resulting graphs, charts, tables, and other visualizations instantly. It’s ideal for math, statistics, data analysis, and any scenario where seeing the data makes concepts clearer—such as integrals, functions, distributions, or real-world datasets—directly alongside the explanation.

---

## Target Audience

**User**

---

## Features

#### In-Chat Graphs & Visualizations
Ask the agent to plot functions, integrals, histograms, bar charts, scatterplots, and more. Visuals appear directly below the AI’s response.

#### Python Sandbox Execution
The agent safely runs Python code behind the scenes, enabling calculations, filtering, aggregation, and visualization without leaving the chat.

#### Automatic Task Restatement
Before executing, the agent restates your request (e.g., “Plot the integral of x² from 1 to 100”) so you can confirm it understood correctly.

#### Immediate, Context-Aware Explanations
After rendering a visualization, the agent explains what you’re seeing—highlighting trends, key values, comparisons, or anomalies.

#### File-Based Data Analysis
Upload spreadsheets or datasets (CSV, Excel, etc.) and ask the agent to:
- Analyze the data
- Generate charts
- Summarize patterns
- Extract specific records

#### Privacy-Aware Processing
When datasets contain sensitive information, the agent follows privacy guardrails—automatically anonymizing or omitting restricted fields when generating outputs.

#### Downloadable Results
For certain requests, the agent can generate CSV outputs you can download and review outside the platform.

---

## How to Use (step by step)

#### Verify the Tool Is Enabled
In the agent sidebar, confirm Code Interpreter is toggled On.

#### Enter Your Request
Type a prompt in the chat, such as:

> ”Plot the integral of x² from 1 to 100.”

#### Agentic OS Restates the Task
The AI echoes your request to confirm understanding, for example:

> “Sure — plotting ∫ x² dx from 1 to 100.”

#### View the Generated Output
The agent runs the code and displays the visualization directly in the chat.

#### Review the Explanation
Beneath the output, the agent explains what the graph or table represents and why it matters.

#### Iterate or Refine
You can ask follow-up prompts such as:
> ”Add gridlines.”  
> ”Zoom into x = 1 to 10.”  
> ”Overlay y = x³ for comparison.”  

The agent updates the visualization accordingly.

---

## Working with Uploaded Data (Advanced Example)

#### Upload a Dataset
Use the file upload option to provide a dataset, such as a spreadsheet containing incident reports, lab results, or survey data.

#### Ask a Visualization Question
For example:

> “Show me a graph of the campuses with the most incidents reported.“

The agent will:
- Analyze the uploaded data  
- Aggregate values as needed  
- Render a chart (e.g., bar graph)  
- Explain what the chart shows  

Sensitive fields are anonymized automatically if required.

#### Ask for Filtered Records
You can also request specific subsets of the data, for example:

> ”Show me all records involving hydrochloric acid.”

In this case, the agent may:
- Provide a short executive summary  
- Generate a CSV file containing only the relevant records  
- Include a download link so you can open the data externally  

---

## Pedagogical Use Cases

#### Calculus Visualization
Plot definite or indefinite integrals, derivatives, and Riemann sums to see area under curves and slope behavior.

#### Function Exploration
Compare multiple functions (e.g., y = sin x vs. y = cos x) on the same axes to study amplitude, period, and phase shifts.

#### Statistics & Data Analysis
Upload datasets and generate histograms, box plots, bar charts, or scatterplots to analyze distributions and correlations.

#### Physics & Engineering Labs
Graph experimental data (e.g., projectile motion or lab incident frequency) and fit trend lines or models to validate hypotheses.

#### Data Literacy & Real-World Analysis
Explore real institutional or research datasets—summarizing trends, identifying outliers, and extracting specific records.

#### Quick Concept Checks
Replicate textbook graphs or lab figures to verify understanding or test “what-if” scenarios.

---

With Code Interpreter enabled, you can move seamlessly from raw data or abstract equations to clear visuals, summaries, and downloadable results—all inside Agentic OS.
