LoslegenKostenlos loslegen

Single-turn conversation

Time to give your Conversation class a go! You'll use this class to create a travel recommendation chatbot, that takes a description or specification of what you're looking for, and the model returns a location.

The Conversation class you created in the previous exercise is still available with the following methods:

  • __init__(self, llm: Llama, system_prompt='', history=[])
  • create_completion(self, user_prompt='')

Diese Übung ist Teil des Kurses

Working with Llama 3

Kurs anzeigen

Anleitung zur Übung

  • Instantiate an Conversation class with the instruction defined and the pre-loaded llm.
  • Send a prompt to the model to get a travel recommendation (feel free to add your own prompt here).

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

instruction = "You are a travel expert that recommends a travel destination based on a specification. Return the location name only in City, Country form."

# Define a chatbot using the Conversation class
chatbot = ____(llm, system_prompt=____)

# Send a prompt to the model
result = chatbot.____("I'd like to learn about the Aztecs.")
print(result)
Code bearbeiten und ausführen