Skip to content

Commit b5beb92

Browse files
authored
[azure-ai-projects] Emit SDK from TypeSpec (code-based agents operations) (#46776)
1 parent 62fcdc3 commit b5beb92

13 files changed

Lines changed: 1099 additions & 66 deletions

File tree

sdk/ai/azure-ai-projects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* New `.beta.datasets` sub-client with data generation job operations: `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job`.
1111
* New read-only property `content_hash` on `CodeConfiguration`, returning the SHA-256 hex digest of the uploaded code zip.
1212
* New evaluator generation job operations on `.beta.evaluators`: `create_generation_job`, `get_generation_job`, `list_generation_jobs`, `cancel_generation_job`, `delete_generation_job`.
13+
* New methods on `.beta.agents` sub-client for code-based hosted agents: `update_agent_from_code()`, `create_agent_version_from_code()`, `download_agent_version_code()`, `download_agent_code()`.
1314

1415
### Breaking Changes
1516

sdk/ai/azure-ai-projects/apiview-properties.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
"azure.ai.projects.models.EvaluationRuleAction": "Azure.AI.Projects.EvaluationRuleAction",
8686
"azure.ai.projects.models.ContinuousEvaluationRuleAction": "Azure.AI.Projects.ContinuousEvaluationRuleAction",
8787
"azure.ai.projects.models.CosmosDBIndex": "Azure.AI.Projects.CosmosDBIndex",
88+
"azure.ai.projects.models.CreateAgentVersionFromCodeContent": "Azure.AI.Projects.CreateAgentVersionFromCodeContent",
89+
"azure.ai.projects.models.CreateAgentVersionFromCodeRequest": "Azure.AI.Projects.CreateAgentVersionFromCodeRequest",
8890
"azure.ai.projects.models.Trigger": "Azure.AI.Projects.Trigger",
8991
"azure.ai.projects.models.CronTrigger": "Azure.AI.Projects.CronTrigger",
9092
"azure.ai.projects.models.CustomCredential": "Azure.AI.Projects.CustomCredential",
@@ -239,7 +241,6 @@
239241
"azure.ai.projects.models.SpecificFunctionShellParam": "OpenAI.SpecificFunctionShellParam",
240242
"azure.ai.projects.models.StructuredInputDefinition": "Azure.AI.Projects.StructuredInputDefinition",
241243
"azure.ai.projects.models.StructuredOutputDefinition": "Azure.AI.Projects.StructuredOutputDefinition",
242-
"azure.ai.projects.models.TaskDataGenerationJobOptions": "Azure.AI.Projects.TaskDataGenerationJobOptions",
243244
"azure.ai.projects.models.TaxonomyCategory": "Azure.AI.Projects.TaxonomyCategory",
244245
"azure.ai.projects.models.TaxonomySubCategory": "Azure.AI.Projects.TaxonomySubCategory",
245246
"azure.ai.projects.models.TelemetryConfig": "Azure.AI.Projects.TelemetryConfig",
@@ -298,6 +299,7 @@
298299
"azure.ai.projects.models.ContainerSkillType": "OpenAI.ContainerSkillType",
299300
"azure.ai.projects.models.SearchContextSize": "OpenAI.SearchContextSize",
300301
"azure.ai.projects.models.AgentProtocol": "Azure.AI.Projects.AgentProtocol",
302+
"azure.ai.projects.models.CodeDependencyResolution": "Azure.AI.Projects.CodeDependencyResolution",
301303
"azure.ai.projects.models.TelemetryEndpointKind": "Azure.AI.Projects.TelemetryEndpointKind",
302304
"azure.ai.projects.models.TelemetryDataKind": "Azure.AI.Projects.TelemetryDataKind",
303305
"azure.ai.projects.models.TelemetryEndpointAuthType": "Azure.AI.Projects.TelemetryEndpointAuthType",

sdk/ai/azure-ai-projects/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "python",
44
"TagPrefix": "python/ai/azure-ai-projects",
5-
"Tag": "python/ai/azure-ai-projects_33354b389b"
5+
"Tag": "python/ai/azure-ai-projects_f15b61b44c"
66
}

sdk/ai/azure-ai-projects/azure/ai/projects/_utils/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from .._utils.model_base import Model, SdkJSONEncoder
1212

