toucans
1.0.0
Kein Bullshit -Eingabeaufforderungsingenieurwesen mit Jinja2 für dynamische schnelle Vorlagen und Litellm, um eine breite Palette von LLM -Anbietern nahtlos zu verwenden.
pip install toucans
Initialisieren Sie eine Eingabeaufforderung:
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 }}" },
],
)
Erstellen Sie eine Fertigstellung, indem Sie die Eingabeaufforderung mit einem Satz aufrufen:
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 )
Speichern/laden Sie die Eingabeaufforderung in ein Verzeichnis:
# Push to dir (not implemented yet)
sentiment . push_to_dir ( "./sentiment/" )
# Load from dir (not implemented yet)
sentiment = PromptFunction . from_dir ( "./sentiment/" )
Drücken/Ziehen Sie die Eingabeaufforderung aus dem Hub der Toukaner:
# Push to hub
sentiment . push_to_hub ( "juunge/sentiment" )
# Load from hub
sentiment = PromptFunction . from_hub ( "juunge/sentiment" )
Das Laden aus dem Hub des Toucans erfordert vorerst selbst eine Instanz davon selbst und setze die Umgebungsvariable hub_api_url.