codex-function

1.0.1 • Public • Published

Codex-Function

A Node.JS library to generate functions at runtime using OpenAI Codex.

⚠️ DO NOT USE IN ANY PRODUCTION CODE! ⚠️

⚠️ THIS WILL DOWNLOAD CODE FROM OPENAI AND EVAL IT ⚠️

Usage

This library currently only supports ESM imports.
The library will automaticly try to find a key in an environmental variable called OPENAI_KEY.
If you do not have this one you can manually set the key.

import { setOpenAIKey } from "codex-function";

setOpenAIKey("someSuperSecretKey");

To generate a function you do

import { createFunction } from "codex-function";

const fizzbuzz = await createFunction("prints fizzbuzz from 0 to 100");

fizzbuzz();

Notice how createFunction needs to be awaited as it needs to make a HTTP request to OpenAI API.

If you want the function to take in arguments you need to pass in an array of those.
This is done so that AI has something more to work with and you know what to pass to the generate function.

import { createFunction } from "codex-function";

const add = await createFunction("add together two numbers", ["a", "b"]);

console.log(add(15, 20));

Readme

Keywords

none

Package Sidebar

Install

npm i codex-function

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

11.8 kB

Total Files

12

Last publish

Collaborators

  • anttie