Git Product home page Git Product logo

aifunction's Introduction

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.

aifunction's People

Contributors

cadenmarinozzi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.