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,145 @@
|
|
|
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 typing_extensions import Annotated
|
|
22
|
+
from pydantic import StrictStr, Field
|
|
23
|
+
from typing import Union, List, Optional, Dict
|
|
24
|
+
from typing_extensions import Literal, Self
|
|
25
|
+
|
|
26
|
+
CREATECHATCOMPLETIONREQUESTSTOP_ONE_OF_SCHEMAS = ["List[str]", "str"]
|
|
27
|
+
|
|
28
|
+
class CreateChatCompletionRequestStop(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
Up to 4 sequences where the API will stop generating further tokens.
|
|
31
|
+
"""
|
|
32
|
+
# data type: str
|
|
33
|
+
oneof_schema_1_validator: Optional[StrictStr] = None
|
|
34
|
+
# data type: List[str]
|
|
35
|
+
oneof_schema_2_validator: Optional[Annotated[List[StrictStr], Field(min_length=1, max_length=4)]] = None
|
|
36
|
+
actual_instance: Optional[Union[List[str], str]] = None
|
|
37
|
+
one_of_schemas: List[str] = Field(default=Literal["List[str]", "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 = CreateChatCompletionRequestStop.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: List[str]
|
|
67
|
+
try:
|
|
68
|
+
instance.oneof_schema_2_validator = v
|
|
69
|
+
match += 1
|
|
70
|
+
except (ValidationError, ValueError) as e:
|
|
71
|
+
error_messages.append(str(e))
|
|
72
|
+
if match > 1:
|
|
73
|
+
# more than 1 match
|
|
74
|
+
raise ValueError("Multiple matches found when setting `actual_instance` in CreateChatCompletionRequestStop with oneOf schemas: List[str], str. Details: " + ", ".join(error_messages))
|
|
75
|
+
elif match == 0:
|
|
76
|
+
# no match
|
|
77
|
+
raise ValueError("No match found when setting `actual_instance` in CreateChatCompletionRequestStop with oneOf schemas: List[str], str. Details: " + ", ".join(error_messages))
|
|
78
|
+
else:
|
|
79
|
+
return v
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
|
|
83
|
+
return cls.from_json(json.dumps(obj))
|
|
84
|
+
|
|
85
|
+
@classmethod
|
|
86
|
+
def from_json(cls, json_str: str) -> Self:
|
|
87
|
+
"""Returns the object represented by the json string"""
|
|
88
|
+
instance = cls.model_construct()
|
|
89
|
+
error_messages = []
|
|
90
|
+
match = 0
|
|
91
|
+
|
|
92
|
+
# deserialize data into str
|
|
93
|
+
try:
|
|
94
|
+
# validation
|
|
95
|
+
instance.oneof_schema_1_validator = json.loads(json_str)
|
|
96
|
+
# assign value to actual_instance
|
|
97
|
+
instance.actual_instance = instance.oneof_schema_1_validator
|
|
98
|
+
match += 1
|
|
99
|
+
except (ValidationError, ValueError) as e:
|
|
100
|
+
error_messages.append(str(e))
|
|
101
|
+
# deserialize data into List[str]
|
|
102
|
+
try:
|
|
103
|
+
# validation
|
|
104
|
+
instance.oneof_schema_2_validator = json.loads(json_str)
|
|
105
|
+
# assign value to actual_instance
|
|
106
|
+
instance.actual_instance = instance.oneof_schema_2_validator
|
|
107
|
+
match += 1
|
|
108
|
+
except (ValidationError, ValueError) as e:
|
|
109
|
+
error_messages.append(str(e))
|
|
110
|
+
|
|
111
|
+
if match > 1:
|
|
112
|
+
# more than 1 match
|
|
113
|
+
raise ValueError("Multiple matches found when deserializing the JSON string into CreateChatCompletionRequestStop with oneOf schemas: List[str], str. Details: " + ", ".join(error_messages))
|
|
114
|
+
elif match == 0:
|
|
115
|
+
# no match
|
|
116
|
+
raise ValueError("No match found when deserializing the JSON string into CreateChatCompletionRequestStop with oneOf schemas: List[str], str. Details: " + ", ".join(error_messages))
|
|
117
|
+
else:
|
|
118
|
+
return instance
|
|
119
|
+
|
|
120
|
+
def to_json(self) -> str:
|
|
121
|
+
"""Returns the JSON representation of the actual instance"""
|
|
122
|
+
if self.actual_instance is None:
|
|
123
|
+
return "null"
|
|
124
|
+
|
|
125
|
+
if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
|
|
126
|
+
return self.actual_instance.to_json()
|
|
127
|
+
else:
|
|
128
|
+
return json.dumps(self.actual_instance)
|
|
129
|
+
|
|
130
|
+
def to_dict(self) -> Optional[Union[Dict[str, Any], List[str], str]]:
|
|
131
|
+
"""Returns the dict representation of the actual instance"""
|
|
132
|
+
if self.actual_instance is None:
|
|
133
|
+
return None
|
|
134
|
+
|
|
135
|
+
if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
|
|
136
|
+
return self.actual_instance.to_dict()
|
|
137
|
+
else:
|
|
138
|
+
# primitive type
|
|
139
|
+
return self.actual_instance
|
|
140
|
+
|
|
141
|
+
def to_str(self) -> str:
|
|
142
|
+
"""Returns the string representation of the actual instance"""
|
|
143
|
+
return pprint.pformat(self.model_dump())
|
|
144
|
+
|
|
145
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
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, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from openapiopenai.models.create_chat_completion_response_choices_inner import CreateChatCompletionResponseChoicesInner
|
|
24
|
+
from openapiopenai.models.create_completion_response_usage import CreateCompletionResponseUsage
|
|
25
|
+
from typing import Optional, Set
|
|
26
|
+
from typing_extensions import Self
|
|
27
|
+
|
|
28
|
+
class CreateChatCompletionResponse(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
CreateChatCompletionResponse
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
id: StrictStr
|
|
33
|
+
object: StrictStr
|
|
34
|
+
created: StrictInt
|
|
35
|
+
model: StrictStr
|
|
36
|
+
choices: List[CreateChatCompletionResponseChoicesInner]
|
|
37
|
+
usage: Optional[CreateCompletionResponseUsage] = None
|
|
38
|
+
__properties: ClassVar[List[str]] = ["id", "object", "created", "model", "choices", "usage"]
|
|
39
|
+
|
|
40
|
+
model_config = ConfigDict(
|
|
41
|
+
populate_by_name=True,
|
|
42
|
+
validate_assignment=True,
|
|
43
|
+
protected_namespaces=(),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def to_str(self) -> str:
|
|
48
|
+
"""Returns the string representation of the model using alias"""
|
|
49
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
50
|
+
|
|
51
|
+
def to_json(self) -> str:
|
|
52
|
+
"""Returns the JSON representation of the model using alias"""
|
|
53
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
54
|
+
return json.dumps(self.to_dict())
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
58
|
+
"""Create an instance of CreateChatCompletionResponse from a JSON string"""
|
|
59
|
+
return cls.from_dict(json.loads(json_str))
|
|
60
|
+
|
|
61
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
62
|
+
"""Return the dictionary representation of the model using alias.
|
|
63
|
+
|
|
64
|
+
This has the following differences from calling pydantic's
|
|
65
|
+
`self.model_dump(by_alias=True)`:
|
|
66
|
+
|
|
67
|
+
* `None` is only added to the output dict for nullable fields that
|
|
68
|
+
were set at model initialization. Other fields with value `None`
|
|
69
|
+
are ignored.
|
|
70
|
+
"""
|
|
71
|
+
excluded_fields: Set[str] = set([
|
|
72
|
+
])
|
|
73
|
+
|
|
74
|
+
_dict = self.model_dump(
|
|
75
|
+
by_alias=True,
|
|
76
|
+
exclude=excluded_fields,
|
|
77
|
+
exclude_none=True,
|
|
78
|
+
)
|
|
79
|
+
# override the default output from pydantic by calling `to_dict()` of each item in choices (list)
|
|
80
|
+
_items = []
|
|
81
|
+
if self.choices:
|
|
82
|
+
for _item in self.choices:
|
|
83
|
+
if _item:
|
|
84
|
+
_items.append(_item.to_dict())
|
|
85
|
+
_dict['choices'] = _items
|
|
86
|
+
# override the default output from pydantic by calling `to_dict()` of usage
|
|
87
|
+
if self.usage:
|
|
88
|
+
_dict['usage'] = self.usage.to_dict()
|
|
89
|
+
return _dict
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
93
|
+
"""Create an instance of CreateChatCompletionResponse from a dict"""
|
|
94
|
+
if obj is None:
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
if not isinstance(obj, dict):
|
|
98
|
+
return cls.model_validate(obj)
|
|
99
|
+
|
|
100
|
+
_obj = cls.model_validate({
|
|
101
|
+
"id": obj.get("id"),
|
|
102
|
+
"object": obj.get("object"),
|
|
103
|
+
"created": obj.get("created"),
|
|
104
|
+
"model": obj.get("model"),
|
|
105
|
+
"choices": [CreateChatCompletionResponseChoicesInner.from_dict(_item) for _item in obj["choices"]] if obj.get("choices") is not None else None,
|
|
106
|
+
"usage": CreateCompletionResponseUsage.from_dict(obj["usage"]) if obj.get("usage") is not None else None
|
|
107
|
+
})
|
|
108
|
+
return _obj
|
|
109
|
+
|
|
110
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
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, StrictInt, StrictStr, field_validator
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from openapiopenai.models.chat_completion_response_message import ChatCompletionResponseMessage
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class CreateChatCompletionResponseChoicesInner(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
CreateChatCompletionResponseChoicesInner
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
index: Optional[StrictInt] = None
|
|
32
|
+
message: Optional[ChatCompletionResponseMessage] = None
|
|
33
|
+
finish_reason: Optional[StrictStr] = None
|
|
34
|
+
__properties: ClassVar[List[str]] = ["index", "message", "finish_reason"]
|
|
35
|
+
|
|
36
|
+
@field_validator('finish_reason')
|
|
37
|
+
def finish_reason_validate_enum(cls, value):
|
|
38
|
+
"""Validates the enum"""
|
|
39
|
+
if value is None:
|
|
40
|
+
return value
|
|
41
|
+
|
|
42
|
+
if value not in set(['stop', 'length', 'function_call']):
|
|
43
|
+
raise ValueError("must be one of enum values ('stop', 'length', 'function_call')")
|
|
44
|
+
return value
|
|
45
|
+
|
|
46
|
+
model_config = ConfigDict(
|
|
47
|
+
populate_by_name=True,
|
|
48
|
+
validate_assignment=True,
|
|
49
|
+
protected_namespaces=(),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def to_str(self) -> str:
|
|
54
|
+
"""Returns the string representation of the model using alias"""
|
|
55
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
56
|
+
|
|
57
|
+
def to_json(self) -> str:
|
|
58
|
+
"""Returns the JSON representation of the model using alias"""
|
|
59
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
60
|
+
return json.dumps(self.to_dict())
|
|
61
|
+
|
|
62
|
+
@classmethod
|
|
63
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
64
|
+
"""Create an instance of CreateChatCompletionResponseChoicesInner from a JSON string"""
|
|
65
|
+
return cls.from_dict(json.loads(json_str))
|
|
66
|
+
|
|
67
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
68
|
+
"""Return the dictionary representation of the model using alias.
|
|
69
|
+
|
|
70
|
+
This has the following differences from calling pydantic's
|
|
71
|
+
`self.model_dump(by_alias=True)`:
|
|
72
|
+
|
|
73
|
+
* `None` is only added to the output dict for nullable fields that
|
|
74
|
+
were set at model initialization. Other fields with value `None`
|
|
75
|
+
are ignored.
|
|
76
|
+
"""
|
|
77
|
+
excluded_fields: Set[str] = set([
|
|
78
|
+
])
|
|
79
|
+
|
|
80
|
+
_dict = self.model_dump(
|
|
81
|
+
by_alias=True,
|
|
82
|
+
exclude=excluded_fields,
|
|
83
|
+
exclude_none=True,
|
|
84
|
+
)
|
|
85
|
+
# override the default output from pydantic by calling `to_dict()` of message
|
|
86
|
+
if self.message:
|
|
87
|
+
_dict['message'] = self.message.to_dict()
|
|
88
|
+
return _dict
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
92
|
+
"""Create an instance of CreateChatCompletionResponseChoicesInner from a dict"""
|
|
93
|
+
if obj is None:
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
if not isinstance(obj, dict):
|
|
97
|
+
return cls.model_validate(obj)
|
|
98
|
+
|
|
99
|
+
_obj = cls.model_validate({
|
|
100
|
+
"index": obj.get("index"),
|
|
101
|
+
"message": ChatCompletionResponseMessage.from_dict(obj["message"]) if obj.get("message") is not None else None,
|
|
102
|
+
"finish_reason": obj.get("finish_reason")
|
|
103
|
+
})
|
|
104
|
+
return _obj
|
|
105
|
+
|
|
106
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
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, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from openapiopenai.models.create_chat_completion_stream_response_choices_inner import CreateChatCompletionStreamResponseChoicesInner
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class CreateChatCompletionStreamResponse(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
CreateChatCompletionStreamResponse
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
id: StrictStr
|
|
32
|
+
object: StrictStr
|
|
33
|
+
created: StrictInt
|
|
34
|
+
model: StrictStr
|
|
35
|
+
choices: List[CreateChatCompletionStreamResponseChoicesInner]
|
|
36
|
+
__properties: ClassVar[List[str]] = ["id", "object", "created", "model", "choices"]
|
|
37
|
+
|
|
38
|
+
model_config = ConfigDict(
|
|
39
|
+
populate_by_name=True,
|
|
40
|
+
validate_assignment=True,
|
|
41
|
+
protected_namespaces=(),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def to_str(self) -> str:
|
|
46
|
+
"""Returns the string representation of the model using alias"""
|
|
47
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
48
|
+
|
|
49
|
+
def to_json(self) -> str:
|
|
50
|
+
"""Returns the JSON representation of the model using alias"""
|
|
51
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
52
|
+
return json.dumps(self.to_dict())
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
56
|
+
"""Create an instance of CreateChatCompletionStreamResponse from a JSON string"""
|
|
57
|
+
return cls.from_dict(json.loads(json_str))
|
|
58
|
+
|
|
59
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
60
|
+
"""Return the dictionary representation of the model using alias.
|
|
61
|
+
|
|
62
|
+
This has the following differences from calling pydantic's
|
|
63
|
+
`self.model_dump(by_alias=True)`:
|
|
64
|
+
|
|
65
|
+
* `None` is only added to the output dict for nullable fields that
|
|
66
|
+
were set at model initialization. Other fields with value `None`
|
|
67
|
+
are ignored.
|
|
68
|
+
"""
|
|
69
|
+
excluded_fields: Set[str] = set([
|
|
70
|
+
])
|
|
71
|
+
|
|
72
|
+
_dict = self.model_dump(
|
|
73
|
+
by_alias=True,
|
|
74
|
+
exclude=excluded_fields,
|
|
75
|
+
exclude_none=True,
|
|
76
|
+
)
|
|
77
|
+
# override the default output from pydantic by calling `to_dict()` of each item in choices (list)
|
|
78
|
+
_items = []
|
|
79
|
+
if self.choices:
|
|
80
|
+
for _item in self.choices:
|
|
81
|
+
if _item:
|
|
82
|
+
_items.append(_item.to_dict())
|
|
83
|
+
_dict['choices'] = _items
|
|
84
|
+
return _dict
|
|
85
|
+
|
|
86
|
+
@classmethod
|
|
87
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
88
|
+
"""Create an instance of CreateChatCompletionStreamResponse from a dict"""
|
|
89
|
+
if obj is None:
|
|
90
|
+
return None
|
|
91
|
+
|
|
92
|
+
if not isinstance(obj, dict):
|
|
93
|
+
return cls.model_validate(obj)
|
|
94
|
+
|
|
95
|
+
_obj = cls.model_validate({
|
|
96
|
+
"id": obj.get("id"),
|
|
97
|
+
"object": obj.get("object"),
|
|
98
|
+
"created": obj.get("created"),
|
|
99
|
+
"model": obj.get("model"),
|
|
100
|
+
"choices": [CreateChatCompletionStreamResponseChoicesInner.from_dict(_item) for _item in obj["choices"]] if obj.get("choices") is not None else None
|
|
101
|
+
})
|
|
102
|
+
return _obj
|
|
103
|
+
|
|
104
|
+
|
|
@@ -0,0 +1,106 @@
|
|
|
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, StrictInt, StrictStr, field_validator
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
23
|
+
from openapiopenai.models.chat_completion_stream_response_delta import ChatCompletionStreamResponseDelta
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class CreateChatCompletionStreamResponseChoicesInner(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
CreateChatCompletionStreamResponseChoicesInner
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
index: Optional[StrictInt] = None
|
|
32
|
+
delta: Optional[ChatCompletionStreamResponseDelta] = None
|
|
33
|
+
finish_reason: Optional[StrictStr] = None
|
|
34
|
+
__properties: ClassVar[List[str]] = ["index", "delta", "finish_reason"]
|
|
35
|
+
|
|
36
|
+
@field_validator('finish_reason')
|
|
37
|
+
def finish_reason_validate_enum(cls, value):
|
|
38
|
+
"""Validates the enum"""
|
|
39
|
+
if value is None:
|
|
40
|
+
return value
|
|
41
|
+
|
|
42
|
+
if value not in set(['stop', 'length', 'function_call']):
|
|
43
|
+
raise ValueError("must be one of enum values ('stop', 'length', 'function_call')")
|
|
44
|
+
return value
|
|
45
|
+
|
|
46
|
+
model_config = ConfigDict(
|
|
47
|
+
populate_by_name=True,
|
|
48
|
+
validate_assignment=True,
|
|
49
|
+
protected_namespaces=(),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def to_str(self) -> str:
|
|
54
|
+
"""Returns the string representation of the model using alias"""
|
|
55
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
56
|
+
|
|
57
|
+
def to_json(self) -> str:
|
|
58
|
+
"""Returns the JSON representation of the model using alias"""
|
|
59
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
60
|
+
return json.dumps(self.to_dict())
|
|
61
|
+
|
|
62
|
+
@classmethod
|
|
63
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
64
|
+
"""Create an instance of CreateChatCompletionStreamResponseChoicesInner from a JSON string"""
|
|
65
|
+
return cls.from_dict(json.loads(json_str))
|
|
66
|
+
|
|
67
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
68
|
+
"""Return the dictionary representation of the model using alias.
|
|
69
|
+
|
|
70
|
+
This has the following differences from calling pydantic's
|
|
71
|
+
`self.model_dump(by_alias=True)`:
|
|
72
|
+
|
|
73
|
+
* `None` is only added to the output dict for nullable fields that
|
|
74
|
+
were set at model initialization. Other fields with value `None`
|
|
75
|
+
are ignored.
|
|
76
|
+
"""
|
|
77
|
+
excluded_fields: Set[str] = set([
|
|
78
|
+
])
|
|
79
|
+
|
|
80
|
+
_dict = self.model_dump(
|
|
81
|
+
by_alias=True,
|
|
82
|
+
exclude=excluded_fields,
|
|
83
|
+
exclude_none=True,
|
|
84
|
+
)
|
|
85
|
+
# override the default output from pydantic by calling `to_dict()` of delta
|
|
86
|
+
if self.delta:
|
|
87
|
+
_dict['delta'] = self.delta.to_dict()
|
|
88
|
+
return _dict
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
92
|
+
"""Create an instance of CreateChatCompletionStreamResponseChoicesInner from a dict"""
|
|
93
|
+
if obj is None:
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
if not isinstance(obj, dict):
|
|
97
|
+
return cls.model_validate(obj)
|
|
98
|
+
|
|
99
|
+
_obj = cls.model_validate({
|
|
100
|
+
"index": obj.get("index"),
|
|
101
|
+
"delta": ChatCompletionStreamResponseDelta.from_dict(obj["delta"]) if obj.get("delta") is not None else None,
|
|
102
|
+
"finish_reason": obj.get("finish_reason")
|
|
103
|
+
})
|
|
104
|
+
return _obj
|
|
105
|
+
|
|
106
|
+
|