toucans
1.0.0
Aucune ingénierie rapide de conneries utilisant Jinja2 pour les modèles d'invite dynamique et Litellm pour utiliser de manière transparente une large gamme de fournisseurs LLM.
pip install toucans
Initialiser une InviteFunction:
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 }}" },
],
)
Générez une réalisation en appelant le promptfunction avec une phrase:
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 )
Enregistrer / charger le promptfonction vers un répertoire:
# Push to dir (not implemented yet)
sentiment . push_to_dir ( "./sentiment/" )
# Load from dir (not implemented yet)
sentiment = PromptFunction . from_dir ( "./sentiment/" )
Push / Tirez la fonction d'invite du hub Toucans:
# Push to hub
sentiment . push_to_hub ( "juunge/sentiment" )
# Load from hub
sentiment = PromptFunction . from_hub ( "juunge/sentiment" )
Pour l'instant, le chargement à partir du hub Toucans nécessite d'héberger vous-même une instance et de définir la variable d'environnement Hub_API_URL.