ChatGPT Endpoint Doesn't Listen to Basic Instructions!

If I ask ChatGPT to output ‘X’, and not to output anything else, it will output ‘Here is X! I hope this helps!’ or similar. It is really frustrating.

I am asking it to output a dash separated list of values where each is a complete sentence and it outputs single words at times separated by a dash and won’t listen to the instructions. It is breaking my project.

Welcome to the Forum!

Can you show some examples of your prompt and the resulting response?

response = openai.ChatCompletion.create(
            model=model_engine,
            messages=[
                {"role": "user", "content": "Take the input and output a dash separated list of steps."},
                {"role": "user", "content": "Each dash separated output must be a complete sentence."},
                {"role": "user", "content": "The input is: " + primary_objective},
            ]
        )

What is the primary objective? How do you build a swimming pool?

  • First
    you need to choose a suitable location for your swimming pool.
  • Then
    you have to obtain the necessary permits and approvals from the local authorities.
  • Excavate the area and prepare it for the installation of the pool.
  • Install the pool shell and connect the plumbing and electrical systems.
  • Pour concrete around the pool and install the decking.
  • Fill the pool with water and balance the chemicals to make it safe for swimming.
  • Install any necessary safety features such as fencing or pool covers.
  • Finally
    add any desired features such as lighting
    landscaping
    or water features.

Each line should be a complete sentence, as my script parses the dashes into newline characters. Please ask me to elaborate if you are having trouble understanding my code, I only included a snippet.

1 Like

For similar task, I use Text Completions API. It is more reliable specially if you give them several sample response.

1 Like

I see, do you have an example of the usage of that endpoint? The one I am using looks like this.

model_engine = "gpt-3.5-turbo"

response = openai.ChatCompletion.create(
            model=model_engine,
            messages=[
                {"role": "user", "content": "Take the input and output a dash separated list of steps."},
                {"role": "user", "content": "Each dash separated output must be a complete sentence."},
                {"role": "user", "content": "The input is: " + primary_objective},
            ]
        )

try this

import os
import openai

openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.Completion.create(
  model="text-davinci-003",
  prompt="You are Bob the builder.\n\nTake the user input and output a dash separated list of steps to achieve the user input.\nEach dash separated output must be a complete sentence.\n\nSample:\nUser Input: how to plant basil\n\nOutput:\n-Gather your basil plant potting mix, pot, and basil seedling.\n-Fill the pot with the potting soil so that the soil level is an inch or two below the pot’s rim.\n-Place the seedling into the pot and fill in the area around the roots with the potting mix.\n-Gently press the soil around the roots to ensure the roots will have contact with the soil.\n-Water the plant so that the soil is moist.\n-Move the pot to a sunny spot and check the soil moisture daily.\n\nUser Input: build swimming pool\n\nOutput:",
  temperature=1,
  max_tokens=256,
  top_p=1,
  frequency_penalty=0,
  presence_penalty=0,
  stop=["Output:"]
)

prompt is:

You are Bob the builder.

Take the user input and output a dash separated list of steps to achieve the user input.

Each dash separated output must be a complete sentence.

Sample:

User Input: how to plant basil

Output:

-Gather your basil plant potting mix, pot, and basil seedling.

-Fill the pot with the potting soil so that the soil level is an inch or two below the pot’s rim.

-Place the seedling into the pot and fill in the area around the roots with the potting mix.

-Gently press the soil around the roots to ensure the roots will have contact with the soil.

-Water the plant so that the soil is moist.

-Move the pot to a sunny spot and check the soil moisture daily.

User Input: build swimming pool

Output:

2 Likes

It works! Is there any way to achieve this with the turbo-3.5 endpoint? I know it is a bit more expensive for the completions endpoint and I am using it a lot. I am building a babyAGI-like application which calls this function hundreds of times.

Using Chat Completions API plainly will give output with additional texts like your previous result. You can probably just remove them when you parse the result.

Another way, is to use function call. Using this function:

{
        name: "how_to",
        description: "Generate steps to achieve user input",
        parameters: {
            type: "object",
            properties: {
                steps: {
                    type: "array",
                    items: {
                        type: "string",
                    }
                }
            },
            required: ["steps"]
        }
    }

To call the API:

const messages = [{ role: 'user', content: user_prompt }]
const result = await openai.createChatCompletion({
            messages,
            model: 'gpt-3.5-turbo-0613',
            temperature: 0,
            functions,
        })

Using this user prompt: build swimming pool

Will give this result:

{
  role: 'assistant',
  content: null,
  function_call: {
    name: 'how_to',
    arguments: '{\n' +
      '  "steps": [\n' +
      '    "1. Determine the location and size of the swimming pool.",\n' +
      '    "2. Obtain any necessary permits or approvals from local authorities.",\n' +
      '    "3. Excavate the area for the pool, ensuring it is level and free from any obstructions.",\n' +
      '    "4. Install the pool shell or structure, which can be made of concrete, fiberglass, or vinyl.",\n' +
      '    "5. Connect the necessary plumbing and electrical systems for the pool.",\n' +
      '    "6. Install the pool liner or finish the interior surface of the pool.",\n' +
      '    "7. Fill the pool with water and check for any leaks or issues.",\n' +
      '    "8. Install any additional features such as a pool heater, lighting, or a filtration system.",\n' +
      '    "9. Landscaping around the pool area to enhance its appearance.",\n' +
      '    "10. Regularly maintain and clean the pool to ensure its longevity and safety."\n' +
      '  ]\n' +
      '}'
  }
}
2 Likes