Get startedGet started for free

Extracting the response

The data analytics AI assistant must return clean and readable responses to users, and the company has asked you to extract only the relevant text from the model's response.

Extract and print only the generated text from the pre-imported Llama's response.

This exercise is part of the course

Working with Llama 3

View Course

Exercise instructions

  • Extract the "text" from the first element of the "choices" list in response and store it in extracted.
  • Print extracted.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Extract the first choice and generated text
extracted = response["choices"]____

# Print the extracted text
print(____)
Edit and Run Code