Prompts
Description of your new file.
Writing a prompt
A prompt is a set of natural language instructions to an AI Agent that detail everything the Agent does, how it does those things, and what it shouldn’t do. Through the prompt, you also give the Agent access to tools which give it the ability to do useful work like schedule appointments, or relay messages. A prompt can be reused by multiple agents.
Writing a good prompt for an AI to follow is the same as writing good instructions for a human to follow. It’s essentially a written communication challenge that requires the prompt writer to write clear, unambiguous, and explicit instructions. Writing a good prompt for your use case is an iterative process that requires lots of trial and error, writing and testing.
-
Give the Agent(s) a role: Tell the Agent(s) exactly what role you want it to assume, like “You are a conscientious customer service agent who is dedicated to helping callers out with their appointment related requests.”
-
State the context: Define the situations when the Agent would be used, such as people calling in to manage an appointment, or ask a question about their bill.
-
State the desired behavior: Specify how you want the Agent to respond to callers, and give examples of how you want it to respond. For example, ““Please use phrases like ‘Thank you,’ ‘You’re welcome,’ and ‘How can I assist you?’ during the call.” and “Keep responses short and to the point to avoid confusion.
-
Set Parameters: Include specific guidelines about error handling and edge cases, like “Do not give out medical advice or attempt to diagnose any condition, medical or otherwise.”
-
Give the prompt access to a tool: Explicitly mention the name of the tool, its purpose, and usage conditions. For example, “Use the ScheduleNewAppointment tool to schedule new appointments for callers. Only use this tool if the day is on or between Monday-Friday AND the time is between 9am-5pm PST.”
Here’s an example of a low quality prompt and an example of a high quality prompt:
Example Prompt 1
"Reply to a customer who is mad about their late order."
Low quality prompt attributes:
-
Lack of Clarity: The instruction is vague and does not specify what to include in the response.
-
Lack of Conciseness: Although short, it is too brief to provide meaningful guidance.
-
Irrelevance: The prompt does not guide the LLM on how to address the customer’s feelings or the issue.
-
Ambiguousness: The term “mad” is vague, and the prompt does not specify the tone or content required.
-
Lack of Explicitness: There are no explicit instructions on what elements the response should contain, leading to potential gaps in the reply.
Example Prompt 2
"As an AI customer service agent, craft a response to a customer who is upset because their order did not arrive on time. Your response should include an apology, an explanation of possible reasons for the delay, a reassurance that the issue will be addressed, and an offer for compensation or a solution. Keep the response professional, empathetic, and concise."
High Quality Prompt Attributes:
-
Clarity: The task is clearly defined with specific elements to include (apology, explanation, reassurance, and offer for compensation).
-
Conciseness: The prompt is direct and to the point, without unnecessary details.
-
Relevance: All instructions are related to addressing the customer’s complaint.
-
Unambiguousness: There is no room for misinterpretation about what the response should contain.
-
Explicitness: Each part of the desired response is explicitly described, ensuring the LLM understands the structure and tone needed.
The cost of a prompt
Each word and punctuation mark in your prompt counts toward the token limit. Longer prompts and responses use more tokens, increasing the cost. The more concise your instructions, the cheaper it will be to run.
You can estimate the cost of your prompt with OpenAI’s Tokenizer: https://platform.openai.com/tokenizer
Other prompt resources
If you’re interested in learning more about how to write effective prompts for your AI Agent, check out some of these resources: