autofunc
Easily define Python functions for structured output from GPT-4.
⚠️ This was primarily written for personal use, and is neither well-tested nor documented. There are similar and much better projects out there, such as magentic.
Install
pip install autofunc
Usage
Expects OPENAI_API_KEY to be defined in your environment.
Define your function
from autofunc import AutoFunc
swap_animals = AutoFunc("Swap the animals in the sentence. Eg. The dog barked at the cat -> the cat meowed at the dog")
Call it
swap_animals("The tigers growled at each other until they saw the snakes slithering near the trees.")
'The snakes hissed at each other until they saw the tigers prowling near the trees.'
Use pydantic for structured output
from pydantic import BaseModel, Field
class TravelDescription(BaseModel):
from_city: str = Field(description="City name including the country")
to_city: str = Field(description="City name including the country")
mode_of_travel: str = Field(description="eg. train or flight")
description: str = Field(description="A one-line description of a fictional journey, in the style of an adventure game. Simple present tense.")
duration: str
travel_fn = AutoFunc("Describe travelling between the two provided cities.", TravelDescription)
travel_fn("londres to paris")
{
'from_city': 'London, United Kingdom',
'to_city': 'Paris, France',
'mode_of_travel': 'train',
'description': 'You embark on a journey from the bustling city of London, crossing the English Channel through the Eurotunnel, to the romantic city of Paris.',
'duration': '2 hours 20 minutes'
}
CHANGES
2023.10.05: Initial release
Metadata
Release files for autofunc 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 |
|---|---|---|---|---|
| autofunc-0.1.0.tar.gz | 4.4 kB | Without provenance | Details for autofunc-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| autofunc-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for autofunc-0.1.0-py3-none-any.whl |
Total release size: 8.2 kB
Release files / autofunc-0.1.0.tar.gz
| Download URL | autofunc-0.1.0.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
60ec5a986808cad7bc1263ffdeb2688805b1f1fd33be92d0a2df0c502ea7fc04
|
|
BLAKE2b-256 checksum How to use checksums |
2ad3321c1aaa6b1ffe1db2b1b50f808e0e649af38963b3d1e574d0d61060625c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / autofunc-0.1.0-py3-none-any.whl
| Download URL | autofunc-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e82e3ac40627ea76836bedfccbbc669beb2135dc60851d3a10b355fe83d2610
|
|
BLAKE2b-256 checksum How to use checksums |
d1a60fa4b26796581897ddb57652ef17de69ffe93d6f03a43487fdfbe066a065
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for autofunc 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.