Skip to content

Is it impossible to construct this simple JSON schema for a function definition? #321

@SwiftedMind

Description

@SwiftedMind

Hey,

so, I might just be stupid but I struggle with building a very simple JSON object schema as a tool.

What I want is this:

{
  "name": "Name",
  "parameters": {
    "type": "object",
    "properties": {
      "key": {
        "type": "object",
        "properties": {
          "anotherKey": "value"
        }
      }
    }
  }
}

But this seems impossible to build with ChatQuery.ChatCompletionToolParam.FunctionDefinition:

let tool = ChatQuery.ChatCompletionToolParam.FunctionDefinition(
  name: "name",
  parameters: .init(
    type: .object,
    properties: [
      "key": .init(
        type: .object,
        // cant' use "properties" here, there's just "items", which is technically not allowed
      )
    ]
  )
)

Is there a trick to this? Or am I doing something wrong?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions