toucans
1.0.0
JINJA2を使用して動的なプロンプトテンプレートを使用して、LitellMを使用してLLMプロバイダーをシームレスに使用するためのブルシットプロンプトエンジニアリングはありません。
pip install toucans
プロンプト機能の初期化:
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 }}" },
],
)
文でPromptFunctionを呼び出すことにより、完了を生成します。
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 )
プロンプト機能をディレクトリに保存/ロードします。
# Push to dir (not implemented yet)
sentiment . push_to_dir ( "./sentiment/" )
# Load from dir (not implemented yet)
sentiment = PromptFunction . from_dir ( "./sentiment/" )
Toucans HubからPromptFunctionをプッシュ/プルする:
# Push to hub
sentiment . push_to_hub ( "juunge/sentiment" )
# Load from hub
sentiment = PromptFunction . from_hub ( "juunge/sentiment" )
とりあえず、Toucans Hubからの読み込みには、自分でインスタンスをホストし、hub_api_url環境変数を設定する必要があります。