Skip to content

cadenmarinozzi/AIFunction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Function

Generate realtime AI Functions!

Installation

Python

To install AI Function for python, run:

pip install AIFunction

Node.js

To install AI Function for node.js, run:

npm install aifunction

Usage

To use AIFunction, you must have an OpenAI API key.

aiFunction(name <string>, description <string>, installPackages <bool>)
  • name: The name of the function. Ex: "time", "current_president"
  • description: A description of the function. Ex: "Returns the current time", "Returns the date in the format YYYY-MM-DD"
  • installPackages: Whether or not to install the required packages for the function. Ex: "time" requires the "datetime" package, so it will be installed if this is set to true.

Python

Firstly, add a .env file to your project, and add the following:

OPENAI_API_KEY="key_here"

Then, import the aiFunction function:

from AIFunction import aiFunction

Now, you can use the aiFunction function to generate AI Functions!

print(aiFunction("bitcoin_price", "Returns the current price of bitcoin."));
# --> 27002.055

Node.js

Firstly, add a .env file to your project, and add the following:

OPENAI_API_KEY="key_here"

Then, import the aiFunction function:

const aiFunction = require("aifunction");

Now, you can use the aiFunction function to generate AI Functions!

(async () => {
  console.log(await aiFunction("time", "Return the current time"));
})();
// --> 12:00:00

What is an AI Function?

Let's say you want to write a function to get the current time in python. All you have to do is:

from AIFunction import aiFunction

print(aiFunction("time", "Returns the current time."));
# --> 12:00:00

How does it work?

AI function uses OpenAI's GPT model to generate the code for the function. It then runs the code and returns the output. If specified, it will also install the required packages for the code.

Security

AI Functions are not very secure, as they run code without any user testing, and can be used to run malicious code.

About

Generate realtime AI Functions!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published