Python AI Functions
Simple library that can convert from python functions to a JSON schema description of those functions, suitable for use with AI libraries.
For example:
from ai_functions import get_openai_functions, execute_function
def search_web(query: Annotated[str, "google formatted keywords to search for"]):
"""Search the web"""
print(openai_function_dict([search_web]))
Also, if you get a response.function_call from openai, you can use execute_function
openai_function_execute([search_web], function_call)
Or, if you have the name and arguments split out already:
function_execute([search_web], name, arguments)
Finally, if you want a container to handle this:
from ai_functions import AIFunctions
container = AIFunctions([search_web, add_calendar_entry])
functions = container.openai_dict()
subset_functions = container.openai_dict(["search_web"])
container.execute("search_web", {"query":"top web hosting sites"})
container.opeanai_execute({"name": "search_web", "arguments": "{\"query\":\"top web hosting sites\"}")
It handles converting arguments to JSON if they are specified as a string.
It auto-casts arguments to the right types, if they aren't right.
It returns errors that AI engines understands, instead of errors with poor descriptions.
If a loop is provided to the AIFunctions constructor, or to any execute calls, it will be used to schedule a coroutine.
Async versions of execute are available, prefix all calls with async_
Metadata
Release files for ai-functions 0.1.0
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 |
|---|---|---|---|---|
| ai_functions-0.1.0.tar.gz | 3.2 kB | Without provenance | Details for ai_functions-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ai_functions-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ai_functions-0.1.0-py3-none-any.whl |
Total release size: 7.0 kB
Release files / ai_functions-0.1.0.tar.gz
| Download URL | ai_functions-0.1.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fbdce75308ff62076241b697513463ae151639d3724d4727cb452b67e0a4bfec
|
|
BLAKE2b-256 checksum How to use checksums |
96862a0143d5fcfc3fd2021bedd6aa8eb3883c99901466cba19abf5bdc6bde52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Release files / ai_functions-0.1.0-py3-none-any.whl
| Download URL | ai_functions-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
09c1e104f114f81f1e31a1e29b816538ab0f1e1d03368243ae28ae042131826e
|
|
BLAKE2b-256 checksum How to use checksums |
3989b6f68a08c30d220dbed06588822e083469abf3171107e14853aef22f7c2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for ai-functions 0.1.0
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.