Prompt Engineering - CREATE A LIST Prompt



The CREATE A LIST prompt allows us to harness the power of ChatGPT to generate curated lists of items, recommendations, or suggestions.

By utilizing the CREATE A LIST directive, we can prompt ChatGPT to provide organized and structured responses in the form of lists.

Understanding the CREATE A LIST Directive

The CREATE A LIST directive enables us to instruct ChatGPT to generate lists based on specific criteria or prompts. By incorporating the CREATE A LIST directive in our prompts, we can leverage ChatGPT's knowledge and language understanding to create curated lists.

The basic syntax for the CREATE A LIST directive is as follows −

User: Can you create a list of must-read books?
ChatGPT: Certainly! Here are some must-read books:
- "To Kill a Mockingbird" by Harper Lee
- "1984" by George Orwell
- "Pride and Prejudice" by Jane Austen
- "The Great Gatsby" by F. Scott Fitzgerald

In this example, the user requests a list of must-read books. The response from ChatGPT includes a curated list of books based on the given prompt.

Best Practices for Using the CREATE A LIST Directive

To make the most of the CREATE A LIST directive, let's consider the following best practices −

  • Provide Clear and Specific Prompts − Clearly state the criteria or topic for which we need a list. The more specific and detailed the prompt, the more focused and relevant the generated list will be.

  • Organize the List − Format the response generated by ChatGPT as a well-structured list. Use bullet points, numbers, or other appropriate formatting to present the items in an organized and readable manner.

  • Contextualize the List − Incorporate relevant context or specific requirements within the prompt to guide the generation of the list. This helps ensure that the list aligns with the specific criteria or constraints of the given topic.

  • Iterate and Refine − Experiment with different prompts and iterate on them to generate diverse and comprehensive lists. Adjust the prompts based on the quality and relevance of the generated lists.

Example Application − Python Implementation

Let's explore a practical example of using the CREATE A LIST directive with a Python script that interacts with ChatGPT.

In this example, we define a function generate_chat_response() that takes a prompt and uses the OpenAI API to generate a response using ChatGPT.

The chat_prompt variable contains the user's prompt and the ChatGPT response, including the CREATE A LIST directive to create a list of must-watch movies.

import openai

# Set your API key here
openai.api_key = 'YOUR_API_KEY'

def generate_chat_response(prompt):
   response = openai.Completion.create(
      engine="text-davinci-003",
      prompt=prompt,
      max_tokens=100,
      temperature=0.7,
      n=1,
      stop=None
   )
   return response
   
user_prompt = "User: Can you create a list of must-watch movies?\n"
chat_prompt = user_prompt + "ChatGPT: [CREATE A LIST: must-watch movies]"

response = generate_chat_response(chat_prompt)
print(response)

Output

When we run the script, we will receive the generated response from ChatGPT, including the curated list of movies specified within the CREATE A LIST directive.

1. The Godfather (1972) 
2. The Shawshank Redemption (1994) 
3. The Dark Knight (2008) 
4. Schindler's List (1993) 
5. Pulp Fiction (1994) 
6. The Lord of the Rings Trilogy (2001-2003) 
7. The Good, the Bad and the Ugly (1966) 
8. 12 Angry Men (1957)

Conclusion

In this chapter, we explored the CREATE A LIST directive in prompt engineering for ChatGPT. By utilizing the CREATE A LIST directive, we can leverage ChatGPT to generate curated lists of items, recommendations, or suggestions.

Advertisements