Generate realtime AI Functions!
To install AI Function for python, run:
pip install AIFunction
To install AI Function for node.js, run:
npm install aifunction
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.
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
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
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
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.
AI Functions are not very secure, as they run code without any user testing, and can be used to run malicious code.