from openai import OpenAI
from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv())
client = OpenAI()
def get_llm_response(message, system=None):
response = client.responses.create(
model="gpt-6-luna",
instructions=system,
input=message
)
print(response.output_text)Get the model to write a social media post announcing the opening of a new coffee shop.
Write the simplest prompt you can for this task and run it. Save the result and note what you like and don't like.
get_llm_response("...") # your prompt hereWrite two more versions of your prompt, each better than the last. Try adding things like:
- A role for the model
- Context: the name of the shop, its location, what makes it special
- Format: length, tone, emojis or not, hashtags or not
- Do's and don'ts
Run each version and compare the three results. Which prompt gave the best output? Why?
Reuse your best prompt, but change the tone or audience (e.g. formal LinkedIn post, post for teenagers, post in another language). How much of the prompt do you need to change?
Add one example of a post you like to your prompt (one-shot). Does the output get closer to your example's style?
Solution: Iteration 1 and 2
There is no single correct answer. Here is one example of how prompts can evolve:
# Version 1: basic
get_llm_response("Write a post announcing a new coffee shop.")
# Version 2: role + context
get_llm_response(
"Write a post announcing the opening of a new coffee shop called 'Bean There', "
"located in downtown Madrid. It serves specialty coffee and homemade pastries.",
system="You are a social media manager for local businesses."
)
# Version 3: role + context + format + do's and don'ts
get_llm_response(
"Write a post announcing the opening of a new coffee shop called 'Bean There', "
"located in downtown Madrid. It serves specialty coffee and homemade pastries. "
"The opening is this Saturday at 9am.",
system="""
You are a social media manager for local businesses.
Write one Instagram post with these rules:
- Friendly, warm tone
- Maximum 50 words
- Include 3 hashtags at the end
- Use at most 2 emojis
- Do not invent discounts or prices
"""
)What to notice: each added piece of information (context, format, constraints) makes the output more specific and closer to what you want.