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