Use ChatGPT like a Pro: Hallucination and Chaining

Using ChatGPT like a Pro.

Use ChatGPT like a Pro: Hallucination and Chaining

In the realm of AI-powered text generation, fine-tuning the parameters of your interactions with models like ChatGPT can significantly impact the quality and relevance of the responses you receive. From managing response length to altering the "temperature" setting, exploring chaining techniques, and using strategic prompt examples, these are essential tactics for wielding ChatGPT effectively. In this blog, we will delve into each of these aspects to help you master the art of prompting, ensuring that you can harness the full potential of ChatGPT to suit your specific needs, while also addressing challenges like hallucinations. Whether you're using it for creative writing, content generation, or problem-solving, understanding these prompt-related strategies is crucial for achieving the desired outcomes in your AI-powered conversations.

🪄 Prompting Tips & Tricks

How to Limit Response Length

Phrases to try:

  • "Be concise"
  • "Limit prose"
  • "No explanations"

Generating Summary Per Message in Conversation

ChatGPT 3.5 can’t do instructions like “write a bullet point for each message.” Instead, you have to tell how many bullet points to write:

Write {{ @bullets | length }} bullet points summarizing the messages. Write one bullet per message

Avoiding Hallucination

  • Turn down the temperature to 0.2-0.3, especially for summarization tasks
  • Use chaining to get information. E.g.: fetch a page via search and then have GPT summarize it vs. asking GPT directly

Including Multiple Comments of Free Form Text

To refer to multiple instances of free-form text, I’ve found it helpful to wrap each instance in a tag to help delineate it from the others:

{% for @comment of @comments $} 
{{ @comment }} 
{% endfor %}

This approach can also distinguish customer vs. agent messages:

{% for @comment of @comments $} 
<{{ "customer" if @comment.isCustomer else "agent"> 
{{ @comment.text }} 
</{{ "customer" if @comment.isCustomer else "agent"> 
{% endfor %}

⛓️ Chaining

Escaping {{ in Text Templates with {% raw % }

If you want ChatGPT to generate placeholders for use in mail-merge or downstream text templates, you need to escape the template braces in the prompt.

Example of telling ChatGPT how to use Salesforce Merge Fields:

Use the following placeholders for the sender and recipient: 
- Recipient {% raw %}{{{Recipient.FirstName}}}{% endraw %} 
- Sender: {% raw %}{{{Sender.Name}}}{% endraw %}

Prompt Examples

Generating JSON

The ratings generated from this prompt don’t seem to be very accurate. Needs chain of thought prompting to improve.


You are an AI designed to train and evaluate customer support agents. 

You will be given the following: 
- A customer request in text format 
- A support agent response in text format 
- A grading rubric in JSON format 

Complete the grading rubric by replacing <number> with a rating 1-5. A rating of 1 corresponds to "Not at all," and a rating of 5 corresponds to "Outstanding." 

Do not provide any other response except for the scorecard in JSON format.


Customer request: 

My package didn't arrive yet. Could you tell me when it's supposed to arrive? 

Associate response: 

Hi there! I checked the portal, and it looks like your package was delivered yesterday. You can check your shipment status using the shipment tracking portal. Let me know if you have any problems with the item. Enjoy! 

Your scorecard: 
  "Was the customer issue understood and all inquiries solved correctly?": <number>, 
  "Was the question answered with empathy?": <number>, 
  "Did the associate anticipate future questions?": <number>, 
  "Did the associate provide helpful resources where possible?": <number>, 
  "Was the interaction easily readable?": <number>, 
  "Provide an overall rating?": <number>, 

Parsing JSON

  • Use the Parse JSON brick
  • Always wrap in a Try-Except in case Chat GPT decides to respond with non-JSON. (ChatGPT will return non-JSON if it thinks it’s unable to perform the task)

Recommending Tools/Actions with Placeholders

  1. Provide the available actions in JSON Schema Format.
  2. Minify the available actions.'
You are an action recommender. You will be given a customer support conversation.

Respond with a JSON array where each item is a matching action, and the arguments for the action.

If you are missing a piece of information for the argument, provide null for that argument. For example:
{"actions":[{"name":"Check Repair Status","args":{"repair_id": null}}]}

Here is the list of available actions, in JSONSchema format.

{"actions":[{"name":"Check Repairs for Customer","description":"Useful for when you need to check the status of a repair and don't have the repair id","args_schema":{"customer_email":{"type":"string","format":"email","title":"Customer Email","description":"The email address of the customer"}}},{"name":"Check Shipment Status","description":"Useful for when you need to check the status of a shipment","args_schema":{"shipment_id":{"type":"string","title":"Shipment Id","description":"The id of the shipment"}}},{"name":"Check Repair Status","description":"Useful for when you need to check the status a single repair","args_schema":{"repair_id":{"type":"string","title":"Repair Id","description":"The id of the repair"}}}]}

If none of the actions are a good match. Respond with an empty JSON Array []