toucans
1.0.0
No Bullshit Prompt Engineering Menggunakan Jinja2 untuk Templating Dinamis Prompt dan Litellm untuk dengan mulus menggunakan berbagai penyedia LLM.
pip install toucans
Inisialisasi fungsi prompt:
from toucans import PromptFunction
sentiment = PromptFunction (
model = "gpt-4" ,
temperature = 0.7 ,
messages = [
{ "role" : "system" , "content" : "You are a helpful mood-sensitive agent." },
{ "role" : "user" , "content" : "Determine the sentiment of the sentence: {{ sentence }}" },
],
)
Menghasilkan penyelesaian dengan menelepon fungsi prompt dengan kalimat:
completion = sentiment ( sentence = "I'm so happy!" )
batch_args = [
{ "sentence" : "Toucans is nice Python package!" },
{ "sentence" : "I hate bloated prompt engineering frameworks!" }
]
completion_batch = sentiment . batch_call ( batch_args = batch_args )
Simpan/muat fungsi prompt ke direktori:
# Push to dir (not implemented yet)
sentiment . push_to_dir ( "./sentiment/" )
# Load from dir (not implemented yet)
sentiment = PromptFunction . from_dir ( "./sentiment/" )
Tekan/tarik fungsi prompt dari hub Toucans:
# Push to hub
sentiment . push_to_hub ( "juunge/sentiment" )
# Load from hub
sentiment = PromptFunction . from_hub ( "juunge/sentiment" )
Untuk saat ini, memuat dari hub Toucans memerlukan hosting sendiri dan mengatur variabel lingkungan hub_api_url.