ActionAI
A small library to run local functions using the openai function calling
Warning This library is still in its early stages, so please use it cautiously. If you find any bugs, please create a new issue.
Install
pip install actionai
Usage
Note A function must be fully typed and must have a docstring
# define a new function
def get_current_weather(location: str, unit: str = "fahrenheit"):
"""Function to get current weather for the given location"""
weather_info = {
"location": location,
"temperature": "72",
"unit": unit,
"forecast": ["sunny", "windy"],
}
return weather_info
import actionai
action = actionai.ActionAI()
action.register(get_current_weather)
response = action.prompt("What is the current weather in the north pole?")
print(response["choices"][0]["message"]["content"])
# The current weather at the North Pole is 72°F. It is sunny and windy.
The openai api key will be read automatically from the OPENAI_API_KEY environment variable. You can pass it manually as,
import actionai
action = actionai.ActionAI(openai_api_key="YOUR_KEY")
Adding context
Sometimes your function will have variables that need to be set by the program.
def list_todos(user: str):
"""Function to list all todos"""
return todos[user]
action = actionai.ActionAI(context={"user": "jason"})
The context keys are skipped when creating json schema. The values are directly passed at the time of the function call.
Choosing a model
By default, the completion run on the gpt-3.5-turbo-0613 model. You can change the model using the model argument.
import actionai
action = actionai.ActionAI(model="gpt-4")
You can see the complete list of supported chat completion models here
Demo
Running todo example 👇🏻
For more examples, check out the examples directory.
Metadata
Release files for actionai 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| actionai-0.0.7.tar.gz | 5.4 kB | Without provenance | Details for actionai-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| actionai-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for actionai-0.0.7-py3-none-any.whl |
Total release size: 11.3 kB
Release files / actionai-0.0.7.tar.gz
| Download URL | actionai-0.0.7.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c19f95c272fef2567c87d02966492d33a7f28ed0da59ddd85f3559f4b6e6144b
|
|
BLAKE2b-256 checksum How to use checksums |
a41fb753f6e634cb8d879770a43559fe73d134ce5a3d48ca26d022fd5adc1fd7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.10 Darwin/22.5.0
|
Release files / actionai-0.0.7-py3-none-any.whl
| Download URL | actionai-0.0.7-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae4e8e892a8424f5ad7483e86710dce43825d09df696780f68724d2e9bad629c
|
|
BLAKE2b-256 checksum How to use checksums |
374de9add6f05101a4651b26dff6af969222597e6d182ec9f53c67db3b3d0164
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.2.0 CPython/3.10.10 Darwin/22.5.0
|
Security for actionai 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.