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.8.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toucans-0.0.8-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file toucans-0.0.8.tar.gz.

File metadata

  • Download URL: toucans-0.0.8.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.6 Darwin/22.4.0

File hashes

Hashes for toucans-0.0.8.tar.gz
Algorithm Hash digest
SHA256 be167cb7796cc1f09a34395580b34ca35c6c6be1b9608d6a552156580666d84a
MD5 312fa8a7ae0bf28cb739705bd8fad0e8
BLAKE2b-256 28a723d1486928f5fce90465acd8a4c95b26002fa9b808c5d89ab576e55b9fde

See more details on using hashes here.

File details

Details for the file toucans-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: toucans-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 6.0 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

Hashes for toucans-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4d10cfa5f772ca42c99b7727789eeb1c17f586ec1fea71fbbd5070f2b0920063
MD5 215fb744af53b4f9858118b230133a61
BLAKE2b-256 a4680b3aa01bfad5e3b66b6da1d5f562de3a5537faeb65ce26e600f69aed8894

See more details on using hashes here.

Supported by

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