IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Working with Llama 3

Visualizza il corso

Istruzioni dell'esercizio

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

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

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

# Print the extracted text
print(____)
Modifica ed esegui il codice