What is the JSON schema for OpenAI function properties for a two dimensional array.
As of my knowledge cutoff in September 2021, OpenAI does not provide a specific JSON schema for function properties that includes a two-dimensional array. However, you can define the structure of a two-dimensional array within the function properties using a nested array structure. Here’s an example of how you might structure the properties for an OpenAI function with a two-dimensional array using JSON:
In this example, the function has a parameter named “array” which is an array of arrays. The inner arrays represent rows in the two-dimensional array, and each element within the inner arrays represents a value in the two-dimensional array (in this case, numbers). The output of the function is also a two-dimensional array with the same structure.
Please note that the actual schema for OpenAI function properties may differ depending on the specific implementation and requirements of the OpenAI API. It’s always a good idea to refer to the official OpenAI documentation or resources for the most up-to-date and accurate information on function properties.
I have not tried this.
IIRC this is what I found the other day, may or may not be correct.
This OpenAI API reference page
Section: Create chat completion
parameters object Optional
The parameters the functions accepts, described as a JSON Schema object. See the guide for examples, and the JSON Schema reference for documentation about the format.
I found using pydantic made things easier for me and worked well with str, int, lists and dictionaries.
Here is an example where I extract data from a set of user interviews.
from pydantic import BaseModel, Field
from typing import Optional, List
# define function structure in pydantic
name: str = Field(..., description="Classification category")
count: int = Field(..., description="Count for the category")
interviewee_names: List[str] = Field(..., description="The names of the interviewees, e.g. Christoph, person y")
interviewee_count: int = Field(..., description="Number of people interviewed")
interview_topics: List[Topic] = Field(..., description="List of top 10 classification categories with their counts")