orq-ai-sdk 4.2.0rc28__py3-none-any.whl → 4.2.6__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.
- orq_ai_sdk/_hooks/globalhook.py +0 -1
- orq_ai_sdk/_version.py +3 -3
- orq_ai_sdk/audio.py +30 -0
- orq_ai_sdk/basesdk.py +20 -6
- orq_ai_sdk/chat.py +22 -0
- orq_ai_sdk/completions.py +332 -0
- orq_ai_sdk/contacts.py +43 -855
- orq_ai_sdk/deployments.py +61 -0
- orq_ai_sdk/edits.py +258 -0
- orq_ai_sdk/embeddings.py +238 -0
- orq_ai_sdk/generations.py +272 -0
- orq_ai_sdk/identities.py +1037 -0
- orq_ai_sdk/images.py +28 -0
- orq_ai_sdk/models/__init__.py +5341 -737
- orq_ai_sdk/models/actionreviewedstreamingevent.py +18 -1
- orq_ai_sdk/models/actionreviewrequestedstreamingevent.py +44 -1
- orq_ai_sdk/models/agenterroredstreamingevent.py +18 -1
- orq_ai_sdk/models/agentinactivestreamingevent.py +168 -70
- orq_ai_sdk/models/agentmessagecreatedstreamingevent.py +18 -2
- orq_ai_sdk/models/agentresponsemessage.py +18 -2
- orq_ai_sdk/models/agentstartedstreamingevent.py +127 -2
- orq_ai_sdk/models/agentthoughtstreamingevent.py +178 -211
- orq_ai_sdk/models/conversationresponse.py +31 -20
- orq_ai_sdk/models/conversationwithmessagesresponse.py +31 -20
- orq_ai_sdk/models/createagentrequestop.py +1922 -384
- orq_ai_sdk/models/createagentresponse.py +147 -91
- orq_ai_sdk/models/createagentresponserequestop.py +111 -2
- orq_ai_sdk/models/createchatcompletionop.py +1375 -861
- orq_ai_sdk/models/createchunkop.py +46 -19
- orq_ai_sdk/models/createcompletionop.py +1890 -0
- orq_ai_sdk/models/createcontactop.py +45 -56
- orq_ai_sdk/models/createconversationop.py +61 -39
- orq_ai_sdk/models/createconversationresponseop.py +68 -4
- orq_ai_sdk/models/createdatasetitemop.py +424 -80
- orq_ai_sdk/models/createdatasetop.py +19 -2
- orq_ai_sdk/models/createdatasourceop.py +92 -26
- orq_ai_sdk/models/createembeddingop.py +384 -0
- orq_ai_sdk/models/createevalop.py +552 -24
- orq_ai_sdk/models/createidentityop.py +176 -0
- orq_ai_sdk/models/createimageeditop.py +504 -0
- orq_ai_sdk/models/createimageop.py +208 -117
- orq_ai_sdk/models/createimagevariationop.py +486 -0
- orq_ai_sdk/models/createknowledgeop.py +186 -121
- orq_ai_sdk/models/creatememorydocumentop.py +50 -1
- orq_ai_sdk/models/creatememoryop.py +34 -21
- orq_ai_sdk/models/creatememorystoreop.py +34 -1
- orq_ai_sdk/models/createmoderationop.py +521 -0
- orq_ai_sdk/models/createpromptop.py +2748 -1252
- orq_ai_sdk/models/creatererankop.py +416 -0
- orq_ai_sdk/models/createresponseop.py +2567 -0
- orq_ai_sdk/models/createspeechop.py +316 -0
- orq_ai_sdk/models/createtoolop.py +537 -12
- orq_ai_sdk/models/createtranscriptionop.py +562 -0
- orq_ai_sdk/models/createtranslationop.py +540 -0
- orq_ai_sdk/models/datapart.py +18 -1
- orq_ai_sdk/models/deletechunksop.py +34 -1
- orq_ai_sdk/models/{deletecontactop.py → deleteidentityop.py} +9 -9
- orq_ai_sdk/models/deletepromptop.py +26 -0
- orq_ai_sdk/models/deploymentcreatemetricop.py +362 -76
- orq_ai_sdk/models/deploymentgetconfigop.py +635 -194
- orq_ai_sdk/models/deploymentinvokeop.py +168 -173
- orq_ai_sdk/models/deploymentsop.py +195 -58
- orq_ai_sdk/models/deploymentstreamop.py +652 -304
- orq_ai_sdk/models/errorpart.py +18 -1
- orq_ai_sdk/models/filecontentpartschema.py +18 -1
- orq_ai_sdk/models/filegetop.py +19 -2
- orq_ai_sdk/models/filelistop.py +35 -2
- orq_ai_sdk/models/filepart.py +50 -1
- orq_ai_sdk/models/fileuploadop.py +51 -2
- orq_ai_sdk/models/generateconversationnameop.py +31 -20
- orq_ai_sdk/models/get_v2_evaluators_id_versionsop.py +34 -1
- orq_ai_sdk/models/get_v2_tools_tool_id_versions_version_id_op.py +18 -1
- orq_ai_sdk/models/get_v2_tools_tool_id_versionsop.py +34 -1
- orq_ai_sdk/models/getallmemoriesop.py +34 -21
- orq_ai_sdk/models/getallmemorydocumentsop.py +42 -1
- orq_ai_sdk/models/getallmemorystoresop.py +34 -1
- orq_ai_sdk/models/getallpromptsop.py +1690 -230
- orq_ai_sdk/models/getalltoolsop.py +325 -8
- orq_ai_sdk/models/getchunkscountop.py +34 -1
- orq_ai_sdk/models/getevalsop.py +395 -43
- orq_ai_sdk/models/getonechunkop.py +14 -19
- orq_ai_sdk/models/getoneknowledgeop.py +116 -96
- orq_ai_sdk/models/getonepromptop.py +1673 -230
- orq_ai_sdk/models/getpromptversionop.py +1670 -216
- orq_ai_sdk/models/imagecontentpartschema.py +50 -1
- orq_ai_sdk/models/internal/globals.py +18 -1
- orq_ai_sdk/models/invokeagentop.py +140 -2
- orq_ai_sdk/models/invokedeploymentrequest.py +418 -80
- orq_ai_sdk/models/invokeevalop.py +160 -131
- orq_ai_sdk/models/listagentsop.py +793 -166
- orq_ai_sdk/models/listchunksop.py +32 -19
- orq_ai_sdk/models/listchunkspaginatedop.py +46 -19
- orq_ai_sdk/models/listconversationsop.py +18 -1
- orq_ai_sdk/models/listdatasetdatapointsop.py +252 -42
- orq_ai_sdk/models/listdatasetsop.py +35 -2
- orq_ai_sdk/models/listdatasourcesop.py +35 -26
- orq_ai_sdk/models/{listcontactsop.py → listidentitiesop.py} +89 -79
- orq_ai_sdk/models/listknowledgebasesop.py +132 -96
- orq_ai_sdk/models/listmodelsop.py +1 -0
- orq_ai_sdk/models/listpromptversionsop.py +1684 -216
- orq_ai_sdk/models/parseop.py +161 -17
- orq_ai_sdk/models/partdoneevent.py +19 -2
- orq_ai_sdk/models/post_v2_router_ocrop.py +408 -0
- orq_ai_sdk/models/publiccontact.py +27 -4
- orq_ai_sdk/models/publicidentity.py +62 -0
- orq_ai_sdk/models/reasoningpart.py +19 -2
- orq_ai_sdk/models/refusalpartschema.py +18 -1
- orq_ai_sdk/models/remoteconfigsgetconfigop.py +34 -1
- orq_ai_sdk/models/responsedoneevent.py +114 -84
- orq_ai_sdk/models/responsestartedevent.py +18 -1
- orq_ai_sdk/models/retrieveagentrequestop.py +787 -166
- orq_ai_sdk/models/retrievedatapointop.py +236 -42
- orq_ai_sdk/models/retrievedatasetop.py +19 -2
- orq_ai_sdk/models/retrievedatasourceop.py +17 -26
- orq_ai_sdk/models/{retrievecontactop.py → retrieveidentityop.py} +38 -41
- orq_ai_sdk/models/retrievememorydocumentop.py +18 -1
- orq_ai_sdk/models/retrievememoryop.py +18 -21
- orq_ai_sdk/models/retrievememorystoreop.py +18 -1
- orq_ai_sdk/models/retrievetoolop.py +309 -8
- orq_ai_sdk/models/runagentop.py +1451 -197
- orq_ai_sdk/models/searchknowledgeop.py +108 -1
- orq_ai_sdk/models/security.py +18 -1
- orq_ai_sdk/models/streamagentop.py +93 -2
- orq_ai_sdk/models/streamrunagentop.py +1428 -195
- orq_ai_sdk/models/textcontentpartschema.py +34 -1
- orq_ai_sdk/models/thinkingconfigenabledschema.py +18 -1
- orq_ai_sdk/models/toolcallpart.py +18 -1
- orq_ai_sdk/models/tooldoneevent.py +18 -1
- orq_ai_sdk/models/toolexecutionfailedstreamingevent.py +50 -1
- orq_ai_sdk/models/toolexecutionfinishedstreamingevent.py +34 -1
- orq_ai_sdk/models/toolexecutionstartedstreamingevent.py +34 -1
- orq_ai_sdk/models/toolresultpart.py +18 -1
- orq_ai_sdk/models/toolreviewrequestedevent.py +18 -1
- orq_ai_sdk/models/toolstartedevent.py +18 -1
- orq_ai_sdk/models/updateagentop.py +1951 -404
- orq_ai_sdk/models/updatechunkop.py +46 -19
- orq_ai_sdk/models/updateconversationop.py +61 -39
- orq_ai_sdk/models/updatedatapointop.py +424 -80
- orq_ai_sdk/models/updatedatasetop.py +51 -2
- orq_ai_sdk/models/updatedatasourceop.py +17 -26
- orq_ai_sdk/models/updateevalop.py +577 -16
- orq_ai_sdk/models/{updatecontactop.py → updateidentityop.py} +78 -68
- orq_ai_sdk/models/updateknowledgeop.py +234 -190
- orq_ai_sdk/models/updatememorydocumentop.py +50 -1
- orq_ai_sdk/models/updatememoryop.py +50 -21
- orq_ai_sdk/models/updatememorystoreop.py +66 -1
- orq_ai_sdk/models/updatepromptop.py +2844 -1450
- orq_ai_sdk/models/updatetoolop.py +592 -9
- orq_ai_sdk/models/usermessagerequest.py +18 -2
- orq_ai_sdk/moderations.py +218 -0
- orq_ai_sdk/orq_completions.py +660 -0
- orq_ai_sdk/orq_responses.py +398 -0
- orq_ai_sdk/prompts.py +28 -36
- orq_ai_sdk/rerank.py +232 -0
- orq_ai_sdk/router.py +89 -641
- orq_ai_sdk/sdk.py +3 -0
- orq_ai_sdk/speech.py +251 -0
- orq_ai_sdk/transcriptions.py +326 -0
- orq_ai_sdk/translations.py +298 -0
- orq_ai_sdk/utils/__init__.py +13 -1
- orq_ai_sdk/variations.py +254 -0
- orq_ai_sdk-4.2.6.dist-info/METADATA +888 -0
- orq_ai_sdk-4.2.6.dist-info/RECORD +263 -0
- {orq_ai_sdk-4.2.0rc28.dist-info → orq_ai_sdk-4.2.6.dist-info}/WHEEL +2 -1
- orq_ai_sdk-4.2.6.dist-info/top_level.txt +1 -0
- orq_ai_sdk-4.2.0rc28.dist-info/METADATA +0 -867
- orq_ai_sdk-4.2.0rc28.dist-info/RECORD +0 -233
orq_ai_sdk/deployments.py
CHANGED
|
@@ -9,6 +9,7 @@ from orq_ai_sdk.models import (
|
|
|
9
9
|
deploymentgetconfigop as models_deploymentgetconfigop,
|
|
10
10
|
deploymentstreamop as models_deploymentstreamop,
|
|
11
11
|
invokedeploymentrequest as models_invokedeploymentrequest,
|
|
12
|
+
publicidentity as models_publicidentity,
|
|
12
13
|
)
|
|
13
14
|
from orq_ai_sdk.types import OptionalNullable, UNSET
|
|
14
15
|
from orq_ai_sdk.utils import eventstreaming, get_security_from_env
|
|
@@ -48,6 +49,12 @@ class Deployments(BaseSDK):
|
|
|
48
49
|
List[models_invokedeploymentrequest.MessagesTypedDict],
|
|
49
50
|
]
|
|
50
51
|
] = None,
|
|
52
|
+
identity: Optional[
|
|
53
|
+
Union[
|
|
54
|
+
models_publicidentity.PublicIdentity,
|
|
55
|
+
models_publicidentity.PublicIdentityTypedDict,
|
|
56
|
+
]
|
|
57
|
+
] = None,
|
|
51
58
|
file_ids: Optional[List[str]] = None,
|
|
52
59
|
metadata: Optional[Dict[str, Any]] = None,
|
|
53
60
|
extra_params: Optional[Dict[str, Any]] = None,
|
|
@@ -90,6 +97,7 @@ class Deployments(BaseSDK):
|
|
|
90
97
|
:param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
|
|
91
98
|
:param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
|
|
92
99
|
:param messages: A list of messages to send to the deployment.
|
|
100
|
+
:param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
|
|
93
101
|
:param file_ids: A list of file IDs that are associated with the deployment request.
|
|
94
102
|
:param metadata: Key-value pairs that you want to attach to the log generated by this request.
|
|
95
103
|
:param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
|
|
@@ -126,6 +134,9 @@ class Deployments(BaseSDK):
|
|
|
126
134
|
messages=utils.get_pydantic_model(
|
|
127
135
|
messages, Optional[List[models.Messages]]
|
|
128
136
|
),
|
|
137
|
+
identity=utils.get_pydantic_model(
|
|
138
|
+
identity, Optional[models.PublicIdentity]
|
|
139
|
+
),
|
|
129
140
|
file_ids=file_ids,
|
|
130
141
|
metadata=metadata,
|
|
131
142
|
extra_params=extra_params,
|
|
@@ -222,6 +233,12 @@ class Deployments(BaseSDK):
|
|
|
222
233
|
List[models_invokedeploymentrequest.MessagesTypedDict],
|
|
223
234
|
]
|
|
224
235
|
] = None,
|
|
236
|
+
identity: Optional[
|
|
237
|
+
Union[
|
|
238
|
+
models_publicidentity.PublicIdentity,
|
|
239
|
+
models_publicidentity.PublicIdentityTypedDict,
|
|
240
|
+
]
|
|
241
|
+
] = None,
|
|
225
242
|
file_ids: Optional[List[str]] = None,
|
|
226
243
|
metadata: Optional[Dict[str, Any]] = None,
|
|
227
244
|
extra_params: Optional[Dict[str, Any]] = None,
|
|
@@ -264,6 +281,7 @@ class Deployments(BaseSDK):
|
|
|
264
281
|
:param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
|
|
265
282
|
:param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
|
|
266
283
|
:param messages: A list of messages to send to the deployment.
|
|
284
|
+
:param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
|
|
267
285
|
:param file_ids: A list of file IDs that are associated with the deployment request.
|
|
268
286
|
:param metadata: Key-value pairs that you want to attach to the log generated by this request.
|
|
269
287
|
:param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
|
|
@@ -300,6 +318,9 @@ class Deployments(BaseSDK):
|
|
|
300
318
|
messages=utils.get_pydantic_model(
|
|
301
319
|
messages, Optional[List[models.Messages]]
|
|
302
320
|
),
|
|
321
|
+
identity=utils.get_pydantic_model(
|
|
322
|
+
identity, Optional[models.PublicIdentity]
|
|
323
|
+
),
|
|
303
324
|
file_ids=file_ids,
|
|
304
325
|
metadata=metadata,
|
|
305
326
|
extra_params=extra_params,
|
|
@@ -591,6 +612,12 @@ class Deployments(BaseSDK):
|
|
|
591
612
|
List[models_deploymentgetconfigop.DeploymentGetConfigMessagesTypedDict],
|
|
592
613
|
]
|
|
593
614
|
] = None,
|
|
615
|
+
identity: Optional[
|
|
616
|
+
Union[
|
|
617
|
+
models_publicidentity.PublicIdentity,
|
|
618
|
+
models_publicidentity.PublicIdentityTypedDict,
|
|
619
|
+
]
|
|
620
|
+
] = None,
|
|
594
621
|
file_ids: Optional[List[str]] = None,
|
|
595
622
|
metadata: Optional[Dict[str, Any]] = None,
|
|
596
623
|
extra_params: Optional[Dict[str, Any]] = None,
|
|
@@ -634,6 +661,7 @@ class Deployments(BaseSDK):
|
|
|
634
661
|
:param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
|
|
635
662
|
:param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
|
|
636
663
|
:param messages: A list of messages to send to the deployment.
|
|
664
|
+
:param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
|
|
637
665
|
:param file_ids: A list of file IDs that are associated with the deployment request.
|
|
638
666
|
:param metadata: Key-value pairs that you want to attach to the log generated by this request.
|
|
639
667
|
:param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
|
|
@@ -670,6 +698,9 @@ class Deployments(BaseSDK):
|
|
|
670
698
|
messages=utils.get_pydantic_model(
|
|
671
699
|
messages, Optional[List[models.DeploymentGetConfigMessages]]
|
|
672
700
|
),
|
|
701
|
+
identity=utils.get_pydantic_model(
|
|
702
|
+
identity, Optional[models.PublicIdentity]
|
|
703
|
+
),
|
|
673
704
|
file_ids=file_ids,
|
|
674
705
|
metadata=metadata,
|
|
675
706
|
extra_params=extra_params,
|
|
@@ -765,6 +796,12 @@ class Deployments(BaseSDK):
|
|
|
765
796
|
List[models_deploymentgetconfigop.DeploymentGetConfigMessagesTypedDict],
|
|
766
797
|
]
|
|
767
798
|
] = None,
|
|
799
|
+
identity: Optional[
|
|
800
|
+
Union[
|
|
801
|
+
models_publicidentity.PublicIdentity,
|
|
802
|
+
models_publicidentity.PublicIdentityTypedDict,
|
|
803
|
+
]
|
|
804
|
+
] = None,
|
|
768
805
|
file_ids: Optional[List[str]] = None,
|
|
769
806
|
metadata: Optional[Dict[str, Any]] = None,
|
|
770
807
|
extra_params: Optional[Dict[str, Any]] = None,
|
|
@@ -808,6 +845,7 @@ class Deployments(BaseSDK):
|
|
|
808
845
|
:param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
|
|
809
846
|
:param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
|
|
810
847
|
:param messages: A list of messages to send to the deployment.
|
|
848
|
+
:param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
|
|
811
849
|
:param file_ids: A list of file IDs that are associated with the deployment request.
|
|
812
850
|
:param metadata: Key-value pairs that you want to attach to the log generated by this request.
|
|
813
851
|
:param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
|
|
@@ -844,6 +882,9 @@ class Deployments(BaseSDK):
|
|
|
844
882
|
messages=utils.get_pydantic_model(
|
|
845
883
|
messages, Optional[List[models.DeploymentGetConfigMessages]]
|
|
846
884
|
),
|
|
885
|
+
identity=utils.get_pydantic_model(
|
|
886
|
+
identity, Optional[models.PublicIdentity]
|
|
887
|
+
),
|
|
847
888
|
file_ids=file_ids,
|
|
848
889
|
metadata=metadata,
|
|
849
890
|
extra_params=extra_params,
|
|
@@ -937,6 +978,12 @@ class Deployments(BaseSDK):
|
|
|
937
978
|
List[models_deploymentstreamop.DeploymentStreamMessagesTypedDict],
|
|
938
979
|
]
|
|
939
980
|
] = None,
|
|
981
|
+
identity: Optional[
|
|
982
|
+
Union[
|
|
983
|
+
models_publicidentity.PublicIdentity,
|
|
984
|
+
models_publicidentity.PublicIdentityTypedDict,
|
|
985
|
+
]
|
|
986
|
+
] = None,
|
|
940
987
|
file_ids: Optional[List[str]] = None,
|
|
941
988
|
metadata: Optional[Dict[str, Any]] = None,
|
|
942
989
|
extra_params: Optional[Dict[str, Any]] = None,
|
|
@@ -978,6 +1025,7 @@ class Deployments(BaseSDK):
|
|
|
978
1025
|
:param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
|
|
979
1026
|
:param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
|
|
980
1027
|
:param messages: A list of messages to send to the deployment.
|
|
1028
|
+
:param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
|
|
981
1029
|
:param file_ids: A list of file IDs that are associated with the deployment request.
|
|
982
1030
|
:param metadata: Key-value pairs that you want to attach to the log generated by this request.
|
|
983
1031
|
:param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
|
|
@@ -1013,6 +1061,9 @@ class Deployments(BaseSDK):
|
|
|
1013
1061
|
messages=utils.get_pydantic_model(
|
|
1014
1062
|
messages, Optional[List[models.DeploymentStreamMessages]]
|
|
1015
1063
|
),
|
|
1064
|
+
identity=utils.get_pydantic_model(
|
|
1065
|
+
identity, Optional[models.PublicIdentity]
|
|
1066
|
+
),
|
|
1016
1067
|
file_ids=file_ids,
|
|
1017
1068
|
metadata=metadata,
|
|
1018
1069
|
extra_params=extra_params,
|
|
@@ -1115,6 +1166,12 @@ class Deployments(BaseSDK):
|
|
|
1115
1166
|
List[models_deploymentstreamop.DeploymentStreamMessagesTypedDict],
|
|
1116
1167
|
]
|
|
1117
1168
|
] = None,
|
|
1169
|
+
identity: Optional[
|
|
1170
|
+
Union[
|
|
1171
|
+
models_publicidentity.PublicIdentity,
|
|
1172
|
+
models_publicidentity.PublicIdentityTypedDict,
|
|
1173
|
+
]
|
|
1174
|
+
] = None,
|
|
1118
1175
|
file_ids: Optional[List[str]] = None,
|
|
1119
1176
|
metadata: Optional[Dict[str, Any]] = None,
|
|
1120
1177
|
extra_params: Optional[Dict[str, Any]] = None,
|
|
@@ -1156,6 +1213,7 @@ class Deployments(BaseSDK):
|
|
|
1156
1213
|
:param context: Key-value pairs that match your data model and fields declared in your deployment routing configuration
|
|
1157
1214
|
:param prefix_messages: A list of messages to include after the `System` message, but before the `User` and `Assistant` pairs configured in your deployment.
|
|
1158
1215
|
:param messages: A list of messages to send to the deployment.
|
|
1216
|
+
:param identity: Information about the identity making the request. If the identity does not exist, it will be created automatically.
|
|
1159
1217
|
:param file_ids: A list of file IDs that are associated with the deployment request.
|
|
1160
1218
|
:param metadata: Key-value pairs that you want to attach to the log generated by this request.
|
|
1161
1219
|
:param extra_params: Utilized for passing additional parameters to the model provider. Exercise caution when using this feature, as the included parameters will overwrite any parameters specified in the deployment prompt configuration.
|
|
@@ -1191,6 +1249,9 @@ class Deployments(BaseSDK):
|
|
|
1191
1249
|
messages=utils.get_pydantic_model(
|
|
1192
1250
|
messages, Optional[List[models.DeploymentStreamMessages]]
|
|
1193
1251
|
),
|
|
1252
|
+
identity=utils.get_pydantic_model(
|
|
1253
|
+
identity, Optional[models.PublicIdentity]
|
|
1254
|
+
),
|
|
1194
1255
|
file_ids=file_ids,
|
|
1195
1256
|
metadata=metadata,
|
|
1196
1257
|
extra_params=extra_params,
|
orq_ai_sdk/edits.py
ADDED
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from orq_ai_sdk import models, utils
|
|
5
|
+
from orq_ai_sdk._hooks import HookContext
|
|
6
|
+
from orq_ai_sdk.models import createimageeditop as models_createimageeditop
|
|
7
|
+
from orq_ai_sdk.types import OptionalNullable, UNSET
|
|
8
|
+
from orq_ai_sdk.utils import get_security_from_env
|
|
9
|
+
from orq_ai_sdk.utils.unmarshal_json_response import unmarshal_json_response
|
|
10
|
+
from typing import Any, Mapping, Optional, Union
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Edits(BaseSDK):
|
|
14
|
+
def create(
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
17
|
+
model: str,
|
|
18
|
+
prompt: str,
|
|
19
|
+
image: Optional[Any] = None,
|
|
20
|
+
n: OptionalNullable[int] = 1,
|
|
21
|
+
size: OptionalNullable[str] = UNSET,
|
|
22
|
+
quality: OptionalNullable[
|
|
23
|
+
models_createimageeditop.CreateImageEditQuality
|
|
24
|
+
] = UNSET,
|
|
25
|
+
response_format: Optional[
|
|
26
|
+
models_createimageeditop.CreateImageEditResponseFormat
|
|
27
|
+
] = None,
|
|
28
|
+
user: Optional[str] = None,
|
|
29
|
+
orq: Optional[
|
|
30
|
+
Union[
|
|
31
|
+
models_createimageeditop.CreateImageEditOrq,
|
|
32
|
+
models_createimageeditop.CreateImageEditOrqTypedDict,
|
|
33
|
+
]
|
|
34
|
+
] = None,
|
|
35
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
36
|
+
server_url: Optional[str] = None,
|
|
37
|
+
timeout_ms: Optional[int] = None,
|
|
38
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
39
|
+
) -> models.CreateImageEditResponseBody:
|
|
40
|
+
r"""Create image edit
|
|
41
|
+
|
|
42
|
+
Edit an Image
|
|
43
|
+
|
|
44
|
+
:param model: The model to use for image edit. [Check models](https://docs.orq.ai/docs/ai-gateway-supported-models#image-models)
|
|
45
|
+
:param prompt: A text description of the desired image(s).
|
|
46
|
+
:param image: The image(s) to edit. Must be a supported image file or an array of images. Each image should be a png, webp, or jpg file less than 50MB. You can provide up to 16 images.
|
|
47
|
+
:param n: The number of images to generate. Must be between 1 and 10.
|
|
48
|
+
:param size: The size of the generated images
|
|
49
|
+
:param quality: The quality of the image that will be generated. Auto will automatically select the best quality for the given model.
|
|
50
|
+
:param response_format: The format in which the generated images are returned. Some of the models only return the image in base64 format.
|
|
51
|
+
:param user: A unique identifier representing your end-user, which can help to monitor and detect abuse.
|
|
52
|
+
:param orq:
|
|
53
|
+
:param retries: Override the default retry configuration for this method
|
|
54
|
+
:param server_url: Override the default server URL for this method
|
|
55
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
56
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
57
|
+
"""
|
|
58
|
+
base_url = None
|
|
59
|
+
url_variables = None
|
|
60
|
+
if timeout_ms is None:
|
|
61
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
62
|
+
|
|
63
|
+
if timeout_ms is None:
|
|
64
|
+
timeout_ms = 600000
|
|
65
|
+
|
|
66
|
+
if server_url is not None:
|
|
67
|
+
base_url = server_url
|
|
68
|
+
else:
|
|
69
|
+
base_url = self._get_url(base_url, url_variables)
|
|
70
|
+
|
|
71
|
+
request = models.CreateImageEditRequestBody(
|
|
72
|
+
model=model,
|
|
73
|
+
image=image,
|
|
74
|
+
prompt=prompt,
|
|
75
|
+
n=n,
|
|
76
|
+
size=size,
|
|
77
|
+
quality=quality,
|
|
78
|
+
response_format=response_format,
|
|
79
|
+
user=user,
|
|
80
|
+
orq=utils.get_pydantic_model(orq, Optional[models.CreateImageEditOrq]),
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
req = self._build_request(
|
|
84
|
+
method="POST",
|
|
85
|
+
path="/v2/router/images/edits",
|
|
86
|
+
base_url=base_url,
|
|
87
|
+
url_variables=url_variables,
|
|
88
|
+
request=request,
|
|
89
|
+
request_body_required=True,
|
|
90
|
+
request_has_path_params=False,
|
|
91
|
+
request_has_query_params=True,
|
|
92
|
+
user_agent_header="user-agent",
|
|
93
|
+
accept_header_value="application/json",
|
|
94
|
+
http_headers=http_headers,
|
|
95
|
+
security=self.sdk_configuration.security,
|
|
96
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
97
|
+
request, False, False, "multipart", models.CreateImageEditRequestBody
|
|
98
|
+
),
|
|
99
|
+
allow_empty_value=None,
|
|
100
|
+
timeout_ms=timeout_ms,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
if retries == UNSET:
|
|
104
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
105
|
+
retries = self.sdk_configuration.retry_config
|
|
106
|
+
|
|
107
|
+
retry_config = None
|
|
108
|
+
if isinstance(retries, utils.RetryConfig):
|
|
109
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
110
|
+
|
|
111
|
+
http_res = self.do_request(
|
|
112
|
+
hook_ctx=HookContext(
|
|
113
|
+
config=self.sdk_configuration,
|
|
114
|
+
base_url=base_url or "",
|
|
115
|
+
operation_id="createImageEdit",
|
|
116
|
+
oauth2_scopes=None,
|
|
117
|
+
security_source=get_security_from_env(
|
|
118
|
+
self.sdk_configuration.security, models.Security
|
|
119
|
+
),
|
|
120
|
+
),
|
|
121
|
+
request=req,
|
|
122
|
+
error_status_codes=["4XX", "5XX"],
|
|
123
|
+
retry_config=retry_config,
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
127
|
+
return unmarshal_json_response(models.CreateImageEditResponseBody, http_res)
|
|
128
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
129
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
130
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
131
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
132
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
133
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
134
|
+
|
|
135
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
136
|
+
|
|
137
|
+
async def create_async(
|
|
138
|
+
self,
|
|
139
|
+
*,
|
|
140
|
+
model: str,
|
|
141
|
+
prompt: str,
|
|
142
|
+
image: Optional[Any] = None,
|
|
143
|
+
n: OptionalNullable[int] = 1,
|
|
144
|
+
size: OptionalNullable[str] = UNSET,
|
|
145
|
+
quality: OptionalNullable[
|
|
146
|
+
models_createimageeditop.CreateImageEditQuality
|
|
147
|
+
] = UNSET,
|
|
148
|
+
response_format: Optional[
|
|
149
|
+
models_createimageeditop.CreateImageEditResponseFormat
|
|
150
|
+
] = None,
|
|
151
|
+
user: Optional[str] = None,
|
|
152
|
+
orq: Optional[
|
|
153
|
+
Union[
|
|
154
|
+
models_createimageeditop.CreateImageEditOrq,
|
|
155
|
+
models_createimageeditop.CreateImageEditOrqTypedDict,
|
|
156
|
+
]
|
|
157
|
+
] = None,
|
|
158
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
159
|
+
server_url: Optional[str] = None,
|
|
160
|
+
timeout_ms: Optional[int] = None,
|
|
161
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
162
|
+
) -> models.CreateImageEditResponseBody:
|
|
163
|
+
r"""Create image edit
|
|
164
|
+
|
|
165
|
+
Edit an Image
|
|
166
|
+
|
|
167
|
+
:param model: The model to use for image edit. [Check models](https://docs.orq.ai/docs/ai-gateway-supported-models#image-models)
|
|
168
|
+
:param prompt: A text description of the desired image(s).
|
|
169
|
+
:param image: The image(s) to edit. Must be a supported image file or an array of images. Each image should be a png, webp, or jpg file less than 50MB. You can provide up to 16 images.
|
|
170
|
+
:param n: The number of images to generate. Must be between 1 and 10.
|
|
171
|
+
:param size: The size of the generated images
|
|
172
|
+
:param quality: The quality of the image that will be generated. Auto will automatically select the best quality for the given model.
|
|
173
|
+
:param response_format: The format in which the generated images are returned. Some of the models only return the image in base64 format.
|
|
174
|
+
:param user: A unique identifier representing your end-user, which can help to monitor and detect abuse.
|
|
175
|
+
:param orq:
|
|
176
|
+
:param retries: Override the default retry configuration for this method
|
|
177
|
+
:param server_url: Override the default server URL for this method
|
|
178
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
179
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
180
|
+
"""
|
|
181
|
+
base_url = None
|
|
182
|
+
url_variables = None
|
|
183
|
+
if timeout_ms is None:
|
|
184
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
185
|
+
|
|
186
|
+
if timeout_ms is None:
|
|
187
|
+
timeout_ms = 600000
|
|
188
|
+
|
|
189
|
+
if server_url is not None:
|
|
190
|
+
base_url = server_url
|
|
191
|
+
else:
|
|
192
|
+
base_url = self._get_url(base_url, url_variables)
|
|
193
|
+
|
|
194
|
+
request = models.CreateImageEditRequestBody(
|
|
195
|
+
model=model,
|
|
196
|
+
image=image,
|
|
197
|
+
prompt=prompt,
|
|
198
|
+
n=n,
|
|
199
|
+
size=size,
|
|
200
|
+
quality=quality,
|
|
201
|
+
response_format=response_format,
|
|
202
|
+
user=user,
|
|
203
|
+
orq=utils.get_pydantic_model(orq, Optional[models.CreateImageEditOrq]),
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
req = self._build_request_async(
|
|
207
|
+
method="POST",
|
|
208
|
+
path="/v2/router/images/edits",
|
|
209
|
+
base_url=base_url,
|
|
210
|
+
url_variables=url_variables,
|
|
211
|
+
request=request,
|
|
212
|
+
request_body_required=True,
|
|
213
|
+
request_has_path_params=False,
|
|
214
|
+
request_has_query_params=True,
|
|
215
|
+
user_agent_header="user-agent",
|
|
216
|
+
accept_header_value="application/json",
|
|
217
|
+
http_headers=http_headers,
|
|
218
|
+
security=self.sdk_configuration.security,
|
|
219
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
220
|
+
request, False, False, "multipart", models.CreateImageEditRequestBody
|
|
221
|
+
),
|
|
222
|
+
allow_empty_value=None,
|
|
223
|
+
timeout_ms=timeout_ms,
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
if retries == UNSET:
|
|
227
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
228
|
+
retries = self.sdk_configuration.retry_config
|
|
229
|
+
|
|
230
|
+
retry_config = None
|
|
231
|
+
if isinstance(retries, utils.RetryConfig):
|
|
232
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
233
|
+
|
|
234
|
+
http_res = await self.do_request_async(
|
|
235
|
+
hook_ctx=HookContext(
|
|
236
|
+
config=self.sdk_configuration,
|
|
237
|
+
base_url=base_url or "",
|
|
238
|
+
operation_id="createImageEdit",
|
|
239
|
+
oauth2_scopes=None,
|
|
240
|
+
security_source=get_security_from_env(
|
|
241
|
+
self.sdk_configuration.security, models.Security
|
|
242
|
+
),
|
|
243
|
+
),
|
|
244
|
+
request=req,
|
|
245
|
+
error_status_codes=["4XX", "5XX"],
|
|
246
|
+
retry_config=retry_config,
|
|
247
|
+
)
|
|
248
|
+
|
|
249
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
250
|
+
return unmarshal_json_response(models.CreateImageEditResponseBody, http_res)
|
|
251
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
252
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
253
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
254
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
255
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
256
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
257
|
+
|
|
258
|
+
raise models.APIError("Unexpected response received", http_res)
|
orq_ai_sdk/embeddings.py
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
|
|
2
|
+
|
|
3
|
+
from .basesdk import BaseSDK
|
|
4
|
+
from orq_ai_sdk import models, utils
|
|
5
|
+
from orq_ai_sdk._hooks import HookContext
|
|
6
|
+
from orq_ai_sdk.models import createembeddingop as models_createembeddingop
|
|
7
|
+
from orq_ai_sdk.types import OptionalNullable, UNSET
|
|
8
|
+
from orq_ai_sdk.utils import get_security_from_env
|
|
9
|
+
from orq_ai_sdk.utils.unmarshal_json_response import unmarshal_json_response
|
|
10
|
+
from typing import Mapping, Optional, Union
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Embeddings(BaseSDK):
|
|
14
|
+
def create(
|
|
15
|
+
self,
|
|
16
|
+
*,
|
|
17
|
+
input_: Union[
|
|
18
|
+
models_createembeddingop.CreateEmbeddingInput,
|
|
19
|
+
models_createembeddingop.CreateEmbeddingInputTypedDict,
|
|
20
|
+
],
|
|
21
|
+
model: str,
|
|
22
|
+
encoding_format: Optional[models_createembeddingop.EncodingFormat] = "float",
|
|
23
|
+
dimensions: Optional[float] = None,
|
|
24
|
+
user: Optional[str] = None,
|
|
25
|
+
orq: Optional[
|
|
26
|
+
Union[
|
|
27
|
+
models_createembeddingop.CreateEmbeddingOrq,
|
|
28
|
+
models_createembeddingop.CreateEmbeddingOrqTypedDict,
|
|
29
|
+
]
|
|
30
|
+
] = None,
|
|
31
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
32
|
+
server_url: Optional[str] = None,
|
|
33
|
+
timeout_ms: Optional[int] = None,
|
|
34
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
35
|
+
) -> models.CreateEmbeddingResponseBody:
|
|
36
|
+
r"""Create embeddings
|
|
37
|
+
|
|
38
|
+
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
|
|
39
|
+
|
|
40
|
+
:param input: Input text to embed, encoded as a string or array of tokens.
|
|
41
|
+
:param model: ID of the model to use
|
|
42
|
+
:param encoding_format: Type of the document element
|
|
43
|
+
:param dimensions: The number of dimensions the resulting output embeddings should have.
|
|
44
|
+
:param user: A unique identifier representing your end-user
|
|
45
|
+
:param orq:
|
|
46
|
+
:param retries: Override the default retry configuration for this method
|
|
47
|
+
:param server_url: Override the default server URL for this method
|
|
48
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
49
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
50
|
+
"""
|
|
51
|
+
base_url = None
|
|
52
|
+
url_variables = None
|
|
53
|
+
if timeout_ms is None:
|
|
54
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
55
|
+
|
|
56
|
+
if timeout_ms is None:
|
|
57
|
+
timeout_ms = 600000
|
|
58
|
+
|
|
59
|
+
if server_url is not None:
|
|
60
|
+
base_url = server_url
|
|
61
|
+
else:
|
|
62
|
+
base_url = self._get_url(base_url, url_variables)
|
|
63
|
+
|
|
64
|
+
request = models.CreateEmbeddingRequestBody(
|
|
65
|
+
input=input_,
|
|
66
|
+
model=model,
|
|
67
|
+
encoding_format=encoding_format,
|
|
68
|
+
dimensions=dimensions,
|
|
69
|
+
user=user,
|
|
70
|
+
orq=utils.get_pydantic_model(orq, Optional[models.CreateEmbeddingOrq]),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
req = self._build_request(
|
|
74
|
+
method="POST",
|
|
75
|
+
path="/v2/router/embeddings",
|
|
76
|
+
base_url=base_url,
|
|
77
|
+
url_variables=url_variables,
|
|
78
|
+
request=request,
|
|
79
|
+
request_body_required=True,
|
|
80
|
+
request_has_path_params=False,
|
|
81
|
+
request_has_query_params=True,
|
|
82
|
+
user_agent_header="user-agent",
|
|
83
|
+
accept_header_value="application/json",
|
|
84
|
+
http_headers=http_headers,
|
|
85
|
+
security=self.sdk_configuration.security,
|
|
86
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
87
|
+
request, False, False, "json", models.CreateEmbeddingRequestBody
|
|
88
|
+
),
|
|
89
|
+
allow_empty_value=None,
|
|
90
|
+
timeout_ms=timeout_ms,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
if retries == UNSET:
|
|
94
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
95
|
+
retries = self.sdk_configuration.retry_config
|
|
96
|
+
|
|
97
|
+
retry_config = None
|
|
98
|
+
if isinstance(retries, utils.RetryConfig):
|
|
99
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
100
|
+
|
|
101
|
+
http_res = self.do_request(
|
|
102
|
+
hook_ctx=HookContext(
|
|
103
|
+
config=self.sdk_configuration,
|
|
104
|
+
base_url=base_url or "",
|
|
105
|
+
operation_id="createEmbedding",
|
|
106
|
+
oauth2_scopes=None,
|
|
107
|
+
security_source=get_security_from_env(
|
|
108
|
+
self.sdk_configuration.security, models.Security
|
|
109
|
+
),
|
|
110
|
+
),
|
|
111
|
+
request=req,
|
|
112
|
+
error_status_codes=["4XX", "5XX"],
|
|
113
|
+
retry_config=retry_config,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
117
|
+
return unmarshal_json_response(models.CreateEmbeddingResponseBody, http_res)
|
|
118
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
119
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
120
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
121
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
122
|
+
http_res_text = utils.stream_to_text(http_res)
|
|
123
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
124
|
+
|
|
125
|
+
raise models.APIError("Unexpected response received", http_res)
|
|
126
|
+
|
|
127
|
+
async def create_async(
|
|
128
|
+
self,
|
|
129
|
+
*,
|
|
130
|
+
input_: Union[
|
|
131
|
+
models_createembeddingop.CreateEmbeddingInput,
|
|
132
|
+
models_createembeddingop.CreateEmbeddingInputTypedDict,
|
|
133
|
+
],
|
|
134
|
+
model: str,
|
|
135
|
+
encoding_format: Optional[models_createembeddingop.EncodingFormat] = "float",
|
|
136
|
+
dimensions: Optional[float] = None,
|
|
137
|
+
user: Optional[str] = None,
|
|
138
|
+
orq: Optional[
|
|
139
|
+
Union[
|
|
140
|
+
models_createembeddingop.CreateEmbeddingOrq,
|
|
141
|
+
models_createembeddingop.CreateEmbeddingOrqTypedDict,
|
|
142
|
+
]
|
|
143
|
+
] = None,
|
|
144
|
+
retries: OptionalNullable[utils.RetryConfig] = UNSET,
|
|
145
|
+
server_url: Optional[str] = None,
|
|
146
|
+
timeout_ms: Optional[int] = None,
|
|
147
|
+
http_headers: Optional[Mapping[str, str]] = None,
|
|
148
|
+
) -> models.CreateEmbeddingResponseBody:
|
|
149
|
+
r"""Create embeddings
|
|
150
|
+
|
|
151
|
+
Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
|
|
152
|
+
|
|
153
|
+
:param input: Input text to embed, encoded as a string or array of tokens.
|
|
154
|
+
:param model: ID of the model to use
|
|
155
|
+
:param encoding_format: Type of the document element
|
|
156
|
+
:param dimensions: The number of dimensions the resulting output embeddings should have.
|
|
157
|
+
:param user: A unique identifier representing your end-user
|
|
158
|
+
:param orq:
|
|
159
|
+
:param retries: Override the default retry configuration for this method
|
|
160
|
+
:param server_url: Override the default server URL for this method
|
|
161
|
+
:param timeout_ms: Override the default request timeout configuration for this method in milliseconds
|
|
162
|
+
:param http_headers: Additional headers to set or replace on requests.
|
|
163
|
+
"""
|
|
164
|
+
base_url = None
|
|
165
|
+
url_variables = None
|
|
166
|
+
if timeout_ms is None:
|
|
167
|
+
timeout_ms = self.sdk_configuration.timeout_ms
|
|
168
|
+
|
|
169
|
+
if timeout_ms is None:
|
|
170
|
+
timeout_ms = 600000
|
|
171
|
+
|
|
172
|
+
if server_url is not None:
|
|
173
|
+
base_url = server_url
|
|
174
|
+
else:
|
|
175
|
+
base_url = self._get_url(base_url, url_variables)
|
|
176
|
+
|
|
177
|
+
request = models.CreateEmbeddingRequestBody(
|
|
178
|
+
input=input_,
|
|
179
|
+
model=model,
|
|
180
|
+
encoding_format=encoding_format,
|
|
181
|
+
dimensions=dimensions,
|
|
182
|
+
user=user,
|
|
183
|
+
orq=utils.get_pydantic_model(orq, Optional[models.CreateEmbeddingOrq]),
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
req = self._build_request_async(
|
|
187
|
+
method="POST",
|
|
188
|
+
path="/v2/router/embeddings",
|
|
189
|
+
base_url=base_url,
|
|
190
|
+
url_variables=url_variables,
|
|
191
|
+
request=request,
|
|
192
|
+
request_body_required=True,
|
|
193
|
+
request_has_path_params=False,
|
|
194
|
+
request_has_query_params=True,
|
|
195
|
+
user_agent_header="user-agent",
|
|
196
|
+
accept_header_value="application/json",
|
|
197
|
+
http_headers=http_headers,
|
|
198
|
+
security=self.sdk_configuration.security,
|
|
199
|
+
get_serialized_body=lambda: utils.serialize_request_body(
|
|
200
|
+
request, False, False, "json", models.CreateEmbeddingRequestBody
|
|
201
|
+
),
|
|
202
|
+
allow_empty_value=None,
|
|
203
|
+
timeout_ms=timeout_ms,
|
|
204
|
+
)
|
|
205
|
+
|
|
206
|
+
if retries == UNSET:
|
|
207
|
+
if self.sdk_configuration.retry_config is not UNSET:
|
|
208
|
+
retries = self.sdk_configuration.retry_config
|
|
209
|
+
|
|
210
|
+
retry_config = None
|
|
211
|
+
if isinstance(retries, utils.RetryConfig):
|
|
212
|
+
retry_config = (retries, ["429", "500", "502", "503", "504"])
|
|
213
|
+
|
|
214
|
+
http_res = await self.do_request_async(
|
|
215
|
+
hook_ctx=HookContext(
|
|
216
|
+
config=self.sdk_configuration,
|
|
217
|
+
base_url=base_url or "",
|
|
218
|
+
operation_id="createEmbedding",
|
|
219
|
+
oauth2_scopes=None,
|
|
220
|
+
security_source=get_security_from_env(
|
|
221
|
+
self.sdk_configuration.security, models.Security
|
|
222
|
+
),
|
|
223
|
+
),
|
|
224
|
+
request=req,
|
|
225
|
+
error_status_codes=["4XX", "5XX"],
|
|
226
|
+
retry_config=retry_config,
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
if utils.match_response(http_res, "200", "application/json"):
|
|
230
|
+
return unmarshal_json_response(models.CreateEmbeddingResponseBody, http_res)
|
|
231
|
+
if utils.match_response(http_res, "4XX", "*"):
|
|
232
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
233
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
234
|
+
if utils.match_response(http_res, "5XX", "*"):
|
|
235
|
+
http_res_text = await utils.stream_to_text_async(http_res)
|
|
236
|
+
raise models.APIError("API error occurred", http_res, http_res_text)
|
|
237
|
+
|
|
238
|
+
raise models.APIError("Unexpected response received", http_res)
|