Skip to main content

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:

prompt_func.push_to_dir("./prompt_save_dir/")

Load Saved Prompt Function

To load a saved PromptFunction from a directory:

prompt_func = PromptFunction.from_dir("./prompt_save_dir/")

By following these steps, you can easily initialize, save, and load a PromptFunction for your needs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toucans-0.0.7.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

toucans-0.0.7-py3-none-any.whl (6.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page