13+
1314
# file-like tuple could be `(filename, IO (or bytes))` or `(filename, IO (or bytes), content_type)`
1415
FileContent = Union[str, bytes, IO[str], IO[bytes]]
1516

sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py

Lines changed: 425 additions & 1 deletion
Large diffs are not rendered by default.

sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class BetaOperations(GeneratedBetaOperations):
5959
skills: BetaSkillsOperations
6060
""":class:`~azure.ai.projects.aio.operations.BetaSkillsOperations` operations"""
6161
datasets: BetaDatasetsOperations
62-
""":class:`~azure.ai.projects.aio.operations.BetaDatasetsOperations` operations"""
62+
""":class:`~azure.ai.projects.aio.operations.BetaDatasetsOperations` operations"""
6363

6464
def __init__(self, *args: Any, **kwargs: Any) -> None:
6565
super().__init__(*args, **kwargs)

sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585
ContainerSkill,
8686
ContinuousEvaluationRuleAction,
8787
CosmosDBIndex,
88+
CreateAgentVersionFromCodeContent,
89+
CreateAgentVersionFromCodeRequest,
8890
CronTrigger,
8991
CustomCredential,
9092
CustomGrammarFormatParam,
@@ -246,7 +248,6 @@
246248
StructuredOutputDefinition,
247249
Target,
248250
TargetConfig,
249-
TaskDataGenerationJobOptions,
250251
TaxonomyCategory,
251252
TaxonomySubCategory,
252253
TelemetryConfig,
@@ -307,6 +308,7 @@
307308
AgentVersionStatus,
308309
AttackStrategy,
309310
AzureAISearchQueryType,
311+
CodeDependencyResolution,
310312
ComputerEnvironment,
311313
ConnectionType,
312314
ContainerMemoryLimit,
@@ -443,6 +445,8 @@
443445
"ContainerSkill",
444446
"ContinuousEvaluationRuleAction",
445447
"CosmosDBIndex",
448+
"CreateAgentVersionFromCodeContent",
449+
"CreateAgentVersionFromCodeRequest",
446450
"CronTrigger",
447451
"CustomCredential",
448452
"CustomGrammarFormatParam",
@@ -604,7 +608,6 @@
604608
"StructuredOutputDefinition",
605609
"Target",
606610
"TargetConfig",
607-
"TaskDataGenerationJobOptions",
608611
"TaxonomyCategory",
609612
"TaxonomySubCategory",
610613
"TelemetryConfig",
@@ -662,6 +665,7 @@
662665
"AgentVersionStatus",
663666
"AttackStrategy",
664667
"AzureAISearchQueryType",
668+
"CodeDependencyResolution",
665669
"ComputerEnvironment",
666670
"ConnectionType",
667671
"ContainerMemoryLimit",

sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class _AgentDefinitionOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta):
2121
"""CONTAINER_AGENTS_V1_PREVIEW."""
2222
AGENT_ENDPOINT_V1_PREVIEW = "AgentEndpoints=V1Preview"
2323
"""AGENT_ENDPOINT_V1_PREVIEW."""
24+
CODE_AGENTS_V1_PREVIEW = "CodeAgents=V1Preview"
25+
"""CODE_AGENTS_V1_PREVIEW."""
2426

2527

2628
class _FoundryFeaturesOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta):
@@ -234,6 +236,16 @@ class AzureAISearchQueryType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
234236
"""Query type ``vector_semantic_hybrid``."""
235237

236238

239+
class CodeDependencyResolution(str, Enum, metaclass=CaseInsensitiveEnumMeta):
240+
"""How package dependencies are resolved at deployment time for a code-based hosted agent."""
241+
242+
BUNDLED = "bundled"
243+
"""The caller has bundled all dependencies into the uploaded zip; the service performs no remote
244+
build."""
245+
REMOTE_BUILD = "remote_build"
246+
"""The service builds dependencies remotely from the manifest included in the uploaded zip."""
247+
248+
237249
class ComputerEnvironment(str, Enum, metaclass=CaseInsensitiveEnumMeta):
238250
"""Type of ComputerEnvironment."""
239251

@@ -375,9 +387,6 @@ class DataGenerationJobType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
375387
"""Single turn query and response from agent traces."""
376388
TOOL_USE = "tool_use"
377389
"""Tool calling conversation between user and agent."""
378-
TASK = "task"
379-
"""Task helps in providing a scenario description for generating multi turn conversation between
380-
user and agent."""
381390

