npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

function-agents

v0.0.17

Published

A collection of Function Agents with specific purposes, utilizing the OpenAI API.

Downloads

39

Readme

function-agents

Introduction

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 https://platform.openai.com/docs/guides/gpt/function-calling.

Installation

To install the package, run the following command:

npm install function-agents

Dependencies

  • 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(
    'your-openai-api-key',
    'gpt-4-0613' // or any other supported model
);

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

Agents

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))

Citation

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

Parameters

  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 agent.run()
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

Contributing

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

License

This package is under the MIT License. See LICENSE file for more details.