AutoFNS
Introduction
AutoFNS is a wrapper around OpenAI's Chat Completion API.
It allows you to define functions as you normally would, and have them be called automatically when a message containing tool calls is detected. This allows you to focus on more important things, like the logic of your application.
Note: 🧪 This is a work in progress and may not be ready for production use.
Requirements
- python >= 3.10
- openai
Installation
pip install autofns
Usage
from autofns import AutoFNS
FUNCTION_DEFINITIONS = [
{
"type": "function",
"function": {
"name": "get_temp_units",
"description": "Get a list of temperature units",
}
},
{
"type": "function",
"function": {
"name": "get_current_temperature",
"description": "Get the current temperature in a city",
},
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The city to get the temperature of",
},
"unit": {
"type": "string",
"description": "The unit to get the temperature in",
"enum": ["Fahrenheit", "Celsius", "Kelvin"],
}
},
"required": ["city", "unit"],
}
},
]
def get_temp_units():
return ["Fahrenheit", "Celsius", "Kelvin"]
def get_current_temperature(city: str, unit: str):
return "The current temperature in {} is {} degrees {}".format(
city, 72, unit
)
fns = AutoFNS(
"gpt-4-32k",
fns_mapping={
"get_temp_units": get_temp_units,
"get_current_temperature": get_current_temperature
},
fns_definitions=FUNCTION_DEFINITIONS,
)
result = fns.create_completion(messages=[...])
You can also use the AutoFNSAsync class to use async functions:
from autofns import AutoFNSAsync
fns = AutoFNSAsync(...)
result = await fns.create_completion(messages=[...])
License
This project is licensed under the terms of the MIT license.
Contributing
Contributions are welcome! Please open an issue or a pull request.
Metadata
Release files for autofns 0.1.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 |
|---|---|---|---|---|
| autofns-0.1.7.tar.gz | 4.0 kB | Without provenance | Details for autofns-0.1.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| autofns-0.1.7-py3-none-any.whl | Python 3 | none | any | Details for autofns-0.1.7-py3-none-any.whl |
Total release size: 8.4 kB
Release files / autofns-0.1.7.tar.gz
| Download URL | autofns-0.1.7.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0a7ab25a77787c4f91dab2a39844170cf9a018465f73f06f01077979eb0b9e62
|
|
BLAKE2b-256 checksum How to use checksums |
dd2ea50aa0cfadc44ab9d9c0f91fdd81801048dc2ea49a758849dfb857200303
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / autofns-0.1.7-py3-none-any.whl
| Download URL | autofns-0.1.7-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6f1d2a1947a35680738a2cd04a0ba2a658ccdad6bf028f6011e031bfdf0228c
|
|
BLAKE2b-256 checksum How to use checksums |
3f3ed69e93849163f6239b1a0e3d7fdcf90fee136be1b80b872b5f3165a1714c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for autofns 0.1.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.