Skip to main content

Create AI prediction functions by describing what they should do. Register at https://fxn.ai.

Project description

AutoFunction

autofxn

Create AI prediction functions by describing what they do. This project explores using an AI agent to write AI prediction functions, which can then be used to make predictions from anywhere using Function.

This project is what powers creating predictors from prompts on fxn.ai/create.

Installing AutoFunction

AutoFunction is distributed on PyPi. This distribution contains both the Python library and the command line interface (CLI):

# Open a terminal and run the following command:
pip install autofxn

Writing Predictor Code with AI

First, you will need to generate an OpenAI API key with GPT-4 access:

# Specify your OpenAI API key
export OPENAI_API_KEY="<Your OpenAI API key>"

✅ If you don't have an OpenAI account, you can generate predictors from prompts at zero cost at fxn.ai/create.

Next, run the following command to generate a predictor notebook:

# Create a predictor notebook that returns a greeting
# This will generate a `predictor.ipynb` notebook in the current directory
autofxn create --output-dir . \
    "Create a predictor that accepts a user's 'name' and returns a greeting"

Usage from Code

This library exports a single function, create_predictor_notebook which generates a predictor notebook from a given prompt:

from autofxn import create_predictor_notebook
from nbformat import NotebookNode, write

# Generate the notebook
prompt = "Create a predictor that accepts a user's 'name' and returns a greeting"
notebook: NotebookNode = create_predictor_notebook(prompt)

# Write to file
with open("predictor.ipynb", "w") as f:
    write(notebook, f)

Making Predictions from Anywhere with Function

With Function, you can use the predictor notebook to make predictions from JavaScript, Python, Unity, Zapier, Slack, and more.

First, register or login to Function and generate an access key:

generate access key

Then login to the Function CLI:

# Open a terminal and run the following command:
fxn auth login <ACCESS KEY>

Now you can create and provision an AI-generated predictor notebook on Function by simply specifying a predictor tag:

# Create a predictor notebook that returns a greeting
autofxn create --tag @username/greeting \
    "Create a predictor that accepts a user's 'name' and returns a greeting"

Replace username with your Function username.

The predictor tag uniquely identifies every predictor on Function.

Once the predictor is active, you can use it to make predictions!

# Make a prediction with our AI-generated predictor
fxn predict @username/greeting --name "Carti"

Roadmap

  • Generate simple predictors that can be provisioned and used for predictions on Function.
  • Support other LLM providers (Anthropic, on-device LLM using edgefxn etc).
  • Plug into organization data sources (Snowflake, Databricks) to leverage highly-relevant information.
  • Fault tolerance with OpenAI API requests.
  • External program correctness and validation testing.
  • Discover and compose Function predictors.
  • Discover and compose GitHub repositories.

Useful Links

Thank you very much!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autofxn-0.0.3.tar.gz (9.8 kB view hashes)

Uploaded Source

Built Distribution

autofxn-0.0.3-py3-none-any.whl (10.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page