skip to Main Content

Explanation

I am currently working on a game project using the openapi and python. One of the function calling I had wrote is given below.

getCaseFile

{
    "name": "getCaseFile",
    "description": "Generate a hard to solve, self-contained detective game scenario including a brief introduction, setting, key characters, and initial evidence or clues. The scenario should be structured to allow for interactive investigation through text commands such as 'Inspect the area', 'Talk to [character name]', or 'Examine [object]'. Ask user whats their next move but don't display choices of what to do. Provide a clear mystery or objective for the player to solve, ensuring the narrative includes enough detail for engaging gameplay without prior knowledge of this conversation. Avoid making your message seem like a chatgpt response and make it so its like a story beginning, maybe your partner letting you in on the details or maybe you just got the files on the event and your reading them. AVOID TEXT FORMATTING since the text will be displayed in a terminal.",
    "parameters": {
        "type": "object",
        "required": ["case_name", "intro", "setting", "key_characters", "initial_clues", "solution", "objective"],
        "properties": {
            "case_name": {
                "type": "string",
                "description": "The name of the case file. Eg: The Vanishing Vintner"
            },
            "intro": {
                "type": "string",
                "description": "A brief introduction to the story. Eg: As a seasoned detective, you were just briefed on a new case by your partner, who looked specifically concerned about this one. 'It's baffling,' they said, handing over a file. 'An esteemed winemaker, Paulo Rossetti, vanished without a trace from his locked winery. Here's the kicker: no one was seen entering or leaving the place around the time he disappeared. We need your expertise.' You open the dossier and begin unraveling the case details."
            },
            "setting": {
                "type": "string",
                "description": "A brief explanation of the setting. Eg: The case is set at the Rossetti Vineyard, a sprawling estate known for its exquisite wines and its owner's exceptional taste. The majestic villa and adjacent winery are surrounded by acres of grapevines. Paulo Rossetti was last seen in his private study inside the winery, a room known to have one solid locked door and no windows."
            },
            "key_characters": {
                "type": "array",
                "description": "A list of suspects with their name, maybe title or position, and their relationship to the crime",
                "items": {
                    "type": "string"
                }
            },
            "initial_clues": {
                "type": "array",
                "description": "A list of initial clues. Eg: A vintage bottle of wine, with its seal intact, was left on Paulo's desk.",
                "items": {
                    "type": "string"
                }
            },
            "solution": {
                "type": "object",
                "additionalProperties": {
                    "type": "object",
                    "required" : ["culprit", "motive", "key_evidence"],
                    "properties": {
                        "culprit": {
                            "type": "string",
                            "description": "Name and last name of the culprit."
                        },
                        "motive" : {
                            "type": "string",
                            "description": "Motive of the culprit."
                        },
                        "key_evidence": {
                            "type": "string",
                            "description": "The key evidence for the crime commited by the culprit."
                        }
                    }
                }
            },
            "objective": {
                "type": "string",
                "description": "A simple objective to let player know that its time to act. Eg: Determine who is responsible for Paulo Rossetti's disappearance and uncover the motive behind their actions."
            }
        }
    }

}

As you can see, this function takes 7 paramaters with one of them being, solution, a dictionary that has 3 keys inside.

When I use this function calling with the OpenApi Playground, it does not provide me the solution.

An example given below:

getCaseFile(
    {
     "case_name": "The Mysterious Machinations at Merriweather Mansion", 
     "intro": "Just as you settle into your office with a steamy cup of coffee, your partner slides a bulky folder across the desk toward you. 'Here's something that will put that caffeine to good use,' they quip. The file contains details about the passing of a reclusive millionaire, Bernard Blackwood, found motionless at his estate. 'Bernard was a hermit, hardly seen outside his study. The doors were locked from the inside. No signs of forced entry, no obvious cause of death. This case is a real head-scratcher.'", 
     "setting": "The sprawling and enigmatic Merriweather Mansion, a remote abode located just outside the sleepy town of Galeshire. The mansion is known for its eccentric design and assortment of automatons and contraptions. Bernard was discovered in his personal study, a place brimming with oddities and inventions.", 
     "key_characters": [
          "Bernard Blackwood - The deceased millionaire and inventor.", 
          "Cecil Hawthorne - The estate's caretaker and Bernard's old friend.", 
          "Agatha Christie - The suspiciously named and ambitious niece.", 
          "Dr. Edward Bellamy - The family doctor last to visit Bernard.", 
          "Sofia Marlowe - The reclusive author living as a guest on the property."
     ], 
     "initial_clues": [
          "An unusual mechanical device on Bernard's desk, unfinished and whirring silently.", 
          "A will, freshly revised, with significant changes to beneficiaries.", 
          "A torn piece of fabric caught on a bramble outside a study window that doesn't quite close.", 
          "Bernard's journal, open to a page expressing his growing paranoia over someone betraying him."
     ], 
     "objective": "Unravel the cause of Bernard's death, decipher who could have engineered such an elaborate act, and determine their motive."
     }
 )

What is the reason of this occurance, and how can I fix it?

2

Answers


  1. Chosen as BEST ANSWER

    I solved my problem after long hours of searching the web.

    Apparently additionalProperties keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword or match any of the regular expressions in the patternProperties keyword.

    The correct use was:

    ...
    
    "solution": {
            "type": "object",
            "properties": {
                 "culprit": {
                      "type": "string",
                      "description": "Name and last name of the culprit."
                 },
                 "motive" : {
                      "type": "string",
                      "description": "Motive of the culprit."
                 },
                 "key_evidence": {
                      "type": "string",
                      "description": "The key evidence for the crime commited by the culprit."
                 }
             }
         }
    
    ...
    

    Instead of using additionalProperties, I used the properties which allowed me to have properties that had listed names on the schema.


  2. I can’t speak to why the tool is omitting the solution property, but the schema doesn’t look right.

    The way you have it, it’s an object that can take any number of properties of any name, where each value must itself be an object with culprit, motive, and key_evidence properties. From your description, this sounds nested one level too deep.

    My suggestion to resolve this is to extract the inner schema and throw away the outer (with type and additionalProperties).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search