Function just not giving best response

When I use function, it does worse job than simply just calling the get message endpoint.
the function give answers are incorrect most of the time.

{
  "name": "get_entities",
  "description": "Get entities from given name and locaitions and type",
  "parameters": {
    "type": "object",
    "properties": {
      "entities": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "Name of person (human-being) or company, to identify an Australian company from a financial document. An Australian company typically has a name with proprietary terms like 'Pty' or 'Ltd', indicating a private entity. They are assigned an Australian Business Number (ABN), an 11-digit identifier, or an Australian Company Number (ACN), which is 9 digits. Legal phrases such as 'Incorporated', 'Proprietary', or 'Limited' are commonly used in their names, aligning with Australian business law. Using this criteria, I need to determine if a name in this document represents an Australian company"
            },
            "address": {
              "type": "string",
              "description": "locaition, e.g. 1303E 888 Collins street"
            },
            "entityType": {
              "type": "string",
              "description": "Please analyze the provided document to identify the type of each entity mentioned within it. The possible entity types are limited to 'settlor', 'trustee', 'beneficiaries', 'appointor', and 'advisor'. Each entity in the document should correspond to only one of these categories. Base your response strictly on the information in the document and indicate the identified type for each entity."
            }
          }
        }
      }
    },
    "required": [
      "entities"
    ]
  }
}

my promt

I need to extract and analyze entity information from a Trust Deed document. The task is to identify the names and addresses of persons and companies mentioned in the document and categorize them by their entity type. The expected output should be in JSON format, including the 'name', 'address', and 'type' for each identified entry.

the following wordings are wordings that are extracted from the trustdeed to help you find what I need, those wordings include human name, company name and address.

John Kennedy, 1/90 Marshall Street, Ivanhoe, Victoria, 3079, Smith Holdings Pty Ltd, 124 The Righi, Eaglemont, Victoria, 3084, Smith Family Trust, Seamus O'Concheanainn, Seamus Padraig O'Concheanainn, Rhonda Fallon

Please return the results in JSON format only. If you successfully find the information, present it in the specified JSON structure. If you cannot find any relevant information, simply respond with: { "result": "failed" }. Do not include any plaintext explanations or additional details in your response or make up your answer.

my promt works better without my function. it looks like my function even confused the GPT. it always messed up at the entity Type property.

can you try this updated function?

{
  "name": "get_entities",
  "description": "Extracts entities from the provided document, identifying each entity's name, location, and type.",
  "parameters": {
    "type": "object",
    "properties": {
      "entities": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "The name of the entity. This could be a person or a company. For example, an Australian company typically includes proprietary terms like 'Pty' or 'Ltd' in its name, and is assigned an Australian Business Number (ABN) or an Australian Company Number (ACN)."
            },
            "address": {
              "type": "string",
              "description": "The location of the entity, formatted as a full address. For example, '1303E 888 Collins Street, Melbourne, VIC 3008, Australia'."
            },
            "entityType": {
              "type": "string",
              "description": "The type of entity, based on the information provided in the document. Possible types include 'settlor', 'trustee', 'beneficiaries', 'appointor', and 'advisor'. Each entity should correspond to only one of these categories."
            }
          }
        }
      }
    },
    "required": [
      "entities"
    ]
  }
}

Thanks for the response. I have tried your altered function. however, the answer is still incorrect as always. No matter how I describe those properties, it looks like the function just simply make the GPT even confuse what I am looking for. one of horrific answer that were given from the function is not even the correct Json format.

I modified the function again to align better with what you need by using enum on entityType.

{
    "name": "get_entities",
    "description": "Extracts entities from the given text, identifying each entity's name, location, and type.",
    "parameters": {
      "type": "object",
      "properties": {
        "entities": {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "description": "The name of the entity. This could be a person or a company. For example, an Australian company typically includes proprietary terms like 'Pty' or 'Ltd' in its name, and is assigned an Australian Business Number (ABN) or an Australian Company Number (ACN)."
              },
              "address": {
                "type": "string",
                "description": "The location of the entity, formatted as a full address. For example, '1303E 888 Collins Street, Melbourne, VIC 3008, Australia'."
              },
              "entityType": {
                "type": "string",
                "description": "The type of entity, based on the information provided in the document.",
                "enum": [
                    "settlor", 
                    "trustee", 
                    "beneficiaries", 
                    "appointor", 
                    "advisor",
                    "unknown"
                ]
              }
            },
            "required": [
                "name",
                "entityType"
            ]
          }
        }
      },
      "required": [
        "entities"
      ]
    }
}

Here is my simple system prompt

let system_prompt = `You are a helpful assistant.\n` +
        `You will extract entities from the given text by calling get_entities function.`

Then I get a mock Trust of Deed for testing

THIS DEED OF TRUST is made on this 20th day of November, 2023.

BETWEEN

**Settlor:**
Mr. John Doe
Address: 1234 Elm Street, Sydney, NSW 2000, Australia

**Trustee:**
XYZ Pty Ltd
Address: 5678 Oak Avenue, Melbourne, VIC 3000, Australia

**Beneficiaries:**
1. Ms. Jane Doe
   Address: 9012 Pine Road, Brisbane, QLD 4000, Australia
2. ABC Pty Ltd
   Address: 3456 Maple Lane, Adelaide, SA 5000, Australia

**Appointor:**
Mr. Richard Roe
Address: 7890 Birch Boulevard, Perth, WA 6000, Australia

**Advisor:**
DEF Ltd
Address: 1234 Willow Way, Hobart, TAS 7000, Australia

The Settlor has agreed to settle the sum of AUD 10,000 upon the Trustee, and the Trustee has agreed to hold the Trust Fund upon the trusts and with and subject to the powers and provisions hereinafter declared and contained of and concerning the same.

IN WITNESS WHEREOF, the parties hereto have executed this Deed as of the day and year first above written.

____________________
John Doe, Settlor

____________________
XYZ Pty Ltd, Trustee

____________________
Richard Roe, Appointor

____________________
DEF Ltd, Advisor

Here is the output

{
  entities: [
    {
      name: 'Mr. John Doe',
      address: '1234 Elm Street, Sydney, NSW 2000, Australia',
      entityType: 'settlor'
    },
    {
      name: 'XYZ Pty Ltd',
      address: '5678 Oak Avenue, Melbourne, VIC 3000, Australia',
      entityType: 'trustee'
    },
    {
      name: 'Ms. Jane Doe',
      address: '9012 Pine Road, Brisbane, QLD 4000, Australia',
      entityType: 'beneficiaries'
    },
    {
      name: 'ABC Pty Ltd',
      address: '3456 Maple Lane, Adelaide, SA 5000, Australia',
      entityType: 'beneficiaries'
    },
    {
      name: 'Mr. Richard Roe',
      address: '7890 Birch Boulevard, Perth, WA 6000, Australia',
      entityType: 'appointor'
    },
    {
      name: 'DEF Ltd',
      address: '1234 Willow Way, Hobart, TAS 7000, Australia',
      entityType: 'advisor'
    }
  ]
}

I tried your function with little alteration and your promt with your given trustdeed. the function indeed return desired result. however, whenever I switch to my trustdeed files which is found online and the content of the file is long and fairly complicated. none of them given correct result.

btw im testing it in playground.

thanks for you help tho. I prob will just go the old way to call for the completion API instead of using tool api since the answer that given without function is always correct.