BaşlayınÜcretsiz Başlayın

Customizing output format

You work as a developer at a startup that offers a text analysis platform for content creators. Your platform helps users automatically categorize and format their content, and you're now working on a new feature that detects the language of a given piece of text and generates a suitable title for that text in a custom format. You decide to craft a prompt that guides the language model through this.

The OpenAI package, the get_response() function, and the text variable have been pre-loaded for you.

Bu egzersiz

Prompt Engineering with the OpenAI API

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Create the instructions for the prompt, asking the model to determine the language and generate a suitable title for the pre-loaded text excerpt that will be provided using triple backticks (```) delimiters.
  • Create the output_format with directions to include the text, language, and title, each on a separate line, using 'Text:', 'Language:', and 'Title:' as prefixes for each line.
  • Create the final_prompt by combining all parts and the delimited text to use.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

client = OpenAI(api_key="")

# Create the instructions
instructions = ____

# Create the output format
output_format = ____

# Create the final prompt
prompt = ____
response = get_response(prompt)
print(response)
Kodu Düzenle ve Çalıştır