Function Agents: OpenAI-powered Tasks



function-agents is a collection of Function Agents with specific purposes, designed to simplify various tasks. To use these agents, you'll need to pass an OpenAI API Key upon construction.

For more examples and the full documentation, please visit


To install the package, run the following command:

npm install function-agents


  • Node.js (or another JavaScript runtime environment like Bun)
  • OpenAI API Key

Getting Started

Import the agent you want to use into your project:

import { JavaScriptFunctionCallTransformationAgent } from 'function-agents';

const javascriptFunctionCallTransformationAgent = new JavaScriptFunctionCallTransformationAgent(
    'gpt-4-0613' // or any other supported model

const result = await'function add(a, b) { return a + b; }');


Here's a list of available agents with brief descriptions and direct links to their code:

Data Transformation

Intent Classification

Sentiment Classification

Code Interpretation

Function Call Transformation

JavaScript Development

Math Operations

  • MathAgent
    • Performs mathematical operations based on user requests. (addition, subtraction, multiplication, and division so far))


  • CitationAgent
    • Retrieves and formats citations for content, including filename, pageNumber, and explanationOfWhyThisSourceWasChosen.


  1. openai_api_key: Your OpenAI API Key.
  2. model: The name of the OpenAI model. Must be either gpt-3.5-turbo-0613 or gpt-4-0613 or gpt-4-32k-0613

Note: Some agents may have additional parameters such as the IntentClassificationAgent which requires a list of intents to be passed in.

Example Console Output

JavaScriptCodeInterpreterAgent invoked with: What is the square root of 20?

JavascriptDeveloperAgent invoked with: Write a JavaScript function to calculate the square root of 20.

function calculateSquareRoot() {
    return Math.sqrt(20);

JavascriptDeveloperAgent successfully completed in  1827 ms

JavaScriptFunctionCallTransformationAgent invoked with function code and arguments: function calculateSquareRoot() {
    return Math.sqrt(20);

JavaScriptInterpreterAgent successfully completed in  3111 ms

Generated OpenAI Function Call: {
  "name": "calculateSquareRoot",
  "description": "This function returns the square root of 20.",
  "parameters": {
    "type": "object",
    "properties": {},
    "required": []

Calling function with params:

Function result: 4.47213595499958

JavaScriptCodeInterpreterAgent successfully completed in  11787 ms

# console.log(response); from
response {
  message: "The square root of 20 is approximately 4.47.",
  success: true,
  duration: 11787

Build Instructions

Install Bun

Run the following commands:

bun install

bun run build


We welcome contributions! Please feel free to submit a pull request.

Download Details:

Author: mattlgroff
Source Code: 
License: MIT license

#openai #function #agents 

Function Agents: OpenAI-powered Tasks
1.65 GEEK