openapiopenai 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openapiopenai/__init__.py +93 -0
- openapiopenai/api/__init__.py +5 -0
- openapiopenai/api/open_ai_api.py +6334 -0
- openapiopenai/api_client.py +759 -0
- openapiopenai/api_response.py +21 -0
- openapiopenai/configuration.py +437 -0
- openapiopenai/exceptions.py +200 -0
- openapiopenai/models/__init__.py +76 -0
- openapiopenai/models/chat_completion_functions.py +92 -0
- openapiopenai/models/chat_completion_request_message.py +105 -0
- openapiopenai/models/chat_completion_request_message_function_call.py +90 -0
- openapiopenai/models/chat_completion_response_message.py +108 -0
- openapiopenai/models/chat_completion_stream_response_delta.py +111 -0
- openapiopenai/models/create_chat_completion_request.py +178 -0
- openapiopenai/models/create_chat_completion_request_function_call.py +141 -0
- openapiopenai/models/create_chat_completion_request_function_call_one_of.py +88 -0
- openapiopenai/models/create_chat_completion_request_model.py +144 -0
- openapiopenai/models/create_chat_completion_request_stop.py +145 -0
- openapiopenai/models/create_chat_completion_response.py +110 -0
- openapiopenai/models/create_chat_completion_response_choices_inner.py +106 -0
- openapiopenai/models/create_chat_completion_stream_response.py +104 -0
- openapiopenai/models/create_chat_completion_stream_response_choices_inner.py +106 -0
- openapiopenai/models/create_completion_request.py +201 -0
- openapiopenai/models/create_completion_request_model.py +144 -0
- openapiopenai/models/create_completion_request_prompt.py +185 -0
- openapiopenai/models/create_completion_request_stop.py +151 -0
- openapiopenai/models/create_completion_response.py +110 -0
- openapiopenai/models/create_completion_response_choices_inner.py +110 -0
- openapiopenai/models/create_completion_response_choices_inner_logprobs.py +94 -0
- openapiopenai/models/create_completion_response_usage.py +92 -0
- openapiopenai/models/create_edit_request.py +123 -0
- openapiopenai/models/create_edit_request_model.py +144 -0
- openapiopenai/models/create_edit_response.py +106 -0
- openapiopenai/models/create_edit_response_choices_inner.py +113 -0
- openapiopenai/models/create_embedding_request.py +100 -0
- openapiopenai/models/create_embedding_request_input.py +179 -0
- openapiopenai/models/create_embedding_request_model.py +144 -0
- openapiopenai/models/create_embedding_response.py +106 -0
- openapiopenai/models/create_embedding_response_data_inner.py +92 -0
- openapiopenai/models/create_embedding_response_usage.py +90 -0
- openapiopenai/models/create_fine_tune_request.py +170 -0
- openapiopenai/models/create_fine_tune_request_model.py +150 -0
- openapiopenai/models/create_image_request.py +132 -0
- openapiopenai/models/create_moderation_request.py +98 -0
- openapiopenai/models/create_moderation_request_input.py +144 -0
- openapiopenai/models/create_moderation_request_model.py +144 -0
- openapiopenai/models/create_moderation_response.py +100 -0
- openapiopenai/models/create_moderation_response_results_inner.py +100 -0
- openapiopenai/models/create_moderation_response_results_inner_categories.py +100 -0
- openapiopenai/models/create_moderation_response_results_inner_category_scores.py +100 -0
- openapiopenai/models/create_transcription_request_model.py +144 -0
- openapiopenai/models/create_transcription_response.py +88 -0
- openapiopenai/models/create_translation_response.py +88 -0
- openapiopenai/models/delete_file_response.py +92 -0
- openapiopenai/models/delete_model_response.py +92 -0
- openapiopenai/models/error.py +104 -0
- openapiopenai/models/error_response.py +92 -0
- openapiopenai/models/fine_tune.py +147 -0
- openapiopenai/models/fine_tune_event.py +94 -0
- openapiopenai/models/images_response.py +98 -0
- openapiopenai/models/images_response_data_inner.py +90 -0
- openapiopenai/models/list_files_response.py +98 -0
- openapiopenai/models/list_fine_tune_events_response.py +98 -0
- openapiopenai/models/list_fine_tunes_response.py +98 -0
- openapiopenai/models/list_models_response.py +98 -0
- openapiopenai/models/model.py +94 -0
- openapiopenai/models/open_ai_file.py +107 -0
- openapiopenai/py.typed +0 -0
- openapiopenai/rest.py +256 -0
- openapiopenai-1.0.0.dist-info/METADATA +19 -0
- openapiopenai-1.0.0.dist-info/RECORD +73 -0
- openapiopenai-1.0.0.dist-info/WHEEL +5 -0
- openapiopenai-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
OpenAI API
|
|
5
|
+
|
|
6
|
+
APIs for sampling from and fine-tuning language models
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Contact: blah+oapicf@cliffano.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional, Union
|
|
23
|
+
from typing_extensions import Annotated
|
|
24
|
+
from openapiopenai.models.chat_completion_functions import ChatCompletionFunctions
|
|
25
|
+
from openapiopenai.models.chat_completion_request_message import ChatCompletionRequestMessage
|
|
26
|
+
from openapiopenai.models.create_chat_completion_request_function_call import CreateChatCompletionRequestFunctionCall
|
|
27
|
+
from openapiopenai.models.create_chat_completion_request_model import CreateChatCompletionRequestModel
|
|
28
|
+
from openapiopenai.models.create_chat_completion_request_stop import CreateChatCompletionRequestStop
|
|
29
|
+
from typing import Optional, Set
|
|
30
|
+
from typing_extensions import Self
|
|
31
|
+
|
|
32
|
+
class CreateChatCompletionRequest(BaseModel):
|
|
33
|
+
"""
|
|
34
|
+
CreateChatCompletionRequest
|
|
35
|
+
""" # noqa: E501
|
|
36
|
+
model: CreateChatCompletionRequestModel
|
|
37
|
+
messages: Annotated[List[ChatCompletionRequestMessage], Field(min_length=1)] = Field(description="A list of messages comprising the conversation so far. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_format_inputs_to_ChatGPT_models.ipynb).")
|
|
38
|
+
functions: Optional[Annotated[List[ChatCompletionFunctions], Field(min_length=1)]] = Field(default=None, description="A list of functions the model may generate JSON inputs for.")
|
|
39
|
+
function_call: Optional[CreateChatCompletionRequestFunctionCall] = None
|
|
40
|
+
temperature: Optional[Union[Annotated[float, Field(le=2, strict=True, ge=0)], Annotated[int, Field(le=2, strict=True, ge=0)]]] = Field(default=1, description="What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both. ")
|
|
41
|
+
top_p: Optional[Union[Annotated[float, Field(le=1, strict=True, ge=0)], Annotated[int, Field(le=1, strict=True, ge=0)]]] = Field(default=1, description="An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both. ")
|
|
42
|
+
n: Optional[Annotated[int, Field(le=128, strict=True, ge=1)]] = Field(default=1, description="How many chat completion choices to generate for each input message.")
|
|
43
|
+
stream: Optional[StrictBool] = Field(default=False, description="If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only [server-sent events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format) as they become available, with the stream terminated by a `data: [DONE]` message. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_stream_completions.ipynb). ")
|
|
44
|
+
stop: Optional[CreateChatCompletionRequestStop] = None
|
|
45
|
+
max_tokens: Optional[StrictInt] = Field(default=None, description="The maximum number of [tokens](/tokenizer) to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. [Example Python code](https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb) for counting tokens. ")
|
|
46
|
+
presence_penalty: Optional[Union[Annotated[float, Field(le=2, strict=True, ge=-2)], Annotated[int, Field(le=2, strict=True, ge=-2)]]] = Field(default=0, description="Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics. [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details) ")
|
|
47
|
+
frequency_penalty: Optional[Union[Annotated[float, Field(le=2, strict=True, ge=-2)], Annotated[int, Field(le=2, strict=True, ge=-2)]]] = Field(default=0, description="Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim. [See more information about frequency and presence penalties.](/docs/api-reference/parameter-details) ")
|
|
48
|
+
logit_bias: Optional[Dict[str, Any]] = Field(default=None, description="Modify the likelihood of specified tokens appearing in the completion. Accepts a json object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100. Mathematically, the bias is added to the logits generated by the model prior to sampling. The exact effect will vary per model, but values between -1 and 1 should decrease or increase likelihood of selection; values like -100 or 100 should result in a ban or exclusive selection of the relevant token. ")
|
|
49
|
+
user: Optional[StrictStr] = Field(default=None, description="A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. [Learn more](/docs/guides/safety-best-practices/end-user-ids). ")
|
|
50
|
+
__properties: ClassVar[List[str]] = ["model", "messages", "functions", "function_call", "temperature", "top_p", "n", "stream", "stop", "max_tokens", "presence_penalty", "frequency_penalty", "logit_bias", "user"]
|
|
51
|
+
|
|
52
|
+
model_config = ConfigDict(
|
|
53
|
+
populate_by_name=True,
|
|
54
|
+
validate_assignment=True,
|
|
55
|
+
protected_namespaces=(),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def to_str(self) -> str:
|
|
60
|
+
"""Returns the string representation of the model using alias"""
|
|
61
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
62
|
+
|
|
63
|
+
def to_json(self) -> str:
|
|
64
|
+
"""Returns the JSON representation of the model using alias"""
|
|
65
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
66
|
+
return json.dumps(self.to_dict())
|
|
67
|
+
|
|
68
|
+
@classmethod
|
|
69
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
70
|
+
"""Create an instance of CreateChatCompletionRequest from a JSON string"""
|
|
71
|
+
return cls.from_dict(json.loads(json_str))
|
|
72
|
+
|
|
73
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
74
|
+
"""Return the dictionary representation of the model using alias.
|
|
75
|
+
|
|
76
|
+
This has the following differences from calling pydantic's
|
|
77
|
+
`self.model_dump(by_alias=True)`:
|
|
78
|
+
|
|
79
|
+
* `None` is only added to the output dict for nullable fields that
|
|
80
|
+
were set at model initialization. Other fields with value `None`
|
|
81
|
+
are ignored.
|
|
82
|
+
"""
|
|
83
|
+
excluded_fields: Set[str] = set([
|
|
84
|
+
])
|
|
85
|
+
|
|
86
|
+
_dict = self.model_dump(
|
|
87
|
+
by_alias=True,
|
|
88
|
+
exclude=excluded_fields,
|
|
89
|
+
exclude_none=True,
|
|
90
|
+
)
|
|
91
|
+
# override the default output from pydantic by calling `to_dict()` of model
|
|
92
|
+
if self.model:
|
|
93
|
+
_dict['model'] = self.model.to_dict()
|
|
94
|
+
# override the default output from pydantic by calling `to_dict()` of each item in messages (list)
|
|
95
|
+
_items = []
|
|
96
|
+
if self.messages:
|
|
97
|
+
for _item in self.messages:
|
|
98
|
+
if _item:
|
|
99
|
+
_items.append(_item.to_dict())
|
|
100
|
+
_dict['messages'] = _items
|
|
101
|
+
# override the default output from pydantic by calling `to_dict()` of each item in functions (list)
|
|
102
|
+
_items = []
|
|
103
|
+
if self.functions:
|
|
104
|
+
for _item in self.functions:
|
|
105
|
+
if _item:
|
|
106
|
+
_items.append(_item.to_dict())
|
|
107
|
+
_dict['functions'] = _items
|
|
108
|
+
# override the default output from pydantic by calling `to_dict()` of function_call
|
|
109
|
+
if self.function_call:
|
|
110
|
+
_dict['function_call'] = self.function_call.to_dict()
|
|
111
|
+
# override the default output from pydantic by calling `to_dict()` of stop
|
|
112
|
+
if self.stop:
|
|
113
|
+
_dict['stop'] = self.stop.to_dict()
|
|
114
|
+
# set to None if temperature (nullable) is None
|
|
115
|
+
# and model_fields_set contains the field
|
|
116
|
+
if self.temperature is None and "temperature" in self.model_fields_set:
|
|
117
|
+
_dict['temperature'] = None
|
|
118
|
+
|
|
119
|
+
# set to None if top_p (nullable) is None
|
|
120
|
+
# and model_fields_set contains the field
|
|
121
|
+
if self.top_p is None and "top_p" in self.model_fields_set:
|
|
122
|
+
_dict['top_p'] = None
|
|
123
|
+
|
|
124
|
+
# set to None if n (nullable) is None
|
|
125
|
+
# and model_fields_set contains the field
|
|
126
|
+
if self.n is None and "n" in self.model_fields_set:
|
|
127
|
+
_dict['n'] = None
|
|
128
|
+
|
|
129
|
+
# set to None if stream (nullable) is None
|
|
130
|
+
# and model_fields_set contains the field
|
|
131
|
+
if self.stream is None and "stream" in self.model_fields_set:
|
|
132
|
+
_dict['stream'] = None
|
|
133
|
+
|
|
134
|
+
# set to None if presence_penalty (nullable) is None
|
|
135
|
+
# and model_fields_set contains the field
|
|
136
|
+
if self.presence_penalty is None and "presence_penalty" in self.model_fields_set:
|
|
137
|
+
_dict['presence_penalty'] = None
|
|
138
|
+
|
|
139
|
+
# set to None if frequency_penalty (nullable) is None
|
|
140
|
+
# and model_fields_set contains the field
|
|
141
|
+
if self.frequency_penalty is None and "frequency_penalty" in self.model_fields_set:
|
|
142
|
+
_dict['frequency_penalty'] = None
|
|
143
|
+
|
|
144
|
+
# set to None if logit_bias (nullable) is None
|
|
145
|
+
# and model_fields_set contains the field
|
|
146
|
+
if self.logit_bias is None and "logit_bias" in self.model_fields_set:
|
|
147
|
+
_dict['logit_bias'] = None
|
|
148
|
+
|
|
149
|
+
return _dict
|
|
150
|
+
|
|
151
|
+
@classmethod
|
|
152
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
153
|
+
"""Create an instance of CreateChatCompletionRequest from a dict"""
|
|
154
|
+
if obj is None:
|
|
155
|
+
return None
|
|
156
|
+
|
|
157
|
+
if not isinstance(obj, dict):
|
|
158
|
+
return cls.model_validate(obj)
|
|
159
|
+
|
|
160
|
+
_obj = cls.model_validate({
|
|
161
|
+
"model": CreateChatCompletionRequestModel.from_dict(obj["model"]) if obj.get("model") is not None else None,
|
|
162
|
+
"messages": [ChatCompletionRequestMessage.from_dict(_item) for _item in obj["messages"]] if obj.get("messages") is not None else None,
|
|
163
|
+
"functions": [ChatCompletionFunctions.from_dict(_item) for _item in obj["functions"]] if obj.get("functions") is not None else None,
|
|
164
|
+
"function_call": CreateChatCompletionRequestFunctionCall.from_dict(obj["function_call"]) if obj.get("function_call") is not None else None,
|
|
165
|
+
"temperature": obj.get("temperature") if obj.get("temperature") is not None else 1,
|
|
166
|
+
"top_p": obj.get("top_p") if obj.get("top_p") is not None else 1,
|
|
167
|
+
"n": obj.get("n") if obj.get("n") is not None else 1,
|
|
168
|
+
"stream": obj.get("stream") if obj.get("stream") is not None else False,
|
|
169
|
+
"stop": CreateChatCompletionRequestStop.from_dict(obj["stop"]) if obj.get("stop") is not None else None,
|
|
170
|
+
"max_tokens": obj.get("max_tokens"),
|
|
171
|
+
"presence_penalty": obj.get("presence_penalty") if obj.get("presence_penalty") is not None else 0,
|
|
172
|
+
"frequency_penalty": obj.get("frequency_penalty") if obj.get("frequency_penalty") is not None else 0,
|
|
173
|
+
"logit_bias": obj.get("logit_bias"),
|
|
174
|
+
"user": obj.get("user")
|
|
175
|
+
})
|
|
176
|
+
return _obj
|
|
177
|
+
|
|
178
|
+
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
OpenAI API
|
|
5
|
+
|
|
6
|
+
APIs for sampling from and fine-tuning language models
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Contact: blah+oapicf@cliffano.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
|
20
|
+
from typing import Any, List, Optional
|
|
21
|
+
from openapiopenai.models.create_chat_completion_request_function_call_one_of import CreateChatCompletionRequestFunctionCallOneOf
|
|
22
|
+
from pydantic import StrictStr, Field
|
|
23
|
+
from typing import Union, List, Optional, Dict
|
|
24
|
+
from typing_extensions import Literal, Self
|
|
25
|
+
|
|
26
|
+
CREATECHATCOMPLETIONREQUESTFUNCTIONCALL_ONE_OF_SCHEMAS = ["CreateChatCompletionRequestFunctionCallOneOf", "str"]
|
|
27
|
+
|
|
28
|
+
class CreateChatCompletionRequestFunctionCall(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
Controls how the model responds to function calls. \"none\" means the model does not call a function, and responds to the end-user. \"auto\" means the model can pick between an end-user or calling a function. Specifying a particular function via `{\"name\":\\ \"my_function\"}` forces the model to call that function. \"none\" is the default when no functions are present. \"auto\" is the default if functions are present.
|
|
31
|
+
"""
|
|
32
|
+
# data type: str
|
|
33
|
+
oneof_schema_1_validator: Optional[StrictStr] = None
|
|
34
|
+
# data type: CreateChatCompletionRequestFunctionCallOneOf
|
|
35
|
+
oneof_schema_2_validator: Optional[CreateChatCompletionRequestFunctionCallOneOf] = None
|
|
36
|
+
actual_instance: Optional[Union[CreateChatCompletionRequestFunctionCallOneOf, str]] = None
|
|
37
|
+
one_of_schemas: List[str] = Field(default=Literal["CreateChatCompletionRequestFunctionCallOneOf", "str"])
|
|
38
|
+
|
|
39
|
+
model_config = ConfigDict(
|
|
40
|
+
validate_assignment=True,
|
|
41
|
+
protected_namespaces=(),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
46
|
+
if args:
|
|
47
|
+
if len(args) > 1:
|
|
48
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
49
|
+
if kwargs:
|
|
50
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
51
|
+
super().__init__(actual_instance=args[0])
|
|
52
|
+
else:
|
|
53
|
+
super().__init__(**kwargs)
|
|
54
|
+
|
|
55
|
+
@field_validator('actual_instance')
|
|
56
|
+
def actual_instance_must_validate_oneof(cls, v):
|
|
57
|
+
instance = CreateChatCompletionRequestFunctionCall.model_construct()
|
|
58
|
+
error_messages = []
|
|
59
|
+
match = 0
|
|
60
|
+
# validate data type: str
|
|
61
|
+
try:
|
|
62
|
+
instance.oneof_schema_1_validator = v
|
|
63
|
+
match += 1
|
|
64
|
+
except (ValidationError, ValueError) as e:
|
|
65
|
+
error_messages.append(str(e))
|
|
66
|
+
# validate data type: CreateChatCompletionRequestFunctionCallOneOf
|
|
67
|
+
if not isinstance(v, CreateChatCompletionRequestFunctionCallOneOf):
|
|
68
|
+
error_messages.append(f"Error! Input type `{type(v)}` is not `CreateChatCompletionRequestFunctionCallOneOf`")
|
|
69
|
+
else:
|
|
70
|
+
match += 1
|
|
71
|
+
if match > 1:
|
|
72
|
+
# more than 1 match
|
|
73
|
+
raise ValueError("Multiple matches found when setting `actual_instance` in CreateChatCompletionRequestFunctionCall with oneOf schemas: CreateChatCompletionRequestFunctionCallOneOf, str. Details: " + ", ".join(error_messages))
|
|
74
|
+
elif match == 0:
|
|
75
|
+
# no match
|
|
76
|
+
raise ValueError("No match found when setting `actual_instance` in CreateChatCompletionRequestFunctionCall with oneOf schemas: CreateChatCompletionRequestFunctionCallOneOf, str. Details: " + ", ".join(error_messages))
|
|
77
|
+
else:
|
|
78
|
+
return v
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
|
|
82
|
+
return cls.from_json(json.dumps(obj))
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
def from_json(cls, json_str: str) -> Self:
|
|
86
|
+
"""Returns the object represented by the json string"""
|
|
87
|
+
instance = cls.model_construct()
|
|
88
|
+
error_messages = []
|
|
89
|
+
match = 0
|
|
90
|
+
|
|
91
|
+
# deserialize data into str
|
|
92
|
+
try:
|
|
93
|
+
# validation
|
|
94
|
+
instance.oneof_schema_1_validator = json.loads(json_str)
|
|
95
|
+
# assign value to actual_instance
|
|
96
|
+
instance.actual_instance = instance.oneof_schema_1_validator
|
|
97
|
+
match += 1
|
|
98
|
+
except (ValidationError, ValueError) as e:
|
|
99
|
+
error_messages.append(str(e))
|
|
100
|
+
# deserialize data into CreateChatCompletionRequestFunctionCallOneOf
|
|
101
|
+
try:
|
|
102
|
+
instance.actual_instance = CreateChatCompletionRequestFunctionCallOneOf.from_json(json_str)
|
|
103
|
+
match += 1
|
|
104
|
+
except (ValidationError, ValueError) as e:
|
|
105
|
+
error_messages.append(str(e))
|
|
106
|
+
|
|
107
|
+
if match > 1:
|
|
108
|
+
# more than 1 match
|
|
109
|
+
raise ValueError("Multiple matches found when deserializing the JSON string into CreateChatCompletionRequestFunctionCall with oneOf schemas: CreateChatCompletionRequestFunctionCallOneOf, str. Details: " + ", ".join(error_messages))
|
|
110
|
+
elif match == 0:
|
|
111
|
+
# no match
|
|
112
|
+
raise ValueError("No match found when deserializing the JSON string into CreateChatCompletionRequestFunctionCall with oneOf schemas: CreateChatCompletionRequestFunctionCallOneOf, str. Details: " + ", ".join(error_messages))
|
|
113
|
+
else:
|
|
114
|
+
return instance
|
|
115
|
+
|
|
116
|
+
def to_json(self) -> str:
|
|
117
|
+
"""Returns the JSON representation of the actual instance"""
|
|
118
|
+
if self.actual_instance is None:
|
|
119
|
+
return "null"
|
|
120
|
+
|
|
121
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
122
|
+
return self.actual_instance.to_json()
|
|
123
|
+
else:
|
|
124
|
+
return json.dumps(self.actual_instance)
|
|
125
|
+
|
|
126
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], CreateChatCompletionRequestFunctionCallOneOf, str]]:
|
|
127
|
+
"""Returns the dict representation of the actual instance"""
|
|
128
|
+
if self.actual_instance is None:
|
|
129
|
+
return None
|
|
130
|
+
|
|
131
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
132
|
+
return self.actual_instance.to_dict()
|
|
133
|
+
else:
|
|
134
|
+
# primitive type
|
|
135
|
+
return self.actual_instance
|
|
136
|
+
|
|
137
|
+
def to_str(self) -> str:
|
|
138
|
+
"""Returns the string representation of the actual instance"""
|
|
139
|
+
return pprint.pformat(self.model_dump())
|
|
140
|
+
|
|
141
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
OpenAI API
|
|
5
|
+
|
|
6
|
+
APIs for sampling from and fine-tuning language models
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Contact: blah+oapicf@cliffano.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
|
|
26
|
+
class CreateChatCompletionRequestFunctionCallOneOf(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
CreateChatCompletionRequestFunctionCallOneOf
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
name: StrictStr = Field(description="The name of the function to call.")
|
|
31
|
+
__properties: ClassVar[List[str]] = ["name"]
|
|
32
|
+
|
|
33
|
+
model_config = ConfigDict(
|
|
34
|
+
populate_by_name=True,
|
|
35
|
+
validate_assignment=True,
|
|
36
|
+
protected_namespaces=(),
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def to_str(self) -> str:
|
|
41
|
+
"""Returns the string representation of the model using alias"""
|
|
42
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
43
|
+
|
|
44
|
+
def to_json(self) -> str:
|
|
45
|
+
"""Returns the JSON representation of the model using alias"""
|
|
46
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
47
|
+
return json.dumps(self.to_dict())
|
|
48
|
+
|
|
49
|
+
@classmethod
|
|
50
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
51
|
+
"""Create an instance of CreateChatCompletionRequestFunctionCallOneOf from a JSON string"""
|
|
52
|
+
return cls.from_dict(json.loads(json_str))
|
|
53
|
+
|
|
54
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
55
|
+
"""Return the dictionary representation of the model using alias.
|
|
56
|
+
|
|
57
|
+
This has the following differences from calling pydantic's
|
|
58
|
+
`self.model_dump(by_alias=True)`:
|
|
59
|
+
|
|
60
|
+
* `None` is only added to the output dict for nullable fields that
|
|
61
|
+
were set at model initialization. Other fields with value `None`
|
|
62
|
+
are ignored.
|
|
63
|
+
"""
|
|
64
|
+
excluded_fields: Set[str] = set([
|
|
65
|
+
])
|
|
66
|
+
|
|
67
|
+
_dict = self.model_dump(
|
|
68
|
+
by_alias=True,
|
|
69
|
+
exclude=excluded_fields,
|
|
70
|
+
exclude_none=True,
|
|
71
|
+
)
|
|
72
|
+
return _dict
|
|
73
|
+
|
|
74
|
+
@classmethod
|
|
75
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
76
|
+
"""Create an instance of CreateChatCompletionRequestFunctionCallOneOf from a dict"""
|
|
77
|
+
if obj is None:
|
|
78
|
+
return None
|
|
79
|
+
|
|
80
|
+
if not isinstance(obj, dict):
|
|
81
|
+
return cls.model_validate(obj)
|
|
82
|
+
|
|
83
|
+
_obj = cls.model_validate({
|
|
84
|
+
"name": obj.get("name")
|
|
85
|
+
})
|
|
86
|
+
return _obj
|
|
87
|
+
|
|
88
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
OpenAI API
|
|
5
|
+
|
|
6
|
+
APIs for sampling from and fine-tuning language models
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 2.0.0
|
|
9
|
+
Contact: blah+oapicf@cliffano.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import json
|
|
18
|
+
import pprint
|
|
19
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
|
|
20
|
+
from typing import Any, List, Optional
|
|
21
|
+
from pydantic import StrictStr, Field
|
|
22
|
+
from typing import Union, List, Optional, Dict
|
|
23
|
+
from typing_extensions import Literal, Self
|
|
24
|
+
|
|
25
|
+
CREATECHATCOMPLETIONREQUESTMODEL_ONE_OF_SCHEMAS = ["str"]
|
|
26
|
+
|
|
27
|
+
class CreateChatCompletionRequestModel(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
ID of the model to use. See the [model endpoint compatibility](/docs/models/model-endpoint-compatibility) table for details on which models work with the Chat API.
|
|
30
|
+
"""
|
|
31
|
+
# data type: str
|
|
32
|
+
oneof_schema_1_validator: Optional[StrictStr] = None
|
|
33
|
+
# data type: str
|
|
34
|
+
oneof_schema_2_validator: Optional[StrictStr] = None
|
|
35
|
+
actual_instance: Optional[Union[str]] = None
|
|
36
|
+
one_of_schemas: List[str] = Field(default=Literal["str"])
|
|
37
|
+
|
|
38
|
+
model_config = ConfigDict(
|
|
39
|
+
validate_assignment=True,
|
|
40
|
+
protected_namespaces=(),
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
45
|
+
if args:
|
|
46
|
+
if len(args) > 1:
|
|
47
|
+
raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
|
|
48
|
+
if kwargs:
|
|
49
|
+
raise ValueError("If a position argument is used, keyword arguments cannot be used.")
|
|
50
|
+
super().__init__(actual_instance=args[0])
|
|
51
|
+
else:
|
|
52
|
+
super().__init__(**kwargs)
|
|
53
|
+
|
|
54
|
+
@field_validator('actual_instance')
|
|
55
|
+
def actual_instance_must_validate_oneof(cls, v):
|
|
56
|
+
instance = CreateChatCompletionRequestModel.model_construct()
|
|
57
|
+
error_messages = []
|
|
58
|
+
match = 0
|
|
59
|
+
# validate data type: str
|
|
60
|
+
try:
|
|
61
|
+
instance.oneof_schema_1_validator = v
|
|
62
|
+
match += 1
|
|
63
|
+
except (ValidationError, ValueError) as e:
|
|
64
|
+
error_messages.append(str(e))
|
|
65
|
+
# validate data type: str
|
|
66
|
+
try:
|
|
67
|
+
instance.oneof_schema_2_validator = v
|
|
68
|
+
match += 1
|
|
69
|
+
except (ValidationError, ValueError) as e:
|
|
70
|
+
error_messages.append(str(e))
|
|
71
|
+
if match > 1:
|
|
72
|
+
# more than 1 match
|
|
73
|
+
raise ValueError("Multiple matches found when setting `actual_instance` in CreateChatCompletionRequestModel with oneOf schemas: str. Details: " + ", ".join(error_messages))
|
|
74
|
+
elif match == 0:
|
|
75
|
+
# no match
|
|
76
|
+
raise ValueError("No match found when setting `actual_instance` in CreateChatCompletionRequestModel with oneOf schemas: str. Details: " + ", ".join(error_messages))
|
|
77
|
+
else:
|
|
78
|
+
return v
|
|
79
|
+
|
|
80
|
+
@classmethod
|
|
81
|
+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
|
|
82
|
+
return cls.from_json(json.dumps(obj))
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
def from_json(cls, json_str: str) -> Self:
|
|
86
|
+
"""Returns the object represented by the json string"""
|
|
87
|
+
instance = cls.model_construct()
|
|
88
|
+
error_messages = []
|
|
89
|
+
match = 0
|
|
90
|
+
|
|
91
|
+
# deserialize data into str
|
|
92
|
+
try:
|
|
93
|
+
# validation
|
|
94
|
+
instance.oneof_schema_1_validator = json.loads(json_str)
|
|
95
|
+
# assign value to actual_instance
|
|
96
|
+
instance.actual_instance = instance.oneof_schema_1_validator
|
|
97
|
+
match += 1
|
|
98
|
+
except (ValidationError, ValueError) as e:
|
|
99
|
+
error_messages.append(str(e))
|
|
100
|
+
# deserialize data into str
|
|
101
|
+
try:
|
|
102
|
+
# validation
|
|
103
|
+
instance.oneof_schema_2_validator = json.loads(json_str)
|
|
104
|
+
# assign value to actual_instance
|
|
105
|
+
instance.actual_instance = instance.oneof_schema_2_validator
|
|
106
|
+
match += 1
|
|
107
|
+
except (ValidationError, ValueError) as e:
|
|
108
|
+
error_messages.append(str(e))
|
|
109
|
+
|
|
110
|
+
if match > 1:
|
|
111
|
+
# more than 1 match
|
|
112
|
+
raise ValueError("Multiple matches found when deserializing the JSON string into CreateChatCompletionRequestModel with oneOf schemas: str. Details: " + ", ".join(error_messages))
|
|
113
|
+
elif match == 0:
|
|
114
|
+
# no match
|
|
115
|
+
raise ValueError("No match found when deserializing the JSON string into CreateChatCompletionRequestModel with oneOf schemas: str. Details: " + ", ".join(error_messages))
|
|
116
|
+
else:
|
|
117
|
+
return instance
|
|
118
|
+
|
|
119
|
+
def to_json(self) -> str:
|
|
120
|
+
"""Returns the JSON representation of the actual instance"""
|
|
121
|
+
if self.actual_instance is None:
|
|
122
|
+
return "null"
|
|
123
|
+
|
|
124
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
125
|
+
return self.actual_instance.to_json()
|
|
126
|
+
else:
|
|
127
|
+
return json.dumps(self.actual_instance)
|
|
128
|
+
|
|
129
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], str]]:
|
|
130
|
+
"""Returns the dict representation of the actual instance"""
|
|
131
|
+
if self.actual_instance is None:
|
|
132
|
+
return None
|
|
133
|
+
|
|
134
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
135
|
+
return self.actual_instance.to_dict()
|
|
136
|
+
else:
|
|
137
|
+
# primitive type
|
|
138
|
+
return self.actual_instance
|
|
139
|
+
|
|
140
|
+
def to_str(self) -> str:
|
|
141
|
+
"""Returns the string representation of the actual instance"""
|
|
142
|
+
return pprint.pformat(self.model_dump())
|
|
143
|
+
|
|
144
|
+
|