No project description provided
Project description
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
prompt_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 = prompt_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)
prompt_func.push_to_dir("./prompt_save_dir/")
# Push to toucans hub
prompt_func.push_to_hub("./prompt_save_dir/")
Load Saved Prompt Function
To load a saved PromptFunction from a directory or the toucans hub:
# Load from dir (not implemented yet)
prompt_func = PromptFunction.from_dir("./prompt_save_dir/")
# Load from toucans hub
prompt_func = PromptFunction.from_hub("./prompt_save_dir/")
Loading from Toucans Hub requires that you run a hub and connect to it by setting the HUB_API_URL environment variable.
By following these steps, you can easily initialize, save, and load a PromptFunction for your needs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toucans-0.0.13.tar.gz.
File metadata
- Download URL: toucans-0.0.13.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/22.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07498531d6ef8ab22d936d4db17d66aef59e8da1453e8e01cbc0a4fc4242fbe8
|
|
| MD5 |
aa0b7f7bffd91f36089206d037073cf7
|
|
| BLAKE2b-256 |
30ff1311564a60a2b5989dc94f06691c37d8c3a9d861967dede247612f6acd70
|
File details
Details for the file toucans-0.0.13-py3-none-any.whl.
File metadata
- Download URL: toucans-0.0.13-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/22.4.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e512477221cd36fcb3bb7fb8af3e228843dfd0605ba8653511cd01be869cdd74
|
|
| MD5 |
486ca829e2418d18bddde2095b26ff09
|
|
| BLAKE2b-256 |
e70348718e1e8f7c6a75b08e75a15c73d6901951cbd62ecae30747d0ae289128
|