CommencerCommencer gratuitement

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='')

Cet exercice fait partie du cours

Working with Llama 3

Afficher le cours

Instructions

  • 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).

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

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)
Modifier et exécuter le code