diff --git a/sdk/ai/azure-ai-projects/CHANGELOG.md b/sdk/ai/azure-ai-projects/CHANGELOG.md index b8c248424a5b..af601d25d498 100644 --- a/sdk/ai/azure-ai-projects/CHANGELOG.md +++ b/sdk/ai/azure-ai-projects/CHANGELOG.md @@ -4,6 +4,7 @@ ### Features Added +* Agent Insights monitor APIs are now GA, available through `.agent_insight_monitors` without a preview opt-in header. Custom run pollers continue to expose the run ID through `details`. * Added preview `.beta.voice_agents.live.connect()` and `VoiceAgentLiveDefinition` for synchronous and asynchronous GPT Live sessions, with typed client and server events, session updates, text and audio input, and Responses backend function-tool support. * Added Live delegation models for Responses backends, application-managed work, and same-project prompt agents: `VoiceAgentLiveResponsesDelegation`, `VoiceAgentLiveClientDelegation`, and `VoiceAgentLiveManagedAgentDelegation`. * Added `.beta.voice_agents.live_conversations` for listing, retrieving, and deleting stored Live conversations, retrieving conversation items, and retrieving or downloading item-level and conversation-level audio. @@ -27,12 +28,16 @@ All breaking changes affect preview APIs. Breaking changes in beta methods: +* Moved `.beta.agent_insight_monitors` operations to the top-level `.agent_insight_monitors` sub-client. +* Agent Insights monitor `create()`, `update()`, `begin_create_run()`, and `update_insight()` now accept keyword parameters or JSON/binary bodies instead of dedicated preview request models. Use `lookback_hours` for run inputs. * Argument `telephony_binding` in `.beta.voice_agents.telephony.create_binding()` renamed to `binding`; the typed body now accepts `TelephonyBinding` instead of `CreateTelephonyBindingRequest`. * Argument `body` in `.beta.voice_agents.telephony.create_call_job()` renamed to `job`; the typed body now accepts `TelephonyCallJobCreate` instead of `CreateTelephonyCallJobRequest`. * Removed the `status` filter from `.beta.voice_agents.telephony.list_bindings()`. Breaking changes in beta classes: +* Class `BetaAgentInsightMonitorsOperations` renamed to `AgentInsightMonitorsOperations`. +* Removed `AgentInsightMonitorCreate`, `AgentInsightMonitorUpdate`, `AgentInsightRunCreate`, and `AgentInsightUpdate`; use the corresponding operation's keyword parameters instead. * Removed `CreateTelephonyBindingRequest`, `CreateTeamsPhoneExtensibilityTelephonyBindingRequest`, and `CreateTwilioTelephonyBindingRequest`. Use `TelephonyBinding`, `TeamsPhoneExtensibilityTelephonyBinding`, and `TwilioTelephonyBinding`, respectively. * Class `CreateTelephonyCallJobRequest` renamed to `TelephonyCallJobCreate`. * Removed `TelephonyOutboundDestination` and `TelephonyOutboundDestinationType`; use `TelephonyAddress` and `TelephonyAddressType`. The `source` and `destination` properties on `TelephonyCallJobCreate` and `TelephonyCallJob` now use `TelephonyAddress`; `source` no longer accepts a plain string. @@ -50,6 +55,7 @@ Breaking changes in beta classes: ### Sample updates +* Agent Insights samples demonstrate GA analysis priorities, instructions, and plural status filters. * Added Live voice-agent samples under `samples/agents/voice/` for session lifecycle, text and audio conversations, local function tools, and same-project managed-agent delegation. * Added `sample_voice_agent_live_read_conversation.py` demonstrating stored Live conversation, transcript, and audio retrieval, with an optional temporary greeting session. * Added `sample_voice_agent_read_generated_audio.py` demonstrating retrieval of generated, unheard audio from an interrupted Realtime reply. diff --git a/sdk/ai/azure-ai-projects/README.md b/sdk/ai/azure-ai-projects/README.md index c7dda7b377de..c10673194910 100644 --- a/sdk/ai/azure-ai-projects/README.md +++ b/sdk/ai/azure-ai-projects/README.md @@ -35,6 +35,7 @@ resources in your [Microsoft Foundry](https://ai.azure.com/) Project. Use it to: * **Enumerate connected Azure resources** in your Foundry project using `.connections` operations. * **Upload documents and create Datasets** to reference them using `.datasets` operations. * **Create and enumerate Search Indexes** using `.indexes` operations. +* **Analyze agent traces and manage insights** with configurable priorities, on-demand runs, scheduled monitors, and list-based insight filters through `.agent_insight_monitors` operations. * **Explore additional evaluation tools (some in preview)** to assess the performance of your generative AI application, using `.evaluation_rules`, `.beta.evaluation_taxonomies`, `.beta.evaluators`, `.beta.insights`, and `.beta.schedules` operations. * **Manage memory stores (preview)** for Agent conversations, using `.beta.memory_stores` operations. @@ -175,7 +176,7 @@ The table below lists the operation groups supported by the client library, with | Topic | Foundry documentation | Samples folder | |---|---|---| | Agents (create, run, stream) | [Agents overview](https://learn.microsoft.com/azure/foundry/agents/overview) | `samples/agents/` | -| Agent Insights (preview) | | [On-demand analysis and scheduled monitors](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/ai/azure-ai-projects/samples/agent_insights) | +| Agent Insights | | [On-demand analysis and scheduled monitors](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/ai/azure-ai-projects/samples/agent_insights) | | Hosted agents | [Hosted agents concepts](https://learn.microsoft.com/azure/foundry/agents/concepts/hosted-agents), [Deploy your first hosted agent](https://learn.microsoft.com/azure/foundry/agents/quickstarts/quickstart-hosted-agent) | `samples/hosted_agents/` | | Agents tools | [Tool catalog](https://learn.microsoft.com/azure/foundry/agents/concepts/tool-catalog) | `samples/agents/tools/` | | Agents optimization | [Prompt optimizer](https://learn.microsoft.com/azure/foundry/observability/how-to/prompt-optimizer), [Agent optimizer overview](https://learn.microsoft.com/azure/foundry/agents/concepts/agent-optimizer-overview) | `samples/agents/optimization/` | diff --git a/sdk/ai/azure-ai-projects/api.md b/sdk/ai/azure-ai-projects/api.md index 235f3e562a6b..bfbc08f755d8 100644 --- a/sdk/ai/azure-ai-projects/api.md +++ b/sdk/ai/azure-ai-projects/api.md @@ -2,6 +2,7 @@ namespace azure.ai.projects class azure.ai.projects.AIProjectClient(AIProjectClientGenerated): implements ContextManager + agent_insight_monitors: AgentInsightMonitorsOperations agents: AgentsOperations beta: BetaOperations connections: ConnectionsOperations @@ -44,6 +45,7 @@ namespace azure.ai.projects namespace azure.ai.projects.aio class azure.ai.projects.aio.AIProjectClient(AIProjectClientGenerated): implements AsyncContextManager + agent_insight_monitors: AgentInsightMonitorsOperations agents: AgentsOperations beta: BetaOperations connections: ConnectionsOperations @@ -85,6 +87,231 @@ namespace azure.ai.projects.aio namespace azure.ai.projects.aio.operations + class azure.ai.projects.aio.operations.AgentInsightMonitorsOperations(AgentInsightMonitorsOperationsGenerated): + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + *, + content_type: str = "application/json", + lookback_hours: Optional[float] = ..., + operation_id: Optional[str] = ..., + **kwargs: Any + ) -> AsyncAgentInsightRunLROPoller: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + body: JSON, + *, + content_type: str = "application/json", + operation_id: Optional[str] = ..., + **kwargs: Any + ) -> AsyncAgentInsightRunLROPoller: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + operation_id: Optional[str] = ..., + **kwargs: Any + ) -> AsyncAgentInsightRunLROPoller: ... + + @distributed_trace_async + async def cancel_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @overload + async def create( + self, + *, + agent_name: str, + content_type: str = "application/json", + enabled: Optional[bool] = ..., + model_deployment_name: str, + priorities: Optional[AgentInsightPriorities] = ..., + run_interval_hours: Optional[float] = ..., + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def create( + self, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def create( + self, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace_async + async def delete( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + async def get( + self, + monitor_id: str, + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace_async + async def get_insight( + self, + monitor_id: str, + insight_id: str, + *, + include_details: Optional[bool] = ..., + **kwargs: Any + ) -> AgentInsight: ... + + @distributed_trace_async + async def get_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @distributed_trace + def list( + self, + *, + agent_name: Optional[str] = ..., + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + **kwargs: Any + ) -> AsyncItemPaged[AgentInsightMonitorListItem]: ... + + @distributed_trace + def list_insights( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + categories: Optional[List[str]] = ..., + include_details: Optional[bool] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + severities: Optional[List[Union[str, AgentInsightSeverity]]] = ..., + statuses: Optional[List[Union[str, AgentInsightStatus]]] = ..., + **kwargs: Any + ) -> AsyncItemPaged[AgentInsight]: ... + + @distributed_trace + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + status: Optional[Union[str, JobStatus]] = ..., + trigger: Optional[Union[str, AgentInsightRunTrigger]] = ..., + **kwargs: Any + ) -> AsyncItemPaged[AgentInsightRun]: ... + + @distributed_trace_async + async def reset( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @overload + async def update( + self, + monitor_id: str, + *, + content_type: str = "application/merge-patch+json", + enabled: Optional[bool] = ..., + model_deployment_name: Optional[str] = ..., + priorities: Optional[AgentInsightPriorities] = ..., + run_interval_hours: Optional[float] = ..., + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def update( + self, + monitor_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def update( + self, + monitor_id: str, + body: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + *, + content_type: str = "application/merge-patch+json", + status: Optional[Union[str, AgentInsightStatus]] = ..., + **kwargs: Any + ) -> AgentInsight: ... + + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + body: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + class azure.ai.projects.aio.operations.AgentsOperations(GeneratedAgentsOperations): def __init__( @@ -768,7 +995,23 @@ namespace azure.ai.projects.aio.operations async def enter(self) -> AsyncBetaRealtimeConnection: ... - class azure.ai.projects.aio.operations.BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): + class azure.ai.projects.aio.operations.BetaAgentsOperations(BetaAgentsOperationsGenerated): + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @distributed_trace_async + async def create_from_prompt( + self, + body: GenerateAgentRequest, + **kwargs: Any + ) -> AgentDetails: ... + + + class azure.ai.projects.aio.operations.BetaEvaluationTaxonomiesOperations: def __init__( self, @@ -777,264 +1020,30 @@ namespace azure.ai.projects.aio.operations ) -> None: ... @overload - async def begin_create_run( + async def create( self, - monitor_id: str, - run: AgentInsightRunCreate, + name: str, + taxonomy: EvaluationTaxonomy, *, content_type: str = "application/json", - operation_id: Optional[str] = ..., **kwargs: Any - ) -> AsyncAgentInsightRunLROPoller: ... + ) -> EvaluationTaxonomy: ... @overload - async def begin_create_run( + async def create( self, - monitor_id: str, - run: JSON, + name: str, + taxonomy: JSON, *, content_type: str = "application/json", - operation_id: Optional[str] = ..., **kwargs: Any - ) -> AsyncAgentInsightRunLROPoller: ... + ) -> EvaluationTaxonomy: ... @overload - async def begin_create_run( + async def create( self, - monitor_id: str, - run: IO[bytes], - *, - content_type: str = "application/json", - operation_id: Optional[str] = ..., - **kwargs: Any - ) -> AsyncAgentInsightRunLROPoller: ... - - @distributed_trace_async - async def cancel_run( - self, - monitor_id: str, - run_id: str, - **kwargs: Any - ) -> AgentInsightRun: ... - - @overload - async def create( - self, - monitor: AgentInsightMonitorCreate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - async def create( - self, - monitor: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - async def create( - self, - monitor: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @distributed_trace_async - async def delete( - self, - monitor_id: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace_async - async def get( - self, - monitor_id: str, - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @distributed_trace_async - async def get_insight( - self, - monitor_id: str, - insight_id: str, - *, - include_details: Optional[bool] = ..., - **kwargs: Any - ) -> AgentInsight: ... - - @distributed_trace_async - async def get_run( - self, - monitor_id: str, - run_id: str, - **kwargs: Any - ) -> AgentInsightRun: ... - - @distributed_trace - def list( - self, - *, - agent_name: Optional[str] = ..., - before: Optional[str] = ..., - limit: Optional[int] = ..., - order: Optional[Union[str, PageOrder]] = ..., - **kwargs: Any - ) -> AsyncItemPaged[AgentInsightMonitorListItem]: ... - - @distributed_trace - def list_insights( - self, - monitor_id: str, - *, - before: Optional[str] = ..., - category: Optional[str] = ..., - include_details: Optional[bool] = ..., - limit: Optional[int] = ..., - order: Optional[Union[str, PageOrder]] = ..., - severity: Optional[Union[str, AgentInsightSeverity]] = ..., - status: Optional[Union[str, AgentInsightStatus]] = ..., - **kwargs: Any - ) -> AsyncItemPaged[AgentInsight]: ... - - @distributed_trace - def list_runs( - self, - monitor_id: str, - *, - before: Optional[str] = ..., - limit: Optional[int] = ..., - order: Optional[Union[str, PageOrder]] = ..., - status: Optional[Union[str, JobStatus]] = ..., - trigger: Optional[Union[str, AgentInsightRunTrigger]] = ..., - **kwargs: Any - ) -> AsyncItemPaged[AgentInsightRun]: ... - - @distributed_trace_async - async def reset( - self, - monitor_id: str, - **kwargs: Any - ) -> None: ... - - @overload - async def update( - self, - monitor_id: str, - monitor: AgentInsightMonitorUpdate, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - async def update( - self, - monitor_id: str, - monitor: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - async def update( - self, - monitor_id: str, - monitor: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - async def update_insight( - self, - monitor_id: str, - insight_id: str, - update: AgentInsightUpdate, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsight: ... - - @overload - async def update_insight( - self, - monitor_id: str, - insight_id: str, - update: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsight: ... - - @overload - async def update_insight( - self, - monitor_id: str, - insight_id: str, - update: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsight: ... - - - class azure.ai.projects.aio.operations.BetaAgentsOperations(BetaAgentsOperationsGenerated): - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @distributed_trace_async - async def create_from_prompt( - self, - body: GenerateAgentRequest, - **kwargs: Any - ) -> AgentDetails: ... - - - class azure.ai.projects.aio.operations.BetaEvaluationTaxonomiesOperations: - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - async def create( - self, - name: str, - taxonomy: EvaluationTaxonomy, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> EvaluationTaxonomy: ... - - @overload - async def create( - self, - name: str, - taxonomy: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> EvaluationTaxonomy: ... - - @overload - async def create( - self, - name: str, - taxonomy: IO[bytes], + name: str, + taxonomy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1666,7 +1675,6 @@ namespace azure.ai.projects.aio.operations class azure.ai.projects.aio.operations.BetaOperations(GeneratedBetaOperations): - agent_insight_monitors: BetaAgentInsightMonitorsOperations agents: BetaAgentsOperations evaluation_taxonomies: BetaEvaluationTaxonomiesOperations insights: BetaInsightsOperations @@ -3944,37 +3952,18 @@ namespace azure.ai.projects.models class azure.ai.projects.models.AgentInsightMonitor(_Model): agent_name: str + agent_summary: Optional[AgentInsightSummary] enabled: bool estimated_cost: Optional[AgentInsightEstimatedCost] id: str model_deployment_name: str next_scheduled_run_at: Optional[datetime] - overview: AgentInsightsOverview + priorities: Optional[AgentInsightPrioritiesRead] run_interval_hours: float suspension: AgentInsightSuspension updated_at: datetime - class azure.ai.projects.models.AgentInsightMonitorCreate(_Model): - agent_name: str - enabled: Optional[bool] - model_deployment_name: str - run_interval_hours: Optional[float] - - @overload - def __init__( - self, - *, - agent_name: str, - enabled: Optional[bool] = ..., - model_deployment_name: str, - run_interval_hours: Optional[float] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - class azure.ai.projects.models.AgentInsightMonitorListItem(_Model): agent_name: str enabled: bool @@ -3982,34 +3971,42 @@ namespace azure.ai.projects.models id: str model_deployment_name: str next_scheduled_run_at: Optional[datetime] + priorities: Optional[AgentInsightPrioritiesRead] run_interval_hours: float suspension: AgentInsightSuspension updated_at: datetime - class azure.ai.projects.models.AgentInsightMonitorUpdate(_Model): - enabled: Optional[bool] - model_deployment_name: Optional[str] - overview_override: Optional[AgentInsightsOverviewOverride] - run_interval_hours: Optional[float] + class azure.ai.projects.models.AgentInsightPriorities(_Model): + categories: list[str] + instructions: Optional[str] @overload def __init__( self, *, - enabled: Optional[bool] = ..., - model_deployment_name: Optional[str] = ..., - overview_override: Optional[AgentInsightsOverviewOverride] = ..., - run_interval_hours: Optional[float] = ... + categories: list[str], + instructions: Optional[str] = ... ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.ai.projects.models.AgentInsightOverviewSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - GENERATED = "generated" - USER_OVERRIDE = "user_override" + class azure.ai.projects.models.AgentInsightPrioritiesRead(_Model): + categories: list[str] + instructions: Optional[str] + + @overload + def __init__( + self, + *, + categories: list[str], + instructions: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... class azure.ai.projects.models.AgentInsightPromptSurface(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -4087,7 +4084,7 @@ namespace azure.ai.projects.models created_at: datetime error: Optional[ApiError] id: str - inputs: Optional[AgentInsightRunCreate] + inputs: Optional[AgentInsightRunInputs] model_deployment_name: str monitor_id: str result: Optional[AgentInsightRunResult] @@ -4102,14 +4099,14 @@ namespace azure.ai.projects.models def __init__( self, *, - inputs: Optional[AgentInsightRunCreate] = ... + inputs: Optional[AgentInsightRunInputs] = ... ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.ai.projects.models.AgentInsightRunCreate(_Model): + class azure.ai.projects.models.AgentInsightRunInputs(_Model): lookback_hours: Optional[float] @overload @@ -4186,6 +4183,10 @@ namespace azure.ai.projects.models RESOLVED = "resolved" + class azure.ai.projects.models.AgentInsightSummary(_Model): + markdown: str + + class azure.ai.projects.models.AgentInsightSuspension(_Model): code: str details: Optional[dict[str, Any]] @@ -4226,52 +4227,6 @@ namespace azure.ai.projects.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.ai.projects.models.AgentInsightUpdate(_Model): - status: Optional[Union[str, AgentInsightStatus]] - - @overload - def __init__( - self, - *, - status: Optional[Union[str, AgentInsightStatus]] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.ai.projects.models.AgentInsightsOverview(_Model): - content: str - source: Union[str, AgentInsightOverviewSource] - updated_at: datetime - - @overload - def __init__( - self, - *, - content: str, - source: Union[str, AgentInsightOverviewSource], - updated_at: datetime - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - - class azure.ai.projects.models.AgentInsightsOverviewOverride(_Model): - content: str - - @overload - def __init__( - self, - *, - content: str - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - class azure.ai.projects.models.AgentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): EXTERNAL = "external" HOSTED = "hosted" @@ -7080,14 +7035,14 @@ namespace azure.ai.projects.models class azure.ai.projects.models.DatasetReference(_Model): name: str - version: str + version: Optional[str] @overload def __init__( self, *, name: str, - version: str + version: Optional[str] = ... ) -> None: ... @overload @@ -7885,14 +7840,14 @@ namespace azure.ai.projects.models class azure.ai.projects.models.EvaluatorGenerationArtifacts(_Model): - dataset: DatasetReference + dataset: VersionedDatasetReference kinds: list[str] @overload def __init__( self, *, - dataset: DatasetReference, + dataset: VersionedDatasetReference, kinds: list[str] ) -> None: ... @@ -17327,7 +17282,7 @@ namespace azure.ai.projects.models name: str operation_id: str progress: TelephonyCampaignProgress - recipient_dataset: Optional[TelephonyCampaignDatasetReference] + recipient_dataset: Optional[DatasetReference] recipients: Optional[list[TelephonyRecipient]] retry_policy: Optional[TelephonyOutboundRetryPolicy] schedule: Optional[TelephonyCampaignSchedule] @@ -17340,7 +17295,7 @@ namespace azure.ai.projects.models self, *, connection_name: str, - recipient_dataset: Optional[TelephonyCampaignDatasetReference] = ..., + recipient_dataset: Optional[DatasetReference] = ..., recipients: Optional[list[TelephonyRecipient]] = ..., retry_policy: Optional[TelephonyOutboundRetryPolicy] = ..., schedule: Optional[TelephonyCampaignSchedule] = ..., @@ -17351,22 +17306,6 @@ namespace azure.ai.projects.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.ai.projects.models.TelephonyCampaignDatasetReference(_Model): - name: str - version: Optional[str] - - @overload - def __init__( - self, - *, - name: str, - version: Optional[str] = ... - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: ... - - class azure.ai.projects.models.TelephonyCampaignOperation(_Model): created_at: datetime error: Optional[ApiError] @@ -18686,6 +18625,22 @@ namespace azure.ai.projects.models FIXED_RATIO = "FixedRatio" + class azure.ai.projects.models.VersionedDatasetReference(_Model): + name: str + version: str + + @overload + def __init__( + self, + *, + name: str, + version: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.ai.projects.models.VoiceAgentAnimationConfig(_Model): model_name: Optional[str] outputs: Optional[list[Union[str, VoiceAgentAnimationOutputType]]] @@ -22239,6 +22194,231 @@ namespace azure.ai.projects.models namespace azure.ai.projects.operations + class azure.ai.projects.operations.AgentInsightMonitorsOperations(AgentInsightMonitorsOperationsGenerated): + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + *, + content_type: str = "application/json", + lookback_hours: Optional[float] = ..., + operation_id: Optional[str] = ..., + **kwargs: Any + ) -> AgentInsightRunLROPoller: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + body: JSON, + *, + content_type: str = "application/json", + operation_id: Optional[str] = ..., + **kwargs: Any + ) -> AgentInsightRunLROPoller: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + body: IO[bytes], + *, + content_type: str = "application/json", + operation_id: Optional[str] = ..., + **kwargs: Any + ) -> AgentInsightRunLROPoller: ... + + @distributed_trace + def cancel_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @overload + def create( + self, + *, + agent_name: str, + content_type: str = "application/json", + enabled: Optional[bool] = ..., + model_deployment_name: str, + priorities: Optional[AgentInsightPriorities] = ..., + run_interval_hours: Optional[float] = ..., + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def create( + self, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def create( + self, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace + def delete( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace + def get( + self, + monitor_id: str, + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace + def get_insight( + self, + monitor_id: str, + insight_id: str, + *, + include_details: Optional[bool] = ..., + **kwargs: Any + ) -> AgentInsight: ... + + @distributed_trace + def get_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @distributed_trace + def list( + self, + *, + agent_name: Optional[str] = ..., + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + **kwargs: Any + ) -> ItemPaged[AgentInsightMonitorListItem]: ... + + @distributed_trace + def list_insights( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + categories: Optional[List[str]] = ..., + include_details: Optional[bool] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + severities: Optional[List[Union[str, AgentInsightSeverity]]] = ..., + statuses: Optional[List[Union[str, AgentInsightStatus]]] = ..., + **kwargs: Any + ) -> ItemPaged[AgentInsight]: ... + + @distributed_trace + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + status: Optional[Union[str, JobStatus]] = ..., + trigger: Optional[Union[str, AgentInsightRunTrigger]] = ..., + **kwargs: Any + ) -> ItemPaged[AgentInsightRun]: ... + + @distributed_trace + def reset( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @overload + def update( + self, + monitor_id: str, + *, + content_type: str = "application/merge-patch+json", + enabled: Optional[bool] = ..., + model_deployment_name: Optional[str] = ..., + priorities: Optional[AgentInsightPriorities] = ..., + run_interval_hours: Optional[float] = ..., + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def update( + self, + monitor_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def update( + self, + monitor_id: str, + body: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + *, + content_type: str = "application/merge-patch+json", + status: Optional[Union[str, AgentInsightStatus]] = ..., + **kwargs: Any + ) -> AgentInsight: ... + + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + body: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + class azure.ai.projects.operations.AgentsOperations(GeneratedAgentsOperations): def __init__( @@ -22789,224 +22969,6 @@ namespace azure.ai.projects.operations ) -> SessionFileWriteResult: ... - class azure.ai.projects.operations.BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): - - def __init__( - self, - *args, - **kwargs - ) -> None: ... - - @overload - def begin_create_run( - self, - monitor_id: str, - run: AgentInsightRunCreate, - *, - content_type: str = "application/json", - operation_id: Optional[str] = ..., - **kwargs: Any - ) -> AgentInsightRunLROPoller: ... - - @overload - def begin_create_run( - self, - monitor_id: str, - run: JSON, - *, - content_type: str = "application/json", - operation_id: Optional[str] = ..., - **kwargs: Any - ) -> AgentInsightRunLROPoller: ... - - @overload - def begin_create_run( - self, - monitor_id: str, - run: IO[bytes], - *, - content_type: str = "application/json", - operation_id: Optional[str] = ..., - **kwargs: Any - ) -> AgentInsightRunLROPoller: ... - - @distributed_trace - def cancel_run( - self, - monitor_id: str, - run_id: str, - **kwargs: Any - ) -> AgentInsightRun: ... - - @overload - def create( - self, - monitor: AgentInsightMonitorCreate, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - def create( - self, - monitor: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - def create( - self, - monitor: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @distributed_trace - def delete( - self, - monitor_id: str, - **kwargs: Any - ) -> None: ... - - @distributed_trace - def get( - self, - monitor_id: str, - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @distributed_trace - def get_insight( - self, - monitor_id: str, - insight_id: str, - *, - include_details: Optional[bool] = ..., - **kwargs: Any - ) -> AgentInsight: ... - - @distributed_trace - def get_run( - self, - monitor_id: str, - run_id: str, - **kwargs: Any - ) -> AgentInsightRun: ... - - @distributed_trace - def list( - self, - *, - agent_name: Optional[str] = ..., - before: Optional[str] = ..., - limit: Optional[int] = ..., - order: Optional[Union[str, PageOrder]] = ..., - **kwargs: Any - ) -> ItemPaged[AgentInsightMonitorListItem]: ... - - @distributed_trace - def list_insights( - self, - monitor_id: str, - *, - before: Optional[str] = ..., - category: Optional[str] = ..., - include_details: Optional[bool] = ..., - limit: Optional[int] = ..., - order: Optional[Union[str, PageOrder]] = ..., - severity: Optional[Union[str, AgentInsightSeverity]] = ..., - status: Optional[Union[str, AgentInsightStatus]] = ..., - **kwargs: Any - ) -> ItemPaged[AgentInsight]: ... - - @distributed_trace - def list_runs( - self, - monitor_id: str, - *, - before: Optional[str] = ..., - limit: Optional[int] = ..., - order: Optional[Union[str, PageOrder]] = ..., - status: Optional[Union[str, JobStatus]] = ..., - trigger: Optional[Union[str, AgentInsightRunTrigger]] = ..., - **kwargs: Any - ) -> ItemPaged[AgentInsightRun]: ... - - @distributed_trace - def reset( - self, - monitor_id: str, - **kwargs: Any - ) -> None: ... - - @overload - def update( - self, - monitor_id: str, - monitor: AgentInsightMonitorUpdate, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - def update( - self, - monitor_id: str, - monitor: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - def update( - self, - monitor_id: str, - monitor: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsightMonitor: ... - - @overload - def update_insight( - self, - monitor_id: str, - insight_id: str, - update: AgentInsightUpdate, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsight: ... - - @overload - def update_insight( - self, - monitor_id: str, - insight_id: str, - update: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsight: ... - - @overload - def update_insight( - self, - monitor_id: str, - insight_id: str, - update: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> AgentInsight: ... - - class azure.ai.projects.operations.BetaAgentsOperations(BetaAgentsOperationsGenerated): def __init__( @@ -23751,7 +23713,6 @@ namespace azure.ai.projects.operations class azure.ai.projects.operations.BetaOperations(GeneratedBetaOperations): - agent_insight_monitors: BetaAgentInsightMonitorsOperations agents: BetaAgentsOperations evaluation_taxonomies: BetaEvaluationTaxonomiesOperations insights: BetaInsightsOperations diff --git a/sdk/ai/azure-ai-projects/api.metadata.yml b/sdk/ai/azure-ai-projects/api.metadata.yml index 8368e9dbfddf..7aa41b353d94 100644 --- a/sdk/ai/azure-ai-projects/api.metadata.yml +++ b/sdk/ai/azure-ai-projects/api.metadata.yml @@ -1,4 +1,4 @@ -apiHash: 7dadb152e4753a2fe41a0e92a5e2574a3334d5f5193f88d37381fd4977217393 +apiHash: 91542f8590117469c0192049cb73d67f18e1faf40f8ad682010ba9c0700b39bf packageVersion: 2.11.0 parserVersion: 0.3.31 pythonVersion: 3.12.4 diff --git a/sdk/ai/azure-ai-projects/apiview-properties.json b/sdk/ai/azure-ai-projects/apiview-properties.json index bcd5477c98c4..5ab2cff2c6bf 100644 --- a/sdk/ai/azure-ai-projects/apiview-properties.json +++ b/sdk/ai/azure-ai-projects/apiview-properties.json @@ -34,20 +34,18 @@ "azure.ai.projects.models.AgentInsightHighlightedTrace": "Azure.AI.Projects.AgentInsightHighlightedTrace", "azure.ai.projects.models.AgentInsightLinkedTrace": "Azure.AI.Projects.AgentInsightLinkedTrace", "azure.ai.projects.models.AgentInsightMonitor": "Azure.AI.Projects.AgentInsightMonitor", - "azure.ai.projects.models.AgentInsightMonitorCreate": "Azure.AI.Projects.AgentInsightMonitorCreate", "azure.ai.projects.models.AgentInsightMonitorListItem": "Azure.AI.Projects.AgentInsightMonitorListItem", - "azure.ai.projects.models.AgentInsightMonitorUpdate": "Azure.AI.Projects.AgentInsightMonitorUpdate", + "azure.ai.projects.models.AgentInsightPriorities": "Azure.AI.Projects.AgentInsightPriorities", + "azure.ai.projects.models.AgentInsightPrioritiesRead": "Azure.AI.Projects.AgentInsightPrioritiesRead", "azure.ai.projects.models.AgentInsightProposedFix": "Azure.AI.Projects.AgentInsightProposedFix", "azure.ai.projects.models.AgentInsightProposedFixChange": "Azure.AI.Projects.AgentInsightProposedFixChange", "azure.ai.projects.models.AgentInsightRecommendedAction": "Azure.AI.Projects.AgentInsightRecommendedAction", "azure.ai.projects.models.AgentInsightRun": "Azure.AI.Projects.AgentInsightRun", - "azure.ai.projects.models.AgentInsightRunCreate": "Azure.AI.Projects.AgentInsightRunCreate", + "azure.ai.projects.models.AgentInsightRunInputs": "Azure.AI.Projects.AgentInsightRunInputs", "azure.ai.projects.models.AgentInsightRunResult": "Azure.AI.Projects.AgentInsightRunResult", - "azure.ai.projects.models.AgentInsightsOverview": "Azure.AI.Projects.AgentInsightsOverview", - "azure.ai.projects.models.AgentInsightsOverviewOverride": "Azure.AI.Projects.AgentInsightsOverviewOverride", + "azure.ai.projects.models.AgentInsightSummary": "Azure.AI.Projects.AgentInsightSummary", "azure.ai.projects.models.AgentInsightSuspension": "Azure.AI.Projects.AgentInsightSuspension", "azure.ai.projects.models.AgentInsightTokenUsage": "Azure.AI.Projects.AgentInsightTokenUsage", - "azure.ai.projects.models.AgentInsightUpdate": "Azure.AI.Projects.AgentInsightUpdate", "azure.ai.projects.models.AgentObjectVersions": "Azure.AI.Projects.AgentObject.versions.anonymous", "azure.ai.projects.models.AgentOptimizationCandidateOutput": "Azure.AI.Projects.AgentOptimizationCandidateOutput", "azure.ai.projects.models.AgentOptimizationAgentCandidateOutput": "Azure.AI.Projects.AgentOptimizationAgentCandidateOutput", @@ -196,7 +194,7 @@ "azure.ai.projects.models.DatasetCredential": "Azure.AI.Projects.AssetCredentialResponse", "azure.ai.projects.models.DatasetDataGenerationJobOutput": "Azure.AI.Projects.DatasetDataGenerationJobOutput", "azure.ai.projects.models.DatasetEvaluatorGenerationJobSource": "Azure.AI.Projects.DatasetEvaluatorGenerationJobSource", - "azure.ai.projects.models.DatasetReference": "Azure.AI.Projects.VersionedDatasetReference", + "azure.ai.projects.models.DatasetReference": "Azure.AI.Projects.DatasetReference", "azure.ai.projects.models.DatasetVersion": "Azure.AI.Projects.DatasetVersion", "azure.ai.projects.models.DecisionResponse": "OpenAI.DecisionResponse", "azure.ai.projects.models.DeleteAgentResponse": "Azure.AI.Projects.DeleteAgentResponse", @@ -690,7 +688,6 @@ "azure.ai.projects.models.TelephonyCallTiming": "Azure.AI.Projects.TelephonyCallTiming", "azure.ai.projects.models.TelephonyCallTrace": "Azure.AI.Projects.TelephonyCallTrace", "azure.ai.projects.models.TelephonyCampaign": "Azure.AI.Projects.TelephonyCampaign", - "azure.ai.projects.models.TelephonyCampaignDatasetReference": "Azure.AI.Projects.DatasetReference", "azure.ai.projects.models.TelephonyCampaignOperation": "Azure.AI.Projects.TelephonyCampaignOperation", "azure.ai.projects.models.TelephonyCampaignProgress": "Azure.AI.Projects.TelephonyCampaignProgress", "azure.ai.projects.models.TelephonyCampaignValidationError": "Azure.AI.Projects.TelephonyCampaignValidationError", @@ -751,6 +748,7 @@ "azure.ai.projects.models.UserConversationSimulationTestCase": "Azure.AI.Projects.UserConversationSimulationTestCase", "azure.ai.projects.models.UserConversationSimulationUserBehaviorConfiguration": "Azure.AI.Projects.UserConversationSimulationUserBehaviorConfiguration", "azure.ai.projects.models.UserProfileMemoryItem": "Azure.AI.Projects.UserProfileMemoryItem", + "azure.ai.projects.models.VersionedDatasetReference": "Azure.AI.Projects.VersionedDatasetReference", "azure.ai.projects.models.VersionIndicator": "Azure.AI.Projects.VersionIndicator", "azure.ai.projects.models.VersionRefIndicator": "Azure.AI.Projects.VersionRefIndicator", "azure.ai.projects.models.VersionSelector": "Azure.AI.Projects.VersionSelector", @@ -1017,12 +1015,6 @@ "azure.ai.projects.models.AgentEndpointAuthorizationSchemeType": "Azure.AI.Projects.AgentEndpointAuthorizationSchemeType", "azure.ai.projects.models.PublishApprovalStatus": "Azure.AI.Projects.PublishApprovalStatus", "azure.ai.projects.models.DigitalWorkerType": "Azure.AI.Projects.DigitalWorkerType", - "azure.ai.projects.models.AgentInsightOverviewSource": "Azure.AI.Projects.AgentInsightOverviewSource", - "azure.ai.projects.models.AgentInsightRunTrigger": "Azure.AI.Projects.AgentInsightRunTrigger", - "azure.ai.projects.models.AgentInsightSeverity": "Azure.AI.Projects.AgentInsightSeverity", - "azure.ai.projects.models.AgentInsightStatus": "Azure.AI.Projects.AgentInsightStatus", - "azure.ai.projects.models.AgentInsightProposedFixKind": "Azure.AI.Projects.AgentInsightProposedFixKind", - "azure.ai.projects.models.AgentInsightPromptSurface": "Azure.AI.Projects.AgentInsightPromptSurface", "azure.ai.projects.models.EvaluationTaxonomyInputType": "Azure.AI.Projects.EvaluationTaxonomyInputType", "azure.ai.projects.models.RiskCategory": "Azure.AI.Projects.RiskCategory", "azure.ai.projects.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType", @@ -1077,6 +1069,11 @@ "azure.ai.projects.models.SimpleQnAFineTuningQuestionType": "Azure.AI.Projects.SimpleQnAFineTuningQuestionType", "azure.ai.projects.models.DataGenerationJobScenario": "Azure.AI.Projects.DataGenerationJobScenario", "azure.ai.projects.models.DataGenerationJobOutputWriteMode": "Azure.AI.Projects.DataGenerationJobOutputWriteMode", + "azure.ai.projects.models.AgentInsightRunTrigger": "Azure.AI.Projects.AgentInsightRunTrigger", + "azure.ai.projects.models.AgentInsightSeverity": "Azure.AI.Projects.AgentInsightSeverity", + "azure.ai.projects.models.AgentInsightStatus": "Azure.AI.Projects.AgentInsightStatus", + "azure.ai.projects.models.AgentInsightProposedFixKind": "Azure.AI.Projects.AgentInsightProposedFixKind", + "azure.ai.projects.models.AgentInsightPromptSurface": "Azure.AI.Projects.AgentInsightPromptSurface", "azure.ai.projects.models.ConnectionType": "Azure.AI.Projects.ConnectionType", "azure.ai.projects.models.CredentialType": "Azure.AI.Projects.CredentialType", "azure.ai.projects.models.DeploymentType": "Azure.AI.Projects.DeploymentType", @@ -1224,6 +1221,32 @@ "azure.ai.projects.aio.operations.DatasetsOperations.cancel_generation_job": "Azure.AI.Projects.DataGenerationJobs.cancel", "azure.ai.projects.operations.DatasetsOperations.delete_generation_job": "Azure.AI.Projects.DataGenerationJobs.delete", "azure.ai.projects.aio.operations.DatasetsOperations.delete_generation_job": "Azure.AI.Projects.DataGenerationJobs.delete", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.list": "Azure.AI.Projects.AgentInsightMonitors.list", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.list": "Azure.AI.Projects.AgentInsightMonitors.list", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.create": "Azure.AI.Projects.AgentInsightMonitors.create", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.create": "Azure.AI.Projects.AgentInsightMonitors.create", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.get": "Azure.AI.Projects.AgentInsightMonitors.get", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.get": "Azure.AI.Projects.AgentInsightMonitors.get", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.delete": "Azure.AI.Projects.AgentInsightMonitors.delete", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.delete": "Azure.AI.Projects.AgentInsightMonitors.delete", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.update": "Azure.AI.Projects.AgentInsightMonitors.update", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.update": "Azure.AI.Projects.AgentInsightMonitors.update", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.reset": "Azure.AI.Projects.AgentInsightMonitors.reset", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.reset": "Azure.AI.Projects.AgentInsightMonitors.reset", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.begin_create_run": "Azure.AI.Projects.AgentInsightMonitors.createRun", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.begin_create_run": "Azure.AI.Projects.AgentInsightMonitors.createRun", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.list_runs": "Azure.AI.Projects.AgentInsightMonitors.listRuns", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.list_runs": "Azure.AI.Projects.AgentInsightMonitors.listRuns", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.get_run": "Azure.AI.Projects.AgentInsightMonitors.getRun", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.get_run": "Azure.AI.Projects.AgentInsightMonitors.getRun", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.cancel_run": "Azure.AI.Projects.AgentInsightMonitors.cancelRun", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.cancel_run": "Azure.AI.Projects.AgentInsightMonitors.cancelRun", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.list_insights": "Azure.AI.Projects.AgentInsightMonitors.listInsights", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.list_insights": "Azure.AI.Projects.AgentInsightMonitors.listInsights", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.get_insight": "Azure.AI.Projects.AgentInsightMonitors.getInsight", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.get_insight": "Azure.AI.Projects.AgentInsightMonitors.getInsight", + "azure.ai.projects.operations.AgentInsightMonitorsOperations.update_insight": "Azure.AI.Projects.AgentInsightMonitors.updateInsight", + "azure.ai.projects.aio.operations.AgentInsightMonitorsOperations.update_insight": "Azure.AI.Projects.AgentInsightMonitors.updateInsight", "azure.ai.projects.operations.ConnectionsOperations.list": "Azure.AI.Projects.Connections.list", "azure.ai.projects.aio.operations.ConnectionsOperations.list": "Azure.AI.Projects.Connections.list", "azure.ai.projects.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", @@ -1281,5 +1304,5 @@ "azure.ai.projects.operations.ToolboxesOperations.delete_version": "Azure.AI.Projects.Toolboxes.deleteToolboxVersion", "azure.ai.projects.aio.operations.ToolboxesOperations.delete_version": "Azure.AI.Projects.Toolboxes.deleteToolboxVersion" }, - "CrossLanguageVersion": "3247452fbac8" + "CrossLanguageVersion": "ec08eba03394" } \ No newline at end of file diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_client.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_client.py index d8f873a816da..2e3544a0ea98 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_client.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_client.py @@ -17,6 +17,7 @@ from ._configuration import AIProjectClientConfiguration from ._utils.serialization import Deserializer, Serializer from .operations import ( + AgentInsightMonitorsOperations, AgentsOperations, BetaOperations, ConnectionsOperations, @@ -48,6 +49,8 @@ class AIProjectClient: # pylint: disable=too-many-instance-attributes,docstring :vartype evaluation_rules: azure.ai.projects.operations.EvaluationRulesOperations :ivar datasets: DatasetsOperations operations :vartype datasets: azure.ai.projects.operations.DatasetsOperations + :ivar agent_insight_monitors: AgentInsightMonitorsOperations operations + :vartype agent_insight_monitors: azure.ai.projects.operations.AgentInsightMonitorsOperations :ivar connections: ConnectionsOperations operations :vartype connections: azure.ai.projects.operations.ConnectionsOperations :ivar deployments: DeploymentsOperations operations @@ -113,6 +116,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.agent_insight_monitors = AgentInsightMonitorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py index 94863905f720..b7266293476b 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py @@ -161,6 +161,8 @@ class AIProjectClient(AIProjectClientGenerated): # pylint: disable=too-many-ins :vartype beta: azure.ai.projects.operations.BetaOperations :ivar agents: AgentsOperations operations :vartype agents: azure.ai.projects.operations.AgentsOperations + :ivar agent_insight_monitors: AgentInsightMonitorsOperations operations + :vartype agent_insight_monitors: azure.ai.projects.operations.AgentInsightMonitorsOperations :ivar evaluation_rules: EvaluationRulesOperations operations :vartype evaluation_rules: azure.ai.projects.operations.EvaluationRulesOperations :ivar connections: ConnectionsOperations operations diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_client.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_client.py index 117a175f61a6..0a71114fd4ed 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_client.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_client.py @@ -17,6 +17,7 @@ from .._utils.serialization import Deserializer, Serializer from ._configuration import AIProjectClientConfiguration from .operations import ( + AgentInsightMonitorsOperations, AgentsOperations, BetaOperations, ConnectionsOperations, @@ -48,6 +49,9 @@ class AIProjectClient: # pylint: disable=too-many-instance-attributes,docstring :vartype evaluation_rules: azure.ai.projects.aio.operations.EvaluationRulesOperations :ivar datasets: DatasetsOperations operations :vartype datasets: azure.ai.projects.aio.operations.DatasetsOperations + :ivar agent_insight_monitors: AgentInsightMonitorsOperations operations + :vartype agent_insight_monitors: + azure.ai.projects.aio.operations.AgentInsightMonitorsOperations :ivar connections: ConnectionsOperations operations :vartype connections: azure.ai.projects.aio.operations.ConnectionsOperations :ivar deployments: DeploymentsOperations operations @@ -113,6 +117,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) + self.agent_insight_monitors = AgentInsightMonitorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_patch.py index 3441904edb28..be4333581c32 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_patch.py @@ -41,6 +41,8 @@ class AIProjectClient(AIProjectClientGenerated): # pylint: disable=too-many-ins :vartype beta: azure.ai.projects.aio.operations.BetaOperations :ivar agents: AgentsOperations operations :vartype agents: azure.ai.projects.aio.operations.AgentsOperations + :ivar agent_insight_monitors: AgentInsightMonitorsOperations operations + :vartype agent_insight_monitors: azure.ai.projects.aio.operations.AgentInsightMonitorsOperations :ivar evaluation_rules: EvaluationRulesOperations operations :vartype evaluation_rules: azure.ai.projects.aio.operations.EvaluationRulesOperations :ivar connections: ConnectionsOperations operations diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/__init__.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/__init__.py index ae40253e5f4f..de2d79fbb7cd 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/__init__.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/__init__.py @@ -16,6 +16,7 @@ from ._operations import AgentsOperations # type: ignore from ._operations import EvaluationRulesOperations # type: ignore from ._operations import DatasetsOperations # type: ignore +from ._operations import AgentInsightMonitorsOperations # type: ignore from ._operations import ConnectionsOperations # type: ignore from ._operations import DeploymentsOperations # type: ignore from ._operations import IndexesOperations # type: ignore @@ -31,6 +32,7 @@ "AgentsOperations", "EvaluationRulesOperations", "DatasetsOperations", + "AgentInsightMonitorsOperations", "ConnectionsOperations", "DeploymentsOperations", "IndexesOperations", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py index 7d6532c59514..03a10ed68296 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py @@ -39,6 +39,19 @@ from ..._utils.serialization import Deserializer, Serializer from ..._utils.utils import prepare_multipart_form_data from ...operations._operations import ( + build_agent_insight_monitors_cancel_run_request, + build_agent_insight_monitors_create_request, + build_agent_insight_monitors_create_run_request, + build_agent_insight_monitors_delete_request, + build_agent_insight_monitors_get_insight_request, + build_agent_insight_monitors_get_request, + build_agent_insight_monitors_get_run_request, + build_agent_insight_monitors_list_insights_request, + build_agent_insight_monitors_list_request, + build_agent_insight_monitors_list_runs_request, + build_agent_insight_monitors_reset_request, + build_agent_insight_monitors_update_insight_request, + build_agent_insight_monitors_update_request, build_agents_cancel_optimization_job_request, build_agents_create_optimization_job_request, build_agents_create_session_request, @@ -74,19 +87,6 @@ build_agents_stop_session_request, build_agents_update_details_request, build_agents_upload_session_file_request, - build_beta_agent_insight_monitors_cancel_run_request, - build_beta_agent_insight_monitors_create_request, - build_beta_agent_insight_monitors_create_run_request, - build_beta_agent_insight_monitors_delete_request, - build_beta_agent_insight_monitors_get_insight_request, - build_beta_agent_insight_monitors_get_request, - build_beta_agent_insight_monitors_get_run_request, - build_beta_agent_insight_monitors_list_insights_request, - build_beta_agent_insight_monitors_list_request, - build_beta_agent_insight_monitors_list_runs_request, - build_beta_agent_insight_monitors_reset_request, - build_beta_agent_insight_monitors_update_insight_request, - build_beta_agent_insight_monitors_update_request, build_beta_agents_create_from_prompt_request, build_beta_evaluation_taxonomies_create_request, build_beta_evaluation_taxonomies_delete_request, @@ -270,9 +270,6 @@ def __init__(self, *args, **kwargs) -> None: self.voice_agents = BetaVoiceAgentsOperations(self._client, self._config, self._serialize, self._deserialize) self.agents = BetaAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -5990,14 +5987,14 @@ async def delete_generation_job(self, job_id: str, **kwargs: Any) -> None: return cls(pipeline_response, None, {}) # type: ignore -class ConnectionsOperations: # pylint: disable=docstring-missing-param +class AgentInsightMonitorsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`connections` attribute. + :attr:`agent_insight_monitors` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -6007,17 +6004,195 @@ def __init__(self, *args, **kwargs) -> None: self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def _get(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection. + @distributed_trace + def list( + self, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + agent_name: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.AgentInsightMonitorListItem"]: + """List Agent Insights monitors, optionally filtered by agent name. - Retrieves the specified connection and its configuration details without including credential - values. + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword agent_name: Filter monitors by agent name. Default value is None. + :paramtype agent_name: str + :return: An iterator like instance of AgentInsightMonitorListItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsightMonitorListItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + cls: ClsType[List[_models.AgentInsightMonitorListItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_agent_insight_monitors_list_request( + after=_continuation_token, + before=before, + limit=limit, + order=order, + agent_name=agent_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentInsightMonitorListItem], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @overload + async def create( + self, + *, + agent_name: str, + model_deployment_name: str, + content_type: str = "application/json", + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :keyword agent_name: The agent this monitor should analyze. Required. + :paramtype agent_name: str + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Required. + :paramtype model_deployment_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword enabled: Whether scheduled insight generation should be armed. Defaults to false. + Default value is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Defaults to 6. + Default value is None. + :paramtype run_interval_hours: float + :keyword priorities: Analysis priorities for the monitor. Default value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + agent_name: str = _Unset, + model_deployment_name: str = _Unset, + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword agent_name: The agent this monitor should analyze. Required. + :paramtype agent_name: str + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Required. + :paramtype model_deployment_name: str + :keyword enabled: Whether scheduled insight generation should be armed. Defaults to false. + Default value is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Defaults to 6. + Default value is None. + :paramtype run_interval_hours: float + :keyword priorities: Analysis priorities for the monitor. Default value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6028,14 +6203,36 @@ async def _get(self, name: str, **kwargs: Any) -> _models.Connection: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_connections_get_request( - name=name, + if body is _Unset: + if agent_name is _Unset: + raise TypeError("missing required argument: agent_name") + if model_deployment_name is _Unset: + raise TypeError("missing required argument: model_deployment_name") + body = { + "agent_name": agent_name, + "enabled": enabled, + "model_deployment_name": model_deployment_name, + "priorities": priorities, + "run_interval_hours": run_interval_hours, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_insight_monitors_create_request( + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -6052,24 +6249,26 @@ async def _get(self, name: str, **kwargs: Any) -> _models.Connection: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -6077,15 +6276,13 @@ async def _get(self, name: str, **kwargs: Any) -> _models.Connection: return deserialized # type: ignore @distributed_trace_async - async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection with credentials. - - Retrieves the specified connection together with its credential values. + async def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: + """Get an Agent Insights monitor. - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6099,10 +6296,10 @@ async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Conne _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_connections_get_with_credentials_request( - name=name, + _request = build_agent_insight_monitors_get_request( + monitor_id=monitor_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6127,53 +6324,32 @@ async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Conne except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( - self, - *, - connection_type: Optional[Union[str, _models.ConnectionType]] = None, - default_connection: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Connection"]: - """List connections. + @distributed_trace_async + async def delete(self, monitor_id: str, **kwargs: Any) -> None: + """Delete an Agent Insights monitor and all of its runs, insights, and state. - Returns the connections available in the current project, optionally filtered by type or - default status. - - :keyword connection_type: Lists connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", "RemoteTool_Preview", "OpenAPI", and "RemoteA2A". - Default value is None. - :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType - :keyword default_connection: Lists connections that are default connections. Default value is - None. - :paramtype default_connection: bool - :return: An iterator like instance of Connection - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Connection] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6182,103 +6358,146 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[None] = kwargs.pop("cls", None) - return _request + _request = build_agent_insight_monitors_delete_request( + monitor_id=monitor_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Connection], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return pipeline_response + @overload + async def update( + self, + monitor_id: str, + *, + content_type: str = "application/merge-patch+json", + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + model_deployment_name: Optional[str] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - return AsyncItemPaged(get_next, extract_data) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword enabled: Whether scheduled insight generation is armed for the monitor. Default value + is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Default value + is None. + :paramtype run_interval_hours: float + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Default value is None. + :paramtype model_deployment_name: str + :keyword priorities: Replaces all priorities. Omit to preserve them; null clears them. Default + value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def update( + self, monitor_id: str, body: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. -class DeploymentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`deployments` attribute. - """ + @overload + async def update( + self, monitor_id: str, body: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _models.Deployment: - """Get a deployment. - - Retrieves a deployed model. + async def update( + self, + monitor_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + model_deployment_name: Optional[str] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - :param name: Name of the deployment. Required. - :type name: str - :return: Deployment. The Deployment is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Deployment + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword enabled: Whether scheduled insight generation is armed for the monitor. Default value + is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Default value + is None. + :paramtype run_interval_hours: float + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Default value is None. + :paramtype model_deployment_name: str + :keyword priorities: Replaces all priorities. Omit to preserve them; null clears them. Default + value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6289,14 +6508,32 @@ async def get(self, name: str, **kwargs: Any) -> _models.Deployment: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_deployments_get_request( - name=name, + if body is _Unset: + body = { + "enabled": enabled, + "model_deployment_name": model_deployment_name, + "priorities": priorities, + "run_interval_hours": run_interval_hours, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_insight_monitors_update_request( + monitor_id=monitor_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -6320,54 +6557,32 @@ async def get(self, name: str, **kwargs: Any) -> _models.Deployment: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Deployment, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( - self, - *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Deployment"]: - """List deployments. - - Returns the deployed models available in the current project, optionally filtered by publisher, - model name, or deployment type. + @distributed_trace_async + async def reset(self, monitor_id: str, **kwargs: Any) -> None: + """Reset an Agent Insights monitor's generated summary, checkpoint, and active insight state. - :keyword model_publisher: Model publisher to filter models by. Default value is None. - :paramtype model_publisher: str - :keyword model_name: Model name (the publisher specific name) to filter models by. Default - value is None. - :paramtype model_name: str - :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value - is None. - :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType - :return: An iterator like instance of Deployment - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Deployment] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6376,262 +6591,369 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[None] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request = build_agent_insight_monitors_reset_request( + monitor_id=monitor_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Deployment], - deserialized.get("value", []), + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + raise HttpResponseError(response=response, model=error) - async def get_next(next_link=None): - _request = prepare_request(next_link) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + async def _create_run_initial( + self, + monitor_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + operation_id: Optional[str] = None, + lookback_hours: Optional[float] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - return pipeline_response + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - return AsyncItemPaged(get_next, extract_data) + if body is _Unset: + body = {"lookback_hours": lookback_hours} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _request = build_agent_insight_monitors_create_run_request( + monitor_id=monitor_id, + operation_id=operation_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) -class IndexesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`indexes` attribute. - """ + response = pipeline_response.http_response - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + if response.status_code not in [201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) - @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: - """List versions. + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - List all versions of the given Index. + deserialized = response.iter_bytes() if _decompress else response.iter_raw() - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of Index - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_create_run( + self, + monitor_id: str, + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + lookback_hours: Optional[float] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword lookback_hours: Optional finite positive number of hours of trace history to analyze, + up to 2,160. Defaults to 168. Default value is None. + :paramtype lookback_hours: float + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + @overload + async def begin_create_run( + self, + monitor_id: str, + body: JSON, + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: JSON + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @overload + async def begin_create_run( + self, + monitor_id: str, + body: IO[bytes], + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - _request = build_indexes_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + @distributed_trace_async + async def begin_create_run( + self, + monitor_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + operation_id: Optional[str] = None, + lookback_hours: Optional[float] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - return _request + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword lookback_hours: Optional finite positive number of hours of trace history to analyze, + up to 2,160. Defaults to 168. Default value is None. + :paramtype lookback_hours: float + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightRunResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_run_initial( + monitor_id=monitor_id, + body=body, + operation_id=operation_id, + lookback_hours=lookback_hours, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def get_long_running_output(pipeline_response): + response_headers = {} response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized - return pipeline_response + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } - return AsyncItemPaged(get_next, extract_data) + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AgentInsightRunResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AgentInsightRunResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: - """List latest versions. - - List the latest version of each Index. + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + status: Optional[Union[str, _models.JobStatus]] = None, + trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.AgentInsightRun"]: + """List Agent Insights runs for a monitor. - :return: An iterator like instance of Index - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword status: Filter runs by status. Known values are: "queued", "in_progress", "succeeded", + "failed", and "cancelled". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.JobStatus + :keyword trigger: Filter runs by trigger. Known values are: "on_demand" and "scheduled". + Default value is None. + :paramtype trigger: str or ~azure.ai.projects.models.AgentInsightRunTrigger + :return: An iterator like instance of AgentInsightRun + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsightRun] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsightRun]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_agent_insight_monitors_list_runs_request( + monitor_id=monitor_id, + after=_continuation_token, + before=before, + limit=limit, + order=order, + status=status, + trigger=trigger, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), + List[_models.AgentInsightRun], + deserialized.get("data", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - async def get_next(next_link=None): - _request = prepare_request(next_link) + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -6641,25 +6963,26 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: - """Get a version. - - Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. + async def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Get an Agent Insights run. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to retrieve. Required. - :type version: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6673,11 +6996,11 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Index] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_indexes_get_request( - name=name, - version=version, + _request = build_agent_insight_monitors_get_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6702,12 +7025,16 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6715,18 +7042,15 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: return deserialized # type: ignore @distributed_trace_async - async def delete(self, name: str, version: str, **kwargs: Any) -> None: - """Delete a version. - - Delete the specific version of the Index. The service returns 204 No Content if the Index was - deleted successfully or if the Index does not exist. + async def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Cancel an Agent Insights run. - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the Index to delete. Required. - :type version: str - :return: None - :rtype: None + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6740,158 +7064,12 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_indexes_delete_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def create_or_update( - self, - name: str, - version: str, - index: _models.Index, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: ~azure.ai.projects.models.Index - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - name: str, - version: str, - index: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Is one of the following types: Index, JSON, - IO[bytes] Required. - :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Index] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _content = None - if isinstance(index, (IOBase, bytes)): - _content = index - else: - _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_indexes_create_or_update_request( - name=name, - version=version, - content_type=content_type, + _request = build_agent_insight_monitors_cancel_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -6908,73 +7086,74 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class EvaluatorsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`evaluators` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_versions( + def list_insights( self, - name: str, + monitor_id: str, *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + before: Optional[str] = None, limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + categories: Optional[List[str]] = None, + severities: Optional[List[Union[str, _models.AgentInsightSeverity]]] = None, + statuses: Optional[List[Union[str, _models.AgentInsightStatus]]] = None, + include_details: Optional[bool] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.EvaluatorVersion"]: - """List evaluator versions. - - Returns the available versions for the specified evaluator. + ) -> AsyncItemPaged["_models.AgentInsight"]: + """List current insights for a monitor. Filter types combine with AND; values within each list + combine with OR. - :param name: The name of the resource. Required. - :type name: str - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorVersion] + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword categories: Match any listed category. Commas separate identifiers; identifiers + containing commas cannot be filtered individually. Default value is None. + :paramtype categories: list[str] + :keyword severities: Match any listed severity. Default value is None. + :paramtype severities: list[str or ~azure.ai.projects.models.AgentInsightSeverity] + :keyword statuses: Match any listed status. Default value is None. + :paramtype statuses: list[str or ~azure.ai.projects.models.AgentInsightStatus] + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: An iterator like instance of AgentInsight + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsight] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6984,61 +7163,40 @@ def list_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_evaluators_list_versions_request( - name=name, - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_agent_insight_monitors_list_insights_request( + monitor_id=monitor_id, + after=_continuation_token, + before=before, + limit=limit, + order=order, + categories=categories, + severities=severities, + statuses=statuses, + include_details=include_details, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.EvaluatorVersion], - deserialized.get("value", []), + List[_models.AgentInsight], + deserialized.get("data", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - async def get_next(next_link=None): - _request = prepare_request(next_link) + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -7048,40 +7206,33 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list( - self, - *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.EvaluatorVersion"]: - """List latest evaluator versions. - - Lists the latest version of each evaluator. + @distributed_trace_async + async def get_insight( + self, monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any + ) -> _models.AgentInsight: + """Get a full insight for an Agent Insights monitor. - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorVersion] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7090,87 +7241,157 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_evaluators_list_request( - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request = build_agent_insight_monitors_get_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, + include_details=include_details, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) - return _request + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentInsight, response.json()) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.EvaluatorVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - async def get_next(next_link=None): - _request = prepare_request(next_link) + return deserialized # type: ignore - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + *, + content_type: str = "application/merge-patch+json", + status: Optional[Union[str, _models.AgentInsightStatus]] = None, + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword status: The lifecycle status to apply to the insight. Known values are: "active", + "resolved", and "ignored". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight + :raises ~azure.core.exceptions.HttpResponseError: + """ - return pipeline_response + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - return AsyncItemPaged(get_next, extract_data) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace_async - async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: - """Get an evaluator version. + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + body: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - Retrieves the specified evaluator version, returning 404 if it does not exist. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the EvaluatorVersion to retrieve. Required. - :type version: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + @distributed_trace_async + async def update_insight( + self, + monitor_id: str, + insight_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + status: Optional[Union[str, _models.AgentInsightStatus]] = None, + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword status: The lifecycle status to apply to the insight. Known values are: "active", + "resolved", and "ignored". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7181,15 +7402,28 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.E } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - _request = build_evaluators_get_version_request( - name=name, - version=version, + if body is _Unset: + body = {"status": status} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_insight_monitors_update_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -7213,30 +7447,51 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.E except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.AgentInsight, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class ConnectionsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async - async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: - """Delete an evaluator version. + async def _get(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection. - Removes the specified evaluator version. Returns 204 whether the version existed or not. + Retrieves the specified connection and its configuration details without including credential + values. - :param name: The name of the resource. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param version: The version of the EvaluatorVersion to delete. Required. - :type version: str - :return: None - :rtype: None + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7250,11 +7505,10 @@ async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_evaluators_delete_version_request( + _request = build_connections_get_request( name=name, - version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7264,100 +7518,48 @@ async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def create_version( - self, - name: str, - evaluator_version: _models.EvaluatorVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. - - Creates a new evaluator version with an auto-incremented version identifier. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_version( - self, name: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. - - Creates a new evaluator version with an auto-incremented version identifier. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_version( - self, name: str, evaluator_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) - Creates a new evaluator version with an auto-incremented version identifier. + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Connection, response.json()) - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace_async - async def create_version( - self, name: str, evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. + async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection with credentials. - Creates a new evaluator version with an auto-incremented version identifier. + Retrieves the specified connection together with its credential values. - :param name: The name of the resource. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param evaluator_version: Is one of the following types: EvaluatorVersion, JSON, IO[bytes] - Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7368,24 +7570,14 @@ async def create_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_evaluators_create_version_request( + _request = build_connections_get_with_credentials_request( name=name, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -7402,7 +7594,7 @@ async def create_version( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket @@ -7411,115 +7603,156 @@ async def create_version( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.Connection, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def update_version( + @distributed_trace + def list( self, - name: str, - version: str, - evaluator_version: _models.EvaluatorVersion, *, - content_type: str = "application/json", + connection_type: Optional[Union[str, _models.ConnectionType]] = None, + default_connection: Optional[bool] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + ) -> AsyncItemPaged["_models.Connection"]: + """List connections. - Updates the specified evaluator version in place. + Returns the connections available in the current project, optionally filtered by type or + default status. - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :keyword connection_type: Lists connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", "RemoteTool_Preview", "OpenAPI", and "RemoteA2A". + Default value is None. + :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType + :keyword default_connection: Lists connections that are default connections. Default value is + None. + :paramtype default_connection: bool + :return: An iterator like instance of Connection + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Connection] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - async def update_version( - self, name: str, version: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) - Updates the specified evaluator version in place. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(next_link=None): + if not next_link: - @overload - async def update_version( - self, - name: str, - version: str, - evaluator_version: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + _request = build_connections_list_request( + connection_type=connection_type, + default_connection=default_connection, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Updates the specified evaluator version in place. + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Connection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DeploymentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def update_version( - self, - name: str, - version: str, - evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + async def get(self, name: str, **kwargs: Any) -> _models.Deployment: + """Get a deployment. - Updates the specified evaluator version in place. + Retrieves a deployed model. - :param name: The name of the resource. Required. + :param name: Name of the deployment. Required. :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Is one of the following types: EvaluatorVersion, - JSON, IO[bytes] Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7530,25 +7763,14 @@ async def update_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) - _request = build_evaluators_update_version_request( + _request = build_deployments_get_request( name=name, - version=version, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -7574,261 +7796,165 @@ async def update_version( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - async def _create_generation_job_initial( - self, - job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], - *, - operation_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(job, (IOBase, bytes)): - _content = job - else: - _content = json.dumps(job, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_evaluators_create_generation_job_request( - operation_id=operation_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = _deserialize(_models.Deployment, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - async def begin_create_generation_job( + @distributed_trace + def list( self, - job: _models.EvaluatorGenerationInputs, *, - operation_id: Optional[str] = None, - content_type: str = "application/json", + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[Union[str, _models.DeploymentType]] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. - - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. - - :param job: The evaluator generation job inputs to create. Required. - :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def begin_create_generation_job( - self, job: JSON, *, operation_id: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. + ) -> AsyncItemPaged["_models.Deployment"]: + """List deployments. - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. + Returns the deployed models available in the current project, optionally filtered by publisher, + model name, or deployment type. - :param job: The evaluator generation job inputs to create. Required. - :type job: JSON - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] + :keyword model_publisher: Model publisher to filter models by. Default value is None. + :paramtype model_publisher: str + :keyword model_name: Model name (the publisher specific name) to filter models by. Default + value is None. + :paramtype model_name: str + :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value + is None. + :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType + :return: An iterator like instance of Deployment + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Deployment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - async def begin_create_generation_job( - self, - job: IO[bytes], - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param job: The evaluator generation job inputs to create. Required. - :type job: IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(next_link=None): + if not next_link: - @distributed_trace_async - async def begin_create_generation_job( - self, - job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], - *, - operation_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncLROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. + _request = build_deployments_list_request( + model_publisher=model_publisher, + model_name=model_name, + deployment_type=deployment_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param job: The evaluator generation job inputs to create. Is one of the following types: - EvaluatorGenerationInputs, JSON, IO[bytes] Required. - :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs or JSON or IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + return _request - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_generation_job_initial( - job=job, - operation_id=operation_id, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Deployment], + deserialized.get("value", []), ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response = pipeline_response.http_response - deserialized = _deserialize(_models.EvaluatorVersion, response.json().get("result", {})) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + return pipeline_response - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.EvaluatorVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.EvaluatorVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def get_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: - """Get an evaluator generation job. - Gets the details of an evaluator generation job by its ID. +class IndexesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param job_id: The ID of the job. Required. - :type job_id: str - :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`indexes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: + """List versions. + + List all versions of the given Index. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of Index + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7837,94 +7963,88 @@ async def get_generation_job(self, job_id: str, **kwargs: Any) -> _models.Evalua } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_evaluators_get_generation_job_request( - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request = build_indexes_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - response = pipeline_response.http_response + return _request - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Index], + deserialized.get("value", []), ) - raise HttpResponseError(response=response, model=error) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - response_headers = {} - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + async def get_next(next_link=None): + _request = prepare_request(next_link) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - return deserialized # type: ignore + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_generation_jobs( - self, - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.EvaluatorGenerationJob"]: - """List evaluator generation jobs. + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: + """List latest versions. - Returns a list of evaluator generation jobs. The List API has up to a few seconds of - propagation delay, so a recently created job may not appear immediately; use the Get evaluator - generation job API with the job ID to retrieve a specific job without delay. + List the latest version of each Index. - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of EvaluatorGenerationJob - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorGenerationJob] + :return: An iterator like instance of Index + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluatorGenerationJob]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7934,35 +8054,58 @@ def list_generation_jobs( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_evaluators_list_generation_jobs_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.EvaluatorGenerationJob], - deserialized.get("data", []), + List[_models.Index], + deserialized.get("value", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + async def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -7972,26 +8115,25 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: - """Cancel an evaluator generation job. + async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: + """Get a version. - Cancels an evaluator generation job by its ID. + Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. - :param job_id: The ID of the job to cancel. Required. - :type job_id: str - :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to retrieve. Required. + :type version: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8005,10 +8147,11 @@ async def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.Eva _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - _request = build_evaluators_cancel_generation_job_request( - job_id=job_id, + _request = build_indexes_get_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8033,16 +8176,12 @@ async def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.Eva except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8050,14 +8189,16 @@ async def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.Eva return deserialized # type: ignore @distributed_trace_async - async def delete_generation_job(self, job_id: str, **kwargs: Any) -> None: - """Delete an evaluator generation job. + async def delete(self, name: str, version: str, **kwargs: Any) -> None: + """Delete a version. - Deletes an evaluator generation job by its ID. Deletes the job record only; the generated - evaluator (if any) is preserved. + Delete the specific version of the Index. The service returns 204 No Content if the Index was + deleted successfully or if the Index does not exist. - :param job_id: The ID of the job to delete. Required. - :type job_id: str + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the Index to delete. Required. + :type version: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -8075,8 +8216,9 @@ async def delete_generation_job(self, job_id: str, **kwargs: Any) -> None: cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_evaluators_delete_generation_job_request( - job_id=job_id, + _request = build_indexes_delete_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8095,153 +8237,106 @@ async def delete_generation_job(self, job_id: str, **kwargs: Any) -> None: if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if cls: return cls(pipeline_response, None, {}) # type: ignore - -class ToolboxesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`toolboxes` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @overload - async def create_version( + async def create_or_update( self, name: str, + version: str, + index: _models.Index, *, - tools: List[_models.ToolboxTool], - content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + ) -> _models.Index: + """Create or update a version. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + Create a new or update an existing Index with the given version id. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + :param name: The name of the resource. Required. :type name: str - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: ~azure.ai.projects.models.Index :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is - None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_version( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + async def create_or_update( + self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.Index: + """Create or update a version. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + Create a new or update an existing Index with the given version id. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: JSON + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_version( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + async def create_or_update( + self, + name: str, + version: str, + index: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.Index: + """Create or update a version. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + Create a new or update an existing Index with the given version id. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: IO[bytes] + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async - async def create_version( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - tools: List[_models.ToolboxTool] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, - **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. - - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + @distributed_trace_async + async def create_or_update( + self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Index: + """Create or update a version. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is - None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Is one of the following types: Index, JSON, + IO[bytes] Required. + :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8256,28 +8351,18 @@ async def create_version( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - if body is _Unset: - if tools is _Unset: - raise TypeError("missing required argument: tools") - body = { - "description": description, - "metadata": metadata, - "policies": policies, - "skills": skills, - "tools": tools, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(index, (IOBase, bytes)): + _content = index else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_create_version_request( + _request = build_indexes_create_or_update_request( name=name, + version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -8297,131 +8382,73 @@ async def create_version( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: - """Retrieve a toolbox. - - Retrieves the specified toolbox and its current configuration. - - :param name: The name of the toolbox to retrieve. Required. - :type name: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) - - _request = build_toolboxes_get_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) +class EvaluatorsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`evaluators` attribute. + """ - return deserialized # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( + def list_versions( self, + name: str, *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ToolboxObject"]: - """List toolboxes. + ) -> AsyncItemPaged["_models.EvaluatorVersion"]: + """List evaluator versions. - Returns the toolboxes available in the current project. + Returns the available versions for the specified evaluator. + :param name: The name of the resource. Required. + :type name: str + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxObject - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxObject] + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8431,92 +8458,103 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_evaluators_list_versions_request( + name=name, + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_toolboxes_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.ToolboxObject], - deserialized.get("data", []), + List[_models.EvaluatorVersion], + deserialized.get("value", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + async def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) return pipeline_response return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_versions( + def list( self, - name: str, *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ToolboxVersionObject"]: - """List toolbox versions. + ) -> AsyncItemPaged["_models.EvaluatorVersion"]: + """List latest evaluator versions. - Returns the available versions for the specified toolbox. + Lists the latest version of each evaluator. - :param name: The name of the toolbox to list versions for. Required. - :type name: str + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxVersionObject - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxVersionObject] + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8526,36 +8564,60 @@ def list_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_evaluators_list_request( + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_toolboxes_list_versions_request( - name=name, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.ToolboxVersionObject], - deserialized.get("data", []), + List[_models.EvaluatorVersion], + deserialized.get("value", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + async def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -8565,28 +8627,24 @@ async def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: - """Retrieve a specific version of a toolbox. + async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: + """Get an evaluator version. - Retrieves the specified version of a toolbox by name and version identifier. + Retrieves the specified evaluator version, returning 404 if it does not exist. - :param name: The name of the toolbox. Required. + :param name: The name of the resource. Required. :type name: str - :param version: The version identifier to retrieve. Required. + :param version: The specific version id of the EvaluatorVersion to retrieve. Required. :type version: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8600,9 +8658,9 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.T _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - _request = build_toolboxes_get_version_request( + _request = build_evaluators_get_version_request( name=name, version=version, api_version=self._config.api_version, @@ -8629,16 +8687,12 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.T except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8646,17 +8700,138 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.T return deserialized # type: ignore @distributed_trace_async - async def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], **kwargs: Any) -> Any: - """Invoke the latest toolbox version through MCP. + async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: + """Delete an evaluator version. + + Removes the specified evaluator version. Returns 204 whether the version existed or not. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_evaluators_delete_version_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_version( + self, + name: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. + + Creates a new evaluator version with an auto-incremented version identifier. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_version( + self, name: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. + + Creates a new evaluator version with an auto-incremented version identifier. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_version( + self, name: str, evaluator_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. + + Creates a new evaluator version with an auto-incremented version identifier. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_version( + self, name: str, evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. - Invokes the latest version of the specified toolbox through its MCP endpoint. + Creates a new evaluator version with an auto-incremented version identifier. - :param name: The name of the toolbox. Required. + :param name: The name of the resource. Required. :type name: str - :param request: The MCP request body. Required. - :type request: dict[str, any] - :return: any - :rtype: any + :param evaluator_version: Is one of the following types: EvaluatorVersion, JSON, IO[bytes] + Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8667,15 +8842,20 @@ async def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], ** } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type") - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - _content = request + content_type = content_type or "application/json" + _content = None + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version + else: + _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_invoke_latest_toolbox_mcp_request( + _request = build_evaluators_create_version_request( name=name, content_type=content_type, api_version=self._config.api_version, @@ -8696,110 +8876,124 @@ async def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], ** response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(Any, response.text()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload - async def update( - self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + async def update_version( + self, + name: str, + version: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + async def update_version( + self, name: str, version: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: JSON + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + async def update_version( + self, + name: str, + version: str, + evaluator_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: IO[bytes] + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( - self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + async def update_version( + self, + name: str, + version: str, + evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Is one of the following types: EvaluatorVersion, + JSON, IO[bytes] Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8814,22 +9008,18 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - if body is _Unset: - if default_version is _Unset: - raise TypeError("missing required argument: default_version") - body = {"default_version": default_version} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_update_request( + _request = build_evaluators_update_version_request( name=name, + version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -8856,90 +9046,25 @@ async def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete(self, name: str, **kwargs: Any) -> None: - """Delete a toolbox. - - Removes the specified toolbox along with all of its versions. - - :param name: The name of the toolbox to delete. Required. - :type name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_toolboxes_delete_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: - """Delete a specific version of a toolbox. - - Removes the specified version of a toolbox. - - :param name: The name of the toolbox. Required. - :type name: str - :param version: The version identifier to delete. Required. - :type version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _create_generation_job_initial( + self, + job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], + *, + operation_id: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8948,15 +9073,24 @@ async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_toolboxes_delete_version_request( - name=name, - version=version, + content_type = content_type or "application/json" + _content = None + if isinstance(job, (IOBase, bytes)): + _content = job + else: + _content = json.dumps(job, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_evaluators_create_generation_job_request( + operation_id=operation_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -8965,14 +9099,19 @@ async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ApiErrorResponse, @@ -8980,70 +9119,188 @@ async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized # type: ignore -class BetaVoiceAgentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + @overload + async def begin_create_generation_job( + self, + job: _models.EvaluatorGenerationInputs, + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`voice_agents` attribute. - """ + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + :param job: The evaluator generation job inputs to create. Required. + :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ - self.conversations = BetaVoiceAgentsConversationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.live_conversations = BetaVoiceAgentsLiveConversationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.telephony = BetaVoiceAgentsTelephonyOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.campaigns = BetaVoiceAgentsCampaignsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + @overload + async def begin_create_generation_job( + self, job: JSON, *, operation_id: Optional[str] = None, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. -class BetaAgentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param job: The evaluator generation job inputs to create. Required. + :type job: JSON + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`agents` attribute. - """ + @overload + async def begin_create_generation_job( + self, + job: IO[bytes], + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. + + :param job: The evaluator generation job inputs to create. Required. + :type job: IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwargs: Any) -> _models.AgentDetails: - """Generate an agent. + async def begin_create_generation_job( + self, + job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], + *, + operation_id: Optional[str] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. - Generates and creates an agent from kind-specific high-level inputs. The generated definition - remains fully editable through the standard agent versioning operations. + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. - :param body: The kind-specific inputs for generating and creating an agent. Is one of the - following types: GenerateVoiceAgentRequest Required. - :type body: ~azure.ai.projects.models.GenerateVoiceAgentRequest - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails + :param job: The evaluator generation job inputs to create. Is one of the following types: + EvaluatorGenerationInputs, JSON, IO[bytes] Required. + :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs or JSON or IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :return: An instance of AsyncLROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_generation_job_initial( + job=job, + operation_id=operation_id, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.EvaluatorVersion, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.EvaluatorVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.EvaluatorVersion]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace_async + async def get_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: + """Get an evaluator generation job. + + Gets the details of an evaluator generation job by its ID. + + :param job_id: The ID of the job. Required. + :type job_id: str + :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9054,18 +9311,14 @@ async def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwarg } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.AgentDetails] = kwargs.pop("cls", None) - - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) - _request = build_beta_agents_create_from_prompt_request( - content_type=content_type, + _request = build_evaluators_get_generation_job_request( + job_id=job_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -9095,65 +9348,57 @@ async def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwarg ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentDetails, response.json()) + deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - -class BetaAgentInsightMonitorsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`agent_insight_monitors` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( + def list_generation_jobs( self, *, - before: Optional[str] = None, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - agent_name: Optional[str] = None, + before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AgentInsightMonitorListItem"]: - """List Agent Insights monitors, optionally filtered by agent name. + ) -> AsyncItemPaged["_models.EvaluatorGenerationJob"]: + """List evaluator generation jobs. - :keyword before: A cursor that identifies the first item in the next page. Default value is - None. - :paramtype before: str - :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + Returns a list of evaluator generation jobs. The List API has up to a few seconds of + propagation delay, so a recently created job may not appear immediately; use the Get evaluator + generation job API with the job ID to retrieve a specific job without delay. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" - and "desc". Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword agent_name: Filter monitors by agent name. Default value is None. - :paramtype agent_name: str - :return: An iterator like instance of AgentInsightMonitorListItem + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of EvaluatorGenerationJob :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsightMonitorListItem] + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorGenerationJob] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.AgentInsightMonitorListItem]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorGenerationJob]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9165,12 +9410,11 @@ def list( def prepare_request(_continuation_token=None): - _request = build_beta_agent_insight_monitors_list_request( - after=_continuation_token, - before=before, + _request = build_evaluators_list_generation_jobs_request( limit=limit, order=order, - agent_name=agent_name, + after=_continuation_token, + before=before, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9184,7 +9428,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.AgentInsightMonitorListItem], + List[_models.EvaluatorGenerationJob], deserialized.get("data", []), ) if cls: @@ -9212,142 +9456,16 @@ async def get_next(_continuation_token=None): return AsyncItemPaged(get_next, extract_data) - @overload - async def create( - self, monitor: _models.AgentInsightMonitorCreate, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, monitor: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Required. - :type monitor: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, monitor: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Required. - :type monitor: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def create( - self, monitor: Union[_models.AgentInsightMonitorCreate, JSON, IO[bytes]], **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Is one of the following types: - AgentInsightMonitorCreate, JSON, IO[bytes] Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate or JSON or IO[bytes] - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(monitor, (IOBase, bytes)): - _content = monitor - else: - _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_beta_agent_insight_monitors_create_request( - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + async def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: + """Cancel an evaluator generation job. - @distributed_trace_async - async def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: - """Get an Agent Insights monitor. + Cancels an evaluator generation job by its ID. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :param job_id: The ID of the job to cancel. Required. + :type job_id: str + :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9361,10 +9479,10 @@ async def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonit _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_get_request( - monitor_id=monitor_id, + _request = build_evaluators_cancel_generation_job_request( + job_id=job_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9398,7 +9516,7 @@ async def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonit if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) + deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9406,11 +9524,14 @@ async def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonit return deserialized # type: ignore @distributed_trace_async - async def delete(self, monitor_id: str, **kwargs: Any) -> None: - """Delete an Agent Insights monitor and all of its runs, insights, and state. + async def delete_generation_job(self, job_id: str, **kwargs: Any) -> None: + """Delete an evaluator generation job. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str + Deletes an evaluator generation job by its ID. Deletes the job record only; the generated + evaluator (if any) is preserved. + + :param job_id: The ID of the job to delete. Required. + :type job_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -9428,8 +9549,8 @@ async def delete(self, monitor_id: str, **kwargs: Any) -> None: cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_delete_request( - monitor_id=monitor_id, + _request = build_evaluators_delete_generation_job_request( + job_id=job_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9457,78 +9578,144 @@ async def delete(self, monitor_id: str, **kwargs: Any) -> None: if cls: return cls(pipeline_response, None, {}) # type: ignore + +class ToolboxesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`toolboxes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload - async def update( + async def create_version( self, - monitor_id: str, - monitor: _models.AgentInsightMonitorUpdate, + name: str, *, - content_type: str = "application/merge-patch+json", + tools: List[_models.ToolboxTool], + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, monitor_id: str, monitor: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + async def create_version( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Required. - :type monitor: JSON + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, monitor_id: str, monitor: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + async def create_version( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Required. - :type monitor: IO[bytes] + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( - self, monitor_id: str, monitor: Union[_models.AgentInsightMonitorUpdate, JSON, IO[bytes]], **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + async def create_version( + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + tools: List[_models.ToolboxTool] = _Unset, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, + **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Is one of the following types: - AgentInsightMonitorUpdate, JSON, IO[bytes] Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate or JSON or IO[bytes] - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9543,17 +9730,28 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) - content_type = content_type or "application/merge-patch+json" + if body is _Unset: + if tools is _Unset: + raise TypeError("missing required argument: tools") + body = { + "description": description, + "metadata": metadata, + "policies": policies, + "skills": skills, + "tools": tools, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" _content = None - if isinstance(monitor, (IOBase, bytes)): - _content = monitor + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_agent_insight_monitors_update_request( - monitor_id=monitor_id, + _request = build_toolboxes_create_version_request( + name=name, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -9589,7 +9787,7 @@ async def update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -9597,13 +9795,15 @@ async def update( return deserialized # type: ignore @distributed_trace_async - async def reset(self, monitor_id: str, **kwargs: Any) -> None: - """Reset an Agent Insights monitor's overview, checkpoint, and active insight state. + async def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: + """Retrieve a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :return: None - :rtype: None + Retrieves the specified toolbox and its current configuration. + + :param name: The name of the toolbox to retrieve. Required. + :type name: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -9617,72 +9817,11 @@ async def reset(self, monitor_id: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_beta_agent_insight_monitors_reset_request( - monitor_id=monitor_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - async def _create_run_initial( - self, - monitor_id: str, - run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], - *, - operation_id: Optional[str] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(run, (IOBase, bytes)): - _content = run - else: - _content = json.dumps(run, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_create_run_request( - monitor_id=monitor_id, - operation_id=operation_id, - content_type=content_type, + _request = build_toolboxes_get_request( + name=name, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -9692,244 +9831,166 @@ async def _create_run_initial( _request.url = self._client.format_url(_request.url, **path_format_arguments) _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) - response = pipeline_response.http_response - - if response.status_code not in [201]: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - async def begin_create_run( - self, - monitor_id: str, - run: _models.AgentInsightRunCreate, - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. - - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. - Required. - :type run: ~azure.ai.projects.models.AgentInsightRunCreate - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The - AgentInsightRunResult is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + response = pipeline_response.http_response - @overload - async def begin_create_run( - self, - monitor_id: str, - run: JSON, - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. - Required. - :type run: JSON - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The - AgentInsightRunResult is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxObject, response.json()) - @overload - async def begin_create_run( - self, - monitor_id: str, - run: IO[bytes], - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> AsyncLROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. - Required. - :type run: IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The - AgentInsightRunResult is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + return deserialized # type: ignore - @distributed_trace_async - async def begin_create_run( + @distributed_trace + def list( self, - monitor_id: str, - run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], *, - operation_id: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> AsyncLROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. + ) -> AsyncItemPaged["_models.ToolboxObject"]: + """List toolboxes. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is - one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. - :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The - AgentInsightRunResult is compatible with MutableMapping - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + Returns the toolboxes available in the current project. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of ToolboxObject + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxObject] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsightRunResult] = kwargs.pop("cls", None) - polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = await self._create_run_initial( - monitor_id=monitor_id, - run=run, - operation_id=operation_id, - content_type=content_type, - cls=lambda x, y, z: x, + cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_toolboxes_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, headers=_headers, params=_params, - **kwargs ) - await raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolboxObject], + deserialized.get("data", []), ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - if polling is True: - polling_method: AsyncPollingMethod = cast( - AsyncPollingMethod, - AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), - ) - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller[_models.AgentInsightRunResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return AsyncLROPoller[_models.AgentInsightRunResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list_runs( + def list_versions( self, - monitor_id: str, + name: str, *, - before: Optional[str] = None, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - status: Optional[Union[str, _models.JobStatus]] = None, - trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.AgentInsightRun"]: - """List Agent Insights runs for a monitor. + ) -> AsyncItemPaged["_models.ToolboxVersionObject"]: + """List toolbox versions. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :keyword before: A cursor that identifies the first item in the next page. Default value is - None. - :paramtype before: str - :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + Returns the available versions for the specified toolbox. + + :param name: The name of the toolbox to list versions for. Required. + :type name: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" - and "desc". Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword status: Filter runs by status. Known values are: "queued", "in_progress", "succeeded", - "failed", and "cancelled". Default value is None. - :paramtype status: str or ~azure.ai.projects.models.JobStatus - :keyword trigger: Filter runs by trigger. Known values are: "on_demand" and "scheduled". + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. Default value is None. - :paramtype trigger: str or ~azure.ai.projects.models.AgentInsightRunTrigger - :return: An iterator like instance of AgentInsightRun - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsightRun] + :paramtype before: str + :return: An iterator like instance of ToolboxVersionObject + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxVersionObject] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.AgentInsightRun]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -9941,14 +10002,12 @@ def list_runs( def prepare_request(_continuation_token=None): - _request = build_beta_agent_insight_monitors_list_runs_request( - monitor_id=monitor_id, - after=_continuation_token, - before=before, + _request = build_toolboxes_list_versions_request( + name=name, limit=limit, order=order, - status=status, - trigger=trigger, + after=_continuation_token, + before=before, api_version=self._config.api_version, headers=_headers, params=_params, @@ -9962,7 +10021,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.AgentInsightRun], + List[_models.ToolboxVersionObject], deserialized.get("data", []), ) if cls: @@ -9991,15 +10050,17 @@ async def get_next(_continuation_token=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: - """Get an Agent Insights run. + async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: + """Retrieve a specific version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run_id: The identifier of the run. Required. - :type run_id: str - :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightRun + Retrieves the specified version of a toolbox by name and version identifier. + + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to retrieve. Required. + :type version: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10013,11 +10074,11 @@ async def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_get_run_request( - monitor_id=monitor_id, - run_id=run_id, + _request = build_toolboxes_get_version_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -10051,7 +10112,7 @@ async def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models. if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightRun, response.json()) + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -10059,15 +10120,17 @@ async def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models. return deserialized # type: ignore @distributed_trace_async - async def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: - """Cancel an Agent Insights run. + async def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], **kwargs: Any) -> Any: + """Invoke the latest toolbox version through MCP. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run_id: The identifier of the run. Required. - :type run_id: str - :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightRun + Invokes the latest version of the specified toolbox through its MCP endpoint. + + :param name: The name of the toolbox. Required. + :type name: str + :param request: The MCP request body. Required. + :type request: dict[str, any] + :return: any + :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10081,12 +10144,16 @@ async def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type") + cls: ClsType[Any] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_cancel_run_request( - monitor_id=monitor_id, - run_id=run_id, + _content = request + + _request = build_toolboxes_invoke_latest_toolbox_mcp_request( + name=name, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -10116,62 +10183,99 @@ async def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _mode ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightRun, response.json()) + deserialized = _deserialize(Any, response.text()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_insights( - self, - monitor_id: str, - *, - before: Optional[str] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - category: Optional[str] = None, - severity: Optional[Union[str, _models.AgentInsightSeverity]] = None, - status: Optional[Union[str, _models.AgentInsightStatus]] = None, - include_details: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.AgentInsight"]: - """List current insights for an Agent Insights monitor. + @overload + async def update( + self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :keyword before: A cursor that identifies the first item in the next page. Default value is - None. - :paramtype before: str - :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" - and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword category: Filter insights by category. Default value is None. - :paramtype category: str - :keyword severity: Filter insights by severity. Known values are: "high", "medium", and "low". - Default value is None. - :paramtype severity: str or ~azure.ai.projects.models.AgentInsightSeverity - :keyword status: Filter insights by lifecycle status. Known values are: "active", "resolved", - and "ignored". Default value is None. - :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus - :keyword include_details: Whether to include expanded insight details such as evidence and run - links in the response. Defaults to false. Default value is None. - :paramtype include_details: bool - :return: An iterator like instance of AgentInsight - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsight] + Updates the toolbox's default version pointer to the specified version. + + :param name: The name of the toolbox to update. Required. + :type name: str + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.AgentInsight]] = kwargs.pop("cls", None) + @overload + async def update( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. + + Updates the toolbox's default version pointer to the specified version. + + :param name: The name of the toolbox to update. Required. + :type name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. + + Updates the toolbox's default version pointer to the specified version. + + :param name: The name of the toolbox to update. Required. + :type name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. + Updates the toolbox's default version pointer to the specified version. + + :param name: The name of the toolbox to update. Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -10180,74 +10284,134 @@ def list_insights( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _request = build_beta_agent_insight_monitors_list_insights_request( - monitor_id=monitor_id, - after=_continuation_token, - before=before, - limit=limit, - order=order, - category=category, - severity=severity, - status=status, - include_details=include_details, - api_version=self._config.api_version, - headers=_headers, - params=_params, + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + + if body is _Unset: + if default_version is _Unset: + raise TypeError("missing required argument: default_version") + body = {"default_version": default_version} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_toolboxes_update_request( + name=name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, name: str, **kwargs: Any) -> None: + """Delete a toolbox. + + Removes the specified toolbox along with all of its versions. + + :param name: The name of the toolbox to delete. Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.AgentInsight], - deserialized.get("data", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + cls: ClsType[None] = kwargs.pop("cls", None) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _request = build_toolboxes_delete_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return pipeline_response + response = pipeline_response.http_response - return AsyncItemPaged(get_next, extract_data) + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async - async def get_insight( - self, monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any - ) -> _models.AgentInsight: - """Get a full insight for an Agent Insights monitor. + async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: + """Delete a specific version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :keyword include_details: Whether to include expanded insight details such as evidence and run - links in the response. Defaults to false. Default value is None. - :paramtype include_details: bool - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight + Removes the specified version of a toolbox. + + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to delete. Required. + :type version: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10261,12 +10425,11 @@ async def get_insight( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_get_insight_request( - monitor_id=monitor_id, - insight_id=insight_id, - include_details=include_details, + _request = build_toolboxes_delete_version_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -10276,20 +10439,14 @@ async def get_insight( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ApiErrorResponse, @@ -10297,113 +10454,70 @@ async def get_insight( ) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.AgentInsight, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore - @overload - async def update_insight( - self, - monitor_id: str, - insight_id: str, - update: _models.AgentInsightUpdate, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. +class BetaVoiceAgentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Required. - :type update: ~azure.ai.projects.models.AgentInsightUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`voice_agents` attribute. + """ - @overload - async def update_insight( - self, - monitor_id: str, - insight_id: str, - update: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Required. - :type update: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight - :raises ~azure.core.exceptions.HttpResponseError: - """ + self.conversations = BetaVoiceAgentsConversationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.live_conversations = BetaVoiceAgentsLiveConversationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.telephony = BetaVoiceAgentsTelephonyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.campaigns = BetaVoiceAgentsCampaignsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - @overload - async def update_insight( - self, - monitor_id: str, - insight_id: str, - update: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Required. - :type update: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight - :raises ~azure.core.exceptions.HttpResponseError: - """ +class BetaAgentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`agents` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def update_insight( - self, - monitor_id: str, - insight_id: str, - update: Union[_models.AgentInsightUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. + async def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwargs: Any) -> _models.AgentDetails: + """Generate an agent. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Is one of the following types: AgentInsightUpdate, - JSON, IO[bytes] Required. - :type update: ~azure.ai.projects.models.AgentInsightUpdate or JSON or IO[bytes] - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight + Generates and creates an agent from kind-specific high-level inputs. The generated definition + remains fully editable through the standard agent versioning operations. + + :param body: The kind-specific inputs for generating and creating an agent. Is one of the + following types: GenerateVoiceAgentRequest Required. + :type body: ~azure.ai.projects.models.GenerateVoiceAgentRequest + :return: AgentDetails. The AgentDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -10417,19 +10531,12 @@ async def update_insight( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.AgentDetails] = kwargs.pop("cls", None) - content_type = content_type or "application/merge-patch+json" - _content = None - if isinstance(update, (IOBase, bytes)): - _content = update - else: - _content = json.dumps(update, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_agent_insight_monitors_update_insight_request( - monitor_id=monitor_id, - insight_id=insight_id, + _request = build_beta_agents_create_from_prompt_request( content_type=content_type, api_version=self._config.api_version, content=_content, @@ -10465,7 +10572,7 @@ async def update_insight( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsight, response.json()) + deserialized = _deserialize(_models.AgentDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py index 3a9607548c11..ccd30ef6304f 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py @@ -10,7 +10,7 @@ from typing import Any, List from ._patch_agents_async import AgentsOperations, BetaAgentsOperations -from ._patch_agent_insights_async import BetaAgentInsightMonitorsOperations +from ._patch_agent_insights_async import AgentInsightMonitorsOperations from ._patch_datasets_async import DatasetsOperations from ._patch_evaluators_async import EvaluatorsOperations from ._patch_evaluation_rules_async import EvaluationRulesOperations @@ -99,8 +99,6 @@ class BetaOperations(GeneratedBetaOperations): agents: BetaAgentsOperations """:class:`~azure.ai.projects.aio.operations.BetaAgentsOperations` operations""" - agent_insight_monitors: BetaAgentInsightMonitorsOperations - """:class:`~azure.ai.projects.aio.operations.BetaAgentInsightMonitorsOperations` operations""" evaluation_taxonomies: BetaEvaluationTaxonomiesOperations """:class:`~azure.ai.projects.aio.operations.BetaEvaluationTaxonomiesOperations` operations""" insights: BetaInsightsOperations @@ -128,10 +126,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) # Replace with patched class that includes create (3-step upload helper) self.models = BetaModelsOperations(self._client, self._config, self._serialize, self._deserialize) - # Replace with patched class that returns AsyncAgentInsightRunLROPoller - self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) # Replace with patched class that wires up the hand-written realtime client self.voice_agents = BetaVoiceAgentsOperations(self._client, self._config, self._serialize, self._deserialize) @@ -144,6 +138,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: __all__: List[str] = [ + "AgentInsightMonitorsOperations", "AgentsOperations", "AsyncBetaRealtime", "AsyncBetaRealtimeConnection", @@ -153,7 +148,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: "AsyncBetaLiveConnectionManager", "LiveClientEvent", "LiveServerEvent", - "BetaAgentInsightMonitorsOperations", "BetaAgentsOperations", "BetaEvaluationTaxonomiesOperations", "BetaInsightsOperations", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_agent_insights_async.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_agent_insights_async.py index 80f4fb033829..d582d16c301b 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_agent_insights_async.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_agent_insights_async.py @@ -15,9 +15,8 @@ from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.utils import case_insensitive_dict -from ._operations import ( - BetaAgentInsightMonitorsOperations as BetaAgentInsightMonitorsOperationsGenerated, -) +from ._operations import AgentInsightMonitorsOperations as AgentInsightMonitorsOperationsGenerated +from ._operations import _Unset from ... import models as _models from ..._utils.model_base import _deserialize from ..._utils.polling import AsyncAIProjectsLROBasePolling @@ -26,17 +25,17 @@ JSON = MutableMapping[str, Any] -class BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): - """Custom async operations for beta Agent Insights monitors.""" +class AgentInsightMonitorsOperations(AgentInsightMonitorsOperationsGenerated): + """Custom async operations for GA Agent Insights monitors.""" @overload async def begin_create_run( self, monitor_id: str, - run: _models.AgentInsightRunCreate, *, operation_id: Optional[str] = None, content_type: str = "application/json", + lookback_hours: Optional[float] = None, **kwargs: Any, ) -> AsyncAgentInsightRunLROPoller: ... @@ -44,7 +43,7 @@ async def begin_create_run( async def begin_create_run( self, monitor_id: str, - run: JSON, + body: JSON, *, operation_id: Optional[str] = None, content_type: str = "application/json", @@ -55,7 +54,7 @@ async def begin_create_run( async def begin_create_run( self, monitor_id: str, - run: IO[bytes], + body: IO[bytes], *, operation_id: Optional[str] = None, content_type: str = "application/json", @@ -66,21 +65,24 @@ async def begin_create_run( async def begin_create_run( self, monitor_id: str, - run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], + body: Union[JSON, IO[bytes]] = _Unset, *, operation_id: Optional[str] = None, + lookback_hours: Optional[float] = None, **kwargs: Any, ) -> AsyncAgentInsightRunLROPoller: """Start an Agent Insights run for a monitor. :param monitor_id: The identifier of the monitor. Required. :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is - one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. - :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] + :param body: Optional JSON or binary request body. Omit to use the keyword parameters. + :type body: MutableMapping[str, Any] or IO[bytes] :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the server creates the run unconditionally. Default value is None. :paramtype operation_id: str + :keyword lookback_hours: Optional finite positive number of hours of trace history to analyze, + up to 2,160. Defaults to 168. + :paramtype lookback_hours: float :return: A poller that returns AgentInsightRunResult and exposes the run ID in ``details``. :rtype: ~azure.ai.projects.models.AsyncAgentInsightRunLROPoller :raises ~azure.core.exceptions.HttpResponseError: @@ -97,8 +99,9 @@ async def begin_create_run( if continuation_token is None: raw_result = await self._create_run_initial( monitor_id=monitor_id, - run=run, + body=body, operation_id=operation_id, + lookback_hours=lookback_hours, content_type=content_type, cls=lambda x, y, z: x, headers=headers, diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py index 718c0725ebb2..1c5663e8b8af 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py @@ -41,20 +41,18 @@ AgentInsightHighlightedTrace, AgentInsightLinkedTrace, AgentInsightMonitor, - AgentInsightMonitorCreate, AgentInsightMonitorListItem, - AgentInsightMonitorUpdate, + AgentInsightPriorities, + AgentInsightPrioritiesRead, AgentInsightProposedFix, AgentInsightProposedFixChange, AgentInsightRecommendedAction, AgentInsightRun, - AgentInsightRunCreate, + AgentInsightRunInputs, AgentInsightRunResult, + AgentInsightSummary, AgentInsightSuspension, AgentInsightTokenUsage, - AgentInsightUpdate, - AgentInsightsOverview, - AgentInsightsOverviewOverride, AgentObjectVersions, AgentOptimizationAgentCandidateOutput, AgentOptimizationBaselineAgentConfiguration, @@ -697,7 +695,6 @@ TelephonyCallTiming, TelephonyCallTrace, TelephonyCampaign, - TelephonyCampaignDatasetReference, TelephonyCampaignOperation, TelephonyCampaignProgress, TelephonyCampaignSchedule, @@ -768,6 +765,7 @@ VersionRefIndicator, VersionSelectionRule, VersionSelector, + VersionedDatasetReference, VoiceAgentAnimationConfig, VoiceAgentAudioConfig, VoiceAgentAudioInputConfig, @@ -922,7 +920,6 @@ AgentEndpointAuthorizationSchemeType, AgentEndpointProtocol, AgentIdentityStatus, - AgentInsightOverviewSource, AgentInsightPromptSurface, AgentInsightProposedFixKind, AgentInsightRunTrigger, @@ -1173,20 +1170,18 @@ "AgentInsightHighlightedTrace", "AgentInsightLinkedTrace", "AgentInsightMonitor", - "AgentInsightMonitorCreate", "AgentInsightMonitorListItem", - "AgentInsightMonitorUpdate", + "AgentInsightPriorities", + "AgentInsightPrioritiesRead", "AgentInsightProposedFix", "AgentInsightProposedFixChange", "AgentInsightRecommendedAction", "AgentInsightRun", - "AgentInsightRunCreate", + "AgentInsightRunInputs", "AgentInsightRunResult", + "AgentInsightSummary", "AgentInsightSuspension", "AgentInsightTokenUsage", - "AgentInsightUpdate", - "AgentInsightsOverview", - "AgentInsightsOverviewOverride", "AgentObjectVersions", "AgentOptimizationAgentCandidateOutput", "AgentOptimizationBaselineAgentConfiguration", @@ -1829,7 +1824,6 @@ "TelephonyCallTiming", "TelephonyCallTrace", "TelephonyCampaign", - "TelephonyCampaignDatasetReference", "TelephonyCampaignOperation", "TelephonyCampaignProgress", "TelephonyCampaignSchedule", @@ -1900,6 +1894,7 @@ "VersionRefIndicator", "VersionSelectionRule", "VersionSelector", + "VersionedDatasetReference", "VoiceAgentAnimationConfig", "VoiceAgentAudioConfig", "VoiceAgentAudioInputConfig", @@ -2051,7 +2046,6 @@ "AgentEndpointAuthorizationSchemeType", "AgentEndpointProtocol", "AgentIdentityStatus", - "AgentInsightOverviewSource", "AgentInsightPromptSurface", "AgentInsightProposedFixKind", "AgentInsightRunTrigger", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py index 160e942193ca..35bcf52dceb5 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py @@ -43,8 +43,6 @@ class _FoundryFeaturesOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta): """RED_TEAMS_V1_PREVIEW.""" INSIGHTS_V1_PREVIEW = "Insights=V1Preview" """INSIGHTS_V1_PREVIEW.""" - AGENT_INSIGHTS_V1_PREVIEW = "AgentInsights=V1Preview" - """AGENT_INSIGHTS_V1_PREVIEW.""" MEMORY_STORES_V1_PREVIEW = "MemoryStores=V1Preview" """MEMORY_STORES_V1_PREVIEW.""" ROUTINES_V2_PREVIEW = "Routines=V2Preview" @@ -162,15 +160,6 @@ class AgentIdentityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The agent identity is disabled and cannot be used to access resources.""" -class AgentInsightOverviewSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Identifies where an Agent Insights overview came from.""" - - GENERATED = "generated" - """The overview was generated by Agent Insights.""" - USER_OVERRIDE = "user_override" - """The overview was provided by the user.""" - - class AgentInsightPromptSurface(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Prompt surface changed by a proposed fix.""" diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py index 83f8cee29332..c02d050391b1 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py @@ -1678,8 +1678,10 @@ class AgentInsightMonitor(_Model): :ivar suspension: Why the system suspended scheduled generation. Null when the monitor is not suspended. Required. :vartype suspension: ~azure.ai.projects.models.AgentInsightSuspension - :ivar overview: The effective overview, or null before an overview is available. Required. - :vartype overview: ~azure.ai.projects.models.AgentInsightsOverview + :ivar agent_summary: Generated summary. Omitted when unavailable. + :vartype agent_summary: ~azure.ai.projects.models.AgentInsightSummary + :ivar priorities: Analysis priorities. Omitted when not configured. + :vartype priorities: ~azure.ai.projects.models.AgentInsightPrioritiesRead :ivar updated_at: The time when this monitor was last updated. Required. :vartype updated_at: ~datetime.datetime """ @@ -1703,60 +1705,16 @@ class AgentInsightMonitor(_Model): suspension: "_models.AgentInsightSuspension" = rest_field(visibility=["read"]) """Why the system suspended scheduled generation. Null when the monitor is not suspended. Required.""" - overview: "_models.AgentInsightsOverview" = rest_field(visibility=["read"]) - """The effective overview, or null before an overview is available. Required.""" + agent_summary: Optional["_models.AgentInsightSummary"] = rest_field(visibility=["read"]) + """Generated summary. Omitted when unavailable.""" + priorities: Optional["_models.AgentInsightPrioritiesRead"] = rest_field(visibility=["read"]) + """Analysis priorities. Omitted when not configured.""" updated_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") """The time when this monitor was last updated. Required.""" -class AgentInsightMonitorCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Fields accepted when creating an Agent Insights monitor for an agent. - - :ivar agent_name: The agent this monitor should analyze. Required. - :vartype agent_name: str - :ivar enabled: Whether scheduled insight generation should be armed. Defaults to false. - :vartype enabled: bool - :ivar run_interval_hours: Interval between scheduled insight runs, in hours. Defaults to 6. - :vartype run_interval_hours: float - :ivar model_deployment_name: The model deployment to use for analyzing traces. Accepts either - the deployment name alone or with the connection name as - '{connectionName}/modelDeploymentName'. Required. - :vartype model_deployment_name: str - """ - - agent_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The agent this monitor should analyze. Required.""" - enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Whether scheduled insight generation should be armed. Defaults to false.""" - run_interval_hours: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Interval between scheduled insight runs, in hours. Defaults to 6.""" - model_deployment_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The model deployment to use for analyzing traces. Accepts either the deployment name alone or - with the connection name as '{connectionName}/modelDeploymentName'. Required.""" - - @overload - def __init__( - self, - *, - agent_name: str, - model_deployment_name: str, - enabled: Optional[bool] = None, - run_interval_hours: Optional[float] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class AgentInsightMonitorListItem(_Model): - """An Agent Insights monitor summary returned by list operations. + """Monitor list item without the summary. :ivar id: The monitor identifier. Required. :vartype id: str @@ -1779,6 +1737,8 @@ class AgentInsightMonitorListItem(_Model): :ivar suspension: Why the system suspended scheduled generation. Null when the monitor is not suspended. Required. :vartype suspension: ~azure.ai.projects.models.AgentInsightSuspension + :ivar priorities: Analysis priorities. Omitted when not configured. + :vartype priorities: ~azure.ai.projects.models.AgentInsightPrioritiesRead :ivar updated_at: The time when this monitor was last updated. Required. :vartype updated_at: ~datetime.datetime """ @@ -1802,48 +1762,70 @@ class AgentInsightMonitorListItem(_Model): suspension: "_models.AgentInsightSuspension" = rest_field(visibility=["read"]) """Why the system suspended scheduled generation. Null when the monitor is not suspended. Required.""" + priorities: Optional["_models.AgentInsightPrioritiesRead"] = rest_field(visibility=["read"]) + """Analysis priorities. Omitted when not configured.""" updated_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") """The time when this monitor was last updated. Required.""" -class AgentInsightMonitorUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Fields that can be updated on an Agent Insights monitor. +class AgentInsightPriorities(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Monitor analysis priorities. - :ivar enabled: Whether scheduled insight generation is armed for the monitor. - :vartype enabled: bool - :ivar run_interval_hours: Interval between scheduled insight runs, in hours. - :vartype run_interval_hours: float - :ivar model_deployment_name: The model deployment to use for analyzing traces. Accepts either - the deployment name alone or with the connection name as - '{connectionName}/modelDeploymentName'. - :vartype model_deployment_name: str - :ivar overview_override: Sets the effective user overview, or clears it when explicitly set to - null. Omission leaves the overview unchanged. This field cannot be combined with other monitor - updates. - :vartype overview_override: ~azure.ai.projects.models.AgentInsightsOverviewOverride + :ivar categories: Up to 20 distinct normalized category identifiers (128 UTF-8 bytes each). + Empty uses defaults. Required. + :vartype categories: list[str] + :ivar instructions: Analysis guidance, up to 2,000 UTF-8 bytes after trimming. Null or blank + removes guidance. + :vartype instructions: str """ - enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Whether scheduled insight generation is armed for the monitor.""" - run_interval_hours: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Interval between scheduled insight runs, in hours.""" - model_deployment_name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The model deployment to use for analyzing traces. Accepts either the deployment name alone or - with the connection name as '{connectionName}/modelDeploymentName'.""" - overview_override: Optional["_models.AgentInsightsOverviewOverride"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Sets the effective user overview, or clears it when explicitly set to null. Omission leaves the - overview unchanged. This field cannot be combined with other monitor updates.""" + categories: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Up to 20 distinct normalized category identifiers (128 UTF-8 bytes each). Empty uses defaults. + Required.""" + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Analysis guidance, up to 2,000 UTF-8 bytes after trimming. Null or blank removes guidance.""" @overload def __init__( self, *, - enabled: Optional[bool] = None, - run_interval_hours: Optional[float] = None, - model_deployment_name: Optional[str] = None, - overview_override: Optional["_models.AgentInsightsOverviewOverride"] = None, + categories: list[str], + instructions: Optional[str] = None, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + +class AgentInsightPrioritiesRead(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Monitor analysis priorities returned by the service. + + :ivar categories: Up to 20 distinct normalized category identifiers. Can include legacy names + containing commas. Empty uses defaults. Required. + :vartype categories: list[str] + :ivar instructions: Analysis guidance. Omitted when unavailable. + :vartype instructions: str + """ + + categories: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Up to 20 distinct normalized category identifiers. Can include legacy names containing commas. + Empty uses defaults. Required.""" + instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Analysis guidance. Omitted when unavailable.""" + + @overload + def __init__( + self, + *, + categories: list[str], + instructions: Optional[str] = None, ) -> None: ... @overload @@ -2001,7 +1983,7 @@ class AgentInsightRun(_Model): # pylint: disable=docstring-keyword-should-match :ivar id: Server-assigned unique identifier. Required. :vartype id: str :ivar inputs: Caller-supplied inputs. - :vartype inputs: ~azure.ai.projects.models.AgentInsightRunCreate + :vartype inputs: ~azure.ai.projects.models.AgentInsightRunInputs :ivar result: Result produced on success. :vartype result: ~azure.ai.projects.models.AgentInsightRunResult :ivar status: Current lifecycle status. Required. Known values are: "queued", "in_progress", @@ -2035,7 +2017,7 @@ class AgentInsightRun(_Model): # pylint: disable=docstring-keyword-should-match id: str = rest_field(visibility=["read"]) """Server-assigned unique identifier. Required.""" - inputs: Optional["_models.AgentInsightRunCreate"] = rest_field( + inputs: Optional["_models.AgentInsightRunInputs"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) """Caller-supplied inputs.""" @@ -2071,7 +2053,7 @@ class AgentInsightRun(_Model): # pylint: disable=docstring-keyword-should-match def __init__( self, *, - inputs: Optional["_models.AgentInsightRunCreate"] = None, + inputs: Optional["_models.AgentInsightRunInputs"] = None, ) -> None: ... @overload @@ -2085,8 +2067,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgentInsightRunCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Inputs used when creating an agent insight run. +class AgentInsightRunInputs(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Inputs recorded for an Agent Insights run. :ivar lookback_hours: Optional finite positive number of hours of trace history to analyze, up to 2,160. Defaults to 168. @@ -2170,77 +2152,15 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgentInsightsOverview(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """The effective overview for an Agent Insights monitor. - - :ivar content: The overview content. Required. - :vartype content: str - :ivar source: Where the effective overview came from. Required. Known values are: "generated" - and "user_override". - :vartype source: str or ~azure.ai.projects.models.AgentInsightOverviewSource - :ivar updated_at: The time when this overview was last updated. Required. - :vartype updated_at: ~datetime.datetime - """ - - content: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The overview content. Required.""" - source: Union[str, "_models.AgentInsightOverviewSource"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Where the effective overview came from. Required. Known values are: \"generated\" and - \"user_override\".""" - updated_at: datetime.datetime = rest_field( - visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" - ) - """The time when this overview was last updated. Required.""" - - @overload - def __init__( - self, - *, - content: str, - source: Union[str, "_models.AgentInsightOverviewSource"], - updated_at: datetime.datetime, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - -class AgentInsightsOverviewOverride(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """A user-provided overview that becomes effective immediately and seeds the next generation. +class AgentInsightSummary(_Model): + """Service-generated agent summary. - :ivar content: The nonblank overview content, limited to 64 KiB when encoded as UTF-8. - Required. - :vartype content: str + :ivar markdown: Summary in Markdown. Required. + :vartype markdown: str """ - content: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The nonblank overview content, limited to 64 KiB when encoded as UTF-8. Required.""" - - @overload - def __init__( - self, - *, - content: str, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) + markdown: str = rest_field(visibility=["read"]) + """Summary in Markdown. Required.""" class AgentInsightSuspension(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only @@ -2331,38 +2251,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgentInsightUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Fields that can be updated on an agent insight. - - :ivar status: The lifecycle status to apply to the insight. Known values are: "active", - "resolved", and "ignored". - :vartype status: str or ~azure.ai.projects.models.AgentInsightStatus - """ - - status: Optional[Union[str, "_models.AgentInsightStatus"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The lifecycle status to apply to the insight. Known values are: \"active\", \"resolved\", and - \"ignored\".""" - - @overload - def __init__( - self, - *, - status: Optional[Union[str, "_models.AgentInsightStatus"]] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class AgentObjectVersions(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """AgentObjectVersions. @@ -8951,25 +8839,28 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class DatasetReference(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Reference to a Dataset whose concrete version has already been resolved. + """Reference to a Foundry Dataset in the current project. Consuming operations define supported + Dataset kinds and resolution behavior. :ivar name: Dataset name. Required. :vartype name: str - :ivar version: Concrete Dataset version. Required. + :ivar version: Optional Dataset version. Omit to select latest when the consuming operation + resolves the reference. :vartype version: str """ name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Dataset name. Required.""" - version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Concrete Dataset version. Required.""" + version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional Dataset version. Omit to select latest when the consuming operation resolves the + reference.""" @overload def __init__( self, *, name: str, - version: str, + version: Optional[str] = None, ) -> None: ... @overload @@ -10670,7 +10561,7 @@ class EvaluatorGenerationArtifacts(_Model): # pylint: disable=docstring-keyword version-aligned to ``EvaluatorVersion.version``) holding all artifacts produced by the generation pipeline. Each row in the JSONL carries a ``kind`` field discriminating its content (e.g. ``spec``, ``tools``, ``context``). Required. - :vartype dataset: ~azure.ai.projects.models.DatasetReference + :vartype dataset: ~azure.ai.projects.models.VersionedDatasetReference :ivar kinds: The kinds of rows present in ``dataset``. Always contains ``"spec"`` (the generated evaluation specification, a Markdown document describing what the evaluator measures). May additionally contain ``"tools"`` (when the generation pipeline produced or @@ -10679,7 +10570,9 @@ class EvaluatorGenerationArtifacts(_Model): # pylint: disable=docstring-keyword :vartype kinds: list[str] """ - dataset: "_models.DatasetReference" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + dataset: "_models.VersionedDatasetReference" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) """Reference to the single Foundry Dataset (one combined JSONL file, version-aligned to ``EvaluatorVersion.version``) holding all artifacts produced by the generation pipeline. Each row in the JSONL carries a ``kind`` field discriminating its content (e.g. ``spec``, ``tools``, @@ -10695,7 +10588,7 @@ class EvaluatorGenerationArtifacts(_Model): # pylint: disable=docstring-keyword def __init__( self, *, - dataset: "_models.DatasetReference", + dataset: "_models.VersionedDatasetReference", kinds: list[str], ) -> None: ... @@ -32735,7 +32628,7 @@ class TelephonyCampaign(_Model): # pylint: disable=docstring-keyword-should-mat :ivar recipient_dataset: Same-project CSV/JSON/JSONL uri_file, exclusive with recipients. Omitted version pins latest per preparation. Limits: 1-1,000,000 rows, 256 MiB decoded/file, 1 MiB/row. - :vartype recipient_dataset: ~azure.ai.projects.models.TelephonyCampaignDatasetReference + :vartype recipient_dataset: ~azure.ai.projects.models.DatasetReference :ivar schedule: Dispatch schedule; omission equals ImmediateSchedule. Every mode waits for successful preparation, then follows its schedule and available capacity. :vartype schedule: ~azure.ai.projects.models.TelephonyCampaignSchedule @@ -32781,7 +32674,7 @@ class TelephonyCampaign(_Model): # pylint: disable=docstring-keyword-should-mat recipients: Optional[list["_models.TelephonyRecipient"]] = rest_field(visibility=["create"]) """1-100 recipients, exclusive with recipient_dataset. The whole UTF-8 request is limited to 1 MiB. Omitted from reads; retain the submission for row correlation.""" - recipient_dataset: Optional["_models.TelephonyCampaignDatasetReference"] = rest_field( + recipient_dataset: Optional["_models.DatasetReference"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) """Same-project CSV/JSON/JSONL uri_file, exclusive with recipients. Omitted version pins latest @@ -32830,7 +32723,7 @@ def __init__( connection_name: str, source: "_models.TelephonyAddress", recipients: Optional[list["_models.TelephonyRecipient"]] = None, - recipient_dataset: Optional["_models.TelephonyCampaignDatasetReference"] = None, + recipient_dataset: Optional["_models.DatasetReference"] = None, schedule: Optional["_models.TelephonyCampaignSchedule"] = None, retry_policy: Optional["_models.TelephonyOutboundRetryPolicy"] = None, ) -> None: ... @@ -32846,42 +32739,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class TelephonyCampaignDatasetReference(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """Reference to a Foundry Dataset in the current project. Consuming operations define supported - Dataset kinds and resolution behavior. - - :ivar name: Dataset name. Required. - :vartype name: str - :ivar version: Optional Dataset version. Omit to select latest when the consuming operation - resolves the reference. - :vartype version: str - """ - - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Dataset name. Required.""" - version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Optional Dataset version. Omit to select latest when the consuming operation resolves the - reference.""" - - @overload - def __init__( - self, - *, - name: str, - version: Optional[str] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class TelephonyCampaignOperation(_Model): """Preparation/cancel/delete monitor bound to its original Campaign instance/round, independent of later actions. Omits result. Retained for the Campaign lifetime and at least 24 hours after @@ -35335,6 +35192,39 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.kind = MemoryItemKind.USER_PROFILE # type: ignore +class VersionedDatasetReference(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Reference to a Dataset whose concrete version has already been resolved. + + :ivar name: Dataset name. Required. + :vartype name: str + :ivar version: Concrete Dataset version. Required. + :vartype version: str + """ + + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Dataset name. Required.""" + version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Concrete Dataset version. Required.""" + + @overload + def __init__( + self, + *, + name: str, + version: str, + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: + """ + :param mapping: raw JSON to initialize the model. + :type mapping: Mapping[str, Any] + """ + + def __init__(self, *args: Any, **kwargs: Any) -> None: + super().__init__(*args, **kwargs) + + class VersionIndicator(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Version indicator determining which agent version backs the session. diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py index ceec269ca869..c06c1a004233 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py @@ -68,7 +68,6 @@ ) _BETA_OPERATION_FEATURE_HEADERS: Final[dict] = { - "agent_insight_monitors": _FoundryFeaturesOptInKeys.AGENT_INSIGHTS_V1_PREVIEW.value, "evaluation_taxonomies": _FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW.value, "evaluators": _FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW.value, "insights": _FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW.value, diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/__init__.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/__init__.py index ae40253e5f4f..de2d79fbb7cd 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/__init__.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/__init__.py @@ -16,6 +16,7 @@ from ._operations import AgentsOperations # type: ignore from ._operations import EvaluationRulesOperations # type: ignore from ._operations import DatasetsOperations # type: ignore +from ._operations import AgentInsightMonitorsOperations # type: ignore from ._operations import ConnectionsOperations # type: ignore from ._operations import DeploymentsOperations # type: ignore from ._operations import IndexesOperations # type: ignore @@ -31,6 +32,7 @@ "AgentsOperations", "EvaluationRulesOperations", "DatasetsOperations", + "AgentInsightMonitorsOperations", "ConnectionsOperations", "DeploymentsOperations", "IndexesOperations", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py index 8ea15a66086c..e102de77c5c8 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py @@ -1443,7 +1443,15 @@ def build_datasets_delete_generation_job_request( # pylint: disable=name-too-lo return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_connections_get_request(name: str, **kwargs: Any) -> HttpRequest: +def build_agent_insight_monitors_list_request( # pylint: disable=name-too-long + *, + after: Optional[str] = None, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + agent_name: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1451,14 +1459,19 @@ def build_connections_get_request(name: str, **kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/connections/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/agent_insight_monitors" # Construct parameters + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if agent_name is not None: + _params["agent_name"] = _SERIALIZER.query("agent_name", agent_name, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1467,38 +1480,29 @@ def build_connections_get_request(name: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_connections_get_with_credentials_request( # pylint: disable=name-too-long - name: str, **kwargs: Any -) -> HttpRequest: +def build_agent_insight_monitors_create_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/connections/{name}/getConnectionWithCredentials" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/agent_insight_monitors" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_connections_list_request( - *, - connection_type: Optional[Union[str, _models.ConnectionType]] = None, - default_connection: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: +def build_agent_insight_monitors_get_request(monitor_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1506,14 +1510,15 @@ def build_connections_list_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/connections" + _url = "/agent_insight_monitors/{monitor_id}" + path_format_arguments = { + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if connection_type is not None: - _params["connectionType"] = _SERIALIZER.query("connection_type", connection_type, "str") - if default_connection is not None: - _params["defaultConnection"] = _SERIALIZER.query("default_connection", default_connection, "bool") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1521,17 +1526,16 @@ def build_connections_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_agent_insight_monitors_delete_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = "/deployments/{name}" + _url = "/agent_insight_monitors/{monitor_id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1539,54 +1543,48 @@ def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_deployments_list_request( - *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, - **kwargs: Any +def build_agent_insight_monitors_update_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/deployments" + _url = "/agent_insight_monitors/{monitor_id}" + path_format_arguments = { + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if model_publisher is not None: - _params["modelPublisher"] = _SERIALIZER.query("model_publisher", model_publisher, "str") - if model_name is not None: - _params["modelName"] = _SERIALIZER.query("model_name", model_name, "str") - if deployment_type is not None: - _params["deploymentType"] = _SERIALIZER.query("deployment_type", deployment_type, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_list_versions_request(name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_agent_insight_monitors_reset_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any +) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = "/indexes/{name}/versions" + _url = "/agent_insight_monitors/{monitor_id}:reset" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1594,32 +1592,51 @@ def build_indexes_list_versions_request(name: str, **kwargs: Any) -> HttpRequest # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_indexes_list_request(**kwargs: Any) -> HttpRequest: +def build_agent_insight_monitors_create_run_request( # pylint: disable=name-too-long + monitor_id: str, *, operation_id: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/indexes" + _url = "/agent_insight_monitors/{monitor_id}/runs" + path_format_arguments = { + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if operation_id is not None: + _headers["Operation-Id"] = _SERIALIZER.header("operation_id", operation_id, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_agent_insight_monitors_list_runs_request( # pylint: disable=name-too-long + monitor_id: str, + *, + after: Optional[str] = None, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + status: Optional[Union[str, _models.JobStatus]] = None, + trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1627,15 +1644,26 @@ def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpReq accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/indexes/{name}/versions/{version}" + _url = "/agent_insight_monitors/{monitor_id}/runs" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if status is not None: + _params["status"] = _SERIALIZER.query("status", status, "str") + if trigger is not None: + _params["trigger"] = _SERIALIZER.query("trigger", trigger, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1644,15 +1672,20 @@ def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpReq return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_delete_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_agent_insight_monitors_get_run_request( # pylint: disable=name-too-long + monitor_id: str, run_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/indexes/{name}/versions/{version}" + _url = "/agent_insight_monitors/{monitor_id}/runs/{run_id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "run_id": _SERIALIZER.url("run_id", run_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1660,22 +1693,26 @@ def build_indexes_delete_request(name: str, version: str, **kwargs: Any) -> Http # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_indexes_create_or_update_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_agent_insight_monitors_cancel_run_request( # pylint: disable=name-too-long + monitor_id: str, run_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/indexes/{name}/versions/{version}" + _url = "/agent_insight_monitors/{monitor_id}/runs/{run_id}:cancel" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "run_id": _SERIALIZER.url("run_id", run_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1684,18 +1721,22 @@ def build_indexes_create_or_update_request(name: str, version: str, **kwargs: An _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_list_versions_request( - name: str, +def build_agent_insight_monitors_list_insights_request( # pylint: disable=name-too-long + monitor_id: str, *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + after: Optional[str] = None, + before: Optional[str] = None, limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + categories: Optional[List[str]] = None, + severities: Optional[List[Union[str, _models.AgentInsightSeverity]]] = None, + statuses: Optional[List[Union[str, _models.AgentInsightStatus]]] = None, + include_details: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1705,19 +1746,31 @@ def build_evaluators_list_versions_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions" + _url = "/agent_insight_monitors/{monitor_id}/insights" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if categories is not None: + _params["categories"] = _SERIALIZER.query("categories", categories, "[str]", div=",") + if severities is not None: + _params["severities"] = _SERIALIZER.query("severities", severities, "[str]", div=",") + if statuses is not None: + _params["statuses"] = _SERIALIZER.query("statuses", statuses, "[str]", div=",") + if include_details is not None: + _params["include_details"] = _SERIALIZER.query("include_details", include_details, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1725,11 +1778,8 @@ def build_evaluators_list_versions_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_list_request( - *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, - **kwargs: Any +def build_agent_insight_monitors_get_insight_request( # pylint: disable=name-too-long + monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1738,14 +1788,18 @@ def build_evaluators_list_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators" + _url = "/agent_insight_monitors/{monitor_id}/insights/{insight_id}" + path_format_arguments = { + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "insight_id": _SERIALIZER.url("insight_id", insight_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if include_details is not None: + _params["include_details"] = _SERIALIZER.query("include_details", include_details, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1753,18 +1807,21 @@ def build_evaluators_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_get_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_agent_insight_monitors_update_insight_request( # pylint: disable=name-too-long + monitor_id: str, insight_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/agent_insight_monitors/{monitor_id}/insights/{insight_id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "insight_id": _SERIALIZER.url("insight_id", insight_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1773,20 +1830,24 @@ def build_evaluators_get_version_request(name: str, version: str, **kwargs: Any) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_delete_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_connections_get_request(name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/connections/{name}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1794,19 +1855,23 @@ def build_evaluators_delete_version_request(name: str, version: str, **kwargs: A # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_create_version_request(name: str, **kwargs: Any) -> HttpRequest: + +def build_connections_get_with_credentials_request( # pylint: disable=name-too-long + name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions" + _url = "/connections/{name}/getConnectionWithCredentials" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), } @@ -1817,26 +1882,50 @@ def build_evaluators_create_version_request(name: str, **kwargs: Any) -> HttpReq _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_update_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_connections_list_request( + *, + connection_type: Optional[Union[str, _models.ConnectionType]] = None, + default_connection: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/connections" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if connection_type is not None: + _params["connectionType"] = _SERIALIZER.query("connection_type", connection_type, "str") + if default_connection is not None: + _params["defaultConnection"] = _SERIALIZER.query("default_connection", default_connection, "bool") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/deployments/{name}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1845,42 +1934,43 @@ def build_evaluators_update_version_request(name: str, version: str, **kwargs: A _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_create_generation_job_request( # pylint: disable=name-too-long - *, operation_id: Optional[str] = None, **kwargs: Any +def build_deployments_list_request( + *, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[Union[str, _models.DeploymentType]] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs" + _url = "/deployments" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if model_publisher is not None: + _params["modelPublisher"] = _SERIALIZER.query("model_publisher", model_publisher, "str") + if model_name is not None: + _params["modelName"] = _SERIALIZER.query("model_name", model_name, "str") + if deployment_type is not None: + _params["deploymentType"] = _SERIALIZER.query("deployment_type", deployment_type, "str") # Construct headers - if operation_id is not None: - _headers["Operation-Id"] = _SERIALIZER.header("operation_id", operation_id, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_get_generation_job_request( # pylint: disable=name-too-long - job_id: str, **kwargs: Any -) -> HttpRequest: +def build_indexes_list_versions_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1888,9 +1978,9 @@ def build_evaluators_get_generation_job_request( # pylint: disable=name-too-lon accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs/{jobId}" + _url = "/indexes/{name}/versions" path_format_arguments = { - "jobId": _SERIALIZER.url("job_id", job_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1904,14 +1994,7 @@ def build_evaluators_get_generation_job_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_list_generation_jobs_request( # pylint: disable=name-too-long - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: +def build_indexes_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1919,17 +2002,9 @@ def build_evaluators_list_generation_jobs_request( # pylint: disable=name-too-l accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs" + _url = "/indexes" # Construct parameters - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1938,9 +2013,7 @@ def build_evaluators_list_generation_jobs_request( # pylint: disable=name-too-l return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_cancel_generation_job_request( # pylint: disable=name-too-long - job_id: str, **kwargs: Any -) -> HttpRequest: +def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1948,9 +2021,10 @@ def build_evaluators_cancel_generation_job_request( # pylint: disable=name-too- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs/{jobId}:cancel" + _url = "/indexes/{name}/versions/{version}" path_format_arguments = { - "jobId": _SERIALIZER.url("job_id", job_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1961,19 +2035,18 @@ def build_evaluators_cancel_generation_job_request( # pylint: disable=name-too- # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_delete_generation_job_request( # pylint: disable=name-too-long - job_id: str, **kwargs: Any -) -> HttpRequest: +def build_indexes_delete_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/evaluator_generation_jobs/{jobId}" + _url = "/indexes/{name}/versions/{version}" path_format_arguments = { - "jobId": _SERIALIZER.url("job_id", job_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1984,7 +2057,7 @@ def build_evaluators_delete_generation_job_request( # pylint: disable=name-too- return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_toolboxes_create_version_request(name: str, **kwargs: Any) -> HttpRequest: +def build_indexes_create_or_update_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1993,9 +2066,10 @@ def build_toolboxes_create_version_request(name: str, **kwargs: Any) -> HttpRequ accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/toolboxes/{name}/versions" + _url = "/indexes/{name}/versions/{version}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2008,10 +2082,16 @@ def build_toolboxes_create_version_request(name: str, **kwargs: Any) -> HttpRequ _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_toolboxes_get_request(name: str, **kwargs: Any) -> HttpRequest: +def build_evaluators_list_versions_request( + name: str, + *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, + **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2019,7 +2099,7 @@ def build_toolboxes_get_request(name: str, **kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/toolboxes/{name}" + _url = "/evaluators/{name}/versions" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), } @@ -2028,6 +2108,10 @@ def build_toolboxes_get_request(name: str, **kwargs: Any) -> HttpRequest: # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -2035,12 +2119,10 @@ def build_toolboxes_get_request(name: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_toolboxes_list_request( +def build_evaluators_list_request( *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2050,18 +2132,14 @@ def build_toolboxes_list_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/toolboxes" + _url = "/evaluators" # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -2069,15 +2147,7 @@ def build_toolboxes_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_toolboxes_list_versions_request( - name: str, - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, - **kwargs: Any -) -> HttpRequest: +def build_evaluators_get_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2085,22 +2155,15 @@ def build_toolboxes_list_versions_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/toolboxes/{name}/versions" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -2109,15 +2172,12 @@ def build_toolboxes_list_versions_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_toolboxes_get_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_evaluators_delete_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = "/toolboxes/{name}/versions/{version}" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), "version": _SERIALIZER.url("version", version, "str"), @@ -2128,24 +2188,19 @@ def build_toolboxes_get_version_request(name: str, version: str, **kwargs: Any) # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_toolboxes_invoke_latest_toolbox_mcp_request( # pylint: disable=name-too-long - name: str, **kwargs: Any -) -> HttpRequest: +def build_evaluators_create_version_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: str = kwargs.pop("content_type") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "*/*") + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/toolboxes/{name}:invoke_mcp" + _url = "/evaluators/{name}/versions" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), } @@ -2156,13 +2211,14 @@ def build_toolboxes_invoke_latest_toolbox_mcp_request( # pylint: disable=name-t _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_toolboxes_update_request(name: str, **kwargs: Any) -> HttpRequest: +def build_evaluators_update_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2171,9 +2227,10 @@ def build_toolboxes_update_request(name: str, **kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/toolboxes/{name}" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2189,33 +2246,45 @@ def build_toolboxes_update_request(name: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_toolboxes_delete_request(name: str, **kwargs: Any) -> HttpRequest: +def build_evaluators_create_generation_job_request( # pylint: disable=name-too-long + *, operation_id: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - # Construct URL - _url = "/toolboxes/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } + accept = _headers.pop("Accept", "application/json") - _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct URL + _url = "/evaluator_generation_jobs" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if operation_id is not None: + _headers["Operation-Id"] = _SERIALIZER.header("operation_id", operation_id, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_toolboxes_delete_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_evaluators_get_generation_job_request( # pylint: disable=name-too-long + job_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/toolboxes/{name}/versions/{version}" + _url = "/evaluator_generation_jobs/{jobId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2223,37 +2292,18 @@ def build_toolboxes_delete_version_request(name: str, version: str, **kwargs: An # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") -def build_beta_agents_create_from_prompt_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - content_type: str = kwargs.pop("content_type") - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = "/agents:generate" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_agent_insight_monitors_list_request( # pylint: disable=name-too-long +def build_evaluators_list_generation_jobs_request( # pylint: disable=name-too-long *, - after: Optional[str] = None, - before: Optional[str] = None, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - agent_name: Optional[str] = None, + after: Optional[str] = None, + before: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2263,19 +2313,17 @@ def build_beta_agent_insight_monitors_list_request( # pylint: disable=name-too- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agent_insight_monitors" + _url = "/evaluator_generation_jobs" # Construct parameters - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") if order is not None: _params["order"] = _SERIALIZER.query("order", order, "str") - if agent_name is not None: - _params["agent_name"] = _SERIALIZER.query("agent_name", agent_name, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -2284,30 +2332,8 @@ def build_beta_agent_insight_monitors_list_request( # pylint: disable=name-too- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_create_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/agent_insight_monitors" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_beta_agent_insight_monitors_get_request( # pylint: disable=name-too-long - monitor_id: str, **kwargs: Any +def build_evaluators_cancel_generation_job_request( # pylint: disable=name-too-long + job_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2316,9 +2342,9 @@ def build_beta_agent_insight_monitors_get_request( # pylint: disable=name-too-l accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agent_insight_monitors/{monitor_id}" + _url = "/evaluator_generation_jobs/{jobId}:cancel" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2329,19 +2355,19 @@ def build_beta_agent_insight_monitors_get_request( # pylint: disable=name-too-l # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_delete_request( # pylint: disable=name-too-long - monitor_id: str, **kwargs: Any +def build_evaluators_delete_generation_job_request( # pylint: disable=name-too-long + job_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/agent_insight_monitors/{monitor_id}" + _url = "/evaluator_generation_jobs/{jobId}" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2352,9 +2378,7 @@ def build_beta_agent_insight_monitors_delete_request( # pylint: disable=name-to return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_beta_agent_insight_monitors_update_request( # pylint: disable=name-too-long - monitor_id: str, **kwargs: Any -) -> HttpRequest: +def build_toolboxes_create_version_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2363,9 +2387,9 @@ def build_beta_agent_insight_monitors_update_request( # pylint: disable=name-to accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agent_insight_monitors/{monitor_id}" + _url = "/toolboxes/{name}/versions" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2378,19 +2402,20 @@ def build_beta_agent_insight_monitors_update_request( # pylint: disable=name-to _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_reset_request( # pylint: disable=name-too-long - monitor_id: str, **kwargs: Any -) -> HttpRequest: +def build_toolboxes_get_request(name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/agent_insight_monitors/{monitor_id}:reset" + _url = "/toolboxes/{name}" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2398,49 +2423,53 @@ def build_beta_agent_insight_monitors_reset_request( # pylint: disable=name-too # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_create_run_request( # pylint: disable=name-too-long - monitor_id: str, *, operation_id: Optional[str] = None, **kwargs: Any + +def build_toolboxes_list_request( + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agent_insight_monitors/{monitor_id}/runs" - path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/toolboxes" # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if operation_id is not None: - _headers["Operation-Id"] = _SERIALIZER.header("operation_id", operation_id, "str") - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_list_runs_request( # pylint: disable=name-too-long - monitor_id: str, +def build_toolboxes_list_versions_request( + name: str, *, - after: Optional[str] = None, - before: Optional[str] = None, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - status: Optional[Union[str, _models.JobStatus]] = None, - trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + after: Optional[str] = None, + before: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -2450,26 +2479,22 @@ def build_beta_agent_insight_monitors_list_runs_request( # pylint: disable=name accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agent_insight_monitors/{monitor_id}/runs" + _url = "/toolboxes/{name}/versions" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") if order is not None: _params["order"] = _SERIALIZER.query("order", order, "str") - if status is not None: - _params["status"] = _SERIALIZER.query("status", status, "str") - if trigger is not None: - _params["trigger"] = _SERIALIZER.query("trigger", trigger, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -2478,9 +2503,7 @@ def build_beta_agent_insight_monitors_list_runs_request( # pylint: disable=name return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_get_run_request( # pylint: disable=name-too-long - monitor_id: str, run_id: str, **kwargs: Any -) -> HttpRequest: +def build_toolboxes_get_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2488,10 +2511,10 @@ def build_beta_agent_insight_monitors_get_run_request( # pylint: disable=name-t accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agent_insight_monitors/{monitor_id}/runs/{run_id}" + _url = "/toolboxes/{name}/versions/{version}" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), - "run_id": _SERIALIZER.url("run_id", run_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2505,20 +2528,20 @@ def build_beta_agent_insight_monitors_get_run_request( # pylint: disable=name-t return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_cancel_run_request( # pylint: disable=name-too-long - monitor_id: str, run_id: str, **kwargs: Any +def build_toolboxes_invoke_latest_toolbox_mcp_request( # pylint: disable=name-too-long + name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: str = kwargs.pop("content_type") api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") + accept = _headers.pop("Accept", "*/*") # Construct URL - _url = "/agent_insight_monitors/{monitor_id}/runs/{run_id}:cancel" + _url = "/toolboxes/{name}:invoke_mcp" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), - "run_id": _SERIALIZER.url("run_id", run_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2527,107 +2550,66 @@ def build_beta_agent_insight_monitors_cancel_run_request( # pylint: disable=nam _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["content-type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_list_insights_request( # pylint: disable=name-too-long - monitor_id: str, - *, - after: Optional[str] = None, - before: Optional[str] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - category: Optional[str] = None, - severity: Optional[Union[str, _models.AgentInsightSeverity]] = None, - status: Optional[Union[str, _models.AgentInsightStatus]] = None, - include_details: Optional[bool] = None, - **kwargs: Any -) -> HttpRequest: +def build_toolboxes_update_request(name: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/agent_insight_monitors/{monitor_id}/insights" + _url = "/toolboxes/{name}" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if category is not None: - _params["category"] = _SERIALIZER.query("category", category, "str") - if severity is not None: - _params["severity"] = _SERIALIZER.query("severity", severity, "str") - if status is not None: - _params["status"] = _SERIALIZER.query("status", status, "str") - if include_details is not None: - _params["include_details"] = _SERIALIZER.query("include_details", include_details, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_agent_insight_monitors_get_insight_request( # pylint: disable=name-too-long - monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_toolboxes_delete_request(name: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = "/agent_insight_monitors/{monitor_id}/insights/{insight_id}" + _url = "/toolboxes/{name}" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), - "insight_id": _SERIALIZER.url("insight_id", insight_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if include_details is not None: - _params["include_details"] = _SERIALIZER.query("include_details", include_details, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_beta_agent_insight_monitors_update_insight_request( # pylint: disable=name-too-long - monitor_id: str, insight_id: str, **kwargs: Any -) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_toolboxes_delete_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = "/agent_insight_monitors/{monitor_id}/insights/{insight_id}" + _url = "/toolboxes/{name}/versions/{version}" path_format_arguments = { - "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), - "insight_id": _SERIALIZER.url("insight_id", insight_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2635,12 +2617,28 @@ def build_beta_agent_insight_monitors_update_insight_request( # pylint: disable # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_beta_agents_create_from_prompt_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: str = kwargs.pop("content_type") + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/agents:generate" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-long @@ -5762,9 +5760,6 @@ def __init__(self, *args, **kwargs) -> None: self.voice_agents = BetaVoiceAgentsOperations(self._client, self._config, self._serialize, self._deserialize) self.agents = BetaAgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -11476,14 +11471,14 @@ def delete_generation_job( # pylint: disable=inconsistent-return-statements return cls(pipeline_response, None, {}) # type: ignore -class ConnectionsOperations: # pylint: disable=docstring-missing-param +class AgentInsightMonitorsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`connections` attribute. + :attr:`agent_insight_monitors` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -11494,16 +11489,193 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def _get(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection. + def list( + self, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + agent_name: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.AgentInsightMonitorListItem"]: + """List Agent Insights monitors, optionally filtered by agent name. - Retrieves the specified connection and its configuration details without including credential - values. + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword agent_name: Filter monitors by agent name. Default value is None. + :paramtype agent_name: str + :return: An iterator like instance of AgentInsightMonitorListItem + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsightMonitorListItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + cls: ClsType[List[_models.AgentInsightMonitorListItem]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_agent_insight_monitors_list_request( + after=_continuation_token, + before=before, + limit=limit, + order=order, + agent_name=agent_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentInsightMonitorListItem], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @overload + def create( + self, + *, + agent_name: str, + model_deployment_name: str, + content_type: str = "application/json", + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :keyword agent_name: The agent this monitor should analyze. Required. + :paramtype agent_name: str + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Required. + :paramtype model_deployment_name: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword enabled: Whether scheduled insight generation should be armed. Defaults to false. + Default value is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Defaults to 6. + Default value is None. + :paramtype run_interval_hours: float + :keyword priorities: Analysis priorities for the monitor. Default value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + agent_name: str = _Unset, + model_deployment_name: str = _Unset, + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword agent_name: The agent this monitor should analyze. Required. + :paramtype agent_name: str + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Required. + :paramtype model_deployment_name: str + :keyword enabled: Whether scheduled insight generation should be armed. Defaults to false. + Default value is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Defaults to 6. + Default value is None. + :paramtype run_interval_hours: float + :keyword priorities: Analysis priorities for the monitor. Default value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11514,14 +11686,36 @@ def _get(self, name: str, **kwargs: Any) -> _models.Connection: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_connections_get_request( - name=name, + if body is _Unset: + if agent_name is _Unset: + raise TypeError("missing required argument: agent_name") + if model_deployment_name is _Unset: + raise TypeError("missing required argument: model_deployment_name") + body = { + "agent_name": agent_name, + "enabled": enabled, + "model_deployment_name": model_deployment_name, + "priorities": priorities, + "run_interval_hours": run_interval_hours, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_insight_monitors_create_request( + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -11538,24 +11732,26 @@ def _get(self, name: str, **kwargs: Any) -> _models.Connection: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -11563,15 +11759,13 @@ def _get(self, name: str, **kwargs: Any) -> _models.Connection: return deserialized # type: ignore @distributed_trace - def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection with credentials. - - Retrieves the specified connection together with its credential values. + def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: + """Get an Agent Insights monitor. - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11585,10 +11779,10 @@ def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_connections_get_with_credentials_request( - name=name, + _request = build_agent_insight_monitors_get_request( + monitor_id=monitor_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -11613,53 +11807,32 @@ def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @distributed_trace - def list( - self, - *, - connection_type: Optional[Union[str, _models.ConnectionType]] = None, - default_connection: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_models.Connection"]: - """List connections. - - Returns the connections available in the current project, optionally filtered by type or - default status. + def delete(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete an Agent Insights monitor and all of its runs, insights, and state. - :keyword connection_type: Lists connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", "RemoteTool_Preview", "OpenAPI", and "RemoteA2A". - Default value is None. - :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType - :keyword default_connection: Lists connections that are default connections. Default value is - None. - :paramtype default_connection: bool - :return: An iterator like instance of Connection - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Connection] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11668,103 +11841,146 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[None] = kwargs.pop("cls", None) - return _request + _request = build_agent_insight_monitors_delete_request( + monitor_id=monitor_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Connection], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - return pipeline_response + @overload + def update( + self, + monitor_id: str, + *, + content_type: str = "application/merge-patch+json", + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + model_deployment_name: Optional[str] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - return ItemPaged(get_next, extract_data) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword enabled: Whether scheduled insight generation is armed for the monitor. Default value + is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Default value + is None. + :paramtype run_interval_hours: float + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Default value is None. + :paramtype model_deployment_name: str + :keyword priorities: Replaces all priorities. Omit to preserve them; null clears them. Default + value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def update( + self, monitor_id: str, body: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. -class DeploymentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`deployments` attribute. - """ + @overload + def update( + self, monitor_id: str, body: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get(self, name: str, **kwargs: Any) -> _models.Deployment: - """Get a deployment. - - Retrieves a deployed model. + def update( + self, + monitor_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + model_deployment_name: Optional[str] = None, + priorities: Optional[_models.AgentInsightPriorities] = None, + **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - :param name: Name of the deployment. Required. - :type name: str - :return: Deployment. The Deployment is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Deployment + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword enabled: Whether scheduled insight generation is armed for the monitor. Default value + is None. + :paramtype enabled: bool + :keyword run_interval_hours: Interval between scheduled insight runs, in hours. Default value + is None. + :paramtype run_interval_hours: float + :keyword model_deployment_name: The model deployment to use for analyzing traces. Accepts + either the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Default value is None. + :paramtype model_deployment_name: str + :keyword priorities: Replaces all priorities. Omit to preserve them; null clears them. Default + value is None. + :paramtype priorities: ~azure.ai.projects.models.AgentInsightPriorities + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -11775,14 +11991,32 @@ def get(self, name: str, **kwargs: Any) -> _models.Deployment: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_deployments_get_request( - name=name, + if body is _Unset: + body = { + "enabled": enabled, + "model_deployment_name": model_deployment_name, + "priorities": priorities, + "run_interval_hours": run_interval_hours, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_insight_monitors_update_request( + monitor_id=monitor_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -11806,54 +12040,32 @@ def get(self, name: str, **kwargs: Any) -> _models.Deployment: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Deployment, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @distributed_trace - def list( - self, - *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, - **kwargs: Any - ) -> ItemPaged["_models.Deployment"]: - """List deployments. - - Returns the deployed models available in the current project, optionally filtered by publisher, - model name, or deployment type. + def reset(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Reset an Agent Insights monitor's generated summary, checkpoint, and active insight state. - :keyword model_publisher: Model publisher to filter models by. Default value is None. - :paramtype model_publisher: str - :keyword model_name: Model name (the publisher specific name) to filter models by. Default - value is None. - :paramtype model_name: str - :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value - is None. - :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType - :return: An iterator like instance of Deployment - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Deployment] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -11862,262 +12074,368 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[None] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request = build_agent_insight_monitors_reset_request( + monitor_id=monitor_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Deployment], - deserialized.get("value", []), + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + raise HttpResponseError(response=response, model=error) - def get_next(next_link=None): - _request = prepare_request(next_link) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + def _create_run_initial( + self, + monitor_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + operation_id: Optional[str] = None, + lookback_hours: Optional[float] = None, + **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - return pipeline_response + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - return ItemPaged(get_next, extract_data) + if body is _Unset: + body = {"lookback_hours": lookback_hours} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _request = build_agent_insight_monitors_create_run_request( + monitor_id=monitor_id, + operation_id=operation_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) -class IndexesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`indexes` attribute. - """ + response = pipeline_response.http_response - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + if response.status_code not in [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) - @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: - """List versions. + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - List all versions of the given Index. + deserialized = response.iter_bytes() if _decompress else response.iter_raw() - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of Index - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_create_run( + self, + monitor_id: str, + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + lookback_hours: Optional[float] = None, + **kwargs: Any + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword lookback_hours: Optional finite positive number of hours of trace history to analyze, + up to 2,160. Defaults to 168. Default value is None. + :paramtype lookback_hours: float + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + @overload + def begin_create_run( + self, + monitor_id: str, + body: JSON, + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: JSON + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @overload + def begin_create_run( + self, + monitor_id: str, + body: IO[bytes], + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - _request = build_indexes_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Required. + :type body: IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + @distributed_trace + def begin_create_run( + self, + monitor_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + operation_id: Optional[str] = None, + lookback_hours: Optional[float] = None, + **kwargs: Any + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - return _request + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword lookback_hours: Optional finite positive number of hours of trace history to analyze, + up to 2,160. Defaults to 168. Default value is None. + :paramtype lookback_hours: float + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightRunResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_run_initial( + monitor_id=monitor_id, + body=body, + operation_id=operation_id, + lookback_hours=lookback_hours, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + def get_long_running_output(pipeline_response): + response_headers = {} response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized - return pipeline_response + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } - return ItemPaged(get_next, extract_data) + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AgentInsightRunResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AgentInsightRunResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: - """List latest versions. - - List the latest version of each Index. + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + status: Optional[Union[str, _models.JobStatus]] = None, + trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + **kwargs: Any + ) -> ItemPaged["_models.AgentInsightRun"]: + """List Agent Insights runs for a monitor. - :return: An iterator like instance of Index - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword status: Filter runs by status. Known values are: "queued", "in_progress", "succeeded", + "failed", and "cancelled". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.JobStatus + :keyword trigger: Filter runs by trigger. Known values are: "on_demand" and "scheduled". + Default value is None. + :paramtype trigger: str or ~azure.ai.projects.models.AgentInsightRunTrigger + :return: An iterator like instance of AgentInsightRun + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsightRun] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsightRun]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_agent_insight_monitors_list_runs_request( + monitor_id=monitor_id, + after=_continuation_token, + before=before, + limit=limit, + order=order, + status=status, + trigger=trigger, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), + List[_models.AgentInsightRun], + deserialized.get("data", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.get("last_id") or None, iter(list_of_elem) - def get_next(next_link=None): - _request = prepare_request(next_link) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -12127,25 +12445,26 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) @distributed_trace - def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: - """Get a version. - - Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. + def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Get an Agent Insights run. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to retrieve. Required. - :type version: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12159,11 +12478,11 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Index] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_indexes_get_request( - name=name, - version=version, + _request = build_agent_insight_monitors_get_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12188,12 +12507,16 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -12201,18 +12524,15 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: return deserialized # type: ignore @distributed_trace - def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a version. - - Delete the specific version of the Index. The service returns 204 No Content if the Index was - deleted successfully or if the Index does not exist. + def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Cancel an Agent Insights run. - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the Index to delete. Required. - :type version: str - :return: None - :rtype: None + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12226,158 +12546,12 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_indexes_delete_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def create_or_update( - self, - name: str, - version: str, - index: _models.Index, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: ~azure.ai.projects.models.Index - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_or_update( - self, - name: str, - version: str, - index: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Is one of the following types: Index, JSON, - IO[bytes] Required. - :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Index] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _content = None - if isinstance(index, (IOBase, bytes)): - _content = index - else: - _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_indexes_create_or_update_request( - name=name, - version=version, - content_type=content_type, + _request = build_agent_insight_monitors_cancel_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -12394,73 +12568,74 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class EvaluatorsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`evaluators` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_versions( + def list_insights( self, - name: str, + monitor_id: str, *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + before: Optional[str] = None, limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + categories: Optional[List[str]] = None, + severities: Optional[List[Union[str, _models.AgentInsightSeverity]]] = None, + statuses: Optional[List[Union[str, _models.AgentInsightStatus]]] = None, + include_details: Optional[bool] = None, **kwargs: Any - ) -> ItemPaged["_models.EvaluatorVersion"]: - """List evaluator versions. - - Returns the available versions for the specified evaluator. + ) -> ItemPaged["_models.AgentInsight"]: + """List current insights for a monitor. Filter types combine with AND; values within each list + combine with OR. - :param name: The name of the resource. Required. - :type name: str - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluatorVersion] + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword categories: Match any listed category. Commas separate identifiers; identifiers + containing commas cannot be filtered individually. Default value is None. + :paramtype categories: list[str] + :keyword severities: Match any listed severity. Default value is None. + :paramtype severities: list[str or ~azure.ai.projects.models.AgentInsightSeverity] + :keyword statuses: Match any listed status. Default value is None. + :paramtype statuses: list[str or ~azure.ai.projects.models.AgentInsightStatus] + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: An iterator like instance of AgentInsight + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsight] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -12470,61 +12645,40 @@ def list_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_evaluators_list_versions_request( - name=name, - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_agent_insight_monitors_list_insights_request( + monitor_id=monitor_id, + after=_continuation_token, + before=before, + limit=limit, + order=order, + categories=categories, + severities=severities, + statuses=statuses, + include_details=include_details, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.EvaluatorVersion], - deserialized.get("value", []), + List[_models.AgentInsight], + deserialized.get("data", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.get("last_id") or None, iter(list_of_elem) - def get_next(next_link=None): - _request = prepare_request(next_link) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -12534,40 +12688,33 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) @distributed_trace - def list( - self, - *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, - **kwargs: Any - ) -> ItemPaged["_models.EvaluatorVersion"]: - """List latest evaluator versions. - - Lists the latest version of each evaluator. + def get_insight( + self, monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any + ) -> _models.AgentInsight: + """Get a full insight for an Agent Insights monitor. - :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one - of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default - value is None. - :paramtype type: str or str or str or str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the default is 20. Default value is None. - :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluatorVersion] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -12576,87 +12723,157 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_evaluators_list_request( - type=type, - limit=limit, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request = build_agent_insight_monitors_get_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, + include_details=include_details, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentInsight, response.json()) - return _request + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.EvaluatorVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized # type: ignore - def get_next(next_link=None): - _request = prepare_request(next_link) + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + *, + content_type: str = "application/merge-patch+json", + status: Optional[Union[str, _models.AgentInsightStatus]] = None, + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :keyword status: The lifecycle status to apply to the insight. Known values are: "active", + "resolved", and "ignored". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight + :raises ~azure.core.exceptions.HttpResponseError: + """ - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + body: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - return pipeline_response + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight + :raises ~azure.core.exceptions.HttpResponseError: + """ - return ItemPaged(get_next, extract_data) + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + body: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - @distributed_trace - def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: - """Get an evaluator version. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight + :raises ~azure.core.exceptions.HttpResponseError: + """ - Retrieves the specified evaluator version, returning 404 if it does not exist. + @distributed_trace + def update_insight( + self, + monitor_id: str, + insight_id: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + status: Optional[Union[str, _models.AgentInsightStatus]] = None, + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the EvaluatorVersion to retrieve. Required. - :type version: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword status: The lifecycle status to apply to the insight. Known values are: "active", + "resolved", and "ignored". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12667,15 +12884,28 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Evaluat } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - _request = build_evaluators_get_version_request( - name=name, - version=version, + if body is _Unset: + body = {"status": status} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agent_insight_monitors_update_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -12699,32 +12929,51 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Evaluat except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.AgentInsight, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class ConnectionsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def delete_version( # pylint: disable=inconsistent-return-statements - self, name: str, version: str, **kwargs: Any - ) -> None: - """Delete an evaluator version. + def _get(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection. - Removes the specified evaluator version. Returns 204 whether the version existed or not. + Retrieves the specified connection and its configuration details without including credential + values. - :param name: The name of the resource. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param version: The version of the EvaluatorVersion to delete. Required. - :type version: str - :return: None - :rtype: None + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12738,11 +12987,10 @@ def delete_version( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_evaluators_delete_version_request( + _request = build_connections_get_request( name=name, - version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -12752,100 +13000,48 @@ def delete_version( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - def create_version( - self, - name: str, - evaluator_version: _models.EvaluatorVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. - - Creates a new evaluator version with an auto-incremented version identifier. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_version( - self, name: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. - - Creates a new evaluator version with an auto-incremented version identifier. - - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create_version( - self, name: str, evaluator_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) - Creates a new evaluator version with an auto-incremented version identifier. + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Connection, response.json()) - :param name: The name of the resource. Required. - :type name: str - :param evaluator_version: Required. - :type evaluator_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @distributed_trace - def create_version( - self, name: str, evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create an evaluator version. + def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection with credentials. - Creates a new evaluator version with an auto-incremented version identifier. + Retrieves the specified connection together with its credential values. - :param name: The name of the resource. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param evaluator_version: Is one of the following types: EvaluatorVersion, JSON, IO[bytes] - Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -12856,24 +13052,14 @@ def create_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_evaluators_create_version_request( + _request = build_connections_get_with_credentials_request( name=name, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -12890,7 +13076,7 @@ def create_version( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -12899,115 +13085,156 @@ def create_version( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.Connection, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def update_version( + @distributed_trace + def list( self, - name: str, - version: str, - evaluator_version: _models.EvaluatorVersion, *, - content_type: str = "application/json", + connection_type: Optional[Union[str, _models.ConnectionType]] = None, + default_connection: Optional[bool] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + ) -> ItemPaged["_models.Connection"]: + """List connections. - Updates the specified evaluator version in place. + Returns the connections available in the current project, optionally filtered by type or + default status. - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :keyword connection_type: Lists connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", "RemoteTool_Preview", "OpenAPI", and "RemoteA2A". + Default value is None. + :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType + :keyword default_connection: Lists connections that are default connections. Default value is + None. + :paramtype default_connection: bool + :return: An iterator like instance of Connection + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Connection] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def update_version( - self, name: str, version: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) - Updates the specified evaluator version in place. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(next_link=None): + if not next_link: - @overload - def update_version( - self, - name: str, - version: str, - evaluator_version: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + _request = build_connections_list_request( + connection_type=connection_type, + default_connection=default_connection, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Updates the specified evaluator version in place. + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Connection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DeploymentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def update_version( - self, - name: str, - version: str, - evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an evaluator version. + def get(self, name: str, **kwargs: Any) -> _models.Deployment: + """Get a deployment. - Updates the specified evaluator version in place. + Retrieves a deployed model. - :param name: The name of the resource. Required. + :param name: Name of the deployment. Required. :type name: str - :param version: The version of the EvaluatorVersion to update. Required. - :type version: str - :param evaluator_version: Evaluator resource. Is one of the following types: EvaluatorVersion, - JSON, IO[bytes] Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] - :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13018,25 +13245,14 @@ def update_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(evaluator_version, (IOBase, bytes)): - _content = evaluator_version - else: - _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) - _request = build_evaluators_update_version_request( + _request = build_deployments_get_request( name=name, - version=version, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -13062,260 +13278,165 @@ def update_version( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - def _create_generation_job_initial( - self, - job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], - *, - operation_id: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(job, (IOBase, bytes)): - _content = job - else: - _content = json.dumps(job, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_evaluators_create_generation_job_request( - operation_id=operation_id, - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = True - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.iter_bytes() if _decompress else response.iter_raw() + deserialized = _deserialize(_models.Deployment, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @overload - def begin_create_generation_job( + @distributed_trace + def list( self, - job: _models.EvaluatorGenerationInputs, *, - operation_id: Optional[str] = None, - content_type: str = "application/json", + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[Union[str, _models.DeploymentType]] = None, **kwargs: Any - ) -> LROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. - - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. - - :param job: The evaluator generation job inputs to create. Required. - :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_generation_job( - self, job: JSON, *, operation_id: Optional[str] = None, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. + ) -> ItemPaged["_models.Deployment"]: + """List deployments. - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. + Returns the deployed models available in the current project, optionally filtered by publisher, + model name, or deployment type. - :param job: The evaluator generation job inputs to create. Required. - :type job: JSON - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] + :keyword model_publisher: Model publisher to filter models by. Default value is None. + :paramtype model_publisher: str + :keyword model_name: Model name (the publisher specific name) to filter models by. Default + value is None. + :paramtype model_name: str + :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value + is None. + :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType + :return: An iterator like instance of Deployment + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Deployment] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def begin_create_generation_job( - self, - job: IO[bytes], - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param job: The evaluator generation job inputs to create. Required. - :type job: IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(next_link=None): + if not next_link: - @distributed_trace - def begin_create_generation_job( - self, - job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], - *, - operation_id: Optional[str] = None, - **kwargs: Any - ) -> LROPoller[_models.EvaluatorVersion]: - """Create an evaluator generation job. + _request = build_deployments_list_request( + model_publisher=model_publisher, + model_name=model_name, + deployment_type=deployment_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Creates an evaluator generation job. The service generates rubric-based evaluator definitions - from the provided source materials asynchronously. + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param job: The evaluator generation job inputs to create. Is one of the following types: - EvaluatorGenerationInputs, JSON, IO[bytes] Required. - :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs or JSON or IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is - compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + return _request - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_generation_job_initial( - job=job, - operation_id=operation_id, - content_type=content_type, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Deployment], + deserialized.get("value", []), ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response = pipeline_response.http_response - deserialized = _deserialize(_models.EvaluatorVersion, response.json().get("result", {})) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + return pipeline_response - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.EvaluatorVersion].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.EvaluatorVersion]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + return ItemPaged(get_next, extract_data) + + +class IndexesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`indexes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def get_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: - """Get an evaluator generation job. + def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: + """List versions. - Gets the details of an evaluator generation job by its ID. + List all versions of the given Index. - :param job_id: The ID of the job. Required. - :type job_id: str - :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of Index + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -13324,93 +13445,88 @@ def get_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGen } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_evaluators_get_generation_job_request( - job_id=job_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _request = build_indexes_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - response = pipeline_response.http_response + return _request - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Index], + deserialized.get("value", []), ) - raise HttpResponseError(response=response, model=error) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - response_headers = {} - response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + def get_next(next_link=None): + _request = prepare_request(next_link) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - return deserialized # type: ignore + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def list_generation_jobs( - self, - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.EvaluatorGenerationJob"]: - """List evaluator generation jobs. + def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: + """List latest versions. - Returns a list of evaluator generation jobs. The List API has up to a few seconds of - propagation delay, so a recently created job may not appear immediately; use the Get evaluator - generation job API with the job ID to retrieve a specific job without delay. + List the latest version of each Index. - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of EvaluatorGenerationJob - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluatorGenerationJob] + :return: An iterator like instance of Index + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluatorGenerationJob]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13420,35 +13536,58 @@ def list_generation_jobs( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_evaluators_list_generation_jobs_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.EvaluatorGenerationJob], - deserialized.get("data", []), + List[_models.Index], + deserialized.get("value", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -13458,26 +13597,25 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return ItemPaged(get_next, extract_data) @distributed_trace - def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: - """Cancel an evaluator generation job. + def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: + """Get a version. - Cancels an evaluator generation job by its ID. + Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. - :param job_id: The ID of the job to cancel. Required. - :type job_id: str - :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to retrieve. Required. + :type version: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13491,10 +13629,11 @@ def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.Evaluator _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - _request = build_evaluators_cancel_generation_job_request( - job_id=job_id, + _request = build_indexes_get_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -13519,16 +13658,12 @@ def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.Evaluator except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -13536,16 +13671,16 @@ def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.Evaluator return deserialized # type: ignore @distributed_trace - def delete_generation_job( # pylint: disable=inconsistent-return-statements - self, job_id: str, **kwargs: Any - ) -> None: - """Delete an evaluator generation job. + def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a version. - Deletes an evaluator generation job by its ID. Deletes the job record only; the generated - evaluator (if any) is preserved. + Delete the specific version of the Index. The service returns 204 No Content if the Index was + deleted successfully or if the Index does not exist. - :param job_id: The ID of the job to delete. Required. - :type job_id: str + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the Index to delete. Required. + :type version: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -13563,8 +13698,9 @@ def delete_generation_job( # pylint: disable=inconsistent-return-statements cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_evaluators_delete_generation_job_request( - job_id=job_id, + _request = build_indexes_delete_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -13583,153 +13719,106 @@ def delete_generation_job( # pylint: disable=inconsistent-return-statements if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if cls: return cls(pipeline_response, None, {}) # type: ignore - -class ToolboxesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`toolboxes` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @overload - def create_version( + def create_or_update( self, name: str, + version: str, + index: _models.Index, *, - tools: List[_models.ToolboxTool], - content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + ) -> _models.Index: + """Create or update a version. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + Create a new or update an existing Index with the given version id. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + :param name: The name of the resource. Required. :type name: str - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: ~azure.ai.projects.models.Index :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is - None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_version( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + def create_or_update( + self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.Index: + """Create or update a version. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + Create a new or update an existing Index with the given version id. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: JSON + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_version( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + def create_or_update( + self, + name: str, + version: str, + index: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.Index: + """Create or update a version. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + Create a new or update an existing Index with the given version id. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: IO[bytes] + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_version( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - tools: List[_models.ToolboxTool] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, - **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + @distributed_trace + def create_or_update( + self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Index: + """Create or update a version. - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is - None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Is one of the following types: Index, JSON, + IO[bytes] Required. + :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -13744,28 +13833,18 @@ def create_version( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - if body is _Unset: - if tools is _Unset: - raise TypeError("missing required argument: tools") - body = { - "description": description, - "metadata": metadata, - "policies": policies, - "skills": skills, - "tools": tools, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(index, (IOBase, bytes)): + _content = index else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_create_version_request( + _request = build_indexes_create_or_update_request( name=name, + version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -13785,131 +13864,73 @@ def create_version( response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: - """Retrieve a toolbox. - - Retrieves the specified toolbox and its current configuration. - - :param name: The name of the toolbox to retrieve. Required. - :type name: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) - - _request = build_toolboxes_get_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) +class EvaluatorsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`evaluators` attribute. + """ - return deserialized # type: ignore + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( + def list_versions( self, + name: str, *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ToolboxObject"]: - """List toolboxes. + ) -> ItemPaged["_models.EvaluatorVersion"]: + """List evaluator versions. - Returns the toolboxes available in the current project. + Returns the available versions for the specified evaluator. + :param name: The name of the resource. Required. + :type name: str + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxObject - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxObject] + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -13919,35 +13940,61 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_evaluators_list_versions_request( + name=name, + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_toolboxes_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.ToolboxObject], - deserialized.get("data", []), + List[_models.EvaluatorVersion], + deserialized.get("value", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -13957,54 +14004,39 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return ItemPaged(get_next, extract_data) @distributed_trace - def list_versions( + def list( self, - name: str, *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.ToolboxVersionObject"]: - """List toolbox versions. + ) -> ItemPaged["_models.EvaluatorVersion"]: + """List latest evaluator versions. - Returns the available versions for the specified toolbox. + Lists the latest version of each evaluator. - :param name: The name of the toolbox to list versions for. Required. - :type name: str + :keyword type: Filter evaluators by type. Possible values: 'all', 'custom', 'builtin'. Is one + of the following types: Literal["builtin"], Literal["custom"], Literal["all"], str Default + value is None. + :paramtype type: str or str or str or str :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + 100, and the default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxVersionObject - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxVersionObject] + :return: An iterator like instance of EvaluatorVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluatorVersion] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14014,36 +14046,60 @@ def list_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + def prepare_request(next_link=None): + if not next_link: + + _request = build_evaluators_list_request( + type=type, + limit=limit, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - _request = build_toolboxes_list_versions_request( - name=name, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.ToolboxVersionObject], - deserialized.get("data", []), + List[_models.EvaluatorVersion], + deserialized.get("value", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + return deserialized.get("nextLink") or None, iter(list_of_elem) - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + def get_next(next_link=None): + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -14053,28 +14109,24 @@ def get_next(_continuation_token=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) return pipeline_response return ItemPaged(get_next, extract_data) @distributed_trace - def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: - """Retrieve a specific version of a toolbox. + def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: + """Get an evaluator version. - Retrieves the specified version of a toolbox by name and version identifier. + Retrieves the specified evaluator version, returning 404 if it does not exist. - :param name: The name of the toolbox. Required. + :param name: The name of the resource. Required. :type name: str - :param version: The version identifier to retrieve. Required. + :param version: The specific version id of the EvaluatorVersion to retrieve. Required. :type version: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14088,9 +14140,9 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Toolbox _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - _request = build_toolboxes_get_version_request( + _request = build_evaluators_get_version_request( name=name, version=version, api_version=self._config.api_version, @@ -14117,16 +14169,12 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Toolbox except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14134,17 +14182,140 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Toolbox return deserialized # type: ignore @distributed_trace - def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], **kwargs: Any) -> Any: - """Invoke the latest toolbox version through MCP. + def delete_version( # pylint: disable=inconsistent-return-statements + self, name: str, version: str, **kwargs: Any + ) -> None: + """Delete an evaluator version. + + Removes the specified evaluator version. Returns 204 whether the version existed or not. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the EvaluatorVersion to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_evaluators_delete_version_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def create_version( + self, + name: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. + + Creates a new evaluator version with an auto-incremented version identifier. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_version( + self, name: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. + + Creates a new evaluator version with an auto-incremented version identifier. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_version( + self, name: str, evaluator_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. + + Creates a new evaluator version with an auto-incremented version identifier. + + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Required. + :type evaluator_version: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_version( + self, name: str, evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create an evaluator version. - Invokes the latest version of the specified toolbox through its MCP endpoint. + Creates a new evaluator version with an auto-incremented version identifier. - :param name: The name of the toolbox. Required. + :param name: The name of the resource. Required. :type name: str - :param request: The MCP request body. Required. - :type request: dict[str, any] - :return: any - :rtype: any + :param evaluator_version: Is one of the following types: EvaluatorVersion, JSON, IO[bytes] + Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14155,15 +14326,20 @@ def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], **kwargs } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type") - cls: ClsType[Any] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - _content = request + content_type = content_type or "application/json" + _content = None + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version + else: + _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_invoke_latest_toolbox_mcp_request( + _request = build_evaluators_create_version_request( name=name, content_type=content_type, api_version=self._config.api_version, @@ -14184,110 +14360,124 @@ def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], **kwargs response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(Any, response.text()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @overload - def update( - self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + def update_version( + self, + name: str, + version: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + def update_version( + self, name: str, version: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: JSON + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + def update_version( + self, + name: str, + version: str, + evaluator_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :param body: Required. - :type body: IO[bytes] + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Required. + :type evaluator_version: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( - self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. + def update_version( + self, + name: str, + version: str, + evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an evaluator version. - Updates the toolbox's default version pointer to the specified version. + Updates the specified evaluator version in place. - :param name: The name of the toolbox to update. Required. + :param name: The name of the resource. Required. :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :param version: The version of the EvaluatorVersion to update. Required. + :type version: str + :param evaluator_version: Evaluator resource. Is one of the following types: EvaluatorVersion, + JSON, IO[bytes] Required. + :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion or JSON or IO[bytes] + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14302,22 +14492,18 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - if body is _Unset: - if default_version is _Unset: - raise TypeError("missing required argument: default_version") - body = {"default_version": default_version} - body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_update_request( + _request = build_evaluators_update_version_request( name=name, + version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -14344,92 +14530,25 @@ def update( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a toolbox. - - Removes the specified toolbox along with all of its versions. - - :param name: The name of the toolbox to delete. Required. - :type name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_toolboxes_delete_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def delete_version( # pylint: disable=inconsistent-return-statements - self, name: str, version: str, **kwargs: Any - ) -> None: - """Delete a specific version of a toolbox. - - Removes the specified version of a toolbox. - - :param name: The name of the toolbox. Required. - :type name: str - :param version: The version identifier to delete. Required. - :type version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ + def _create_generation_job_initial( + self, + job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], + *, + operation_id: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -14438,15 +14557,24 @@ def delete_version( # pylint: disable=inconsistent-return-statements } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_toolboxes_delete_version_request( - name=name, - version=version, + content_type = content_type or "application/json" + _content = None + if isinstance(job, (IOBase, bytes)): + _content = job + else: + _content = json.dumps(job, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_evaluators_create_generation_job_request( + operation_id=operation_id, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -14455,14 +14583,19 @@ def delete_version( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = True pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ApiErrorResponse, @@ -14470,70 +14603,187 @@ def delete_version( # pylint: disable=inconsistent-return-statements ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized # type: ignore -class BetaVoiceAgentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + @overload + def begin_create_generation_job( + self, + job: _models.EvaluatorGenerationInputs, + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`voice_agents` attribute. - """ + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + :param job: The evaluator generation job inputs to create. Required. + :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ - self.conversations = BetaVoiceAgentsConversationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.live_conversations = BetaVoiceAgentsLiveConversationsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.telephony = BetaVoiceAgentsTelephonyOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.campaigns = BetaVoiceAgentsCampaignsOperations( - self._client, self._config, self._serialize, self._deserialize - ) + @overload + def begin_create_generation_job( + self, job: JSON, *, operation_id: Optional[str] = None, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. -class BetaAgentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param job: The evaluator generation job inputs to create. Required. + :type job: JSON + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`agents` attribute. - """ + @overload + def begin_create_generation_job( + self, + job: IO[bytes], + *, + operation_id: Optional[str] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. + + :param job: The evaluator generation job inputs to create. Required. + :type job: IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwargs: Any) -> _models.AgentDetails: - """Generate an agent. + def begin_create_generation_job( + self, + job: Union[_models.EvaluatorGenerationInputs, JSON, IO[bytes]], + *, + operation_id: Optional[str] = None, + **kwargs: Any + ) -> LROPoller[_models.EvaluatorVersion]: + """Create an evaluator generation job. - Generates and creates an agent from kind-specific high-level inputs. The generated definition - remains fully editable through the standard agent versioning operations. + Creates an evaluator generation job. The service generates rubric-based evaluator definitions + from the provided source materials asynchronously. - :param body: The kind-specific inputs for generating and creating an agent. Is one of the - following types: GenerateVoiceAgentRequest Required. - :type body: ~azure.ai.projects.models.GenerateVoiceAgentRequest - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails + :param job: The evaluator generation job inputs to create. Is one of the following types: + EvaluatorGenerationInputs, JSON, IO[bytes] Required. + :type job: ~azure.ai.projects.models.EvaluatorGenerationInputs or JSON or IO[bytes] + :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the + server creates the job unconditionally. Default value is None. + :paramtype operation_id: str + :return: An instance of LROPoller that returns EvaluatorVersion. The EvaluatorVersion is + compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.EvaluatorVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_generation_job_initial( + job=job, + operation_id=operation_id, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.EvaluatorVersion, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.EvaluatorVersion].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.EvaluatorVersion]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def get_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: + """Get an evaluator generation job. + + Gets the details of an evaluator generation job by its ID. + + :param job_id: The ID of the job. Required. + :type job_id: str + :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14544,18 +14794,14 @@ def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwargs: Any } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) - cls: ClsType[_models.AgentDetails] = kwargs.pop("cls", None) - - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) - _request = build_beta_agents_create_from_prompt_request( - content_type=content_type, + _request = build_evaluators_get_generation_job_request( + job_id=job_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -14585,64 +14831,56 @@ def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwargs: Any ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentDetails, response.json()) + deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - -class BetaAgentInsightMonitorsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`agent_insight_monitors` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( + def list_generation_jobs( self, *, - before: Optional[str] = None, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - agent_name: Optional[str] = None, + before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AgentInsightMonitorListItem"]: - """List Agent Insights monitors, optionally filtered by agent name. + ) -> ItemPaged["_models.EvaluatorGenerationJob"]: + """List evaluator generation jobs. - :keyword before: A cursor that identifies the first item in the next page. Default value is - None. - :paramtype before: str - :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + Returns a list of evaluator generation jobs. The List API has up to a few seconds of + propagation delay, so a recently created job may not appear immediately; use the Get evaluator + generation job API with the job ID to retrieve a specific job without delay. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" - and "desc". Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword agent_name: Filter monitors by agent name. Default value is None. - :paramtype agent_name: str - :return: An iterator like instance of AgentInsightMonitorListItem - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsightMonitorListItem] + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of EvaluatorGenerationJob + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluatorGenerationJob] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.AgentInsightMonitorListItem]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorGenerationJob]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -14654,12 +14892,11 @@ def list( def prepare_request(_continuation_token=None): - _request = build_beta_agent_insight_monitors_list_request( - after=_continuation_token, - before=before, + _request = build_evaluators_list_generation_jobs_request( limit=limit, order=order, - agent_name=agent_name, + after=_continuation_token, + before=before, api_version=self._config.api_version, headers=_headers, params=_params, @@ -14673,7 +14910,7 @@ def prepare_request(_continuation_token=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.AgentInsightMonitorListItem], + List[_models.EvaluatorGenerationJob], deserialized.get("data", []), ) if cls: @@ -14701,142 +14938,16 @@ def get_next(_continuation_token=None): return ItemPaged(get_next, extract_data) - @overload - def create( - self, monitor: _models.AgentInsightMonitorCreate, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, monitor: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Required. - :type monitor: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def create( - self, monitor: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Required. - :type monitor: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def create( - self, monitor: Union[_models.AgentInsightMonitorCreate, JSON, IO[bytes]], **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Create an Agent Insights monitor for an agent. - - :param monitor: The monitor to create. Is one of the following types: - AgentInsightMonitorCreate, JSON, IO[bytes] Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate or JSON or IO[bytes] - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(monitor, (IOBase, bytes)): - _content = monitor - else: - _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_beta_agent_insight_monitors_create_request( - content_type=content_type, - api_version=self._config.api_version, - content=_content, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + def cancel_generation_job(self, job_id: str, **kwargs: Any) -> _models.EvaluatorGenerationJob: + """Cancel an evaluator generation job. - @distributed_trace - def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: - """Get an Agent Insights monitor. + Cancels an evaluator generation job by its ID. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :param job_id: The ID of the job to cancel. Required. + :type job_id: str + :return: EvaluatorGenerationJob. The EvaluatorGenerationJob is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorGenerationJob :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -14850,10 +14961,10 @@ def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorGenerationJob] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_get_request( - monitor_id=monitor_id, + _request = build_evaluators_cancel_generation_job_request( + job_id=job_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -14887,7 +14998,7 @@ def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) + deserialized = _deserialize(_models.EvaluatorGenerationJob, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -14895,11 +15006,16 @@ def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: return deserialized # type: ignore @distributed_trace - def delete(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete an Agent Insights monitor and all of its runs, insights, and state. + def delete_generation_job( # pylint: disable=inconsistent-return-statements + self, job_id: str, **kwargs: Any + ) -> None: + """Delete an evaluator generation job. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str + Deletes an evaluator generation job by its ID. Deletes the job record only; the generated + evaluator (if any) is preserved. + + :param job_id: The ID of the job to delete. Required. + :type job_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -14917,8 +15033,8 @@ def delete(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inc cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_delete_request( - monitor_id=monitor_id, + _request = build_evaluators_delete_generation_job_request( + job_id=job_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -14946,78 +15062,144 @@ def delete(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inc if cls: return cls(pipeline_response, None, {}) # type: ignore + +class ToolboxesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`toolboxes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @overload - def update( + def create_version( self, - monitor_id: str, - monitor: _models.AgentInsightMonitorUpdate, + name: str, *, - content_type: str = "application/merge-patch+json", + tools: List[_models.ToolboxTool], + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, monitor_id: str, monitor: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + def create_version( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Required. - :type monitor: JSON + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, monitor_id: str, monitor: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + def create_version( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Required. - :type monitor: IO[bytes] + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". + Default value is "application/json". :paramtype content_type: str - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( - self, monitor_id: str, monitor: Union[_models.AgentInsightMonitorUpdate, JSON, IO[bytes]], **kwargs: Any - ) -> _models.AgentInsightMonitor: - """Update an Agent Insights monitor. + def create_version( + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + tools: List[_models.ToolboxTool] = _Unset, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, + **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param monitor: The monitor fields to update. Is one of the following types: - AgentInsightMonitorUpdate, JSON, IO[bytes] Required. - :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate or JSON or IO[bytes] - :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightMonitor + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -15032,17 +15214,28 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) - content_type = content_type or "application/merge-patch+json" + if body is _Unset: + if tools is _Unset: + raise TypeError("missing required argument: tools") + body = { + "description": description, + "metadata": metadata, + "policies": policies, + "skills": skills, + "tools": tools, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" _content = None - if isinstance(monitor, (IOBase, bytes)): - _content = monitor + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_agent_insight_monitors_update_request( - monitor_id=monitor_id, + _request = build_toolboxes_create_version_request( + name=name, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -15078,7 +15271,7 @@ def update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -15086,13 +15279,15 @@ def update( return deserialized # type: ignore @distributed_trace - def reset(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Reset an Agent Insights monitor's overview, checkpoint, and active insight state. + def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: + """Retrieve a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :return: None - :rtype: None + Retrieves the specified toolbox and its current configuration. + + :param name: The name of the toolbox to retrieve. Required. + :type name: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -15106,72 +15301,11 @@ def reset(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inco _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_beta_agent_insight_monitors_reset_request( - monitor_id=monitor_id, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - def _create_run_initial( - self, - monitor_id: str, - run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], - *, - operation_id: Optional[str] = None, - **kwargs: Any - ) -> Iterator[bytes]: - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} - - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(run, (IOBase, bytes)): - _content = run - else: - _content = json.dumps(run, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_create_run_request( - monitor_id=monitor_id, - operation_id=operation_id, - content_type=content_type, + _request = build_toolboxes_get_request( + name=name, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -15181,243 +15315,166 @@ def _create_run_initial( _request.url = self._client.format_url(_request.url, **path_format_arguments) _decompress = kwargs.pop("decompress", True) - _stream = True + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) - response = pipeline_response.http_response - - if response.status_code not in [201]: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - - @overload - def begin_create_run( - self, - monitor_id: str, - run: _models.AgentInsightRunCreate, - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. - - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. - Required. - :type run: ~azure.ai.projects.models.AgentInsightRunCreate - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def begin_create_run( - self, - monitor_id: str, - run: JSON, - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. + response = pipeline_response.http_response - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. - Required. - :type run: JSON - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) - @overload - def begin_create_run( - self, - monitor_id: str, - run: IO[bytes], - *, - operation_id: Optional[str] = None, - content_type: str = "application/json", - **kwargs: Any - ) -> LROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxObject, response.json()) - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. - Required. - :type run: IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] - :raises ~azure.core.exceptions.HttpResponseError: - """ + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def begin_create_run( + def list( self, - monitor_id: str, - run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], *, - operation_id: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> LROPoller[_models.AgentInsightRunResult]: - """Start an Agent Insights run for a monitor. + ) -> ItemPaged["_models.ToolboxObject"]: + """List toolboxes. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is - one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. - :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] - :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the - server creates the job unconditionally. Default value is None. - :paramtype operation_id: str - :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult - is compatible with MutableMapping - :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + Returns the toolboxes available in the current project. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of ToolboxObject + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxObject] :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsightRunResult] = kwargs.pop("cls", None) - polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token: Optional[str] = kwargs.pop("continuation_token", None) - if cont_token is None: - raw_result = self._create_run_initial( - monitor_id=monitor_id, - run=run, - operation_id=operation_id, - content_type=content_type, - cls=lambda x, y, z: x, + cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_toolboxes_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, headers=_headers, params=_params, - **kwargs ) - raw_result.http_response.read() # type: ignore - kwargs.pop("error_map", None) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - def get_long_running_output(pipeline_response): - response_headers = {} - response = pipeline_response.http_response - response_headers["Operation-Location"] = self._deserialize( - "str", response.headers.get("Operation-Location") + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolboxObject], + deserialized.get("data", []), ) - response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - - deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - if polling is True: - polling_method: PollingMethod = cast( - PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) - ) - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller[_models.AgentInsightRunResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs ) - return LROPoller[_models.AgentInsightRunResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore - ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def list_runs( + def list_versions( self, - monitor_id: str, + name: str, *, - before: Optional[str] = None, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - status: Optional[Union[str, _models.JobStatus]] = None, - trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + before: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.AgentInsightRun"]: - """List Agent Insights runs for a monitor. + ) -> ItemPaged["_models.ToolboxVersionObject"]: + """List toolbox versions. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :keyword before: A cursor that identifies the first item in the next page. Default value is - None. - :paramtype before: str - :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + Returns the available versions for the specified toolbox. + + :param name: The name of the toolbox to list versions for. Required. + :type name: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" - and "desc". Default value is None. + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword status: Filter runs by status. Known values are: "queued", "in_progress", "succeeded", - "failed", and "cancelled". Default value is None. - :paramtype status: str or ~azure.ai.projects.models.JobStatus - :keyword trigger: Filter runs by trigger. Known values are: "on_demand" and "scheduled". + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. Default value is None. - :paramtype trigger: str or ~azure.ai.projects.models.AgentInsightRunTrigger - :return: An iterator like instance of AgentInsightRun - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsightRun] + :paramtype before: str + :return: An iterator like instance of ToolboxVersionObject + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxVersionObject] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.AgentInsightRun]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -15429,14 +15486,12 @@ def list_runs( def prepare_request(_continuation_token=None): - _request = build_beta_agent_insight_monitors_list_runs_request( - monitor_id=monitor_id, - after=_continuation_token, - before=before, + _request = build_toolboxes_list_versions_request( + name=name, limit=limit, order=order, - status=status, - trigger=trigger, + after=_continuation_token, + before=before, api_version=self._config.api_version, headers=_headers, params=_params, @@ -15450,7 +15505,7 @@ def prepare_request(_continuation_token=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.AgentInsightRun], + List[_models.ToolboxVersionObject], deserialized.get("data", []), ) if cls: @@ -15479,15 +15534,17 @@ def get_next(_continuation_token=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: - """Get an Agent Insights run. + def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: + """Retrieve a specific version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run_id: The identifier of the run. Required. - :type run_id: str - :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightRun + Retrieves the specified version of a toolbox by name and version identifier. + + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to retrieve. Required. + :type version: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -15501,11 +15558,11 @@ def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentI _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_get_run_request( - monitor_id=monitor_id, - run_id=run_id, + _request = build_toolboxes_get_version_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -15539,7 +15596,7 @@ def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentI if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightRun, response.json()) + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -15547,15 +15604,17 @@ def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentI return deserialized # type: ignore @distributed_trace - def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: - """Cancel an Agent Insights run. + def invoke_latest_toolbox_mcp(self, name: str, request: dict[str, Any], **kwargs: Any) -> Any: + """Invoke the latest toolbox version through MCP. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param run_id: The identifier of the run. Required. - :type run_id: str - :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsightRun + Invokes the latest version of the specified toolbox through its MCP endpoint. + + :param name: The name of the toolbox. Required. + :type name: str + :param request: The MCP request body. Required. + :type request: dict[str, any] + :return: any + :rtype: any :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -15569,12 +15628,16 @@ def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.Age _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type") + cls: ClsType[Any] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_cancel_run_request( - monitor_id=monitor_id, - run_id=run_id, + _content = request + + _request = build_toolboxes_invoke_latest_toolbox_mcp_request( + name=name, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -15604,62 +15667,99 @@ def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.Age ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["content-type"] = self._deserialize("str", response.headers.get("content-type")) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsightRun, response.json()) + deserialized = _deserialize(Any, response.text()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_insights( - self, - monitor_id: str, - *, - before: Optional[str] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - category: Optional[str] = None, - severity: Optional[Union[str, _models.AgentInsightSeverity]] = None, - status: Optional[Union[str, _models.AgentInsightStatus]] = None, - include_details: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_models.AgentInsight"]: - """List current insights for an Agent Insights monitor. + @overload + def update( + self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :keyword before: A cursor that identifies the first item in the next page. Default value is - None. - :paramtype before: str - :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" - and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword category: Filter insights by category. Default value is None. - :paramtype category: str - :keyword severity: Filter insights by severity. Known values are: "high", "medium", and "low". - Default value is None. - :paramtype severity: str or ~azure.ai.projects.models.AgentInsightSeverity - :keyword status: Filter insights by lifecycle status. Known values are: "active", "resolved", - and "ignored". Default value is None. - :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus - :keyword include_details: Whether to include expanded insight details such as evidence and run - links in the response. Defaults to false. Default value is None. - :paramtype include_details: bool - :return: An iterator like instance of AgentInsight - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsight] + Updates the toolbox's default version pointer to the specified version. + + :param name: The name of the toolbox to update. Required. + :type name: str + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.AgentInsight]] = kwargs.pop("cls", None) + @overload + def update( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. + + Updates the toolbox's default version pointer to the specified version. + + :param name: The name of the toolbox to update. Required. + :type name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. + + Updates the toolbox's default version pointer to the specified version. + + :param name: The name of the toolbox to update. Required. + :type name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. + + Updates the toolbox's default version pointer to the specified version. + :param name: The name of the toolbox to update. Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -15668,74 +15768,136 @@ def list_insights( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(_continuation_token=None): + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _request = build_beta_agent_insight_monitors_list_insights_request( - monitor_id=monitor_id, - after=_continuation_token, - before=before, - limit=limit, - order=order, - category=category, - severity=severity, - status=status, - include_details=include_details, - api_version=self._config.api_version, - headers=_headers, - params=_params, + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + + if body is _Unset: + if default_version is _Unset: + raise TypeError("missing required argument: default_version") + body = {"default_version": default_version} + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_toolboxes_update_request( + name=name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a toolbox. + + Removes the specified toolbox along with all of its versions. + + :param name: The name of the toolbox to delete. Required. + :type name: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.AgentInsight], - deserialized.get("data", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) + cls: ClsType[None] = kwargs.pop("cls", None) - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + _request = build_toolboxes_delete_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return pipeline_response + response = pipeline_response.http_response - return ItemPaged(get_next, extract_data) + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def get_insight( - self, monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any - ) -> _models.AgentInsight: - """Get a full insight for an Agent Insights monitor. + def delete_version( # pylint: disable=inconsistent-return-statements + self, name: str, version: str, **kwargs: Any + ) -> None: + """Delete a specific version of a toolbox. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :keyword include_details: Whether to include expanded insight details such as evidence and run - links in the response. Defaults to false. Default value is None. - :paramtype include_details: bool - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight + Removes the specified version of a toolbox. + + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to delete. Required. + :type version: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -15749,12 +15911,11 @@ def get_insight( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_beta_agent_insight_monitors_get_insight_request( - monitor_id=monitor_id, - insight_id=insight_id, - include_details=include_details, + _request = build_toolboxes_delete_version_request( + name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -15764,20 +15925,14 @@ def get_insight( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ApiErrorResponse, @@ -15785,113 +15940,70 @@ def get_insight( ) raise HttpResponseError(response=response, model=error) - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.AgentInsight, response.json()) - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore - @overload - def update_insight( - self, - monitor_id: str, - insight_id: str, - update: _models.AgentInsightUpdate, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. +class BetaVoiceAgentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Required. - :type update: ~azure.ai.projects.models.AgentInsightUpdate - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight - :raises ~azure.core.exceptions.HttpResponseError: - """ + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`voice_agents` attribute. + """ - @overload - def update_insight( - self, - monitor_id: str, - insight_id: str, - update: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Required. - :type update: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight - :raises ~azure.core.exceptions.HttpResponseError: - """ + self.conversations = BetaVoiceAgentsConversationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.live_conversations = BetaVoiceAgentsLiveConversationsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.telephony = BetaVoiceAgentsTelephonyOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.campaigns = BetaVoiceAgentsCampaignsOperations( + self._client, self._config, self._serialize, self._deserialize + ) - @overload - def update_insight( - self, - monitor_id: str, - insight_id: str, - update: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Required. - :type update: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight - :raises ~azure.core.exceptions.HttpResponseError: - """ +class BetaAgentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`agents` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def update_insight( - self, - monitor_id: str, - insight_id: str, - update: Union[_models.AgentInsightUpdate, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.AgentInsight: - """Update the lifecycle status of an insight. + def create_from_prompt(self, body: "_unions.GenerateAgentRequest", **kwargs: Any) -> _models.AgentDetails: + """Generate an agent. - :param monitor_id: The identifier of the monitor. Required. - :type monitor_id: str - :param insight_id: The identifier of the insight. Required. - :type insight_id: str - :param update: The insight fields to update. Is one of the following types: AgentInsightUpdate, - JSON, IO[bytes] Required. - :type update: ~azure.ai.projects.models.AgentInsightUpdate or JSON or IO[bytes] - :return: AgentInsight. The AgentInsight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentInsight + Generates and creates an agent from kind-specific high-level inputs. The generated definition + remains fully editable through the standard agent versioning operations. + + :param body: The kind-specific inputs for generating and creating an agent. Is one of the + following types: GenerateVoiceAgentRequest Required. + :type body: ~azure.ai.projects.models.GenerateVoiceAgentRequest + :return: AgentDetails. The AgentDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -15905,19 +16017,12 @@ def update_insight( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) + content_type: str = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) + cls: ClsType[_models.AgentDetails] = kwargs.pop("cls", None) - content_type = content_type or "application/merge-patch+json" - _content = None - if isinstance(update, (IOBase, bytes)): - _content = update - else: - _content = json.dumps(update, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_beta_agent_insight_monitors_update_insight_request( - monitor_id=monitor_id, - insight_id=insight_id, + _request = build_beta_agents_create_from_prompt_request( content_type=content_type, api_version=self._config.api_version, content=_content, @@ -15953,7 +16058,7 @@ def update_insight( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.AgentInsight, response.json()) + deserialized = _deserialize(_models.AgentDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py index 535c7257d534..921248e56952 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py @@ -22,7 +22,7 @@ ) from .._live import BetaLive, BetaLiveConnection, BetaLiveConnectionManager, LiveClientEvent, LiveServerEvent from ._patch_agents import AgentsOperations, BetaAgentsOperations -from ._patch_agent_insights import BetaAgentInsightMonitorsOperations +from ._patch_agent_insights import AgentInsightMonitorsOperations from ._patch_datasets import DatasetsOperations from ._patch_evaluators import EvaluatorsOperations from ._patch_evaluation_rules import EvaluationRulesOperations @@ -173,8 +173,6 @@ class BetaOperations(GeneratedBetaOperations): agents: BetaAgentsOperations """:class:`~azure.ai.projects.operations.BetaAgentsOperations` operations""" - agent_insight_monitors: BetaAgentInsightMonitorsOperations - """:class:`~azure.ai.projects.operations.BetaAgentInsightMonitorsOperations` operations""" evaluation_taxonomies: BetaEvaluationTaxonomiesOperations """:class:`~azure.ai.projects.operations.BetaEvaluationTaxonomiesOperations` operations""" insights: BetaInsightsOperations @@ -202,10 +200,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) # Replace with patched class that includes create (3-step upload helper) self.models = BetaModelsOperations(self._client, self._config, self._serialize, self._deserialize) - # Replace with patched class that returns AgentInsightRunLROPoller - self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) # Replace with patched class that wires up the hand-written realtime client self.voice_agents = BetaVoiceAgentsOperations(self._client, self._config, self._serialize, self._deserialize) @@ -218,8 +212,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: __all__: List[str] = [ + "AgentInsightMonitorsOperations", "AgentsOperations", - "BetaAgentInsightMonitorsOperations", "BetaAgentsOperations", "BetaEvaluationTaxonomiesOperations", "BetaInsightsOperations", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_agent_insights.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_agent_insights.py index fb72238bc880..d41e09ee4f29 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_agent_insights.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_agent_insights.py @@ -15,9 +15,8 @@ from azure.core.tracing.decorator import distributed_trace from azure.core.utils import case_insensitive_dict -from ._operations import ( - BetaAgentInsightMonitorsOperations as BetaAgentInsightMonitorsOperationsGenerated, -) +from ._operations import AgentInsightMonitorsOperations as AgentInsightMonitorsOperationsGenerated +from ._operations import _Unset from .. import models as _models from .._utils.model_base import _deserialize from .._utils.polling import AIProjectsLROBasePolling @@ -26,17 +25,17 @@ JSON = MutableMapping[str, Any] -class BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): - """Custom operations for beta Agent Insights monitors.""" +class AgentInsightMonitorsOperations(AgentInsightMonitorsOperationsGenerated): + """Custom operations for GA Agent Insights monitors.""" @overload def begin_create_run( self, monitor_id: str, - run: _models.AgentInsightRunCreate, *, operation_id: Optional[str] = None, content_type: str = "application/json", + lookback_hours: Optional[float] = None, **kwargs: Any, ) -> AgentInsightRunLROPoller: ... @@ -44,7 +43,7 @@ def begin_create_run( def begin_create_run( self, monitor_id: str, - run: JSON, + body: JSON, *, operation_id: Optional[str] = None, content_type: str = "application/json", @@ -55,7 +54,7 @@ def begin_create_run( def begin_create_run( self, monitor_id: str, - run: IO[bytes], + body: IO[bytes], *, operation_id: Optional[str] = None, content_type: str = "application/json", @@ -66,21 +65,24 @@ def begin_create_run( def begin_create_run( self, monitor_id: str, - run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], + body: Union[JSON, IO[bytes]] = _Unset, *, operation_id: Optional[str] = None, + lookback_hours: Optional[float] = None, **kwargs: Any, ) -> AgentInsightRunLROPoller: """Start an Agent Insights run for a monitor. :param monitor_id: The identifier of the monitor. Required. :type monitor_id: str - :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is - one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. - :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] + :param body: Optional JSON or binary request body. Omit to use the keyword parameters. + :type body: MutableMapping[str, Any] or IO[bytes] :keyword operation_id: Client-generated unique ID for idempotent retries. When absent, the server creates the run unconditionally. Default value is None. :paramtype operation_id: str + :keyword lookback_hours: Optional finite positive number of hours of trace history to analyze, + up to 2,160. Defaults to 168. + :paramtype lookback_hours: float :return: A poller that returns AgentInsightRunResult and exposes the run ID in ``details``. :rtype: ~azure.ai.projects.models.AgentInsightRunLROPoller :raises ~azure.core.exceptions.HttpResponseError: @@ -97,8 +99,9 @@ def begin_create_run( if continuation_token is None: raw_result = self._create_run_initial( monitor_id=monitor_id, - run=run, + body=body, operation_id=operation_id, + lookback_hours=lookback_hours, content_type=content_type, cls=lambda x, y, z: x, headers=headers, diff --git a/sdk/ai/azure-ai-projects/docs/public-methods.md b/sdk/ai/azure-ai-projects/docs/public-methods.md index 7b17fb38ea82..a84db2c94c1c 100644 --- a/sdk/ai/azure-ai-projects/docs/public-methods.md +++ b/sdk/ai/azure-ai-projects/docs/public-methods.md @@ -9,13 +9,14 @@ This document lists all public methods available on `AIProjectClient` and its su There are a total of 211 unique public methods: - 5 stable methods on the client -- 84 stable methods on top-level sub-clients -- 122 beta methods on nested beta sub-clients +- 97 stable methods on top-level sub-clients +- 109 beta methods on nested beta sub-clients ### Top-level sub-clients (stable operations) | Subclient | Class Name | Methods Count | | --- | --- | --- | +| `agent_insight_monitors` | AgentInsightMonitorsOperations | 13 | | `agents` | AgentsOperations | 35 | | `connections` | ConnectionsOperations | 3 | | `datasets` | DatasetsOperations | 14 | @@ -30,7 +31,6 @@ There are a total of 211 unique public methods: | Subclient | Class Name | Methods Count | | --- | --- | --- | -| `beta.agent_insight_monitors` | BetaAgentInsightMonitorsOperations | 13 | | `beta.agents` | BetaAgentsOperations | 1 | | `beta.evaluation_taxonomies` | BetaEvaluationTaxonomiesOperations | 5 | | `beta.evaluators` | BetaEvaluatorsOperations | 2 | @@ -65,6 +65,20 @@ Alphabetically sorted. An asterisk at the end of the method name means it is a h Alphabetically sorted. An asterisk at the end of the method name means it is a hand-written method. ```text +.agent_insight_monitors.begin_create_run* +.agent_insight_monitors.cancel_run +.agent_insight_monitors.create +.agent_insight_monitors.delete +.agent_insight_monitors.get +.agent_insight_monitors.get_insight +.agent_insight_monitors.get_run +.agent_insight_monitors.list +.agent_insight_monitors.list_insights +.agent_insight_monitors.list_runs +.agent_insight_monitors.reset +.agent_insight_monitors.update +.agent_insight_monitors.update_insight + .agents.begin_create_optimization_job* .agents.cancel_optimization_job .agents.create_session @@ -164,20 +178,6 @@ Alphabetically sorted. An asterisk at the end of the method name means it is a h Alphabetically sorted. An asterisk at the end of the method name means it is a hand-written method. ```text -.beta.agent_insight_monitors.begin_create_run* -.beta.agent_insight_monitors.cancel_run -.beta.agent_insight_monitors.create -.beta.agent_insight_monitors.delete -.beta.agent_insight_monitors.get -.beta.agent_insight_monitors.get_insight -.beta.agent_insight_monitors.get_run -.beta.agent_insight_monitors.list -.beta.agent_insight_monitors.list_insights -.beta.agent_insight_monitors.list_runs -.beta.agent_insight_monitors.reset -.beta.agent_insight_monitors.update -.beta.agent_insight_monitors.update_insight - .beta.agents.create_from_prompt .beta.evaluation_taxonomies.create diff --git a/sdk/ai/azure-ai-projects/samples/agent_insights/agent_insights_util.py b/sdk/ai/azure-ai-projects/samples/agent_insights/agent_insights_util.py index 4f4c784e5af2..1bc0cfee5c0d 100644 --- a/sdk/ai/azure-ai-projects/samples/agent_insights/agent_insights_util.py +++ b/sdk/ai/azure-ai-projects/samples/agent_insights/agent_insights_util.py @@ -23,12 +23,11 @@ from azure.monitor.query import LogsQueryClient, LogsQueryStatus from azure.ai.projects import AIProjectClient from azure.ai.projects.models import ( - AgentInsightMonitorUpdate, AgentVersionDetails, ExternalAgentDefinition, JobStatus, ) -from azure.ai.projects.operations import BetaAgentInsightMonitorsOperations +from azure.ai.projects.operations import AgentInsightMonitorsOperations def create_agent(project_client: AIProjectClient, name_prefix: str) -> AgentVersionDetails: @@ -54,7 +53,7 @@ def cleanup( ) -> None: # Keep the agent if its monitor cannot be stopped and deleted. if monitor_id is not None: - delete_monitor(project_client.beta.agent_insight_monitors, monitor_id, scheduled=scheduled) + delete_monitor(project_client.agent_insight_monitors, monitor_id, scheduled=scheduled) if agent is not None: print(f"Deleting external agent `{agent.name}`; if cleanup fails, remove it manually.") project_client.agents.delete(agent.name, force=True) @@ -62,14 +61,14 @@ def cleanup( def delete_monitor( - operations: BetaAgentInsightMonitorsOperations, + operations: AgentInsightMonitorsOperations, monitor_id: str, *, scheduled: bool = False, ) -> None: print(f"Cleaning up monitor `{monitor_id}`; if cleanup fails, remove it before deleting its agent.") # Disabling stops future scheduling, but a run may already have started. - operations.update(monitor_id, AgentInsightMonitorUpdate(enabled=False)) + operations.update(monitor_id, enabled=False) active_statuses = {JobStatus.QUEUED, JobStatus.IN_PROGRESS} for attempt in range(12): diff --git a/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_on_demand.py b/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_on_demand.py index 30d81ec6f407..1a5bdb5826a6 100644 --- a/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_on_demand.py +++ b/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_on_demand.py @@ -7,11 +7,12 @@ """ DESCRIPTION: This sample uses the synchronous AIProjectClient to create an Agent Insights - monitor, analyze traces from the last three hours on demand, read run results, - and resolve one insight. + monitor with analysis priorities, analyze traces from the last three hours, + list active insights, and resolve one insight. - Agent Insights is a preview feature. In the Python SDK, you access these - operations through `project_client.beta.agent_insight_monitors`. + Access GA monitor operations through `project_client.agent_insight_monitors`. + No Agent Insights preview header is needed. The temporary external agent + still requires preview support. This sample registers a temporary external agent and emits fictional traces; it does not execute tools or call a model to produce those traces. It waits @@ -29,7 +30,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.6.1" azure-identity python-dotenv azure-monitor-opentelemetry azure-monitor-query opentelemetry-sdk + pip install "azure-ai-projects>=2.11.0" azure-identity python-dotenv azure-monitor-opentelemetry azure-monitor-query opentelemetry-sdk Set these environment variables with your own values: 1) FOUNDRY_PROJECT_ENDPOINT - Your Microsoft Foundry project endpoint. @@ -51,12 +52,7 @@ from azure.identity import DefaultAzureCredential from azure.monitor.query import LogsQueryClient from azure.ai.projects import AIProjectClient -from azure.ai.projects.models import ( - AgentInsightMonitorCreate, - AgentInsightRunCreate, - AgentInsightStatus, - AgentInsightUpdate, -) +from azure.ai.projects.models import AgentInsightPriorities, AgentInsightStatus def main() -> None: @@ -72,7 +68,7 @@ def main() -> None: AIProjectClient(endpoint=endpoint, credential=credential, allow_preview=True) as project_client, LogsQueryClient(credential) as logs_client, ): - monitor_operations = project_client.beta.agent_insight_monitors + monitor_operations = project_client.agent_insight_monitors agent = None monitor = None try: @@ -83,11 +79,13 @@ def main() -> None: # Keep scheduling disabled because this sample starts one explicit run. monitor = monitor_operations.create( - AgentInsightMonitorCreate( - agent_name=agent.name, - model_deployment_name=model_deployment_name, - enabled=False, - ) + agent_name=agent.name, + model_deployment_name=model_deployment_name, + enabled=False, + priorities=AgentInsightPriorities( + categories=[], # Use the default analysis categories. + instructions="Focus on tool calls made without the user's approval.", + ), ) print( f"Created monitor `{monitor.id}` for agent `{monitor.agent_name}` " @@ -96,7 +94,7 @@ def main() -> None: poller = monitor_operations.begin_create_run( monitor.id, - AgentInsightRunCreate(lookback_hours=3), + lookback_hours=3, operation_id=str(uuid.uuid4()), ) run_id = poller.details["run_id"] @@ -105,6 +103,8 @@ def main() -> None: run_result = poller.result() completed_run = monitor_operations.get_run(monitor.id, run_id) print(f"Run status: {completed_run.status}") + if completed_run.inputs: + print(f"Lookback hours: {completed_run.inputs.lookback_hours}") print(f"Traces in window: {run_result.traces_in_window}") print(f"Traces analyzed: {run_result.traces_analyzed}") print(f"Insights created: {run_result.insights_created}") @@ -120,7 +120,13 @@ def main() -> None: runs = list(monitor_operations.list_runs(monitor.id, limit=5)) print(f"Listed runs: {len(runs)}") - insights = list(monitor_operations.list_insights(monitor.id, include_details=True)) + insights = list( + monitor_operations.list_insights( + monitor.id, + statuses=[AgentInsightStatus.ACTIVE], + include_details=True, + ) + ) print(f"Listed insights: {len(insights)}") for insight in insights: print( @@ -135,7 +141,7 @@ def main() -> None: resolved_insight = monitor_operations.update_insight( monitor.id, insights[0].id, - AgentInsightUpdate(status=AgentInsightStatus.RESOLVED), + status=AgentInsightStatus.RESOLVED, ) print(f"Insight status after update: {resolved_insight.status}") else: diff --git a/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_scheduled.py b/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_scheduled.py index b6c956eabd6b..24290a3ecacd 100644 --- a/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_scheduled.py +++ b/sdk/ai/azure-ai-projects/samples/agent_insights/sample_agent_insights_scheduled.py @@ -7,11 +7,12 @@ """ DESCRIPTION: This sample uses the synchronous AIProjectClient to configure an Agent - Insights monitor with a six-hour run interval and read the next scheduled - run time. It does not wait for scheduled analysis. + Insights monitor with analysis priorities and a six-hour run interval, then + read the next scheduled run time. It does not wait for scheduled analysis. - Agent Insights is a preview feature. In the Python SDK, you access these - operations through `project_client.beta.agent_insight_monitors`. + Access GA monitor operations through `project_client.agent_insight_monitors`. + No Agent Insights preview header is needed. The temporary external agent + still requires preview support. This sample registers a temporary external agent and emits fictional traces; it does not execute tools or call a model to produce those traces. It waits @@ -29,7 +30,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.6.1" azure-identity python-dotenv azure-monitor-opentelemetry azure-monitor-query opentelemetry-sdk + pip install "azure-ai-projects>=2.11.0" azure-identity python-dotenv azure-monitor-opentelemetry azure-monitor-query opentelemetry-sdk Set these environment variables with your own values: 1) FOUNDRY_PROJECT_ENDPOINT - Your Microsoft Foundry project endpoint. @@ -50,7 +51,7 @@ from azure.identity import DefaultAzureCredential from azure.monitor.query import LogsQueryClient from azure.ai.projects import AIProjectClient -from azure.ai.projects.models import AgentInsightMonitorCreate, AgentInsightMonitorUpdate +from azure.ai.projects.models import AgentInsightPriorities ANALYSIS_INTERVAL_HOURS = 6 @@ -68,7 +69,7 @@ def main() -> None: AIProjectClient(endpoint=endpoint, credential=credential, allow_preview=True) as project_client, LogsQueryClient(credential) as logs_client, ): - monitor_operations = project_client.beta.agent_insight_monitors + monitor_operations = project_client.agent_insight_monitors agent = None monitor = None @@ -79,26 +80,28 @@ def main() -> None: wait_for_ingestion(logs_client, app_insights_resource_id, agent.name, expected_counts) monitor = monitor_operations.create( - AgentInsightMonitorCreate( - agent_name=agent.name, - model_deployment_name=model_deployment_name, - enabled=False, - ) + agent_name=agent.name, + model_deployment_name=model_deployment_name, + enabled=False, ) print(f"Created disabled monitor `{monitor.id}` for agent `{monitor.agent_name}`.") - # Set the analysis frequency and enable recurring runs in one update. + # Replace priorities and enable recurring runs in one update. scheduled_monitor = monitor_operations.update( monitor.id, - AgentInsightMonitorUpdate( - enabled=True, - run_interval_hours=ANALYSIS_INTERVAL_HOURS, + enabled=True, + run_interval_hours=ANALYSIS_INTERVAL_HOURS, + priorities=AgentInsightPriorities( + categories=[], # Use the default analysis categories. + instructions="Focus on tool calls made without the user's approval.", ), ) print(f"Scheduled monitor enabled: {scheduled_monitor.enabled}") print(f"Run interval hours: {scheduled_monitor.run_interval_hours}") print(f"Next scheduled run: {scheduled_monitor.next_scheduled_run_at}") + if scheduled_monitor.priorities and scheduled_monitor.priorities.instructions: + print(f"Analysis guidance: {scheduled_monitor.priorities.instructions}") finally: # Enabling schedules the first occurrence for now, so a run may already be active. cleanup(project_client, agent, monitor.id if monitor is not None else None, scheduled=True) diff --git a/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insight_pollers.py b/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insight_pollers.py index 69ba5e115a74..f8398ff272e3 100644 --- a/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insight_pollers.py +++ b/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insight_pollers.py @@ -20,12 +20,9 @@ from azure.ai.projects import AIProjectClient from azure.ai.projects.aio import AIProjectClient as AsyncAIProjectClient -from azure.ai.projects.aio.operations._patch_agent_insights_async import ( - BetaAgentInsightMonitorsOperations as AsyncBetaAgentInsightMonitorsOperations, -) -from azure.ai.projects.operations._patch_agent_insights import ( - BetaAgentInsightMonitorsOperations, -) +from azure.ai.projects.aio.operations import AgentInsightMonitorsOperations as AsyncAgentInsightMonitorsOperations +from azure.ai.projects.models import AgentInsightRunLROPoller, AsyncAgentInsightRunLROPoller +from azure.ai.projects.operations import AgentInsightMonitorsOperations class _RunResponse: @@ -87,7 +84,7 @@ def _run_response( def _operation_for_status(terminal_status: str, *, is_async: bool = False, initial_status_code: int = 201): - operation_type = AsyncBetaAgentInsightMonitorsOperations if is_async else BetaAgentInsightMonitorsOperations + operation_type = AsyncAgentInsightMonitorsOperations if is_async else AgentInsightMonitorsOperations operation = operation_type.__new__(operation_type) operation._client = MagicMock() operation._config = MagicMock(polling_interval=0) @@ -110,10 +107,38 @@ def _operation_for_status(terminal_status: str, *, is_async: bool = False, initi @pytest.mark.asyncio @pytest.mark.parametrize("is_async", [False, True]) +async def test_ga_monitors_are_wired_to_public_clients(is_async: bool) -> None: + client_type = AsyncAIProjectClient if is_async else AIProjectClient + operation_type = AsyncAgentInsightMonitorsOperations if is_async else AgentInsightMonitorsOperations + client = client_type(endpoint="https://example.test", credential=MagicMock()) + try: + assert isinstance(client.agent_insight_monitors, operation_type) + assert not hasattr(client.beta, "agent_insight_monitors") + finally: + if is_async: + await client.close() + else: + client.close() + + +@pytest.mark.asyncio +@pytest.mark.parametrize("is_async", [False, True]) +@pytest.mark.parametrize("allow_preview", [False, True]) @pytest.mark.parametrize("custom_headers", [False, True]) -async def test_run_poller_sends_headers_on_every_request(is_async: bool, custom_headers: bool) -> None: +@pytest.mark.parametrize("request_kind", ["defaults", "keywords", "json", "stream"]) +async def test_run_poller_sends_headers_on_every_request( + is_async: bool, allow_preview: bool, custom_headers: bool, request_kind: str +) -> None: headers = {"foundry-features": "custom-preview", "x-custom-header": "custom-value"} if custom_headers else {} original_headers = headers.copy() + request_arguments: dict[str, Any] = {} + expected_body = {} if request_kind == "defaults" else {"lookback_hours": 3} + if request_kind == "keywords": + request_arguments["lookback_hours"] = 3 + elif request_kind == "json": + request_arguments["body"] = expected_body + elif request_kind == "stream": + request_arguments["body"] = io.BytesIO(json.dumps(expected_body).encode()) responses = [] for index, status in enumerate(["queued", "in_progress", "succeeded", "succeeded"]): response = _run_response(status, initial=index == 0).http_response @@ -140,41 +165,53 @@ async def test_run_poller_sends_headers_on_every_request(is_async: bool, custom_ async with AsyncAIProjectClient( endpoint="https://example.test", credential=credential, + allow_preview=allow_preview, transport=AioHttpTransport(session=session, session_owner=False), ) as client: - poller = await client.beta.agent_insight_monitors.begin_create_run( - "monitor-test", run={}, polling_interval=0, headers=headers + poller = await client.agent_insight_monitors.begin_create_run( + "monitor-test", polling_interval=0, headers=headers, **request_arguments ) + assert isinstance(poller, AsyncAgentInsightRunLROPoller) result = await asyncio.wait_for(poller.result(), timeout=5) else: session.request.side_effect = responses credential.get_token.return_value = token with AIProjectClient( - endpoint="https://example.test", credential=credential, transport=RequestsTransport(session=session) + endpoint="https://example.test", + credential=credential, + allow_preview=allow_preview, + transport=RequestsTransport(session=session), ) as client: - poller = client.beta.agent_insight_monitors.begin_create_run( - "monitor-test", run={}, polling_interval=0, headers=headers + poller = client.agent_insight_monitors.begin_create_run( + "monitor-test", polling_interval=0, headers=headers, **request_arguments ) + assert isinstance(poller, AgentInsightRunLROPoller) result = poller.result(timeout=5) + assert poller.details == {"run_id": "run-test"} assert result.traces_analyzed == 10 calls = session.request.call_args_list + request_body = calls[0].kwargs["data"] + if isinstance(request_body, io.BytesIO): + request_body = request_body.getvalue() + assert json.loads(request_body) == expected_body assert [call.args[0] if call.args else call.kwargs["method"] for call in calls] == ["POST", "GET", "GET", "GET"] final_url = calls[-1].args[1] if len(calls[-1].args) > 1 else calls[-1].kwargs["url"] assert final_url == "https://example.test/runs/run-test" for call in calls: sent_headers = {key.lower(): value for key, value in call.kwargs["headers"].items()} - assert sent_headers["foundry-features"] == ("custom-preview" if custom_headers else "AgentInsights=V1Preview") if custom_headers: + assert sent_headers["foundry-features"] == "custom-preview" assert sent_headers["x-custom-header"] == "custom-value" - if custom_headers: - assert headers == original_headers + else: + assert "foundry-features" not in sent_headers + assert headers == original_headers @pytest.mark.parametrize("initial_status_code", [201, 202]) def test_run_poller_stops_after_cancellation(initial_status_code: int) -> None: operation = _operation_for_status("cancelled", initial_status_code=initial_status_code) - poller = operation.begin_create_run("monitor-test", run={}) + poller = operation.begin_create_run("monitor-test") with pytest.raises(HttpResponseError): poller.result(timeout=5) assert poller.done() @@ -186,7 +223,7 @@ def test_run_poller_stops_after_cancellation(initial_status_code: int) -> None: @pytest.mark.parametrize("initial_status_code", [201, 202]) async def test_async_run_poller_stops_after_cancellation(initial_status_code: int) -> None: operation = _operation_for_status("cancelled", is_async=True, initial_status_code=initial_status_code) - poller = await operation.begin_create_run("monitor-test", run={}) + poller = await operation.begin_create_run("monitor-test") with pytest.raises(HttpResponseError): await asyncio.wait_for(poller.result(), timeout=5) assert poller.polling_method().finished() @@ -200,9 +237,9 @@ def test_begin_create_run_preserves_custom_polling_method(is_async): polling_method = MagicMock() polling_method.finished.return_value = True if is_async: - poller = asyncio.run(operation.begin_create_run("monitor-test", run={}, polling=polling_method)) + poller = asyncio.run(operation.begin_create_run("monitor-test", polling=polling_method)) else: - poller = operation.begin_create_run("monitor-test", run={}, polling=polling_method) + poller = operation.begin_create_run("monitor-test", polling=polling_method) assert poller.polling_method() is polling_method polling_method.initialize.assert_called_once() operation._client.send_request.assert_not_called() @@ -213,14 +250,14 @@ def test_begin_create_run_preserves_custom_polling_method(is_async): async def test_begin_create_run_resumes_without_creating_another_run(is_async): original_operation = _operation_for_status("succeeded", is_async=is_async) if is_async: - original = await original_operation.begin_create_run("monitor-test", run={}) + original = await original_operation.begin_create_run("monitor-test") await asyncio.wait_for(original.result(), timeout=5) else: - original = original_operation.begin_create_run("monitor-test", run={}) + original = original_operation.begin_create_run("monitor-test") original.result(timeout=5) operation = _operation_for_status("succeeded", is_async=is_async) - kwargs = {"run": {}, "continuation_token": original.continuation_token()} + kwargs = {"body": {}, "continuation_token": original.continuation_token()} if is_async: poller = await operation.begin_create_run("monitor-test", **kwargs) result = await asyncio.wait_for(poller.result(), timeout=5) diff --git a/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insights_samples.py b/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insights_samples.py index 4509efca05b1..b605cd785713 100644 --- a/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insights_samples.py +++ b/sdk/ai/azure-ai-projects/tests/agent_insights/test_agent_insights_samples.py @@ -15,11 +15,13 @@ from azure.ai.projects.models import ( AgentInsight, + AgentInsightPrioritiesRead, AgentInsightRun, + AgentInsightRunInputs, AgentInsightRunResult, AgentInsightStatus, ) -from azure.ai.projects.operations import BetaAgentInsightMonitorsOperations +from azure.ai.projects.operations import AgentInsightMonitorsOperations from azure.core.exceptions import ResourceExistsError from azure.monitor.query import LogsQueryStatus @@ -66,7 +68,7 @@ def test_longest_agent_prefix_fits_service_limit(on_demand_sample): def test_cleanup_cancels_active_run(cleanup_sample): - operations = MagicMock(spec=BetaAgentInsightMonitorsOperations) + operations = MagicMock(spec=AgentInsightMonitorsOperations) operations.list_runs.side_effect = [ [AgentInsightRun({"id": "run-test", "status": "queued"})], [AgentInsightRun({"id": "run-test", "status": "cancelled"})], @@ -74,7 +76,7 @@ def test_cleanup_cancels_active_run(cleanup_sample): cleanup_sample["delete_monitor"](operations, "monitor-test") - assert operations.update.call_args.args[1].enabled is False + assert operations.update.call_args.kwargs["enabled"] is False operations.cancel_run.assert_called_once_with("monitor-test", "run-test") operations.delete.assert_called_once_with("monitor-test") cleanup_sample["time"].sleep.assert_called_once_with(10) @@ -88,7 +90,7 @@ def test_cleanup_cancels_active_run(cleanup_sample): def test_cleanup_has_bounded_wait(cleanup_sample): - operations = MagicMock(spec=BetaAgentInsightMonitorsOperations) + operations = MagicMock(spec=AgentInsightMonitorsOperations) operations.list_runs.return_value = [SimpleNamespace(id="run-test", status="in_progress")] with pytest.raises(TimeoutError, match="could not be deleted"): @@ -101,7 +103,7 @@ def test_cleanup_has_bounded_wait(cleanup_sample): def test_cleanup_handles_run_dispatch_during_delete(cleanup_sample): - operations = MagicMock(spec=BetaAgentInsightMonitorsOperations) + operations = MagicMock(spec=AgentInsightMonitorsOperations) operations.list_runs.side_effect = [ [], [SimpleNamespace(id="run-test", status="queued")], @@ -116,7 +118,7 @@ def test_cleanup_handles_run_dispatch_during_delete(cleanup_sample): def test_cleanup_handles_run_finishing_during_cancel(cleanup_sample): - operations = MagicMock(spec=BetaAgentInsightMonitorsOperations) + operations = MagicMock(spec=AgentInsightMonitorsOperations) terminal_run = AgentInsightRun({"id": "run-test", "status": "succeeded"}) operations.list_runs.side_effect = [ [AgentInsightRun({"id": "run-test", "status": "queued"})], @@ -132,7 +134,7 @@ def test_cleanup_handles_run_finishing_during_cancel(cleanup_sample): def test_cleanup_repeated_delete_conflict_is_bounded(cleanup_sample): - operations = MagicMock(spec=BetaAgentInsightMonitorsOperations) + operations = MagicMock(spec=AgentInsightMonitorsOperations) operations.list_runs.return_value = [] error = ResourceExistsError("Monitor still has an active run") operations.delete.side_effect = error @@ -148,7 +150,7 @@ def test_cleanup_repeated_delete_conflict_is_bounded(cleanup_sample): @pytest.fixture(name="on_demand_main") def _on_demand_main(on_demand_sample, monkeypatch): main = on_demand_sample["main"] - operations = MagicMock(spec=BetaAgentInsightMonitorsOperations) + operations = MagicMock(spec=AgentInsightMonitorsOperations) operations.list.return_value = [SimpleNamespace(id="old-monitor")] operations.create.return_value = SimpleNamespace( id="new-monitor", agent_name="test-agent", enabled=False, run_interval_hours=6 @@ -176,7 +178,7 @@ def _on_demand_main(on_demand_sample, monkeypatch): operations.update_insight.return_value = AgentInsight({**insight, "status": "resolved"}) client = MagicMock() project = client.return_value.__enter__.return_value - project.beta.agent_insight_monitors = operations + project.agent_insight_monitors = operations project.agents.create_version.return_value = SimpleNamespace(name="test-agent", version="1") monkeypatch.setitem(main.__globals__, "AIProjectClient", client) monkeypatch.setitem(main.__globals__, "DefaultAzureCredential", MagicMock()) @@ -191,6 +193,69 @@ def _on_demand_main(on_demand_sample, monkeypatch): return main, operations +@pytest.mark.parametrize("has_inputs", [False, True]) +def test_on_demand_uses_ga_priorities_and_filters(on_demand_main, capsys, has_inputs): + main, operations = on_demand_main + operations.get_run.return_value = AgentInsightRun( + status="succeeded", + inputs=AgentInsightRunInputs(lookback_hours=3.0) if has_inputs else None, + ) + + main() + + creation = operations.create.call_args.kwargs + assert creation["agent_name"] == "test-agent" + assert creation["model_deployment_name"] == "test-model" + assert creation["priorities"].as_dict() == { + "categories": [], + "instructions": "Focus on tool calls made without the user's approval.", + } + operations.list_insights.assert_called_once_with( + "new-monitor", statuses=[AgentInsightStatus.ACTIVE], include_details=True + ) + output = capsys.readouterr().out + assert ("Lookback hours: 3.0" in output) is has_inputs + + +@pytest.mark.parametrize("has_priorities", [False, True]) +def test_scheduled_sample_replaces_ga_priorities(scheduled_sample, on_demand_main, monkeypatch, capsys, has_priorities): + main = scheduled_sample["main"] + configured_main, operations = on_demand_main + for name in ( + "AIProjectClient", + "DefaultAzureCredential", + "load_dotenv", + "LogsQueryClient", + "seed_traces", + "wait_for_ingestion", + ): + monkeypatch.setitem(main.__globals__, name, configured_main.__globals__[name]) + instructions = "Focus on tool calls made without the user's approval." + operations.update.side_effect = [ + SimpleNamespace( + enabled=True, + run_interval_hours=6, + next_scheduled_run_at="2026-11-07T06:00:00+00:00", + priorities=AgentInsightPrioritiesRead(categories=[], instructions=instructions) if has_priorities else None, + ), + None, + ] + + main() + + update = operations.update.call_args_list[0] + assert update.args == ("new-monitor",) + assert update.kwargs["enabled"] is True + assert update.kwargs["run_interval_hours"] == 6 + assert update.kwargs["priorities"].as_dict() == { + "categories": [], + "instructions": instructions, + } + output = capsys.readouterr().out + assert_agent_insights_output("sample_agent_insights_scheduled.py", output.splitlines()) + assert (f"Analysis guidance: {instructions}" in output) is has_priorities + + @pytest.mark.parametrize("polling_error", [RuntimeError("Polling failed"), KeyboardInterrupt()]) def test_on_demand_cleans_up_after_polling_error(on_demand_main, polling_error, capsys): main, operations = on_demand_main @@ -202,7 +267,7 @@ def test_on_demand_cleans_up_after_polling_error(on_demand_main, polling_error, operations.list.assert_not_called() operations.cancel_run.assert_not_called() operations.delete.assert_called_once_with("new-monitor") - assert operations.update.call_args.args[1].enabled is False + assert operations.update.call_args.kwargs["enabled"] is False operations.list_runs.assert_called_once() project = main.__globals__["AIProjectClient"].return_value.__enter__.return_value project.agents.delete.assert_called_once_with("test-agent", force=True) @@ -222,7 +287,7 @@ def test_on_demand_accepts_future_severity(on_demand_main, capsys): assert any("severity=future-severity," in line for line in output) operations.update_insight.assert_called_once() assert operations.update_insight.call_args.args[:2] == ("new-monitor", "insight-test") - assert operations.update_insight.call_args.args[2].status == "resolved" + assert operations.update_insight.call_args.kwargs["status"] == "resolved" def test_on_demand_reports_no_insights(on_demand_main, capsys): @@ -292,9 +357,9 @@ def test_scheduled_sample_cleans_up_after_configuration_error( cleanup.assert_called_once_with(operations, "new-monitor", scheduled=True) operations.list.assert_not_called() - assert operations.create.call_args.args[0].enabled is False - assert operations.update.call_args.args[1].run_interval_hours == 6 - assert operations.update.call_args.args[1].enabled is True + assert operations.create.call_args.kwargs["enabled"] is False + assert operations.update.call_args.kwargs["run_interval_hours"] == 6 + assert operations.update.call_args.kwargs["enabled"] is True project.agents.delete.assert_called_once_with("test-agent", force=True) assert project.mock_calls.index( call.cleanup_monitor(operations, "new-monitor", scheduled=True) diff --git a/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py b/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py index 884e69e74542..950de4858274 100644 --- a/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py +++ b/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py @@ -35,7 +35,6 @@ # If a new sub-client is added to .beta and is missing from this mapping, the test will # fail at collection time with a message asking you to add it here. EXPECTED_FOUNDRY_FEATURES: dict[str, str] = { - "agent_insight_monitors": "AgentInsights=V1Preview", "evaluation_taxonomies": "Evaluations=V1Preview", "evaluators": "Evaluations=V1Preview", "insights": "Insights=V1Preview",