Mehrstufige Unterhaltungen
Erweitern wir den Reise-Chatbot so, dass Nutzer:innen auf die anfängliche Empfehlung des Modells reagieren können. Du verwendest wieder die Klasse Conversation, rufst das Modell diesmal aber mehrfach auf, um zu sehen, wie es mit früheren Informationen umgeht.
Zur Erinnerung, hier sind die Methoden der Klasse Conversation:
__init__(self, llm: Llama, system_prompt='', history=[])create_completion(self, user_prompt='')
Diese Übung ist Teil des Kurses
Arbeiten mit Llama 3
Anleitung zur Übung
- Bitte um eine erste Reiseempfehlung und stelle nach der ersten Modellantwort eine Nachfrage.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
chatbot = Conversation(llm, system_prompt="You are a travel expert that recommends a travel destination based on a prompt. Return the location name only as 'City, Country'.")
# Ask for the initial travel recommendation
first_recommendation = chatbot.____("Recommend a Spanish-speaking city.")
print(first_recommendation)
# Add an additional request to update the recommendation
second_recommendation = chatbot.____("A different city in the same country")
print(second_recommendation)