Skip to content

Public Models

OpenAI API models

This module contains the models for the OpenAI API.

The models are used to validate the data sent to and received from the OpenAI API.

The models are based on the OpenAI API documentation and use Pydantic to help serialise and deserialise the JSON.

OpenAIFunction

Bases: BaseModel

OpenAI function

This class represents an OpenAI function.

Attributes:

Name Type Description
name str

The name of the function

description str

The description of the function, used by OpenAI to decide whether to use the function

parameters OpenAIParameters

The parameters of the function

Source code in src/simple_openai/models/open_ai_models.py
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class OpenAIFunction(BaseModel):
    """OpenAI function

    This class represents an OpenAI function.

    Attributes:
        name (str): The name of the function
        description (str): The description of the function, used by OpenAI to decide whether to use the function
        parameters (OpenAIParameters): The parameters of the function
    """

    name: str
    description: str
    parameters: OpenAIParameters

OpenAIParameter

Bases: BaseModel

OpenAI parameter

This class represents an OpenAI parameter.

Attributes:

Name Type Description
type str

The type of the parameter

description str

The description of the parameter, used by OpenAI to decide whether to use the parameter

Source code in src/simple_openai/models/open_ai_models.py
13
14
15
16
17
18
19
20
21
22
23
24
class OpenAIParameter(BaseModel):
    """OpenAI parameter

    This class represents an OpenAI parameter.

    Attributes:
        type (str): The type of the parameter
        description (str): The description of the parameter, used by OpenAI to decide whether to use the parameter
    """

    type: str
    description: str

OpenAIParameters

Bases: BaseModel

OpenAI parameters

This class represents a list of OpenAI parameters.

Attributes:

Name Type Description
type str

The type of the parameters

properties dict[str, OpenAIParameter]

The parameters

required list[str]

The required parameters. Defaults to [].

Source code in src/simple_openai/models/open_ai_models.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class OpenAIParameters(BaseModel):
    """OpenAI parameters

    This class represents a list of OpenAI parameters.

    Attributes:
        type (str): The type of the parameters
        properties (dict[str, OpenAIParameter]): The parameters
        required (list[str], optional): The required parameters. Defaults to [].
    """

    type: str = "object"
    properties: dict[str, OpenAIParameter]
    required: list[str] = []