Skip to content

Commit 99d2c0d

Browse files
author
SDKAuto
committed
CodeGen from PR 28438 in Azure/azure-rest-api-specs
Merge 1450ebbc3762009c1e2f03afc9b458717f1c9afd into 20efe6fd4db8a494eab1852a8541fbabe5de569c
1 parent 96b2d6e commit 99d2c0d

26 files changed

+293
-6517
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "671e37b3527ab734a40726a26c078fe63b64b0cf",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/ai/ModelClient",
5+
"@azure-tools/typespec-python": "0.38.3"
6+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"CrossLanguagePackageId": "AI.Model",
3+
"CrossLanguageDefinitionId": {
4+
"azure.ai.inference.models.ContentItem": "AI.Model.ChatMessageContentItem",
5+
"azure.ai.inference.models.AudioContentItem": "AI.Model.ChatMessageAudioContentItem",
6+
"azure.ai.inference.models.ChatChoice": "AI.Model.ChatChoice",
7+
"azure.ai.inference.models.ChatCompletions": "AI.Model.ChatCompletions",
8+
"azure.ai.inference.models.ChatCompletionsNamedToolChoice": "AI.Model.ChatCompletionsNamedToolChoice",
9+
"azure.ai.inference.models.ChatCompletionsNamedToolChoiceFunction": "AI.Model.ChatCompletionsNamedToolChoiceFunction",
10+
"azure.ai.inference.models.ChatCompletionsToolCall": "AI.Model.ChatCompletionsToolCall",
11+
"azure.ai.inference.models.ChatCompletionsToolDefinition": "AI.Model.ChatCompletionsToolDefinition",
12+
"azure.ai.inference.models.ChatResponseMessage": "AI.Model.ChatResponseMessage",
13+
"azure.ai.inference.models.CompletionsUsage": "AI.Model.CompletionsUsage",
14+
"azure.ai.inference.models.EmbeddingItem": "AI.Model.EmbeddingItem",
15+
"azure.ai.inference.models.EmbeddingsResult": "AI.Model.EmbeddingsResult",
16+
"azure.ai.inference.models.EmbeddingsUsage": "AI.Model.EmbeddingsUsage",
17+
"azure.ai.inference.models.FunctionCall": "AI.Model.FunctionCall",
18+
"azure.ai.inference.models.FunctionDefinition": "AI.Model.FunctionDefinition",
19+
"azure.ai.inference.models.ImageContentItem": "AI.Model.ChatMessageImageContentItem",
20+
"azure.ai.inference.models.ImageEmbeddingInput": "AI.Model.ImageEmbeddingInput",
21+
"azure.ai.inference.models.ImageUrl": "AI.Model.ChatMessageImageUrl",
22+
"azure.ai.inference.models.InputAudio": "AI.Model.ChatMessageInputAudio",
23+
"azure.ai.inference.models.JsonSchemaFormat": "AI.Model.ChatCompletionsResponseFormatJsonSchemaDefinition",
24+
"azure.ai.inference.models.ModelInfo": "AI.Model.ModelInfo",
25+
"azure.ai.inference.models.StreamingChatChoiceUpdate": "AI.Model.StreamingChatChoiceUpdate",
26+
"azure.ai.inference.models.StreamingChatCompletionsUpdate": "AI.Model.StreamingChatCompletionsUpdate",
27+
"azure.ai.inference.models.StreamingChatResponseMessageUpdate": "AI.Model.StreamingChatResponseMessageUpdate",
28+
"azure.ai.inference.models.StreamingChatResponseToolCallUpdate": "AI.Model.StreamingChatResponseToolCallUpdate",
29+
"azure.ai.inference.models.TextContentItem": "AI.Model.ChatMessageTextContentItem",
30+
"azure.ai.inference.models.CompletionsFinishReason": "AI.Model.CompletionsFinishReason",
31+
"azure.ai.inference.models.ChatRole": "AI.Model.ChatRole",
32+
"azure.ai.inference.models.ImageDetailLevel": "AI.Model.ChatMessageImageDetailLevel",
33+
"azure.ai.inference.models.AudioContentFormat": "AI.Model.AudioContentFormat",
34+
"azure.ai.inference.models.ChatCompletionsToolChoicePreset": "AI.Model.ChatCompletionsToolChoicePreset",
35+
"azure.ai.inference.models.ModelType": "AI.Model.ModelType",
36+
"azure.ai.inference.models.EmbeddingEncodingFormat": "AI.Model.EmbeddingEncodingFormat",
37+
"azure.ai.inference.models.EmbeddingInputType": "AI.Model.EmbeddingInputType"
38+
}
39+
}

