toucans
1.0.0
동적 프롬프트 템플릿을 위해 Jinja2를 사용하는 헛소리 프롬프트 엔지니어링 및 광범위한 LLM 제공 업체를 원활하게 사용하기 위해 Litellm.
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 허브에서 프롬프트 기능을 푸시/당기십시오.
# Push to hub
sentiment . push_to_hub ( "juunge/sentiment" )
# Load from hub
sentiment = PromptFunction . from_hub ( "juunge/sentiment" )
현재 Toucans 허브에서로드하려면 직접 인스턴스를 호스팅하고 Hub_api_url 환경 변수를 설정해야합니다.