toucans
1.0.0
Nenhuma engenharia imediata de besteira usando o Jinja2 para obter modelos dinâmicos de prompt e litellm para usar perfeitamente uma ampla gama de fornecedores de LLM.
pip install toucans
Inicialize uma Função de 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 }}" },
],
)
Gere uma conclusão chamando a função de prompt com uma frase:
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 )
Salvar/carregar a Função de Prompt para um diretório:
# Push to dir (not implemented yet)
sentiment . push_to_dir ( "./sentiment/" )
# Load from dir (not implemented yet)
sentiment = PromptFunction . from_dir ( "./sentiment/" )
Empurre/puxe a função rápida do hub toucans:
# Push to hub
sentiment . push_to_hub ( "juunge/sentiment" )
# Load from hub
sentiment = PromptFunction . from_hub ( "juunge/sentiment" )
Por enquanto, o carregamento do hub toucans requer hospedagem em uma instância e defina a variável de ambiente hub_api_url.