sdk/ai/azure-ai-inference/azure/ai/inference/_model_base.py

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# pylint: disable=too-many-lines,arguments-differ,signature-differs,no-member
1+
# pylint: disable=too-many-lines
22
# coding=utf-8
33
# --------------------------------------------------------------------------
44
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -373,15 +373,34 @@ def __ne__(self, other: typing.Any) -> bool:
373373
return not self.__eq__(other)
374374

375375
def keys(self) -> typing.KeysView[str]:
376+
"""
377+
:returns: a set-like object providing a view on D's keys
378+
:rtype: ~typing.KeysView
379+
"""
376380
return self._data.keys()
377381

378382
def values(self) -> typing.ValuesView[typing.Any]:
383+
"""
384+
:returns: an object providing a view on D's values
385+
:rtype: ~typing.ValuesView
386+
"""
379387
return self._data.values()
380388

381389
def items(self) -> typing.ItemsView[str, typing.Any]:
390+
"""
391+
:returns: set-like object providing a view on D's items
392+
:rtype: ~typing.ItemsView
393+
"""
382394
return self._data.items()
383395

384396
def get(self, key: str, default: typing.Any = None) -> typing.Any:
397+
"""
398+
Get the value for key if key is in the dictionary, else default.
399+
:param str key: The key to look up.
400+
:param any default: The value to return if key is not in the dictionary. Defaults to None
401+
:returns: D[k] if k in D, else d.
402+
:rtype: any
403+
"""
385404
try:
386405
return self[key]
387406
except KeyError:
@@ -397,17 +416,38 @@ def pop(self, key: str, default: _T) -> _T: ...
397416
def pop(self, key: str, default: typing.Any) -> typing.Any: ...
398417

