Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions: Support for minItems and maxItems for json schema array #1173

Open
tjhiggins opened this issue Jun 15, 2023 · 0 comments
Open

Functions: Support for minItems and maxItems for json schema array #1173

tjhiggins opened this issue Jun 15, 2023 · 0 comments

Comments

@tjhiggins
Copy link

Describe the feature or improvement you're requesting

First off - let me just say how great functions are! Game changer!

It would be really cool if the functions would respect validation like minItems and maxItems for an array.
If I explicitly put the number of questions I want in the function description it works, but I half expected it to work when setting minItems. Unfortunately, if I specify minItems: 10 it only returns 5 questions.

I'd imagine other json schema validation options are ignored, and this could be a more generic ticket.

const func = {
  name: "generateQuiz",
  description: "Generate a questions about a given topic",
  parameters: {
    type: "object",
    properties: {
      topics: {
        type: "array",
        items: {
          type: "string",
          description: "Topic of the lesson, e.g. Planes",
        },
      },
      questions: {
        type: "array",
        minItems: 10,
        maxItems: 20,
        description:
          "Questions, e.g. What is the primary function of an airplane?",
        items: {
          type: "object",
          properties: {
            question: {
              type: "string",
              description:
                "Question, e.g. What is the primary function of an airplane?",
            },
            answer: {
              type: "string",
              description: "Answer for the question",
            },
          },
          required: ["question", "answer"],
        },
      },
    },
    required: ["topic", "questions"],
  },
};

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant