Chat-gpt is replying with a function_call inside of the `content` portion of the message

I would like to force chat-gpt to always use the function_call for its responses to my prompts.

However, in certain cases I often find that chat-gpt will avoid using a function_call and response only with content. In an attempt to modify this behavior, I added additional prompt instructions and now it seems to be replying with a function_call json object but it is inside the content portion of the response instead of the function_call.

This is a simplified example of my prompt:

Go through the following posts and find any relevant statistics on XYZ.

Always respond with the supplied function_call: “collect_all_statistics”.

If there are no statistics, return the function_call of the message with “hasStatistics”: false and set “content” to null.

Note that in my actual prompt, I would replace “XYZ” with an actual topic.

With the above prompt, chat-gpt has a tendency to respond with:

  role: 'assistant',
  content: '{\n' +
    '  "function_call": {\n' +
    '    "function": "functions.collect_conflict_info",\n' +
    '    "kwargs": {\n' +
    '      "hasStatistics": false\n' +
    '    }\n' +
    '  }\n' +

Whereas the desired response is:

  role: 'assistant',
  content: null,
  function_call: {
    hasStatistics: false

What can I do to get the response I want?

For additional context, I am using the openai node.js library (version 3.2.1).
The function_call “collect_all_statistics” is being correctly provided in my completion request. If statistics are found, it seems to generally respond correctly.

You can use the tool_choice parameter to force the model to use a function

How big is your prompt?

Ah thank you. I didn’t see a tool_choice option initially, but I believe the equivalent for the node.js library is function_call. I was only supplying functions before. Prompts range in size, up to a max of about 4K tokens.

Specifying a value for function_call seems to have fixed the issue!

Happy to hear it’s working. You are right that they’re the same. It may be worth changing to tools though as function_call and functions is deprecated

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.