399418
def pop(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
419+
"""
420+
Removes specified key and return the corresponding value.
421+
:param str key: The key to pop.
422+
:param any default: The value to return if key is not in the dictionary
423+
:returns: The value corresponding to the key.
424+
:rtype: any
425+
:raises KeyError: If key is not found and default is not given.
426+
"""
400427
if default is _UNSET:
401428
return self._data.pop(key)
402429
return self._data.pop(key, default)
403430

404431
def popitem(self) -> typing.Tuple[str, typing.Any]:
432+
"""
433+
Removes and returns some (key, value) pair
434+
:returns: The (key, value) pair.
435+
:rtype: tuple
436+
:raises KeyError: if D is empty.
437+
"""
405438
return self._data.popitem()
406439

407440
def clear(self) -> None:
441+
"""
442+
Remove all items from D.
443+
"""
408444
self._data.clear()
409445

410446
def update(self, *args: typing.Any, **kwargs: typing.Any) -> None:
447+
"""
448+
Updates D from mapping/iterable E and F.
449+
:param any args: Either a mapping object or an iterable of key-value pairs.
450+
"""
411451
self._data.update(*args, **kwargs)
412452

413453
@typing.overload
@@ -417,6 +457,13 @@ def setdefault(self, key: str, default: None = None) -> None: ...
417457
def setdefault(self, key: str, default: typing.Any) -> typing.Any: ...
418458

419459
def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
460+
"""
461+
Same as calling D.get(k, d), and setting D[k]=d if k not found
462+
:param str key: The key to look up.
463+
:param any default: The value to set if key is not in the dictionary
464+
:returns: D[k] if k in D, else d.
465+
:rtype: any
466+
"""
420467
if default is _UNSET:
421468
return self._data.setdefault(key)
422469
return self._data.setdefault(key, default)
@@ -910,6 +957,19 @@ def _failsafe_deserialize(
910957
return None
911958

912959

960+
def _failsafe_deserialize_xml(
961+
deserializer: typing.Any,
962+
value: typing.Any,
963+
) -> typing.Any:
964+
try:
965+
return _deserialize_xml(deserializer, value)
966+
except DeserializationError:
967+
_LOGGER.warning(
968+
"Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True
969+
)
970+
return None
971+
972+
913973
class _RestField:
914974
def __init__(
915975
self,

sdk/ai/azure-ai-inference/azure/ai/inference/_operations/_operations.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# pylint: disable=too-many-locals
21
# coding=utf-8
32
# --------------------------------------------------------------------------
43
# Copyright (c) Microsoft Corporation. All rights reserved.
@@ -181,15 +180,6 @@ def build_image_embeddings_get_model_info_request(**kwargs: Any) -> HttpRequest:
181180

182181
class ChatCompletionsClientOperationsMixin(ChatCompletionsClientMixinABC):
183182

184-
@overload
185-
def _complete(
186-
self,
187-
body: JSON,
188-
*,
189-
extra_params: Optional[Union[str, _models._enums.ExtraParameters]] = None,
190-
content_type: str = "application/json",
191-
**kwargs: Any
192-
) -> _models.ChatCompletions: ...
193183
@overload
194184
def _complete(
195185
self,
@@ -214,6 +204,15 @@ def _complete(
214204
**kwargs: Any
215205
) -> _models.ChatCompletions: ...
216206
@overload
207+
def _complete(
208+
self,
209+
body: JSON,
210+
*,
211+
extra_params: Optional[Union[str, _models._enums.ExtraParameters]] = None,
212+
content_type: str = "application/json",
213+
**kwargs: Any
214+
) -> _models.ChatCompletions: ...
215+
@overload
217216
def _complete(
218217
self,
219218
body: IO[bytes],
@@ -488,23 +487,23 @@ class EmbeddingsClientOperationsMixin(EmbeddingsClientMixinABC):
488487
@overload
489488
def _embed(
490489
self,
491-
body: JSON,
492490
*,
491+
input: List[str],
493492
extra_params: Optional[Union[str, _models._enums.ExtraParameters]] = None,
494493
content_type: str = "application/json",
494+
dimensions: Optional[int] = None,
495+
encoding_format: Optional[Union[str, _models.EmbeddingEncodingFormat]] = None,
496+
input_type: Optional[Union[str, _models.EmbeddingInputType]] = None,
497+
model: Optional[str] = None,
495498
**kwargs: Any
496499
) -> _models.EmbeddingsResult: ...
497500
@overload
498501
def _embed(
499502
self,
503+
body: JSON,
500504
*,
501-
input: List[str],
502505
extra_params: Optional[Union[str, _models._enums.ExtraParameters]] = None,
503506
content_type: str = "application/json",
504-
dimensions: Optional[int] = None,
505-
encoding_format: Optional[Union[str, _models.EmbeddingEncodingFormat]] = None,
506-
input_type: Optional[Union[str, _models.EmbeddingInputType]] = None,
507-
model: Optional[str] = None,
508507
**kwargs: Any
509508
) -> _models.EmbeddingsResult: ...
510509
@overload
@@ -701,23 +700,23 @@ class ImageEmbeddingsClientOperationsMixin(ImageEmbeddingsClientMixinABC):
701700
@overload
702701
def _embed(
703702
self,
704-
body: JSON,
705703
*,
704+
input: List[_models.ImageEmbeddingInput],
706705
extra_params: Optional[Union[str, _models._enums.ExtraParameters]] = None,
707706
content_type: str = "application/json",
707+
dimensions: Optional[int] = None,
708+
encoding_format: Optional[Union[str, _models.EmbeddingEncodingFormat]] = None,
709+
input_type: Optional[Union[str, _models.EmbeddingInputType]] = None,
710+
model: Optional[str] = None,
708711
**kwargs: Any
709712
) -> _models.EmbeddingsResult: ...
710713
@overload
711714
def _embed(
712715
self,
716+
body: JSON,
713717
*,
714-
input: List[_models.ImageEmbeddingInput],
715718
extra_params: Optional[Union[str, _models._enums.ExtraParameters]] = None,
716719
content_type: str = "application/json",
717-
dimensions: Optional[int] = None,
718-
encoding_format: Optional[Union[str, _models.EmbeddingEncodingFormat]] = None,
719-
input_type: Optional[Union[str, _models.EmbeddingInputType]] = None,
720-
model: Optional[str] = None,
721720
**kwargs: Any
722721
) -> _models.EmbeddingsResult: ...
723722
@overload

0 commit comments

Comments
 (0)