Toucans is a streamlined library designed for agile and flexible prompt engineering, leveraging jinja2 for dynamic prompt templating and litellm to seamlessly connect with a wide range of language model providers.
Getting Started
Installation
pip install toucans
Initialize Prompt Function
To initialize a PromptFunction:
from toucans import PromptFunction
qa_func = PromptFunction(
model="gpt-4",
temperature=0.7,
messages=[
{"role": "system", "content": "You are a helpful {{ role }}."},
{"role": "user", "content": "Answer the following question: {{ question }}"},
],
)
Generate Completion
Generate a completion by calling the PromptFunction with the desired role and question:
completion = qa_func(
role="Software Developer",
question="What is clean code?"
)
Save Prompt Function
To save the initialized PromptFunction to a directory or the toucans hub:
# Push to dir (not implemented yet)
qa_func.push_to_dir("./qa/")
# Push to toucans hub
qa_func.push_to_hub("juunge/qa")
Load Saved Prompt Function
To load a saved PromptFunction from a directory or the toucans hub:
# Load from dir (not implemented yet)
qa_func = PromptFunction.from_dir("./qa/")
# Load from toucans hub
qa_func = PromptFunction.from_hub("juunge/qa")
Loading from Toucans Hub requires that you run a hub and connect to it by setting the HUB_API_URL environment variable.
Metadata
Release files for toucans 0.0.14
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 | |
|---|---|---|---|---|
| toucans-0.0.14.tar.gz | 3.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| toucans-0.0.14-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.6 kB
Release files / toucans-0.0.14.tar.gz
| Download URL | toucans-0.0.14.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c638e7f0465953cfb33c5cbda4a987a1a44263efc3bce4cd5edc5bca1e45e0f7
|
|
BLAKE2b-256 checksum How to use checksums |
62c0645ac3053ae673b11a94a1ecb07c4468334d1087a759ccf5dde1bee3ce24
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Darwin/22.4.0
|
Release files / toucans-0.0.14-py3-none-any.whl
| Download URL | toucans-0.0.14-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7cfe615b0e40f3cbe78f9dca6b0c8a6c0fc1c9e9199f55a219d18081f8f0ff2b
|
|
BLAKE2b-256 checksum How to use checksums |
5f7670e773f967e98a01faa1698d70e5c26802d3fe05710935cdb7c94e49a6a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.6 Darwin/22.4.0
|
Security for toucans 0.0.14
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.