Skip to content

Latest commit

 

History

History
 
 

030-assistants-nodejs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Code Interpreter With Function Calling

Introduction

This example uses OpenAI's new Assistant API (at the time of writing in preview) to demonstrate how to combine Code Interpreter with Function Calling. As the Assistant API is not yet supported in .NET, this sample uses the official TypeScript SDK and Node.js

The sample covers the following topics:

  • How to setup a TypeScript/Node.js project for OpenAI.
  • How to manage assistants, threads, and runs with the new Assistant API.
  • How to enable Code Interpreter and Function Calling in the assistant.

Exercises

  • Make yourself familiar with the code in src.
  • Try the prompts offered by the app (part of main.ts). Take a close look at the generated SQL queries and try to understand how ChatGPT uses Code Interpreter to process the function calls' results.
  • Think about another series of prompts forcing ChatGPT to combine multiple function calls and processing of the results with Code Interpreter.
  • Think about an application of function calling that would be relevant to your business or personal life.

Advanced Exercises

  • Add a new function to the application and try to design a prompt that makes ChatGPT call this function.
    • Example: Return details about order header and order details for a given customer and product.
  • Quite hard: Use streaming to receive function calls from the OpenAI API step by step.