382391

383392
class DatasetType(str, Enum, metaclass=CaseInsensitiveEnumMeta):

sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py

Lines changed: 120 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from typing import Any, Literal, Mapping, Optional, TYPE_CHECKING, Union, overload
1313

1414
from .._utils.model_base import Model as _Model, rest_discriminator, rest_field
15+
from .._utils.utils import FileType
1516
from ._enums import (
1617
AgentBlueprintReferenceType,
1718
AgentEndpointAuthorizationSchemeType,
@@ -2926,6 +2927,12 @@ class CodeConfiguration(_Model):
29262927
:vartype runtime: str
29272928
:ivar entry_point: The entry point command and arguments for the code execution. Required.
29282929
:vartype entry_point: list[str]
2930+
:ivar dependency_resolution: How package dependencies are resolved at deployment time. Defaults
2931+
to ``bundled``, where the caller bundles all dependencies into the uploaded zip and the service
2932+
performs no remote build. ``remote_build`` instructs the service to build dependencies remotely
2933+
from the manifest included in the uploaded zip. Required. Known values are: "bundled" and
2934+
"remote_build".
2935+
:vartype dependency_resolution: str or ~azure.ai.projects.models.CodeDependencyResolution
29292936
:ivar content_hash: The SHA-256 hex digest of the uploaded code zip. Set by the service from
29302937
the ``x-ms-code-zip-sha256`` request header; read-only in responses and never accepted in
29312938
request payloads.
@@ -2937,6 +2944,13 @@ class CodeConfiguration(_Model):
29372944
Required."""
29382945
entry_point: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
29392946
"""The entry point command and arguments for the code execution. Required."""
2947+
dependency_resolution: Union[str, "_models.CodeDependencyResolution"] = rest_field(
2948+
visibility=["read", "create", "update", "delete", "query"]
2949+
)
2950+
"""How package dependencies are resolved at deployment time. Defaults to ``bundled``, where the
2951+
caller bundles all dependencies into the uploaded zip and the service performs no remote build.
2952+
``remote_build`` instructs the service to build dependencies remotely from the manifest
2953+
included in the uploaded zip. Required. Known values are: \"bundled\" and \"remote_build\"."""
29402954
content_hash: Optional[str] = rest_field(visibility=["read"])
29412955
"""The SHA-256 hex digest of the uploaded code zip. Set by the service from the
29422956
``x-ms-code-zip-sha256`` request header; read-only in responses and never accepted in request
@@ -2948,6 +2962,7 @@ def __init__(
29482962
*,
29492963
runtime: str,
29502964
entry_point: list[str],
2965+
dependency_resolution: Union[str, "_models.CodeDependencyResolution"],
29512966
) -> None: ...
29522967

29532968
@overload
@@ -3633,6 +3648,97 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
36333648
self.type = IndexType.COSMOS_DB # type: ignore
36343649

36353650

3651+
class CreateAgentVersionFromCodeContent(_Model):
3652+
"""Multipart request body for updating or versioning a code-based agent (POST /agents/{name} and
3653+
POST /agents/{name}/versions).
3654+
3655+
:ivar metadata: JSON metadata including description and hosted definition. Required.
3656+
:vartype metadata: ~azure.ai.projects.models.CreateAgentVersionFromCodeRequest
3657+
:ivar code: The code zip file (max 250 MB). Required.
3658+
:vartype code: ~azure.ai.projects._utils.utils.FileType
3659+
"""
3660+
3661+
metadata: "_models.CreateAgentVersionFromCodeRequest" = rest_field(
3662+
visibility=["read", "create", "update", "delete", "query"]
3663+
)
3664+
"""JSON metadata including description and hosted definition. Required."""
3665+
code: FileType = rest_field(
3666+
visibility=["read", "create", "update", "delete", "query"], is_multipart_file_input=True
3667+
)
3668+
"""The code zip file (max 250 MB). Required."""
3669+
3670+
@overload
3671+
def __init__(
3672+
self,
3673+
*,
3674+
metadata: "_models.CreateAgentVersionFromCodeRequest",
3675+
code: FileType,
3676+
) -> None: ...
3677+
3678+
@overload
3679+
def __init__(self, mapping: Mapping[str, Any]) -> None:
3680+
"""
3681+
:param mapping: raw JSON to initialize the model.
3682+
:type mapping: Mapping[str, Any]
3683+
"""
3684+
3685+
def __init__(self, *args: Any, **kwargs: Any) -> None:
3686+
super().__init__(*args, **kwargs)
3687+
3688+
3689+
class CreateAgentVersionFromCodeRequest(_Model):
3690+
"""JSON metadata for code-based agent operations (create, update, create version). The agent name
3691+
comes from the URL path parameter or the ``x-ms-agent-name`` header, so it is not included in
3692+
this model. The content hash (SHA-256 of the zip) is carried in the ``x-ms-code-zip-sha256``
3693+
header.
3694+
3695+
:ivar description: A human-readable description of the agent.
3696+
:vartype description: str
3697+
:ivar metadata: Set of 16 key-value pairs that can be attached to an object. This can be
3698+
useful for storing additional information about the object in a structured
3699+
format, and querying for objects via API or the dashboard.
3700+
3701+
Keys are strings with a maximum length of 64 characters. Values are strings
3702+
with a maximum length of 512 characters.
3703+
:vartype metadata: dict[str, str]
3704+
:ivar definition: The hosted agent definition including code_configuration (runtime,
3705+
entry_point), cpu, memory, and protocol_versions. Required.
3706+
:vartype definition: ~azure.ai.projects.models.HostedAgentDefinition
3707+
"""
3708+
3709+
description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"])
3710+
"""A human-readable description of the agent."""
3711+
metadata: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"])
3712+
"""Set of 16 key-value pairs that can be attached to an object. This can be
3713+
useful for storing additional information about the object in a structured
3714+
format, and querying for objects via API or the dashboard.
3715+
3716+
Keys are strings with a maximum length of 64 characters. Values are strings
3717+
with a maximum length of 512 characters."""
3718+
definition: "_models.HostedAgentDefinition" = rest_field(visibility=["read", "create", "update", "delete", "query"])
3719+
"""The hosted agent definition including code_configuration (runtime, entry_point), cpu, memory,
3720+
and protocol_versions. Required."""
3721+
3722+
@overload
3723+
def __init__(
3724+
self,
3725+
*,
3726+
definition: "_models.HostedAgentDefinition",
3727+
description: Optional[str] = None,
3728+
metadata: Optional[dict[str, str]] = None,
3729+
) -> None: ...
3730+
3731+
@overload
3732+
def __init__(self, mapping: Mapping[str, Any]) -> None:
3733+
"""
3734+
:param mapping: raw JSON to initialize the model.
3735+
:type mapping: Mapping[str, Any]
3736+
"""
3737+
3738+
def __init__(self, *args: Any, **kwargs: Any) -> None:
3739+
super().__init__(*args, **kwargs)
3740+
3741+
36363742
class Trigger(_Model):
36373743
"""Base model for Trigger of the schedule.
36383744
@@ -4073,11 +4179,11 @@ class DataGenerationJobOptions(_Model):
40734179
"""Options for managing data generation jobs.
40744180
40754181
You probably want to use the sub-classes and not this class directly. Known sub-classes are:
4076-
SimpleQnADataGenerationJobOptions, TaskDataGenerationJobOptions,
4077-
ToolUseFineTuningDataGenerationJobOptions, TracesDataGenerationJobOptions
4182+
SimpleQnADataGenerationJobOptions, ToolUseFineTuningDataGenerationJobOptions,
4183+
TracesDataGenerationJobOptions
40784184
40794185
:ivar type: The data generation job type. Required. Known values are: "simple_qna", "traces",
4080-
"tool_use", and "task".
4186+
and "tool_use".
40814187
:vartype type: str or ~azure.ai.projects.models.DataGenerationJobType
40824188
:ivar max_samples: Maximum number of samples to generate. Required.
40834189
:vartype max_samples: int
@@ -4090,8 +4196,8 @@ class DataGenerationJobOptions(_Model):
40904196

40914197
__mapping__: dict[str, _Model] = {}
40924198
type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"])
4093-
"""The data generation job type. Required. Known values are: \"simple_qna\", \"traces\",
4094-
\"tool_use\", and \"task\"."""
4199+
"""The data generation job type. Required. Known values are: \"simple_qna\", \"traces\", and
4200+
\"tool_use\"."""
40954201
max_samples: int = rest_field(visibility=["read", "create", "update", "delete", "query"])
40964202
"""Maximum number of samples to generate. Required."""
40974203
train_split: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"])
@@ -4229,20 +4335,20 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
42294335
class DataGenerationTokenUsage(_Model):
42304336
"""Token usage information for a data generation job.
42314337
4232-
:ivar prompt_tokens: The number of prompt tokens used.
4338+
:ivar prompt_tokens: The number of prompt tokens used. Required.
42334339
:vartype prompt_tokens: int
4234-
:ivar completion_tokens: The number of completion tokens generated.
4340+
:ivar completion_tokens: The number of completion tokens generated. Required.
42354341
:vartype completion_tokens: int
4236-
:ivar total_tokens: Total number of tokens used.
4342+
:ivar total_tokens: Total number of tokens used. Required.
42374343
:vartype total_tokens: int
42384344
"""
42394345

4240-
prompt_tokens: Optional[int] = rest_field(visibility=["read"])
4241-
"""The number of prompt tokens used."""
4242-
completion_tokens: Optional[int] = rest_field(visibility=["read"])
4243-
"""The number of completion tokens generated."""
4244-
total_tokens: Optional[int] = rest_field(visibility=["read"])
4245-
"""Total number of tokens used."""
4346+
prompt_tokens: int = rest_field(visibility=["read"])
4347+
"""The number of prompt tokens used. Required."""
4348+
completion_tokens: int = rest_field(visibility=["read"])
4349+
"""The number of completion tokens generated. Required."""
4350+
total_tokens: int = rest_field(visibility=["read"])
4351+
"""Total number of tokens used. Required."""
42464352

42474353

42484354
class DatasetCredential(_Model):
@@ -10571,46 +10677,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
1057110677
super().__init__(*args, **kwargs)
1057210678

1057310679

10574-
class TaskDataGenerationJobOptions(DataGenerationJobOptions, discriminator="task"):
10575-
"""The options for a data generation job with Task type.
10576-
10577-
:ivar max_samples: Maximum number of samples to generate. Required.
10578-
:vartype max_samples: int
10579-
:ivar train_split: The proportion of the generated data to be used for training when the data
10580-
is used for fine-tuning. The rest will be used for validation. Value should be between 0 and 1.
10581-
:vartype train_split: float
10582-
:ivar model_options: The LLM model options.
10583-
:vartype model_options: ~azure.ai.projects.models.DataGenerationModelOptions
10584-
:ivar type: The data generation job type, which is Task for this model. Required. Task helps in
10585-
providing a scenario description for generating multi turn conversation between user and agent.
10586-
:vartype type: str or ~azure.ai.projects.models.TASK
10587-
"""
10588-
10589-
type: Literal[DataGenerationJobType.TASK] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore
10590-
"""The data generation job type, which is Task for this model. Required. Task helps in providing a
10591-
scenario description for generating multi turn conversation between user and agent."""
10592-
10593-
@overload
10594-
def __init__(
10595-
self,
10596-
*,
10597-
max_samples: int,
10598-
train_split: Optional[float] = None,
10599-
model_options: Optional["_models.DataGenerationModelOptions"] = None,
10600-
) -> None: ...
10601-
10602-
@overload
10603-
def __init__(self, mapping: Mapping[str, Any]) -> None:
10604-
"""
10605-
:param mapping: raw JSON to initialize the model.
10606-
:type mapping: Mapping[str, Any]
10607-
"""
10608-
10609-
def __init__(self, *args: Any, **kwargs: Any) -> None:
10610-
super().__init__(*args, **kwargs)
10611-
self.type = DataGenerationJobType.TASK # type: ignore
10612-
10613-
1061410680
class TaxonomyCategory(_Model):
1061510681
"""Taxonomy category definition.
1061610682

sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
[
5454
_AgentDefinitionOptInKeys.HOSTED_AGENTS_V1_PREVIEW.value,
5555
_AgentDefinitionOptInKeys.AGENT_ENDPOINT_V1_PREVIEW.value,
56+
_AgentDefinitionOptInKeys.CODE_AGENTS_V1_PREVIEW.value,
5657
]
5758
),
5859
}

0 commit comments

Comments
 (0)