Skip to content

Chicken/codex-function

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published