Skip to main content

Overview

This example demonstrates how to use OpenAI’s Function Calling with GBOX to create an AI assistant that can execute Python code based on user queries.

How It Works

  1. User Input - User asks a natural language question
  2. AI Analysis - OpenAI determines if code execution is needed
  3. Code Generation - AI generates Python code using the execute_python function
  4. Code Execution - GBOX executes the code and returns results
  5. Result Integration - AI incorporates results into the final response

Use Cases

  • Data Analysis & Visualization - Process and display data
  • Mathematical Problem Solving - Solve complex computational problems
  • Interactive Code Generation - Real-time code generation and execution

Implementation Example

Step 1: Create the File

Copy the following code locally and create a new file named index.ts:

Step 2: Run the Code

Execute the following commands to run the code: