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 }}" },
],
)
通過用句子調用提示功能來生成一個完成:
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推動/提取及時功能:
# Push to hub
sentiment . push_to_hub ( "juunge/sentiment" )
# Load from hub
sentiment = PromptFunction . from_hub ( "juunge/sentiment" )
目前,從Toucans集線器加載需要自己託管一個實例,並設置HUB_API_URL環境變量。