Skip to main content

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!

Release files for autofxn 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for autofxn 0.0.3
File Size Uploaded
autofxn-0.0.3.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for autofxn 0.0.3
File Interpreter ABI Platform
autofxn-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 20.7 kB

Release files / autofxn-0.0.3.tar.gz

Download URL autofxn-0.0.3.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
18c293af2a77c7c002ad3451b7375709a967e9442939293941d337cff1b713a2
BLAKE2b-256 checksum
How to use checksums
d81f0199a058166394eedfbd1a140277223e62a293f896cfd490bf56d265ec81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release files / autofxn-0.0.3-py3-none-any.whl

Download URL autofxn-0.0.3-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9e1ca500174276e26b31476528635fe23fcb98a2a878e012df8b8ade2d26d47
BLAKE2b-256 checksum
How to use checksums
0dead8ba8b6ebc236b71fb79d783ce6c0ce46d4a419232605c14c25712c00270
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.17

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page