diff --git a/sdk/ai/azure-ai-projects/.env.template b/sdk/ai/azure-ai-projects/.env.template index ca5a9a9beb85..0ce12f86ba09 100644 --- a/sdk/ai/azure-ai-projects/.env.template +++ b/sdk/ai/azure-ai-projects/.env.template @@ -9,10 +9,15 @@ # 3. Run the tests (`pytest`) or run samples in the `samples` folder # +# Set to true for console logging +AZURE_AI_PROJECTS_CONSOLE_LOGGING= + ####################################################################### # # Used in samples # +####################################################################### + # Project endpoint has the format: # `https://.services.ai.azure.com/api/projects/` AZURE_AI_PROJECT_ENDPOINT= @@ -23,12 +28,8 @@ CONNECTION_NAME= AZURE_AI_PROJECTS_AZURE_SUBSCRIPTION_ID= AZURE_AI_PROJECTS_AZURE_RESOURCE_GROUP= AZURE_AI_PROJECTS_AZURE_AOAI_ACCOUNT= - -# Used in Memory Store samples MEMORY_STORE_CHAT_MODEL_DEPLOYMENT_NAME= MEMORY_STORE_EMBEDDING_MODEL_DEPLOYMENT_NAME= - -# Used in Agent tools samples IMAGE_GENERATION_MODEL_DEPLOYMENT_NAME= BING_PROJECT_CONNECTION_ID= MCP_PROJECT_CONNECTION_ID= @@ -50,6 +51,7 @@ A2A_USER_INPUT= ####################################################################### # # Used in tests +# ####################################################################### # Used for recording or playback @@ -67,4 +69,12 @@ AZURE_SUBSCRIPTION_ID= AZURE_RESOURCE_GROUP= # Set to true to run extended finetuning live tests -RUN_EXTENDED_FINE_TUNING_LIVE_TESTS=false \ No newline at end of file +RUN_EXTENDED_FINE_TUNING_LIVE_TESTS=false + +# Used for logging in sample tests (uncomment to generate logs for monitoring and alerting) +# - SAMPLE_TEST_ERROR_LOG: Sample crashed with an exception during execution +# - SAMPLE_TEST_FAILED_LOG: Sample ran successfully but LLM validation failed (incorrect output) +# - SAMPLE_TEST_PASSED_LOG: Sample ran successfully and LLM validation passed (correct output) +# SAMPLE_TEST_PASSED_LOG=_success_.log +# SAMPLE_TEST_FAILED_LOG=_failed_.log +# SAMPLE_TEST_ERROR_LOG=_errors_.log \ No newline at end of file diff --git a/sdk/ai/azure-ai-projects/CHANGELOG.md b/sdk/ai/azure-ai-projects/CHANGELOG.md index a67bcac87415..ccc12ed76e39 100644 --- a/sdk/ai/azure-ai-projects/CHANGELOG.md +++ b/sdk/ai/azure-ai-projects/CHANGELOG.md @@ -21,7 +21,10 @@ * Rename class `MemorySearchTool` to `MemorySearchPreviewTool`. * Rename class `MicrosoftFabricAgentTool` to `MicrosoftFabricPreviewTool`. * Rename class `SharepointAgentTool` to `SharepointPreviewTool`. -* Rename class `ItemParam` to `InputItem`. +* Other class renames: + * Rename class `ItemParam` to `InputItem`. + * Rename class `PromptAgentDefinitionText` to `PromptAgentDefinitionTextOptions` + * Rename class `EvaluationComparisonRequest` to `InsightRequest` * Tracing: workflow actions in conversation item listings are now emitted as "gen_ai.conversation.item" events (with role="workflow") instead of "gen_ai.workflow.action" events in the list_conversation_items span. * Tracing: response generation span names changed from "responses {model_name}" to "chat {model_name}" for model calls and from "responses {agent_name}" to "invoke_agent {agent_name}" for agent calls. * Tracing: response generation operation names changed from "responses" to "chat" for model calls and from "responses" to "invoke_agent" for agent calls. @@ -30,6 +33,11 @@ * Tracing: "gen_ai.provider.name" attribute value changed to "microsoft.foundry". * Tracing: the format of the function tool call related traces in input and output messages changed to {"type": "tool_call", "id": "...", "name": "...", "arguments": {...}} and {"type": "tool_call_response", "id": "...", "result": "..."} +### Sample updates + +* Add and update samples for `AzureFunctionTool`, `WebSearchTool`, and `WebSearchPreviewTool` +* All samples for agent tools call `responses.create` API with `agent_reference` instead of `agent` + ## 2.0.0b3 (2026-01-06) ### Features Added diff --git a/sdk/ai/azure-ai-projects/README.md b/sdk/ai/azure-ai-projects/README.md index 86e711138dcb..e125dd6ce87a 100644 --- a/sdk/ai/azure-ai-projects/README.md +++ b/sdk/ai/azure-ai-projects/README.md @@ -8,6 +8,7 @@ resources in your Microsoft Foundry Project. Use it to: * Agent Memory Search * Agent-to-Agent (A2A) * Azure AI Search + * Azure Functions * Bing Custom Search * Bing Grounding * Browser Automation @@ -20,7 +21,7 @@ resources in your Microsoft Foundry Project. Use it to: * Model Context Protocol (MCP) * OpenAPI * SharePoint - * Web Search + * Web Search/Web Search Preview * **Get an OpenAI client** using `.get_openai_client()` method to run Responses, Conversations, Evals and FineTuning operations with your Agent. * **Manage memory stores** for Agent conversations, using the `.memory_stores` operations. * **Explore additional evaluation tools** to assess the performance of your generative AI application, using the `.evaluation_rules`, @@ -32,7 +33,7 @@ resources in your Microsoft Foundry Project. Use it to: * **Upload documents and create Datasets** to reference them using the `.datasets` operations. * **Create and enumerate Search Indexes** using methods the `.indexes` operations. -The client library uses version `2025-11-15-preview` of the AI Foundry [data plane REST APIs](https://aka.ms/azsdk/azure-ai-projects-v2/api-reference-2025-11-15-preview). +The client library uses version `v1` of the AI Foundry [data plane REST APIs](https://aka.ms/azsdk/azure-ai-projects-v2/api-reference-v1). [Product documentation](https://aka.ms/azsdk/azure-ai-projects-v2/product-doc) | [Samples][samples] @@ -64,12 +65,6 @@ To report an issue with the client library, or request additional features, plea pip install --pre azure-ai-projects ``` -Note that the packages [openai](https://pypi.org/project/openai) and [azure-identity](https://pypi.org/project/azure-identity) also need to be installed if you intend to call `get_openai_client()`: - -```bash -pip install openai azure-identity -``` - ## Key concepts ### Create and authenticate the client with Entra ID @@ -167,8 +162,7 @@ with project_client.get_openai_client() as openai_client: response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -180,8 +174,7 @@ with project_client.get_openai_client() as openai_client: response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -208,8 +201,35 @@ These tools work immediately without requiring external connections. Write and run Python code in a sandboxed environment, process files and work with diverse data formats. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-code-interpreter) +Basic tool declaration (no input files): + +```python +tool = CodeInterpreterTool() +``` + + + +See the basic sample in file `\agents\tools\sample_agent_code_interpreter.py` in the [Samples][samples] folder. + +After calling `responses.create()`, you can extract the code behind the scene from +the `code_interpreter_call` output item: + + + +```python +code = next((output.code for output in response.output if output.type == "code_interpreter_call"), "") +print(f"Code Interpreter code:") +print(code) +``` + + + +If you want to upload an input file and download generated output files, use the with-files sample: + + + ```python # Load the CSV file to be processed asset_file_path = os.path.abspath( @@ -225,7 +245,7 @@ tool = CodeInterpreterTool(container=CodeInterpreterContainerAuto(file_ids=[file *After calling `responses.create()`, check for generated files in response annotations (type `container_file_citation`) and download them using `openai_client.containers.files.content.retrieve()`.* -See the full sample in file `\agents\tools\sample_agent_code_interpreter.py` in the [Samples][samples] folder. +See the with-files sample in file `\agents\tools\sample_agent_code_interpreter_with_files.py` in the [Samples][samples] folder. **File Search** @@ -261,8 +281,8 @@ Generate images based on text prompts with customizable resolution, quality, and ```python -tool = ImageGenTool( # type: ignore[call-overload] - model=image_generation_model, # Model such as "gpt-image-1-mini" # type: ignore +tool = ImageGenTool( + model=image_generation_model, # Model such as "gpt-image-1" quality="low", size="1024x1024", ) @@ -277,7 +297,7 @@ After calling `responses.create()`, you can download file using the returned res image_data = [output.result for output in response.output if output.type == "image_generation_call"] if image_data and image_data[0]: print("Downloading generated image...") - filename = "microsoft.png" + filename = "happy-dogs.png" file_path = os.path.join(tempfile.gettempdir(), filename) with open(file_path, "wb") as f: @@ -288,20 +308,50 @@ if image_data and image_data[0]: See the full sample in file `\agents\tools\sample_agent_image_generation.py` in the [Samples][samples] folder. -**Web Search** +**Web Search/Web Search Preview** -Perform general web searches to retrieve current information from the internet. [OpenAI Documentation](https://platform.openai.com/docs/guides/tools-web-search) +Discover up-to-date web content with the GA Web Search tool or try the Web Search Preview tool for the latest enhancements. Guidance on when to use each option is in the documentation: https://learn.microsoft.com/azure/ai-foundry/agents/how-to/tools/web-overview?view=foundry#determine-the-best-tool-for-your-use-cases. ```python -tool = WebSearchPreviewTool(user_location=ApproximateLocation(country="GB", city="London", region="London")) +tool = WebSearchTool( + user_location=WebSearchApproximateLocation(type="approximate", country="GB", city="London", region="London") +) ``` See the full sample in file `\agents\tools\sample_agent_web_search.py` in the [Samples][samples] folder. + + +```python +tool = WebSearchPreviewTool(user_location=ApproximateLocation(country="GB", city="London", region="London")) +``` + + + +See the full sample in file `\agents\tools\sample_agent_web_search_preview.py` in the [Samples][samples] folder. + +Use the GA Web Search tool with a Bing Custom Search connection to scope results to your custom search instance: + + + +```python +tool = WebSearchTool( + custom_search_configuration=WebSearchConfiguration( + project_connection_id=os.environ["BING_CUSTOM_SEARCH_PROJECT_CONNECTION_ID"], + instance_name=os.environ["BING_CUSTOM_SEARCH_INSTANCE_NAME"], + ) +) +``` + + + +See the full sample in file `\agents\tools\sample_agent_web_search_with_custom_search.py` in the [Samples][samples] folder. + + **Computer Use** Enable agents to interact directly with computer systems for task automation and system operations: @@ -346,7 +396,7 @@ Call external APIs defined by OpenAPI specifications without additional client-s ```python with open(weather_asset_file_path, "r") as f: - openapi_weather = jsonref.loads(f.read()) + openapi_weather = cast(dict[str, Any], jsonref.loads(f.read())) tool = OpenApiTool( openapi=OpenApiFunctionDefinition( @@ -393,6 +443,45 @@ tool = FunctionTool( See the full sample in file `\agents\tools\sample_agent_function_tool.py` in the [Samples][samples] folder. +**Azure Functions** + +Integrate Azure Functions with agents to extend capabilities via serverless compute. Functions are invoked through Azure Storage Queue triggers, allowing asynchronous execution of custom logic. + + + +```python +tool = AzureFunctionTool( + azure_function=AzureFunctionDefinition( + input_binding=AzureFunctionBinding( + storage_queue=AzureFunctionStorageQueue( + queue_name=os.environ["STORAGE_INPUT_QUEUE_NAME"], + queue_service_endpoint=os.environ["STORAGE_QUEUE_SERVICE_ENDPOINT"], + ) + ), + output_binding=AzureFunctionBinding( + storage_queue=AzureFunctionStorageQueue( + queue_name=os.environ["STORAGE_OUTPUT_QUEUE_NAME"], + queue_service_endpoint=os.environ["STORAGE_QUEUE_SERVICE_ENDPOINT"], + ) + ), + function=AzureFunctionDefinitionFunction( + name="queue_trigger", + description="Get weather for a given location", + parameters={ + "type": "object", + "properties": {"location": {"type": "string", "description": "location to determine weather for"}}, + }, + ), + ) +) +``` + + + +*After calling `responses.create()`, the agent enqueues function arguments to the input queue. Your Azure Function processes the request and returns results via the output queue.* + +See the full sample in file `\agents\tools\sample_agent_azure_function.py` and the Azure Function implementation in `\agents\tools\get_weather_func_app.py` in the [Samples][samples] folder. + * **Memory Search Tool** The Memory Store Tool adds Memory to an Agent, allowing the Agent's AI model to search for past information related to the current user prompt. @@ -594,7 +683,7 @@ Call external APIs defined by OpenAPI specifications using project connection au ```python with open(tripadvisor_asset_file_path, "r") as f: - openapi_tripadvisor = jsonref.loads(f.read()) + openapi_tripadvisor = cast(dict[str, Any], jsonref.loads(f.read())) tool = OpenApiTool( openapi=OpenApiFunctionDefinition( @@ -936,7 +1025,7 @@ fine_tuning_job = openai_client.fine_tuning.jobs.create( "trainingType": "GlobalStandard" }, # Recommended approach to set trainingType. Omitting this field may lead to unsupported behavior. # Preferred trainingtype is GlobalStandard. Note: Global training offers cost savings , but copies data and weights outside the current resource region. - # Learn more - https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/ and https://azure.microsoft.com/en-us/explore/global-infrastructure/data-residency/ + # Learn more - https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/ and https://azure.microsoft.com/explore/global-infrastructure/data-residency/ ) print(fine_tuning_job) ``` @@ -954,7 +1043,7 @@ You can add an Application Insights Azure resource to your Microsoft Foundry pro Make sure to install OpenTelemetry and the Azure SDK tracing plugin via ```bash -pip install "azure-ai-projects>=2.0.0b1" azure-identity opentelemetry-sdk azure-core-tracing-opentelemetry azure-monitor-opentelemetry +pip install "azure-ai-projects>=2.0.0b4" opentelemetry-sdk azure-core-tracing-opentelemetry azure-monitor-opentelemetry ``` You will also need an exporter to send telemetry to your observability backend. You can print traces to the console or use a local viewer such as [Aspire Dashboard](https://learn.microsoft.com/dotnet/aspire/fundamentals/dashboard/standalone?tabs=bash). diff --git a/sdk/ai/azure-ai-projects/_metadata.json b/sdk/ai/azure-ai-projects/_metadata.json index 509044270b48..3a000fe50d57 100644 --- a/sdk/ai/azure-ai-projects/_metadata.json +++ b/sdk/ai/azure-ai-projects/_metadata.json @@ -1,3 +1,6 @@ { - "apiVersion": "2025-11-15-preview" + "apiVersion": "v1", + "apiVersions": { + "Azure.AI.Projects": "v1" + } } \ No newline at end of file diff --git a/sdk/ai/azure-ai-projects/_tsp-location.yaml b/sdk/ai/azure-ai-projects/_tsp-location.yaml deleted file mode 100644 index 00631b52071a..000000000000 --- a/sdk/ai/azure-ai-projects/_tsp-location.yaml +++ /dev/null @@ -1,4 +0,0 @@ -directory: specification/ai/Foundry -commit: 51415f0131fc0e65f88e8a75b4b729a528e8e959 -repo: Azure/azure-rest-api-specs -additionalDirectories: diff --git a/sdk/ai/azure-ai-projects/agent-scripts/patch_foundry_features_args.py b/sdk/ai/azure-ai-projects/agent-scripts/patch_foundry_features_args.py new file mode 100644 index 000000000000..460053db63e9 --- /dev/null +++ b/sdk/ai/azure-ai-projects/agent-scripts/patch_foundry_features_args.py @@ -0,0 +1,358 @@ +# pylint: disable=line-too-long,useless-suppression +#!/usr/bin/env python3 +""" +Patch script to modify foundry_features arguments in operations files. + +This script: +1. Finds all public methods with required 'foundry_features' input arguments +2. Removes the argument from method signatures and docstrings +3. Adds an assignment at the start of the method body +4. Skips internal helper methods with names starting with 'build_beta_' +""" + +import re +from pathlib import Path +from typing import List, Dict, Tuple, Optional + +# Files to process +FILES_TO_PROCESS = [ + r"azure\ai\projects\aio\operations\_operations.py", + r"azure\ai\projects\operations\_operations.py", +] + + +def is_decorated_method(lines: List[str], line_idx: int) -> Tuple[bool, Optional[str]]: + """ + Check if the current line is preceded by a relevant decorator. + Returns (is_decorated, decorator_name). + """ + # Look back for decorator + for i in range(line_idx - 1, max(0, line_idx - 10), -1): + stripped = lines[i].strip() + if stripped.startswith("@distributed_trace_async"): + return True, "distributed_trace_async" + elif stripped.startswith("@distributed_trace") and not "async" in stripped: + return True, "distributed_trace" + elif stripped.startswith("@overload"): + return True, "overload" + elif stripped.startswith("def ") or stripped.startswith("async def ") or stripped.startswith("class "): + break + elif stripped == "" or stripped.startswith("#"): + continue + return False, None + + +def extract_foundry_value(signature: str) -> Optional[str]: + """Extract the FoundryFeaturesOptInKeys value from a signature.""" + match = re.search(r"foundry_features:\s*Literal\[FoundryFeaturesOptInKeys\.(\w+)\]", signature) + if match: + return match.group(1) + return None + + +def has_optional_foundry_features(signature: str) -> bool: + """Check if foundry_features is Optional in the signature.""" + return bool(re.search(r"foundry_features:\s*Optional\[", signature)) + + +def remove_foundry_features_from_lines(sig_lines: List[str]) -> List[str]: + """ + Remove the foundry_features parameter from signature lines. + Returns the modified lines. + """ + # Join lines for easier pattern matching, preserving structure + signature = "\n".join(sig_lines) + + # Pattern: line with foundry_features: Literal[FoundryFeaturesOptInKeys.XXX] + # We need to handle: + # 1. Single line: "self, name: str, *, foundry_features: Literal[...], **kwargs: Any" + # 2. Multi-line: foundry_features on its own line + + new_lines = [] + skip_star_comma = False + + for i, line in enumerate(sig_lines): + # Check if this line contains the foundry_features definition + if "foundry_features:" in line and "Literal[FoundryFeaturesOptInKeys." in line: + # This is the line to remove or modify + + # Check if it's part of a single-line signature + if ", *," in line and "**kwargs" in line: + # Pattern: "self, name: str, *, foundry_features: Literal[...], **kwargs: Any" + # Replace with: "self, name: str, **kwargs: Any" + new_line = re.sub( + r",\s*\*\s*,\s*foundry_features:\s*Literal\[FoundryFeaturesOptInKeys\.\w+\]\s*,\s*", ", ", line + ) + new_lines.append(new_line) + elif line.strip().startswith("foundry_features:"): + # foundry_features is on its own line + # Check if previous line was just "*," + if new_lines and new_lines[-1].strip() == "*,": + # Check if there are more params after this + has_more_params = False + for j in range(i + 1, len(sig_lines)): + rest = sig_lines[j].strip() + if rest and not rest.startswith(")") and not rest.startswith("**kwargs"): + has_more_params = True + break + + if not has_more_params: + # Remove the *, line too + new_lines.pop() + # Skip this foundry_features line entirely + continue + else: + # foundry_features embedded in a line with other params + # Remove just the foundry_features part + new_line = re.sub(r",?\s*foundry_features:\s*Literal\[FoundryFeaturesOptInKeys\.\w+\]\s*,?", "", line) + # Clean up resulting issues + new_line = re.sub(r",\s*,", ",", new_line) + new_line = re.sub(r",\s*\)", ")", new_line) + new_line = re.sub(r"\(\s*,", "(", new_line) + if new_line.strip(): + new_lines.append(new_line) + continue + else: + new_lines.append(line) + + # Clean up: if we have "*, " at end of a line followed by "**kwargs", merge nicely + result = "\n".join(new_lines) + # Remove empty *, line followed by **kwargs + result = re.sub(r"\n\s*\*\s*,\s*\n(\s*\*\*kwargs)", r"\n\1", result) + + return result.split("\n") + + +def remove_foundry_features_from_docstring_lines(doc_lines: List[str]) -> List[str]: + """Remove foundry_features documentation from docstring lines.""" + new_lines = [] + skip_continuation = False + + for line in doc_lines: + # Check for :keyword foundry_features: + if ":keyword foundry_features:" in line: + skip_continuation = True + continue + + # Check for :paramtype foundry_features: + if ":paramtype foundry_features:" in line: + continue + + # Check if this is a continuation line for foundry_features + if skip_continuation: + stripped = line.strip() + if stripped.startswith(":") or stripped.startswith('"""') or not stripped: + skip_continuation = False + else: + continue + + new_lines.append(line) + + return new_lines + + +def process_file(filepath: str) -> List[Dict]: + """Process a single file to patch foundry_features arguments.""" + + with open(filepath, "r", encoding="utf-8") as f: + lines = f.readlines() + + # Convert to list without newlines for easier processing + lines = [line.rstrip("\n") for line in lines] + original_lines = lines.copy() + + modified_methods = [] + i = 0 + + while i < len(lines): + line = lines[i] + stripped = line.strip() + + # Check for decorated method start + if stripped.startswith(("@distributed_trace", "@overload")): + decorator = None + if "@distributed_trace_async" in stripped: + decorator = "distributed_trace_async" + elif "@distributed_trace" in stripped: + decorator = "distributed_trace" + elif "@overload" in stripped: + decorator = "overload" + + decorator_idx = i + + # Find the def line + i += 1 + while i < len(lines) and not lines[i].strip().startswith(("def ", "async def ")): + i += 1 + + if i >= len(lines): + continue + + def_idx = i + def_line = lines[i] + + # Extract method name + method_match = re.match(r"\s*(async\s+)?def\s+(\w+)", def_line) + if not method_match: + i += 1 + continue + + method_name = method_match.group(2) + + # Skip build_ functions + if method_name.startswith("build_"): + i += 1 + continue + + # Collect the full signature (may span multiple lines) + sig_start = i + paren_count = def_line.count("(") - def_line.count(")") + i += 1 + + while paren_count > 0 and i < len(lines): + paren_count += lines[i].count("(") - lines[i].count(")") + i += 1 + + sig_end = i - 1 + sig_lines = lines[sig_start : sig_end + 1] + signature = "\n".join(sig_lines) + + # Check if this has required foundry_features + foundry_value = extract_foundry_value(signature) + if not foundry_value or has_optional_foundry_features(signature): + continue + + # Remove foundry_features from signature + new_sig_lines = remove_foundry_features_from_lines(sig_lines) + + # Replace signature in lines + lines = lines[:sig_start] + new_sig_lines + lines[sig_end + 1 :] + + # Adjust i to account for potential line count change + new_sig_end = sig_start + len(new_sig_lines) - 1 + i = new_sig_end + 1 + + # Find and process docstring for ALL methods (including overloads) + doc_start = None + doc_end = None + + for idx in range(i, min(i + 5, len(lines))): + if '"""' in lines[idx]: + doc_start = idx + if lines[idx].count('"""') >= 2: + doc_end = idx + else: + for end_idx in range(idx + 1, len(lines)): + if '"""' in lines[end_idx]: + doc_end = end_idx + break + break + + if doc_start is not None and doc_end is not None: + # Remove foundry_features from docstring + doc_lines = lines[doc_start : doc_end + 1] + new_doc_lines = remove_foundry_features_from_docstring_lines(doc_lines) + + # Replace docstring + lines = lines[:doc_start] + new_doc_lines + lines[doc_end + 1 :] + doc_end = doc_start + len(new_doc_lines) - 1 + + # For main methods (not overloads), add assignment after docstring + if decorator != "overload": + if doc_end is not None: + insert_idx = doc_end + 1 + + # Determine indentation + if insert_idx < len(lines): + next_line = lines[insert_idx] + indent_match = re.match(r"^(\s+)", next_line) + indent = indent_match.group(1) if indent_match else " " + else: + indent = " " + + # Insert the assignment with type annotation for mypy compatibility + assignment = f"{indent}foundry_features: Literal[FoundryFeaturesOptInKeys.{foundry_value}] = FoundryFeaturesOptInKeys.{foundry_value}" + lines.insert(insert_idx, assignment) + i = insert_idx + 1 + + # Track this method + if not any( + m["method_name"] == method_name and m["foundry_value"] == foundry_value for m in modified_methods + ): + modified_methods.append( + { + "method_name": method_name, + "foundry_value": foundry_value, + "file": filepath, + } + ) + + continue + + i += 1 + + # Write back if changed + if lines != original_lines: + with open(filepath, "w", encoding="utf-8") as f: + f.write("\n".join(lines)) + + return modified_methods + + +def main(): + """Main entry point.""" + script_dir = Path(__file__).parent + + all_modified = [] + + for rel_path in FILES_TO_PROCESS: + filepath = script_dir / rel_path + if not filepath.exists(): + print(f"Warning: File not found: {filepath}") + continue + + print(f"\nProcessing: {filepath}") + + modified = process_file(str(filepath)) + all_modified.extend(modified) + + print(f" Modified {len(modified)} methods") + + # Print summary + print("\n" + "=" * 60) + print("SUMMARY REPORT") + print("=" * 60) + + if not all_modified: + print("No methods were modified.") + else: + # Group by file + by_file = {} + for m in all_modified: + fname = Path(m["file"]).name + if fname not in by_file: + by_file[fname] = [] + by_file[fname].append(m) + + for fname, methods in by_file.items(): + print(f"\n{fname}:") + print("-" * 40) + + # Group by foundry value + by_value = {} + for m in methods: + v = m["foundry_value"] + if v not in by_value: + by_value[v] = [] + by_value[v].append(m["method_name"]) + + for value, method_names in sorted(by_value.items()): + print(f"\n FoundryFeaturesOptInKeys.{value}:") + for name in sorted(set(method_names)): + print(f" - {name}") + + print(f"\nTotal methods modified: {len(all_modified)}") + + +if __name__ == "__main__": + main() diff --git a/sdk/ai/azure-ai-projects/agent-scripts/patch_foundry_features_args.readme.txt b/sdk/ai/azure-ai-projects/agent-scripts/patch_foundry_features_args.readme.txt new file mode 100644 index 000000000000..42387cbf743c --- /dev/null +++ b/sdk/ai/azure-ai-projects/agent-scripts/patch_foundry_features_args.readme.txt @@ -0,0 +1,42 @@ +These are the GitHub CoPilot instructions used to edit emitted code, in order to set the +required Foundry-Features HTTP request header in preview operations. Before running the Agent, +make sure your package sources code (files under \sdk\ai\azure-ai-projects\azure) do not have any +mypy errors. + +The agent created the Python script "patch_foundry_features_args.py" in this folder. Next time +you re-emit from TypeSpec, try running that script from the \sdk\ai\azure-ai-projects folder +and see if again it did the job correctly. + +Last updated: 2/11/2026 + +----------------------------- + +I would like you to create a Python script named "patch_foundry_features_args.py" that you will +run to do the work described below. Save the script to the folder \azure-sdk-for-python\sdk\ai\azure-ai-projects. +The work that needs to be done is the following: +Edit these two Python source files, and only these two: +\sdk\ai\azure-ai-projects\azure\ai\projects\aio\operations\_operations.py and +\sdk\ai\azure-ai-projects\azure\ai\projects\operations\_operations.py. +Find all the public methods that have a required input argument named "foundry_features" (note that some method +will have "foundry_features" as an optional input argument. Ignore those). An example of such a method is one that +has the following in the method signature: +foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] +For each of the public methods that have a required input argument named "foundry_features", +remove the input argument from the method signature and the corresponding document strings. +Instead, update the method itself, and set the value of "foundry_features" to the value shown in the +method signature. In the example above, that operation will look like this: +foundry_features = FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW. +Do not modify any of the internal helper methods with names that start with "build_beta_". +At the end, show a summary report of all the methods you edited, and which FoundryFeaturesOptInKeys +value was used for each method. +Once you are done updating the Python files, run the "black" tool in the following way to fix any +format issues: +black --config ../../../eng/black-pyproject.toml . +To verify your result, run the mypy tool and make sure there are no errors originating +from the package source file. This means that when you go to the folder: +\azure-sdk-for-python\sdk\ai\azure-ai-projects\ +and run: +tox run -e mypy -c ../../../eng/tox/tox.ini --root +there will be no errors from files under the folder \azure-sdk-for-python\sdk\ai\azure-ai-projects\azure folder. + + diff --git a/sdk/ai/azure-ai-projects/apiview-properties.json b/sdk/ai/azure-ai-projects/apiview-properties.json index bfc2a677bb06..741b0c8569e6 100644 --- a/sdk/ai/azure-ai-projects/apiview-properties.json +++ b/sdk/ai/azure-ai-projects/apiview-properties.json @@ -3,36 +3,32 @@ "CrossLanguageDefinitionId": { "azure.ai.projects.models.Tool": "OpenAI.Tool", "azure.ai.projects.models.A2APreviewTool": "Azure.AI.Projects.A2APreviewTool", + "azure.ai.projects.models.InsightRequest": "Azure.AI.Projects.InsightRequest", + "azure.ai.projects.models.AgentClusterInsightRequest": "Azure.AI.Projects.AgentClusterInsightRequest", "azure.ai.projects.models.InsightResult": "Azure.AI.Projects.InsightResult", "azure.ai.projects.models.AgentClusterInsightResult": "Azure.AI.Projects.AgentClusterInsightResult", - "azure.ai.projects.models.InsightRequest": "Azure.AI.Projects.InsightRequest", - "azure.ai.projects.models.AgentClusterInsightsRequest": "Azure.AI.Projects.AgentClusterInsightsRequest", "azure.ai.projects.models.AgentDefinition": "Azure.AI.Projects.AgentDefinition", "azure.ai.projects.models.AgentDetails": "Azure.AI.Projects.AgentObject", "azure.ai.projects.models.BaseCredentials": "Azure.AI.Projects.BaseCredentials", - "azure.ai.projects.models.AgenticIdentityCredentials": "Azure.AI.Projects.AgenticIdentityCredentials", - "azure.ai.projects.models.AgentId": "Azure.AI.Projects.AgentId", + "azure.ai.projects.models.AgenticIdentityPreviewCredentials": "Azure.AI.Projects.AgenticIdentityPreviewCredentials", "azure.ai.projects.models.AgentObjectVersions": "Azure.AI.Projects.AgentObject.versions.anonymous", - "azure.ai.projects.models.AgentReference": "Azure.AI.Projects.AgentReference", "azure.ai.projects.models.EvaluationTaxonomyInput": "Azure.AI.Projects.EvaluationTaxonomyInput", "azure.ai.projects.models.AgentTaxonomyInput": "Azure.AI.Projects.AgentTaxonomyInput", "azure.ai.projects.models.AgentVersionDetails": "Azure.AI.Projects.AgentVersionObject", "azure.ai.projects.models.AISearchIndexResource": "Azure.AI.Projects.AISearchIndexResource", "azure.ai.projects.models.Annotation": "OpenAI.Annotation", + "azure.ai.projects.models.ApiError": "OpenAI.Error", "azure.ai.projects.models.ApiErrorResponse": "Azure.AI.Projects.ApiErrorResponse", "azure.ai.projects.models.ApiKeyCredentials": "Azure.AI.Projects.ApiKeyCredentials", - "azure.ai.projects.models.ApplyPatchFileOperation": "OpenAI.ApplyPatchFileOperation", - "azure.ai.projects.models.ApplyPatchCreateFileOperation": "OpenAI.ApplyPatchCreateFileOperation", "azure.ai.projects.models.ApplyPatchOperationParam": "OpenAI.ApplyPatchOperationParam", "azure.ai.projects.models.ApplyPatchCreateFileOperationParam": "OpenAI.ApplyPatchCreateFileOperationParam", - "azure.ai.projects.models.ApplyPatchDeleteFileOperation": "OpenAI.ApplyPatchDeleteFileOperation", "azure.ai.projects.models.ApplyPatchDeleteFileOperationParam": "OpenAI.ApplyPatchDeleteFileOperationParam", "azure.ai.projects.models.ApplyPatchToolParam": "OpenAI.ApplyPatchToolParam", - "azure.ai.projects.models.ApplyPatchUpdateFileOperation": "OpenAI.ApplyPatchUpdateFileOperation", "azure.ai.projects.models.ApplyPatchUpdateFileOperationParam": "OpenAI.ApplyPatchUpdateFileOperationParam", "azure.ai.projects.models.ApproximateLocation": "OpenAI.ApproximateLocation", "azure.ai.projects.models.Target": "Azure.AI.Projects.Target", "azure.ai.projects.models.AzureAIAgentTarget": "Azure.AI.Projects.AzureAIAgentTarget", + "azure.ai.projects.models.AzureAIModelTarget": "Azure.AI.Projects.AzureAIModelTarget", "azure.ai.projects.models.Index": "Azure.AI.Projects.Index", "azure.ai.projects.models.AzureAISearchIndex": "Azure.AI.Projects.AzureAISearchIndex", "azure.ai.projects.models.AzureAISearchTool": "Azure.AI.Projects.AzureAISearchTool", @@ -80,7 +76,6 @@ "azure.ai.projects.models.EvaluationRuleAction": "Azure.AI.Projects.EvaluationRuleAction", "azure.ai.projects.models.ContinuousEvaluationRuleAction": "Azure.AI.Projects.ContinuousEvaluationRuleAction", "azure.ai.projects.models.CosmosDBIndex": "Azure.AI.Projects.CosmosDBIndex", - "azure.ai.projects.models.CreatedBy": "Azure.AI.Projects.CreatedBy", "azure.ai.projects.models.Trigger": "Azure.AI.Projects.Trigger", "azure.ai.projects.models.CronTrigger": "Azure.AI.Projects.CronTrigger", "azure.ai.projects.models.CustomCredential": "Azure.AI.Projects.CustomCredential", @@ -103,19 +98,18 @@ "azure.ai.projects.models.EasyInputMessage": "OpenAI.EasyInputMessage", "azure.ai.projects.models.EmbeddingConfiguration": "Azure.AI.Projects.EmbeddingConfiguration", "azure.ai.projects.models.EntraIDCredentials": "Azure.AI.Projects.EntraIDCredentials", - "azure.ai.projects.models.Error": "OpenAI.Error", - "azure.ai.projects.models.EvalCompareReport": "Azure.AI.Projects.EvalCompareReport", "azure.ai.projects.models.EvalResult": "Azure.AI.Projects.EvalResult", "azure.ai.projects.models.EvalRunResultCompareItem": "Azure.AI.Projects.EvalRunResultCompareItem", "azure.ai.projects.models.EvalRunResultComparison": "Azure.AI.Projects.EvalRunResultComparison", "azure.ai.projects.models.EvalRunResultSummary": "Azure.AI.Projects.EvalRunResultSummary", - "azure.ai.projects.models.EvaluationComparisonRequest": "Azure.AI.Projects.EvaluationComparisonRequest", + "azure.ai.projects.models.EvaluationComparisonInsightRequest": "Azure.AI.Projects.EvaluationComparisonInsightRequest", + "azure.ai.projects.models.EvaluationComparisonInsightResult": "Azure.AI.Projects.EvaluationComparisonInsightResult", "azure.ai.projects.models.InsightSample": "Azure.AI.Projects.InsightSample", "azure.ai.projects.models.EvaluationResultSample": "Azure.AI.Projects.EvaluationResultSample", "azure.ai.projects.models.EvaluationRule": "Azure.AI.Projects.EvaluationRule", "azure.ai.projects.models.EvaluationRuleFilter": "Azure.AI.Projects.EvaluationRuleFilter", + "azure.ai.projects.models.EvaluationRunClusterInsightRequest": "Azure.AI.Projects.EvaluationRunClusterInsightRequest", "azure.ai.projects.models.EvaluationRunClusterInsightResult": "Azure.AI.Projects.EvaluationRunClusterInsightResult", - "azure.ai.projects.models.EvaluationRunClusterInsightsRequest": "Azure.AI.Projects.EvaluationRunClusterInsightsRequest", "azure.ai.projects.models.ScheduleTask": "Azure.AI.Projects.ScheduleTask", "azure.ai.projects.models.EvaluationScheduleTask": "Azure.AI.Projects.EvaluationScheduleTask", "azure.ai.projects.models.EvaluationTaxonomy": "Azure.AI.Projects.EvaluationTaxonomy", @@ -133,23 +127,17 @@ "azure.ai.projects.models.FunctionAndCustomToolCallOutputInputFileContent": "OpenAI.FunctionAndCustomToolCallOutputInputFileContent", "azure.ai.projects.models.FunctionAndCustomToolCallOutputInputImageContent": "OpenAI.FunctionAndCustomToolCallOutputInputImageContent", "azure.ai.projects.models.FunctionAndCustomToolCallOutputInputTextContent": "OpenAI.FunctionAndCustomToolCallOutputInputTextContent", - "azure.ai.projects.models.FunctionShellAction": "OpenAI.FunctionShellAction", "azure.ai.projects.models.FunctionShellActionParam": "OpenAI.FunctionShellActionParam", - "azure.ai.projects.models.FunctionShellCallOutputContent": "OpenAI.FunctionShellCallOutputContent", "azure.ai.projects.models.FunctionShellCallOutputContentParam": "OpenAI.FunctionShellCallOutputContentParam", - "azure.ai.projects.models.FunctionShellCallOutputOutcome": "OpenAI.FunctionShellCallOutputOutcome", - "azure.ai.projects.models.FunctionShellCallOutputExitOutcome": "OpenAI.FunctionShellCallOutputExitOutcome", "azure.ai.projects.models.FunctionShellCallOutputOutcomeParam": "OpenAI.FunctionShellCallOutputOutcomeParam", "azure.ai.projects.models.FunctionShellCallOutputExitOutcomeParam": "OpenAI.FunctionShellCallOutputExitOutcomeParam", - "azure.ai.projects.models.FunctionShellCallOutputTimeoutOutcome": "OpenAI.FunctionShellCallOutputTimeoutOutcome", "azure.ai.projects.models.FunctionShellCallOutputTimeoutOutcomeParam": "OpenAI.FunctionShellCallOutputTimeoutOutcomeParam", "azure.ai.projects.models.FunctionShellToolParam": "OpenAI.FunctionShellToolParam", "azure.ai.projects.models.FunctionTool": "OpenAI.FunctionTool", "azure.ai.projects.models.HostedAgentDefinition": "Azure.AI.Projects.HostedAgentDefinition", "azure.ai.projects.models.HourlyRecurrenceSchedule": "Azure.AI.Projects.HourlyRecurrenceSchedule", - "azure.ai.projects.models.HumanEvaluationRuleAction": "Azure.AI.Projects.HumanEvaluationRuleAction", + "azure.ai.projects.models.HumanEvaluationPreviewRuleAction": "Azure.AI.Projects.HumanEvaluationPreviewRuleAction", "azure.ai.projects.models.HybridSearchOptions": "OpenAI.HybridSearchOptions", - "azure.ai.projects.models.ImageBasedHostedAgentDefinition": "Azure.AI.Projects.ImageBasedHostedAgentDefinition", "azure.ai.projects.models.ImageGenTool": "OpenAI.ImageGenTool", "azure.ai.projects.models.ImageGenToolInputImageMask": "OpenAI.ImageGenToolInputImageMask", "azure.ai.projects.models.InputContent": "OpenAI.InputContent", @@ -181,8 +169,6 @@ "azure.ai.projects.models.InputItemOutputMessage": "OpenAI.InputItemOutputMessage", "azure.ai.projects.models.InputItemReasoningItem": "OpenAI.InputItemReasoningItem", "azure.ai.projects.models.InputItemWebSearchToolCall": "OpenAI.InputItemWebSearchToolCall", - "azure.ai.projects.models.ItemResource": "OpenAI.ItemResource", - "azure.ai.projects.models.InputMessageResource": "OpenAI.InputMessageResource", "azure.ai.projects.models.InputTextContentParam": "OpenAI.InputTextContentParam", "azure.ai.projects.models.Insight": "Azure.AI.Projects.Insight", "azure.ai.projects.models.InsightCluster": "Azure.AI.Projects.InsightCluster", @@ -191,25 +177,6 @@ "azure.ai.projects.models.InsightsMetadata": "Azure.AI.Projects.InsightsMetadata", "azure.ai.projects.models.InsightSummary": "Azure.AI.Projects.InsightSummary", "azure.ai.projects.models.ItemReferenceParam": "OpenAI.ItemReferenceParam", - "azure.ai.projects.models.ItemResourceApplyPatchToolCall": "OpenAI.ItemResourceApplyPatchToolCall", - "azure.ai.projects.models.ItemResourceApplyPatchToolCallOutput": "OpenAI.ItemResourceApplyPatchToolCallOutput", - "azure.ai.projects.models.ItemResourceCodeInterpreterToolCall": "OpenAI.ItemResourceCodeInterpreterToolCall", - "azure.ai.projects.models.ItemResourceComputerToolCall": "OpenAI.ItemResourceComputerToolCall", - "azure.ai.projects.models.ItemResourceComputerToolCallOutputResource": "OpenAI.ItemResourceComputerToolCallOutputResource", - "azure.ai.projects.models.ItemResourceFileSearchToolCall": "OpenAI.ItemResourceFileSearchToolCall", - "azure.ai.projects.models.ItemResourceFunctionShellCall": "OpenAI.ItemResourceFunctionShellCall", - "azure.ai.projects.models.ItemResourceFunctionShellCallOutput": "OpenAI.ItemResourceFunctionShellCallOutput", - "azure.ai.projects.models.ItemResourceFunctionToolCallOutputResource": "OpenAI.ItemResourceFunctionToolCallOutputResource", - "azure.ai.projects.models.ItemResourceFunctionToolCallResource": "OpenAI.ItemResourceFunctionToolCallResource", - "azure.ai.projects.models.ItemResourceImageGenToolCall": "OpenAI.ItemResourceImageGenToolCall", - "azure.ai.projects.models.ItemResourceLocalShellToolCall": "OpenAI.ItemResourceLocalShellToolCall", - "azure.ai.projects.models.ItemResourceLocalShellToolCallOutput": "OpenAI.ItemResourceLocalShellToolCallOutput", - "azure.ai.projects.models.ItemResourceMcpApprovalRequest": "OpenAI.ItemResourceMcpApprovalRequest", - "azure.ai.projects.models.ItemResourceMcpApprovalResponseResource": "OpenAI.ItemResourceMcpApprovalResponseResource", - "azure.ai.projects.models.ItemResourceMcpListTools": "OpenAI.ItemResourceMcpListTools", - "azure.ai.projects.models.ItemResourceMcpToolCall": "OpenAI.ItemResourceMcpToolCall", - "azure.ai.projects.models.ItemResourceOutputMessage": "OpenAI.ItemResourceOutputMessage", - "azure.ai.projects.models.ItemResourceWebSearchToolCall": "OpenAI.ItemResourceWebSearchToolCall", "azure.ai.projects.models.KeyPressAction": "OpenAI.KeyPressAction", "azure.ai.projects.models.LocalShellExecAction": "OpenAI.LocalShellExecAction", "azure.ai.projects.models.LocalShellToolParam": "OpenAI.LocalShellToolParam", @@ -225,7 +192,6 @@ "azure.ai.projects.models.MemorySearchItem": "Azure.AI.Projects.MemorySearchItem", "azure.ai.projects.models.MemorySearchOptions": "Azure.AI.Projects.MemorySearchOptions", "azure.ai.projects.models.MemorySearchPreviewTool": "Azure.AI.Projects.MemorySearchPreviewTool", - "azure.ai.projects.models.MemorySearchToolCallItemResource": "Azure.AI.Projects.MemorySearchToolCallItemResource", "azure.ai.projects.models.MemoryStoreDefinition": "Azure.AI.Projects.MemoryStoreDefinition", "azure.ai.projects.models.MemoryStoreDefaultDefinition": "Azure.AI.Projects.MemoryStoreDefaultDefinition", "azure.ai.projects.models.MemoryStoreDefaultOptions": "Azure.AI.Projects.MemoryStoreDefaultOptions", @@ -238,10 +204,10 @@ "azure.ai.projects.models.MicrosoftFabricPreviewTool": "Azure.AI.Projects.MicrosoftFabricPreviewTool", "azure.ai.projects.models.ModelDeployment": "Azure.AI.Projects.ModelDeployment", "azure.ai.projects.models.ModelDeploymentSku": "Azure.AI.Projects.Sku", + "azure.ai.projects.models.ModelSamplingParams": "Azure.AI.Projects.ModelSamplingParams", "azure.ai.projects.models.MonthlyRecurrenceSchedule": "Azure.AI.Projects.MonthlyRecurrenceSchedule", "azure.ai.projects.models.Move": "OpenAI.Move", "azure.ai.projects.models.NoAuthenticationCredentials": "Azure.AI.Projects.NoAuthenticationCredentials", - "azure.ai.projects.models.OAuthConsentRequestItemResource": "Azure.AI.Projects.OAuthConsentRequestItemResource", "azure.ai.projects.models.OneTimeTrigger": "Azure.AI.Projects.OneTimeTrigger", "azure.ai.projects.models.OpenApiAuthDetails": "Azure.AI.Projects.OpenApiAuthDetails", "azure.ai.projects.models.OpenApiAnonymousAuthDetails": "Azure.AI.Projects.OpenApiAnonymousAuthDetails", @@ -252,14 +218,13 @@ "azure.ai.projects.models.OpenApiProjectConnectionAuthDetails": "Azure.AI.Projects.OpenApiProjectConnectionAuthDetails", "azure.ai.projects.models.OpenApiProjectConnectionSecurityScheme": "Azure.AI.Projects.OpenApiProjectConnectionSecurityScheme", "azure.ai.projects.models.OpenApiTool": "Azure.AI.Projects.OpenApiTool", - "azure.ai.projects.models.OutputContent": "OpenAI.OutputContent", "azure.ai.projects.models.OutputMessageContent": "OpenAI.OutputMessageContent", "azure.ai.projects.models.OutputMessageContentOutputTextContent": "OpenAI.OutputMessageContentOutputTextContent", "azure.ai.projects.models.OutputMessageContentRefusalContent": "OpenAI.OutputMessageContentRefusalContent", "azure.ai.projects.models.PendingUploadRequest": "Azure.AI.Projects.PendingUploadRequest", "azure.ai.projects.models.PendingUploadResponse": "Azure.AI.Projects.PendingUploadResponse", "azure.ai.projects.models.PromptAgentDefinition": "Azure.AI.Projects.PromptAgentDefinition", - "azure.ai.projects.models.PromptAgentDefinitionText": "Azure.AI.Projects.PromptAgentDefinition.text.anonymous", + "azure.ai.projects.models.PromptAgentDefinitionTextOptions": "Azure.AI.Projects.PromptAgentDefinitionTextOptions", "azure.ai.projects.models.PromptBasedEvaluatorDefinition": "Azure.AI.Projects.PromptBasedEvaluatorDefinition", "azure.ai.projects.models.ProtocolVersionRecord": "Azure.AI.Projects.ProtocolVersionRecord", "azure.ai.projects.models.RaiConfig": "Azure.AI.Projects.RaiConfig", @@ -277,9 +242,11 @@ "azure.ai.projects.models.Scroll": "OpenAI.Scroll", "azure.ai.projects.models.SharepointGroundingToolParameters": "Azure.AI.Projects.SharepointGroundingToolParameters", "azure.ai.projects.models.SharepointPreviewTool": "Azure.AI.Projects.SharepointPreviewTool", + "azure.ai.projects.models.ToolChoiceParam": "OpenAI.ToolChoiceParam", + "azure.ai.projects.models.SpecificApplyPatchParam": "OpenAI.SpecificApplyPatchParam", + "azure.ai.projects.models.SpecificFunctionShellParam": "OpenAI.SpecificFunctionShellParam", "azure.ai.projects.models.StructuredInputDefinition": "Azure.AI.Projects.StructuredInputDefinition", "azure.ai.projects.models.StructuredOutputDefinition": "Azure.AI.Projects.StructuredOutputDefinition", - "azure.ai.projects.models.StructuredOutputsItemResource": "Azure.AI.Projects.StructuredOutputsItemResource", "azure.ai.projects.models.Summary": "OpenAI.Summary", "azure.ai.projects.models.TaxonomyCategory": "Azure.AI.Projects.TaxonomyCategory", "azure.ai.projects.models.TaxonomySubCategory": "Azure.AI.Projects.TaxonomySubCategory", @@ -287,6 +254,16 @@ "azure.ai.projects.models.TextResponseFormatConfigurationResponseFormatJsonObject": "OpenAI.TextResponseFormatConfigurationResponseFormatJsonObject", "azure.ai.projects.models.TextResponseFormatConfigurationResponseFormatText": "OpenAI.TextResponseFormatConfigurationResponseFormatText", "azure.ai.projects.models.TextResponseFormatJsonSchema": "OpenAI.TextResponseFormatJsonSchema", + "azure.ai.projects.models.ToolChoiceAllowed": "OpenAI.ToolChoiceAllowed", + "azure.ai.projects.models.ToolChoiceCodeInterpreter": "OpenAI.ToolChoiceCodeInterpreter", + "azure.ai.projects.models.ToolChoiceComputerUsePreview": "OpenAI.ToolChoiceComputerUsePreview", + "azure.ai.projects.models.ToolChoiceCustom": "OpenAI.ToolChoiceCustom", + "azure.ai.projects.models.ToolChoiceFileSearch": "OpenAI.ToolChoiceFileSearch", + "azure.ai.projects.models.ToolChoiceFunction": "OpenAI.ToolChoiceFunction", + "azure.ai.projects.models.ToolChoiceImageGeneration": "OpenAI.ToolChoiceImageGeneration", + "azure.ai.projects.models.ToolChoiceMCP": "OpenAI.ToolChoiceMCP", + "azure.ai.projects.models.ToolChoiceWebSearchPreview": "OpenAI.ToolChoiceWebSearchPreview", + "azure.ai.projects.models.ToolChoiceWebSearchPreview20250311": "OpenAI.ToolChoiceWebSearchPreview20250311", "azure.ai.projects.models.ToolDescription": "Azure.AI.Projects.ToolDescription", "azure.ai.projects.models.ToolProjectConnection": "Azure.AI.Projects.ToolProjectConnection", "azure.ai.projects.models.TopLogProb": "OpenAI.TopLogProb", @@ -305,24 +282,22 @@ "azure.ai.projects.models.WebSearchTool": "OpenAI.WebSearchTool", "azure.ai.projects.models.WebSearchToolFilters": "OpenAI.WebSearchToolFilters", "azure.ai.projects.models.WeeklyRecurrenceSchedule": "Azure.AI.Projects.WeeklyRecurrenceSchedule", - "azure.ai.projects.models.WorkflowActionOutputItemResource": "Azure.AI.Projects.WorkflowActionOutputItemResource", "azure.ai.projects.models.WorkflowAgentDefinition": "Azure.AI.Projects.WorkflowAgentDefinition", - "azure.ai.projects.models.AgentKind": "Azure.AI.Projects.AgentKind", - "azure.ai.projects.models.AgentProtocol": "Azure.AI.Projects.AgentProtocol", - "azure.ai.projects.models.ToolType": "OpenAI.ToolType", - "azure.ai.projects.models.AzureAISearchQueryType": "Azure.AI.Projects.AzureAISearchQueryType", - "azure.ai.projects.models.ContainerMemoryLimit": "OpenAI.ContainerMemoryLimit", - "azure.ai.projects.models.ComputerEnvironment": "OpenAI.ComputerEnvironment", - "azure.ai.projects.models.CustomToolParamFormatType": "OpenAI.CustomToolParamFormatType", - "azure.ai.projects.models.GrammarSyntax1": "OpenAI.GrammarSyntax1", - "azure.ai.projects.models.RankerVersionType": "OpenAI.RankerVersionType", - "azure.ai.projects.models.InputFidelity": "OpenAI.InputFidelity", - "azure.ai.projects.models.OpenApiAuthType": "Azure.AI.Projects.OpenApiAuthType", - "azure.ai.projects.models.SearchContextSize": "OpenAI.SearchContextSize", - "azure.ai.projects.models.TextResponseFormatConfigurationType": "OpenAI.TextResponseFormatConfigurationType", - "azure.ai.projects.models.PageOrder": "Azure.AI.Projects.PageOrder", - "azure.ai.projects.models.ContainerLogKind": "Azure.AI.Projects.ContainerLogKind", + "azure.ai.projects.models.EvaluationTaxonomyInputType": "Azure.AI.Projects.EvaluationTaxonomyInputType", + "azure.ai.projects.models.RiskCategory": "Azure.AI.Projects.RiskCategory", + "azure.ai.projects.models.FoundryFeaturesOptInKeys": "Azure.AI.Projects.FoundryFeaturesOptInKeys", + "azure.ai.projects.models.EvaluatorType": "Azure.AI.Projects.EvaluatorType", + "azure.ai.projects.models.EvaluatorCategory": "Azure.AI.Projects.EvaluatorCategory", + "azure.ai.projects.models.EvaluatorDefinitionType": "Azure.AI.Projects.EvaluatorDefinitionType", + "azure.ai.projects.models.EvaluatorMetricType": "Azure.AI.Projects.EvaluatorMetricType", + "azure.ai.projects.models.EvaluatorMetricDirection": "Azure.AI.Projects.EvaluatorMetricDirection", + "azure.ai.projects.models.OperationState": "Azure.Core.Foundations.OperationState", + "azure.ai.projects.models.InsightType": "Azure.AI.Projects.InsightType", + "azure.ai.projects.models.SampleType": "Azure.AI.Projects.SampleType", + "azure.ai.projects.models.TreatmentEffectType": "Azure.AI.Projects.TreatmentEffectType", + "azure.ai.projects.models.MemoryStoreObjectType": "Azure.AI.Projects.MemoryStoreObjectType", "azure.ai.projects.models.MemoryStoreKind": "Azure.AI.Projects.MemoryStoreKind", + "azure.ai.projects.models.PageOrder": "Azure.AI.Projects.PageOrder", "azure.ai.projects.models.MemoryItemKind": "Azure.AI.Projects.MemoryItemKind", "azure.ai.projects.models.InputItemType": "OpenAI.InputItemType", "azure.ai.projects.models.ApplyPatchCallStatusParam": "OpenAI.ApplyPatchCallStatusParam", @@ -338,52 +313,41 @@ "azure.ai.projects.models.InputContentType": "OpenAI.InputContentType", "azure.ai.projects.models.OutputMessageContentType": "OpenAI.OutputMessageContentType", "azure.ai.projects.models.AnnotationType": "OpenAI.AnnotationType", - "azure.ai.projects.models.OutputContentType": "OpenAI.OutputContentType", "azure.ai.projects.models.FunctionShellCallItemStatus": "OpenAI.FunctionShellCallItemStatus", "azure.ai.projects.models.FunctionShellCallOutputOutcomeParamType": "OpenAI.FunctionShellCallOutputOutcomeParamType", "azure.ai.projects.models.MemoryOperationKind": "Azure.AI.Projects.MemoryOperationKind", - "azure.ai.projects.models.ConnectionType": "Azure.AI.Projects.ConnectionType", - "azure.ai.projects.models.CredentialType": "Azure.AI.Projects.CredentialType", - "azure.ai.projects.models.DatasetType": "Azure.AI.Projects.DatasetType", - "azure.ai.projects.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType", - "azure.ai.projects.models.IndexType": "Azure.AI.Projects.IndexType", - "azure.ai.projects.models.DeploymentType": "Azure.AI.Projects.DeploymentType", "azure.ai.projects.models.AttackStrategy": "Azure.AI.Projects.AttackStrategy", - "azure.ai.projects.models.RiskCategory": "Azure.AI.Projects.RiskCategory", - "azure.ai.projects.models.EvaluationRuleActionType": "Azure.AI.Projects.EvaluationRuleActionType", - "azure.ai.projects.models.EvaluationRuleEventType": "Azure.AI.Projects.EvaluationRuleEventType", - "azure.ai.projects.models.EvaluationTaxonomyInputType": "Azure.AI.Projects.EvaluationTaxonomyInputType", - "azure.ai.projects.models.EvaluatorType": "Azure.AI.Projects.EvaluatorType", - "azure.ai.projects.models.EvaluatorCategory": "Azure.AI.Projects.EvaluatorCategory", - "azure.ai.projects.models.EvaluatorDefinitionType": "Azure.AI.Projects.EvaluatorDefinitionType", - "azure.ai.projects.models.EvaluatorMetricType": "Azure.AI.Projects.EvaluatorMetricType", - "azure.ai.projects.models.EvaluatorMetricDirection": "Azure.AI.Projects.EvaluatorMetricDirection", - "azure.ai.projects.models.OperationState": "Azure.Core.Foundations.OperationState", - "azure.ai.projects.models.InsightType": "Azure.AI.Projects.InsightType", - "azure.ai.projects.models.SampleType": "Azure.AI.Projects.SampleType", - "azure.ai.projects.models.TreatmentEffectType": "Azure.AI.Projects.TreatmentEffectType", "azure.ai.projects.models.ScheduleProvisioningStatus": "Azure.AI.Projects.ScheduleProvisioningStatus", "azure.ai.projects.models.TriggerType": "Azure.AI.Projects.TriggerType", "azure.ai.projects.models.RecurrenceType": "Azure.AI.Projects.RecurrenceType", "azure.ai.projects.models.DayOfWeek": "Azure.AI.Projects.DayOfWeek", "azure.ai.projects.models.ScheduleTaskType": "Azure.AI.Projects.ScheduleTaskType", + "azure.ai.projects.models.AgentObjectType": "Azure.AI.Projects.AgentObjectType", + "azure.ai.projects.models.AgentKind": "Azure.AI.Projects.AgentKind", + "azure.ai.projects.models.AgentProtocol": "Azure.AI.Projects.AgentProtocol", + "azure.ai.projects.models.ToolType": "OpenAI.ToolType", + "azure.ai.projects.models.AzureAISearchQueryType": "Azure.AI.Projects.AzureAISearchQueryType", + "azure.ai.projects.models.ContainerMemoryLimit": "OpenAI.ContainerMemoryLimit", + "azure.ai.projects.models.ComputerEnvironment": "OpenAI.ComputerEnvironment", + "azure.ai.projects.models.CustomToolParamFormatType": "OpenAI.CustomToolParamFormatType", + "azure.ai.projects.models.GrammarSyntax1": "OpenAI.GrammarSyntax1", + "azure.ai.projects.models.RankerVersionType": "OpenAI.RankerVersionType", + "azure.ai.projects.models.InputFidelity": "OpenAI.InputFidelity", + "azure.ai.projects.models.OpenApiAuthType": "Azure.AI.Projects.OpenApiAuthType", + "azure.ai.projects.models.SearchContextSize": "OpenAI.SearchContextSize", + "azure.ai.projects.models.ToolChoiceParamType": "OpenAI.ToolChoiceParamType", + "azure.ai.projects.models.TextResponseFormatConfigurationType": "OpenAI.TextResponseFormatConfigurationType", + "azure.ai.projects.models.EvaluationRuleActionType": "Azure.AI.Projects.EvaluationRuleActionType", + "azure.ai.projects.models.EvaluationRuleEventType": "Azure.AI.Projects.EvaluationRuleEventType", + "azure.ai.projects.models.ConnectionType": "Azure.AI.Projects.ConnectionType", + "azure.ai.projects.models.CredentialType": "Azure.AI.Projects.CredentialType", + "azure.ai.projects.models.DatasetType": "Azure.AI.Projects.DatasetType", + "azure.ai.projects.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType", + "azure.ai.projects.models.DeploymentType": "Azure.AI.Projects.DeploymentType", + "azure.ai.projects.models.IndexType": "Azure.AI.Projects.IndexType", "azure.ai.projects.models.MemoryStoreUpdateStatus": "Azure.AI.Projects.MemoryStoreUpdateStatus", - "azure.ai.projects.models.FunctionShellCallOutputOutcomeType": "OpenAI.FunctionShellCallOutputOutcomeType", - "azure.ai.projects.models.ApplyPatchFileOperationType": "OpenAI.ApplyPatchFileOperationType", - "azure.ai.projects.models.ItemResourceType": "OpenAI.ItemResourceType", - "azure.ai.projects.models.ApplyPatchCallStatus": "OpenAI.ApplyPatchCallStatus", - "azure.ai.projects.models.ApplyPatchCallOutputStatus": "OpenAI.ApplyPatchCallOutputStatus", - "azure.ai.projects.models.LocalShellCallStatus": "OpenAI.LocalShellCallStatus", "azure.ai.projects.operations.AgentsOperations.get": "Azure.AI.Projects.Agents.getAgent", "azure.ai.projects.aio.operations.AgentsOperations.get": "Azure.AI.Projects.Agents.getAgent", - "azure.ai.projects.operations.AgentsOperations.create": "Azure.AI.Projects.Agents.createAgent", - "azure.ai.projects.aio.operations.AgentsOperations.create": "Azure.AI.Projects.Agents.createAgent", - "azure.ai.projects.operations.AgentsOperations.update": "Azure.AI.Projects.Agents.updateAgent", - "azure.ai.projects.aio.operations.AgentsOperations.update": "Azure.AI.Projects.Agents.updateAgent", - "azure.ai.projects.operations.AgentsOperations.create_from_manifest": "Azure.AI.Projects.Agents.createAgentFromManifest", - "azure.ai.projects.aio.operations.AgentsOperations.create_from_manifest": "Azure.AI.Projects.Agents.createAgentFromManifest", - "azure.ai.projects.operations.AgentsOperations.update_from_manifest": "Azure.AI.Projects.Agents.updateAgentFromManifest", - "azure.ai.projects.aio.operations.AgentsOperations.update_from_manifest": "Azure.AI.Projects.Agents.updateAgentFromManifest", "azure.ai.projects.operations.AgentsOperations.delete": "Azure.AI.Projects.Agents.deleteAgent", "azure.ai.projects.aio.operations.AgentsOperations.delete": "Azure.AI.Projects.Agents.deleteAgent", "azure.ai.projects.operations.AgentsOperations.list": "Azure.AI.Projects.Agents.listAgents", @@ -398,22 +362,14 @@ "azure.ai.projects.aio.operations.AgentsOperations.delete_version": "Azure.AI.Projects.Agents.deleteAgentVersion", "azure.ai.projects.operations.AgentsOperations.list_versions": "Azure.AI.Projects.Agents.listAgentVersions", "azure.ai.projects.aio.operations.AgentsOperations.list_versions": "Azure.AI.Projects.Agents.listAgentVersions", - "azure.ai.projects.operations.AgentsOperations.stream_agent_container_logs": "Azure.AI.Projects.Agents.streamAgentContainerLogs", - "azure.ai.projects.aio.operations.AgentsOperations.stream_agent_container_logs": "Azure.AI.Projects.Agents.streamAgentContainerLogs", - "azure.ai.projects.operations.MemoryStoresOperations.create": "Azure.AI.Projects.MemoryStores.createMemoryStore", - "azure.ai.projects.aio.operations.MemoryStoresOperations.create": "Azure.AI.Projects.MemoryStores.createMemoryStore", - "azure.ai.projects.operations.MemoryStoresOperations.update": "Azure.AI.Projects.MemoryStores.updateMemoryStore", - "azure.ai.projects.aio.operations.MemoryStoresOperations.update": "Azure.AI.Projects.MemoryStores.updateMemoryStore", - "azure.ai.projects.operations.MemoryStoresOperations.get": "Azure.AI.Projects.MemoryStores.getMemoryStore", - "azure.ai.projects.aio.operations.MemoryStoresOperations.get": "Azure.AI.Projects.MemoryStores.getMemoryStore", - "azure.ai.projects.operations.MemoryStoresOperations.list": "Azure.AI.Projects.MemoryStores.listMemoryStores", - "azure.ai.projects.aio.operations.MemoryStoresOperations.list": "Azure.AI.Projects.MemoryStores.listMemoryStores", - "azure.ai.projects.operations.MemoryStoresOperations.delete": "Azure.AI.Projects.MemoryStores.deleteMemoryStore", - "azure.ai.projects.aio.operations.MemoryStoresOperations.delete": "Azure.AI.Projects.MemoryStores.deleteMemoryStore", - "azure.ai.projects.operations.MemoryStoresOperations.search_memories": "Azure.AI.Projects.MemoryStores.searchMemories", - "azure.ai.projects.aio.operations.MemoryStoresOperations.search_memories": "Azure.AI.Projects.MemoryStores.searchMemories", - "azure.ai.projects.operations.MemoryStoresOperations.delete_scope": "Azure.AI.Projects.MemoryStores.deleteScope", - "azure.ai.projects.aio.operations.MemoryStoresOperations.delete_scope": "Azure.AI.Projects.MemoryStores.deleteScope", + "azure.ai.projects.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", + "azure.ai.projects.aio.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", + "azure.ai.projects.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", + "azure.ai.projects.aio.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", + "azure.ai.projects.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", + "azure.ai.projects.aio.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", + "azure.ai.projects.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", + "azure.ai.projects.aio.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", "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.DatasetsOperations.list_versions": "Azure.AI.Projects.Datasets.listVersions", @@ -430,6 +386,10 @@ "azure.ai.projects.aio.operations.DatasetsOperations.pending_upload": "Azure.AI.Projects.Datasets.startPendingUploadVersion", "azure.ai.projects.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials", "azure.ai.projects.aio.operations.DatasetsOperations.get_credentials": "Azure.AI.Projects.Datasets.getCredentials", + "azure.ai.projects.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", + "azure.ai.projects.aio.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", + "azure.ai.projects.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", + "azure.ai.projects.aio.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", "azure.ai.projects.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions", "azure.ai.projects.aio.operations.IndexesOperations.list_versions": "Azure.AI.Projects.Indexes.listVersions", "azure.ai.projects.operations.IndexesOperations.list": "Azure.AI.Projects.Indexes.listLatest", @@ -439,64 +399,6 @@ "azure.ai.projects.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion", "azure.ai.projects.aio.operations.IndexesOperations.delete": "Azure.AI.Projects.Indexes.deleteVersion", "azure.ai.projects.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion", - "azure.ai.projects.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion", - "azure.ai.projects.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", - "azure.ai.projects.aio.operations.DeploymentsOperations.get": "Azure.AI.Projects.Deployments.get", - "azure.ai.projects.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", - "azure.ai.projects.aio.operations.DeploymentsOperations.list": "Azure.AI.Projects.Deployments.list", - "azure.ai.projects.operations.RedTeamsOperations.get": "Azure.AI.Projects.RedTeams.get", - "azure.ai.projects.aio.operations.RedTeamsOperations.get": "Azure.AI.Projects.RedTeams.get", - "azure.ai.projects.operations.RedTeamsOperations.list": "Azure.AI.Projects.RedTeams.list", - "azure.ai.projects.aio.operations.RedTeamsOperations.list": "Azure.AI.Projects.RedTeams.list", - "azure.ai.projects.operations.RedTeamsOperations.create": "Azure.AI.Projects.RedTeams.create", - "azure.ai.projects.aio.operations.RedTeamsOperations.create": "Azure.AI.Projects.RedTeams.create", - "azure.ai.projects.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", - "azure.ai.projects.aio.operations.EvaluationRulesOperations.get": "Azure.AI.Projects.EvaluationRules.get", - "azure.ai.projects.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", - "azure.ai.projects.aio.operations.EvaluationRulesOperations.delete": "Azure.AI.Projects.EvaluationRules.delete", - "azure.ai.projects.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", - "azure.ai.projects.aio.operations.EvaluationRulesOperations.create_or_update": "Azure.AI.Projects.EvaluationRules.createOrUpdate", - "azure.ai.projects.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", - "azure.ai.projects.aio.operations.EvaluationRulesOperations.list": "Azure.AI.Projects.EvaluationRules.list", - "azure.ai.projects.operations.EvaluationTaxonomiesOperations.get": "Azure.AI.Projects.EvaluationTaxonomies.get", - "azure.ai.projects.aio.operations.EvaluationTaxonomiesOperations.get": "Azure.AI.Projects.EvaluationTaxonomies.get", - "azure.ai.projects.operations.EvaluationTaxonomiesOperations.list": "Azure.AI.Projects.EvaluationTaxonomies.list", - "azure.ai.projects.aio.operations.EvaluationTaxonomiesOperations.list": "Azure.AI.Projects.EvaluationTaxonomies.list", - "azure.ai.projects.operations.EvaluationTaxonomiesOperations.delete": "Azure.AI.Projects.EvaluationTaxonomies.delete", - "azure.ai.projects.aio.operations.EvaluationTaxonomiesOperations.delete": "Azure.AI.Projects.EvaluationTaxonomies.delete", - "azure.ai.projects.operations.EvaluationTaxonomiesOperations.create": "Azure.AI.Projects.EvaluationTaxonomies.create", - "azure.ai.projects.aio.operations.EvaluationTaxonomiesOperations.create": "Azure.AI.Projects.EvaluationTaxonomies.create", - "azure.ai.projects.operations.EvaluationTaxonomiesOperations.update": "Azure.AI.Projects.EvaluationTaxonomies.update", - "azure.ai.projects.aio.operations.EvaluationTaxonomiesOperations.update": "Azure.AI.Projects.EvaluationTaxonomies.update", - "azure.ai.projects.operations.EvaluatorsOperations.list_versions": "Azure.AI.Projects.Evaluators.listVersions", - "azure.ai.projects.aio.operations.EvaluatorsOperations.list_versions": "Azure.AI.Projects.Evaluators.listVersions", - "azure.ai.projects.operations.EvaluatorsOperations.list_latest_versions": "Azure.AI.Projects.Evaluators.listLatestVersions", - "azure.ai.projects.aio.operations.EvaluatorsOperations.list_latest_versions": "Azure.AI.Projects.Evaluators.listLatestVersions", - "azure.ai.projects.operations.EvaluatorsOperations.get_version": "Azure.AI.Projects.Evaluators.getVersion", - "azure.ai.projects.aio.operations.EvaluatorsOperations.get_version": "Azure.AI.Projects.Evaluators.getVersion", - "azure.ai.projects.operations.EvaluatorsOperations.delete_version": "Azure.AI.Projects.Evaluators.deleteVersion", - "azure.ai.projects.aio.operations.EvaluatorsOperations.delete_version": "Azure.AI.Projects.Evaluators.deleteVersion", - "azure.ai.projects.operations.EvaluatorsOperations.create_version": "Azure.AI.Projects.Evaluators.createVersion", - "azure.ai.projects.aio.operations.EvaluatorsOperations.create_version": "Azure.AI.Projects.Evaluators.createVersion", - "azure.ai.projects.operations.EvaluatorsOperations.update_version": "Azure.AI.Projects.Evaluators.updateVersion", - "azure.ai.projects.aio.operations.EvaluatorsOperations.update_version": "Azure.AI.Projects.Evaluators.updateVersion", - "azure.ai.projects.operations.InsightsOperations.generate": "Azure.AI.Projects.Insights.generate", - "azure.ai.projects.aio.operations.InsightsOperations.generate": "Azure.AI.Projects.Insights.generate", - "azure.ai.projects.operations.InsightsOperations.get": "Azure.AI.Projects.Insights.get", - "azure.ai.projects.aio.operations.InsightsOperations.get": "Azure.AI.Projects.Insights.get", - "azure.ai.projects.operations.InsightsOperations.list": "Azure.AI.Projects.Insights.list", - "azure.ai.projects.aio.operations.InsightsOperations.list": "Azure.AI.Projects.Insights.list", - "azure.ai.projects.operations.SchedulesOperations.delete": "Azure.AI.Projects.Schedules.delete", - "azure.ai.projects.aio.operations.SchedulesOperations.delete": "Azure.AI.Projects.Schedules.delete", - "azure.ai.projects.operations.SchedulesOperations.get": "Azure.AI.Projects.Schedules.get", - "azure.ai.projects.aio.operations.SchedulesOperations.get": "Azure.AI.Projects.Schedules.get", - "azure.ai.projects.operations.SchedulesOperations.list": "Azure.AI.Projects.Schedules.list", - "azure.ai.projects.aio.operations.SchedulesOperations.list": "Azure.AI.Projects.Schedules.list", - "azure.ai.projects.operations.SchedulesOperations.create_or_update": "Azure.AI.Projects.Schedules.createOrUpdate", - "azure.ai.projects.aio.operations.SchedulesOperations.create_or_update": "Azure.AI.Projects.Schedules.createOrUpdate", - "azure.ai.projects.operations.SchedulesOperations.get_run": "Azure.AI.Projects.Schedules.getRun", - "azure.ai.projects.aio.operations.SchedulesOperations.get_run": "Azure.AI.Projects.Schedules.getRun", - "azure.ai.projects.operations.SchedulesOperations.list_runs": "Azure.AI.Projects.Schedules.listRuns", - "azure.ai.projects.aio.operations.SchedulesOperations.list_runs": "Azure.AI.Projects.Schedules.listRuns" + "azure.ai.projects.aio.operations.IndexesOperations.create_or_update": "Azure.AI.Projects.Indexes.createOrUpdateVersion" } } \ 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 65df15b7b235..9f8ec31ab6fa 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_client.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_client.py @@ -18,17 +18,12 @@ from ._utils.serialization import Deserializer, Serializer from .operations import ( AgentsOperations, + BetaOperations, ConnectionsOperations, DatasetsOperations, DeploymentsOperations, EvaluationRulesOperations, - EvaluationTaxonomiesOperations, - EvaluatorsOperations, IndexesOperations, - InsightsOperations, - MemoryStoresOperations, - RedTeamsOperations, - SchedulesOperations, ) if TYPE_CHECKING: @@ -38,40 +33,30 @@ class AIProjectClient: # pylint: disable=too-many-instance-attributes """AIProjectClient. + :ivar beta: BetaOperations operations + :vartype beta: azure.ai.projects.operations.BetaOperations :ivar agents: AgentsOperations operations :vartype agents: azure.ai.projects.operations.AgentsOperations - :ivar memory_stores: MemoryStoresOperations operations - :vartype memory_stores: azure.ai.projects.operations.MemoryStoresOperations + :ivar evaluation_rules: EvaluationRulesOperations operations + :vartype evaluation_rules: azure.ai.projects.operations.EvaluationRulesOperations :ivar connections: ConnectionsOperations operations :vartype connections: azure.ai.projects.operations.ConnectionsOperations :ivar datasets: DatasetsOperations operations :vartype datasets: azure.ai.projects.operations.DatasetsOperations - :ivar indexes: IndexesOperations operations - :vartype indexes: azure.ai.projects.operations.IndexesOperations :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.ai.projects.operations.DeploymentsOperations - :ivar red_teams: RedTeamsOperations operations - :vartype red_teams: azure.ai.projects.operations.RedTeamsOperations - :ivar evaluation_rules: EvaluationRulesOperations operations - :vartype evaluation_rules: azure.ai.projects.operations.EvaluationRulesOperations - :ivar evaluation_taxonomies: EvaluationTaxonomiesOperations operations - :vartype evaluation_taxonomies: azure.ai.projects.operations.EvaluationTaxonomiesOperations - :ivar evaluators: EvaluatorsOperations operations - :vartype evaluators: azure.ai.projects.operations.EvaluatorsOperations - :ivar insights: InsightsOperations operations - :vartype insights: azure.ai.projects.operations.InsightsOperations - :ivar schedules: SchedulesOperations operations - :vartype schedules: azure.ai.projects.operations.SchedulesOperations + :ivar indexes: IndexesOperations operations + :vartype indexes: azure.ai.projects.operations.IndexesOperations :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". - If you only have one Project in your Foundry Hub, or to target the default Project - in your Hub, use the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". Required. + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-15-preview". Note that overriding this default value may result in unsupported + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is "v1". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -102,22 +87,15 @@ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False + self.beta = BetaOperations(self._client, self._config, self._serialize, self._deserialize) self.agents = AgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.memory_stores = MemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) - self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.red_teams = RedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) self.evaluation_rules = EvaluationRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.evaluation_taxonomies = EvaluationTaxonomiesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.evaluators = EvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.insights = InsightsOperations(self._client, self._config, self._serialize, self._deserialize) - self.schedules = SchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.datasets = DatasetsOperations(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) def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_configuration.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_configuration.py index ad3f889051fe..f391755cc641 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_configuration.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_configuration.py @@ -23,21 +23,21 @@ class AIProjectClientConfiguration: # pylint: disable=too-many-instance-attribu attributes. :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". - If you only have one Project in your Foundry Hub, or to target the default Project - in your Hub, use the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". Required. + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-15-preview". Note that overriding this default value may result in unsupported + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is "v1". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "TokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-11-15-preview") + api_version: str = kwargs.pop("api_version", "v1") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") 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 a6902daaafa6..6eb5beafd79e 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_patch.py @@ -10,6 +10,7 @@ import os import logging from typing import List, Any +import httpx from openai import OpenAI from azure.core.tracing.decorator import distributed_trace from azure.core.credentials import TokenCredential @@ -26,43 +27,39 @@ class AIProjectClient(AIProjectClientGenerated): # pylint: disable=too-many-ins :ivar agents: AgentsOperations operations :vartype agents: azure.ai.projects.operations.AgentsOperations - :ivar memory_stores: MemoryStoresOperations operations - :vartype memory_stores: azure.ai.projects.operations.MemoryStoresOperations :ivar connections: ConnectionsOperations operations :vartype connections: azure.ai.projects.operations.ConnectionsOperations :ivar datasets: DatasetsOperations operations :vartype datasets: azure.ai.projects.operations.DatasetsOperations - :ivar indexes: IndexesOperations operations - :vartype indexes: azure.ai.projects.operations.IndexesOperations :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.ai.projects.operations.DeploymentsOperations - :ivar red_teams: RedTeamsOperations operations - :vartype red_teams: azure.ai.projects.operations.RedTeamsOperations - :ivar evaluation_rules: EvaluationRulesOperations operations - :vartype evaluation_rules: azure.ai.projects.operations.EvaluationRulesOperations :ivar evaluation_taxonomies: EvaluationTaxonomiesOperations operations :vartype evaluation_taxonomies: azure.ai.projects.operations.EvaluationTaxonomiesOperations + :ivar evaluation_rules: EvaluationRulesOperations operations + :vartype evaluation_rules: azure.ai.projects.operations.EvaluationRulesOperations :ivar evaluators: EvaluatorsOperations operations :vartype evaluators: azure.ai.projects.operations.EvaluatorsOperations + :ivar indexes: IndexesOperations operations + :vartype indexes: azure.ai.projects.operations.IndexesOperations :ivar insights: InsightsOperations operations :vartype insights: azure.ai.projects.operations.InsightsOperations + :ivar memory_stores: MemoryStoresOperations operations + :vartype memory_stores: azure.ai.projects.operations.MemoryStoresOperations + :ivar red_teams: RedTeamsOperations operations + :vartype red_teams: azure.ai.projects.operations.RedTeamsOperations :ivar schedules: SchedulesOperations operations :vartype schedules: azure.ai.projects.operations.SchedulesOperations :param endpoint: Foundry Project endpoint in the form - ``https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}``. If - you only have one Project in your Foundry Hub, or to target the default Project in your Hub, - use the form - ``https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project``. Required. + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials.TokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-15-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Default value is "v1". Note + that overriding this default value may result in unsupported behavior. :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :keyword user_agent: Optional string identifying the caller. This string will show up at the front of the "User-Agent" HTTP request header in all network calls this client makes. If an OpenAI client was obtained by calling get_openai_client(), this string will also show up at the front of the "User-Agent" request header in network calls that OpenAI client makes. """ def __init__(self, endpoint: str, credential: TokenCredential, **kwargs: Any) -> None: @@ -101,132 +98,48 @@ def get_openai_client(self, **kwargs: Any) -> "OpenAI": # type: ignore[name-def Keyword arguments are passed to the OpenAI client constructor. The OpenAI client constructor is called with: - - * ``base_url`` set to the endpoint provided to the AIProjectClient constructor, with "/openai" appended. - * ``api-version`` set to "2025-05-15-preview" by default, unless overridden by the ``api_version`` keyword argument. - * ``api_key`` set to a get_bearer_token_provider() callable that uses the TokenCredential provided to the AIProjectClient constructor, with scope "https://ai.azure.com/.default". + * ``base_url`` set to the endpoint provided to the AIProjectClient constructor, with "/openai/v1" appended. + Can be overridden by passing ``base_url`` as a keyword argument. + * ``api_key`` set to a get_bearer_token_provider() callable that uses the TokenCredential provided to the + AIProjectClient constructor, with scope "https://ai.azure.com/.default". + Can be overridden by passing ``api_key`` as a keyword argument. .. note:: The packages ``openai`` and ``azure.identity`` must be installed prior to calling this method. :return: An authenticated OpenAI client :rtype: ~openai.OpenAI - :raises ~azure.core.exceptions.ModuleNotFoundError: if the ``openai`` package - is not installed. :raises ~azure.core.exceptions.HttpResponseError: """ - base_url = self._config.endpoint.rstrip("/") + "/openai" # pylint: disable=protected-access + kwargs = kwargs.copy() if kwargs else {} - if "default_query" not in kwargs: - kwargs["default_query"] = {"api-version": "2025-11-15-preview"} + # Allow caller to override base_url + if "base_url" in kwargs: + base_url = kwargs.pop("base_url") + else: + base_url = self._config.endpoint.rstrip("/") + "/openai/v1" # pylint: disable=protected-access logger.debug( # pylint: disable=specify-parameter-names-in-call "[get_openai_client] Creating OpenAI client using Entra ID authentication, base_url = `%s`", # pylint: disable=line-too-long base_url, ) - http_client = None - - kwargs = kwargs.copy() if kwargs else {} - - if self._console_logging_enabled: - try: - import httpx - except ModuleNotFoundError as e: - raise ModuleNotFoundError("Failed to import httpx. Please install it using 'pip install httpx'") from e - - class OpenAILoggingTransport(httpx.HTTPTransport): - - def _sanitize_auth_header(self, headers) -> None: - """Sanitize authorization header by redacting sensitive information. - - :param headers: Dictionary of HTTP headers to sanitize - :type headers: dict - """ - - if "authorization" in headers: - auth_value = headers["authorization"] - if len(auth_value) >= 7: - headers["authorization"] = auth_value[:7] + "" - else: - headers["authorization"] = "" - - def handle_request(self, request: httpx.Request) -> httpx.Response: - """ - Log HTTP request and response details to console, in a nicely formatted way, - for OpenAI / Azure OpenAI clients. - - :param request: The HTTP request to handle and log - :type request: httpx.Request - - :return: The HTTP response received - :rtype: httpx.Response - """ - - print(f"\n==> Request:\n{request.method} {request.url}") - headers = dict(request.headers) - self._sanitize_auth_header(headers) - print("Headers:") - for key, value in sorted(headers.items()): - print(f" {key}: {value}") - - self._log_request_body(request) - - response = super().handle_request(request) - - print(f"\n<== Response:\n{response.status_code} {response.reason_phrase}") - print("Headers:") - for key, value in sorted(dict(response.headers).items()): - print(f" {key}: {value}") - - content = response.read() - if content is None or content == b"": - print("Body: [No content]") - else: - try: - print(f"Body:\n {content.decode('utf-8')}") - except Exception: # pylint: disable=broad-exception-caught - print(f"Body (raw):\n {content!r}") - print("\n") - - return response - - def _log_request_body(self, request: httpx.Request) -> None: - """Log request body content safely, handling binary data and streaming content. - - :param request: The HTTP request object containing the body to log - :type request: httpx.Request - """ - - # Check content-type header to identify file uploads - content_type = request.headers.get("content-type", "").lower() - if "multipart/form-data" in content_type: - print("Body: [Multipart form data - file upload, not logged]") - return - - # Safely check if content exists without accessing it - if not hasattr(request, "content"): - print("Body: [No content attribute]") - return - - # Very careful content access - wrap in try-catch immediately - try: - content = request.content - except Exception as access_error: # pylint: disable=broad-exception-caught - print(f"Body: [Cannot access content: {access_error}]") - return - - if content is None or content == b"": - print("Body: [No content]") - return - - try: - print(f"Body:\n {content.decode('utf-8')}") - except Exception: # pylint: disable=broad-exception-caught - print(f"Body (raw):\n {content!r}") + # Allow caller to override api_key, otherwise use token provider + if "api_key" in kwargs: + api_key = kwargs.pop("api_key") + else: + api_key = get_bearer_token_provider( + self._config.credential, # pylint: disable=protected-access + "https://ai.azure.com/.default", + ) + if "http_client" in kwargs: + http_client = kwargs.pop("http_client") + elif self._console_logging_enabled: http_client = httpx.Client(transport=OpenAILoggingTransport()) + else: + http_client = None default_headers = dict[str, str](kwargs.pop("default_headers", None) or {}) @@ -234,11 +147,7 @@ def _log_request_body(self, request: httpx.Request) -> None: def _create_openai_client(**kwargs) -> OpenAI: return OpenAI( - # See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider # pylint: disable=line-too-long - api_key=get_bearer_token_provider( - self._config.credential, # pylint: disable=protected-access - "https://ai.azure.com/.default", - ), + api_key=api_key, base_url=base_url, http_client=http_client, **kwargs, @@ -264,6 +173,107 @@ def _create_openai_client(**kwargs) -> OpenAI: return client +class OpenAILoggingTransport(httpx.HTTPTransport): + """Custom HTTP transport that logs OpenAI API requests and responses to the console. + + This transport wraps httpx.HTTPTransport to intercept all HTTP traffic and print + detailed request/response information for debugging purposes. It automatically + redacts sensitive authorization headers and handles various content types including + multipart form data (file uploads). + + Used internally by AIProjectClient when console logging is enabled via the + AZURE_AI_PROJECTS_CONSOLE_LOGGING environment variable. + """ + + def _sanitize_auth_header(self, headers) -> None: + """Sanitize authorization header by redacting sensitive information. + + :param headers: Dictionary of HTTP headers to sanitize + :type headers: dict + """ + + if "authorization" in headers: + auth_value = headers["authorization"] + if len(auth_value) >= 7: + headers["authorization"] = auth_value[:7] + "" + else: + headers["authorization"] = "" + + def handle_request(self, request: httpx.Request) -> httpx.Response: + """ + Log HTTP request and response details to console, in a nicely formatted way, + for OpenAI / Azure OpenAI clients. + + :param request: The HTTP request to handle and log + :type request: httpx.Request + + :return: The HTTP response received + :rtype: httpx.Response + """ + + print(f"\n==> Request:\n{request.method} {request.url}") + headers = dict(request.headers) + self._sanitize_auth_header(headers) + print("Headers:") + for key, value in sorted(headers.items()): + print(f" {key}: {value}") + + self._log_request_body(request) + + response = super().handle_request(request) + + print(f"\n<== Response:\n{response.status_code} {response.reason_phrase}") + print("Headers:") + for key, value in sorted(dict(response.headers).items()): + print(f" {key}: {value}") + + content = response.read() + if content is None or content == b"": + print("Body: [No content]") + else: + try: + print(f"Body:\n {content.decode('utf-8')}") + except Exception: # pylint: disable=broad-exception-caught + print(f"Body (raw):\n {content!r}") + print("\n") + + return response + + def _log_request_body(self, request: httpx.Request) -> None: + """Log request body content safely, handling binary data and streaming content. + + :param request: The HTTP request object containing the body to log + :type request: httpx.Request + """ + + # Check content-type header to identify file uploads + content_type = request.headers.get("content-type", "").lower() + if "multipart/form-data" in content_type: + print("Body: [Multipart form data - file upload, not logged]") + return + + # Safely check if content exists without accessing it + if not hasattr(request, "content"): + print("Body: [No content attribute]") + return + + # Very careful content access - wrap in try-catch immediately + try: + content = request.content + except Exception as access_error: # pylint: disable=broad-exception-caught + print(f"Body: [Cannot access content: {access_error}]") + return + + if content is None or content == b"": + print("Body: [No content]") + return + + try: + print(f"Body:\n {content.decode('utf-8')}") + except Exception: # pylint: disable=broad-exception-caught + print(f"Body (raw):\n {content!r}") + + __all__: List[str] = [ "AIProjectClient", ] # Add all objects you want publicly available to users at this package level diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_types.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_types.py index 380d39c39ab4..d9d85f4c4811 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_types.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_types.py @@ -10,5 +10,5 @@ if TYPE_CHECKING: from . import models as _models -ComparisonFilterValueItems = Union[str, float] +ComparisonFilterValueItems = Union[str, int] Filters = Union["_models.ComparisonFilter", "_models.CompoundFilter"] diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/_utils/model_base.py b/sdk/ai/azure-ai-projects/azure/ai/projects/_utils/model_base.py index e0637b7cfdc4..4f7316e3cba1 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/_utils/model_base.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/_utils/model_base.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) Python Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -# pylint: disable=protected-access, broad-except, import-error, no-value-for-parameter +# pylint: disable=protected-access, broad-except import copy import calendar @@ -1037,7 +1037,7 @@ def _failsafe_deserialize( ) -> typing.Any: try: return _deserialize(deserializer, response.json(), module, rf, format) - except DeserializationError: + except Exception: # pylint: disable=broad-except _LOGGER.warning( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) @@ -1050,7 +1050,7 @@ def _failsafe_deserialize_xml( ) -> typing.Any: try: return _deserialize_xml(deserializer, response.text()) - except DeserializationError: + except Exception: # pylint: disable=broad-except _LOGGER.warning( "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True ) 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 1b918785c3c0..405bad1f59e3 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 @@ -18,17 +18,12 @@ from ._configuration import AIProjectClientConfiguration from .operations import ( AgentsOperations, + BetaOperations, ConnectionsOperations, DatasetsOperations, DeploymentsOperations, EvaluationRulesOperations, - EvaluationTaxonomiesOperations, - EvaluatorsOperations, IndexesOperations, - InsightsOperations, - MemoryStoresOperations, - RedTeamsOperations, - SchedulesOperations, ) if TYPE_CHECKING: @@ -38,40 +33,30 @@ class AIProjectClient: # pylint: disable=too-many-instance-attributes """AIProjectClient. + :ivar beta: BetaOperations operations + :vartype beta: azure.ai.projects.aio.operations.BetaOperations :ivar agents: AgentsOperations operations :vartype agents: azure.ai.projects.aio.operations.AgentsOperations - :ivar memory_stores: MemoryStoresOperations operations - :vartype memory_stores: azure.ai.projects.aio.operations.MemoryStoresOperations + :ivar evaluation_rules: EvaluationRulesOperations operations + :vartype evaluation_rules: azure.ai.projects.aio.operations.EvaluationRulesOperations :ivar connections: ConnectionsOperations operations :vartype connections: azure.ai.projects.aio.operations.ConnectionsOperations :ivar datasets: DatasetsOperations operations :vartype datasets: azure.ai.projects.aio.operations.DatasetsOperations - :ivar indexes: IndexesOperations operations - :vartype indexes: azure.ai.projects.aio.operations.IndexesOperations :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.ai.projects.aio.operations.DeploymentsOperations - :ivar red_teams: RedTeamsOperations operations - :vartype red_teams: azure.ai.projects.aio.operations.RedTeamsOperations - :ivar evaluation_rules: EvaluationRulesOperations operations - :vartype evaluation_rules: azure.ai.projects.aio.operations.EvaluationRulesOperations - :ivar evaluation_taxonomies: EvaluationTaxonomiesOperations operations - :vartype evaluation_taxonomies: azure.ai.projects.aio.operations.EvaluationTaxonomiesOperations - :ivar evaluators: EvaluatorsOperations operations - :vartype evaluators: azure.ai.projects.aio.operations.EvaluatorsOperations - :ivar insights: InsightsOperations operations - :vartype insights: azure.ai.projects.aio.operations.InsightsOperations - :ivar schedules: SchedulesOperations operations - :vartype schedules: azure.ai.projects.aio.operations.SchedulesOperations + :ivar indexes: IndexesOperations operations + :vartype indexes: azure.ai.projects.aio.operations.IndexesOperations :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". - If you only have one Project in your Foundry Hub, or to target the default Project - in your Hub, use the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". Required. + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-15-preview". Note that overriding this default value may result in unsupported + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is "v1". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ @@ -102,22 +87,15 @@ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: self._serialize = Serializer() self._deserialize = Deserializer() self._serialize.client_side_validation = False + self.beta = BetaOperations(self._client, self._config, self._serialize, self._deserialize) self.agents = AgentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.memory_stores = MemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) - self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.datasets = DatasetsOperations(self._client, self._config, self._serialize, self._deserialize) - self.indexes = IndexesOperations(self._client, self._config, self._serialize, self._deserialize) - self.deployments = DeploymentsOperations(self._client, self._config, self._serialize, self._deserialize) - self.red_teams = RedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) self.evaluation_rules = EvaluationRulesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.evaluation_taxonomies = EvaluationTaxonomiesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.evaluators = EvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) - self.insights = InsightsOperations(self._client, self._config, self._serialize, self._deserialize) - self.schedules = SchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.connections = ConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) + self.datasets = DatasetsOperations(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) def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_configuration.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_configuration.py index 39ed534eb174..cd2d6bca5bff 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_configuration.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/_configuration.py @@ -23,21 +23,21 @@ class AIProjectClientConfiguration: # pylint: disable=too-many-instance-attribu attributes. :param endpoint: Foundry Project endpoint in the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". - If you only have one Project in your Foundry Hub, or to target the default Project - in your Hub, use the form - "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". Required. + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-15-preview". Note that overriding this default value may result in unsupported + :keyword api_version: The API version to use for this operation. Known values are "v1" and + None. Default value is "v1". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, credential: "AsyncTokenCredential", **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2025-11-15-preview") + api_version: str = kwargs.pop("api_version", "v1") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") 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 4a9f2d6ca489..1e195b2fd00a 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 @@ -10,6 +10,7 @@ import os import logging from typing import List, Any +import httpx from openai import AsyncOpenAI from azure.core.tracing.decorator import distributed_trace from azure.core.credentials_async import AsyncTokenCredential @@ -26,44 +27,39 @@ class AIProjectClient(AIProjectClientGenerated): # pylint: disable=too-many-ins :ivar agents: AgentsOperations operations :vartype agents: azure.ai.projects.aio.operations.AgentsOperations - :ivar memory_stores: MemoryStoresOperations operations - :vartype memory_stores: azure.ai.projects.aio.operations.MemoryStoresOperations :ivar connections: ConnectionsOperations operations :vartype connections: azure.ai.projects.aio.operations.ConnectionsOperations :ivar datasets: DatasetsOperations operations :vartype datasets: azure.ai.projects.aio.operations.DatasetsOperations - :ivar indexes: IndexesOperations operations - :vartype indexes: azure.ai.projects.aio.operations.IndexesOperations :ivar deployments: DeploymentsOperations operations :vartype deployments: azure.ai.projects.aio.operations.DeploymentsOperations - :ivar red_teams: RedTeamsOperations operations - :vartype red_teams: azure.ai.projects.aio.operations.RedTeamsOperations - :ivar evaluation_rules: EvaluationRulesOperations operations - :vartype evaluation_rules: azure.ai.projects.aio.operations.EvaluationRulesOperations :ivar evaluation_taxonomies: EvaluationTaxonomiesOperations operations :vartype evaluation_taxonomies: azure.ai.projects.aio.operations.EvaluationTaxonomiesOperations + :ivar evaluation_rules: EvaluationRulesOperations operations + :vartype evaluation_rules: azure.ai.projects.aio.operations.EvaluationRulesOperations :ivar evaluators: EvaluatorsOperations operations :vartype evaluators: azure.ai.projects.aio.operations.EvaluatorsOperations + :ivar indexes: IndexesOperations operations + :vartype indexes: azure.ai.projects.aio.operations.IndexesOperations :ivar insights: InsightsOperations operations :vartype insights: azure.ai.projects.aio.operations.InsightsOperations + :ivar memory_stores: MemoryStoresOperations operations + :vartype memory_stores: azure.ai.projects.aio.operations.MemoryStoresOperations + :ivar red_teams: RedTeamsOperations operations + :vartype red_teams: azure.ai.projects.aio.operations.RedTeamsOperations :ivar schedules: SchedulesOperations operations :vartype schedules: azure.ai.projects.aio.operations.SchedulesOperations :param endpoint: Foundry Project endpoint in the form - ``https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}``. If - you only have one Project in your Foundry Hub, or to target the default Project in your Hub, - use the form - ``https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project``. Required. + "https://{ai-services-account-name}.services.ai.azure.com/api/projects/{project-name}". If you + only have one Project in your Foundry Hub, or to target the default Project in your Hub, use + the form "https://{ai-services-account-name}.services.ai.azure.com/api/projects/_project". + Required. :type endpoint: str :param credential: Credential used to authenticate requests to the service. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :keyword api_version: The API version to use for this operation. Default value is - "2025-11-15-preview". Note that overriding this default value may result in unsupported - behavior. + :keyword api_version: The API version to use for this operation. Default value is "v1". Note + that overriding this default value may result in unsupported behavior. :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :keyword user_agent: Optional string identifying the caller. This string will show up at the front of the "User-Agent" HTTP request header in all network calls this client makes. If an OpenAI client was obtained by calling get_openai_client(), this string will also show up at the front of the "User-Agent" request header in network calls that OpenAI client makes. - :meth:`get_openai_client`. """ def __init__(self, endpoint: str, credential: AsyncTokenCredential, **kwargs: Any) -> None: @@ -102,132 +98,48 @@ def get_openai_client(self, **kwargs: Any) -> "AsyncOpenAI": # type: ignore[nam Keyword arguments are passed to the AsyncOpenAI client constructor. The AsyncOpenAI client constructor is called with: - - * ``base_url`` set to the endpoint provided to the AIProjectClient constructor, with "/openai" appended. - * ``api-version`` set to "2025-05-15-preview" by default, unless overridden by the ``api_version`` keyword argument. - * ``api_key`` set to a get_bearer_token_provider() callable that uses the TokenCredential provided to the AIProjectClient constructor, with scope "https://ai.azure.com/.default". + * ``base_url`` set to the endpoint provided to the AIProjectClient constructor, with "/openai/v1" appended. + Can be overridden by passing ``base_url`` as a keyword argument. + * ``api_key`` set to a get_bearer_token_provider() callable that uses the TokenCredential provided to the + AIProjectClient constructor, with scope "https://ai.azure.com/.default". + Can be overridden by passing ``api_key`` as a keyword argument. .. note:: The packages ``openai`` and ``azure.identity`` must be installed prior to calling this method. :return: An authenticated AsyncOpenAI client :rtype: ~openai.AsyncOpenAI - :raises ~azure.core.exceptions.ModuleNotFoundError: if the ``openai`` package - is not installed. :raises ~azure.core.exceptions.HttpResponseError: """ - base_url = self._config.endpoint.rstrip("/") + "/openai" # pylint: disable=protected-access + kwargs = kwargs.copy() if kwargs else {} - if "default_query" not in kwargs: - kwargs["default_query"] = {"api-version": "2025-11-15-preview"} + # Allow caller to override base_url + if "base_url" in kwargs: + base_url = kwargs.pop("base_url") + else: + base_url = self._config.endpoint.rstrip("/") + "/openai/v1" # pylint: disable=protected-access logger.debug( # pylint: disable=specify-parameter-names-in-call "[get_openai_client] Creating OpenAI client using Entra ID authentication, base_url = `%s`", # pylint: disable=line-too-long base_url, ) - http_client = None - - kwargs = kwargs.copy() if kwargs else {} - - if self._console_logging_enabled: - try: - import httpx - except ModuleNotFoundError as e: - raise ModuleNotFoundError("Failed to import httpx. Please install it using 'pip install httpx'") from e - - class OpenAILoggingTransport(httpx.AsyncHTTPTransport): - - def _sanitize_auth_header(self, headers): - """Sanitize authorization header by redacting sensitive information. - - :param headers: Dictionary of HTTP headers to sanitize - :type headers: dict - """ - - if "authorization" in headers: - auth_value = headers["authorization"] - if len(auth_value) >= 7: - headers["authorization"] = auth_value[:7] + "" - else: - headers["authorization"] = "" - - async def handle_async_request(self, request: httpx.Request) -> httpx.Response: - """ - Log HTTP request and response details to console, in a nicely formatted way, - for OpenAI / Azure OpenAI clients. - - :param request: The HTTP request to handle and log - :type request: httpx.Request - - :return: The HTTP response received - :rtype: httpx.Response - """ - - print(f"\n==> Request:\n{request.method} {request.url}") - headers = dict(request.headers) - self._sanitize_auth_header(headers) - print("Headers:") - for key, value in sorted(headers.items()): - print(f" {key}: {value}") - - self._log_request_body(request) - - response = await super().handle_async_request(request) - - print(f"\n<== Response:\n{response.status_code} {response.reason_phrase}") - print("Headers:") - for key, value in sorted(dict(response.headers).items()): - print(f" {key}: {value}") - - content = await response.aread() - if content is None or content == b"": - print("Body: [No content]") - else: - try: - print(f"Body:\n {content.decode('utf-8')}") - except Exception: # pylint: disable=broad-exception-caught - print(f"Body (raw):\n {content!r}") - print("\n") - - return response - - def _log_request_body(self, request: httpx.Request) -> None: - """Log request body content safely, handling binary data and streaming content. - - :param request: The HTTP request object containing the body to log - :type request: httpx.Request - """ - - # Check content-type header to identify file uploads - content_type = request.headers.get("content-type", "").lower() - if "multipart/form-data" in content_type: - print("Body: [Multipart form data - file upload, not logged]") - return - - # Safely check if content exists without accessing it - if not hasattr(request, "content"): - print("Body: [No content attribute]") - return - - # Very careful content access - wrap in try-catch immediately - try: - content = request.content - except Exception as access_error: # pylint: disable=broad-exception-caught - print(f"Body: [Cannot access content: {access_error}]") - return - - if content is None or content == b"": - print("Body: [No content]") - return - - try: - print(f"Body:\n {content.decode('utf-8')}") - except Exception: # pylint: disable=broad-exception-caught - print(f"Body (raw):\n {content!r}") + # Allow caller to override api_key, otherwise use token provider + if "api_key" in kwargs: + api_key = kwargs.pop("api_key") + else: + api_key = get_bearer_token_provider( + self._config.credential, # pylint: disable=protected-access + "https://ai.azure.com/.default", + ) + if "http_client" in kwargs: + http_client = kwargs.pop("http_client") + elif self._console_logging_enabled: http_client = httpx.AsyncClient(transport=OpenAILoggingTransport()) + else: + http_client = None default_headers = dict[str, str](kwargs.pop("default_headers", None) or {}) @@ -235,11 +147,7 @@ def _log_request_body(self, request: httpx.Request) -> None: def _create_openai_client(**kwargs) -> AsyncOpenAI: return AsyncOpenAI( - # See https://learn.microsoft.com/python/api/azure-identity/azure.identity?view=azure-python#azure-identity-get-bearer-token-provider # pylint: disable=line-too-long - api_key=get_bearer_token_provider( - self._config.credential, # pylint: disable=protected-access - "https://ai.azure.com/.default", - ), + api_key=api_key, base_url=base_url, http_client=http_client, **kwargs, @@ -265,6 +173,107 @@ def _create_openai_client(**kwargs) -> AsyncOpenAI: return client +class OpenAILoggingTransport(httpx.AsyncHTTPTransport): + """Custom HTTP async transport that logs OpenAI API requests and responses to the console. + + This transport wraps httpx.AsyncHTTPTransport to intercept all HTTP traffic and print + detailed request/response information for debugging purposes. It automatically + redacts sensitive authorization headers and handles various content types including + multipart form data (file uploads). + + Used internally by AIProjectClient when console logging is enabled via the + AZURE_AI_PROJECTS_CONSOLE_LOGGING environment variable. + """ + + def _sanitize_auth_header(self, headers): + """Sanitize authorization header by redacting sensitive information. + + :param headers: Dictionary of HTTP headers to sanitize + :type headers: dict + """ + + if "authorization" in headers: + auth_value = headers["authorization"] + if len(auth_value) >= 7: + headers["authorization"] = auth_value[:7] + "" + else: + headers["authorization"] = "" + + async def handle_async_request(self, request: httpx.Request) -> httpx.Response: + """ + Log HTTP request and response details to console, in a nicely formatted way, + for OpenAI / Azure OpenAI clients. + + :param request: The HTTP request to handle and log + :type request: httpx.Request + + :return: The HTTP response received + :rtype: httpx.Response + """ + + print(f"\n==> Request:\n{request.method} {request.url}") + headers = dict(request.headers) + self._sanitize_auth_header(headers) + print("Headers:") + for key, value in sorted(headers.items()): + print(f" {key}: {value}") + + self._log_request_body(request) + + response = await super().handle_async_request(request) + + print(f"\n<== Response:\n{response.status_code} {response.reason_phrase}") + print("Headers:") + for key, value in sorted(dict(response.headers).items()): + print(f" {key}: {value}") + + content = await response.aread() + if content is None or content == b"": + print("Body: [No content]") + else: + try: + print(f"Body:\n {content.decode('utf-8')}") + except Exception: # pylint: disable=broad-exception-caught + print(f"Body (raw):\n {content!r}") + print("\n") + + return response + + def _log_request_body(self, request: httpx.Request) -> None: + """Log request body content safely, handling binary data and streaming content. + + :param request: The HTTP request object containing the body to log + :type request: httpx.Request + """ + + # Check content-type header to identify file uploads + content_type = request.headers.get("content-type", "").lower() + if "multipart/form-data" in content_type: + print("Body: [Multipart form data - file upload, not logged]") + return + + # Safely check if content exists without accessing it + if not hasattr(request, "content"): + print("Body: [No content attribute]") + return + + # Very careful content access - wrap in try-catch immediately + try: + content = request.content + except Exception as access_error: # pylint: disable=broad-exception-caught + print(f"Body: [Cannot access content: {access_error}]") + return + + if content is None or content == b"": + print("Body: [No content]") + return + + try: + print(f"Body:\n {content.decode('utf-8')}") + except Exception: # pylint: disable=broad-exception-caught + print(f"Body (raw):\n {content!r}") + + __all__: List[str] = ["AIProjectClient"] # Add all objects you want publicly available to users at this package level 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 5ae1225f30fa..1a1c0ffec86c 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 @@ -12,36 +12,26 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import BetaOperations # type: ignore from ._operations import AgentsOperations # type: ignore -from ._operations import MemoryStoresOperations # type: ignore +from ._operations import EvaluationRulesOperations # type: ignore from ._operations import ConnectionsOperations # type: ignore from ._operations import DatasetsOperations # type: ignore -from ._operations import IndexesOperations # type: ignore from ._operations import DeploymentsOperations # type: ignore -from ._operations import RedTeamsOperations # type: ignore -from ._operations import EvaluationRulesOperations # type: ignore -from ._operations import EvaluationTaxonomiesOperations # type: ignore -from ._operations import EvaluatorsOperations # type: ignore -from ._operations import InsightsOperations # type: ignore -from ._operations import SchedulesOperations # type: ignore +from ._operations import IndexesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "BetaOperations", "AgentsOperations", - "MemoryStoresOperations", + "EvaluationRulesOperations", "ConnectionsOperations", "DatasetsOperations", - "IndexesOperations", "DeploymentsOperations", - "RedTeamsOperations", - "EvaluationRulesOperations", - "EvaluationTaxonomiesOperations", - "EvaluatorsOperations", - "InsightsOperations", - "SchedulesOperations", + "IndexesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 c5bbefb67fe9..2b2706e9c30c 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 @@ -1,4 +1,4 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,9 +35,10 @@ from ... import models as _models from ..._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from ..._utils.serialization import Deserializer, Serializer +from ...models._enums import FoundryFeaturesOptInKeys from ...operations._operations import ( - build_agents_create_from_manifest_request, - build_agents_create_request, + build_agents_create_agent_from_manifest_request, + build_agents_create_agent_request, build_agents_create_version_from_manifest_request, build_agents_create_version_request, build_agents_delete_request, @@ -46,9 +47,39 @@ build_agents_get_version_request, build_agents_list_request, build_agents_list_versions_request, - build_agents_stream_agent_container_logs_request, - build_agents_update_from_manifest_request, - build_agents_update_request, + build_agents_update_agent_from_manifest_request, + build_agents_update_agent_request, + build_beta_evaluation_taxonomies_create_request, + build_beta_evaluation_taxonomies_delete_request, + build_beta_evaluation_taxonomies_get_request, + build_beta_evaluation_taxonomies_list_request, + build_beta_evaluation_taxonomies_update_request, + build_beta_evaluators_create_version_request, + build_beta_evaluators_delete_version_request, + build_beta_evaluators_get_version_request, + build_beta_evaluators_list_latest_versions_request, + build_beta_evaluators_list_versions_request, + build_beta_evaluators_update_version_request, + build_beta_insights_generate_request, + build_beta_insights_get_request, + build_beta_insights_list_request, + build_beta_memory_stores_create_request, + build_beta_memory_stores_delete_request, + build_beta_memory_stores_delete_scope_request, + build_beta_memory_stores_get_request, + build_beta_memory_stores_list_request, + build_beta_memory_stores_search_memories_request, + build_beta_memory_stores_update_memories_request, + build_beta_memory_stores_update_request, + build_beta_red_teams_create_request, + build_beta_red_teams_get_request, + build_beta_red_teams_list_request, + build_beta_schedules_create_or_update_request, + build_beta_schedules_delete_request, + build_beta_schedules_get_request, + build_beta_schedules_get_run_request, + build_beta_schedules_list_request, + build_beta_schedules_list_runs_request, build_connections_get_request, build_connections_get_with_credentials_request, build_connections_list_request, @@ -65,42 +96,11 @@ build_evaluation_rules_delete_request, build_evaluation_rules_get_request, build_evaluation_rules_list_request, - build_evaluation_taxonomies_create_request, - build_evaluation_taxonomies_delete_request, - build_evaluation_taxonomies_get_request, - build_evaluation_taxonomies_list_request, - build_evaluation_taxonomies_update_request, - build_evaluators_create_version_request, - build_evaluators_delete_version_request, - build_evaluators_get_version_request, - build_evaluators_list_latest_versions_request, - build_evaluators_list_versions_request, - build_evaluators_update_version_request, build_indexes_create_or_update_request, build_indexes_delete_request, build_indexes_get_request, build_indexes_list_request, build_indexes_list_versions_request, - build_insights_generate_request, - build_insights_get_request, - build_insights_list_request, - build_memory_stores_create_request, - build_memory_stores_delete_request, - build_memory_stores_delete_scope_request, - build_memory_stores_get_request, - build_memory_stores_list_request, - build_memory_stores_search_memories_request, - build_memory_stores_update_memories_request, - build_memory_stores_update_request, - build_red_teams_create_request, - build_red_teams_get_request, - build_red_teams_list_request, - build_schedules_create_or_update_request, - build_schedules_delete_request, - build_schedules_get_request, - build_schedules_get_run_request, - build_schedules_list_request, - build_schedules_list_runs_request, ) from .._configuration import AIProjectClientConfiguration @@ -111,6 +111,33 @@ List = list +class BetaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`beta` 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") + + self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.evaluators = BetaEvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.insights = BetaInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.red_teams = BetaRedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = BetaSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + + class AgentsOperations: """ .. warning:: @@ -193,84 +220,68 @@ async def get(self, agent_name: str, **kwargs: Any) -> _models.AgentDetails: return deserialized # type: ignore @overload - async def create( + async def _create_agent( self, *, name: str, definition: _models.AgentDefinition, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, content_type: str = "application/json", metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any - ) -> _models.AgentDetails: - """Creates the agent. - - :keyword name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :paramtype name: str - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :paramtype definition: ~azure.ai.projects.models.AgentDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - async def create( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Creates the 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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + async def _create_agent( + self, + body: JSON, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... @overload - async def create( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Creates the 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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _create_agent( + self, + body: IO[bytes], + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... @distributed_trace_async - async def create( + async def _create_agent( self, body: Union[JSON, IO[bytes]] = _Unset, *, name: str = _Unset, definition: _models.AgentDefinition = _Unset, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any @@ -289,6 +300,14 @@ async def create( :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. @@ -330,7 +349,8 @@ async def create( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_create_request( + _request = build_agents_create_agent_request( + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -373,92 +393,76 @@ async def create( return deserialized # type: ignore @overload - async def update( + async def _update_agent( self, agent_name: str, *, definition: _models.AgentDefinition, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, content_type: str = "application/json", metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :paramtype definition: ~azure.ai.projects.models.AgentDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - async def update( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + async def _update_agent( + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... @overload - async def update( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to retrieve. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def _update_agent( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... @distributed_trace_async - async def update( + async def _update_agent( self, agent_name: str, body: Union[JSON, IO[bytes]] = _Unset, *, definition: _models.AgentDefinition = _Unset, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. + """Updates the agent by adding a new version if there are any changes to the agent definition. If + no changes, returns the existing agent version. :param agent_name: The name of the agent to retrieve. Required. :type agent_name: str @@ -467,6 +471,14 @@ async def update( :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. @@ -506,8 +518,9 @@ async def update( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_update_request( + _request = build_agents_update_agent_request( agent_name=agent_name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -550,7 +563,7 @@ async def update( return deserialized # type: ignore @overload - async def create_from_manifest( + async def _create_agent_from_manifest( self, *, name: str, @@ -560,72 +573,18 @@ async def create_from_manifest( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any - ) -> _models.AgentDetails: - """Creates an agent from a manifest. - - :keyword name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :paramtype name: str - :keyword manifest_id: The manifest ID to import the agent version from. Required. - :paramtype manifest_id: str - :keyword parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :paramtype parameter_values: dict[str, any] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - async def create_from_manifest( + async def _create_agent_from_manifest( self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Creates an agent from a manifest. - - :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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - async def create_from_manifest( + async def _create_agent_from_manifest( self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Creates an agent from a manifest. - - :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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> _models.AgentDetails: ... @distributed_trace_async - async def create_from_manifest( + async def _create_agent_from_manifest( self, body: Union[JSON, IO[bytes]] = _Unset, *, @@ -701,7 +660,7 @@ async def create_from_manifest( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_create_from_manifest_request( + _request = build_agents_create_agent_from_manifest_request( content_type=content_type, api_version=self._config.api_version, content=_content, @@ -744,7 +703,7 @@ async def create_from_manifest( return deserialized # type: ignore @overload - async def update_from_manifest( + async def _update_agent_from_manifest( self, agent_name: str, *, @@ -754,21 +713,40 @@ async def update_from_manifest( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any + ) -> _models.AgentDetails: ... + @overload + async def _update_agent_from_manifest( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentDetails: ... + @overload + async def _update_agent_from_manifest( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentDetails: ... + + @distributed_trace_async + async def _update_agent_from_manifest( + self, + agent_name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + manifest_id: str = _Unset, + parameter_values: dict[str, Any] = _Unset, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + **kwargs: Any ) -> _models.AgentDetails: """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. + definition. If no changes, returns the existing agent version. :param agent_name: The name of the agent to update. Required. :type agent_name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] :keyword manifest_id: The manifest ID to import the agent version from. Required. :paramtype manifest_id: str :keyword parameter_values: The inputs to the manifest that will result in a fully materialized Agent. Required. :paramtype parameter_values: dict[str, any] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. @@ -782,95 +760,16 @@ async def update_from_manifest( :rtype: ~azure.ai.projects.models.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def update_from_manifest( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def update_from_manifest( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def update_from_manifest( - self, - agent_name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - manifest_id: str = _Unset, - parameter_values: dict[str, Any] = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword manifest_id: The manifest ID to import the agent version from. Required. - :paramtype manifest_id: str - :keyword parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :paramtype parameter_values: dict[str, any] - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :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 {} + _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.AgentDetails] = kwargs.pop("cls", None) @@ -894,7 +793,7 @@ async def update_from_manifest( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_update_from_manifest_request( + _request = build_agents_update_agent_from_manifest_request( agent_name=agent_name, content_type=content_type, api_version=self._config.api_version, @@ -1099,6 +998,13 @@ async def create_version( agent_name: str, *, definition: _models.AgentDefinition, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, content_type: str = "application/json", metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, @@ -1116,6 +1022,14 @@ async def create_version( :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1135,7 +1049,19 @@ async def create_version( @overload async def create_version( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AgentVersionDetails: """Create a new agent version. @@ -1148,6 +1074,14 @@ async def create_version( :type agent_name: str :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1158,7 +1092,19 @@ async def create_version( @overload async def create_version( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AgentVersionDetails: """Create a new agent version. @@ -1171,6 +1117,14 @@ async def create_version( :type agent_name: str :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -1186,6 +1140,13 @@ async def create_version( body: Union[JSON, IO[bytes]] = _Unset, *, definition: _models.AgentDefinition = _Unset, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any @@ -1204,6 +1165,14 @@ async def create_version( :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. @@ -1245,6 +1214,7 @@ async def create_version( _request = build_agents_create_version_request( agent_name=agent_name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -1720,115 +1690,15 @@ async def get_next(_continuation_token=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def stream_agent_container_logs( - self, - agent_name: str, - agent_version: str, - *, - kind: Optional[Union[str, _models.ContainerLogKind]] = None, - replica_name: Optional[str] = None, - tail: Optional[int] = None, - **kwargs: Any - ) -> None: - """Container log entry streamed from the container as text chunks. - Each chunk is a UTF-8 string that may be either a plain text log line - or a JSON-formatted log entry, depending on the type of container log being streamed. - Clients should treat each chunk as opaque text and, if needed, attempt - to parse it as JSON based on their logging requirements. - - For system logs, the format is JSON with the following structure: - {"TimeStamp":"2025-12-15T16:51:33Z","Type":"Normal","ContainerAppName":null,"RevisionName":null,"ReplicaName":null,"Msg":"Connecting - to the events - collector...","Reason":"StartingGettingEvents","EventSource":"ContainerAppController","Count":1} - {"TimeStamp":"2025-12-15T16:51:34Z","Type":"Normal","ContainerAppName":null,"RevisionName":null,"ReplicaName":null,"Msg":"Successfully - connected to events - server","Reason":"ConnectedToEventsServer","EventSource":"ContainerAppController","Count":1} - - For console logs, the format is plain text as emitted by the container's stdout/stderr. - 2025-12-15T08:43:48.72656 Connecting to the container 'agent-container'... - 2025-12-15T08:43:48.75451 Successfully Connected to container: 'agent-container' [Revision: - 'je90fe655aa742ef9a188b9fd14d6764--7tca06b', Replica: - 'je90fe655aa742ef9a188b9fd14d6764--7tca06b-6898b9c89f-mpkjc'] - 2025-12-15T08:33:59.0671054Z stdout F INFO: 127.0.0.1:42588 - "GET /readiness HTTP/1.1" 200 - OK - 2025-12-15T08:34:29.0649033Z stdout F INFO: 127.0.0.1:60246 - "GET /readiness HTTP/1.1" 200 - OK - 2025-12-15T08:34:59.0644467Z stdout F INFO: 127.0.0.1:43994 - "GET /readiness HTTP/1.1" 200 - OK. - - :param agent_name: The name of the agent. Required. - :type agent_name: str - :param agent_version: The version of the agent. Required. - :type agent_version: str - :keyword kind: console returns container stdout/stderr, system returns container app event - stream. defaults to console. Known values are: "console" and "system". Default value is None. - :paramtype kind: str or ~azure.ai.projects.models.ContainerLogKind - :keyword replica_name: When omitted, the server chooses the first replica for console logs. - Required to target a specific replica. Default value is None. - :paramtype replica_name: str - :keyword tail: Number of trailing lines returned. Enforced to 1-300. Defaults to 20. Default - value is None. - :paramtype tail: int - :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_agents_stream_agent_container_logs_request( - agent_name=agent_name, - agent_version=agent_version, - kind=kind, - replica_name=replica_name, - tail=tail, - 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 [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) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - -class MemoryStoresOperations: +class EvaluationRulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`memory_stores` attribute. + :attr:`evaluation_rules` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -1838,94 +1708,14 @@ 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") - @overload - async def create( - self, - *, - name: str, - definition: _models.MemoryStoreDefinition, - content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. - - :keyword name: The name of the memory store. Required. - :paramtype name: str - :keyword definition: The memory store definition. Required. - :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. - - :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: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. - - :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: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def create( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: str = _Unset, - definition: _models.MemoryStoreDefinition = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. + async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: + """Get an evaluation rule. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: The name of the memory store. Required. - :paramtype name: str - :keyword definition: The memory store definition. Required. - :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition - :keyword description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -1936,30 +1726,14 @@ async def create( } 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.MemoryStoreDetails] = kwargs.pop("cls", None) - - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata, "name": name} - 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 + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - _request = build_memory_stores_create_request( - content_type=content_type, + _request = build_evaluation_rules_get_request( + id=id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -1982,108 +1756,168 @@ async def create( 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() else: - deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) + deserialized = _deserialize(_models.EvaluationRule, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def update( + @distributed_trace_async + async def delete(self, id: str, **kwargs: Any) -> None: + """Delete an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: 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_evaluation_rules_delete_request( + id=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) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_or_update( self, - name: str, + id: str, + evaluation_rule: _models.EvaluationRule, *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :param name: The name of the memory store to update. Required. - :type name: str + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + async def create_or_update( + self, + id: str, + evaluation_rule: JSON, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :param name: The name of the memory store to update. Required. - :type name: str - :param body: Required. - :type body: JSON + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + async def create_or_update( + self, + id: str, + evaluation_rule: IO[bytes], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :param name: The name of the memory store to update. Required. - :type name: str - :param body: Required. - :type body: IO[bytes] + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( + async def create_or_update( self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, + id: str, + evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], *, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :param name: The name of the memory store 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 description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Is one of the following types: + EvaluationRule, JSON, IO[bytes] Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2098,20 +1932,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.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - if body is _Unset: - body = {"description": description, "metadata": metadata} - 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(evaluation_rule, (IOBase, bytes)): + _content = evaluation_rule else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_memory_stores_update_request( - name=name, + _request = build_evaluation_rules_create_or_update_request( + id=id, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -2130,39 +1962,52 @@ async def update( 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() else: - deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) + deserialized = _deserialize(_models.EvaluationRule, 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.MemoryStoreDetails: - """Retrieve a memory store. + @distributed_trace + def list( + self, + *, + action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, + agent_name: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.EvaluationRule"]: + """List all evaluation rules. - :param name: The name of the memory store to retrieve. Required. - :type name: str - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :keyword action_type: Filter by the type of evaluation rule. Known values are: + "continuousEvaluation" and "humanEvaluationPreview". Default value is None. + :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of EvaluationRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluationRule] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.EvaluationRule]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2171,120 +2016,55 @@ async def get(self, name: str, **kwargs: Any) -> _models.MemoryStoreDetails: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) + def prepare_request(next_link=None): + if not next_link: - _request = build_memory_stores_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) + _request = build_evaluation_rules_list_request( + action_type=action_type, + agent_name=agent_name, + enabled=enabled, + 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 = 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), 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 - - 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() - else: - deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.MemoryStoreDetails"]: - """List all memory stores. - - :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 MemoryStoreDetails - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.MemoryStoreDetails] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.MemoryStoreDetails]] = 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_memory_stores_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 + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.MemoryStoreDetails], deserialized.get("data", [])) + list_of_elem = _deserialize(List[_models.EvaluationRule], 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 @@ -2294,24 +2074,38 @@ 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) + +class ConnectionsOperations: + """ + .. 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(self, name: str, **kwargs: Any) -> _models.DeleteMemoryStoreResult: - """Delete a memory store. + async def _get(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection by name, without populating connection credentials. - :param name: The name of the memory store to delete. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :return: DeleteMemoryStoreResult. The DeleteMemoryStoreResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DeleteMemoryStoreResult + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2325,9 +2119,9 @@ async def delete(self, name: str, **kwargs: Any) -> _models.DeleteMemoryStoreRes _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.DeleteMemoryStoreResult] = kwargs.pop("cls", None) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_memory_stores_delete_request( + _request = build_connections_get_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -2352,122 +2146,31 @@ async def delete(self, name: str, **kwargs: Any) -> _models.DeleteMemoryStoreRes 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) + + 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() else: - deserialized = _deserialize(_models.DeleteMemoryStoreResult, 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 search_memories( - self, - name: str, - *, - scope: str, - content_type: str = "application/json", - items: Optional[List[_models.InputItem]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_models.MemorySearchOptions] = None, - **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. - - :param name: The name of the memory store to search. Required. - :type name: str - :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :paramtype scope: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword items: Items for which to search for relevant memories. Default value is None. - :paramtype items: list[~azure.ai.projects.models.InputItem] - :keyword previous_search_id: The unique ID of the previous search request, enabling incremental - memory search from where the last operation left off. Default value is None. - :paramtype previous_search_id: str - :keyword options: Memory search options. Default value is None. - :paramtype options: ~azure.ai.projects.models.MemorySearchOptions - :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def search_memories( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. - - :param name: The name of the memory store to search. 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: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def search_memories( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. - - :param name: The name of the memory store to search. 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: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def search_memories( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - scope: str = _Unset, - items: Optional[List[_models.InputItem]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_models.MemorySearchOptions] = None, - **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. + async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection by name, with its connection credentials. - :param name: The name of the memory store to search. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :paramtype scope: str - :keyword items: Items for which to search for relevant memories. Default value is None. - :paramtype items: list[~azure.ai.projects.models.InputItem] - :keyword previous_search_id: The unique ID of the previous search request, enabling incremental - memory search from where the last operation left off. Default value is None. - :paramtype previous_search_id: str - :keyword options: Memory search options. Default value is None. - :paramtype options: ~azure.ai.projects.models.MemorySearchOptions - :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2478,34 +2181,365 @@ async def search_memories( } 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.MemoryStoreSearchResult] = kwargs.pop("cls", None) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = { - "items": items, - "options": options, - "previous_search_id": previous_search_id, - "scope": scope, - } - 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 + _request = build_connections_get_with_credentials_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 = 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) + 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() else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + deserialized = _deserialize(_models.Connection, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # 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 all connections in the project, without populating connection credentials. - _request = build_memory_stores_search_memories_request( + :keyword connection_type: List connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. + :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType + :keyword default_connection: List 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 {} + + cls: ClsType[List[_models.Connection]] = 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_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) + + 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), 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) + + 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 DatasetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`datasets` 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.DatasetVersion"]: + """List all versions of the given DatasetVersion. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatasetVersion]] = 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_datasets_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) + + 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), 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) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DatasetVersion], 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) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: + """List the latest version of each DatasetVersion. + + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatasetVersion]] = 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_datasets_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), 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) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DatasetVersion], 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) + + @distributed_trace_async + async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: + """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the + DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to retrieve. Required. + :type version: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :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.DatasetVersion] = kwargs.pop("cls", None) + + _request = build_datasets_get_request( name=name, - content_type=content_type, + version=version, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -2528,33 +2562,31 @@ async def search_memories( 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() else: - deserialized = _deserialize(_models.MemoryStoreSearchResult, response.json()) + deserialized = _deserialize(_models.DatasetVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - async def _update_memories_initial( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - scope: str = _Unset, - items: Optional[List[_models.InputItem]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - **kwargs: Any - ) -> AsyncIterator[bytes]: + @distributed_trace_async + async def delete(self, name: str, version: str, **kwargs: Any) -> None: + """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the + DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the DatasetVersion to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -2563,34 +2595,15 @@ async def _update_memories_initial( } 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[AsyncIterator[bytes]] = kwargs.pop("cls", None) - - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = { - "items": items, - "previous_update_id": previous_update_id, - "scope": scope, - "update_delay": update_delay, - } - 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 + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_memory_stores_update_memories_request( + _request = build_datasets_delete_request( name=name, - content_type=content_type, + version=version, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -2599,229 +2612,274 @@ async def _update_memories_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = True + _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 [202]: - 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, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - - deserialized = response.iter_bytes() + raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @overload - async def _begin_update_memories( + async def create_or_update( self, name: str, + version: str, + dataset_version: _models.DatasetVersion, *, - scope: str, - content_type: str = "application/json", - items: Optional[List[_models.InputItem]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: ... - @overload - async def _begin_update_memories( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion + :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: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - async def _begin_update_memories( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + async def create_or_update( + self, + name: str, + version: str, + dataset_version: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. - @distributed_trace_async - async def _begin_update_memories( + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: 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: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( self, name: str, - body: Union[JSON, IO[bytes]] = _Unset, + version: str, + dataset_version: IO[bytes], *, - scope: str = _Unset, - items: Optional[List[_models.InputItem]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: - """Update memory store with conversation memories. + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. - :param name: The name of the memory store 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 scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :paramtype scope: str - :keyword items: Conversation items from which to extract memories. Default value is None. - :paramtype items: list[~azure.ai.projects.models.InputItem] - :keyword previous_update_id: The unique ID of the previous update request, enabling incremental - memory updates from where the last operation left off. Default value is None. - :paramtype previous_update_id: str - :keyword update_delay: Timeout period before processing the memory update in seconds. - If a new update request is received during this period, it will cancel the current request and - reset the timeout. - Set to 0 to immediately trigger the update without delay. - Defaults to 300 (5 minutes). Default value is None. - :paramtype update_delay: int - :return: An instance of AsyncLROPoller that returns MemoryStoreUpdateCompletedResult. The - MemoryStoreUpdateCompletedResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.MemoryStoreUpdateCompletedResult] + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: 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: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Is one of the following types: + DatasetVersion, JSON, IO[bytes] Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion :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.MemoryStoreUpdateCompletedResult] = 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._update_memories_initial( - name=name, - body=body, - scope=scope, - items=items, - previous_update_id=previous_update_id, - update_delay=update_delay, - 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") - ) + cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) - deserialized = _deserialize(_models.MemoryStoreUpdateCompletedResult, response.json().get("result", {})) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(dataset_version, (IOBase, bytes)): + _content = dataset_version + else: + _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _request = build_datasets_create_or_update_request( + name=name, + version=version, + 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) - 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.MemoryStoreUpdateCompletedResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _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, 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) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.DatasetVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload - async def delete_scope( - self, name: str, *, scope: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: _models.PendingUploadRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. Required. + :param name: The name of the resource. Required. :type name: str - :keyword scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :paramtype scope: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def delete_scope( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. 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 DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def delete_scope( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. 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 DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: 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: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def delete_scope( - self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, scope: str = _Unset, **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. 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 scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :paramtype scope: str - :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Is one of the following + types: PendingUploadRequest, JSON, IO[bytes] Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or + IO[bytes] + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2836,22 +2894,18 @@ async def delete_scope( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) + cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = {"scope": scope} - 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(pending_upload_request, (IOBase, bytes)): + _content = pending_upload_request else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_memory_stores_delete_scope_request( + _request = build_datasets_pending_upload_request( name=name, + version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -2877,48 +2931,28 @@ async def delete_scope( 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() else: - deserialized = _deserialize(_models.MemoryStoreDeleteScopeResult, response.json()) + deserialized = _deserialize(_models.PendingUploadResponse, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class ConnectionsOperations: - """ - .. 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 _get(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection by name, without populating connection credentials. + async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: + """Get the SAS credential to access the storage account associated with a Dataset version. - :param name: The friendly name of the connection, provided by the user. Required. + :param name: The name of the resource. Required. :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetCredential :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2932,10 +2966,11 @@ async def _get(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.DatasetCredential] = kwargs.pop("cls", None) - _request = build_connections_get_request( + _request = build_datasets_get_credentials_request( name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2961,29 +2996,42 @@ async def _get(self, name: str, **kwargs: Any) -> _models.Connection: 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() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.DatasetCredential, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class DeploymentsOperations: + """ + .. 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 _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection by name, with its connection credentials. + async def get(self, name: str, **kwargs: Any) -> _models.Deployment: + """Get a deployed model. - :param name: The friendly name of the connection, provided by the user. Required. + :param name: Name of the deployment. Required. :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2997,9 +3045,9 @@ 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.Deployment] = kwargs.pop("cls", None) - _request = build_connections_get_with_credentials_request( + _request = build_deployments_get_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -3034,7 +3082,7 @@ async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Conne if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.Deployment, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -3045,27 +3093,29 @@ async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Conne def list( self, *, - connection_type: Optional[Union[str, _models.ConnectionType]] = None, - default_connection: Optional[bool] = None, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[Union[str, _models.DeploymentType]] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Connection"]: - """List all connections in the project, without populating connection credentials. + ) -> AsyncItemPaged["_models.Deployment"]: + """List all deployed models in the project. - :keyword connection_type: List connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool". Default value is None. - :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType - :keyword default_connection: List 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] + :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 {} - cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3078,9 +3128,10 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, + _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, @@ -3116,7 +3167,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Connection], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Deployment], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -3139,14 +3190,14 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) -class DatasetsOperations: +class IndexesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`datasets` attribute. + :attr:`indexes` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -3157,19 +3208,19 @@ def __init__(self, *args, **kwargs) -> None: 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.DatasetVersion"]: - """List all versions of the given DatasetVersion. + def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: + """List all versions of the given Index. :param name: The name of the resource. Required. :type name: str - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] + :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.DatasetVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3182,7 +3233,7 @@ def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Dat def prepare_request(next_link=None): if not next_link: - _request = build_datasets_list_versions_request( + _request = build_indexes_list_versions_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -3219,7 +3270,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.DatasetVersion], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -3242,17 +3293,17 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: - """List the latest version of each DatasetVersion. + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: + """List the latest version of each Index. - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] + :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.DatasetVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3265,7 +3316,7 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: def prepare_request(next_link=None): if not next_link: - _request = build_datasets_list_request( + _request = build_indexes_list_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -3301,7 +3352,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.DatasetVersion], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -3324,16 +3375,16 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: - """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the - DatasetVersion does not exist. + async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: + """Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. :param name: The name of the resource. Required. :type name: str - :param version: The specific version id of the DatasetVersion to retrieve. Required. + :param version: The specific version id of the Index to retrieve. Required. :type version: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3347,9 +3398,9 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVe _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - _request = build_datasets_get_request( + _request = build_indexes_get_request( name=name, version=version, api_version=self._config.api_version, @@ -3380,7 +3431,7 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVe if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3389,12 +3440,12 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVe @distributed_trace_async async def delete(self, name: str, version: str, **kwargs: Any) -> None: - """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the - DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + """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 name: The name of the resource. Required. :type name: str - :param version: The version of the DatasetVersion to delete. Required. + :param version: The version of the Index to delete. Required. :type version: str :return: None :rtype: None @@ -3413,7 +3464,7 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None: cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_datasets_delete_request( + _request = build_indexes_delete_request( name=name, version=version, api_version=self._config.api_version, @@ -3444,255 +3495,88 @@ async def create_or_update( self, name: str, version: str, - dataset_version: _models.DatasetVersion, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion - :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: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - name: str, - version: str, - dataset_version: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: 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: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create_or_update( - self, - name: str, - version: str, - dataset_version: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: 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: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Is one of the following types: - DatasetVersion, JSON, IO[bytes] Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :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.DatasetVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _content = None - if isinstance(dataset_version, (IOBase, bytes)): - _content = dataset_version - else: - _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_datasets_create_or_update_request( - name=name, - version=version, - 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) - - _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, 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) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: _models.PendingUploadRequest, + index: _models.Index, *, - content_type: str = "application/json", + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. + ) -> _models.Index: + """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 DatasetVersion to operate on. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest + :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 - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. + async def create_or_update( + self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.Index: + """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 DatasetVersion to operate on. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: JSON + :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: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def pending_upload( + async def create_or_update( self, name: str, version: str, - pending_upload_request: IO[bytes], + index: IO[bytes], *, - content_type: str = "application/json", + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. + ) -> _models.Index: + """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 DatasetVersion to operate on. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: IO[bytes] + :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: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. + async def create_or_update( + self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Index: + """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 DatasetVersion to operate on. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param pending_upload_request: The pending upload request parameters. Is one of the following - types: PendingUploadRequest, JSON, IO[bytes] Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or - IO[bytes] - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :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 = { @@ -3707,16 +3591,16 @@ async def pending_upload( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(pending_upload_request, (IOBase, bytes)): - _content = pending_upload_request + if isinstance(index, (IOBase, bytes)): + _content = index else: - _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_datasets_pending_upload_request( + _request = build_indexes_create_or_update_request( name=name, version=version, content_type=content_type, @@ -3737,70 +3621,7 @@ async def pending_upload( 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) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.PendingUploadResponse, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: - """Get the SAS credential to access the storage account associated with a Dataset version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetCredential - :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.DatasetCredential] = kwargs.pop("cls", None) - - _request = build_datasets_get_credentials_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 = 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 response.status_code not in [200, 201]: if _stream: try: await response.read() # Load the body in memory and close the socket @@ -3812,7 +3633,7 @@ async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _mode if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.DatasetCredential, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3820,14 +3641,14 @@ async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _mode return deserialized # type: ignore -class IndexesOperations: +class BetaEvaluationTaxonomiesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`indexes` attribute. + :attr:`evaluation_taxonomies` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -3837,21 +3658,19 @@ 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 - def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: - """List all versions of the given Index. + @distributed_trace_async + async def get(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: + """Get an evaluation run by name. :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] + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) - + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3860,80 +3679,70 @@ def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Ind } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _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) - - 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), 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) - - return _request + _headers = 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", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _request = build_beta_evaluation_taxonomies_get_request( + name=name, + foundry_features=foundry_features, + 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 + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + response = pipeline_response.http_response - return pipeline_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) + raise HttpResponseError(response=response) - return AsyncItemPaged(get_next, extract_data) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: - """List the latest version of each Index. + def list( + self, *, input_name: Optional[str] = None, input_type: Optional[str] = None, **kwargs: Any + ) -> AsyncItemPaged["_models.EvaluationTaxonomy"]: + """List evaluation taxonomies. - :return: An iterator like instance of Index - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] + :keyword input_name: Filter by the evaluation input name. Default value is None. + :paramtype input_name: str + :keyword input_type: Filter by taxonomy input type. Default value is None. + :paramtype input_type: str + :return: An iterator like instance of EvaluationTaxonomy + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluationTaxonomy] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluationTaxonomy]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3946,7 +3755,10 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: def prepare_request(next_link=None): if not next_link: - _request = build_indexes_list_request( + _request = build_beta_evaluation_taxonomies_list_request( + foundry_features=foundry_features, + input_name=input_name, + input_type=input_type, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3982,7 +3794,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.EvaluationTaxonomy], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -4005,18 +3817,18 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: - """Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. + async def delete(self, name: str, **kwargs: Any) -> None: + """Delete an evaluation taxonomy by name. :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 + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4028,11 +3840,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[None] = kwargs.pop("cls", None) - _request = build_indexes_get_request( + _request = build_beta_evaluation_taxonomies_delete_request( name=name, - version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4042,45 +3854,92 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _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) raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Index, 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 create( + self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.projects.models.EvaluationTaxonomy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. 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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. 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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def delete(self, name: str, version: str, **kwargs: Any) -> None: - """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 create( + self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. Required. :type name: str - :param version: The version of the Index to delete. Required. - :type version: str - :return: None - :rtype: None + :param body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, JSON, + IO[bytes] Required. + :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4089,15 +3948,25 @@ async def delete(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[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) - _request = build_indexes_delete_request( + 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_beta_evaluation_taxonomies_create_request( name=name, - version=version, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -4106,109 +3975,104 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _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, 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) + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # 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 a new or update an existing Index with the given version id. + async def update( + self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. 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 + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.projects.models.EvaluationTaxonomy :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: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :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 a new or update an existing Index with the given version id. + async def update( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. 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 + :param body: The evaluation taxonomy. 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: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :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 a new or update an existing Index with the given version id. + async def update( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :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] + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. 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: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :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 a new or update an existing Index with the given version id. + async def update( + self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. 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, + :param body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, 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 + :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4221,18 +4085,18 @@ async def create_or_update( _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) + cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) - content_type = content_type or "application/merge-patch+json" + content_type = content_type or "application/json" _content = None - if isinstance(index, (IOBase, bytes)): - _content = index + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_indexes_create_or_update_request( + _request = build_beta_evaluation_taxonomies_update_request( name=name, - version=version, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -4251,7 +4115,7 @@ 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 @@ -4263,7 +4127,7 @@ async def create_or_update( if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4271,14 +4135,14 @@ async def create_or_update( return deserialized # type: ignore -class DeploymentsOperations: +class BetaEvaluatorsOperations: """ .. 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. + :attr:`evaluators` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -4288,98 +4152,37 @@ 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.Deployment: - """Get a deployed model. - - :param name: Name of the deployment. Required. - :type name: str - :return: Deployment. The Deployment is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Deployment - :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.Deployment] = kwargs.pop("cls", None) - - _request = build_deployments_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) - - _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) - 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() - else: - deserialized = _deserialize(_models.Deployment, response.json()) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - @distributed_trace - def list( + def list_versions( self, + name: str, *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.Deployment"]: - """List all deployed models in the project. + ) -> AsyncItemPaged["_models.EvaluatorVersion"]: + """List all versions of the given evaluator. - :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 + :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 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] + :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] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4392,10 +4195,11 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, + _request = build_beta_evaluators_list_versions_request( + name=name, + foundry_features=foundry_features, + type=type, + limit=limit, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4431,7 +4235,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Deployment], deserialized.get("value", [])) + 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) @@ -4453,101 +4257,34 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - -class RedTeamsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`red_teams` 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 get(self, name: str, **kwargs: Any) -> _models.RedTeam: - """Get a redteam by name. - - :param name: Identifier of the red team run. Required. - :type name: str - :return: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam - :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.RedTeam] = kwargs.pop("cls", None) - - _request = build_red_teams_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) - - _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) - 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() - else: - deserialized = _deserialize(_models.RedTeam, response.json()) - - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.RedTeam"]: - """List a redteam by name. + def list_latest_versions( + self, + *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.EvaluatorVersion"]: + """List the latest version of each evaluator. - :return: An iterator like instance of RedTeam - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.RedTeam] + :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] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.RedTeam]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4560,7 +4297,10 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.RedTeam"]: def prepare_request(next_link=None): if not next_link: - _request = build_red_teams_list_request( + _request = build_beta_evaluators_list_latest_versions_request( + foundry_features=foundry_features, + type=type, + limit=limit, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4596,7 +4336,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RedTeam], deserialized.get("value", [])) + 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) @@ -4618,63 +4358,22 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @overload - async def create( - self, red_team: _models.RedTeam, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Required. - :type red_team: ~azure.ai.projects.models.RedTeam - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create(self, red_team: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Required. - :type red_team: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - async def create( - self, red_team: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RedTeam: - """Creates a redteam run. - - :param red_team: Redteam to be run. Required. - :type red_team: 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: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace_async - async def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwargs: Any) -> _models.RedTeam: - """Creates a redteam run. + async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: + """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if + the EvaluatorVersion does not exist. - :param red_team: Redteam to be run. Is one of the following types: RedTeam, JSON, IO[bytes] - Required. - :type red_team: ~azure.ai.projects.models.RedTeam or JSON or IO[bytes] - :return: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam + :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 :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4683,23 +4382,16 @@ async def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwar } 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.RedTeam] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(red_team, (IOBase, bytes)): - _content = red_team - else: - _content = json.dumps(red_team, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - _request = build_red_teams_create_request( - content_type=content_type, + _request = build_beta_evaluators_get_version_request( + name=name, + version=version, + foundry_features=foundry_features, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -4715,7 +4407,7 @@ async def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwar 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 @@ -4727,41 +4419,29 @@ async def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwar if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.RedTeam, response.json()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class EvaluationRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`evaluation_rules` 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 get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: - """Get an evaluation rule. + async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: + """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the + EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :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: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4773,10 +4453,12 @@ async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_evaluation_rules_get_request( - id=id, + _request = build_beta_evaluators_delete_version_request( + name=name, + version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4786,47 +4468,97 @@ async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _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) 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 cls: + return cls(pipeline_response, None, {}) # type: ignore - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + @overload + async def create_version( + self, + name: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + :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: + """ - return deserialized # type: ignore + @overload + async def create_version( + self, name: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :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 a new EvaluatorVersion with auto incremented version id. + + :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 delete(self, id: str, **kwargs: Any) -> None: - """Delete an evaluation rule. + async def create_version( + self, name: str, evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: None - :rtype: None + :param name: The name of the resource. 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 :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4835,14 +4567,25 @@ async def delete(self, id: 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[_models.EvaluatorVersion] = kwargs.pop("cls", None) - _request = build_evaluation_rules_delete_request( - id=id, + 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_beta_evaluators_create_version_request( + name=name, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -4851,94 +4594,128 @@ async def delete(self, id: str, **kwargs: Any) -> None: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _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 [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) - 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() + else: + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - async def create_or_update( - self, id: str, evaluation_rule: _models.EvaluationRule, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + async def update_version( + self, + name: str, + version: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule + :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: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( - self, id: str, evaluation_rule: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + async def update_version( + self, name: str, version: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: JSON + :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: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( - self, id: str, evaluation_rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + async def update_version( + self, + name: str, + version: str, + evaluator_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: IO[bytes] + :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: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :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_or_update( - self, id: str, evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + async def update_version( + self, + name: str, + version: str, + evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Is one of the following types: - EvaluationRule, JSON, IO[bytes] Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :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. 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: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4951,17 +4728,19 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None - if isinstance(evaluation_rule, (IOBase, bytes)): - _content = evaluation_rule + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version else: - _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluation_rules_create_or_update_request( - id=id, + _request = build_beta_evaluators_update_version_request( + name=name, + version=version, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -4980,7 +4759,7 @@ 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 @@ -4992,140 +4771,172 @@ async def create_or_update( if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def list( - self, - *, - action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.EvaluationRule"]: - """List all evaluation rules. - :keyword action_type: Filter by the type of evaluation rule. Known values are: - "continuousEvaluation" and "humanEvaluation". Default value is None. - :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of EvaluationRule - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluationRule] +class BetaInsightsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`insights` 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 generate( + self, insight: _models.Insight, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Insight: + """Generate Insights. + + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: ~azure.ai.projects.models.Insight + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluationRule]] = kwargs.pop("cls", None) + @overload + async def generate( + self, insight: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Insight: + """Generate Insights. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight + :raises ~azure.core.exceptions.HttpResponseError: + """ - def prepare_request(next_link=None): - if not next_link: + @overload + async def generate( + self, insight: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Insight: + """Generate Insights. - _request = build_evaluation_rules_list_request( - action_type=action_type, - agent_name=agent_name, - enabled=enabled, - 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 insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: 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: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight + :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), 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 generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwargs: Any) -> _models.Insight: + """Generate Insights. - return _request + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Is one of the following types: Insight, JSON, IO[bytes] Required. + :type insight: ~azure.ai.projects.models.Insight or JSON or IO[bytes] + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight + :raises ~azure.core.exceptions.HttpResponseError: + """ + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW + ) + 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.EvaluationRule], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - async def get_next(next_link=None): - _request = prepare_request(next_link) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Insight] = 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 + content_type = content_type or "application/json" + _content = None + if isinstance(insight, (IOBase, bytes)): + _content = insight + else: + _content = json.dumps(insight, cls=SdkJSONEncoder, exclude_readonly=True) # 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) + _request = build_beta_insights_generate_request( + foundry_features=foundry_features, + 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) - return pipeline_response + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return AsyncItemPaged(get_next, extract_data) + 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) + raise HttpResponseError(response=response) -class EvaluationTaxonomiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.Insight, response.json()) - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`evaluation_taxonomies` attribute. - """ + if cls: + return cls(pipeline_response, 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") + return deserialized # type: ignore @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: - """Get an evaluation run by name. + async def get(self, id: str, *, include_coordinates: Optional[bool] = None, **kwargs: Any) -> _models.Insight: + """Get a specific insight by Id. - :param name: The name of the resource. Required. - :type name: str - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :param id: The unique identifier for the insights report. Required. + :type id: str + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5137,10 +4948,12 @@ async def get(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.Insight] = kwargs.pop("cls", None) - _request = build_evaluation_taxonomies_get_request( - name=name, + _request = build_beta_insights_get_request( + id=id, + foundry_features=foundry_features, + include_coordinates=include_coordinates, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5166,39 +4979,52 @@ async def get(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: 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() else: - deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) + deserialized = _deserialize(_models.Insight, 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, *, input_name: Optional[str] = None, input_type: Optional[str] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.EvaluationTaxonomy"]: - """List evaluation taxonomies. + self, + *, + type: Optional[Union[str, _models.InsightType]] = None, + eval_id: Optional[str] = None, + run_id: Optional[str] = None, + agent_name: Optional[str] = None, + include_coordinates: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Insight"]: + """List all insights in reverse chronological order (newest first). - :keyword input_name: Filter by the evaluation input name. Default value is None. - :paramtype input_name: str - :keyword input_type: Filter by taxonomy input type. Default value is None. - :paramtype input_type: str - :return: An iterator like instance of EvaluationTaxonomy - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluationTaxonomy] + :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", + "AgentClusterInsight", and "EvaluationComparison". Default value is None. + :paramtype type: str or ~azure.ai.projects.models.InsightType + :keyword eval_id: Filter by the evaluation ID. Default value is None. + :paramtype eval_id: str + :keyword run_id: Filter by the evaluation run ID. Default value is None. + :paramtype run_id: str + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: An iterator like instance of Insight + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Insight] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluationTaxonomy]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Insight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5211,9 +5037,13 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_evaluation_taxonomies_list_request( - input_name=input_name, - input_type=input_type, + _request = build_beta_insights_list_request( + foundry_features=foundry_features, + type=type, + eval_id=eval_id, + run_id=run_id, + agent_name=agent_name, + include_coordinates=include_coordinates, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5249,7 +5079,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.EvaluationTaxonomy], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Insight], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -5271,128 +5101,117 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace_async - async def delete(self, name: str, **kwargs: Any) -> None: - """Delete an evaluation taxonomy by name. - - :param name: The name of the resource. 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_evaluation_taxonomies_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) - raise HttpResponseError(response=response) +class BetaMemoryStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`memory_stores` attribute. + """ - if cls: - return cls(pipeline_response, None, response_headers) # 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") @overload async def create( - self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. + self, + *, + name: str, + definition: _models.MemoryStoreDefinition, + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy + :keyword name: The name of the memory store. Required. + :paramtype name: str + :keyword definition: The memory store definition. Required. + :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :keyword description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default + value is None. + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. + + :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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def create( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. + :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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def create( - self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: str = _Unset, + definition: _models.MemoryStoreDefinition = _Unset, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, JSON, - IO[bytes] Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: The name of the memory store. Required. + :paramtype name: str + :keyword definition: The memory store definition. Required. + :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition + :keyword description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default + value is None. + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5405,8 +5224,15 @@ async def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata, "name": name} + 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)): @@ -5414,8 +5240,8 @@ async def create( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluation_taxonomies_create_request( - name=name, + _request = build_beta_memory_stores_create_request( + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -5434,19 +5260,23 @@ async def create( 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() else: - deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) + deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5455,73 +5285,95 @@ async def create( @overload async def update( - self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. + self, + name: str, + *, + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Update a memory store. - :param name: The name of the evaluation taxonomy. Required. + :param name: The name of the memory store to update. Required. :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :keyword description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default + value is None. + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. + ) -> _models.MemoryStoreDetails: + """Update a memory store. - :param name: The name of the evaluation taxonomy. Required. + :param name: The name of the memory store to update. Required. :type name: str - :param body: The evaluation taxonomy. Required. + :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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @overload async def update( self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. + ) -> _models.MemoryStoreDetails: + """Update a memory store. - :param name: The name of the evaluation taxonomy. Required. + :param name: The name of the memory store to update. Required. :type name: str - :param body: The evaluation taxonomy. Required. + :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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async async def update( - self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Update a memory store. - :param name: The name of the evaluation taxonomy. Required. + :param name: The name of the memory store to update. Required. :type name: str - :param body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, JSON, - IO[bytes] Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default + value is None. + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5534,8 +5386,11 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) + if body is _Unset: + body = {"description": description, "metadata": metadata} + 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)): @@ -5543,8 +5398,9 @@ async def update( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluation_taxonomies_update_request( + _request = build_beta_memory_stores_update_request( name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -5570,162 +5426,126 @@ async def update( 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() else: - deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) + deserialized = _deserialize(_models.MemoryStoreDetails, 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.MemoryStoreDetails: + """Retrieve a memory store. -class EvaluatorsOperations: - """ - .. 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( - self, - name: str, - *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.EvaluatorVersion"]: - """List all versions of the given evaluator. - - :param name: The name of the resource. Required. + :param name: The name of the memory store to retrieve. 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. - :paramtype limit: int - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorVersion] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) - + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) 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_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), 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) + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - return _request + _headers = 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.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) + cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) - async def get_next(next_link=None): - _request = prepare_request(next_link) + _request = build_beta_memory_stores_get_request( + name=name, + foundry_features=foundry_features, + 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 + _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, ) - 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 _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return AsyncItemPaged(get_next, extract_data) + return deserialized # type: ignore @distributed_trace - def list_latest_versions( + def list( self, *, - 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.EvaluatorVersion"]: - """List the latest version of each evaluator. + ) -> AsyncItemPaged["_models.MemoryStoreDetails"]: + """List all memory stores. - :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 - :return: An iterator like instance of EvaluatorVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluatorVersion] + :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 MemoryStoreDetails + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.MemoryStoreDetails] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.MemoryStoreDetails]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5735,54 +5555,33 @@ def list_latest_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_evaluators_list_latest_versions_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), 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_beta_memory_stores_list_request( + foundry_features=foundry_features, + 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.EvaluatorVersion], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.MemoryStoreDetails], 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 @@ -5792,25 +5591,29 @@ 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_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: - """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if - the EvaluatorVersion does not exist. + async def delete(self, name: str, **kwargs: Any) -> _models.DeleteMemoryStoreResult: + """Delete a memory store. - :param name: The name of the resource. Required. + :param name: The name of the memory store to delete. 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 + :return: DeleteMemoryStoreResult. The DeleteMemoryStoreResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DeleteMemoryStoreResult :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5822,11 +5625,11 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.E _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.DeleteMemoryStoreResult] = kwargs.pop("cls", None) - _request = build_evaluators_get_version_request( + _request = build_beta_memory_stores_delete_request( name=name, - version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5850,144 +5653,127 @@ 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() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.DeleteMemoryStoreResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: - """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the - EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. - - :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( + async def search_memories( self, name: str, - evaluator_version: _models.EvaluatorVersion, *, + scope: str, content_type: str = "application/json", + items: Optional[List[_models.InputItem]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_models.MemorySearchOptions] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion + :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :paramtype scope: str :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 items: Items for which to search for relevant memories. Default value is None. + :paramtype items: list[~azure.ai.projects.models.InputItem] + :keyword previous_search_id: The unique ID of the previous search request, enabling incremental + memory search from where the last operation left off. Default value is None. + :paramtype previous_search_id: str + :keyword options: Memory search options. Default value is None. + :paramtype options: ~azure.ai.projects.models.MemorySearchOptions + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :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 a new EvaluatorVersion with auto incremented version id. + async def search_memories( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: JSON + :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: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :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 a new EvaluatorVersion with auto incremented version id. + async def search_memories( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: IO[bytes] + :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: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :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 a new EvaluatorVersion with auto incremented version id. + async def search_memories( + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + scope: str = _Unset, + items: Optional[List[_models.InputItem]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_models.MemorySearchOptions] = None, + **kwargs: Any + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: 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 + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :paramtype scope: str + :keyword items: Items for which to search for relevant memories. Default value is None. + :paramtype items: list[~azure.ai.projects.models.InputItem] + :keyword previous_search_id: The unique ID of the previous search request, enabling incremental + memory search from where the last operation left off. Default value is None. + :paramtype previous_search_id: str + :keyword options: Memory search options. Default value is None. + :paramtype options: ~azure.ai.projects.models.MemorySearchOptions + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6000,17 +5786,28 @@ 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.EvaluatorVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.MemoryStoreSearchResult] = kwargs.pop("cls", None) + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = { + "items": items, + "options": options, + "previous_search_id": previous_search_id, + "scope": scope, + } + 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(evaluator_version, (IOBase, bytes)): - _content = evaluator_version + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluators_create_version_request( + _request = build_beta_memory_stores_search_memories_request( name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -6029,259 +5826,318 @@ 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 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() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.MemoryStoreSearchResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - async def update_version( + async def _update_memories_initial( self, name: str, - version: str, - evaluator_version: _models.EvaluatorVersion, + body: Union[JSON, IO[bytes]] = _Unset, *, - content_type: str = "application/json", + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + scope: str = _Unset, + items: Optional[List[_models.InputItem]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. + ) -> AsyncIterator[bytes]: + 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: ~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: - """ + _headers = case_insensitive_dict(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 existing EvaluatorVersion with the given version id. + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - :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: - """ + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = { + "items": items, + "previous_update_id": previous_update_id, + "scope": scope, + "update_delay": update_delay, + } + 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_beta_memory_stores_update_memories_request( + name=name, + foundry_features=foundry_features, + 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) + + _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 [202]: + 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")) + + deserialized = response.iter_bytes() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload - async def update_version( + async def _begin_update_memories( self, name: str, - version: str, - evaluator_version: IO[bytes], *, + scope: str, content_type: str = "application/json", + items: Optional[List[_models.InputItem]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :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: - """ + ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + @overload + async def _begin_update_memories( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + @overload + async def _begin_update_memories( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: ... @distributed_trace_async - async def update_version( + async def _begin_update_memories( self, name: str, - version: str, - evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], + body: Union[JSON, IO[bytes]] = _Unset, + *, + scope: str = _Unset, + items: Optional[List[_models.InputItem]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. + ) -> AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]: + """Update memory store with conversation memories. - :param name: The name of the resource. Required. + :param name: The name of the memory store to update. 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 + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :paramtype scope: str + :keyword items: Conversation items from which to extract memories. Default value is None. + :paramtype items: list[~azure.ai.projects.models.InputItem] + :keyword previous_update_id: The unique ID of the previous update request, enabling incremental + memory updates from where the last operation left off. Default value is None. + :paramtype previous_update_id: str + :keyword update_delay: Timeout period before processing the memory update in seconds. + If a new update request is received during this period, it will cancel the current request and + reset the timeout. + Set to 0 to immediately trigger the update without delay. + Defaults to 300 (5 minutes). Default value is None. + :paramtype update_delay: int + :return: An instance of AsyncLROPoller that returns MemoryStoreUpdateCompletedResult. The + MemoryStoreUpdateCompletedResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.MemoryStoreUpdateCompletedResult] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) _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) + cls: ClsType[_models.MemoryStoreUpdateCompletedResult] = 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._update_memories_initial( + name=name, + body=body, + foundry_features=foundry_features, + scope=scope, + items=items, + previous_update_id=previous_update_id, + update_delay=update_delay, + 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) - 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 + 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") + ) + + deserialized = _deserialize(_models.MemoryStoreUpdateCompletedResult, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized - _request = build_evaluators_update_version_request( - name=name, - version=version, - 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) - - _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) - raise HttpResponseError(response=response) - if _stream: - deserialized = response.iter_bytes() + 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: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - -class InsightsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`insights` 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") + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.MemoryStoreUpdateCompletedResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload - async def generate( - self, insight: _models.Insight, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Insight: - """Generate Insights. + async def delete_scope( + self, name: str, *, scope: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: ~azure.ai.projects.models.Insight + :param name: The name of the memory store. Required. + :type name: str + :keyword scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :paramtype scope: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def generate( - self, insight: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Insight: - """Generate Insights. + async def delete_scope( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: JSON + :param name: The name of the memory store. 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: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def generate( - self, insight: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Insight: - """Generate Insights. + async def delete_scope( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: IO[bytes] + :param name: The name of the memory store. 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: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwargs: Any) -> _models.Insight: - """Generate Insights. + async def delete_scope( + self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, scope: str = _Unset, **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Is one of the following types: Insight, JSON, IO[bytes] Required. - :type insight: ~azure.ai.projects.models.Insight or JSON or IO[bytes] - :return: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :param name: The name of the memory store. Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :paramtype scope: str + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6294,16 +6150,23 @@ async def generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwa _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Insight] = kwargs.pop("cls", None) + cls: ClsType[_models.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = {"scope": scope} + 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(insight, (IOBase, bytes)): - _content = insight + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(insight, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_insights_generate_request( + _request = build_beta_memory_stores_delete_scope_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -6322,38 +6185,60 @@ async def generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwa 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 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() else: - deserialized = _deserialize(_models.Insight, response.json()) + deserialized = _deserialize(_models.MemoryStoreDeleteScopeResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class BetaRedTeamsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`red_teams` 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 get(self, id: str, *, include_coordinates: Optional[bool] = None, **kwargs: Any) -> _models.Insight: - """Get a specific insight by Id. + async def get(self, name: str, **kwargs: Any) -> _models.RedTeam: + """Get a redteam by name. - :param id: The unique identifier for the insights report. Required. - :type id: str - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :param name: Identifier of the red team run. Required. + :type name: str + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6365,11 +6250,11 @@ async def get(self, id: str, *, include_coordinates: Optional[bool] = None, **kw _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Insight] = kwargs.pop("cls", None) + cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None) - _request = build_insights_get_request( - id=id, - include_coordinates=include_coordinates, + _request = build_beta_red_teams_get_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6395,54 +6280,31 @@ async def get(self, id: str, *, include_coordinates: Optional[bool] = None, **kw 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() else: - deserialized = _deserialize(_models.Insight, response.json()) + deserialized = _deserialize(_models.RedTeam, 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, - *, - type: Optional[Union[str, _models.InsightType]] = None, - eval_id: Optional[str] = None, - run_id: Optional[str] = None, - agent_name: Optional[str] = None, - include_coordinates: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Insight"]: - """List all insights in reverse chronological order (newest first). + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.RedTeam"]: + """List a redteam by name. - :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", - "AgentClusterInsight", and "EvaluationComparison". Default value is None. - :paramtype type: str or ~azure.ai.projects.models.InsightType - :keyword eval_id: Filter by the evaluation ID. Default value is None. - :paramtype eval_id: str - :keyword run_id: Filter by the evaluation run ID. Default value is None. - :paramtype run_id: str - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: An iterator like instance of Insight - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Insight] + :return: An iterator like instance of RedTeam + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.RedTeam] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Insight]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.RedTeam]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6455,12 +6317,8 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_insights_list_request( - type=type, - eval_id=eval_id, - run_id=run_id, - agent_name=agent_name, - include_coordinates=include_coordinates, + _request = build_beta_red_teams_list_request( + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6496,7 +6354,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Insight], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.RedTeam], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, AsyncList(list_of_elem) @@ -6518,8 +6376,132 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) + @overload + async def create( + self, red_team: _models.RedTeam, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: ~azure.ai.projects.models.RedTeam + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create(self, red_team: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, red_team: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: 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: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwargs: Any) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Is one of the following types: RedTeam, JSON, IO[bytes] + Required. + :type red_team: ~azure.ai.projects.models.RedTeam or JSON or IO[bytes] + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW + ) + 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.RedTeam] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(red_team, (IOBase, bytes)): + _content = red_team + else: + _content = json.dumps(red_team, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_beta_red_teams_create_request( + foundry_features=foundry_features, + 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) + + _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) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.RedTeam, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + -class SchedulesOperations: +class BetaSchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. @@ -6546,6 +6528,9 @@ async def delete(self, id: str, **kwargs: Any) -> None: :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6559,8 +6544,9 @@ async def delete(self, id: str, **kwargs: Any) -> None: cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_schedules_delete_request( + _request = build_beta_schedules_delete_request( id=id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6581,13 +6567,8 @@ async def delete(self, id: str, **kwargs: Any) -> None: 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 cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def get(self, id: str, **kwargs: Any) -> _models.Schedule: @@ -6599,6 +6580,9 @@ async def get(self, id: str, **kwargs: Any) -> _models.Schedule: :rtype: ~azure.ai.projects.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6612,8 +6596,9 @@ async def get(self, id: str, **kwargs: Any) -> _models.Schedule: cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) - _request = build_schedules_get_request( + _request = build_beta_schedules_get_request( id=id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6639,29 +6624,38 @@ async def get(self, id: str, **kwargs: Any) -> _models.Schedule: 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() else: deserialized = _deserialize(_models.Schedule, 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, **kwargs: Any) -> AsyncItemPaged["_models.Schedule"]: + def list( + self, + *, + type: Optional[Union[str, _models.ScheduleTaskType]] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Schedule"]: """List all schedules. + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + Default value is None. + :paramtype type: str or ~azure.ai.projects.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool :return: An iterator like instance of Schedule :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -6678,7 +6672,10 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Schedule"]: def prepare_request(next_link=None): if not next_link: - _request = build_schedules_list_request( + _request = build_beta_schedules_list_request( + foundry_features=foundry_features, + type=type, + enabled=enabled, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6740,11 +6737,11 @@ async def get_next(next_link=None): async def create_or_update( self, id: str, schedule: _models.Schedule, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Required. + :param schedule: The resource instance. Required. :type schedule: ~azure.ai.projects.models.Schedule :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -6758,11 +6755,11 @@ async def create_or_update( async def create_or_update( self, id: str, schedule: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Required. + :param schedule: The resource instance. Required. :type schedule: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -6776,11 +6773,11 @@ async def create_or_update( async def create_or_update( self, id: str, schedule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Required. + :param schedule: The resource instance. Required. :type schedule: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -6794,17 +6791,20 @@ async def create_or_update( async def create_or_update( self, id: str, schedule: Union[_models.Schedule, JSON, IO[bytes]], **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Is one of the following types: Schedule, JSON, IO[bytes] - Required. + :param schedule: The resource instance. Is one of the following types: Schedule, JSON, + IO[bytes] Required. :type schedule: ~azure.ai.projects.models.Schedule or JSON or IO[bytes] :return: Schedule. The Schedule is compatible with MutableMapping :rtype: ~azure.ai.projects.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6826,8 +6826,9 @@ async def create_or_update( else: _content = json.dumps(schedule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_schedules_create_or_update_request( + _request = build_beta_schedules_create_or_update_request( id=id, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -6869,14 +6870,17 @@ async def create_or_update( async def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models.ScheduleRun: """Get a schedule run by id. - :param schedule_id: Identifier of the schedule. Required. + :param schedule_id: The unique identifier of the schedule. Required. :type schedule_id: str - :param run_id: Identifier of the schedule run. Required. + :param run_id: The unique identifier of the schedule run. Required. :type run_id: str :return: ScheduleRun. The ScheduleRun is compatible with MutableMapping :rtype: ~azure.ai.projects.models.ScheduleRun :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6890,9 +6894,10 @@ async def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models cls: ClsType[_models.ScheduleRun] = kwargs.pop("cls", None) - _request = build_schedules_get_run_request( + _request = build_beta_schedules_get_run_request( schedule_id=schedule_id, run_id=run_id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6916,7 +6921,11 @@ async def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models 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() @@ -6929,15 +6938,30 @@ async def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models return deserialized # type: ignore @distributed_trace - def list_runs(self, id: str, **kwargs: Any) -> AsyncItemPaged["_models.ScheduleRun"]: + def list_runs( + self, + id: str, + *, + type: Optional[Union[str, _models.ScheduleTaskType]] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ScheduleRun"]: """List all schedule runs. :param id: Identifier of the schedule. Required. :type id: str + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + Default value is None. + :paramtype type: str or ~azure.ai.projects.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool :return: An iterator like instance of ScheduleRun :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ScheduleRun] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -6954,8 +6978,11 @@ def list_runs(self, id: str, **kwargs: Any) -> AsyncItemPaged["_models.ScheduleR def prepare_request(next_link=None): if not next_link: - _request = build_schedules_list_runs_request( + _request = build_beta_schedules_list_runs_request( id=id, + foundry_features=foundry_features, + type=type, + enabled=enabled, api_version=self._config.api_version, headers=_headers, params=_params, 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 6423852990a5..be25ff27a13b 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 @@ -11,13 +11,46 @@ from ._patch_datasets_async import DatasetsOperations from ._patch_telemetry_async import TelemetryOperations from ._patch_connections_async import ConnectionsOperations -from ._patch_memories_async import MemoryStoresOperations +from ._patch_memories_async import BetaMemoryStoresOperations +from ._operations import ( + BetaEvaluationTaxonomiesOperations, + BetaEvaluatorsOperations, + BetaInsightsOperations, + BetaOperations as GenerateBetaOperations, + BetaRedTeamsOperations, + BetaSchedulesOperations, +) + + +class BetaOperations(GenerateBetaOperations): + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`beta` attribute. + """ + + memory_stores: BetaMemoryStoresOperations # type override for mypy + + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + # Override memory_stores with the patched version that has begin_update_memories + self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) + __all__: List[str] = [ - "TelemetryOperations", - "DatasetsOperations", + "BetaEvaluationTaxonomiesOperations", + "BetaEvaluatorsOperations", + "BetaInsightsOperations", + "BetaMemoryStoresOperations", + "BetaOperations", + "BetaRedTeamsOperations", + "BetaSchedulesOperations", "ConnectionsOperations", - "MemoryStoresOperations", + "DatasetsOperations", + "TelemetryOperations", ] # Add all objects you want publicly available to users at this package level diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_memories_async.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_memories_async.py index 4f1343541de5..72ac9333d313 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_memories_async.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_memories_async.py @@ -7,12 +7,13 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Union, Optional, Any, List, overload, IO, cast +from typing import Union, Optional, Any, List, overload, IO, cast, Literal from azure.core.tracing.decorator_async import distributed_trace_async from azure.core.polling import AsyncNoPolling from azure.core.utils import case_insensitive_dict from ... import models as _models from ...models import ( + FoundryFeaturesOptInKeys, MemoryStoreOperationUsage, ResponseUsageInputTokensDetails, ResponseUsageOutputTokensDetails, @@ -20,12 +21,12 @@ AsyncUpdateMemoriesLROPoller, AsyncUpdateMemoriesLROPollingMethod, ) -from ._operations import JSON, _Unset, ClsType, MemoryStoresOperations as GenerateMemoryStoresOperations +from ._operations import JSON, _Unset, ClsType, BetaMemoryStoresOperations as GenerateBetaMemoryStoresOperations from ..._validation import api_version_validation from ..._utils.model_base import _deserialize -class MemoryStoresOperations(GenerateMemoryStoresOperations): +class BetaMemoryStoresOperations(GenerateBetaMemoryStoresOperations): @overload async def begin_update_memories( @@ -69,7 +70,12 @@ async def begin_update_memories( @overload async def begin_update_memories( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, ) -> AsyncUpdateMemoriesLROPoller: """Update memory store with conversation memories. @@ -89,7 +95,12 @@ async def begin_update_memories( @overload async def begin_update_memories( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, + name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, ) -> AsyncUpdateMemoriesLROPoller: """Update memory store with conversation memories. @@ -109,9 +120,9 @@ async def begin_update_memories( @distributed_trace_async @api_version_validation( - method_added_on="2025-11-15-preview", - params_added_on={"2025-11-15-preview": ["api_version", "name", "content_type", "accept"]}, - api_versions_list=["2025-11-15-preview"], + method_added_on="v1", + params_added_on={"v1": ["api_version", "name", "content_type", "accept"]}, + api_versions_list=["v1"], ) async def begin_update_memories( self, @@ -150,6 +161,10 @@ async def begin_update_memories( ~azure.ai.projects.models.AsyncUpdateMemoriesLROPoller :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} @@ -160,6 +175,7 @@ async def begin_update_memories( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._update_memories_initial( + foundry_features=foundry_features, name=name, body=body, scope=scope, 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 2537d1bd8040..a2c1e8a981e9 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 @@ -16,30 +16,26 @@ from ._models import ( # type: ignore A2APreviewTool, AISearchIndexResource, + AgentClusterInsightRequest, AgentClusterInsightResult, - AgentClusterInsightsRequest, AgentDefinition, AgentDetails, - AgentId, AgentObjectVersions, - AgentReference, AgentTaxonomyInput, AgentVersionDetails, - AgenticIdentityCredentials, + AgenticIdentityPreviewCredentials, Annotation, + ApiError, ApiErrorResponse, ApiKeyCredentials, - ApplyPatchCreateFileOperation, ApplyPatchCreateFileOperationParam, - ApplyPatchDeleteFileOperation, ApplyPatchDeleteFileOperationParam, - ApplyPatchFileOperation, ApplyPatchOperationParam, ApplyPatchToolParam, - ApplyPatchUpdateFileOperation, ApplyPatchUpdateFileOperationParam, ApproximateLocation, AzureAIAgentTarget, + AzureAIModelTarget, AzureAISearchIndex, AzureAISearchTool, AzureAISearchToolResource, @@ -83,7 +79,6 @@ ContainerFileCitationBody, ContinuousEvaluationRuleAction, CosmosDBIndex, - CreatedBy, CronTrigger, CustomCredential, CustomGrammarFormatParam, @@ -103,19 +98,18 @@ EasyInputMessage, EmbeddingConfiguration, EntraIDCredentials, - Error, - EvalCompareReport, EvalResult, EvalRunResultCompareItem, EvalRunResultComparison, EvalRunResultSummary, - EvaluationComparisonRequest, + EvaluationComparisonInsightRequest, + EvaluationComparisonInsightResult, EvaluationResultSample, EvaluationRule, EvaluationRuleAction, EvaluationRuleFilter, + EvaluationRunClusterInsightRequest, EvaluationRunClusterInsightResult, - EvaluationRunClusterInsightsRequest, EvaluationScheduleTask, EvaluationTaxonomy, EvaluationTaxonomyInput, @@ -134,23 +128,17 @@ FunctionAndCustomToolCallOutputInputFileContent, FunctionAndCustomToolCallOutputInputImageContent, FunctionAndCustomToolCallOutputInputTextContent, - FunctionShellAction, FunctionShellActionParam, - FunctionShellCallOutputContent, FunctionShellCallOutputContentParam, - FunctionShellCallOutputExitOutcome, FunctionShellCallOutputExitOutcomeParam, - FunctionShellCallOutputOutcome, FunctionShellCallOutputOutcomeParam, - FunctionShellCallOutputTimeoutOutcome, FunctionShellCallOutputTimeoutOutcomeParam, FunctionShellToolParam, FunctionTool, HostedAgentDefinition, HourlyRecurrenceSchedule, - HumanEvaluationRuleAction, + HumanEvaluationPreviewRuleAction, HybridSearchOptions, - ImageBasedHostedAgentDefinition, ImageGenTool, ImageGenToolInputImageMask, Index, @@ -184,7 +172,6 @@ InputItemOutputMessage, InputItemReasoningItem, InputItemWebSearchToolCall, - InputMessageResource, InputTextContentParam, Insight, InsightCluster, @@ -196,26 +183,6 @@ InsightSummary, InsightsMetadata, ItemReferenceParam, - ItemResource, - ItemResourceApplyPatchToolCall, - ItemResourceApplyPatchToolCallOutput, - ItemResourceCodeInterpreterToolCall, - ItemResourceComputerToolCall, - ItemResourceComputerToolCallOutputResource, - ItemResourceFileSearchToolCall, - ItemResourceFunctionShellCall, - ItemResourceFunctionShellCallOutput, - ItemResourceFunctionToolCallOutputResource, - ItemResourceFunctionToolCallResource, - ItemResourceImageGenToolCall, - ItemResourceLocalShellToolCall, - ItemResourceLocalShellToolCallOutput, - ItemResourceMcpApprovalRequest, - ItemResourceMcpApprovalResponseResource, - ItemResourceMcpListTools, - ItemResourceMcpToolCall, - ItemResourceOutputMessage, - ItemResourceWebSearchToolCall, KeyPressAction, LocalShellExecAction, LocalShellToolParam, @@ -232,7 +199,6 @@ MemorySearchItem, MemorySearchOptions, MemorySearchPreviewTool, - MemorySearchToolCallItemResource, MemoryStoreDefaultDefinition, MemoryStoreDefaultOptions, MemoryStoreDefinition, @@ -245,10 +211,10 @@ MicrosoftFabricPreviewTool, ModelDeployment, ModelDeploymentSku, + ModelSamplingParams, MonthlyRecurrenceSchedule, Move, NoAuthenticationCredentials, - OAuthConsentRequestItemResource, OneTimeTrigger, OpenApiAnonymousAuthDetails, OpenApiAuthDetails, @@ -259,14 +225,13 @@ OpenApiProjectConnectionAuthDetails, OpenApiProjectConnectionSecurityScheme, OpenApiTool, - OutputContent, OutputMessageContent, OutputMessageContentOutputTextContent, OutputMessageContentRefusalContent, PendingUploadRequest, PendingUploadResponse, PromptAgentDefinition, - PromptAgentDefinitionText, + PromptAgentDefinitionTextOptions, PromptBasedEvaluatorDefinition, ProtocolVersionRecord, RaiConfig, @@ -286,9 +251,10 @@ Scroll, SharepointGroundingToolParameters, SharepointPreviewTool, + SpecificApplyPatchParam, + SpecificFunctionShellParam, StructuredInputDefinition, StructuredOutputDefinition, - StructuredOutputsItemResource, Summary, Target, TargetConfig, @@ -299,6 +265,17 @@ TextResponseFormatConfigurationResponseFormatText, TextResponseFormatJsonSchema, Tool, + ToolChoiceAllowed, + ToolChoiceCodeInterpreter, + ToolChoiceComputerUsePreview, + ToolChoiceCustom, + ToolChoiceFileSearch, + ToolChoiceFunction, + ToolChoiceImageGeneration, + ToolChoiceMCP, + ToolChoiceParam, + ToolChoiceWebSearchPreview, + ToolChoiceWebSearchPreview20250311, ToolDescription, ToolProjectConnection, TopLogProb, @@ -318,19 +295,16 @@ WebSearchTool, WebSearchToolFilters, WeeklyRecurrenceSchedule, - WorkflowActionOutputItemResource, WorkflowAgentDefinition, ) from ._enums import ( # type: ignore AgentKind, + AgentObjectType, AgentProtocol, AnnotationType, - ApplyPatchCallOutputStatus, ApplyPatchCallOutputStatusParam, - ApplyPatchCallStatus, ApplyPatchCallStatusParam, - ApplyPatchFileOperationType, ApplyPatchOperationParamType, AttackStrategy, AzureAISearchQueryType, @@ -338,7 +312,6 @@ ComputerActionType, ComputerEnvironment, ConnectionType, - ContainerLogKind, ContainerMemoryLimit, CredentialType, CustomToolParamFormatType, @@ -354,11 +327,11 @@ EvaluatorMetricDirection, EvaluatorMetricType, EvaluatorType, + FoundryFeaturesOptInKeys, FunctionAndCustomToolCallOutputType, FunctionCallItemStatus, FunctionShellCallItemStatus, FunctionShellCallOutputOutcomeParamType, - FunctionShellCallOutputOutcomeType, GrammarSyntax1, ImageDetail, IndexType, @@ -366,16 +339,14 @@ InputFidelity, InputItemType, InsightType, - ItemResourceType, - LocalShellCallStatus, MCPToolCallStatus, MemoryItemKind, MemoryOperationKind, MemoryStoreKind, + MemoryStoreObjectType, MemoryStoreUpdateStatus, OpenApiAuthType, OperationState, - OutputContentType, OutputMessageContentType, PageOrder, PendingUploadType, @@ -387,6 +358,7 @@ ScheduleTaskType, SearchContextSize, TextResponseFormatConfigurationType, + ToolChoiceParamType, ToolType, TreatmentEffectType, TriggerType, @@ -398,30 +370,26 @@ __all__ = [ "A2APreviewTool", "AISearchIndexResource", + "AgentClusterInsightRequest", "AgentClusterInsightResult", - "AgentClusterInsightsRequest", "AgentDefinition", "AgentDetails", - "AgentId", "AgentObjectVersions", - "AgentReference", "AgentTaxonomyInput", "AgentVersionDetails", - "AgenticIdentityCredentials", + "AgenticIdentityPreviewCredentials", "Annotation", + "ApiError", "ApiErrorResponse", "ApiKeyCredentials", - "ApplyPatchCreateFileOperation", "ApplyPatchCreateFileOperationParam", - "ApplyPatchDeleteFileOperation", "ApplyPatchDeleteFileOperationParam", - "ApplyPatchFileOperation", "ApplyPatchOperationParam", "ApplyPatchToolParam", - "ApplyPatchUpdateFileOperation", "ApplyPatchUpdateFileOperationParam", "ApproximateLocation", "AzureAIAgentTarget", + "AzureAIModelTarget", "AzureAISearchIndex", "AzureAISearchTool", "AzureAISearchToolResource", @@ -465,7 +433,6 @@ "ContainerFileCitationBody", "ContinuousEvaluationRuleAction", "CosmosDBIndex", - "CreatedBy", "CronTrigger", "CustomCredential", "CustomGrammarFormatParam", @@ -485,19 +452,18 @@ "EasyInputMessage", "EmbeddingConfiguration", "EntraIDCredentials", - "Error", - "EvalCompareReport", "EvalResult", "EvalRunResultCompareItem", "EvalRunResultComparison", "EvalRunResultSummary", - "EvaluationComparisonRequest", + "EvaluationComparisonInsightRequest", + "EvaluationComparisonInsightResult", "EvaluationResultSample", "EvaluationRule", "EvaluationRuleAction", "EvaluationRuleFilter", + "EvaluationRunClusterInsightRequest", "EvaluationRunClusterInsightResult", - "EvaluationRunClusterInsightsRequest", "EvaluationScheduleTask", "EvaluationTaxonomy", "EvaluationTaxonomyInput", @@ -516,23 +482,17 @@ "FunctionAndCustomToolCallOutputInputFileContent", "FunctionAndCustomToolCallOutputInputImageContent", "FunctionAndCustomToolCallOutputInputTextContent", - "FunctionShellAction", "FunctionShellActionParam", - "FunctionShellCallOutputContent", "FunctionShellCallOutputContentParam", - "FunctionShellCallOutputExitOutcome", "FunctionShellCallOutputExitOutcomeParam", - "FunctionShellCallOutputOutcome", "FunctionShellCallOutputOutcomeParam", - "FunctionShellCallOutputTimeoutOutcome", "FunctionShellCallOutputTimeoutOutcomeParam", "FunctionShellToolParam", "FunctionTool", "HostedAgentDefinition", "HourlyRecurrenceSchedule", - "HumanEvaluationRuleAction", + "HumanEvaluationPreviewRuleAction", "HybridSearchOptions", - "ImageBasedHostedAgentDefinition", "ImageGenTool", "ImageGenToolInputImageMask", "Index", @@ -566,7 +526,6 @@ "InputItemOutputMessage", "InputItemReasoningItem", "InputItemWebSearchToolCall", - "InputMessageResource", "InputTextContentParam", "Insight", "InsightCluster", @@ -578,26 +537,6 @@ "InsightSummary", "InsightsMetadata", "ItemReferenceParam", - "ItemResource", - "ItemResourceApplyPatchToolCall", - "ItemResourceApplyPatchToolCallOutput", - "ItemResourceCodeInterpreterToolCall", - "ItemResourceComputerToolCall", - "ItemResourceComputerToolCallOutputResource", - "ItemResourceFileSearchToolCall", - "ItemResourceFunctionShellCall", - "ItemResourceFunctionShellCallOutput", - "ItemResourceFunctionToolCallOutputResource", - "ItemResourceFunctionToolCallResource", - "ItemResourceImageGenToolCall", - "ItemResourceLocalShellToolCall", - "ItemResourceLocalShellToolCallOutput", - "ItemResourceMcpApprovalRequest", - "ItemResourceMcpApprovalResponseResource", - "ItemResourceMcpListTools", - "ItemResourceMcpToolCall", - "ItemResourceOutputMessage", - "ItemResourceWebSearchToolCall", "KeyPressAction", "LocalShellExecAction", "LocalShellToolParam", @@ -614,7 +553,6 @@ "MemorySearchItem", "MemorySearchOptions", "MemorySearchPreviewTool", - "MemorySearchToolCallItemResource", "MemoryStoreDefaultDefinition", "MemoryStoreDefaultOptions", "MemoryStoreDefinition", @@ -627,10 +565,10 @@ "MicrosoftFabricPreviewTool", "ModelDeployment", "ModelDeploymentSku", + "ModelSamplingParams", "MonthlyRecurrenceSchedule", "Move", "NoAuthenticationCredentials", - "OAuthConsentRequestItemResource", "OneTimeTrigger", "OpenApiAnonymousAuthDetails", "OpenApiAuthDetails", @@ -641,14 +579,13 @@ "OpenApiProjectConnectionAuthDetails", "OpenApiProjectConnectionSecurityScheme", "OpenApiTool", - "OutputContent", "OutputMessageContent", "OutputMessageContentOutputTextContent", "OutputMessageContentRefusalContent", "PendingUploadRequest", "PendingUploadResponse", "PromptAgentDefinition", - "PromptAgentDefinitionText", + "PromptAgentDefinitionTextOptions", "PromptBasedEvaluatorDefinition", "ProtocolVersionRecord", "RaiConfig", @@ -668,9 +605,10 @@ "Scroll", "SharepointGroundingToolParameters", "SharepointPreviewTool", + "SpecificApplyPatchParam", + "SpecificFunctionShellParam", "StructuredInputDefinition", "StructuredOutputDefinition", - "StructuredOutputsItemResource", "Summary", "Target", "TargetConfig", @@ -681,6 +619,17 @@ "TextResponseFormatConfigurationResponseFormatText", "TextResponseFormatJsonSchema", "Tool", + "ToolChoiceAllowed", + "ToolChoiceCodeInterpreter", + "ToolChoiceComputerUsePreview", + "ToolChoiceCustom", + "ToolChoiceFileSearch", + "ToolChoiceFunction", + "ToolChoiceImageGeneration", + "ToolChoiceMCP", + "ToolChoiceParam", + "ToolChoiceWebSearchPreview", + "ToolChoiceWebSearchPreview20250311", "ToolDescription", "ToolProjectConnection", "TopLogProb", @@ -700,16 +649,13 @@ "WebSearchTool", "WebSearchToolFilters", "WeeklyRecurrenceSchedule", - "WorkflowActionOutputItemResource", "WorkflowAgentDefinition", "AgentKind", + "AgentObjectType", "AgentProtocol", "AnnotationType", - "ApplyPatchCallOutputStatus", "ApplyPatchCallOutputStatusParam", - "ApplyPatchCallStatus", "ApplyPatchCallStatusParam", - "ApplyPatchFileOperationType", "ApplyPatchOperationParamType", "AttackStrategy", "AzureAISearchQueryType", @@ -717,7 +663,6 @@ "ComputerActionType", "ComputerEnvironment", "ConnectionType", - "ContainerLogKind", "ContainerMemoryLimit", "CredentialType", "CustomToolParamFormatType", @@ -733,11 +678,11 @@ "EvaluatorMetricDirection", "EvaluatorMetricType", "EvaluatorType", + "FoundryFeaturesOptInKeys", "FunctionAndCustomToolCallOutputType", "FunctionCallItemStatus", "FunctionShellCallItemStatus", "FunctionShellCallOutputOutcomeParamType", - "FunctionShellCallOutputOutcomeType", "GrammarSyntax1", "ImageDetail", "IndexType", @@ -745,16 +690,14 @@ "InputFidelity", "InputItemType", "InsightType", - "ItemResourceType", - "LocalShellCallStatus", "MCPToolCallStatus", "MemoryItemKind", "MemoryOperationKind", "MemoryStoreKind", + "MemoryStoreObjectType", "MemoryStoreUpdateStatus", "OpenApiAuthType", "OperationState", - "OutputContentType", "OutputMessageContentType", "PageOrder", "PendingUploadType", @@ -766,6 +709,7 @@ "ScheduleTaskType", "SearchContextSize", "TextResponseFormatConfigurationType", + "ToolChoiceParamType", "ToolType", "TreatmentEffectType", "TriggerType", 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 145ae30df168..a31c33b3bd01 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 @@ -14,69 +14,79 @@ class AgentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of AgentKind.""" PROMPT = "prompt" + """PROMPT.""" HOSTED = "hosted" + """HOSTED.""" CONTAINER_APP = "container_app" + """CONTAINER_APP.""" WORKFLOW = "workflow" + """WORKFLOW.""" + + +class AgentObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of AgentObjectType.""" + + AGENT = "agent" + """AGENT.""" + AGENT_VERSION = "agent.version" + """AGENT_VERSION.""" + AGENT_DELETED = "agent.deleted" + """AGENT_DELETED.""" + AGENT_VERSION_DELETED = "agent.version.deleted" + """AGENT_VERSION_DELETED.""" + AGENT_CONTAINER = "agent.container" + """AGENT_CONTAINER.""" class AgentProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of AgentProtocol.""" ACTIVITY_PROTOCOL = "activity_protocol" + """ACTIVITY_PROTOCOL.""" RESPONSES = "responses" + """RESPONSES.""" class AnnotationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of AnnotationType.""" FILE_CITATION = "file_citation" + """FILE_CITATION.""" URL_CITATION = "url_citation" + """URL_CITATION.""" CONTAINER_FILE_CITATION = "container_file_citation" + """CONTAINER_FILE_CITATION.""" FILE_PATH = "file_path" - - -class ApplyPatchCallOutputStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of ApplyPatchCallOutputStatus.""" - - COMPLETED = "completed" - FAILED = "failed" + """FILE_PATH.""" class ApplyPatchCallOutputStatusParam(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Apply patch call output status.""" COMPLETED = "completed" + """COMPLETED.""" FAILED = "failed" - - -class ApplyPatchCallStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of ApplyPatchCallStatus.""" - - IN_PROGRESS = "in_progress" - COMPLETED = "completed" + """FAILED.""" class ApplyPatchCallStatusParam(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Apply patch call status.""" IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" COMPLETED = "completed" - - -class ApplyPatchFileOperationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of ApplyPatchFileOperationType.""" - - CREATE_FILE = "create_file" - DELETE_FILE = "delete_file" - UPDATE_FILE = "update_file" + """COMPLETED.""" class ApplyPatchOperationParamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of ApplyPatchOperationParamType.""" CREATE_FILE = "create_file" + """CREATE_FILE.""" DELETE_FILE = "delete_file" + """DELETE_FILE.""" UPDATE_FILE = "update_file" + """UPDATE_FILE.""" class AttackStrategy(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -154,116 +164,132 @@ class AzureAISearchQueryType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Available query types for Azure AI Search tool.""" SIMPLE = "simple" - """Query type ``simple``""" + """Query type ``simple``.""" SEMANTIC = "semantic" - """Query type ``semantic``""" + """Query type ``semantic``.""" VECTOR = "vector" - """Query type ``vector``""" + """Query type ``vector``.""" VECTOR_SIMPLE_HYBRID = "vector_simple_hybrid" - """Query type ``vector_simple_hybrid``""" + """Query type ``vector_simple_hybrid``.""" VECTOR_SEMANTIC_HYBRID = "vector_semantic_hybrid" - """Query type ``vector_semantic_hybrid``""" + """Query type ``vector_semantic_hybrid``.""" class ClickButtonType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of ClickButtonType.""" LEFT = "left" + """LEFT.""" RIGHT = "right" + """RIGHT.""" WHEEL = "wheel" + """WHEEL.""" BACK = "back" + """BACK.""" FORWARD = "forward" + """FORWARD.""" class ComputerActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of ComputerActionType.""" CLICK = "click" + """CLICK.""" DOUBLE_CLICK = "double_click" + """DOUBLE_CLICK.""" DRAG = "drag" + """DRAG.""" KEYPRESS = "keypress" + """KEYPRESS.""" MOVE = "move" + """MOVE.""" SCREENSHOT = "screenshot" + """SCREENSHOT.""" SCROLL = "scroll" + """SCROLL.""" TYPE = "type" + """TYPE.""" WAIT = "wait" + """WAIT.""" class ComputerEnvironment(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of ComputerEnvironment.""" WINDOWS = "windows" + """WINDOWS.""" MAC = "mac" + """MAC.""" LINUX = "linux" + """LINUX.""" UBUNTU = "ubuntu" + """UBUNTU.""" BROWSER = "browser" + """BROWSER.""" class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The Type (or category) of the connection.""" AZURE_OPEN_AI = "AzureOpenAI" - """Azure OpenAI Service""" + """Azure OpenAI Service.""" AZURE_BLOB_STORAGE = "AzureBlob" - """Azure Blob Storage, with specified container""" + """Azure Blob Storage, with specified container.""" AZURE_STORAGE_ACCOUNT = "AzureStorageAccount" - """Azure Blob Storage, with container not specified (used by Agents)""" + """Azure Blob Storage, with container not specified (used by Agents).""" AZURE_AI_SEARCH = "CognitiveSearch" - """Azure AI Search""" + """Azure AI Search.""" COSMOS_DB = "CosmosDB" - """CosmosDB""" + """CosmosDB.""" API_KEY = "ApiKey" - """Generic connection that uses API Key authentication""" + """Generic connection that uses API Key authentication.""" APPLICATION_CONFIGURATION = "AppConfig" - """Application Configuration""" + """Application Configuration.""" APPLICATION_INSIGHTS = "AppInsights" - """Application Insights""" + """Application Insights.""" CUSTOM = "CustomKeys" - """Custom Keys""" - REMOTE_TOOL = "RemoteTool" - """Remote tool""" - - -class ContainerLogKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of logs to stream from a container.""" - - CONSOLE = "console" - """Console logs from the container.""" - SYSTEM = "system" - """System logs from the container.""" + """Custom Keys.""" + REMOTE_TOOL = "RemoteTool_Preview" + """Remote tool.""" class ContainerMemoryLimit(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of ContainerMemoryLimit.""" ENUM_1_G = "1g" + """1_G.""" ENUM_4_G = "4g" + """4_G.""" ENUM_16_G = "16g" + """16_G.""" ENUM_64_G = "64g" + """64_G.""" class CredentialType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The credential type used by the connection.""" API_KEY = "ApiKey" - """API Key credential""" + """API Key credential.""" ENTRA_ID = "AAD" - """Entra ID credential (formerly known as AAD)""" + """Entra ID credential (formerly known as AAD).""" SAS = "SAS" - """Shared Access Signature (SAS) credential""" + """Shared Access Signature (SAS) credential.""" CUSTOM = "CustomKeys" - """Custom credential""" + """Custom credential.""" NONE = "None" - """No credential""" - AGENTIC_IDENTITY = "AgenticIdentityToken" - """Agentic identity credential""" + """No credential.""" + AGENTIC_IDENTITY_PREVIEW = "AgenticIdentityToken_Preview" + """Agentic identity credential.""" class CustomToolParamFormatType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of CustomToolParamFormatType.""" TEXT = "text" + """TEXT.""" GRAMMAR = "grammar" + """GRAMMAR.""" class DatasetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -298,15 +324,18 @@ class DeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of DeploymentType.""" MODEL_DEPLOYMENT = "ModelDeployment" - """Model deployment""" + """Model deployment.""" class DetailEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of DetailEnum.""" LOW = "low" + """LOW.""" HIGH = "high" + """HIGH.""" AUTO = "auto" + """AUTO.""" class EvaluationRuleActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -314,8 +343,8 @@ class EvaluationRuleActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONTINUOUS_EVALUATION = "continuousEvaluation" """Continuous evaluation.""" - HUMAN_EVALUATION = "humanEvaluation" - """Human evaluation.""" + HUMAN_EVALUATION_PREVIEW = "humanEvaluationPreview" + """Human evaluation preview.""" class EvaluationRuleEventType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -331,7 +360,7 @@ class EvaluationTaxonomyInputType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of the evaluation taxonomy input.""" AGENT = "agent" - """Agent""" + """Agent.""" POLICY = "policy" """Policy.""" @@ -340,26 +369,26 @@ class EvaluatorCategory(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The category of the evaluator.""" QUALITY = "quality" - """Quality""" + """Quality.""" SAFETY = "safety" - """Risk & Safety""" + """Risk & Safety.""" AGENTS = "agents" - """Agents""" + """Agents.""" class EvaluatorDefinitionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of evaluator definition.""" PROMPT = "prompt" - """Prompt-based definition""" + """Prompt-based definition.""" CODE = "code" - """Code-based definition""" + """Code-based definition.""" PROMPT_AND_CODE = "prompt_and_code" - """Prompt & Code Based definition""" + """Prompt & Code Based definition.""" SERVICE = "service" - """Service-based evaluator""" + """Service-based evaluator.""" OPENAI_GRADERS = "openai_graders" - """OpenAI graders""" + """OpenAI graders.""" class EvaluatorMetricDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -368,11 +397,11 @@ class EvaluatorMetricDirection(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ INCREASE = "increase" - """It indicates a higher value is better for this metric""" + """It indicates a higher value is better for this metric.""" DECREASE = "decrease" - """It indicates a lower value is better for this metric""" + """It indicates a lower value is better for this metric.""" NEUTRAL = "neutral" - """It indicates no preference for this metric direction""" + """It indicates no preference for this metric direction.""" class EvaluatorMetricType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -383,88 +412,121 @@ class EvaluatorMetricType(str, Enum, metaclass=CaseInsensitiveEnumMeta): CONTINUOUS = "continuous" """Continuous metric representing values in a continuous range.""" BOOLEAN = "boolean" - """Boolean metric representing true/false values""" + """Boolean metric representing true/false values.""" class EvaluatorType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the evaluator.""" BUILT_IN = "builtin" - """Built-in evaluator (Microsoft provided)""" + """Built-in evaluator (Microsoft provided).""" CUSTOM = "custom" - """Custom evaluator""" + """Custom evaluator.""" + + +class FoundryFeaturesOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of FoundryFeaturesOptInKeys.""" + + CONTAINER_AGENTS_V1_PREVIEW = "ContainerAgents=V1Preview" + """CONTAINER_AGENTS_V1_PREVIEW.""" + HOSTED_AGENTS_V1_PREVIEW = "HostedAgents=V1Preview" + """HOSTED_AGENTS_V1_PREVIEW.""" + WORKFLOW_AGENTS_V1_PREVIEW = "WorkflowAgents=V1Preview" + """WORKFLOW_AGENTS_V1_PREVIEW.""" + EVALUATIONS_V1_PREVIEW = "Evaluations=V1Preview" + """EVALUATIONS_V1_PREVIEW.""" + SCHEDULES_V1_PREVIEW = "Schedules=V1Preview" + """SCHEDULES_V1_PREVIEW.""" + RED_TEAMS_V1_PREVIEW = "RedTeams=V1Preview" + """RED_TEAMS_V1_PREVIEW.""" + INSIGHTS_V1_PREVIEW = "Insights=V1Preview" + """INSIGHTS_V1_PREVIEW.""" + MEMORY_STORES_V1_PREVIEW = "MemoryStores=V1Preview" + """MEMORY_STORES_V1_PREVIEW.""" class FunctionAndCustomToolCallOutputType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of FunctionAndCustomToolCallOutputType.""" INPUT_TEXT = "input_text" + """INPUT_TEXT.""" INPUT_IMAGE = "input_image" + """INPUT_IMAGE.""" INPUT_FILE = "input_file" + """INPUT_FILE.""" class FunctionCallItemStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of FunctionCallItemStatus.""" IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" COMPLETED = "completed" + """COMPLETED.""" INCOMPLETE = "incomplete" + """INCOMPLETE.""" class FunctionShellCallItemStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Shell call status.""" IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" COMPLETED = "completed" + """COMPLETED.""" INCOMPLETE = "incomplete" + """INCOMPLETE.""" class FunctionShellCallOutputOutcomeParamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of FunctionShellCallOutputOutcomeParamType.""" TIMEOUT = "timeout" + """TIMEOUT.""" EXIT = "exit" - - -class FunctionShellCallOutputOutcomeType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of FunctionShellCallOutputOutcomeType.""" - - TIMEOUT = "timeout" - EXIT = "exit" + """EXIT.""" class GrammarSyntax1(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of GrammarSyntax1.""" LARK = "lark" + """LARK.""" REGEX = "regex" + """REGEX.""" class ImageDetail(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of ImageDetail.""" LOW = "low" + """LOW.""" HIGH = "high" + """HIGH.""" AUTO = "auto" + """AUTO.""" class IndexType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of IndexType.""" AZURE_SEARCH = "AzureSearch" - """Azure search""" + """Azure search.""" COSMOS_DB = "CosmosDBNoSqlVectorStore" - """CosmosDB""" + """CosmosDB.""" MANAGED_AZURE_SEARCH = "ManagedAzureSearch" - """Managed Azure Search""" + """Managed Azure Search.""" class InputContentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of InputContentType.""" INPUT_TEXT = "input_text" + """INPUT_TEXT.""" INPUT_IMAGE = "input_image" + """INPUT_IMAGE.""" INPUT_FILE = "input_file" + """INPUT_FILE.""" class InputFidelity(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -474,37 +536,64 @@ class InputFidelity(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ HIGH = "high" + """HIGH.""" LOW = "low" + """LOW.""" class InputItemType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of InputItemType.""" MESSAGE = "message" + """MESSAGE.""" OUTPUT_MESSAGE = "output_message" + """OUTPUT_MESSAGE.""" FILE_SEARCH_CALL = "file_search_call" + """FILE_SEARCH_CALL.""" COMPUTER_CALL = "computer_call" + """COMPUTER_CALL.""" COMPUTER_CALL_OUTPUT = "computer_call_output" + """COMPUTER_CALL_OUTPUT.""" WEB_SEARCH_CALL = "web_search_call" + """WEB_SEARCH_CALL.""" FUNCTION_CALL = "function_call" + """FUNCTION_CALL.""" FUNCTION_CALL_OUTPUT = "function_call_output" + """FUNCTION_CALL_OUTPUT.""" REASONING = "reasoning" + """REASONING.""" COMPACTION = "compaction" + """COMPACTION.""" IMAGE_GENERATION_CALL = "image_generation_call" + """IMAGE_GENERATION_CALL.""" CODE_INTERPRETER_CALL = "code_interpreter_call" + """CODE_INTERPRETER_CALL.""" LOCAL_SHELL_CALL = "local_shell_call" + """LOCAL_SHELL_CALL.""" LOCAL_SHELL_CALL_OUTPUT = "local_shell_call_output" + """LOCAL_SHELL_CALL_OUTPUT.""" SHELL_CALL = "shell_call" + """SHELL_CALL.""" SHELL_CALL_OUTPUT = "shell_call_output" + """SHELL_CALL_OUTPUT.""" APPLY_PATCH_CALL = "apply_patch_call" + """APPLY_PATCH_CALL.""" APPLY_PATCH_CALL_OUTPUT = "apply_patch_call_output" + """APPLY_PATCH_CALL_OUTPUT.""" MCP_LIST_TOOLS = "mcp_list_tools" + """MCP_LIST_TOOLS.""" MCP_APPROVAL_REQUEST = "mcp_approval_request" + """MCP_APPROVAL_REQUEST.""" MCP_APPROVAL_RESPONSE = "mcp_approval_response" + """MCP_APPROVAL_RESPONSE.""" MCP_CALL = "mcp_call" + """MCP_CALL.""" CUSTOM_TOOL_CALL_OUTPUT = "custom_tool_call_output" + """CUSTOM_TOOL_CALL_OUTPUT.""" CUSTOM_TOOL_CALL = "custom_tool_call" + """CUSTOM_TOOL_CALL.""" ITEM_REFERENCE = "item_reference" + """ITEM_REFERENCE.""" class InsightType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -518,51 +607,19 @@ class InsightType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Evaluation Comparison.""" -class ItemResourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of ItemResourceType.""" - - MESSAGE = "message" - OUTPUT_MESSAGE = "output_message" - FILE_SEARCH_CALL = "file_search_call" - COMPUTER_CALL = "computer_call" - COMPUTER_CALL_OUTPUT = "computer_call_output" - WEB_SEARCH_CALL = "web_search_call" - FUNCTION_CALL = "function_call" - FUNCTION_CALL_OUTPUT = "function_call_output" - IMAGE_GENERATION_CALL = "image_generation_call" - CODE_INTERPRETER_CALL = "code_interpreter_call" - LOCAL_SHELL_CALL = "local_shell_call" - LOCAL_SHELL_CALL_OUTPUT = "local_shell_call_output" - SHELL_CALL = "shell_call" - SHELL_CALL_OUTPUT = "shell_call_output" - APPLY_PATCH_CALL = "apply_patch_call" - APPLY_PATCH_CALL_OUTPUT = "apply_patch_call_output" - MCP_LIST_TOOLS = "mcp_list_tools" - MCP_APPROVAL_REQUEST = "mcp_approval_request" - MCP_APPROVAL_RESPONSE = "mcp_approval_response" - MCP_CALL = "mcp_call" - STRUCTURED_OUTPUTS = "structured_outputs" - WORKFLOW_ACTION = "workflow_action" - MEMORY_SEARCH_CALL = "memory_search_call" - OAUTH_CONSENT_REQUEST = "oauth_consent_request" - - -class LocalShellCallStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of LocalShellCallStatus.""" - - IN_PROGRESS = "in_progress" - COMPLETED = "completed" - INCOMPLETE = "incomplete" - - class MCPToolCallStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of MCPToolCallStatus.""" IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" COMPLETED = "completed" + """COMPLETED.""" INCOMPLETE = "incomplete" + """INCOMPLETE.""" CALLING = "calling" + """CALLING.""" FAILED = "failed" + """FAILED.""" class MemoryItemKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -592,14 +649,30 @@ class MemoryStoreKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The default memory store implementation.""" +class MemoryStoreObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of MemoryStoreObjectType.""" + + MEMORY_STORE = "memory_store" + """MEMORY_STORE.""" + MEMORY_STORE_DELETED = "memory_store.deleted" + """MEMORY_STORE_DELETED.""" + MEMORY_STORE_SCOPE_DELETED = "memory_store.scope.deleted" + """MEMORY_STORE_SCOPE_DELETED.""" + + class MemoryStoreUpdateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Status of a memory store update operation.""" QUEUED = "queued" + """QUEUED.""" IN_PROGRESS = "in_progress" + """IN_PROGRESS.""" COMPLETED = "completed" + """COMPLETED.""" FAILED = "failed" + """FAILED.""" SUPERSEDED = "superseded" + """SUPERSEDED.""" class OpenApiAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -611,8 +684,11 @@ class OpenApiAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ ANONYMOUS = "anonymous" + """ANONYMOUS.""" PROJECT_CONNECTION = "project_connection" + """PROJECT_CONNECTION.""" MANAGED_IDENTITY = "managed_identity" + """MANAGED_IDENTITY.""" class OperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -630,26 +706,22 @@ class OperationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The operation has been canceled by the user.""" -class OutputContentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Type of OutputContentType.""" - - OUTPUT_TEXT = "output_text" - REFUSAL = "refusal" - REASONING_TEXT = "reasoning_text" - - class OutputMessageContentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of OutputMessageContentType.""" OUTPUT_TEXT = "output_text" + """OUTPUT_TEXT.""" REFUSAL = "refusal" + """REFUSAL.""" class PageOrder(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of PageOrder.""" ASC = "asc" + """ASC.""" DESC = "desc" + """DESC.""" class PendingUploadType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -665,7 +737,9 @@ class RankerVersionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of RankerVersionType.""" AUTO = "auto" + """AUTO.""" DEFAULT2024_11_15 = "default-2024-11-15" + """DEFAULT2024_11_15.""" class RecurrenceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -741,44 +815,102 @@ class SearchContextSize(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of SearchContextSize.""" LOW = "low" + """LOW.""" MEDIUM = "medium" + """MEDIUM.""" HIGH = "high" + """HIGH.""" class TextResponseFormatConfigurationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of TextResponseFormatConfigurationType.""" TEXT = "text" + """TEXT.""" JSON_SCHEMA = "json_schema" + """JSON_SCHEMA.""" JSON_OBJECT = "json_object" + """JSON_OBJECT.""" + + +class ToolChoiceParamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of ToolChoiceParamType.""" + + ALLOWED_TOOLS = "allowed_tools" + """ALLOWED_TOOLS.""" + FUNCTION = "function" + """FUNCTION.""" + MCP = "mcp" + """MCP.""" + CUSTOM = "custom" + """CUSTOM.""" + APPLY_PATCH = "apply_patch" + """APPLY_PATCH.""" + SHELL = "shell" + """SHELL.""" + FILE_SEARCH = "file_search" + """FILE_SEARCH.""" + WEB_SEARCH_PREVIEW = "web_search_preview" + """WEB_SEARCH_PREVIEW.""" + COMPUTER_USE_PREVIEW = "computer_use_preview" + """COMPUTER_USE_PREVIEW.""" + WEB_SEARCH_PREVIEW2025_03_11 = "web_search_preview_2025_03_11" + """WEB_SEARCH_PREVIEW2025_03_11.""" + IMAGE_GENERATION = "image_generation" + """IMAGE_GENERATION.""" + CODE_INTERPRETER = "code_interpreter" + """CODE_INTERPRETER.""" class ToolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of ToolType.""" FUNCTION = "function" + """FUNCTION.""" FILE_SEARCH = "file_search" + """FILE_SEARCH.""" COMPUTER_USE_PREVIEW = "computer_use_preview" + """COMPUTER_USE_PREVIEW.""" WEB_SEARCH = "web_search" + """WEB_SEARCH.""" MCP = "mcp" + """MCP.""" CODE_INTERPRETER = "code_interpreter" + """CODE_INTERPRETER.""" IMAGE_GENERATION = "image_generation" + """IMAGE_GENERATION.""" LOCAL_SHELL = "local_shell" + """LOCAL_SHELL.""" SHELL = "shell" + """SHELL.""" CUSTOM = "custom" + """CUSTOM.""" WEB_SEARCH_PREVIEW = "web_search_preview" + """WEB_SEARCH_PREVIEW.""" APPLY_PATCH = "apply_patch" + """APPLY_PATCH.""" A2A_PREVIEW = "a2a_preview" + """A2A_PREVIEW.""" BING_CUSTOM_SEARCH_PREVIEW = "bing_custom_search_preview" + """BING_CUSTOM_SEARCH_PREVIEW.""" BROWSER_AUTOMATION_PREVIEW = "browser_automation_preview" + """BROWSER_AUTOMATION_PREVIEW.""" FABRIC_DATAAGENT_PREVIEW = "fabric_dataagent_preview" + """FABRIC_DATAAGENT_PREVIEW.""" SHAREPOINT_GROUNDING_PREVIEW = "sharepoint_grounding_preview" + """SHAREPOINT_GROUNDING_PREVIEW.""" + MEMORY_SEARCH_PREVIEW = "memory_search_preview" + """MEMORY_SEARCH_PREVIEW.""" AZURE_AI_SEARCH = "azure_ai_search" + """AZURE_AI_SEARCH.""" AZURE_FUNCTION = "azure_function" + """AZURE_FUNCTION.""" BING_GROUNDING = "bing_grounding" + """BING_GROUNDING.""" CAPTURE_STRUCTURED_OUTPUTS = "capture_structured_outputs" + """CAPTURE_STRUCTURED_OUTPUTS.""" OPENAPI = "openapi" - MEMORY_SEARCH = "memory_search" + """OPENAPI.""" class TreatmentEffectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): 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 148f0517a776..ac02f7ae85e5 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 @@ -14,8 +14,8 @@ from .._utils.model_base import Model as _Model, rest_discriminator, rest_field from ._enums import ( AgentKind, + AgentObjectType, AnnotationType, - ApplyPatchFileOperationType, ApplyPatchOperationParamType, ComputerActionType, CredentialType, @@ -27,22 +27,21 @@ EvaluatorDefinitionType, FunctionAndCustomToolCallOutputType, FunctionShellCallOutputOutcomeParamType, - FunctionShellCallOutputOutcomeType, IndexType, InputContentType, InputItemType, InsightType, - ItemResourceType, MemoryItemKind, MemoryStoreKind, + MemoryStoreObjectType, OpenApiAuthType, - OutputContentType, OutputMessageContentType, PendingUploadType, RecurrenceType, SampleType, ScheduleTaskType, TextResponseFormatConfigurationType, + ToolChoiceParamType, ToolType, TriggerType, ) @@ -66,8 +65,8 @@ class Tool(_Model): "web_search", "mcp", "code_interpreter", "image_generation", "local_shell", "shell", "custom", "web_search_preview", "apply_patch", "a2a_preview", "bing_custom_search_preview", "browser_automation_preview", "fabric_dataagent_preview", "sharepoint_grounding_preview", - "azure_ai_search", "azure_function", "bing_grounding", "capture_structured_outputs", "openapi", - and "memory_search". + "memory_search_preview", "azure_ai_search", "azure_function", "bing_grounding", + "capture_structured_outputs", and "openapi". :vartype type: str or ~azure.ai.projects.models.ToolType """ @@ -77,8 +76,8 @@ class Tool(_Model): \"web_search\", \"mcp\", \"code_interpreter\", \"image_generation\", \"local_shell\", \"shell\", \"custom\", \"web_search_preview\", \"apply_patch\", \"a2a_preview\", \"bing_custom_search_preview\", \"browser_automation_preview\", \"fabric_dataagent_preview\", - \"sharepoint_grounding_preview\", \"azure_ai_search\", \"azure_function\", \"bing_grounding\", - \"capture_structured_outputs\", \"openapi\", and \"memory_search\".""" + \"sharepoint_grounding_preview\", \"memory_search_preview\", \"azure_ai_search\", + \"azure_function\", \"bing_grounding\", \"capture_structured_outputs\", and \"openapi\".""" @overload def __init__( @@ -101,30 +100,29 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class A2APreviewTool(Tool, discriminator="a2a_preview"): """An agent implementing the A2A protocol. - :ivar type: The type of the tool. Always ``"a2a_preview``. Required. + :ivar type: The type of the tool. Always ``"a2a_preview``. Required. A2A_PREVIEW. :vartype type: str or ~azure.ai.projects.models.A2A_PREVIEW :ivar base_url: Base URL of the agent. :vartype base_url: str - :ivar agent_card_path: The path to the agent card relative to the ``base_url``. - If not provided, defaults to ``/.well-known/agent-card.json``. + :ivar agent_card_path: The path to the agent card relative to the ``base_url``. If not + provided, defaults to ``/.well-known/agent-card.json``. :vartype agent_card_path: str - :ivar project_connection_id: The connection ID in the project for the A2A server. - The connection stores authentication and other connection details needed to connect to the A2A + :ivar project_connection_id: The connection ID in the project for the A2A server. The + connection stores authentication and other connection details needed to connect to the A2A server. :vartype project_connection_id: str """ type: Literal[ToolType.A2A_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the tool. Always ``\"a2a_preview``. Required.""" + """The type of the tool. Always ``\"a2a_preview``. Required. A2A_PREVIEW.""" base_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Base URL of the agent.""" agent_card_path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The path to the agent card relative to the ``base_url``. - If not provided, defaults to ``/.well-known/agent-card.json``.""" + """The path to the agent card relative to the ``base_url``. If not provided, defaults to + ``/.well-known/agent-card.json``.""" project_connection_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The connection ID in the project for the A2A server. - The connection stores authentication and other connection details needed to connect to the A2A - server.""" + """The connection ID in the project for the A2A server. The connection stores authentication and + other connection details needed to connect to the A2A server.""" @overload def __init__( @@ -147,20 +145,21 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = ToolType.A2A_PREVIEW # type: ignore -class InsightResult(_Model): - """The result of the insights. +class InsightRequest(_Model): + """The request of the insights report. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AgentClusterInsightResult, EvalCompareReport, EvaluationRunClusterInsightResult + AgentClusterInsightRequest, EvaluationComparisonInsightRequest, + EvaluationRunClusterInsightRequest - :ivar type: The type of insights result. Required. Known values are: - "EvaluationRunClusterInsight", "AgentClusterInsight", and "EvaluationComparison". + :ivar type: The type of request. Required. Known values are: "EvaluationRunClusterInsight", + "AgentClusterInsight", and "EvaluationComparison". :vartype type: str or ~azure.ai.projects.models.InsightType """ __mapping__: dict[str, _Model] = {} type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) - """The type of insights result. Required. Known values are: \"EvaluationRunClusterInsight\", + """The type of request. Required. Known values are: \"EvaluationRunClusterInsight\", \"AgentClusterInsight\", and \"EvaluationComparison\".""" @overload @@ -181,27 +180,32 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgentClusterInsightResult(InsightResult, discriminator="AgentClusterInsight"): - """Insights from the agent cluster analysis. +class AgentClusterInsightRequest(InsightRequest, discriminator="AgentClusterInsight"): + """Insights on set of Agent Evaluation Results. - :ivar type: The type of insights result. Required. Cluster Insight on an Agent. + :ivar type: The type of request. Required. Cluster Insight on an Agent. :vartype type: str or ~azure.ai.projects.models.AGENT_CLUSTER_INSIGHT - :ivar cluster_insight: Required. - :vartype cluster_insight: ~azure.ai.projects.models.ClusterInsightResult + :ivar agent_name: Identifier for the agent. Required. + :vartype agent_name: str + :ivar model_configuration: Configuration of the model used in the insight generation. + :vartype model_configuration: ~azure.ai.projects.models.InsightModelConfiguration """ type: Literal[InsightType.AGENT_CLUSTER_INSIGHT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of insights result. Required. Cluster Insight on an Agent.""" - cluster_insight: "_models.ClusterInsightResult" = rest_field( - name="clusterInsight", visibility=["read", "create", "update", "delete", "query"] + """The type of request. Required. Cluster Insight on an Agent.""" + agent_name: str = rest_field(name="agentName", visibility=["read", "create", "update", "delete", "query"]) + """Identifier for the agent. Required.""" + model_configuration: Optional["_models.InsightModelConfiguration"] = rest_field( + name="modelConfiguration", visibility=["read", "create", "update", "delete", "query"] ) - """Required.""" + """Configuration of the model used in the insight generation.""" @overload def __init__( self, *, - cluster_insight: "_models.ClusterInsightResult", + agent_name: str, + model_configuration: Optional["_models.InsightModelConfiguration"] = None, ) -> None: ... @overload @@ -216,20 +220,20 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = InsightType.AGENT_CLUSTER_INSIGHT # type: ignore -class InsightRequest(_Model): - """The request of the insights report. +class InsightResult(_Model): + """The result of the insights. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - AgentClusterInsightsRequest, EvaluationComparisonRequest, EvaluationRunClusterInsightsRequest + AgentClusterInsightResult, EvaluationComparisonInsightResult, EvaluationRunClusterInsightResult - :ivar type: The type of request. Required. Known values are: "EvaluationRunClusterInsight", - "AgentClusterInsight", and "EvaluationComparison". + :ivar type: The type of insights result. Required. Known values are: + "EvaluationRunClusterInsight", "AgentClusterInsight", and "EvaluationComparison". :vartype type: str or ~azure.ai.projects.models.InsightType """ __mapping__: dict[str, _Model] = {} type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) - """The type of request. Required. Known values are: \"EvaluationRunClusterInsight\", + """The type of insights result. Required. Known values are: \"EvaluationRunClusterInsight\", \"AgentClusterInsight\", and \"EvaluationComparison\".""" @overload @@ -250,32 +254,27 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgentClusterInsightsRequest(InsightRequest, discriminator="AgentClusterInsight"): - """Insights on set of Agent Evaluation Results. +class AgentClusterInsightResult(InsightResult, discriminator="AgentClusterInsight"): + """Insights from the agent cluster analysis. - :ivar type: The type of request. Required. Cluster Insight on an Agent. + :ivar type: The type of insights result. Required. Cluster Insight on an Agent. :vartype type: str or ~azure.ai.projects.models.AGENT_CLUSTER_INSIGHT - :ivar agent_name: Identifier for the agent. Required. - :vartype agent_name: str - :ivar model_configuration: Configuration of the model used in the insight generation. - :vartype model_configuration: ~azure.ai.projects.models.InsightModelConfiguration + :ivar cluster_insight: Required. + :vartype cluster_insight: ~azure.ai.projects.models.ClusterInsightResult """ type: Literal[InsightType.AGENT_CLUSTER_INSIGHT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of request. Required. Cluster Insight on an Agent.""" - agent_name: str = rest_field(name="agentName", visibility=["read", "create", "update", "delete", "query"]) - """Identifier for the agent. Required.""" - model_configuration: Optional["_models.InsightModelConfiguration"] = rest_field( - name="modelConfiguration", visibility=["read", "create", "update", "delete", "query"] + """The type of insights result. Required. Cluster Insight on an Agent.""" + cluster_insight: "_models.ClusterInsightResult" = rest_field( + name="clusterInsight", visibility=["read", "create", "update", "delete", "query"] ) - """Configuration of the model used in the insight generation.""" + """Required.""" @overload def __init__( self, *, - agent_name: str, - model_configuration: Optional["_models.InsightModelConfiguration"] = None, + cluster_insight: "_models.ClusterInsightResult", ) -> None: ... @overload @@ -331,8 +330,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class AgentDetails(_Model): """AgentDetails. - :ivar object: The object type, which is always 'agent'. Required. Default value is "agent". - :vartype object: str + :ivar object: The object type, which is always 'agent'. Required. AGENT. + :vartype object: str or ~azure.ai.projects.models.AGENT :ivar id: The unique identifier of the agent. Required. :vartype id: str :ivar name: The name of the agent. Required. @@ -341,8 +340,8 @@ class AgentDetails(_Model): :vartype versions: ~azure.ai.projects.models.AgentObjectVersions """ - object: Literal["agent"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The object type, which is always 'agent'. Required. Default value is \"agent\".""" + object: Literal[AgentObjectType.AGENT] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The object type, which is always 'agent'. Required. AGENT.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique identifier of the agent. Required.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -354,6 +353,7 @@ class AgentDetails(_Model): def __init__( self, *, + object: Literal[AgentObjectType.AGENT], id: str, # pylint: disable=redefined-builtin name: str, versions: "_models.AgentObjectVersions", @@ -368,25 +368,24 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.object: Literal["agent"] = "agent" class BaseCredentials(_Model): """A base class for connection credentials. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EntraIDCredentials, AgenticIdentityCredentials, ApiKeyCredentials, CustomCredential, + EntraIDCredentials, AgenticIdentityPreviewCredentials, ApiKeyCredentials, CustomCredential, NoAuthenticationCredentials, SASCredentials :ivar type: The type of credential used by the connection. Required. Known values are: - "ApiKey", "AAD", "SAS", "CustomKeys", "None", and "AgenticIdentityToken". + "ApiKey", "AAD", "SAS", "CustomKeys", "None", and "AgenticIdentityToken_Preview". :vartype type: str or ~azure.ai.projects.models.CredentialType """ __mapping__: dict[str, _Model] = {} type: str = rest_discriminator(name="type", visibility=["read"]) """The type of credential used by the connection. Required. Known values are: \"ApiKey\", \"AAD\", - \"SAS\", \"CustomKeys\", \"None\", and \"AgenticIdentityToken\".""" + \"SAS\", \"CustomKeys\", \"None\", and \"AgenticIdentityToken_Preview\".""" @overload def __init__( @@ -406,57 +405,19 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgenticIdentityCredentials(BaseCredentials, discriminator="AgenticIdentityToken"): +class AgenticIdentityPreviewCredentials(BaseCredentials, discriminator="AgenticIdentityToken_Preview"): """Agentic identity credential definition. - :ivar type: The credential type. Required. Agentic identity credential - :vartype type: str or ~azure.ai.projects.models.AGENTIC_IDENTITY - """ - - type: Literal[CredentialType.AGENTIC_IDENTITY] = rest_discriminator(name="type", visibility=["read"]) # type: ignore - """The credential type. Required. Agentic identity credential""" - - @overload - def __init__( - self, - ) -> 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) - self.type = CredentialType.AGENTIC_IDENTITY # type: ignore - - -class AgentId(_Model): - """AgentId. - - :ivar type: Required. Default value is "agent_id". - :vartype type: str - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar version: The version identifier of the agent. Required. - :vartype version: str + :ivar type: The credential type. Required. Agentic identity credential. + :vartype type: str or ~azure.ai.projects.models.AGENTIC_IDENTITY_PREVIEW """ - type: Literal["agent_id"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required. Default value is \"agent_id\".""" - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name of the agent. Required.""" - version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The version identifier of the agent. Required.""" + type: Literal[CredentialType.AGENTIC_IDENTITY_PREVIEW] = rest_discriminator(name="type", visibility=["read"]) # type: ignore + """The credential type. Required. Agentic identity credential.""" @overload def __init__( self, - *, - name: str, - version: str, ) -> None: ... @overload @@ -468,7 +429,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type: Literal["agent_id"] = "agent_id" + self.type = CredentialType.AGENTIC_IDENTITY_PREVIEW # type: ignore class AgentObjectVersions(_Model): @@ -499,44 +460,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgentReference(_Model): - """AgentReference. - - :ivar type: Required. Default value is "agent_reference". - :vartype type: str - :ivar name: The name of the agent. Required. - :vartype name: str - :ivar version: The version identifier of the agent. - :vartype version: str - """ - - type: Literal["agent_reference"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required. Default value is \"agent_reference\".""" - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name of the agent. Required.""" - version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The version identifier of the agent.""" - - @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) - self.type: Literal["agent_reference"] = "agent_reference" - - class EvaluationTaxonomyInput(_Model): """Input configuration for the evaluation taxonomy. @@ -573,17 +496,17 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class AgentTaxonomyInput(EvaluationTaxonomyInput, discriminator="agent"): """Input configuration for the evaluation taxonomy when the input type is agent. - :ivar type: Input type of the evaluation taxonomy. Required. Agent + :ivar type: Input type of the evaluation taxonomy. Required. Agent. :vartype type: str or ~azure.ai.projects.models.AGENT :ivar target: Target configuration for the agent. Required. - :vartype target: ~azure.ai.projects.models.AzureAIAgentTarget + :vartype target: ~azure.ai.projects.models.Target :ivar risk_categories: List of risk categories to evaluate against. Required. :vartype risk_categories: list[str or ~azure.ai.projects.models.RiskCategory] """ type: Literal[EvaluationTaxonomyInputType.AGENT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Input type of the evaluation taxonomy. Required. Agent""" - target: "_models.AzureAIAgentTarget" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Input type of the evaluation taxonomy. Required. Agent.""" + target: "_models.Target" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Target configuration for the agent. Required.""" risk_categories: list[Union[str, "_models.RiskCategory"]] = rest_field( name="riskCategories", visibility=["read", "create", "update", "delete", "query"] @@ -594,7 +517,7 @@ class AgentTaxonomyInput(EvaluationTaxonomyInput, discriminator="agent"): def __init__( self, *, - target: "_models.AzureAIAgentTarget", + target: "_models.Target", risk_categories: list[Union[str, "_models.RiskCategory"]], ) -> None: ... @@ -620,9 +543,8 @@ class AgentVersionDetails(_Model): Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. Required. :vartype metadata: dict[str, str] - :ivar object: The object type, which is always 'agent.version'. Required. Default value is - "agent.version". - :vartype object: str + :ivar object: The object type, which is always 'agent.version'. Required. AGENT_VERSION. + :vartype object: str or ~azure.ai.projects.models.AGENT_VERSION :ivar id: The unique identifier of the agent version. Required. :vartype id: str :ivar name: The name of the agent. Name can be used to retrieve/update/delete the agent. @@ -646,8 +568,10 @@ class AgentVersionDetails(_Model): Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters. Required.""" - object: Literal["agent.version"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The object type, which is always 'agent.version'. Required. Default value is \"agent.version\".""" + object: Literal[AgentObjectType.AGENT_VERSION] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object type, which is always 'agent.version'. Required. AGENT_VERSION.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique identifier of the agent version. Required.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -669,6 +593,7 @@ def __init__( self, *, metadata: dict[str, str], + object: Literal[AgentObjectType.AGENT_VERSION], id: str, # pylint: disable=redefined-builtin name: str, version: str, @@ -686,7 +611,6 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.object: Literal["agent.version"] = "agent.version" class AISearchIndexResource(_Model): @@ -782,51 +706,50 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ApiErrorResponse(_Model): - """Error response for API failures. +class ApiError(_Model): + """ApiError. - :ivar error: Required. - :vartype error: ~azure.ai.projects.models.Error + :ivar code: Required. + :vartype code: str + :ivar message: Required. + :vartype message: str + :ivar param: + :vartype param: str + :ivar type: + :vartype type: str + :ivar details: + :vartype details: list[~azure.ai.projects.models.ApiError] + :ivar additional_info: + :vartype additional_info: dict[str, any] + :ivar debug_info: + :vartype debug_info: dict[str, any] """ - error: "_models.Error" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" + param: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + type: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + details: Optional[list["_models.ApiError"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + additional_info: Optional[dict[str, Any]] = rest_field( + name="additionalInfo", visibility=["read", "create", "update", "delete", "query"] + ) + debug_info: Optional[dict[str, Any]] = rest_field( + name="debugInfo", visibility=["read", "create", "update", "delete", "query"] + ) @overload def __init__( self, *, - error: "_models.Error", - ) -> 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 ApiKeyCredentials(BaseCredentials, discriminator="ApiKey"): - """API Key Credential definition. - - :ivar type: The credential type. Required. API Key credential - :vartype type: str or ~azure.ai.projects.models.API_KEY - :ivar api_key: API Key. - :vartype api_key: str - """ - - type: Literal[CredentialType.API_KEY] = rest_discriminator(name="type", visibility=["read"]) # type: ignore - """The credential type. Required. API Key credential""" - api_key: Optional[str] = rest_field(name="key", visibility=["read"]) - """API Key.""" - - @overload - def __init__( - self, + code: str, + message: str, + param: Optional[str] = None, + type: Optional[str] = None, + details: Optional[list["_models.ApiError"]] = None, + additional_info: Optional[dict[str, Any]] = None, + debug_info: Optional[dict[str, Any]] = None, ) -> None: ... @overload @@ -838,28 +761,23 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = CredentialType.API_KEY # type: ignore -class ApplyPatchFileOperation(_Model): - """Apply patch operation. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ApplyPatchCreateFileOperation, ApplyPatchDeleteFileOperation, ApplyPatchUpdateFileOperation +class ApiErrorResponse(_Model): + """Error response for API failures. - :ivar type: Required. Known values are: "create_file", "delete_file", and "update_file". - :vartype type: str or ~azure.ai.projects.models.ApplyPatchFileOperationType + :ivar error: Required. + :vartype error: ~azure.ai.projects.models.ApiError """ - __mapping__: dict[str, _Model] = {} - type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) - """Required. Known values are: \"create_file\", \"delete_file\", and \"update_file\".""" + error: "_models.ApiError" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Required.""" @overload def __init__( self, *, - type: str, + error: "_models.ApiError", ) -> None: ... @overload @@ -873,30 +791,23 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ApplyPatchCreateFileOperation(ApplyPatchFileOperation, discriminator="create_file"): - """Apply patch create file operation. +class ApiKeyCredentials(BaseCredentials, discriminator="ApiKey"): + """API Key Credential definition. - :ivar type: Create a new file with the provided diff. Required. - :vartype type: str or ~azure.ai.projects.models.CREATE_FILE - :ivar path: Path of the file to create. Required. - :vartype path: str - :ivar diff: Diff to apply. Required. - :vartype diff: str + :ivar type: The credential type. Required. API Key credential. + :vartype type: str or ~azure.ai.projects.models.API_KEY + :ivar api_key: API Key. + :vartype api_key: str """ - type: Literal[ApplyPatchFileOperationType.CREATE_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Create a new file with the provided diff. Required.""" - path: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Path of the file to create. Required.""" - diff: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Diff to apply. Required.""" + type: Literal[CredentialType.API_KEY] = rest_discriminator(name="type", visibility=["read"]) # type: ignore + """The credential type. Required. API Key credential.""" + api_key: Optional[str] = rest_field(name="key", visibility=["read"]) + """API Key.""" @overload def __init__( self, - *, - path: str, - diff: str, ) -> None: ... @overload @@ -908,7 +819,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = ApplyPatchFileOperationType.CREATE_FILE # type: ignore + self.type = CredentialType.API_KEY # type: ignore class ApplyPatchOperationParam(_Model): @@ -947,7 +858,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class ApplyPatchCreateFileOperationParam(ApplyPatchOperationParam, discriminator="create_file"): """Apply patch create file operation. - :ivar type: The operation type. Always ``create_file``. Required. + :ivar type: The operation type. Always ``create_file``. Required. CREATE_FILE. :vartype type: str or ~azure.ai.projects.models.CREATE_FILE :ivar path: Path of the file to create relative to the workspace root. Required. :vartype path: str @@ -956,7 +867,7 @@ class ApplyPatchCreateFileOperationParam(ApplyPatchOperationParam, discriminator """ type: Literal[ApplyPatchOperationParamType.CREATE_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The operation type. Always ``create_file``. Required.""" + """The operation type. Always ``create_file``. Required. CREATE_FILE.""" path: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Path of the file to create relative to the workspace root. Required.""" diff: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -982,50 +893,17 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = ApplyPatchOperationParamType.CREATE_FILE # type: ignore -class ApplyPatchDeleteFileOperation(ApplyPatchFileOperation, discriminator="delete_file"): - """Apply patch delete file operation. - - :ivar type: Delete the specified file. Required. - :vartype type: str or ~azure.ai.projects.models.DELETE_FILE - :ivar path: Path of the file to delete. Required. - :vartype path: str - """ - - type: Literal[ApplyPatchFileOperationType.DELETE_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Delete the specified file. Required.""" - path: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Path of the file to delete. Required.""" - - @overload - def __init__( - self, - *, - path: 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) - self.type = ApplyPatchFileOperationType.DELETE_FILE # type: ignore - - class ApplyPatchDeleteFileOperationParam(ApplyPatchOperationParam, discriminator="delete_file"): """Apply patch delete file operation. - :ivar type: The operation type. Always ``delete_file``. Required. + :ivar type: The operation type. Always ``delete_file``. Required. DELETE_FILE. :vartype type: str or ~azure.ai.projects.models.DELETE_FILE :ivar path: Path of the file to delete relative to the workspace root. Required. :vartype path: str """ type: Literal[ApplyPatchOperationParamType.DELETE_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The operation type. Always ``delete_file``. Required.""" + """The operation type. Always ``delete_file``. Required. DELETE_FILE.""" path: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Path of the file to delete relative to the workspace root. Required.""" @@ -1051,12 +929,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class ApplyPatchToolParam(Tool, discriminator="apply_patch"): """Apply patch tool. - :ivar type: The type of the tool. Always ``apply_patch``. Required. + :ivar type: The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH. :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH """ type: Literal[ToolType.APPLY_PATCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the tool. Always ``apply_patch``. Required.""" + """The type of the tool. Always ``apply_patch``. Required. APPLY_PATCH.""" @overload def __init__( @@ -1075,23 +953,23 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = ToolType.APPLY_PATCH # type: ignore -class ApplyPatchUpdateFileOperation(ApplyPatchFileOperation, discriminator="update_file"): +class ApplyPatchUpdateFileOperationParam(ApplyPatchOperationParam, discriminator="update_file"): """Apply patch update file operation. - :ivar type: Update an existing file with the provided diff. Required. + :ivar type: The operation type. Always ``update_file``. Required. UPDATE_FILE. :vartype type: str or ~azure.ai.projects.models.UPDATE_FILE - :ivar path: Path of the file to update. Required. + :ivar path: Path of the file to update relative to the workspace root. Required. :vartype path: str - :ivar diff: Diff to apply. Required. + :ivar diff: Unified diff content to apply to the existing file. Required. :vartype diff: str """ - type: Literal[ApplyPatchFileOperationType.UPDATE_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Update an existing file with the provided diff. Required.""" + type: Literal[ApplyPatchOperationParamType.UPDATE_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The operation type. Always ``update_file``. Required. UPDATE_FILE.""" path: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Path of the file to update. Required.""" + """Path of the file to update relative to the workspace root. Required.""" diff: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Diff to apply. Required.""" + """Unified diff content to apply to the existing file. Required.""" @overload def __init__( @@ -1110,49 +988,11 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = ApplyPatchFileOperationType.UPDATE_FILE # type: ignore + self.type = ApplyPatchOperationParamType.UPDATE_FILE # type: ignore -class ApplyPatchUpdateFileOperationParam(ApplyPatchOperationParam, discriminator="update_file"): - """Apply patch update file operation. - - :ivar type: The operation type. Always ``update_file``. Required. - :vartype type: str or ~azure.ai.projects.models.UPDATE_FILE - :ivar path: Path of the file to update relative to the workspace root. Required. - :vartype path: str - :ivar diff: Unified diff content to apply to the existing file. Required. - :vartype diff: str - """ - - type: Literal[ApplyPatchOperationParamType.UPDATE_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The operation type. Always ``update_file``. Required.""" - path: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Path of the file to update relative to the workspace root. Required.""" - diff: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Unified diff content to apply to the existing file. Required.""" - - @overload - def __init__( - self, - *, - path: str, - diff: 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) - self.type = ApplyPatchOperationParamType.UPDATE_FILE # type: ignore - - -class ApproximateLocation(_Model): - """ApproximateLocation. +class ApproximateLocation(_Model): + """ApproximateLocation. :ivar type: The type of location approximation. Always ``approximate``. Required. Default value is "approximate". @@ -1276,6 +1116,48 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = "azure_ai_agent" # type: ignore +class AzureAIModelTarget(Target, discriminator="azure_ai_model"): + """Represents a target specifying an Azure AI model for operations requiring model selection. + + :ivar type: The type of target, always ``azure_ai_model``. Required. Default value is + "azure_ai_model". + :vartype type: str + :ivar model: The unique identifier of the Azure AI model. + :vartype model: str + :ivar sampling_params: The parameters used to control the sampling behavior of the model during + text generation. + :vartype sampling_params: ~azure.ai.projects.models.ModelSamplingParams + """ + + type: Literal["azure_ai_model"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of target, always ``azure_ai_model``. Required. Default value is \"azure_ai_model\".""" + model: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unique identifier of the Azure AI model.""" + sampling_params: Optional["_models.ModelSamplingParams"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The parameters used to control the sampling behavior of the model during text generation.""" + + @overload + def __init__( + self, + *, + model: Optional[str] = None, + sampling_params: Optional["_models.ModelSamplingParams"] = 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) + self.type = "azure_ai_model" # type: ignore + + class Index(_Model): """Index resource Definition. @@ -1345,7 +1227,7 @@ class AzureAISearchIndex(Index, discriminator="AzureSearch"): :vartype description: str :ivar tags: Tag dictionary. Tags can be added, removed, and updated. :vartype tags: dict[str, str] - :ivar type: Type of index. Required. Azure search + :ivar type: Type of index. Required. Azure search. :vartype type: str or ~azure.ai.projects.models.AZURE_SEARCH :ivar connection_name: Name of connection to Azure AI Search. Required. :vartype connection_name: str @@ -1356,7 +1238,7 @@ class AzureAISearchIndex(Index, discriminator="AzureSearch"): """ type: Literal[IndexType.AZURE_SEARCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Type of index. Required. Azure search""" + """Type of index. Required. Azure search.""" connection_name: str = rest_field(name="connectionName", visibility=["create"]) """Name of connection to Azure AI Search. Required.""" index_name: str = rest_field(name="indexName", visibility=["create"]) @@ -1390,14 +1272,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class AzureAISearchTool(Tool, discriminator="azure_ai_search"): """The input definition information for an Azure AI search tool as used to configure an agent. - :ivar type: The object type, which is always 'azure_ai_search'. Required. + :ivar type: The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH. :vartype type: str or ~azure.ai.projects.models.AZURE_AI_SEARCH :ivar azure_ai_search: The azure ai search index resource. Required. :vartype azure_ai_search: ~azure.ai.projects.models.AzureAISearchToolResource """ type: Literal[ToolType.AZURE_AI_SEARCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'azure_ai_search'. Required.""" + """The object type, which is always 'azure_ai_search'. Required. AZURE_AI_SEARCH.""" azure_ai_search: "_models.AzureAISearchToolResource" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -1425,16 +1307,16 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class AzureAISearchToolResource(_Model): """A set of index resources used by the ``azure_ai_search`` tool. - :ivar indexes: The indices attached to this agent. There can be a maximum of 1 index - resource attached to the agent. Required. + :ivar indexes: The indices attached to this agent. There can be a maximum of 1 index resource + attached to the agent. Required. :vartype indexes: list[~azure.ai.projects.models.AISearchIndexResource] """ indexes: list["_models.AISearchIndexResource"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The indices attached to this agent. There can be a maximum of 1 index - resource attached to the agent. Required.""" + """The indices attached to this agent. There can be a maximum of 1 index resource attached to the + agent. Required.""" @overload def __init__( @@ -1549,7 +1431,7 @@ class AzureFunctionDefinitionFunction(_Model): :vartype description: str :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. Required. - :vartype parameters: any + :vartype parameters: dict[str, any] """ name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -1557,7 +1439,7 @@ class AzureFunctionDefinitionFunction(_Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A description of what the function does, used by the model to choose when and how to call the function.""" - parameters: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) + parameters: dict[str, Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The parameters the functions accepts, described as a JSON Schema object. Required.""" @overload @@ -1565,7 +1447,7 @@ def __init__( self, *, name: str, - parameters: Any, + parameters: dict[str, Any], description: Optional[str] = None, ) -> None: ... @@ -1617,14 +1499,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class AzureFunctionTool(Tool, discriminator="azure_function"): """The input definition information for an Azure Function Tool, as used to configure an Agent. - :ivar type: The object type, which is always 'browser_automation'. Required. + :ivar type: The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION. :vartype type: str or ~azure.ai.projects.models.AZURE_FUNCTION :ivar azure_function: The Azure Function Tool definition. Required. :vartype azure_function: ~azure.ai.projects.models.AzureFunctionDefinition """ type: Literal[ToolType.AZURE_FUNCTION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'browser_automation'. Required.""" + """The object type, which is always 'browser_automation'. Required. AZURE_FUNCTION.""" azure_function: "_models.AzureFunctionDefinition" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -1779,13 +1661,15 @@ class BingCustomSearchPreviewTool(Tool, discriminator="bing_custom_search_previe """The input definition information for a Bing custom search tool as used to configure an agent. :ivar type: The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW. :vartype type: str or ~azure.ai.projects.models.BING_CUSTOM_SEARCH_PREVIEW :ivar bing_custom_search_preview: The bing custom search tool parameters. Required. :vartype bing_custom_search_preview: ~azure.ai.projects.models.BingCustomSearchToolParameters """ type: Literal[ToolType.BING_CUSTOM_SEARCH_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'bing_custom_search_preview'. Required.""" + """The object type, which is always 'bing_custom_search_preview'. Required. + BING_CUSTOM_SEARCH_PREVIEW.""" bing_custom_search_preview: "_models.BingCustomSearchToolParameters" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -1814,16 +1698,15 @@ class BingCustomSearchToolParameters(_Model): """The bing custom search tool parameters. :ivar search_configurations: The project connections attached to this tool. There can be a - maximum of 1 connection - resource attached to the tool. Required. + maximum of 1 connection resource attached to the tool. Required. :vartype search_configurations: list[~azure.ai.projects.models.BingCustomSearchConfiguration] """ search_configurations: list["_models.BingCustomSearchConfiguration"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The project connections attached to this tool. There can be a maximum of 1 connection - resource attached to the tool. Required.""" + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool. Required.""" @overload def __init__( @@ -1897,8 +1780,7 @@ class BingGroundingSearchToolParameters(_Model): """The bing grounding search tool parameters. :ivar search_configurations: The search configurations attached to this tool. There can be a - maximum of 1 - search configuration resource attached to the tool. Required. + maximum of 1 search configuration resource attached to the tool. Required. :vartype search_configurations: list[~azure.ai.projects.models.BingGroundingSearchConfiguration] """ @@ -1906,8 +1788,8 @@ class BingGroundingSearchToolParameters(_Model): search_configurations: list["_models.BingGroundingSearchConfiguration"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The search configurations attached to this tool. There can be a maximum of 1 - search configuration resource attached to the tool. Required.""" + """The search configurations attached to this tool. There can be a maximum of 1 search + configuration resource attached to the tool. Required.""" @overload def __init__( @@ -1931,14 +1813,14 @@ class BingGroundingTool(Tool, discriminator="bing_grounding"): """The input definition information for a bing grounding search tool as used to configure an agent. - :ivar type: The object type, which is always 'bing_grounding'. Required. + :ivar type: The object type, which is always 'bing_grounding'. Required. BING_GROUNDING. :vartype type: str or ~azure.ai.projects.models.BING_GROUNDING :ivar bing_grounding: The bing grounding search tool parameters. Required. :vartype bing_grounding: ~azure.ai.projects.models.BingGroundingSearchToolParameters """ type: Literal[ToolType.BING_GROUNDING] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'bing_grounding'. Required.""" + """The object type, which is always 'bing_grounding'. Required. BING_GROUNDING.""" bing_grounding: "_models.BingGroundingSearchToolParameters" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -2030,13 +1912,15 @@ class BrowserAutomationPreviewTool(Tool, discriminator="browser_automation_previ """The input definition information for a Browser Automation Tool, as used to configure an Agent. :ivar type: The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW. :vartype type: str or ~azure.ai.projects.models.BROWSER_AUTOMATION_PREVIEW :ivar browser_automation_preview: The Browser Automation Tool parameters. Required. :vartype browser_automation_preview: ~azure.ai.projects.models.BrowserAutomationToolParameters """ type: Literal[ToolType.BROWSER_AUTOMATION_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'browser_automation_preview'. Required.""" + """The object type, which is always 'browser_automation_preview'. Required. + BROWSER_AUTOMATION_PREVIEW.""" browser_automation_preview: "_models.BrowserAutomationToolParameters" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -2125,13 +2009,15 @@ class CaptureStructuredOutputsTool(Tool, discriminator="capture_structured_outpu """A tool for capturing structured outputs. :ivar type: The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS. :vartype type: str or ~azure.ai.projects.models.CAPTURE_STRUCTURED_OUTPUTS :ivar outputs: The structured outputs to capture from the model. Required. :vartype outputs: ~azure.ai.projects.models.StructuredOutputDefinition """ type: Literal[ToolType.CAPTURE_STRUCTURED_OUTPUTS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the tool. Always ``capture_structured_outputs``. Required.""" + """The type of the tool. Always ``capture_structured_outputs``. Required. + CAPTURE_STRUCTURED_OUTPUTS.""" outputs: "_models.StructuredOutputDefinition" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -2329,7 +2215,7 @@ class ClickParam(ComputerAction, discriminator="click"): """Click. :ivar type: Specifies the event type. For a click action, this property is always ``click``. - Required. + Required. CLICK. :vartype type: str or ~azure.ai.projects.models.CLICK :ivar button: Indicates which mouse button was pressed during the click. One of ``left``, ``right``, ``wheel``, ``back``, or ``forward``. Required. Known values are: "left", "right", @@ -2342,7 +2228,8 @@ class ClickParam(ComputerAction, discriminator="click"): """ type: Literal[ComputerActionType.CLICK] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Specifies the event type. For a click action, this property is always ``click``. Required.""" + """Specifies the event type. For a click action, this property is always ``click``. Required. + CLICK.""" button: Union[str, "_models.ClickButtonType"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -2507,10 +2394,10 @@ class EvaluatorDefinition(_Model): :vartype type: str or ~azure.ai.projects.models.EvaluatorDefinitionType :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. - :vartype init_parameters: any + :vartype init_parameters: dict[str, any] :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. - :vartype data_schema: any + :vartype data_schema: dict[str, any] :ivar metrics: List of output metrics produced by this evaluator. :vartype metrics: dict[str, ~azure.ai.projects.models.EvaluatorMetric] """ @@ -2519,10 +2406,10 @@ class EvaluatorDefinition(_Model): type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) """The type of evaluator definition. Required. Known values are: \"prompt\", \"code\", \"prompt_and_code\", \"service\", and \"openai_graders\".""" - init_parameters: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + init_parameters: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required.""" - data_schema: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + data_schema: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required.""" metrics: Optional[dict[str, "_models.EvaluatorMetric"]] = rest_field( @@ -2535,8 +2422,8 @@ def __init__( self, *, type: str, - init_parameters: Optional[Any] = None, - data_schema: Optional[Any] = None, + init_parameters: Optional[dict[str, Any]] = None, + data_schema: Optional[dict[str, Any]] = None, metrics: Optional[dict[str, "_models.EvaluatorMetric"]] = None, ) -> None: ... @@ -2556,20 +2443,20 @@ class CodeBasedEvaluatorDefinition(EvaluatorDefinition, discriminator="code"): :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. - :vartype init_parameters: any + :vartype init_parameters: dict[str, any] :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. - :vartype data_schema: any + :vartype data_schema: dict[str, any] :ivar metrics: List of output metrics produced by this evaluator. :vartype metrics: dict[str, ~azure.ai.projects.models.EvaluatorMetric] - :ivar type: Required. Code-based definition + :ivar type: Required. Code-based definition. :vartype type: str or ~azure.ai.projects.models.CODE :ivar code_text: Inline code text for the evaluator. Required. :vartype code_text: str """ type: Literal[EvaluatorDefinitionType.CODE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required. Code-based definition""" + """Required. Code-based definition.""" code_text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Inline code text for the evaluator. Required.""" @@ -2578,8 +2465,8 @@ def __init__( self, *, code_text: str, - init_parameters: Optional[Any] = None, - data_schema: Optional[Any] = None, + init_parameters: Optional[dict[str, Any]] = None, + data_schema: Optional[dict[str, Any]] = None, metrics: Optional[dict[str, "_models.EvaluatorMetric"]] = None, ) -> None: ... @@ -2705,29 +2592,30 @@ class CodeInterpreterTool(Tool, discriminator="code_interpreter"): """Code interpreter. :ivar type: The type of the code interpreter tool. Always ``code_interpreter``. Required. + CODE_INTERPRETER. :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER :ivar container: The code interpreter container. Can be a container ID or an object that - specifies uploaded file IDs to make available to your code, along with an - optional ``memory_limit`` setting. Required. Is either a str type or a + specifies uploaded file IDs to make available to your code, along with an optional + ``memory_limit`` setting. If not provided, the service assumes auto. Is either a str type or a CodeInterpreterContainerAuto type. :vartype container: str or ~azure.ai.projects.models.CodeInterpreterContainerAuto """ type: Literal[ToolType.CODE_INTERPRETER] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the code interpreter tool. Always ``code_interpreter``. Required.""" - container: Union[str, "_models.CodeInterpreterContainerAuto"] = rest_field( + """The type of the code interpreter tool. Always ``code_interpreter``. Required. CODE_INTERPRETER.""" + container: Optional[Union[str, "_models.CodeInterpreterContainerAuto"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The code interpreter container. Can be a container ID or an object that - specifies uploaded file IDs to make available to your code, along with an - optional ``memory_limit`` setting. Required. Is either a str type or a - CodeInterpreterContainerAuto type.""" + """The code interpreter container. Can be a container ID or an object that specifies uploaded file + IDs to make available to your code, along with an optional ``memory_limit`` setting. If not + provided, the service assumes auto. Is either a str type or a CodeInterpreterContainerAuto + type.""" @overload def __init__( self, *, - container: Union[str, "_models.CodeInterpreterContainerAuto"], + container: Optional[Union[str, "_models.CodeInterpreterContainerAuto"]] = None, ) -> None: ... @overload @@ -2761,9 +2649,9 @@ class ComparisonFilter(_Model): :ivar key: The key to compare against the value. Required. :vartype key: str :ivar value: The value to compare against the attribute key; supports string, number, or - boolean types. Required. Is one of the following types: str, float, bool, + boolean types. Required. Is one of the following types: str, int, bool, ["_types.ComparisonFilterValueItems"] - :vartype value: str or float or bool or list[str or float] + :vartype value: str or int or bool or list[str or int] """ type: Literal["eq", "ne", "gt", "gte", "lt", "lte"] = rest_field( @@ -2783,11 +2671,11 @@ class ComparisonFilter(_Model): Literal[\"ne\"], Literal[\"gt\"], Literal[\"gte\"], Literal[\"lt\"], Literal[\"lte\"]""" key: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The key to compare against the value. Required.""" - value: Union[str, float, bool, list["_types.ComparisonFilterValueItems"]] = rest_field( + value: Union[str, int, bool, list["_types.ComparisonFilterValueItems"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) """The value to compare against the attribute key; supports string, number, or boolean types. - Required. Is one of the following types: str, float, bool, + Required. Is one of the following types: str, int, bool, [\"_types.ComparisonFilterValueItems\"]""" @overload @@ -2796,7 +2684,7 @@ def __init__( *, type: Literal["eq", "ne", "gt", "gte", "lt", "lte"], key: str, - value: Union[str, float, bool, list["_types.ComparisonFilterValueItems"]], + value: Union[str, int, bool, list["_types.ComparisonFilterValueItems"]], ) -> None: ... @overload @@ -2887,8 +2775,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class ComputerScreenshotImage(_Model): """A computer screenshot image used with the computer use tool. - :ivar type: Specifies the event type. For a computer screenshot, this property is - always set to ``computer_screenshot``. Required. Default value is "computer_screenshot". + :ivar type: Specifies the event type. For a computer screenshot, this property is always set to + ``computer_screenshot``. Required. Default value is "computer_screenshot". :vartype type: str :ivar image_url: The URL of the screenshot image. :vartype image_url: str @@ -2897,8 +2785,8 @@ class ComputerScreenshotImage(_Model): """ type: Literal["computer_screenshot"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Specifies the event type. For a computer screenshot, this property is - always set to ``computer_screenshot``. Required. Default value is \"computer_screenshot\".""" + """Specifies the event type. For a computer screenshot, this property is always set to + ``computer_screenshot``. Required. Default value is \"computer_screenshot\".""" image_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The URL of the screenshot image.""" file_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -2928,6 +2816,7 @@ class ComputerUsePreviewTool(Tool, discriminator="computer_use_preview"): """Computer use preview. :ivar type: The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW. :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW :ivar environment: The type of computer environment to control. Required. Known values are: "windows", "mac", "linux", "ubuntu", and "browser". @@ -2939,7 +2828,8 @@ class ComputerUsePreviewTool(Tool, discriminator="computer_use_preview"): """ type: Literal[ToolType.COMPUTER_USE_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the computer use tool. Always ``computer_use_preview``. Required.""" + """The type of the computer use tool. Always ``computer_use_preview``. Required. + COMPUTER_USE_PREVIEW.""" environment: Union[str, "_models.ComputerEnvironment"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -2980,7 +2870,7 @@ class Connection(_Model): :vartype id: str :ivar type: Category of the connection. Required. Known values are: "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", - "CustomKeys", and "RemoteTool". + "CustomKeys", and "RemoteTool_Preview". :vartype type: str or ~azure.ai.projects.models.ConnectionType :ivar target: The connection URL to be used for this service. Required. :vartype target: str @@ -3000,7 +2890,7 @@ class Connection(_Model): type: Union[str, "_models.ConnectionType"] = rest_field(visibility=["read"]) """Category of the connection. Required. Known values are: \"AzureOpenAI\", \"AzureBlob\", \"AzureStorageAccount\", \"CognitiveSearch\", \"CosmosDB\", \"ApiKey\", \"AppConfig\", - \"AppInsights\", \"CustomKeys\", and \"RemoteTool\".""" + \"AppInsights\", \"CustomKeys\", and \"RemoteTool_Preview\".""" target: str = rest_field(visibility=["read"]) """The connection URL to be used for this service. Required.""" is_default: bool = rest_field(name="isDefault", visibility=["read"]) @@ -3016,7 +2906,7 @@ class ContainerAppAgentDefinition(AgentDefinition, discriminator="container_app" :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. :vartype rai_config: ~azure.ai.projects.models.RaiConfig - :ivar kind: Required. + :ivar kind: Required. CONTAINER_APP. :vartype kind: str or ~azure.ai.projects.models.CONTAINER_APP :ivar container_protocol_versions: The protocols that the agent supports for ingress communication of the containers. Required. @@ -3031,7 +2921,7 @@ class ContainerAppAgentDefinition(AgentDefinition, discriminator="container_app" """ kind: Literal[AgentKind.CONTAINER_APP] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" + """Required. CONTAINER_APP.""" container_protocol_versions: list["_models.ProtocolVersionRecord"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -3070,7 +2960,7 @@ class ContainerFileCitationBody(Annotation, discriminator="container_file_citati """Container file citation. :ivar type: The type of the container file citation. Always ``container_file_citation``. - Required. + Required. CONTAINER_FILE_CITATION. :vartype type: str or ~azure.ai.projects.models.CONTAINER_FILE_CITATION :ivar container_id: The ID of the container file. Required. :vartype container_id: str @@ -3087,7 +2977,8 @@ class ContainerFileCitationBody(Annotation, discriminator="container_file_citati """ type: Literal[AnnotationType.CONTAINER_FILE_CITATION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the container file citation. Always ``container_file_citation``. Required.""" + """The type of the container file citation. Always ``container_file_citation``. Required. + CONTAINER_FILE_CITATION.""" container_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The ID of the container file. Required.""" file_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -3126,17 +3017,17 @@ class EvaluationRuleAction(_Model): """Evaluation action model. You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ContinuousEvaluationRuleAction, HumanEvaluationRuleAction + ContinuousEvaluationRuleAction, HumanEvaluationPreviewRuleAction :ivar type: Type of the evaluation action. Required. Known values are: "continuousEvaluation" - and "humanEvaluation". + and "humanEvaluationPreview". :vartype type: str or ~azure.ai.projects.models.EvaluationRuleActionType """ __mapping__: dict[str, _Model] = {} type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) """Type of the evaluation action. Required. Known values are: \"continuousEvaluation\" and - \"humanEvaluation\".""" + \"humanEvaluationPreview\".""" @overload def __init__( @@ -3209,7 +3100,7 @@ class CosmosDBIndex(Index, discriminator="CosmosDBNoSqlVectorStore"): :vartype description: str :ivar tags: Tag dictionary. Tags can be added, removed, and updated. :vartype tags: dict[str, str] - :ivar type: Type of index. Required. CosmosDB + :ivar type: Type of index. Required. CosmosDB. :vartype type: str or ~azure.ai.projects.models.COSMOS_DB :ivar connection_name: Name of connection to CosmosDB. Required. :vartype connection_name: str @@ -3224,7 +3115,7 @@ class CosmosDBIndex(Index, discriminator="CosmosDBNoSqlVectorStore"): """ type: Literal[IndexType.COSMOS_DB] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Type of index. Required. CosmosDB""" + """Type of index. Required. CosmosDB.""" connection_name: str = rest_field(name="connectionName", visibility=["create"]) """Name of connection to CosmosDB. Required.""" database_name: str = rest_field(name="databaseName", visibility=["create"]) @@ -3263,39 +3154,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = IndexType.COSMOS_DB # type: ignore -class CreatedBy(_Model): - """CreatedBy. - - :ivar agent: The agent that created the item. - :vartype agent: ~azure.ai.projects.models.AgentId - :ivar response_id: The response on which the item is created. - :vartype response_id: str - """ - - agent: Optional["_models.AgentId"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The agent that created the item.""" - response_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The response on which the item is created.""" - - @overload - def __init__( - self, - *, - agent: Optional["_models.AgentId"] = None, - response_id: 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 Trigger(_Model): """Base model for Trigger of the schedule. @@ -3380,12 +3238,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class CustomCredential(BaseCredentials, discriminator="CustomKeys"): """Custom credential definition. - :ivar type: The credential type. Required. Custom credential + :ivar type: The credential type. Required. Custom credential. :vartype type: str or ~azure.ai.projects.models.CUSTOM """ type: Literal[CredentialType.CUSTOM] = rest_discriminator(name="type", visibility=["read"]) # type: ignore - """The credential type. Required. Custom credential""" + """The credential type. Required. Custom credential.""" @overload def __init__( @@ -3439,7 +3297,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class CustomGrammarFormatParam(CustomToolParamFormat, discriminator="grammar"): """Grammar format. - :ivar type: Grammar format. Always ``grammar``. Required. + :ivar type: Grammar format. Always ``grammar``. Required. GRAMMAR. :vartype type: str or ~azure.ai.projects.models.GRAMMAR :ivar syntax: The syntax of the grammar definition. One of ``lark`` or ``regex``. Required. Known values are: "lark" and "regex". @@ -3449,7 +3307,7 @@ class CustomGrammarFormatParam(CustomToolParamFormat, discriminator="grammar"): """ type: Literal[CustomToolParamFormatType.GRAMMAR] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Grammar format. Always ``grammar``. Required.""" + """Grammar format. Always ``grammar``. Required. GRAMMAR.""" syntax: Union[str, "_models.GrammarSyntax1"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -3481,12 +3339,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class CustomTextFormatParam(CustomToolParamFormat, discriminator="text"): """Text format. - :ivar type: Unconstrained text format. Always ``text``. Required. + :ivar type: Unconstrained text format. Always ``text``. Required. TEXT. :vartype type: str or ~azure.ai.projects.models.TEXT """ type: Literal[CustomToolParamFormatType.TEXT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Unconstrained text format. Always ``text``. Required.""" + """Unconstrained text format. Always ``text``. Required. TEXT.""" @overload def __init__( @@ -3508,7 +3366,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class CustomToolParam(Tool, discriminator="custom"): """Custom tool. - :ivar type: The type of the custom tool. Always ``custom``. Required. + :ivar type: The type of the custom tool. Always ``custom``. Required. CUSTOM. :vartype type: str or ~azure.ai.projects.models.CUSTOM :ivar name: The name of the custom tool, used to identify it in tool calls. Required. :vartype name: str @@ -3519,7 +3377,7 @@ class CustomToolParam(Tool, discriminator="custom"): """ type: Literal[ToolType.CUSTOM] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the custom tool. Always ``custom``. Required.""" + """The type of the custom tool. Always ``custom``. Required. CUSTOM.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the custom tool, used to identify it in tool calls. Required.""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -3725,17 +3583,18 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class DeleteAgentResponse(_Model): """A deleted agent Object. - :ivar object: The object type. Always 'agent.deleted'. Required. Default value is - "agent.deleted". - :vartype object: str + :ivar object: The object type. Always 'agent.deleted'. Required. AGENT_DELETED. + :vartype object: str or ~azure.ai.projects.models.AGENT_DELETED :ivar name: The name of the agent. Required. :vartype name: str :ivar deleted: Whether the agent was successfully deleted. Required. :vartype deleted: bool """ - object: Literal["agent.deleted"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The object type. Always 'agent.deleted'. Required. Default value is \"agent.deleted\".""" + object: Literal[AgentObjectType.AGENT_DELETED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object type. Always 'agent.deleted'. Required. AGENT_DELETED.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the agent. Required.""" deleted: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -3745,6 +3604,7 @@ class DeleteAgentResponse(_Model): def __init__( self, *, + object: Literal[AgentObjectType.AGENT_DELETED], name: str, deleted: bool, ) -> None: ... @@ -3758,15 +3618,13 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.object: Literal["agent.deleted"] = "agent.deleted" class DeleteAgentVersionResponse(_Model): """A deleted agent version Object. - :ivar object: The object type. Always 'agent.deleted'. Required. Default value is - "agent.version.deleted". - :vartype object: str + :ivar object: The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED. + :vartype object: str or ~azure.ai.projects.models.AGENT_VERSION_DELETED :ivar name: The name of the agent. Required. :vartype name: str :ivar version: The version identifier of the agent. Required. @@ -3775,8 +3633,10 @@ class DeleteAgentVersionResponse(_Model): :vartype deleted: bool """ - object: Literal["agent.version.deleted"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The object type. Always 'agent.deleted'. Required. Default value is \"agent.version.deleted\".""" + object: Literal[AgentObjectType.AGENT_VERSION_DELETED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object type. Always 'agent.version.deleted'. Required. AGENT_VERSION_DELETED.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the agent. Required.""" version: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -3788,6 +3648,7 @@ class DeleteAgentVersionResponse(_Model): def __init__( self, *, + object: Literal[AgentObjectType.AGENT_VERSION_DELETED], name: str, version: str, deleted: bool, @@ -3802,24 +3663,23 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.object: Literal["agent.version.deleted"] = "agent.version.deleted" class DeleteMemoryStoreResult(_Model): """DeleteMemoryStoreResult. - :ivar object: The object type. Always 'memory_store.deleted'. Required. Default value is - "memory_store.deleted". - :vartype object: str + :ivar object: The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED. + :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE_DELETED :ivar name: The name of the memory store. Required. :vartype name: str :ivar deleted: Whether the memory store was successfully deleted. Required. :vartype deleted: bool """ - object: Literal["memory_store.deleted"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The object type. Always 'memory_store.deleted'. Required. Default value is - \"memory_store.deleted\".""" + object: Literal[MemoryStoreObjectType.MEMORY_STORE_DELETED] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object type. Always 'memory_store.deleted'. Required. MEMORY_STORE_DELETED.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the memory store. Required.""" deleted: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -3829,6 +3689,7 @@ class DeleteMemoryStoreResult(_Model): def __init__( self, *, + object: Literal[MemoryStoreObjectType.MEMORY_STORE_DELETED], name: str, deleted: bool, ) -> None: ... @@ -3842,7 +3703,6 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.object: Literal["memory_store.deleted"] = "memory_store.deleted" class Deployment(_Model): @@ -3885,7 +3745,7 @@ class DoubleClickAction(ComputerAction, discriminator="double_click"): """DoubleClick. :ivar type: Specifies the event type. For a double click action, this property is always set to - ``double_click``. Required. + ``double_click``. Required. DOUBLE_CLICK. :vartype type: str or ~azure.ai.projects.models.DOUBLE_CLICK :ivar x: The x-coordinate where the double click occurred. Required. :vartype x: int @@ -3895,7 +3755,7 @@ class DoubleClickAction(ComputerAction, discriminator="double_click"): type: Literal[ComputerActionType.DOUBLE_CLICK] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Specifies the event type. For a double click action, this property is always set to - ``double_click``. Required.""" + ``double_click``. Required. DOUBLE_CLICK.""" x: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The x-coordinate where the double click occurred. Required.""" y: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -3924,8 +3784,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Drag(ComputerAction, discriminator="drag"): """Drag. - :ivar type: Specifies the event type. For a drag action, this property is - always set to ``drag``. Required. + :ivar type: Specifies the event type. For a drag action, this property is always set to + ``drag``. Required. DRAG. :vartype type: str or ~azure.ai.projects.models.DRAG :ivar path: An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg @@ -3940,8 +3800,8 @@ class Drag(ComputerAction, discriminator="drag"): """ type: Literal[ComputerActionType.DRAG] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Specifies the event type. For a drag action, this property is - always set to ``drag``. Required.""" + """Specifies the event type. For a drag action, this property is always set to ``drag``. Required. + DRAG.""" path: list["_models.DragPoint"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """An array of coordinates representing the path of the drag action. Coordinates will appear as an array of objects, eg @@ -4006,9 +3866,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputItem(_Model): - """An item representing part of the context for the response to be - generated by the model. Can contain text, images, and audio inputs, - as well as previous assistant responses and tool call outputs. + """An item representing part of the context for the response to be generated by the model. Can + contain text, images, and audio inputs, as well as previous assistant responses and tool call + outputs. You probably want to use the sub-classes and not this class directly. Known sub-classes are: InputItemApplyPatchToolCallItemParam, InputItemApplyPatchToolCallOutputItemParam, @@ -4063,17 +3923,16 @@ class EasyInputMessage(InputItem, discriminator="message"): """Input message. :ivar role: The role of the message input. One of ``user``, ``assistant``, ``system``, or - ``developer``. Required. Is one of the following types: Literal["user"], - Literal["assistant"], Literal["system"], Literal["developer"] + ``developer``. Required. Is one of the following types: Literal["user"], Literal["assistant"], + Literal["system"], Literal["developer"] :vartype role: str or str or str or str - :ivar content: Text, image, or audio input to the model, used to generate a response. - Can also contain previous assistant responses. Required. Is either a str type or a - [InputContent] type. + :ivar content: Text, image, or audio input to the model, used to generate a response. Can also + contain previous assistant responses. Required. Is either a str type or a [InputContent] type. :vartype content: str or list[~azure.ai.projects.models.InputContent] - :ivar type: The type of the message input. Always ``message``. Required. + :ivar type: The type of the message input. Always ``message``. Required. MESSAGE. :vartype type: str or ~azure.ai.projects.models.MESSAGE - :ivar status: The status of item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: + :ivar status: The status of item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] :vartype status: str or str or str """ @@ -4081,23 +3940,22 @@ class EasyInputMessage(InputItem, discriminator="message"): role: Literal["user", "assistant", "system", "developer"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The role of the message input. One of ``user``, ``assistant``, ``system``, or - ``developer``. Required. Is one of the following types: Literal[\"user\"], - Literal[\"assistant\"], Literal[\"system\"], Literal[\"developer\"]""" + """The role of the message input. One of ``user``, ``assistant``, ``system``, or ``developer``. + Required. Is one of the following types: Literal[\"user\"], Literal[\"assistant\"], + Literal[\"system\"], Literal[\"developer\"]""" content: Union[str, list["_models.InputContent"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """Text, image, or audio input to the model, used to generate a response. - Can also contain previous assistant responses. Required. Is either a str type or a - [InputContent] type.""" + """Text, image, or audio input to the model, used to generate a response. Can also contain + previous assistant responses. Required. Is either a str type or a [InputContent] type.""" type: Literal[InputItemType.MESSAGE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the message input. Always ``message``. Required.""" + """The type of the message input. Always ``message``. Required. MESSAGE.""" status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The status of item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + """The status of item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated when + items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" @overload def __init__( @@ -4158,12 +4016,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class EntraIDCredentials(BaseCredentials, discriminator="AAD"): """Entra ID credential definition. - :ivar type: The credential type. Required. Entra ID credential (formerly known as AAD) + :ivar type: The credential type. Required. Entra ID credential (formerly known as AAD). :vartype type: str or ~azure.ai.projects.models.ENTRA_ID """ type: Literal[CredentialType.ENTRA_ID] = rest_discriminator(name="type", visibility=["read"]) # type: ignore - """The credential type. Required. Entra ID credential (formerly known as AAD)""" + """The credential type. Required. Entra ID credential (formerly known as AAD).""" @overload def __init__( @@ -4182,105 +4040,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = CredentialType.ENTRA_ID # type: ignore -class Error(_Model): - """Error. - - :ivar code: Required. - :vartype code: str - :ivar message: Required. - :vartype message: str - :ivar param: Required. - :vartype param: str - :ivar type: Required. - :vartype type: str - :ivar details: - :vartype details: list[~azure.ai.projects.models.Error] - :ivar additional_info: - :vartype additional_info: dict[str, any] - :ivar debug_info: - :vartype debug_info: dict[str, any] - """ - - code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - param: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - type: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - details: Optional[list["_models.Error"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - additional_info: Optional[dict[str, Any]] = rest_field( - name="additionalInfo", visibility=["read", "create", "update", "delete", "query"] - ) - debug_info: Optional[dict[str, Any]] = rest_field( - name="debugInfo", visibility=["read", "create", "update", "delete", "query"] - ) - - @overload - def __init__( - self, - *, - code: str, - message: str, - param: str, - type: str, - details: Optional[list["_models.Error"]] = None, - additional_info: Optional[dict[str, Any]] = None, - debug_info: Optional[dict[str, Any]] = 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 EvalCompareReport(InsightResult, discriminator="EvaluationComparison"): - """Insights from the evaluation comparison. - - :ivar type: The type of insights result. Required. Evaluation Comparison. - :vartype type: str or ~azure.ai.projects.models.EVALUATION_COMPARISON - :ivar comparisons: Comparison results for each treatment run against the baseline. Required. - :vartype comparisons: list[~azure.ai.projects.models.EvalRunResultComparison] - :ivar method: The statistical method used for comparison. Required. - :vartype method: str - """ - - type: Literal[InsightType.EVALUATION_COMPARISON] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of insights result. Required. Evaluation Comparison.""" - comparisons: list["_models.EvalRunResultComparison"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Comparison results for each treatment run against the baseline. Required.""" - method: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The statistical method used for comparison. Required.""" - - @overload - def __init__( - self, - *, - comparisons: list["_models.EvalRunResultComparison"], - method: 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) - self.type = InsightType.EVALUATION_COMPARISON # type: ignore - - class EvalResult(_Model): """Result of the evaluation. @@ -4479,7 +4238,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class EvaluationComparisonRequest(InsightRequest, discriminator="EvaluationComparison"): +class EvaluationComparisonInsightRequest(InsightRequest, discriminator="EvaluationComparison"): """Evaluation Comparison Request. :ivar type: The type of request. Required. Evaluation Comparison. @@ -4524,6 +4283,46 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = InsightType.EVALUATION_COMPARISON # type: ignore +class EvaluationComparisonInsightResult(InsightResult, discriminator="EvaluationComparison"): + """Insights from the evaluation comparison. + + :ivar type: The type of insights result. Required. Evaluation Comparison. + :vartype type: str or ~azure.ai.projects.models.EVALUATION_COMPARISON + :ivar comparisons: Comparison results for each treatment run against the baseline. Required. + :vartype comparisons: list[~azure.ai.projects.models.EvalRunResultComparison] + :ivar method: The statistical method used for comparison. Required. + :vartype method: str + """ + + type: Literal[InsightType.EVALUATION_COMPARISON] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of insights result. Required. Evaluation Comparison.""" + comparisons: list["_models.EvalRunResultComparison"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Comparison results for each treatment run against the baseline. Required.""" + method: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The statistical method used for comparison. Required.""" + + @overload + def __init__( + self, + *, + comparisons: list["_models.EvalRunResultComparison"], + method: 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) + self.type = InsightType.EVALUATION_COMPARISON # type: ignore + + class InsightSample(_Model): """A sample from the analysis. @@ -4714,27 +4513,37 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class EvaluationRunClusterInsightResult(InsightResult, discriminator="EvaluationRunClusterInsight"): - """Insights from the evaluation run cluster analysis. +class EvaluationRunClusterInsightRequest(InsightRequest, discriminator="EvaluationRunClusterInsight"): + """Insights on set of Evaluation Results. - :ivar type: The type of insights result. Required. Insights on an Evaluation run result. + :ivar type: The type of insights request. Required. Insights on an Evaluation run result. :vartype type: str or ~azure.ai.projects.models.EVALUATION_RUN_CLUSTER_INSIGHT - :ivar cluster_insight: Required. - :vartype cluster_insight: ~azure.ai.projects.models.ClusterInsightResult + :ivar eval_id: Evaluation Id for the insights. Required. + :vartype eval_id: str + :ivar run_ids: List of evaluation run IDs for the insights. Required. + :vartype run_ids: list[str] + :ivar model_configuration: Configuration of the model used in the insight generation. + :vartype model_configuration: ~azure.ai.projects.models.InsightModelConfiguration """ type: Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of insights result. Required. Insights on an Evaluation run result.""" - cluster_insight: "_models.ClusterInsightResult" = rest_field( - name="clusterInsight", visibility=["read", "create", "update", "delete", "query"] + """The type of insights request. Required. Insights on an Evaluation run result.""" + eval_id: str = rest_field(name="evalId", visibility=["read", "create", "update", "delete", "query"]) + """Evaluation Id for the insights. Required.""" + run_ids: list[str] = rest_field(name="runIds", visibility=["read", "create", "update", "delete", "query"]) + """List of evaluation run IDs for the insights. Required.""" + model_configuration: Optional["_models.InsightModelConfiguration"] = rest_field( + name="modelConfiguration", visibility=["read", "create", "update", "delete", "query"] ) - """Required.""" + """Configuration of the model used in the insight generation.""" @overload def __init__( self, *, - cluster_insight: "_models.ClusterInsightResult", + eval_id: str, + run_ids: list[str], + model_configuration: Optional["_models.InsightModelConfiguration"] = None, ) -> None: ... @overload @@ -4749,37 +4558,27 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = InsightType.EVALUATION_RUN_CLUSTER_INSIGHT # type: ignore -class EvaluationRunClusterInsightsRequest(InsightRequest, discriminator="EvaluationRunClusterInsight"): - """Insights on set of Evaluation Results. +class EvaluationRunClusterInsightResult(InsightResult, discriminator="EvaluationRunClusterInsight"): + """Insights from the evaluation run cluster analysis. - :ivar type: The type of insights request. Required. Insights on an Evaluation run result. + :ivar type: The type of insights result. Required. Insights on an Evaluation run result. :vartype type: str or ~azure.ai.projects.models.EVALUATION_RUN_CLUSTER_INSIGHT - :ivar eval_id: Evaluation Id for the insights. Required. - :vartype eval_id: str - :ivar run_ids: List of evaluation run IDs for the insights. Required. - :vartype run_ids: list[str] - :ivar model_configuration: Configuration of the model used in the insight generation. - :vartype model_configuration: ~azure.ai.projects.models.InsightModelConfiguration + :ivar cluster_insight: Required. + :vartype cluster_insight: ~azure.ai.projects.models.ClusterInsightResult """ type: Literal[InsightType.EVALUATION_RUN_CLUSTER_INSIGHT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of insights request. Required. Insights on an Evaluation run result.""" - eval_id: str = rest_field(name="evalId", visibility=["read", "create", "update", "delete", "query"]) - """Evaluation Id for the insights. Required.""" - run_ids: list[str] = rest_field(name="runIds", visibility=["read", "create", "update", "delete", "query"]) - """List of evaluation run IDs for the insights. Required.""" - model_configuration: Optional["_models.InsightModelConfiguration"] = rest_field( - name="modelConfiguration", visibility=["read", "create", "update", "delete", "query"] + """The type of insights result. Required. Insights on an Evaluation run result.""" + cluster_insight: "_models.ClusterInsightResult" = rest_field( + name="clusterInsight", visibility=["read", "create", "update", "delete", "query"] ) - """Configuration of the model used in the insight generation.""" + """Required.""" @overload def __init__( self, *, - eval_id: str, - run_ids: list[str], - model_configuration: Optional["_models.InsightModelConfiguration"] = None, + cluster_insight: "_models.ClusterInsightResult", ) -> None: ... @overload @@ -5008,9 +4807,9 @@ class EvaluatorVersion(_Model): :ivar created_by: Creator of the evaluator. Required. :vartype created_by: str :ivar created_at: Creation date/time of the evaluator. Required. - :vartype created_at: int + :vartype created_at: str :ivar modified_at: Last modified date/time of the evaluator. Required. - :vartype modified_at: int + :vartype modified_at: str :ivar id: Asset ID, a unique identifier for the asset. :vartype id: str :ivar name: The name of the resource. Required. @@ -5038,9 +4837,9 @@ class EvaluatorVersion(_Model): """Definition of the evaluator. Required.""" created_by: str = rest_field(visibility=["read"]) """Creator of the evaluator. Required.""" - created_at: int = rest_field(visibility=["read"]) + created_at: str = rest_field(visibility=["read"]) """Creation date/time of the evaluator. Required.""" - modified_at: int = rest_field(visibility=["read"]) + modified_at: str = rest_field(visibility=["read"]) """Last modified date/time of the evaluator. Required.""" id: Optional[str] = rest_field(visibility=["read"]) """Asset ID, a unique identifier for the asset.""" @@ -5081,16 +4880,15 @@ class FabricDataAgentToolParameters(_Model): """The fabric data agent tool parameters. :ivar project_connections: The project connections attached to this tool. There can be a - maximum of 1 connection - resource attached to the tool. + maximum of 1 connection resource attached to the tool. :vartype project_connections: list[~azure.ai.projects.models.ToolProjectConnection] """ project_connections: Optional[list["_models.ToolProjectConnection"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The project connections attached to this tool. There can be a maximum of 1 connection - resource attached to the tool.""" + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" @overload def __init__( @@ -5166,7 +4964,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class FileCitationBody(Annotation, discriminator="file_citation"): """File citation. - :ivar type: The type of the file citation. Always ``file_citation``. Required. + :ivar type: The type of the file citation. Always ``file_citation``. Required. FILE_CITATION. :vartype type: str or ~azure.ai.projects.models.FILE_CITATION :ivar file_id: The ID of the file. Required. :vartype file_id: str @@ -5177,7 +4975,7 @@ class FileCitationBody(Annotation, discriminator="file_citation"): """ type: Literal[AnnotationType.FILE_CITATION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the file citation. Always ``file_citation``. Required.""" + """The type of the file citation. Always ``file_citation``. Required. FILE_CITATION.""" file_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The ID of the file. Required.""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -5261,7 +5059,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class FilePath(Annotation, discriminator="file_path"): """File path. - :ivar type: The type of the file path. Always ``file_path``. Required. + :ivar type: The type of the file path. Always ``file_path``. Required. FILE_PATH. :vartype type: str or ~azure.ai.projects.models.FILE_PATH :ivar file_id: The ID of the file. Required. :vartype file_id: str @@ -5270,7 +5068,7 @@ class FilePath(Annotation, discriminator="file_path"): """ type: Literal[AnnotationType.FILE_PATH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the file path. Always ``file_path``. Required.""" + """The type of the file path. Always ``file_path``. Required. FILE_PATH.""" file_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The ID of the file. Required.""" index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -5299,7 +5097,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class FileSearchTool(Tool, discriminator="file_search"): """File search. - :ivar type: The type of the file search tool. Always ``file_search``. Required. + :ivar type: The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH. :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH :ivar vector_store_ids: The IDs of the vector stores to search. Required. :vartype vector_store_ids: list[str] @@ -5314,7 +5112,7 @@ class FileSearchTool(Tool, discriminator="file_search"): """ type: Literal[ToolType.FILE_SEARCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the file search tool. Always ``file_search``. Required.""" + """The type of the file search tool. Always ``file_search``. Required. FILE_SEARCH.""" vector_store_ids: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The IDs of the vector stores to search. Required.""" max_num_results: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -5323,9 +5121,7 @@ class FileSearchTool(Tool, discriminator="file_search"): visibility=["read", "create", "update", "delete", "query"] ) """Ranking options for search.""" - filters: Optional[Union["_models.ComparisonFilter", "_models.CompoundFilter"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) + filters: Optional["_types.Filters"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Is either a ComparisonFilter type or a CompoundFilter type.""" @overload @@ -5335,7 +5131,7 @@ def __init__( vector_store_ids: list[str], max_num_results: Optional[int] = None, ranking_options: Optional["_models.RankingOptions"] = None, - filters: Optional[Union["_models.ComparisonFilter", "_models.CompoundFilter"]] = None, + filters: Optional["_types.Filters"] = None, ) -> None: ... @overload @@ -5486,7 +5282,7 @@ class FunctionAndCustomToolCallOutputInputFileContent( ): # pylint: disable=name-too-long """Input file. - :ivar type: The type of the input item. Always ``input_file``. Required. + :ivar type: The type of the input item. Always ``input_file``. Required. INPUT_FILE. :vartype type: str or ~azure.ai.projects.models.INPUT_FILE :ivar file_id: :vartype file_id: str @@ -5499,7 +5295,7 @@ class FunctionAndCustomToolCallOutputInputFileContent( """ type: Literal[FunctionAndCustomToolCallOutputType.INPUT_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the input item. Always ``input_file``. Required.""" + """The type of the input item. Always ``input_file``. Required. INPUT_FILE.""" file_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) filename: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the file to be sent to the model.""" @@ -5535,7 +5331,7 @@ class FunctionAndCustomToolCallOutputInputImageContent( ): # pylint: disable=name-too-long """Input image. - :ivar type: The type of the input item. Always ``input_image``. Required. + :ivar type: The type of the input item. Always ``input_image``. Required. INPUT_IMAGE. :vartype type: str or ~azure.ai.projects.models.INPUT_IMAGE :ivar image_url: :vartype image_url: str @@ -5547,7 +5343,7 @@ class FunctionAndCustomToolCallOutputInputImageContent( """ type: Literal[FunctionAndCustomToolCallOutputType.INPUT_IMAGE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the input item. Always ``input_image``. Required.""" + """The type of the input item. Always ``input_image``. Required. INPUT_IMAGE.""" image_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) file_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) detail: Union[str, "_models.ImageDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -5580,14 +5376,14 @@ class FunctionAndCustomToolCallOutputInputTextContent( ): # pylint: disable=name-too-long """Input text. - :ivar type: The type of the input item. Always ``input_text``. Required. + :ivar type: The type of the input item. Always ``input_text``. Required. INPUT_TEXT. :vartype type: str or ~azure.ai.projects.models.INPUT_TEXT :ivar text: The text input to the model. Required. :vartype text: str """ type: Literal[FunctionAndCustomToolCallOutputType.INPUT_TEXT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the input item. Always ``input_text``. Required.""" + """The type of the input item. Always ``input_text``. Required. INPUT_TEXT.""" text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The text input to the model. Required.""" @@ -5610,44 +5406,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = FunctionAndCustomToolCallOutputType.INPUT_TEXT # type: ignore -class FunctionShellAction(_Model): - """Shell exec action. - - :ivar commands: Required. - :vartype commands: list[str] - :ivar timeout_ms: Required. - :vartype timeout_ms: int - :ivar max_output_length: Required. - :vartype max_output_length: int - """ - - commands: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - timeout_ms: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - max_output_length: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - - @overload - def __init__( - self, - *, - commands: list[str], - timeout_ms: int, - max_output_length: int, - ) -> 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 FunctionShellActionParam(_Model): """Shell action. @@ -5684,55 +5442,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FunctionShellCallOutputContent(_Model): - """Shell call output content. - - :ivar stdout: The standard output that was captured. Required. - :vartype stdout: str - :ivar stderr: The standard error output that was captured. Required. - :vartype stderr: str - :ivar outcome: Represents either an exit outcome (with an exit code) or a timeout outcome for a - shell call output chunk. Required. - :vartype outcome: ~azure.ai.projects.models.FunctionShellCallOutputOutcome - :ivar created_by: The identifier of the actor that created the item. - :vartype created_by: str - """ - - stdout: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The standard output that was captured. Required.""" - stderr: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The standard error output that was captured. Required.""" - outcome: "_models.FunctionShellCallOutputOutcome" = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Represents either an exit outcome (with an exit code) or a timeout outcome for a shell call - output chunk. Required.""" - created_by: Optional[str] = rest_field( # pyright: ignore[reportIncompatibleVariableOverride] - visibility=["read", "create", "update", "delete", "query"] - ) - """The identifier of the actor that created the item.""" - - @overload - def __init__( - self, - *, - stdout: str, - stderr: str, - outcome: "_models.FunctionShellCallOutputOutcome", - created_by: 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 FunctionShellCallOutputContentParam(_Model): """Shell output content. @@ -5773,71 +5482,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class FunctionShellCallOutputOutcome(_Model): - """Shell call outcome. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - FunctionShellCallOutputExitOutcome, FunctionShellCallOutputTimeoutOutcome - - :ivar type: Required. Known values are: "timeout" and "exit". - :vartype type: str or ~azure.ai.projects.models.FunctionShellCallOutputOutcomeType - """ - - __mapping__: dict[str, _Model] = {} - type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) - """Required. Known values are: \"timeout\" and \"exit\".""" - - @overload - def __init__( - self, - *, - type: 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 FunctionShellCallOutputExitOutcome(FunctionShellCallOutputOutcome, discriminator="exit"): - """Shell call exit outcome. - - :ivar type: The outcome type. Always ``exit``. Required. - :vartype type: str or ~azure.ai.projects.models.EXIT - :ivar exit_code: Exit code from the shell process. Required. - :vartype exit_code: int - """ - - type: Literal[FunctionShellCallOutputOutcomeType.EXIT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The outcome type. Always ``exit``. Required.""" - exit_code: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Exit code from the shell process. Required.""" - - @overload - def __init__( - self, - *, - exit_code: int, - ) -> 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) - self.type = FunctionShellCallOutputOutcomeType.EXIT # type: ignore - - class FunctionShellCallOutputOutcomeParam(_Model): """Shell call outcome. @@ -5873,14 +5517,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class FunctionShellCallOutputExitOutcomeParam(FunctionShellCallOutputOutcomeParam, discriminator="exit"): """Shell call exit outcome. - :ivar type: The outcome type. Always ``exit``. Required. + :ivar type: The outcome type. Always ``exit``. Required. EXIT. :vartype type: str or ~azure.ai.projects.models.EXIT :ivar exit_code: The exit code returned by the shell process. Required. :vartype exit_code: int """ type: Literal[FunctionShellCallOutputOutcomeParamType.EXIT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The outcome type. Always ``exit``. Required.""" + """The outcome type. Always ``exit``. Required. EXIT.""" exit_code: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The exit code returned by the shell process. Required.""" @@ -5903,44 +5547,17 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = FunctionShellCallOutputOutcomeParamType.EXIT # type: ignore -class FunctionShellCallOutputTimeoutOutcome(FunctionShellCallOutputOutcome, discriminator="timeout"): - """Shell call timeout outcome. - - :ivar type: The outcome type. Always ``timeout``. Required. - :vartype type: str or ~azure.ai.projects.models.TIMEOUT - """ - - type: Literal[FunctionShellCallOutputOutcomeType.TIMEOUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The outcome type. Always ``timeout``. Required.""" - - @overload - def __init__( - self, - ) -> 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) - self.type = FunctionShellCallOutputOutcomeType.TIMEOUT # type: ignore - - class FunctionShellCallOutputTimeoutOutcomeParam( FunctionShellCallOutputOutcomeParam, discriminator="timeout" ): # pylint: disable=name-too-long """Shell call timeout outcome. - :ivar type: The outcome type. Always ``timeout``. Required. + :ivar type: The outcome type. Always ``timeout``. Required. TIMEOUT. :vartype type: str or ~azure.ai.projects.models.TIMEOUT """ type: Literal[FunctionShellCallOutputOutcomeParamType.TIMEOUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The outcome type. Always ``timeout``. Required.""" + """The outcome type. Always ``timeout``. Required. TIMEOUT.""" @overload def __init__( @@ -5962,12 +5579,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class FunctionShellToolParam(Tool, discriminator="shell"): """Shell tool. - :ivar type: The type of the shell tool. Always ``shell``. Required. + :ivar type: The type of the shell tool. Always ``shell``. Required. SHELL. :vartype type: str or ~azure.ai.projects.models.SHELL """ type: Literal[ToolType.SHELL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the shell tool. Always ``shell``. Required.""" + """The type of the shell tool. Always ``shell``. Required. SHELL.""" @overload def __init__( @@ -5989,7 +5606,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class FunctionTool(Tool, discriminator="function"): """Function. - :ivar type: The type of the function tool. Always ``function``. Required. + :ivar type: The type of the function tool. Always ``function``. Required. FUNCTION. :vartype type: str or ~azure.ai.projects.models.FUNCTION :ivar name: The name of the function to call. Required. :vartype name: str @@ -6002,7 +5619,7 @@ class FunctionTool(Tool, discriminator="function"): """ type: Literal[ToolType.FUNCTION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the function tool. Always ``function``. Required.""" + """The type of the function tool. Always ``function``. Required. FUNCTION.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the function to call. Required.""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -6036,16 +5653,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class HostedAgentDefinition(AgentDefinition, discriminator="hosted"): """The hosted agent definition. - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ImageBasedHostedAgentDefinition - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. :vartype rai_config: ~azure.ai.projects.models.RaiConfig - :ivar kind: Required. + :ivar kind: Required. HOSTED. :vartype kind: str or ~azure.ai.projects.models.HOSTED :ivar tools: An array of tools the hosted agent's model may call while generating a response. - You - can specify which tool to use by setting the ``tool_choice`` parameter. + You can specify which tool to use by setting the ``tool_choice`` parameter. :vartype tools: list[~azure.ai.projects.models.Tool] :ivar container_protocol_versions: The protocols that the agent supports for ingress communication of the containers. Required. @@ -6056,14 +5669,15 @@ class HostedAgentDefinition(AgentDefinition, discriminator="hosted"): :vartype memory: str :ivar environment_variables: Environment variables to set in the hosted agent container. :vartype environment_variables: dict[str, str] + :ivar image: The image ID for the agent, applicable to image-based hosted agents. + :vartype image: str """ - __mapping__: dict[str, _Model] = {} kind: Literal[AgentKind.HOSTED] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" + """Required. HOSTED.""" tools: Optional[list["_models.Tool"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """An array of tools the hosted agent's model may call while generating a response. You - can specify which tool to use by setting the ``tool_choice`` parameter.""" + """An array of tools the hosted agent's model may call while generating a response. You can + specify which tool to use by setting the ``tool_choice`` parameter.""" container_protocol_versions: list["_models.ProtocolVersionRecord"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -6076,6 +5690,8 @@ class HostedAgentDefinition(AgentDefinition, discriminator="hosted"): visibility=["read", "create", "update", "delete", "query"] ) """Environment variables to set in the hosted agent container.""" + image: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The image ID for the agent, applicable to image-based hosted agents.""" @overload def __init__( @@ -6087,6 +5703,7 @@ def __init__( rai_config: Optional["_models.RaiConfig"] = None, tools: Optional[list["_models.Tool"]] = None, environment_variables: Optional[dict[str, str]] = None, + image: Optional[str] = None, ) -> None: ... @overload @@ -6128,17 +5745,17 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = RecurrenceType.HOURLY # type: ignore -class HumanEvaluationRuleAction(EvaluationRuleAction, discriminator="humanEvaluation"): +class HumanEvaluationPreviewRuleAction(EvaluationRuleAction, discriminator="humanEvaluationPreview"): """Evaluation rule action for human evaluation. - :ivar type: Required. Human evaluation. - :vartype type: str or ~azure.ai.projects.models.HUMAN_EVALUATION + :ivar type: Required. Human evaluation preview. + :vartype type: str or ~azure.ai.projects.models.HUMAN_EVALUATION_PREVIEW :ivar template_id: Human evaluation template Id. Required. :vartype template_id: str """ - type: Literal[EvaluationRuleActionType.HUMAN_EVALUATION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required. Human evaluation.""" + type: Literal[EvaluationRuleActionType.HUMAN_EVALUATION_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. Human evaluation preview.""" template_id: str = rest_field(name="templateId", visibility=["read", "create", "update", "delete", "query"]) """Human evaluation template Id. Required.""" @@ -6158,80 +5775,29 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = EvaluationRuleActionType.HUMAN_EVALUATION # type: ignore + self.type = EvaluationRuleActionType.HUMAN_EVALUATION_PREVIEW # type: ignore class HybridSearchOptions(_Model): """HybridSearchOptions. :ivar embedding_weight: The weight of the embedding in the reciprocal ranking fusion. Required. - :vartype embedding_weight: float + :vartype embedding_weight: int :ivar text_weight: The weight of the text in the reciprocal ranking fusion. Required. - :vartype text_weight: float + :vartype text_weight: int """ - embedding_weight: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + embedding_weight: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The weight of the embedding in the reciprocal ranking fusion. Required.""" - text_weight: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + text_weight: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The weight of the text in the reciprocal ranking fusion. Required.""" @overload def __init__( self, *, - embedding_weight: float, - text_weight: float, - ) -> 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 ImageBasedHostedAgentDefinition(HostedAgentDefinition, discriminator="hosted"): - """The image-based deployment definition for a hosted agent. - - :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. - :vartype rai_config: ~azure.ai.projects.models.RaiConfig - :ivar tools: An array of tools the hosted agent's model may call while generating a response. - You - can specify which tool to use by setting the ``tool_choice`` parameter. - :vartype tools: list[~azure.ai.projects.models.Tool] - :ivar container_protocol_versions: The protocols that the agent supports for ingress - communication of the containers. Required. - :vartype container_protocol_versions: list[~azure.ai.projects.models.ProtocolVersionRecord] - :ivar cpu: The CPU configuration for the hosted agent. Required. - :vartype cpu: str - :ivar memory: The memory configuration for the hosted agent. Required. - :vartype memory: str - :ivar environment_variables: Environment variables to set in the hosted agent container. - :vartype environment_variables: dict[str, str] - :ivar kind: Required. - :vartype kind: str or ~azure.ai.projects.models.HOSTED - :ivar image: The image for the hosted agent. Required. - :vartype image: str - """ - - image: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The image for the hosted agent. Required.""" - - @overload - def __init__( - self, - *, - container_protocol_versions: list["_models.ProtocolVersionRecord"], - cpu: str, - memory: str, - image: str, - rai_config: Optional["_models.RaiConfig"] = None, - tools: Optional[list["_models.Tool"]] = None, - environment_variables: Optional[dict[str, str]] = None, + embedding_weight: int, + text_weight: int, ) -> None: ... @overload @@ -6249,13 +5815,14 @@ class ImageGenTool(Tool, discriminator="image_generation"): """Image generation tool. :ivar type: The type of the image generation tool. Always ``image_generation``. Required. + IMAGE_GENERATION. :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION :ivar model: Is one of the following types: Literal["gpt-image-1"], Literal["gpt-image-1-mini"], str :vartype model: str or str or str - :ivar quality: The quality of the generated image. One of ``low``, ``medium``, ``high``, - or ``auto``. Default: ``auto``. Is one of the following types: Literal["low"], - Literal["medium"], Literal["high"], Literal["auto"] + :ivar quality: The quality of the generated image. One of ``low``, ``medium``, ``high``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal["low"], Literal["medium"], + Literal["high"], Literal["auto"] :vartype quality: str or str or str or str :ivar size: The size of the generated image. One of ``1024x1024``, ``1024x1536``, ``1536x1024``, or ``auto``. Default: ``auto``. Is one of the following types: @@ -6270,14 +5837,14 @@ class ImageGenTool(Tool, discriminator="image_generation"): :ivar moderation: Moderation level for the generated image. Default: ``auto``. Is either a Literal["auto"] type or a Literal["low"] type. :vartype moderation: str or str - :ivar background: Background type for the generated image. One of ``transparent``, - ``opaque``, or ``auto``. Default: ``auto``. Is one of the following types: - Literal["transparent"], Literal["opaque"], Literal["auto"] + :ivar background: Background type for the generated image. One of ``transparent``, ``opaque``, + or ``auto``. Default: ``auto``. Is one of the following types: Literal["transparent"], + Literal["opaque"], Literal["auto"] :vartype background: str or str or str :ivar input_fidelity: Known values are: "high" and "low". :vartype input_fidelity: str or ~azure.ai.projects.models.InputFidelity - :ivar input_image_mask: Optional mask for inpainting. Contains ``image_url`` - (string, optional) and ``file_id`` (string, optional). + :ivar input_image_mask: Optional mask for inpainting. Contains ``image_url`` (string, optional) + and ``file_id`` (string, optional). :vartype input_image_mask: ~azure.ai.projects.models.ImageGenToolInputImageMask :ivar partial_images: Number of partial images to generate in streaming mode, from 0 (default value) to 3. @@ -6285,7 +5852,7 @@ class ImageGenTool(Tool, discriminator="image_generation"): """ type: Literal[ToolType.IMAGE_GENERATION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the image generation tool. Always ``image_generation``. Required.""" + """The type of the image generation tool. Always ``image_generation``. Required. IMAGE_GENERATION.""" model: Optional[Union[Literal["gpt-image-1"], Literal["gpt-image-1-mini"], str]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -6293,21 +5860,20 @@ class ImageGenTool(Tool, discriminator="image_generation"): quality: Optional[Literal["low", "medium", "high", "auto"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The quality of the generated image. One of ``low``, ``medium``, ``high``, - or ``auto``. Default: ``auto``. Is one of the following types: Literal[\"low\"], - Literal[\"medium\"], Literal[\"high\"], Literal[\"auto\"]""" + """The quality of the generated image. One of ``low``, ``medium``, ``high``, or ``auto``. Default: + ``auto``. Is one of the following types: Literal[\"low\"], Literal[\"medium\"], + Literal[\"high\"], Literal[\"auto\"]""" size: Optional[Literal["1024x1024", "1024x1536", "1536x1024", "auto"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The size of the generated image. One of ``1024x1024``, ``1024x1536``, - ``1536x1024``, or ``auto``. Default: ``auto``. Is one of the following types: - Literal[\"1024x1024\"], Literal[\"1024x1536\"], Literal[\"1536x1024\"], Literal[\"auto\"]""" + """The size of the generated image. One of ``1024x1024``, ``1024x1536``, ``1536x1024``, or + ``auto``. Default: ``auto``. Is one of the following types: Literal[\"1024x1024\"], + Literal[\"1024x1536\"], Literal[\"1536x1024\"], Literal[\"auto\"]""" output_format: Optional[Literal["png", "webp", "jpeg"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The output format of the generated image. One of ``png``, ``webp``, or - ``jpeg``. Default: ``png``. Is one of the following types: Literal[\"png\"], - Literal[\"webp\"], Literal[\"jpeg\"]""" + """The output format of the generated image. One of ``png``, ``webp``, or ``jpeg``. Default: + ``png``. Is one of the following types: Literal[\"png\"], Literal[\"webp\"], Literal[\"jpeg\"]""" output_compression: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Compression level for the output image. Default: 100.""" moderation: Optional[Literal["auto", "low"]] = rest_field( @@ -6318,9 +5884,9 @@ class ImageGenTool(Tool, discriminator="image_generation"): background: Optional[Literal["transparent", "opaque", "auto"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """Background type for the generated image. One of ``transparent``, - ``opaque``, or ``auto``. Default: ``auto``. Is one of the following types: - Literal[\"transparent\"], Literal[\"opaque\"], Literal[\"auto\"]""" + """Background type for the generated image. One of ``transparent``, ``opaque``, or ``auto``. + Default: ``auto``. Is one of the following types: Literal[\"transparent\"], + Literal[\"opaque\"], Literal[\"auto\"]""" input_fidelity: Optional[Union[str, "_models.InputFidelity"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -6328,8 +5894,8 @@ class ImageGenTool(Tool, discriminator="image_generation"): input_image_mask: Optional["_models.ImageGenToolInputImageMask"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """Optional mask for inpainting. Contains ``image_url`` - (string, optional) and ``file_id`` (string, optional).""" + """Optional mask for inpainting. Contains ``image_url`` (string, optional) and ``file_id`` + (string, optional).""" partial_images: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Number of partial images to generate in streaming mode, from 0 (default value) to 3.""" @@ -6427,7 +5993,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputContentInputFileContent(InputContent, discriminator="input_file"): """Input file. - :ivar type: The type of the input item. Always ``input_file``. Required. + :ivar type: The type of the input item. Always ``input_file``. Required. INPUT_FILE. :vartype type: str or ~azure.ai.projects.models.INPUT_FILE :ivar file_id: :vartype file_id: str @@ -6440,7 +6006,7 @@ class InputContentInputFileContent(InputContent, discriminator="input_file"): """ type: Literal[InputContentType.INPUT_FILE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the input item. Always ``input_file``. Required.""" + """The type of the input item. Always ``input_file``. Required. INPUT_FILE.""" file_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) filename: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the file to be sent to the model.""" @@ -6474,7 +6040,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputContentInputImageContent(InputContent, discriminator="input_image"): """Input image. - :ivar type: The type of the input item. Always ``input_image``. Required. + :ivar type: The type of the input item. Always ``input_image``. Required. INPUT_IMAGE. :vartype type: str or ~azure.ai.projects.models.INPUT_IMAGE :ivar image_url: :vartype image_url: str @@ -6486,7 +6052,7 @@ class InputContentInputImageContent(InputContent, discriminator="input_image"): """ type: Literal[InputContentType.INPUT_IMAGE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the input item. Always ``input_image``. Required.""" + """The type of the input item. Always ``input_image``. Required. INPUT_IMAGE.""" image_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) file_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) detail: Union[str, "_models.ImageDetail"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -6517,14 +6083,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputContentInputTextContent(InputContent, discriminator="input_text"): """Input text. - :ivar type: The type of the input item. Always ``input_text``. Required. + :ivar type: The type of the input item. Always ``input_text``. Required. INPUT_TEXT. :vartype type: str or ~azure.ai.projects.models.INPUT_TEXT :ivar text: The text input to the model. Required. :vartype text: str """ type: Literal[InputContentType.INPUT_TEXT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the input item. Always ``input_text``. Required.""" + """The type of the input item. Always ``input_text``. Required. INPUT_TEXT.""" text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The text input to the model. Required.""" @@ -6639,7 +6205,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputItemApplyPatchToolCallItemParam(InputItem, discriminator="apply_patch_call"): """Apply patch tool call. - :ivar type: The type of the item. Always ``apply_patch_call``. Required. + :ivar type: The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL. :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH_CALL :ivar id: :vartype id: str @@ -6654,7 +6220,7 @@ class InputItemApplyPatchToolCallItemParam(InputItem, discriminator="apply_patch """ type: Literal[InputItemType.APPLY_PATCH_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``apply_patch_call``. Required.""" + """The type of the item. Always ``apply_patch_call``. Required. APPLY_PATCH_CALL.""" id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the apply patch tool call generated by the model. Required.""" @@ -6696,6 +6262,7 @@ class InputItemApplyPatchToolCallOutputItemParam( """Apply patch tool call output. :ivar type: The type of the item. Always ``apply_patch_call_output``. Required. + APPLY_PATCH_CALL_OUTPUT. :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH_CALL_OUTPUT :ivar id: :vartype id: str @@ -6709,7 +6276,7 @@ class InputItemApplyPatchToolCallOutputItemParam( """ type: Literal[InputItemType.APPLY_PATCH_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``apply_patch_call_output``. Required.""" + """The type of the item. Always ``apply_patch_call_output``. Required. APPLY_PATCH_CALL_OUTPUT.""" id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the apply patch tool call generated by the model. Required.""" @@ -6746,7 +6313,7 @@ class InputItemCodeInterpreterToolCall(InputItem, discriminator="code_interprete """Code interpreter tool call. :ivar type: The type of the code interpreter tool call. Always ``code_interpreter_call``. - Required. + Required. CODE_INTERPRETER_CALL. :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER_CALL :ivar id: The unique ID of the code interpreter tool call. Required. :vartype id: str @@ -6765,7 +6332,8 @@ class InputItemCodeInterpreterToolCall(InputItem, discriminator="code_interprete """ type: Literal[InputItemType.CODE_INTERPRETER_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the code interpreter tool call. Always ``code_interpreter_call``. Required.""" + """The type of the code interpreter tool call. Always ``code_interpreter_call``. Required. + CODE_INTERPRETER_CALL.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the code interpreter tool call. Required.""" status: Literal["in_progress", "completed", "incomplete", "interpreting", "failed"] = rest_field( @@ -6812,7 +6380,7 @@ class InputItemCompactionSummaryItemParam(InputItem, discriminator="compaction") :ivar id: :vartype id: str - :ivar type: The type of the item. Always ``compaction``. Required. + :ivar type: The type of the item. Always ``compaction``. Required. COMPACTION. :vartype type: str or ~azure.ai.projects.models.COMPACTION :ivar encrypted_content: The encrypted content of the compaction summary. Required. :vartype encrypted_content: str @@ -6820,7 +6388,7 @@ class InputItemCompactionSummaryItemParam(InputItem, discriminator="compaction") id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) type: Literal[InputItemType.COMPACTION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``compaction``. Required.""" + """The type of the item. Always ``compaction``. Required. COMPACTION.""" encrypted_content: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The encrypted content of the compaction summary. Required.""" @@ -6852,7 +6420,7 @@ class InputItemComputerCallOutputItemParam(InputItem, discriminator="computer_ca :ivar call_id: The ID of the computer tool call that produced the output. Required. :vartype call_id: str :ivar type: The type of the computer tool call output. Always ``computer_call_output``. - Required. + Required. COMPUTER_CALL_OUTPUT. :vartype type: str or ~azure.ai.projects.models.COMPUTER_CALL_OUTPUT :ivar output: Required. :vartype output: ~azure.ai.projects.models.ComputerScreenshotImage @@ -6867,7 +6435,8 @@ class InputItemComputerCallOutputItemParam(InputItem, discriminator="computer_ca call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The ID of the computer tool call that produced the output. Required.""" type: Literal[InputItemType.COMPUTER_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the computer tool call output. Always ``computer_call_output``. Required.""" + """The type of the computer tool call output. Always ``computer_call_output``. Required. + COMPUTER_CALL_OUTPUT.""" output: "_models.ComputerScreenshotImage" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" acknowledged_safety_checks: Optional[list["_models.ComputerCallSafetyCheckParam"]] = rest_field( @@ -6904,7 +6473,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputItemComputerToolCall(InputItem, discriminator="computer_call"): """Computer tool call. - :ivar type: The type of the computer call. Always ``computer_call``. Required. + :ivar type: The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL. :vartype type: str or ~azure.ai.projects.models.COMPUTER_CALL :ivar id: The unique ID of the computer call. Required. :vartype id: str @@ -6914,14 +6483,14 @@ class InputItemComputerToolCall(InputItem, discriminator="computer_call"): :vartype action: ~azure.ai.projects.models.ComputerAction :ivar pending_safety_checks: The pending safety checks for the computer call. Required. :vartype pending_safety_checks: list[~azure.ai.projects.models.ComputerCallSafetyCheckParam] - :ivar status: The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Required. Is one of the following - types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Required. Is one of the following types: + Literal["in_progress"], Literal["completed"], Literal["incomplete"] :vartype status: str or str or str """ type: Literal[InputItemType.COMPUTER_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the computer call. Always ``computer_call``. Required.""" + """The type of the computer call. Always ``computer_call``. Required. COMPUTER_CALL.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the computer call. Required.""" call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -6935,9 +6504,9 @@ class InputItemComputerToolCall(InputItem, discriminator="computer_call"): status: Literal["in_progress", "completed", "incomplete"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Required. Is one of the following - types: Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" @overload def __init__( @@ -6966,6 +6535,7 @@ class InputItemCustomToolCall(InputItem, discriminator="custom_tool_call"): """Custom tool call. :ivar type: The type of the custom tool call. Always ``custom_tool_call``. Required. + CUSTOM_TOOL_CALL. :vartype type: str or ~azure.ai.projects.models.CUSTOM_TOOL_CALL :ivar id: The unique ID of the custom tool call in the OpenAI platform. :vartype id: str @@ -6978,7 +6548,7 @@ class InputItemCustomToolCall(InputItem, discriminator="custom_tool_call"): """ type: Literal[InputItemType.CUSTOM_TOOL_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the custom tool call. Always ``custom_tool_call``. Required.""" + """The type of the custom tool call. Always ``custom_tool_call``. Required. CUSTOM_TOOL_CALL.""" id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the custom tool call in the OpenAI platform.""" call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7014,21 +6584,22 @@ class InputItemCustomToolCallOutput(InputItem, discriminator="custom_tool_call_o """Custom tool call output. :ivar type: The type of the custom tool call output. Always ``custom_tool_call_output``. - Required. + Required. CUSTOM_TOOL_CALL_OUTPUT. :vartype type: str or ~azure.ai.projects.models.CUSTOM_TOOL_CALL_OUTPUT :ivar id: The unique ID of the custom tool call output in the OpenAI platform. :vartype id: str :ivar call_id: The call ID, used to map this custom tool call output to a custom tool call. Required. :vartype call_id: str - :ivar output: The output from the custom tool call generated by your code. - Can be a string or an list of output content. Required. Is either a str type or a + :ivar output: The output from the custom tool call generated by your code. Can be a string or + an list of output content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] type. :vartype output: str or list[~azure.ai.projects.models.FunctionAndCustomToolCallOutput] """ type: Literal[InputItemType.CUSTOM_TOOL_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the custom tool call output. Always ``custom_tool_call_output``. Required.""" + """The type of the custom tool call output. Always ``custom_tool_call_output``. Required. + CUSTOM_TOOL_CALL_OUTPUT.""" id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the custom tool call output in the OpenAI platform.""" call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7036,9 +6607,8 @@ class InputItemCustomToolCallOutput(InputItem, discriminator="custom_tool_call_o output: Union[str, list["_models.FunctionAndCustomToolCallOutput"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The output from the custom tool call generated by your code. - Can be a string or an list of output content. Required. Is either a str type or a - [FunctionAndCustomToolCallOutput] type.""" + """The output from the custom tool call generated by your code. Can be a string or an list of + output content. Required. Is either a str type or a [FunctionAndCustomToolCallOutput] type.""" @overload def __init__( @@ -7067,11 +6637,11 @@ class InputItemFileSearchToolCall(InputItem, discriminator="file_search_call"): :ivar id: The unique ID of the file search tool call. Required. :vartype id: str :ivar type: The type of the file search tool call. Always ``file_search_call``. Required. + FILE_SEARCH_CALL. :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH_CALL - :ivar status: The status of the file search tool call. One of ``in_progress``, - ``searching``, ``incomplete`` or ``failed``,. Required. Is one of the following types: - Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["incomplete"], - Literal["failed"] + :ivar status: The status of the file search tool call. One of ``in_progress``, ``searching``, + ``incomplete`` or ``failed``,. Required. Is one of the following types: Literal["in_progress"], + Literal["searching"], Literal["completed"], Literal["incomplete"], Literal["failed"] :vartype status: str or str or str or str or str :ivar queries: The queries used to search for files. Required. :vartype queries: list[str] @@ -7082,14 +6652,13 @@ class InputItemFileSearchToolCall(InputItem, discriminator="file_search_call"): id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the file search tool call. Required.""" type: Literal[InputItemType.FILE_SEARCH_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the file search tool call. Always ``file_search_call``. Required.""" + """The type of the file search tool call. Always ``file_search_call``. Required. FILE_SEARCH_CALL.""" status: Literal["in_progress", "searching", "completed", "incomplete", "failed"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The status of the file search tool call. One of ``in_progress``, - ``searching``, ``incomplete`` or ``failed``,. Required. Is one of the following types: - Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], - Literal[\"incomplete\"], Literal[\"failed\"]""" + """The status of the file search tool call. One of ``in_progress``, ``searching``, ``incomplete`` + or ``failed``,. Required. Is one of the following types: Literal[\"in_progress\"], + Literal[\"searching\"], Literal[\"completed\"], Literal[\"incomplete\"], Literal[\"failed\"]""" queries: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The queries used to search for files. Required.""" results: Optional[list["_models.FileSearchToolCallResults"]] = rest_field( @@ -7126,7 +6695,7 @@ class InputItemFunctionCallOutputItemParam(InputItem, discriminator="function_ca :ivar call_id: The unique ID of the function tool call generated by the model. Required. :vartype call_id: str :ivar type: The type of the function tool call output. Always ``function_call_output``. - Required. + Required. FUNCTION_CALL_OUTPUT. :vartype type: str or ~azure.ai.projects.models.FUNCTION_CALL_OUTPUT :ivar output: Text, image, or file output of the function tool call. Required. Is either a str type or a [Union["_models.InputTextContentParam", "_models.InputImageContentParamAutoParam", @@ -7142,7 +6711,8 @@ class InputItemFunctionCallOutputItemParam(InputItem, discriminator="function_ca call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the function tool call generated by the model. Required.""" type: Literal[InputItemType.FUNCTION_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the function tool call output. Always ``function_call_output``. Required.""" + """The type of the function tool call output. Always ``function_call_output``. Required. + FUNCTION_CALL_OUTPUT.""" output: Union[ str, list[ @@ -7199,7 +6769,7 @@ class InputItemFunctionShellCallItemParam(InputItem, discriminator="shell_call") :vartype id: str :ivar call_id: The unique ID of the shell tool call generated by the model. Required. :vartype call_id: str - :ivar type: The type of the item. Always ``shell_call``. Required. + :ivar type: The type of the item. Always ``shell_call``. Required. SHELL_CALL. :vartype type: str or ~azure.ai.projects.models.SHELL_CALL :ivar action: The shell commands and limits that describe how to run the tool call. Required. :vartype action: ~azure.ai.projects.models.FunctionShellActionParam @@ -7211,7 +6781,7 @@ class InputItemFunctionShellCallItemParam(InputItem, discriminator="shell_call") call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the shell tool call generated by the model. Required.""" type: Literal[InputItemType.SHELL_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``shell_call``. Required.""" + """The type of the item. Always ``shell_call``. Required. SHELL_CALL.""" action: "_models.FunctionShellActionParam" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The shell commands and limits that describe how to run the tool call. Required.""" status: Optional[Union[str, "_models.FunctionShellCallItemStatus"]] = rest_field( @@ -7250,7 +6820,7 @@ class InputItemFunctionShellCallOutputItemParam( :vartype id: str :ivar call_id: The unique ID of the shell tool call generated by the model. Required. :vartype call_id: str - :ivar type: The type of the item. Always ``shell_call_output``. Required. + :ivar type: The type of the item. Always ``shell_call_output``. Required. SHELL_CALL_OUTPUT. :vartype type: str or ~azure.ai.projects.models.SHELL_CALL_OUTPUT :ivar output: Captured chunks of stdout and stderr output, along with their associated outcomes. Required. @@ -7263,7 +6833,7 @@ class InputItemFunctionShellCallOutputItemParam( call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the shell tool call generated by the model. Required.""" type: Literal[InputItemType.SHELL_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``shell_call_output``. Required.""" + """The type of the item. Always ``shell_call_output``. Required. SHELL_CALL_OUTPUT.""" output: list["_models.FunctionShellCallOutputContentParam"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -7298,6 +6868,7 @@ class InputItemFunctionToolCall(InputItem, discriminator="function_call"): :ivar id: The unique ID of the function tool call. :vartype id: str :ivar type: The type of the function tool call. Always ``function_call``. Required. + FUNCTION_CALL. :vartype type: str or ~azure.ai.projects.models.FUNCTION_CALL :ivar call_id: The unique ID of the function tool call generated by the model. Required. :vartype call_id: str @@ -7305,8 +6876,8 @@ class InputItemFunctionToolCall(InputItem, discriminator="function_call"): :vartype name: str :ivar arguments: A JSON string of the arguments to pass to the function. Required. :vartype arguments: str - :ivar status: The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] :vartype status: str or str or str """ @@ -7314,7 +6885,7 @@ class InputItemFunctionToolCall(InputItem, discriminator="function_call"): id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the function tool call.""" type: Literal[InputItemType.FUNCTION_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the function tool call. Always ``function_call``. Required.""" + """The type of the function tool call. Always ``function_call``. Required. FUNCTION_CALL.""" call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the function tool call generated by the model. Required.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7324,9 +6895,9 @@ class InputItemFunctionToolCall(InputItem, discriminator="function_call"): status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" @overload def __init__( @@ -7355,6 +6926,7 @@ class InputItemImageGenToolCall(InputItem, discriminator="image_generation_call" """Image generation call. :ivar type: The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL. :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION_CALL :ivar id: The unique ID of the image generation call. Required. :vartype id: str @@ -7366,7 +6938,8 @@ class InputItemImageGenToolCall(InputItem, discriminator="image_generation_call" """ type: Literal[InputItemType.IMAGE_GENERATION_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the image generation call. Always ``image_generation_call``. Required.""" + """The type of the image generation call. Always ``image_generation_call``. Required. + IMAGE_GENERATION_CALL.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the image generation call. Required.""" status: Literal["in_progress", "completed", "generating", "failed"] = rest_field( @@ -7402,6 +6975,7 @@ class InputItemLocalShellToolCall(InputItem, discriminator="local_shell_call"): """Local shell call. :ivar type: The type of the local shell call. Always ``local_shell_call``. Required. + LOCAL_SHELL_CALL. :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL_CALL :ivar id: The unique ID of the local shell call. Required. :vartype id: str @@ -7415,7 +6989,7 @@ class InputItemLocalShellToolCall(InputItem, discriminator="local_shell_call"): """ type: Literal[InputItemType.LOCAL_SHELL_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the local shell call. Always ``local_shell_call``. Required.""" + """The type of the local shell call. Always ``local_shell_call``. Required. LOCAL_SHELL_CALL.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the local shell call. Required.""" call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7454,7 +7028,7 @@ class InputItemLocalShellToolCallOutput(InputItem, discriminator="local_shell_ca """Local shell call output. :ivar type: The type of the local shell tool call output. Always ``local_shell_call_output``. - Required. + Required. LOCAL_SHELL_CALL_OUTPUT. :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL_CALL_OUTPUT :ivar id: The unique ID of the local shell tool call generated by the model. Required. :vartype id: str @@ -7466,7 +7040,8 @@ class InputItemLocalShellToolCallOutput(InputItem, discriminator="local_shell_ca """ type: Literal[InputItemType.LOCAL_SHELL_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the local shell tool call output. Always ``local_shell_call_output``. Required.""" + """The type of the local shell tool call output. Always ``local_shell_call_output``. Required. + LOCAL_SHELL_CALL_OUTPUT.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the local shell tool call generated by the model. Required.""" output: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7502,6 +7077,7 @@ class InputItemMcpApprovalRequest(InputItem, discriminator="mcp_approval_request """MCP approval request. :ivar type: The type of the item. Always ``mcp_approval_request``. Required. + MCP_APPROVAL_REQUEST. :vartype type: str or ~azure.ai.projects.models.MCP_APPROVAL_REQUEST :ivar id: The unique ID of the approval request. Required. :vartype id: str @@ -7514,7 +7090,7 @@ class InputItemMcpApprovalRequest(InputItem, discriminator="mcp_approval_request """ type: Literal[InputItemType.MCP_APPROVAL_REQUEST] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_approval_request``. Required.""" + """The type of the item. Always ``mcp_approval_request``. Required. MCP_APPROVAL_REQUEST.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the approval request. Required.""" server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7550,6 +7126,7 @@ class InputItemMcpApprovalResponse(InputItem, discriminator="mcp_approval_respon """MCP approval response. :ivar type: The type of the item. Always ``mcp_approval_response``. Required. + MCP_APPROVAL_RESPONSE. :vartype type: str or ~azure.ai.projects.models.MCP_APPROVAL_RESPONSE :ivar id: :vartype id: str @@ -7562,7 +7139,7 @@ class InputItemMcpApprovalResponse(InputItem, discriminator="mcp_approval_respon """ type: Literal[InputItemType.MCP_APPROVAL_RESPONSE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_approval_response``. Required.""" + """The type of the item. Always ``mcp_approval_response``. Required. MCP_APPROVAL_RESPONSE.""" id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) approval_request_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The ID of the approval request being answered. Required.""" @@ -7595,7 +7172,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputItemMcpListTools(InputItem, discriminator="mcp_list_tools"): """MCP list tools. - :ivar type: The type of the item. Always ``mcp_list_tools``. Required. + :ivar type: The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS. :vartype type: str or ~azure.ai.projects.models.MCP_LIST_TOOLS :ivar id: The unique ID of the list. Required. :vartype id: str @@ -7608,7 +7185,7 @@ class InputItemMcpListTools(InputItem, discriminator="mcp_list_tools"): """ type: Literal[InputItemType.MCP_LIST_TOOLS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_list_tools``. Required.""" + """The type of the item. Always ``mcp_list_tools``. Required. MCP_LIST_TOOLS.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the list. Required.""" server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7642,7 +7219,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputItemMcpToolCall(InputItem, discriminator="mcp_call"): """MCP tool call. - :ivar type: The type of the item. Always ``mcp_call``. Required. + :ivar type: The type of the item. Always ``mcp_call``. Required. MCP_CALL. :vartype type: str or ~azure.ai.projects.models.MCP_CALL :ivar id: The unique ID of the tool call. Required. :vartype id: str @@ -7665,7 +7242,7 @@ class InputItemMcpToolCall(InputItem, discriminator="mcp_call"): """ type: Literal[InputItemType.MCP_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_call``. Required.""" + """The type of the item. Always ``mcp_call``. Required. MCP_CALL.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the tool call. Required.""" server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7715,7 +7292,7 @@ class InputItemOutputMessage(InputItem, discriminator="output_message"): :ivar id: The unique ID of the output message. Required. :vartype id: str - :ivar type: The type of the output message. Always ``message``. Required. + :ivar type: The type of the output message. Always ``message``. Required. OUTPUT_MESSAGE. :vartype type: str or ~azure.ai.projects.models.OUTPUT_MESSAGE :ivar role: The role of the output message. Always ``assistant``. Required. Default value is "assistant". @@ -7731,7 +7308,7 @@ class InputItemOutputMessage(InputItem, discriminator="output_message"): id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the output message. Required.""" type: Literal[InputItemType.OUTPUT_MESSAGE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the output message. Always ``message``. Required.""" + """The type of the output message. Always ``message``. Required. OUTPUT_MESSAGE.""" role: Literal["assistant"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The role of the output message. Always ``assistant``. Required. Default value is \"assistant\".""" content: list["_models.OutputMessageContent"] = rest_field( @@ -7741,9 +7318,9 @@ class InputItemOutputMessage(InputItem, discriminator="output_message"): status: Literal["in_progress", "completed", "incomplete"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The status of the message input. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when input items are returned via API. Required. Is one of the - following types: Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + """The status of the message input. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when input items are returned via API. Required. Is one of the following types: + Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" @overload def __init__( @@ -7770,7 +7347,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class InputItemReasoningItem(InputItem, discriminator="reasoning"): """Reasoning. - :ivar type: The type of the object. Always ``reasoning``. Required. + :ivar type: The type of the object. Always ``reasoning``. Required. REASONING. :vartype type: str or ~azure.ai.projects.models.REASONING :ivar id: The unique identifier of the reasoning content. Required. :vartype id: str @@ -7780,14 +7357,14 @@ class InputItemReasoningItem(InputItem, discriminator="reasoning"): :vartype summary: list[~azure.ai.projects.models.Summary] :ivar content: Reasoning text content. :vartype content: list[~azure.ai.projects.models.ReasoningTextContent] - :ivar status: The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: + :ivar status: The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. + Populated when items are returned via API. Is one of the following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] :vartype status: str or str or str """ type: Literal[InputItemType.REASONING] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the object. Always ``reasoning``. Required.""" + """The type of the object. Always ``reasoning``. Required. REASONING.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique identifier of the reasoning content. Required.""" encrypted_content: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -7800,9 +7377,9 @@ class InputItemReasoningItem(InputItem, discriminator="reasoning"): status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + """The status of the item. One of ``in_progress``, ``completed``, or ``incomplete``. Populated + when items are returned via API. Is one of the following types: Literal[\"in_progress\"], + Literal[\"completed\"], Literal[\"incomplete\"]""" @overload def __init__( @@ -7833,13 +7410,14 @@ class InputItemWebSearchToolCall(InputItem, discriminator="web_search_call"): :ivar id: The unique ID of the web search tool call. Required. :vartype id: str :ivar type: The type of the web search tool call. Always ``web_search_call``. Required. + WEB_SEARCH_CALL. :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_CALL :ivar status: The status of the web search tool call. Required. Is one of the following types: Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["failed"] :vartype status: str or str or str or str - :ivar action: An object describing the specific action taken in this web search call. - Includes details on how the model used the web (search, open_page, find). Required. Is one of - the following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind + :ivar action: An object describing the specific action taken in this web search call. Includes + details on how the model used the web (search, open_page, find). Required. Is one of the + following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind :vartype action: ~azure.ai.projects.models.WebSearchActionSearch or ~azure.ai.projects.models.WebSearchActionOpenPage or ~azure.ai.projects.models.WebSearchActionFind @@ -7848,7 +7426,7 @@ class InputItemWebSearchToolCall(InputItem, discriminator="web_search_call"): id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique ID of the web search tool call. Required.""" type: Literal[InputItemType.WEB_SEARCH_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the web search tool call. Always ``web_search_call``. Required.""" + """The type of the web search tool call. Always ``web_search_call``. Required. WEB_SEARCH_CALL.""" status: Literal["in_progress", "searching", "completed", "failed"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -7857,9 +7435,9 @@ class InputItemWebSearchToolCall(InputItem, discriminator="web_search_call"): action: Union["_models.WebSearchActionSearch", "_models.WebSearchActionOpenPage", "_models.WebSearchActionFind"] = ( rest_field(visibility=["read", "create", "update", "delete", "query"]) ) - """An object describing the specific action taken in this web search call. - Includes details on how the model used the web (search, open_page, find). Required. Is one of - the following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind""" + """An object describing the specific action taken in this web search call. Includes details on how + the model used the web (search, open_page, find). Required. Is one of the following types: + WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind""" @overload def __init__( @@ -7884,54 +7462,26 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = InputItemType.WEB_SEARCH_CALL # type: ignore -class ItemResource(_Model): - """Content item used to generate a response. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - ItemResourceApplyPatchToolCall, ItemResourceApplyPatchToolCallOutput, - ItemResourceCodeInterpreterToolCall, ItemResourceComputerToolCall, - ItemResourceComputerToolCallOutputResource, ItemResourceFileSearchToolCall, - ItemResourceFunctionToolCallResource, ItemResourceFunctionToolCallOutputResource, - ItemResourceImageGenToolCall, ItemResourceLocalShellToolCall, - ItemResourceLocalShellToolCallOutput, ItemResourceMcpApprovalRequest, - ItemResourceMcpApprovalResponseResource, ItemResourceMcpToolCall, ItemResourceMcpListTools, - MemorySearchToolCallItemResource, InputMessageResource, OAuthConsentRequestItemResource, - ItemResourceOutputMessage, ItemResourceFunctionShellCall, ItemResourceFunctionShellCallOutput, - StructuredOutputsItemResource, ItemResourceWebSearchToolCall, WorkflowActionOutputItemResource +class InputTextContentParam(_Model): + """Input text. - :ivar type: Required. Known values are: "message", "output_message", "file_search_call", - "computer_call", "computer_call_output", "web_search_call", "function_call", - "function_call_output", "image_generation_call", "code_interpreter_call", "local_shell_call", - "local_shell_call_output", "shell_call", "shell_call_output", "apply_patch_call", - "apply_patch_call_output", "mcp_list_tools", "mcp_approval_request", "mcp_approval_response", - "mcp_call", "structured_outputs", "workflow_action", "memory_search_call", and - "oauth_consent_request". - :vartype type: str or ~azure.ai.projects.models.ItemResourceType - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str + :ivar type: The type of the input item. Always ``input_text``. Required. Default value is + "input_text". + :vartype type: str + :ivar text: The text input to the model. Required. + :vartype text: str """ - __mapping__: dict[str, _Model] = {} - type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) - """Required. Known values are: \"message\", \"output_message\", \"file_search_call\", - \"computer_call\", \"computer_call_output\", \"web_search_call\", \"function_call\", - \"function_call_output\", \"image_generation_call\", \"code_interpreter_call\", - \"local_shell_call\", \"local_shell_call_output\", \"shell_call\", \"shell_call_output\", - \"apply_patch_call\", \"apply_patch_call_output\", \"mcp_list_tools\", - \"mcp_approval_request\", \"mcp_approval_response\", \"mcp_call\", \"structured_outputs\", - \"workflow_action\", \"memory_search_call\", and \"oauth_consent_request\".""" - created_by: Optional[Union["_models.CreatedBy", str]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The information about the creator of the item. Is either a CreatedBy type or a str type.""" + type: Literal["input_text"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the input item. Always ``input_text``. Required. Default value is \"input_text\".""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The text input to the model. Required.""" @overload def __init__( self, *, - type: str, - created_by: Optional[Union["_models.CreatedBy", str]] = None, + text: str, ) -> None: ... @overload @@ -7943,109 +7493,13 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) + self.type: Literal["input_text"] = "input_text" -class InputMessageResource(ItemResource, discriminator="message"): - """InputMessageResource. +class Insight(_Model): + """The response body for cluster insights. - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the message input. Always set to ``message``. Required. - :vartype type: str or ~azure.ai.projects.models.MESSAGE - :ivar role: The role of the message input. One of ``user``, ``system``, or ``developer``. - Required. Is one of the following types: Literal["user"], Literal["system"], - Literal["developer"] - :vartype role: str or str or str - :ivar status: The status of item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal["in_progress"], Literal["completed"], Literal["incomplete"] - :vartype status: str or str or str - :ivar content: Required. - :vartype content: list[~azure.ai.projects.models.InputContent] - :ivar id: The unique ID of the message input. Required. - :vartype id: str - """ - - type: Literal[ItemResourceType.MESSAGE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the message input. Always set to ``message``. Required.""" - role: Literal["user", "system", "developer"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The role of the message input. One of ``user``, ``system``, or ``developer``. Required. Is one - of the following types: Literal[\"user\"], Literal[\"system\"], Literal[\"developer\"]""" - status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" - content: list["_models.InputContent"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the message input. Required.""" - - @overload - def __init__( - self, - *, - role: Literal["user", "system", "developer"], - content: list["_models.InputContent"], - id: str, # pylint: disable=redefined-builtin - created_by: Optional[Union["_models.CreatedBy", str]] = None, - status: Optional[Literal["in_progress", "completed", "incomplete"]] = 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) - self.type = ItemResourceType.MESSAGE # type: ignore - - -class InputTextContentParam(_Model): - """Input text. - - :ivar type: The type of the input item. Always ``input_text``. Required. Default value is - "input_text". - :vartype type: str - :ivar text: The text input to the model. Required. - :vartype text: str - """ - - type: Literal["input_text"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The type of the input item. Always ``input_text``. Required. Default value is \"input_text\".""" - text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The text input to the model. Required.""" - - @overload - def __init__( - self, - *, - text: 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) - self.type: Literal["input_text"] = "input_text" - - -class Insight(_Model): - """The response body for cluster insights. - - :ivar id: The unique identifier for the insights report. Required. + :ivar id: The unique identifier for the insights report. Required. :vartype id: str :ivar metadata: Metadata about the insights report. Required. :vartype metadata: ~azure.ai.projects.models.InsightsMetadata @@ -8295,1141 +7749,20 @@ class InsightSummary(_Model): name="uniqueClusterCount", visibility=["read", "create", "update", "delete", "query"] ) """Total number of unique clusters. Required.""" - method: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Method used for clustering. Required.""" - usage: "_models.ClusterTokenUsage" = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Token usage while performing clustering analysis. Required.""" - - @overload - def __init__( - self, - *, - sample_count: int, - unique_subcluster_count: int, - unique_cluster_count: int, - method: str, - usage: "_models.ClusterTokenUsage", - ) -> 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 ItemReferenceParam(InputItem, discriminator="item_reference"): - """Item reference. - - :ivar type: The type of item to reference. Always ``item_reference``. Required. - :vartype type: str or ~azure.ai.projects.models.ITEM_REFERENCE - :ivar id: The ID of the item to reference. Required. - :vartype id: str - """ - - type: Literal[InputItemType.ITEM_REFERENCE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of item to reference. Always ``item_reference``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The ID of the item to reference. Required.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - ) -> 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) - self.type = InputItemType.ITEM_REFERENCE # type: ignore - - -class ItemResourceApplyPatchToolCall(ItemResource, discriminator="apply_patch_call"): - """Apply patch tool call. - - :ivar type: The type of the item. Always ``apply_patch_call``. Required. - :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH_CALL - :ivar id: The unique ID of the apply patch tool call. Populated when this item is returned via - API. Required. - :vartype id: str - :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. - :vartype call_id: str - :ivar status: The status of the apply patch tool call. One of ``in_progress`` or ``completed``. - Required. Known values are: "in_progress" and "completed". - :vartype status: str or ~azure.ai.projects.models.ApplyPatchCallStatus - :ivar operation: One of the create_file, delete_file, or update_file operations applied via - apply_patch. Required. - :vartype operation: ~azure.ai.projects.models.ApplyPatchFileOperation - :ivar created_by: The ID of the entity that created this tool call. - :vartype created_by: str - """ - - type: Literal[ItemResourceType.APPLY_PATCH_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``apply_patch_call``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the apply patch tool call. Populated when this item is returned via API. - Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the apply patch tool call generated by the model. Required.""" - status: Union[str, "_models.ApplyPatchCallStatus"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the apply patch tool call. One of ``in_progress`` or ``completed``. Required. - Known values are: \"in_progress\" and \"completed\".""" - operation: "_models.ApplyPatchFileOperation" = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """One of the create_file, delete_file, or update_file operations applied via apply_patch. - Required.""" - created_by: Optional[str] = rest_field( # pyright: ignore[reportIncompatibleVariableOverride] - visibility=["read", "create", "update", "delete", "query"] - ) - """The ID of the entity that created this tool call.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - call_id: str, - status: Union[str, "_models.ApplyPatchCallStatus"], - operation: "_models.ApplyPatchFileOperation", - created_by: 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) - self.type = ItemResourceType.APPLY_PATCH_CALL # type: ignore - - -class ItemResourceApplyPatchToolCallOutput(ItemResource, discriminator="apply_patch_call_output"): - """Apply patch tool call output. - - :ivar type: The type of the item. Always ``apply_patch_call_output``. Required. - :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH_CALL_OUTPUT - :ivar id: The unique ID of the apply patch tool call output. Populated when this item is - returned via API. Required. - :vartype id: str - :ivar call_id: The unique ID of the apply patch tool call generated by the model. Required. - :vartype call_id: str - :ivar status: The status of the apply patch tool call output. One of ``completed`` or - ``failed``. Required. Known values are: "completed" and "failed". - :vartype status: str or ~azure.ai.projects.models.ApplyPatchCallOutputStatus - :ivar output: - :vartype output: str - :ivar created_by: The ID of the entity that created this tool call output. - :vartype created_by: str - """ - - type: Literal[ItemResourceType.APPLY_PATCH_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``apply_patch_call_output``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the apply patch tool call output. Populated when this item is returned via - API. Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the apply patch tool call generated by the model. Required.""" - status: Union[str, "_models.ApplyPatchCallOutputStatus"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the apply patch tool call output. One of ``completed`` or ``failed``. Required. - Known values are: \"completed\" and \"failed\".""" - output: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - created_by: Optional[str] = rest_field( # pyright: ignore[reportIncompatibleVariableOverride] - visibility=["read", "create", "update", "delete", "query"] - ) - """The ID of the entity that created this tool call output.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - call_id: str, - status: Union[str, "_models.ApplyPatchCallOutputStatus"], - output: Optional[str] = None, - created_by: 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) - self.type = ItemResourceType.APPLY_PATCH_CALL_OUTPUT # type: ignore - - -class ItemResourceCodeInterpreterToolCall(ItemResource, discriminator="code_interpreter_call"): - """Code interpreter tool call. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the code interpreter tool call. Always ``code_interpreter_call``. - Required. - :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER_CALL - :ivar id: The unique ID of the code interpreter tool call. Required. - :vartype id: str - :ivar status: The status of the code interpreter tool call. Valid values are ``in_progress``, - ``completed``, ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the - following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"], - Literal["interpreting"], Literal["failed"] - :vartype status: str or str or str or str or str - :ivar container_id: The ID of the container used to run the code. Required. - :vartype container_id: str - :ivar code: Required. - :vartype code: str - :ivar outputs: Required. - :vartype outputs: list[~azure.ai.projects.models.CodeInterpreterOutputLogs or - ~azure.ai.projects.models.CodeInterpreterOutputImage] - """ - - type: Literal[ItemResourceType.CODE_INTERPRETER_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the code interpreter tool call. Always ``code_interpreter_call``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the code interpreter tool call. Required.""" - status: Literal["in_progress", "completed", "incomplete", "interpreting", "failed"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the code interpreter tool call. Valid values are ``in_progress``, ``completed``, - ``incomplete``, ``interpreting``, and ``failed``. Required. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"], - Literal[\"interpreting\"], Literal[\"failed\"]""" - container_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The ID of the container used to run the code. Required.""" - code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - outputs: list[Union["_models.CodeInterpreterOutputLogs", "_models.CodeInterpreterOutputImage"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Required.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - status: Literal["in_progress", "completed", "incomplete", "interpreting", "failed"], - container_id: str, - code: str, - outputs: list[Union["_models.CodeInterpreterOutputLogs", "_models.CodeInterpreterOutputImage"]], - created_by: Optional[Union["_models.CreatedBy", 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) - self.type = ItemResourceType.CODE_INTERPRETER_CALL # type: ignore - - -class ItemResourceComputerToolCall(ItemResource, discriminator="computer_call"): - """Computer tool call. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the computer call. Always ``computer_call``. Required. - :vartype type: str or ~azure.ai.projects.models.COMPUTER_CALL - :ivar id: The unique ID of the computer call. Required. - :vartype id: str - :ivar call_id: An identifier used when responding to the tool call with output. Required. - :vartype call_id: str - :ivar action: Required. - :vartype action: ~azure.ai.projects.models.ComputerAction - :ivar pending_safety_checks: The pending safety checks for the computer call. Required. - :vartype pending_safety_checks: list[~azure.ai.projects.models.ComputerCallSafetyCheckParam] - :ivar status: The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Required. Is one of the following - types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] - :vartype status: str or str or str - """ - - type: Literal[ItemResourceType.COMPUTER_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the computer call. Always ``computer_call``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the computer call. Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """An identifier used when responding to the tool call with output. Required.""" - action: "_models.ComputerAction" = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - pending_safety_checks: list["_models.ComputerCallSafetyCheckParam"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The pending safety checks for the computer call. Required.""" - status: Literal["in_progress", "completed", "incomplete"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Required. Is one of the following - types: Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - call_id: str, - action: "_models.ComputerAction", - pending_safety_checks: list["_models.ComputerCallSafetyCheckParam"], - status: Literal["in_progress", "completed", "incomplete"], - created_by: Optional[Union["_models.CreatedBy", 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) - self.type = ItemResourceType.COMPUTER_CALL # type: ignore - - -class ItemResourceComputerToolCallOutputResource( - ItemResource, discriminator="computer_call_output" -): # pylint: disable=name-too-long - """ItemResourceComputerToolCallOutputResource. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the computer tool call output. Always ``computer_call_output``. - Required. - :vartype type: str or ~azure.ai.projects.models.COMPUTER_CALL_OUTPUT - :ivar id: The ID of the computer tool call output. - :vartype id: str - :ivar call_id: The ID of the computer tool call that produced the output. Required. - :vartype call_id: str - :ivar acknowledged_safety_checks: The safety checks reported by the API that have been - acknowledged by the developer. - :vartype acknowledged_safety_checks: - list[~azure.ai.projects.models.ComputerCallSafetyCheckParam] - :ivar output: Required. - :vartype output: ~azure.ai.projects.models.ComputerScreenshotImage - :ivar status: The status of the message input. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when input items are returned via API. Is one of the following - types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] - :vartype status: str or str or str - """ - - type: Literal[ItemResourceType.COMPUTER_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the computer tool call output. Always ``computer_call_output``. Required.""" - id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The ID of the computer tool call output.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The ID of the computer tool call that produced the output. Required.""" - acknowledged_safety_checks: Optional[list["_models.ComputerCallSafetyCheckParam"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The safety checks reported by the API that have been acknowledged by the - developer.""" - output: "_models.ComputerScreenshotImage" = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the message input. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when input items are returned via API. Is one of the following - types: Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" - - @overload - def __init__( - self, - *, - call_id: str, - output: "_models.ComputerScreenshotImage", - created_by: Optional[Union["_models.CreatedBy", str]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - acknowledged_safety_checks: Optional[list["_models.ComputerCallSafetyCheckParam"]] = None, - status: Optional[Literal["in_progress", "completed", "incomplete"]] = 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) - self.type = ItemResourceType.COMPUTER_CALL_OUTPUT # type: ignore - - -class ItemResourceFileSearchToolCall(ItemResource, discriminator="file_search_call"): - """File search tool call. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar id: The unique ID of the file search tool call. Required. - :vartype id: str - :ivar type: The type of the file search tool call. Always ``file_search_call``. Required. - :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH_CALL - :ivar status: The status of the file search tool call. One of ``in_progress``, - ``searching``, ``incomplete`` or ``failed``,. Required. Is one of the following types: - Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["incomplete"], - Literal["failed"] - :vartype status: str or str or str or str or str - :ivar queries: The queries used to search for files. Required. - :vartype queries: list[str] - :ivar results: - :vartype results: list[~azure.ai.projects.models.FileSearchToolCallResults] - """ - - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the file search tool call. Required.""" - type: Literal[ItemResourceType.FILE_SEARCH_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the file search tool call. Always ``file_search_call``. Required.""" - status: Literal["in_progress", "searching", "completed", "incomplete", "failed"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the file search tool call. One of ``in_progress``, - ``searching``, ``incomplete`` or ``failed``,. Required. Is one of the following types: - Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], - Literal[\"incomplete\"], Literal[\"failed\"]""" - queries: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The queries used to search for files. Required.""" - results: Optional[list["_models.FileSearchToolCallResults"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - status: Literal["in_progress", "searching", "completed", "incomplete", "failed"], - queries: list[str], - created_by: Optional[Union["_models.CreatedBy", str]] = None, - results: Optional[list["_models.FileSearchToolCallResults"]] = 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) - self.type = ItemResourceType.FILE_SEARCH_CALL # type: ignore - - -class ItemResourceFunctionShellCall(ItemResource, discriminator="shell_call"): - """Shell tool call. - - :ivar type: The type of the item. Always ``shell_call``. Required. - :vartype type: str or ~azure.ai.projects.models.SHELL_CALL - :ivar id: The unique ID of the shell tool call. Populated when this item is returned via API. - Required. - :vartype id: str - :ivar call_id: The unique ID of the shell tool call generated by the model. Required. - :vartype call_id: str - :ivar action: The shell commands and limits that describe how to run the tool call. Required. - :vartype action: ~azure.ai.projects.models.FunctionShellAction - :ivar status: The status of the shell call. One of ``in_progress``, ``completed``, or - ``incomplete``. Required. Known values are: "in_progress", "completed", and "incomplete". - :vartype status: str or ~azure.ai.projects.models.LocalShellCallStatus - :ivar created_by: The ID of the entity that created this tool call. - :vartype created_by: str - """ - - type: Literal[ItemResourceType.SHELL_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``shell_call``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the shell tool call. Populated when this item is returned via API. Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the shell tool call generated by the model. Required.""" - action: "_models.FunctionShellAction" = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The shell commands and limits that describe how to run the tool call. Required.""" - status: Union[str, "_models.LocalShellCallStatus"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the shell call. One of ``in_progress``, ``completed``, or ``incomplete``. - Required. Known values are: \"in_progress\", \"completed\", and \"incomplete\".""" - created_by: Optional[str] = rest_field( # pyright: ignore[reportIncompatibleVariableOverride] - visibility=["read", "create", "update", "delete", "query"] - ) - """The ID of the entity that created this tool call.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - call_id: str, - action: "_models.FunctionShellAction", - status: Union[str, "_models.LocalShellCallStatus"], - created_by: 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) - self.type = ItemResourceType.SHELL_CALL # type: ignore - - -class ItemResourceFunctionShellCallOutput(ItemResource, discriminator="shell_call_output"): - """Shell call output. - - :ivar type: The type of the shell call output. Always ``shell_call_output``. Required. - :vartype type: str or ~azure.ai.projects.models.SHELL_CALL_OUTPUT - :ivar id: The unique ID of the shell call output. Populated when this item is returned via API. - Required. - :vartype id: str - :ivar call_id: The unique ID of the shell tool call generated by the model. Required. - :vartype call_id: str - :ivar output: An array of shell call output contents. Required. - :vartype output: list[~azure.ai.projects.models.FunctionShellCallOutputContent] - :ivar max_output_length: Required. - :vartype max_output_length: int - :ivar created_by: The identifier of the actor that created the item. - :vartype created_by: str - """ - - type: Literal[ItemResourceType.SHELL_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the shell call output. Always ``shell_call_output``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the shell call output. Populated when this item is returned via API. Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the shell tool call generated by the model. Required.""" - output: list["_models.FunctionShellCallOutputContent"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """An array of shell call output contents. Required.""" - max_output_length: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - created_by: Optional[str] = rest_field( # pyright: ignore[reportIncompatibleVariableOverride] - visibility=["read", "create", "update", "delete", "query"] - ) - """The identifier of the actor that created the item.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - call_id: str, - output: list["_models.FunctionShellCallOutputContent"], - max_output_length: int, - created_by: 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) - self.type = ItemResourceType.SHELL_CALL_OUTPUT # type: ignore - - -class ItemResourceFunctionToolCallOutputResource( - ItemResource, discriminator="function_call_output" -): # pylint: disable=name-too-long - """ItemResourceFunctionToolCallOutputResource. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar id: The unique ID of the function tool call output. Populated when this item - is returned via API. - :vartype id: str - :ivar type: The type of the function tool call output. Always ``function_call_output``. - Required. - :vartype type: str or ~azure.ai.projects.models.FUNCTION_CALL_OUTPUT - :ivar call_id: The unique ID of the function tool call generated by the model. Required. - :vartype call_id: str - :ivar output: The output from the function call generated by your code. - Can be a string or an list of output content. Required. Is either a str type or a - [FunctionAndCustomToolCallOutput] type. - :vartype output: str or list[~azure.ai.projects.models.FunctionAndCustomToolCallOutput] - :ivar status: The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal["in_progress"], Literal["completed"], Literal["incomplete"] - :vartype status: str or str or str - """ - - id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the function tool call output. Populated when this item - is returned via API.""" - type: Literal[ItemResourceType.FUNCTION_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the function tool call output. Always ``function_call_output``. Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the function tool call generated by the model. Required.""" - output: Union[str, list["_models.FunctionAndCustomToolCallOutput"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The output from the function call generated by your code. - Can be a string or an list of output content. Required. Is either a str type or a - [FunctionAndCustomToolCallOutput] type.""" - status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" - - @overload - def __init__( - self, - *, - call_id: str, - output: Union[str, list["_models.FunctionAndCustomToolCallOutput"]], - created_by: Optional[Union["_models.CreatedBy", str]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - status: Optional[Literal["in_progress", "completed", "incomplete"]] = 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) - self.type = ItemResourceType.FUNCTION_CALL_OUTPUT # type: ignore - - -class ItemResourceFunctionToolCallResource(ItemResource, discriminator="function_call"): - """ItemResourceFunctionToolCallResource. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar id: The unique ID of the function tool call. - :vartype id: str - :ivar type: The type of the function tool call. Always ``function_call``. Required. - :vartype type: str or ~azure.ai.projects.models.FUNCTION_CALL - :ivar call_id: The unique ID of the function tool call generated by the model. Required. - :vartype call_id: str - :ivar name: The name of the function to run. Required. - :vartype name: str - :ivar arguments: A JSON string of the arguments to pass to the function. Required. - :vartype arguments: str - :ivar status: The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal["in_progress"], Literal["completed"], Literal["incomplete"] - :vartype status: str or str or str - """ - - id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the function tool call.""" - type: Literal[ItemResourceType.FUNCTION_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the function tool call. Always ``function_call``. Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the function tool call generated by the model. Required.""" - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name of the function to run. Required.""" - arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """A JSON string of the arguments to pass to the function. Required.""" - status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the item. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when items are returned via API. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" - - @overload - def __init__( - self, - *, - call_id: str, - name: str, - arguments: str, - created_by: Optional[Union["_models.CreatedBy", str]] = None, - id: Optional[str] = None, # pylint: disable=redefined-builtin - status: Optional[Literal["in_progress", "completed", "incomplete"]] = 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) - self.type = ItemResourceType.FUNCTION_CALL # type: ignore - - -class ItemResourceImageGenToolCall(ItemResource, discriminator="image_generation_call"): - """Image generation call. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the image generation call. Always ``image_generation_call``. Required. - :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION_CALL - :ivar id: The unique ID of the image generation call. Required. - :vartype id: str - :ivar status: The status of the image generation call. Required. Is one of the following types: - Literal["in_progress"], Literal["completed"], Literal["generating"], Literal["failed"] - :vartype status: str or str or str or str - :ivar result: Required. - :vartype result: str - """ - - type: Literal[ItemResourceType.IMAGE_GENERATION_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the image generation call. Always ``image_generation_call``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the image generation call. Required.""" - status: Literal["in_progress", "completed", "generating", "failed"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the image generation call. Required. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"generating\"], Literal[\"failed\"]""" - result: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - status: Literal["in_progress", "completed", "generating", "failed"], - result: str, - created_by: Optional[Union["_models.CreatedBy", 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) - self.type = ItemResourceType.IMAGE_GENERATION_CALL # type: ignore - - -class ItemResourceLocalShellToolCall(ItemResource, discriminator="local_shell_call"): - """Local shell call. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the local shell call. Always ``local_shell_call``. Required. - :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL_CALL - :ivar id: The unique ID of the local shell call. Required. - :vartype id: str - :ivar call_id: The unique ID of the local shell tool call generated by the model. Required. - :vartype call_id: str - :ivar action: Required. - :vartype action: ~azure.ai.projects.models.LocalShellExecAction - :ivar status: The status of the local shell call. Required. Is one of the following types: - Literal["in_progress"], Literal["completed"], Literal["incomplete"] - :vartype status: str or str or str - """ - - type: Literal[ItemResourceType.LOCAL_SHELL_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the local shell call. Always ``local_shell_call``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the local shell call. Required.""" - call_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the local shell tool call generated by the model. Required.""" - action: "_models.LocalShellExecAction" = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - status: Literal["in_progress", "completed", "incomplete"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the local shell call. Required. Is one of the following types: - Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - call_id: str, - action: "_models.LocalShellExecAction", - status: Literal["in_progress", "completed", "incomplete"], - created_by: Optional[Union["_models.CreatedBy", 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) - self.type = ItemResourceType.LOCAL_SHELL_CALL # type: ignore - - -class ItemResourceLocalShellToolCallOutput(ItemResource, discriminator="local_shell_call_output"): - """Local shell call output. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the local shell tool call output. Always ``local_shell_call_output``. - Required. - :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL_CALL_OUTPUT - :ivar id: The unique ID of the local shell tool call generated by the model. Required. - :vartype id: str - :ivar output: A JSON string of the output of the local shell tool call. Required. - :vartype output: str - :ivar status: Is one of the following types: Literal["in_progress"], Literal["completed"], - Literal["incomplete"] - :vartype status: str or str or str - """ - - type: Literal[ItemResourceType.LOCAL_SHELL_CALL_OUTPUT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the local shell tool call output. Always ``local_shell_call_output``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the local shell tool call generated by the model. Required.""" - output: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """A JSON string of the output of the local shell tool call. Required.""" - status: Optional[Literal["in_progress", "completed", "incomplete"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Is one of the following types: Literal[\"in_progress\"], Literal[\"completed\"], - Literal[\"incomplete\"]""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - output: str, - created_by: Optional[Union["_models.CreatedBy", str]] = None, - status: Optional[Literal["in_progress", "completed", "incomplete"]] = 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) - self.type = ItemResourceType.LOCAL_SHELL_CALL_OUTPUT # type: ignore - - -class ItemResourceMcpApprovalRequest(ItemResource, discriminator="mcp_approval_request"): - """MCP approval request. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the item. Always ``mcp_approval_request``. Required. - :vartype type: str or ~azure.ai.projects.models.MCP_APPROVAL_REQUEST - :ivar id: The unique ID of the approval request. Required. - :vartype id: str - :ivar server_label: The label of the MCP server making the request. Required. - :vartype server_label: str - :ivar name: The name of the tool to run. Required. - :vartype name: str - :ivar arguments: A JSON string of arguments for the tool. Required. - :vartype arguments: str - """ - - type: Literal[ItemResourceType.MCP_APPROVAL_REQUEST] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_approval_request``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the approval request. Required.""" - server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The label of the MCP server making the request. Required.""" - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name of the tool to run. Required.""" - arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """A JSON string of arguments for the tool. Required.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - server_label: str, - name: str, - arguments: str, - created_by: Optional[Union["_models.CreatedBy", 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) - self.type = ItemResourceType.MCP_APPROVAL_REQUEST # type: ignore - - -class ItemResourceMcpApprovalResponseResource(ItemResource, discriminator="mcp_approval_response"): - """MCP approval response. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the item. Always ``mcp_approval_response``. Required. - :vartype type: str or ~azure.ai.projects.models.MCP_APPROVAL_RESPONSE - :ivar id: The unique ID of the approval response. Required. - :vartype id: str - :ivar approval_request_id: The ID of the approval request being answered. Required. - :vartype approval_request_id: str - :ivar approve: Whether the request was approved. Required. - :vartype approve: bool - :ivar reason: - :vartype reason: str - """ - - type: Literal[ItemResourceType.MCP_APPROVAL_RESPONSE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_approval_response``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the approval response. Required.""" - approval_request_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The ID of the approval request being answered. Required.""" - approve: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Whether the request was approved. Required.""" - reason: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - approval_request_id: str, - approve: bool, - created_by: Optional[Union["_models.CreatedBy", str]] = None, - reason: 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) - self.type = ItemResourceType.MCP_APPROVAL_RESPONSE # type: ignore - - -class ItemResourceMcpListTools(ItemResource, discriminator="mcp_list_tools"): - """MCP list tools. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the item. Always ``mcp_list_tools``. Required. - :vartype type: str or ~azure.ai.projects.models.MCP_LIST_TOOLS - :ivar id: The unique ID of the list. Required. - :vartype id: str - :ivar server_label: The label of the MCP server. Required. - :vartype server_label: str - :ivar tools: The tools available on the server. Required. - :vartype tools: list[~azure.ai.projects.models.MCPListToolsTool] - :ivar error: - :vartype error: str - """ - - type: Literal[ItemResourceType.MCP_LIST_TOOLS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_list_tools``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the list. Required.""" - server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The label of the MCP server. Required.""" - tools: list["_models.MCPListToolsTool"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The tools available on the server. Required.""" - error: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - server_label: str, - tools: list["_models.MCPListToolsTool"], - created_by: Optional[Union["_models.CreatedBy", str]] = None, - error: 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) - self.type = ItemResourceType.MCP_LIST_TOOLS # type: ignore - - -class ItemResourceMcpToolCall(ItemResource, discriminator="mcp_call"): - """MCP tool call. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: The type of the item. Always ``mcp_call``. Required. - :vartype type: str or ~azure.ai.projects.models.MCP_CALL - :ivar id: The unique ID of the tool call. Required. - :vartype id: str - :ivar server_label: The label of the MCP server running the tool. Required. - :vartype server_label: str - :ivar name: The name of the tool that was run. Required. - :vartype name: str - :ivar arguments: A JSON string of the arguments passed to the tool. Required. - :vartype arguments: str - :ivar output: - :vartype output: str - :ivar error: - :vartype error: str - :ivar status: The status of the tool call. One of ``in_progress``, ``completed``, - ``incomplete``, ``calling``, or ``failed``. Known values are: "in_progress", "completed", - "incomplete", "calling", and "failed". - :vartype status: str or ~azure.ai.projects.models.MCPToolCallStatus - :ivar approval_request_id: - :vartype approval_request_id: str - """ - - type: Literal[ItemResourceType.MCP_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the item. Always ``mcp_call``. Required.""" - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the tool call. Required.""" - server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The label of the MCP server running the tool. Required.""" - name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name of the tool that was run. Required.""" - arguments: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """A JSON string of the arguments passed to the tool. Required.""" - output: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - error: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - status: Optional[Union[str, "_models.MCPToolCallStatus"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the tool call. One of ``in_progress``, ``completed``, ``incomplete``, - ``calling``, or ``failed``. Known values are: \"in_progress\", \"completed\", \"incomplete\", - \"calling\", and \"failed\".""" - approval_request_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - server_label: str, - name: str, - arguments: str, - created_by: Optional[Union["_models.CreatedBy", str]] = None, - output: Optional[str] = None, - error: Optional[str] = None, - status: Optional[Union[str, "_models.MCPToolCallStatus"]] = None, - approval_request_id: 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) - self.type = ItemResourceType.MCP_CALL # type: ignore - - -class ItemResourceOutputMessage(ItemResource, discriminator="output_message"): - """Output message. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar id: The unique ID of the output message. Required. - :vartype id: str - :ivar type: The type of the output message. Always ``message``. Required. - :vartype type: str or ~azure.ai.projects.models.OUTPUT_MESSAGE - :ivar role: The role of the output message. Always ``assistant``. Required. Default value is - "assistant". - :vartype role: str - :ivar content: The content of the output message. Required. - :vartype content: list[~azure.ai.projects.models.OutputMessageContent] - :ivar status: The status of the message input. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when input items are returned via API. Required. Is one of the - following types: Literal["in_progress"], Literal["completed"], Literal["incomplete"] - :vartype status: str or str or str - """ - - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the output message. Required.""" - type: Literal[ItemResourceType.OUTPUT_MESSAGE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the output message. Always ``message``. Required.""" - role: Literal["assistant"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The role of the output message. Always ``assistant``. Required. Default value is \"assistant\".""" - content: list["_models.OutputMessageContent"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The content of the output message. Required.""" - status: Literal["in_progress", "completed", "incomplete"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the message input. One of ``in_progress``, ``completed``, or - ``incomplete``. Populated when input items are returned via API. Required. Is one of the - following types: Literal[\"in_progress\"], Literal[\"completed\"], Literal[\"incomplete\"]""" + method: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Method used for clustering. Required.""" + usage: "_models.ClusterTokenUsage" = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Token usage while performing clustering analysis. Required.""" @overload def __init__( self, *, - id: str, # pylint: disable=redefined-builtin - content: list["_models.OutputMessageContent"], - status: Literal["in_progress", "completed", "incomplete"], - created_by: Optional[Union["_models.CreatedBy", str]] = None, + sample_count: int, + unique_subcluster_count: int, + unique_cluster_count: int, + method: str, + usage: "_models.ClusterTokenUsage", ) -> None: ... @overload @@ -9441,57 +7774,27 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = ItemResourceType.OUTPUT_MESSAGE # type: ignore - self.role: Literal["assistant"] = "assistant" -class ItemResourceWebSearchToolCall(ItemResource, discriminator="web_search_call"): - """Web search tool call. +class ItemReferenceParam(InputItem, discriminator="item_reference"): + """Item reference. - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar id: The unique ID of the web search tool call. Required. + :ivar type: The type of item to reference. Always ``item_reference``. Required. ITEM_REFERENCE. + :vartype type: str or ~azure.ai.projects.models.ITEM_REFERENCE + :ivar id: The ID of the item to reference. Required. :vartype id: str - :ivar type: The type of the web search tool call. Always ``web_search_call``. Required. - :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_CALL - :ivar status: The status of the web search tool call. Required. Is one of the following types: - Literal["in_progress"], Literal["searching"], Literal["completed"], Literal["failed"] - :vartype status: str or str or str or str - :ivar action: An object describing the specific action taken in this web search call. - Includes details on how the model used the web (search, open_page, find). Required. Is one of - the following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind - :vartype action: ~azure.ai.projects.models.WebSearchActionSearch or - ~azure.ai.projects.models.WebSearchActionOpenPage or - ~azure.ai.projects.models.WebSearchActionFind """ + type: Literal[InputItemType.ITEM_REFERENCE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of item to reference. Always ``item_reference``. Required. ITEM_REFERENCE.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The unique ID of the web search tool call. Required.""" - type: Literal[ItemResourceType.WEB_SEARCH_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the web search tool call. Always ``web_search_call``. Required.""" - status: Literal["in_progress", "searching", "completed", "failed"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the web search tool call. Required. Is one of the following types: - Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], Literal[\"failed\"]""" - action: Union["_models.WebSearchActionSearch", "_models.WebSearchActionOpenPage", "_models.WebSearchActionFind"] = ( - rest_field(visibility=["read", "create", "update", "delete", "query"]) - ) - """An object describing the specific action taken in this web search call. - Includes details on how the model used the web (search, open_page, find). Required. Is one of - the following types: WebSearchActionSearch, WebSearchActionOpenPage, WebSearchActionFind""" + """The ID of the item to reference. Required.""" @overload def __init__( self, *, id: str, # pylint: disable=redefined-builtin - status: Literal["in_progress", "searching", "completed", "failed"], - action: Union[ - "_models.WebSearchActionSearch", "_models.WebSearchActionOpenPage", "_models.WebSearchActionFind" - ], - created_by: Optional[Union["_models.CreatedBy", str]] = None, ) -> None: ... @overload @@ -9503,14 +7806,14 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = ItemResourceType.WEB_SEARCH_CALL # type: ignore + self.type = InputItemType.ITEM_REFERENCE # type: ignore class KeyPressAction(ComputerAction, discriminator="keypress"): """KeyPress. :ivar type: Specifies the event type. For a keypress action, this property is always set to - ``keypress``. Required. + ``keypress``. Required. KEYPRESS. :vartype type: str or ~azure.ai.projects.models.KEYPRESS :ivar keys_property: The combination of keys the model is requesting to be pressed. This is an array of strings, each representing a key. Required. @@ -9519,7 +7822,7 @@ class KeyPressAction(ComputerAction, discriminator="keypress"): type: Literal[ComputerActionType.KEYPRESS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """Specifies the event type. For a keypress action, this property is always set to ``keypress``. - Required.""" + Required. KEYPRESS.""" keys_property: list[str] = rest_field( name="keys", visibility=["read", "create", "update", "delete", "query"], original_tsp_name="keys" ) @@ -9599,12 +7902,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class LocalShellToolParam(Tool, discriminator="local_shell"): """Local shell tool. - :ivar type: The type of the local shell tool. Always ``local_shell``. Required. + :ivar type: The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL. :vartype type: str or ~azure.ai.projects.models.LOCAL_SHELL """ type: Literal[ToolType.LOCAL_SHELL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the local shell tool. Always ``local_shell``. Required.""" + """The type of the local shell tool. Always ``local_shell``. Required. LOCAL_SHELL.""" @overload def __init__( @@ -9629,7 +7932,7 @@ class LogProb(_Model): :ivar token: Required. :vartype token: str :ivar logprob: Required. - :vartype logprob: float + :vartype logprob: int :ivar bytes: Required. :vartype bytes: list[int] :ivar top_logprobs: Required. @@ -9638,7 +7941,7 @@ class LogProb(_Model): token: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - logprob: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + logprob: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" bytes: list[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @@ -9650,7 +7953,7 @@ def __init__( self, *, token: str, - logprob: float, + logprob: int, bytes: list[int], top_logprobs: list["_models.TopLogProb"], ) -> None: ... @@ -9679,14 +7982,14 @@ class ManagedAzureAISearchIndex(Index, discriminator="ManagedAzureSearch"): :vartype description: str :ivar tags: Tag dictionary. Tags can be added, removed, and updated. :vartype tags: dict[str, str] - :ivar type: Type of index. Required. Managed Azure Search + :ivar type: Type of index. Required. Managed Azure Search. :vartype type: str or ~azure.ai.projects.models.MANAGED_AZURE_SEARCH :ivar vector_store_id: Vector store id of managed index. Required. :vartype vector_store_id: str """ type: Literal[IndexType.MANAGED_AZURE_SEARCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Type of index. Required. Managed Azure Search""" + """Type of index. Required. Managed Azure Search.""" vector_store_id: str = rest_field(name="vectorStoreId", visibility=["create"]) """Vector store id of managed index. Required.""" @@ -9767,7 +8070,7 @@ class MCPListToolsToolInputSchema(_Model): class MCPTool(Tool, discriminator="mcp"): """MCP tool. - :ivar type: The type of the MCP tool. Always ``mcp``. Required. + :ivar type: The type of the MCP tool. Always ``mcp``. Required. MCP. :vartype type: str or ~azure.ai.projects.models.MCP :ivar server_label: A label for this MCP server, used to identify it in tool calls. Required. :vartype server_label: str @@ -9775,10 +8078,9 @@ class MCPTool(Tool, discriminator="mcp"): provided. :vartype server_url: str :ivar connector_id: Identifier for service connectors, like those available in ChatGPT. One of - ``server_url`` or ``connector_id`` must be provided. Learn more about service - connectors `here - `_. - Currently supported ``connector_id`` values are: + ``server_url`` or ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported + ``connector_id`` values are: * Dropbox: `connector_dropbox` * Gmail: `connector_gmail` @@ -9794,8 +8096,8 @@ class MCPTool(Tool, discriminator="mcp"): Literal["connector_sharepoint"] :vartype connector_id: str or str or str or str or str or str or str or str :ivar authorization: An OAuth access token that can be used with a remote MCP server, either - with a custom MCP server URL or a service connector. Your application - must handle the OAuth authorization flow and provide the token here. + with a custom MCP server URL or a service connector. Your application must handle the OAuth + authorization flow and provide the token here. :vartype authorization: str :ivar server_description: Optional description of the MCP server, used to provide more context. :vartype server_description: str @@ -9813,12 +8115,11 @@ class MCPTool(Tool, discriminator="mcp"): """ type: Literal[ToolType.MCP] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the MCP tool. Always ``mcp``. Required.""" + """The type of the MCP tool. Always ``mcp``. Required. MCP.""" server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A label for this MCP server, used to identify it in tool calls. Required.""" server_url: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be - provided.""" + """The URL for the MCP server. One of ``server_url`` or ``connector_id`` must be provided.""" connector_id: Optional[ Literal[ "connector_dropbox", @@ -9831,11 +8132,10 @@ class MCPTool(Tool, discriminator="mcp"): "connector_sharepoint", ] ] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Identifier for service connectors, like those available in ChatGPT. One of - ``server_url`` or ``connector_id`` must be provided. Learn more about service - connectors `here - `_. - Currently supported ``connector_id`` values are: + """Identifier for service connectors, like those available in ChatGPT. One of ``server_url`` or + ``connector_id`` must be provided. Learn more about service connectors `here + `_. Currently supported + ``connector_id`` values are: * Dropbox: `connector_dropbox` * Gmail: `connector_gmail` @@ -9850,9 +8150,9 @@ class MCPTool(Tool, discriminator="mcp"): Literal[\"connector_microsoftteams\"], Literal[\"connector_outlookcalendar\"], Literal[\"connector_outlookemail\"], Literal[\"connector_sharepoint\"]""" authorization: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """An OAuth access token that can be used with a remote MCP server, either - with a custom MCP server URL or a service connector. Your application - must handle the OAuth authorization flow and provide the token here.""" + """An OAuth access token that can be used with a remote MCP server, either with a custom MCP + server URL or a service connector. Your application must handle the OAuth authorization flow + and provide the token here.""" server_description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Optional description of the MCP server, used to provide more context.""" headers: Optional[dict[str, str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -9911,20 +8211,20 @@ class MCPToolFilter(_Model): :ivar tool_names: MCP allowed tools. :vartype tool_names: list[str] - :ivar read_only: Indicates whether or not a tool modifies data or is read-only. If an - MCP server is `annotated with `readOnlyHint` + :ivar read_only: Indicates whether or not a tool modifies data or is read-only. If an MCP + server is `annotated with `readOnlyHint` `_, - it will match this filter. + it will match this filter. :vartype read_only: bool """ tool_names: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """MCP allowed tools.""" read_only: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Indicates whether or not a tool modifies data or is read-only. If an - MCP server is `annotated with `readOnlyHint` + """Indicates whether or not a tool modifies data or is read-only. If an MCP server is `annotated + with `readOnlyHint` `_, - it will match this filter.""" + it will match this filter.""" @overload def __init__( @@ -10069,16 +8369,17 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class MemorySearchPreviewTool(Tool, discriminator="memory_search"): +class MemorySearchPreviewTool(Tool, discriminator="memory_search_preview"): """A tool for integrating memories into the agent. - :ivar type: The type of the tool. Always ``memory_search``. Required. - :vartype type: str or ~azure.ai.projects.models.MEMORY_SEARCH + :ivar type: The type of the tool. Always ``memory_search_preview``. Required. + MEMORY_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.MEMORY_SEARCH_PREVIEW :ivar memory_store_name: The name of the memory store to use. Required. :vartype memory_store_name: str - :ivar scope: The namespace used to group and isolate memories, such as a user ID. - Limits which memories can be retrieved or updated. - Use special variable ``{{$userId}}`` to scope memories to the current signed-in user. Required. + :ivar scope: The namespace used to group and isolate memories, such as a user ID. Limits which + memories can be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to + the current signed-in user. Required. :vartype scope: str :ivar search_options: Options for searching the memory store. :vartype search_options: ~azure.ai.projects.models.MemorySearchOptions @@ -10087,14 +8388,14 @@ class MemorySearchPreviewTool(Tool, discriminator="memory_search"): :vartype update_delay: int """ - type: Literal[ToolType.MEMORY_SEARCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the tool. Always ``memory_search``. Required.""" + type: Literal[ToolType.MEMORY_SEARCH_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the tool. Always ``memory_search_preview``. Required. MEMORY_SEARCH_PREVIEW.""" memory_store_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the memory store to use. Required.""" scope: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The namespace used to group and isolate memories, such as a user ID. - Limits which memories can be retrieved or updated. - Use special variable ``{{$userId}}`` to scope memories to the current signed-in user. Required.""" + """The namespace used to group and isolate memories, such as a user ID. Limits which memories can + be retrieved or updated. Use special variable ``{{$userId}}`` to scope memories to the current + signed-in user. Required.""" search_options: Optional["_models.MemorySearchOptions"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -10121,59 +8422,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = ToolType.MEMORY_SEARCH # type: ignore - - -class MemorySearchToolCallItemResource(ItemResource, discriminator="memory_search_call"): - """MemorySearchToolCallItemResource. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: Required. - :vartype type: str or ~azure.ai.projects.models.MEMORY_SEARCH_CALL - :ivar status: The status of the memory search tool call. One of ``in_progress``, - ``searching``, ``completed``, ``incomplete`` or ``failed``,. Required. Is one of the following - types: Literal["in_progress"], Literal["searching"], Literal["completed"], - Literal["incomplete"], Literal["failed"] - :vartype status: str or str or str or str or str - :ivar results: The results returned from the memory search. - :vartype results: list[~azure.ai.projects.models.MemorySearchItem] - """ - - type: Literal[ItemResourceType.MEMORY_SEARCH_CALL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" - status: Literal["in_progress", "searching", "completed", "incomplete", "failed"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The status of the memory search tool call. One of ``in_progress``, - ``searching``, ``completed``, ``incomplete`` or ``failed``,. Required. Is one of the following - types: Literal[\"in_progress\"], Literal[\"searching\"], Literal[\"completed\"], - Literal[\"incomplete\"], Literal[\"failed\"]""" - results: Optional[list["_models.MemorySearchItem"]] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """The results returned from the memory search.""" - - @overload - def __init__( - self, - *, - status: Literal["in_progress", "searching", "completed", "incomplete", "failed"], - created_by: Optional[Union["_models.CreatedBy", str]] = None, - results: Optional[list["_models.MemorySearchItem"]] = 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) - self.type = ItemResourceType.MEMORY_SEARCH_CALL # type: ignore + self.type = ToolType.MEMORY_SEARCH_PREVIEW # type: ignore class MemoryStoreDefinition(_Model): @@ -10298,9 +8547,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class MemoryStoreDeleteScopeResult(_Model): """Response for deleting memories from a scope. - :ivar object: The object type. Always 'memory_store.scope.deleted'. Required. Default value is - "memory_store.scope.deleted". - :vartype object: str + :ivar object: The object type. Always 'memory_store.scope.deleted'. Required. + MEMORY_STORE_SCOPE_DELETED. + :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE_SCOPE_DELETED :ivar name: The name of the memory store. Required. :vartype name: str :ivar scope: The scope from which memories were deleted. Required. @@ -10309,11 +8558,10 @@ class MemoryStoreDeleteScopeResult(_Model): :vartype deleted: bool """ - object: Literal["memory_store.scope.deleted"] = rest_field( + object: Literal[MemoryStoreObjectType.MEMORY_STORE_SCOPE_DELETED] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The object type. Always 'memory_store.scope.deleted'. Required. Default value is - \"memory_store.scope.deleted\".""" + """The object type. Always 'memory_store.scope.deleted'. Required. MEMORY_STORE_SCOPE_DELETED.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The name of the memory store. Required.""" scope: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -10325,6 +8573,7 @@ class MemoryStoreDeleteScopeResult(_Model): def __init__( self, *, + object: Literal[MemoryStoreObjectType.MEMORY_STORE_SCOPE_DELETED], name: str, scope: str, deleted: bool, @@ -10339,15 +8588,13 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.object: Literal["memory_store.scope.deleted"] = "memory_store.scope.deleted" class MemoryStoreDetails(_Model): """A memory store that can store and retrieve user memories. - :ivar object: The object type, which is always 'memory_store'. Required. Default value is - "memory_store". - :vartype object: str + :ivar object: The object type, which is always 'memory_store'. Required. MEMORY_STORE. + :vartype object: str or ~azure.ai.projects.models.MEMORY_STORE :ivar id: The unique identifier of the memory store. Required. :vartype id: str :ivar created_at: The Unix timestamp (seconds) when the memory store was created. Required. @@ -10365,8 +8612,10 @@ class MemoryStoreDetails(_Model): :vartype definition: ~azure.ai.projects.models.MemoryStoreDefinition """ - object: Literal["memory_store"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The object type, which is always 'memory_store'. Required. Default value is \"memory_store\".""" + object: Literal[MemoryStoreObjectType.MEMORY_STORE] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The object type, which is always 'memory_store'. Required. MEMORY_STORE.""" id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The unique identifier of the memory store. Required.""" created_at: datetime.datetime = rest_field( @@ -10390,6 +8639,7 @@ class MemoryStoreDetails(_Model): def __init__( self, *, + object: Literal[MemoryStoreObjectType.MEMORY_STORE], id: str, # pylint: disable=redefined-builtin created_at: datetime.datetime, updated_at: datetime.datetime, @@ -10408,7 +8658,6 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.object: Literal["memory_store"] = "memory_store" class MemoryStoreOperationUsage(_Model): @@ -10559,7 +8808,7 @@ class MemoryStoreUpdateResult(_Model): :ivar result: The result of memory store update operation when status is "completed". :vartype result: ~azure.ai.projects.models.MemoryStoreUpdateCompletedResult :ivar error: Error object that describes the error when status is "failed". - :vartype error: ~azure.ai.projects.models.Error + :vartype error: ~azure.ai.projects.models.ApiError """ update_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -10577,7 +8826,7 @@ class MemoryStoreUpdateResult(_Model): visibility=["read", "create", "update", "delete", "query"] ) """The result of memory store update operation when status is \"completed\".""" - error: Optional["_models.Error"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + error: Optional["_models.ApiError"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Error object that describes the error when status is \"failed\".""" @overload @@ -10588,7 +8837,7 @@ def __init__( status: Union[str, "_models.MemoryStoreUpdateStatus"], superseded_by: Optional[str] = None, result: Optional["_models.MemoryStoreUpdateCompletedResult"] = None, - error: Optional["_models.Error"] = None, + error: Optional["_models.ApiError"] = None, ) -> None: ... @overload @@ -10606,13 +8855,15 @@ class MicrosoftFabricPreviewTool(Tool, discriminator="fabric_dataagent_preview") """The input definition information for a Microsoft Fabric tool as used to configure an agent. :ivar type: The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW. :vartype type: str or ~azure.ai.projects.models.FABRIC_DATAAGENT_PREVIEW :ivar fabric_dataagent_preview: The fabric data agent tool parameters. Required. :vartype fabric_dataagent_preview: ~azure.ai.projects.models.FabricDataAgentToolParameters """ type: Literal[ToolType.FABRIC_DATAAGENT_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'fabric_dataagent_preview'. Required.""" + """The object type, which is always 'fabric_dataagent_preview'. Required. + FABRIC_DATAAGENT_PREVIEW.""" fabric_dataagent_preview: "_models.FabricDataAgentToolParameters" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -10642,7 +8893,7 @@ class ModelDeployment(Deployment, discriminator="ModelDeployment"): :ivar name: Name of the deployment. Required. :vartype name: str - :ivar type: The type of the deployment. Required. Model deployment + :ivar type: The type of the deployment. Required. Model deployment. :vartype type: str or ~azure.ai.projects.models.MODEL_DEPLOYMENT :ivar model_name: Publisher-specific name of the deployed model. Required. :vartype model_name: str @@ -10659,7 +8910,7 @@ class ModelDeployment(Deployment, discriminator="ModelDeployment"): """ type: Literal[DeploymentType.MODEL_DEPLOYMENT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the deployment. Required. Model deployment""" + """The type of the deployment. Required. Model deployment.""" model_name: str = rest_field(name="modelName", visibility=["read"]) """Publisher-specific name of the deployed model. Required.""" model_version: str = rest_field(name="modelVersion", visibility=["read"]) @@ -10738,6 +8989,50 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class ModelSamplingParams(_Model): + """Represents a set of parameters used to control the sampling behavior of a language model during + text generation. + + :ivar temperature: The temperature parameter for sampling. Required. + :vartype temperature: float + :ivar top_p: The top-p parameter for nucleus sampling. Required. + :vartype top_p: float + :ivar seed: The random seed for reproducibility. Required. + :vartype seed: int + :ivar max_completion_tokens: The maximum number of tokens allowed in the completion. Required. + :vartype max_completion_tokens: int + """ + + temperature: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The temperature parameter for sampling. Required.""" + top_p: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The top-p parameter for nucleus sampling. Required.""" + seed: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The random seed for reproducibility. Required.""" + max_completion_tokens: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The maximum number of tokens allowed in the completion. Required.""" + + @overload + def __init__( + self, + *, + temperature: float, + top_p: float, + seed: int, + max_completion_tokens: int, + ) -> 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 MonthlyRecurrenceSchedule(RecurrenceSchedule, discriminator="Monthly"): """Monthly recurrence schedule. @@ -10776,8 +9071,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Move(ComputerAction, discriminator="move"): """Move. - :ivar type: Specifies the event type. For a move action, this property is - always set to ``move``. Required. + :ivar type: Specifies the event type. For a move action, this property is always set to + ``move``. Required. MOVE. :vartype type: str or ~azure.ai.projects.models.MOVE :ivar x: The x-coordinate to move to. Required. :vartype x: int @@ -10786,8 +9081,8 @@ class Move(ComputerAction, discriminator="move"): """ type: Literal[ComputerActionType.MOVE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Specifies the event type. For a move action, this property is - always set to ``move``. Required.""" + """Specifies the event type. For a move action, this property is always set to ``move``. Required. + MOVE.""" x: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The x-coordinate to move to. Required.""" y: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -10816,12 +9111,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class NoAuthenticationCredentials(BaseCredentials, discriminator="None"): """Credentials that do not require authentication. - :ivar type: The credential type. Required. No credential + :ivar type: The credential type. Required. No credential. :vartype type: str or ~azure.ai.projects.models.NONE """ type: Literal[CredentialType.NONE] = rest_discriminator(name="type", visibility=["read"]) # type: ignore - """The credential type. Required. No credential""" + """The credential type. Required. No credential.""" @overload def __init__( @@ -10840,53 +9135,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = CredentialType.NONE # type: ignore -class OAuthConsentRequestItemResource(ItemResource, discriminator="oauth_consent_request"): - """Request from the service for the user to perform OAuth consent. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar id: Required. - :vartype id: str - :ivar type: Required. - :vartype type: str or ~azure.ai.projects.models.OAUTH_CONSENT_REQUEST - :ivar consent_link: The link the user can use to perform OAuth consent. Required. - :vartype consent_link: str - :ivar server_label: The server label for the OAuth consent request. Required. - :vartype server_label: str - """ - - id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Required.""" - type: Literal[ItemResourceType.OAUTH_CONSENT_REQUEST] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" - consent_link: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The link the user can use to perform OAuth consent. Required.""" - server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The server label for the OAuth consent request. Required.""" - - @overload - def __init__( - self, - *, - id: str, # pylint: disable=redefined-builtin - consent_link: str, - server_label: str, - created_by: Optional[Union["_models.CreatedBy", 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) - self.type = ItemResourceType.OAUTH_CONSENT_REQUEST # type: ignore - - class OneTimeTrigger(Trigger, discriminator="OneTime"): """One-time trigger. @@ -10962,12 +9210,12 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OpenApiAnonymousAuthDetails(OpenApiAuthDetails, discriminator="anonymous"): """Security details for OpenApi anonymous authentication. - :ivar type: The object type, which is always 'anonymous'. Required. + :ivar type: The object type, which is always 'anonymous'. Required. ANONYMOUS. :vartype type: str or ~azure.ai.projects.models.ANONYMOUS """ type: Literal[OpenApiAuthType.ANONYMOUS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'anonymous'. Required.""" + """The object type, which is always 'anonymous'. Required. ANONYMOUS.""" @overload def __init__( @@ -10995,7 +9243,7 @@ class OpenApiFunctionDefinition(_Model): and how to call the function. :vartype description: str :ivar spec: The openapi function shape, described as a JSON Schema object. Required. - :vartype spec: any + :vartype spec: dict[str, any] :ivar auth: Open API authentication details. Required. :vartype auth: ~azure.ai.projects.models.OpenApiAuthDetails :ivar default_params: List of OpenAPI spec parameters that will use user-provided defaults. @@ -11009,7 +9257,7 @@ class OpenApiFunctionDefinition(_Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A description of what the function does, used by the model to choose when and how to call the function.""" - spec: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) + spec: dict[str, Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The openapi function shape, described as a JSON Schema object. Required.""" auth: "_models.OpenApiAuthDetails" = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Open API authentication details. Required.""" @@ -11023,7 +9271,7 @@ def __init__( self, *, name: str, - spec: Any, + spec: dict[str, Any], auth: "_models.OpenApiAuthDetails", description: Optional[str] = None, default_params: Optional[list[str]] = None, @@ -11050,7 +9298,7 @@ class OpenApiFunctionDefinitionFunction(_Model): :vartype description: str :ivar parameters: The parameters the functions accepts, described as a JSON Schema object. Required. - :vartype parameters: any + :vartype parameters: dict[str, any] """ name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -11058,7 +9306,7 @@ class OpenApiFunctionDefinitionFunction(_Model): description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A description of what the function does, used by the model to choose when and how to call the function.""" - parameters: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) + parameters: dict[str, Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The parameters the functions accepts, described as a JSON Schema object. Required.""" @overload @@ -11066,7 +9314,7 @@ def __init__( self, *, name: str, - parameters: Any, + parameters: dict[str, Any], description: Optional[str] = None, ) -> None: ... @@ -11084,14 +9332,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OpenApiManagedAuthDetails(OpenApiAuthDetails, discriminator="managed_identity"): """Security details for OpenApi managed_identity authentication. - :ivar type: The object type, which is always 'managed_identity'. Required. + :ivar type: The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY. :vartype type: str or ~azure.ai.projects.models.MANAGED_IDENTITY :ivar security_scheme: Connection auth security details. Required. :vartype security_scheme: ~azure.ai.projects.models.OpenApiManagedSecurityScheme """ type: Literal[OpenApiAuthType.MANAGED_IDENTITY] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'managed_identity'. Required.""" + """The object type, which is always 'managed_identity'. Required. MANAGED_IDENTITY.""" security_scheme: "_models.OpenApiManagedSecurityScheme" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -11148,13 +9396,14 @@ class OpenApiProjectConnectionAuthDetails(OpenApiAuthDetails, discriminator="pro """Security details for OpenApi project connection authentication. :ivar type: The object type, which is always 'project_connection'. Required. + PROJECT_CONNECTION. :vartype type: str or ~azure.ai.projects.models.PROJECT_CONNECTION :ivar security_scheme: Project connection auth security details. Required. :vartype security_scheme: ~azure.ai.projects.models.OpenApiProjectConnectionSecurityScheme """ type: Literal[OpenApiAuthType.PROJECT_CONNECTION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'project_connection'. Required.""" + """The object type, which is always 'project_connection'. Required. PROJECT_CONNECTION.""" security_scheme: "_models.OpenApiProjectConnectionSecurityScheme" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -11210,14 +9459,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OpenApiTool(Tool, discriminator="openapi"): """The input definition information for an OpenAPI tool as used to configure an agent. - :ivar type: The object type, which is always 'openapi'. Required. + :ivar type: The object type, which is always 'openapi'. Required. OPENAPI. :vartype type: str or ~azure.ai.projects.models.OPENAPI :ivar openapi: The openapi function definition. Required. :vartype openapi: ~azure.ai.projects.models.OpenApiFunctionDefinition """ type: Literal[ToolType.OPENAPI] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'openapi'. Required.""" + """The object type, which is always 'openapi'. Required. OPENAPI.""" openapi: "_models.OpenApiFunctionDefinition" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -11242,38 +9491,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = ToolType.OPENAPI # type: ignore -class OutputContent(_Model): - """OutputContent. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - OutputContentOutputTextContent, ReasoningTextContent, OutputContentRefusalContent - - :ivar type: Required. Known values are: "output_text", "refusal", and "reasoning_text". - :vartype type: str or ~azure.ai.projects.models.OutputContentType - """ - - __mapping__: dict[str, _Model] = {} - type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) - """Required. Known values are: \"output_text\", \"refusal\", and \"reasoning_text\".""" - - @overload - def __init__( - self, - *, - type: 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 OutputMessageContent(_Model): """OutputMessageContent. @@ -11309,7 +9526,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OutputMessageContentOutputTextContent(OutputMessageContent, discriminator="output_text"): """Output text. - :ivar type: The type of the output text. Always ``output_text``. Required. + :ivar type: The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT. :vartype type: str or ~azure.ai.projects.models.OUTPUT_TEXT :ivar text: The text output from the model. Required. :vartype text: str @@ -11320,7 +9537,7 @@ class OutputMessageContentOutputTextContent(OutputMessageContent, discriminator= """ type: Literal[OutputMessageContentType.OUTPUT_TEXT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the output text. Always ``output_text``. Required.""" + """The type of the output text. Always ``output_text``. Required. OUTPUT_TEXT.""" text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The text output from the model. Required.""" annotations: list["_models.Annotation"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -11351,14 +9568,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class OutputMessageContentRefusalContent(OutputMessageContent, discriminator="refusal"): """Refusal. - :ivar type: The type of the refusal. Always ``refusal``. Required. + :ivar type: The type of the refusal. Always ``refusal``. Required. REFUSAL. :vartype type: str or ~azure.ai.projects.models.REFUSAL :ivar refusal: The refusal explanation from the model. Required. :vartype refusal: str """ type: Literal[OutputMessageContentType.REFUSAL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the refusal. Always ``refusal``. Required.""" + """The type of the refusal. Always ``refusal``. Required. REFUSAL.""" refusal: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The refusal explanation from the model. Required.""" @@ -11483,7 +9700,7 @@ class PromptAgentDefinition(AgentDefinition, discriminator="prompt"): :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. :vartype rai_config: ~azure.ai.projects.models.RaiConfig - :ivar kind: Required. + :ivar kind: Required. PROMPT. :vartype kind: str or ~azure.ai.projects.models.PROMPT :ivar model: The model deployment to use for this agent. Required. :vartype model: str @@ -11491,8 +9708,7 @@ class PromptAgentDefinition(AgentDefinition, discriminator="prompt"): :vartype instructions: str :ivar temperature: What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and - deterministic. - We generally recommend altering this or ``top_p`` but not both. + deterministic. We generally recommend altering this or ``top_p`` but not both. :vartype temperature: float :ivar top_p: An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability @@ -11503,27 +9719,31 @@ class PromptAgentDefinition(AgentDefinition, discriminator="prompt"): :vartype top_p: float :ivar reasoning: :vartype reasoning: ~azure.ai.projects.models.Reasoning - :ivar tools: An array of tools the model may call while generating a response. You - can specify which tool to use by setting the ``tool_choice`` parameter. + :ivar tools: An array of tools the model may call while generating a response. You can specify + which tool to use by setting the ``tool_choice`` parameter. :vartype tools: list[~azure.ai.projects.models.Tool] + :ivar tool_choice: How the model should select which tool (or tools) to use when generating a + response. See the ``tools`` parameter to see how to specify which tools the model can call. Is + either a str type or a ToolChoiceParam type. + :vartype tool_choice: str or ~azure.ai.projects.models.ToolChoiceParam :ivar text: Configuration options for a text response from the model. Can be plain text or structured JSON data. - :vartype text: ~azure.ai.projects.models.PromptAgentDefinitionText + :vartype text: ~azure.ai.projects.models.PromptAgentDefinitionTextOptions :ivar structured_inputs: Set of structured inputs that can participate in prompt template substitution or tool argument bindings. :vartype structured_inputs: dict[str, ~azure.ai.projects.models.StructuredInputDefinition] """ kind: Literal[AgentKind.PROMPT] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" + """Required. PROMPT.""" model: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The model deployment to use for this agent. Required.""" instructions: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A system (or developer) message inserted into the model's context.""" temperature: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output - more random, while lower values like 0.2 will make it more focused and deterministic. - We generally recommend altering this or ``top_p`` but not both.""" + more random, while lower values like 0.2 will make it more focused and deterministic. We + generally recommend altering this or ``top_p`` but not both.""" top_p: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability @@ -11533,9 +9753,15 @@ class PromptAgentDefinition(AgentDefinition, discriminator="prompt"): We generally recommend altering this or ``temperature`` but not both.""" reasoning: Optional["_models.Reasoning"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) tools: Optional[list["_models.Tool"]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """An array of tools the model may call while generating a response. You - can specify which tool to use by setting the ``tool_choice`` parameter.""" - text: Optional["_models.PromptAgentDefinitionText"] = rest_field( + """An array of tools the model may call while generating a response. You can specify which tool to + use by setting the ``tool_choice`` parameter.""" + tool_choice: Optional[Union[str, "_models.ToolChoiceParam"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """How the model should select which tool (or tools) to use when generating a response. See the + ``tools`` parameter to see how to specify which tools the model can call. Is either a str type + or a ToolChoiceParam type.""" + text: Optional["_models.PromptAgentDefinitionTextOptions"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) """Configuration options for a text response from the model. Can be plain text or structured JSON @@ -11557,7 +9783,8 @@ def __init__( top_p: Optional[float] = None, reasoning: Optional["_models.Reasoning"] = None, tools: Optional[list["_models.Tool"]] = None, - text: Optional["_models.PromptAgentDefinitionText"] = None, + tool_choice: Optional[Union[str, "_models.ToolChoiceParam"]] = None, + text: Optional["_models.PromptAgentDefinitionTextOptions"] = None, structured_inputs: Optional[dict[str, "_models.StructuredInputDefinition"]] = None, ) -> None: ... @@ -11573,8 +9800,9 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.kind = AgentKind.PROMPT # type: ignore -class PromptAgentDefinitionText(_Model): - """PromptAgentDefinitionText. +class PromptAgentDefinitionTextOptions(_Model): + """Configuration options for a text response from the model. Can be plain text or structured JSON + data. :ivar format: :vartype format: ~azure.ai.projects.models.TextResponseFormatConfiguration @@ -11607,20 +9835,20 @@ class PromptBasedEvaluatorDefinition(EvaluatorDefinition, discriminator="prompt" :ivar init_parameters: The JSON schema (Draft 2020-12) for the evaluator's input parameters. This includes parameters like type, properties, required. - :vartype init_parameters: any + :vartype init_parameters: dict[str, any] :ivar data_schema: The JSON schema (Draft 2020-12) for the evaluator's input data. This includes parameters like type, properties, required. - :vartype data_schema: any + :vartype data_schema: dict[str, any] :ivar metrics: List of output metrics produced by this evaluator. :vartype metrics: dict[str, ~azure.ai.projects.models.EvaluatorMetric] - :ivar type: Required. Prompt-based definition + :ivar type: Required. Prompt-based definition. :vartype type: str or ~azure.ai.projects.models.PROMPT :ivar prompt_text: The prompt text used for evaluation. Required. :vartype prompt_text: str """ type: Literal[EvaluatorDefinitionType.PROMPT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required. Prompt-based definition""" + """Required. Prompt-based definition.""" prompt_text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The prompt text used for evaluation. Required.""" @@ -11629,8 +9857,8 @@ def __init__( self, *, prompt_text: str, - init_parameters: Optional[Any] = None, - data_schema: Optional[Any] = None, + init_parameters: Optional[dict[str, Any]] = None, + data_schema: Optional[dict[str, Any]] = None, metrics: Optional[dict[str, "_models.EvaluatorMetric"]] = None, ) -> None: ... @@ -11719,7 +9947,7 @@ class RankingOptions(_Model): :ivar score_threshold: The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results. - :vartype score_threshold: float + :vartype score_threshold: int :ivar hybrid_search: Weights that control how reciprocal rank fusion balances semantic embedding matches versus sparse keyword matches when hybrid search is enabled. :vartype hybrid_search: ~azure.ai.projects.models.HybridSearchOptions @@ -11729,7 +9957,7 @@ class RankingOptions(_Model): visibility=["read", "create", "update", "delete", "query"] ) """The ranker to use for the file search. Known values are: \"auto\" and \"default-2024-11-15\".""" - score_threshold: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + score_threshold: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The score threshold for the file search, a number between 0 and 1. Numbers closer to 1 will attempt to return only the most relevant results, but may return fewer results.""" hybrid_search: Optional["_models.HybridSearchOptions"] = rest_field( @@ -11743,7 +9971,7 @@ def __init__( self, *, ranker: Optional[Union[str, "_models.RankerVersionType"]] = None, - score_threshold: Optional[float] = None, + score_threshold: Optional[int] = None, hybrid_search: Optional["_models.HybridSearchOptions"] = None, ) -> None: ... @@ -11806,17 +10034,19 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class ReasoningTextContent(OutputContent, discriminator="reasoning_text"): +class ReasoningTextContent(_Model): """ReasoningTextContent. - :ivar type: The type of the reasoning text. Always ``reasoning_text``. Required. - :vartype type: str or ~azure.ai.projects.models.REASONING_TEXT + :ivar type: The type of the reasoning text. Always ``reasoning_text``. Required. Default value + is "reasoning_text". + :vartype type: str :ivar text: The reasoning text from the model. Required. :vartype text: str """ - type: Literal[OutputContentType.REASONING_TEXT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the reasoning text. Always ``reasoning_text``. Required.""" + type: Literal["reasoning_text"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The type of the reasoning text. Always ``reasoning_text``. Required. Default value is + \"reasoning_text\".""" text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The reasoning text from the model. Required.""" @@ -11836,7 +10066,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = OutputContentType.REASONING_TEXT # type: ignore + self.type: Literal["reasoning_text"] = "reasoning_text" class RecurrenceTrigger(Trigger, discriminator="Recurrence"): @@ -12042,14 +10272,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class SASCredentials(BaseCredentials, discriminator="SAS"): """Shared Access Signature (SAS) credential definition. - :ivar type: The credential type. Required. Shared Access Signature (SAS) credential + :ivar type: The credential type. Required. Shared Access Signature (SAS) credential. :vartype type: str or ~azure.ai.projects.models.SAS :ivar sas_token: SAS token. :vartype sas_token: str """ type: Literal[CredentialType.SAS] = rest_discriminator(name="type", visibility=["read"]) # type: ignore - """The credential type. Required. Shared Access Signature (SAS) credential""" + """The credential type. Required. Shared Access Signature (SAS) credential.""" sas_token: Optional[str] = rest_field(name="SAS", visibility=["read"]) """SAS token.""" @@ -12202,14 +10432,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Screenshot(ComputerAction, discriminator="screenshot"): """Screenshot. - :ivar type: Specifies the event type. For a screenshot action, this property is - always set to ``screenshot``. Required. + :ivar type: Specifies the event type. For a screenshot action, this property is always set to + ``screenshot``. Required. SCREENSHOT. :vartype type: str or ~azure.ai.projects.models.SCREENSHOT """ type: Literal[ComputerActionType.SCREENSHOT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Specifies the event type. For a screenshot action, this property is - always set to ``screenshot``. Required.""" + """Specifies the event type. For a screenshot action, this property is always set to + ``screenshot``. Required. SCREENSHOT.""" @overload def __init__( @@ -12231,8 +10461,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Scroll(ComputerAction, discriminator="scroll"): """Scroll. - :ivar type: Specifies the event type. For a scroll action, this property is - always set to ``scroll``. Required. + :ivar type: Specifies the event type. For a scroll action, this property is always set to + ``scroll``. Required. SCROLL. :vartype type: str or ~azure.ai.projects.models.SCROLL :ivar x: The x-coordinate where the scroll occurred. Required. :vartype x: int @@ -12245,8 +10475,8 @@ class Scroll(ComputerAction, discriminator="scroll"): """ type: Literal[ComputerActionType.SCROLL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Specifies the event type. For a scroll action, this property is - always set to ``scroll``. Required.""" + """Specifies the event type. For a scroll action, this property is always set to ``scroll``. + Required. SCROLL.""" x: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The x-coordinate where the scroll occurred. Required.""" y: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -12282,16 +10512,15 @@ class SharepointGroundingToolParameters(_Model): """The sharepoint grounding tool parameters. :ivar project_connections: The project connections attached to this tool. There can be a - maximum of 1 connection - resource attached to the tool. + maximum of 1 connection resource attached to the tool. :vartype project_connections: list[~azure.ai.projects.models.ToolProjectConnection] """ project_connections: Optional[list["_models.ToolProjectConnection"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The project connections attached to this tool. There can be a maximum of 1 connection - resource attached to the tool.""" + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" @overload def __init__( @@ -12315,6 +10544,7 @@ class SharepointPreviewTool(Tool, discriminator="sharepoint_grounding_preview"): """The input definition information for a sharepoint tool as used to configure an agent. :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW. :vartype type: str or ~azure.ai.projects.models.SHAREPOINT_GROUNDING_PREVIEW :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. :vartype sharepoint_grounding_preview: @@ -12322,7 +10552,8 @@ class SharepointPreviewTool(Tool, discriminator="sharepoint_grounding_preview"): """ type: Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'sharepoint_grounding_preview'. Required.""" + """The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW.""" sharepoint_grounding_preview: "_models.SharepointGroundingToolParameters" = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -12347,6 +10578,100 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = ToolType.SHAREPOINT_GROUNDING_PREVIEW # type: ignore +class ToolChoiceParam(_Model): + """How the model should select which tool (or tools) to use when generating a response. See the + ``tools`` parameter to see how to specify which tools the model can call. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ToolChoiceAllowed, SpecificApplyPatchParam, ToolChoiceCodeInterpreter, + ToolChoiceComputerUsePreview, ToolChoiceCustom, ToolChoiceFileSearch, ToolChoiceFunction, + ToolChoiceImageGeneration, ToolChoiceMCP, SpecificFunctionShellParam, + ToolChoiceWebSearchPreview, ToolChoiceWebSearchPreview20250311 + + :ivar type: Required. Known values are: "allowed_tools", "function", "mcp", "custom", + "apply_patch", "shell", "file_search", "web_search_preview", "computer_use_preview", + "web_search_preview_2025_03_11", "image_generation", and "code_interpreter". + :vartype type: str or ~azure.ai.projects.models.ToolChoiceParamType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """Required. Known values are: \"allowed_tools\", \"function\", \"mcp\", \"custom\", + \"apply_patch\", \"shell\", \"file_search\", \"web_search_preview\", \"computer_use_preview\", + \"web_search_preview_2025_03_11\", \"image_generation\", and \"code_interpreter\".""" + + @overload + def __init__( + self, + *, + type: 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 SpecificApplyPatchParam(ToolChoiceParam, discriminator="apply_patch"): + """Specific apply patch tool choice. + + :ivar type: The tool to call. Always ``apply_patch``. Required. APPLY_PATCH. + :vartype type: str or ~azure.ai.projects.models.APPLY_PATCH + """ + + type: Literal[ToolChoiceParamType.APPLY_PATCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The tool to call. Always ``apply_patch``. Required. APPLY_PATCH.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.APPLY_PATCH # type: ignore + + +class SpecificFunctionShellParam(ToolChoiceParam, discriminator="shell"): + """Specific shell tool choice. + + :ivar type: The tool to call. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.projects.models.SHELL + """ + + type: Literal[ToolChoiceParamType.SHELL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The tool to call. Always ``shell``. Required. SHELL.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.SHELL # type: ignore + + class StructuredInputDefinition(_Model): """An structured input that can participate in prompt template substitutions and tool argument binding. @@ -12356,7 +10681,7 @@ class StructuredInputDefinition(_Model): :ivar default_value: The default value for the input if no run-time value is provided. :vartype default_value: any :ivar schema: The JSON schema for the structured input (optional). - :vartype schema: any + :vartype schema: dict[str, any] :ivar required: Whether the input property is required when the agent is invoked. :vartype required: bool """ @@ -12365,7 +10690,7 @@ class StructuredInputDefinition(_Model): """A human-readable description of the input.""" default_value: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The default value for the input if no run-time value is provided.""" - schema: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + schema: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The JSON schema for the structured input (optional).""" required: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Whether the input property is required when the agent is invoked.""" @@ -12376,7 +10701,7 @@ def __init__( *, description: Optional[str] = None, default_value: Optional[Any] = None, - schema: Optional[Any] = None, + schema: Optional[dict[str, Any]] = None, required: Optional[bool] = None, ) -> None: ... @@ -12400,7 +10725,7 @@ class StructuredOutputDefinition(_Model): emit the output. Required. :vartype description: str :ivar schema: The JSON schema for the structured output. Required. - :vartype schema: any + :vartype schema: dict[str, any] :ivar strict: Whether to enforce strict validation. Default ``true``. Required. :vartype strict: bool """ @@ -12410,7 +10735,7 @@ class StructuredOutputDefinition(_Model): description: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """A description of the output to emit. Used by the model to determine when to emit the output. Required.""" - schema: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) + schema: dict[str, Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The JSON schema for the structured output. Required.""" strict: bool = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Whether to enforce strict validation. Default ``true``. Required.""" @@ -12421,44 +10746,8 @@ def __init__( *, name: str, description: str, - schema: Any, - strict: bool, - ) -> 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 StructuredOutputsItemResource(ItemResource, discriminator="structured_outputs"): - """StructuredOutputsItemResource. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: Required. - :vartype type: str or ~azure.ai.projects.models.STRUCTURED_OUTPUTS - :ivar output: The structured output captured during the response. Required. - :vartype output: any - """ - - type: Literal[ItemResourceType.STRUCTURED_OUTPUTS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" - output: Any = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The structured output captured during the response. Required.""" - - @overload - def __init__( - self, - *, - output: Any, - created_by: Optional[Union["_models.CreatedBy", str]] = None, + schema: dict[str, Any], + strict: bool, ) -> None: ... @overload @@ -12470,7 +10759,6 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = ItemResourceType.STRUCTURED_OUTPUTS # type: ignore class Summary(_Model): @@ -12619,15 +10907,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class TextResponseFormatConfiguration(_Model): - """An object specifying the format that the model must output. - Configuring ``{ "type": "json_schema" }`` enables Structured Outputs, - which ensures the model will match your supplied JSON schema. Learn more in the - `Structured Outputs guide `_. - The default format is ``{ "type": "text" }`` with no additional options. - *Not recommended for gpt-4o and newer models:** - Setting to ``{ "type": "json_object" }`` enables the older JSON mode, which - ensures the message the model generates is valid JSON. Using ``json_schema`` - is preferred for models that support it. + """An object specifying the format that the model must output. Configuring ``{ "type": + "json_schema" }`` enables Structured Outputs, which ensures the model will match your supplied + JSON schema. Learn more in the `Structured Outputs guide + `_. The default format is ``{ + "type": "text" }`` with no additional options. *Not recommended for gpt-4o and newer models:** + Setting to ``{ "type": "json_object" }`` enables the older JSON mode, which ensures the message + the model generates is valid JSON. Using ``json_schema`` is preferred for models that support + it. You probably want to use the sub-classes and not this class directly. Known sub-classes are: TextResponseFormatConfigurationResponseFormatJsonObject, TextResponseFormatJsonSchema, @@ -12665,11 +10952,12 @@ class TextResponseFormatConfigurationResponseFormatJsonObject( """JSON object. :ivar type: The type of response format being defined. Always ``json_object``. Required. + JSON_OBJECT. :vartype type: str or ~azure.ai.projects.models.JSON_OBJECT """ type: Literal[TextResponseFormatConfigurationType.JSON_OBJECT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of response format being defined. Always ``json_object``. Required.""" + """The type of response format being defined. Always ``json_object``. Required. JSON_OBJECT.""" @overload def __init__( @@ -12693,12 +10981,12 @@ class TextResponseFormatConfigurationResponseFormatText( ): # pylint: disable=name-too-long """Text. - :ivar type: The type of response format being defined. Always ``text``. Required. + :ivar type: The type of response format being defined. Always ``text``. Required. TEXT. :vartype type: str or ~azure.ai.projects.models.TEXT """ type: Literal[TextResponseFormatConfigurationType.TEXT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of response format being defined. Always ``text``. Required.""" + """The type of response format being defined. Always ``text``. Required. TEXT.""" @overload def __init__( @@ -12721,12 +11009,13 @@ class TextResponseFormatJsonSchema(TextResponseFormatConfiguration, discriminato """JSON schema. :ivar type: The type of response format being defined. Always ``json_schema``. Required. + JSON_SCHEMA. :vartype type: str or ~azure.ai.projects.models.JSON_SCHEMA :ivar description: A description of what the response format is for, used by the model to - determine how to respond in the format. + determine how to respond in the format. :vartype description: str - :ivar name: The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. Required. + :ivar name: The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and + dashes, with a maximum length of 64. Required. :vartype name: str :ivar schema: Required. :vartype schema: dict[str, any] @@ -12735,13 +11024,13 @@ class TextResponseFormatJsonSchema(TextResponseFormatConfiguration, discriminato """ type: Literal[TextResponseFormatConfigurationType.JSON_SCHEMA] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of response format being defined. Always ``json_schema``. Required.""" + """The type of response format being defined. Always ``json_schema``. Required. JSON_SCHEMA.""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """A description of what the response format is for, used by the model to - determine how to respond in the format.""" + """A description of what the response format is for, used by the model to determine how to respond + in the format.""" name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The name of the response format. Must be a-z, A-Z, 0-9, or contain - underscores and dashes, with a maximum length of 64. Required.""" + """The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with + a maximum length of 64. Required.""" schema: dict[str, Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" strict: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -12768,6 +11057,335 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = TextResponseFormatConfigurationType.JSON_SCHEMA # type: ignore +class ToolChoiceAllowed(ToolChoiceParam, discriminator="allowed_tools"): + """Allowed tools. + + :ivar type: Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS. + :vartype type: str or ~azure.ai.projects.models.ALLOWED_TOOLS + :ivar mode: Constrains the tools available to the model to a pre-defined set. ``auto`` allows + the model to pick from among the allowed tools and generate a message. ``required`` requires + the model to call one or more of the allowed tools. Required. Is either a Literal["auto"] type + or a Literal["required"] type. + :vartype mode: str or str + :ivar tools: A list of tool definitions that the model should be allowed to call. For the + Responses API, the list of tool definitions might look like: + .. code-block:: json + [ + { "type": "function", "name": "get_weather" }, + { "type": "mcp", "server_label": "deepwiki" }, + { "type": "image_generation" } + ]. Required. + :vartype tools: list[dict[str, any]] + """ + + type: Literal[ToolChoiceParamType.ALLOWED_TOOLS] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Allowed tool configuration type. Always ``allowed_tools``. Required. ALLOWED_TOOLS.""" + mode: Literal["auto", "required"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Constrains the tools available to the model to a pre-defined set. ``auto`` allows the model to + pick from among the allowed tools and generate a message. ``required`` requires the model to + call one or more of the allowed tools. Required. Is either a Literal[\"auto\"] type or a + Literal[\"required\"] type.""" + tools: list[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A list of tool definitions that the model should be allowed to call. For the Responses API, the + list of tool definitions might look like: + .. code-block:: json + [ + { \"type\": \"function\", \"name\": \"get_weather\" }, + { \"type\": \"mcp\", \"server_label\": \"deepwiki\" }, + { \"type\": \"image_generation\" } + ]. Required.""" + + @overload + def __init__( + self, + *, + mode: Literal["auto", "required"], + tools: list[dict[str, Any]], + ) -> 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) + self.type = ToolChoiceParamType.ALLOWED_TOOLS # type: ignore + + +class ToolChoiceCodeInterpreter(ToolChoiceParam, discriminator="code_interpreter"): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. CODE_INTERPRETER. + :vartype type: str or ~azure.ai.projects.models.CODE_INTERPRETER + """ + + type: Literal[ToolChoiceParamType.CODE_INTERPRETER] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. CODE_INTERPRETER.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.CODE_INTERPRETER # type: ignore + + +class ToolChoiceComputerUsePreview(ToolChoiceParam, discriminator="computer_use_preview"): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. COMPUTER_USE_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.COMPUTER_USE_PREVIEW + """ + + type: Literal[ToolChoiceParamType.COMPUTER_USE_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. COMPUTER_USE_PREVIEW.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.COMPUTER_USE_PREVIEW # type: ignore + + +class ToolChoiceCustom(ToolChoiceParam, discriminator="custom"): + """Custom tool. + + :ivar type: For custom tool calling, the type is always ``custom``. Required. CUSTOM. + :vartype type: str or ~azure.ai.projects.models.CUSTOM + :ivar name: The name of the custom tool to call. Required. + :vartype name: str + """ + + type: Literal[ToolChoiceParamType.CUSTOM] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """For custom tool calling, the type is always ``custom``. Required. CUSTOM.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the custom tool to call. Required.""" + + @overload + def __init__( + self, + *, + name: 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) + self.type = ToolChoiceParamType.CUSTOM # type: ignore + + +class ToolChoiceFileSearch(ToolChoiceParam, discriminator="file_search"): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. FILE_SEARCH. + :vartype type: str or ~azure.ai.projects.models.FILE_SEARCH + """ + + type: Literal[ToolChoiceParamType.FILE_SEARCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. FILE_SEARCH.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.FILE_SEARCH # type: ignore + + +class ToolChoiceFunction(ToolChoiceParam, discriminator="function"): + """Function tool. + + :ivar type: For function calling, the type is always ``function``. Required. FUNCTION. + :vartype type: str or ~azure.ai.projects.models.FUNCTION + :ivar name: The name of the function to call. Required. + :vartype name: str + """ + + type: Literal[ToolChoiceParamType.FUNCTION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """For function calling, the type is always ``function``. Required. FUNCTION.""" + name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The name of the function to call. Required.""" + + @overload + def __init__( + self, + *, + name: 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) + self.type = ToolChoiceParamType.FUNCTION # type: ignore + + +class ToolChoiceImageGeneration(ToolChoiceParam, discriminator="image_generation"): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. IMAGE_GENERATION. + :vartype type: str or ~azure.ai.projects.models.IMAGE_GENERATION + """ + + type: Literal[ToolChoiceParamType.IMAGE_GENERATION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. IMAGE_GENERATION.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.IMAGE_GENERATION # type: ignore + + +class ToolChoiceMCP(ToolChoiceParam, discriminator="mcp"): + """MCP tool. + + :ivar type: For MCP tools, the type is always ``mcp``. Required. MCP. + :vartype type: str or ~azure.ai.projects.models.MCP + :ivar server_label: The label of the MCP server to use. Required. + :vartype server_label: str + :ivar name: + :vartype name: str + """ + + type: Literal[ToolChoiceParamType.MCP] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """For MCP tools, the type is always ``mcp``. Required. MCP.""" + server_label: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the MCP server to use. Required.""" + name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + + @overload + def __init__( + self, + *, + server_label: str, + name: 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) + self.type = ToolChoiceParamType.MCP # type: ignore + + +class ToolChoiceWebSearchPreview(ToolChoiceParam, discriminator="web_search_preview"): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW + """ + + type: Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. WEB_SEARCH_PREVIEW.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.WEB_SEARCH_PREVIEW # type: ignore + + +class ToolChoiceWebSearchPreview20250311(ToolChoiceParam, discriminator="web_search_preview_2025_03_11"): + """Indicates that the model should use a built-in tool to generate a response. `Learn more about + built-in tools `_. + + :ivar type: Required. WEB_SEARCH_PREVIEW2025_03_11. + :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW2025_03_11 + """ + + type: Literal[ToolChoiceParamType.WEB_SEARCH_PREVIEW2025_03_11] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. WEB_SEARCH_PREVIEW2025_03_11.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = ToolChoiceParamType.WEB_SEARCH_PREVIEW2025_03_11 # type: ignore + + class ToolDescription(_Model): """Description of a tool that can be used by an agent. @@ -12836,14 +11454,14 @@ class TopLogProb(_Model): :ivar token: Required. :vartype token: str :ivar logprob: Required. - :vartype logprob: float + :vartype logprob: int :ivar bytes: Required. :vartype bytes: list[int] """ token: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" - logprob: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + logprob: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" bytes: list[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Required.""" @@ -12853,7 +11471,7 @@ def __init__( self, *, token: str, - logprob: float, + logprob: int, bytes: list[int], ) -> None: ... @@ -12871,16 +11489,16 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class Type(ComputerAction, discriminator="type"): """Type. - :ivar type: Specifies the event type. For a type action, this property is - always set to ``type``. Required. + :ivar type: Specifies the event type. For a type action, this property is always set to + ``type``. Required. TYPE. :vartype type: str or ~azure.ai.projects.models.TYPE :ivar text: The text to type. Required. :vartype text: str """ type: Literal[ComputerActionType.TYPE] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Specifies the event type. For a type action, this property is - always set to ``type``. Required.""" + """Specifies the event type. For a type action, this property is always set to ``type``. Required. + TYPE.""" text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The text to type. Required.""" @@ -12906,7 +11524,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class UrlCitationBody(Annotation, discriminator="url_citation"): """URL citation. - :ivar type: The type of the URL citation. Always ``url_citation``. Required. + :ivar type: The type of the URL citation. Always ``url_citation``. Required. URL_CITATION. :vartype type: str or ~azure.ai.projects.models.URL_CITATION :ivar url: The URL of the web resource. Required. :vartype url: str @@ -12920,7 +11538,7 @@ class UrlCitationBody(Annotation, discriminator="url_citation"): """ type: Literal[AnnotationType.URL_CITATION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the URL citation. Always ``url_citation``. Required.""" + """The type of the URL citation. Always ``url_citation``. Required. URL_CITATION.""" url: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The URL of the web resource. Required.""" start_index: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -12996,11 +11614,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class VectorStoreFileAttributes(_Model): - """Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. Keys are strings - with a maximum length of 64 characters. Values are strings with a maximum - length of 512 characters, booleans, or numbers. + """Set of 16 key-value pairs that can be attached to an object. This can be useful for storing + additional information about the object in a structured format, and querying for objects via + API or the dashboard. Keys are strings with a maximum length of 64 characters. Values are + strings with a maximum length of 512 characters, booleans, or numbers. """ @@ -13008,14 +11625,14 @@ class VectorStoreFileAttributes(_Model): class Wait(ComputerAction, discriminator="wait"): """Wait. - :ivar type: Specifies the event type. For a wait action, this property is - always set to ``wait``. Required. + :ivar type: Specifies the event type. For a wait action, this property is always set to + ``wait``. Required. WAIT. :vartype type: str or ~azure.ai.projects.models.WAIT """ type: Literal[ComputerActionType.WAIT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Specifies the event type. For a wait action, this property is - always set to ``wait``. Required.""" + """Specifies the event type. For a wait action, this property is always set to ``wait``. Required. + WAIT.""" @overload def __init__( @@ -13266,7 +11883,7 @@ class WebSearchPreviewTool(Tool, discriminator="web_search_preview"): """Web search preview. :ivar type: The type of the web search tool. One of ``web_search_preview`` or - ``web_search_preview_2025_03_11``. Required. + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW. :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH_PREVIEW :ivar user_location: :vartype user_location: ~azure.ai.projects.models.ApproximateLocation @@ -13278,7 +11895,7 @@ class WebSearchPreviewTool(Tool, discriminator="web_search_preview"): type: Literal[ToolType.WEB_SEARCH_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore """The type of the web search tool. One of ``web_search_preview`` or - ``web_search_preview_2025_03_11``. Required.""" + ``web_search_preview_2025_03_11``. Required. WEB_SEARCH_PREVIEW.""" user_location: Optional["_models.ApproximateLocation"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -13313,7 +11930,7 @@ class WebSearchTool(Tool, discriminator="web_search"): """Web search. :ivar type: The type of the web search tool. One of ``web_search`` or - ``web_search_2025_08_26``. Required. + ``web_search_2025_08_26``. Required. WEB_SEARCH. :vartype type: str or ~azure.ai.projects.models.WEB_SEARCH :ivar filters: :vartype filters: ~azure.ai.projects.models.WebSearchToolFilters @@ -13324,13 +11941,13 @@ class WebSearchTool(Tool, discriminator="web_search"): the following types: Literal["low"], Literal["medium"], Literal["high"] :vartype search_context_size: str or str or str :ivar custom_search_configuration: The project connections attached to this tool. There can be - a maximum of 1 connection - resource attached to the tool. + a maximum of 1 connection resource attached to the tool. :vartype custom_search_configuration: ~azure.ai.projects.models.WebSearchConfiguration """ type: Literal[ToolType.WEB_SEARCH] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The type of the web search tool. One of ``web_search`` or ``web_search_2025_08_26``. Required.""" + """The type of the web search tool. One of ``web_search`` or ``web_search_2025_08_26``. Required. + WEB_SEARCH.""" filters: Optional["_models.WebSearchToolFilters"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) @@ -13346,8 +11963,8 @@ class WebSearchTool(Tool, discriminator="web_search"): custom_search_configuration: Optional["_models.WebSearchConfiguration"] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The project connections attached to this tool. There can be a maximum of 1 connection - resource attached to the tool.""" + """The project connections attached to this tool. There can be a maximum of 1 connection resource + attached to the tool.""" @overload def __init__( @@ -13433,82 +12050,19 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = RecurrenceType.WEEKLY # type: ignore -class WorkflowActionOutputItemResource(ItemResource, discriminator="workflow_action"): - """WorkflowActionOutputItemResource. - - :ivar created_by: The information about the creator of the item. Is either a CreatedBy type or - a str type. - :vartype created_by: ~azure.ai.projects.models.CreatedBy or str - :ivar type: Required. - :vartype type: str or ~azure.ai.projects.models.WORKFLOW_ACTION - :ivar kind: The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). Required. - :vartype kind: str - :ivar action_id: Unique identifier for the action. Required. - :vartype action_id: str - :ivar parent_action_id: ID of the parent action if this is a nested action. - :vartype parent_action_id: str - :ivar previous_action_id: ID of the previous action if this action follows another. - :vartype previous_action_id: str - :ivar status: Status of the action (e.g., 'in_progress', 'completed', 'failed', 'cancelled'). - Required. Is one of the following types: Literal["completed"], Literal["failed"], - Literal["in_progress"], Literal["cancelled"] - :vartype status: str or str or str or str - """ - - type: Literal[ItemResourceType.WORKFLOW_ACTION] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" - kind: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The kind of CSDL action (e.g., 'SetVariable', 'InvokeAzureAgent'). Required.""" - action_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Unique identifier for the action. Required.""" - parent_action_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """ID of the parent action if this is a nested action.""" - previous_action_id: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """ID of the previous action if this action follows another.""" - status: Literal["completed", "failed", "in_progress", "cancelled"] = rest_field( - visibility=["read", "create", "update", "delete", "query"] - ) - """Status of the action (e.g., 'in_progress', 'completed', 'failed', 'cancelled'). Required. Is - one of the following types: Literal[\"completed\"], Literal[\"failed\"], - Literal[\"in_progress\"], Literal[\"cancelled\"]""" - - @overload - def __init__( - self, - *, - kind: str, - action_id: str, - status: Literal["completed", "failed", "in_progress", "cancelled"], - created_by: Optional[Union["_models.CreatedBy", str]] = None, - parent_action_id: Optional[str] = None, - previous_action_id: 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) - self.type = ItemResourceType.WORKFLOW_ACTION # type: ignore - - class WorkflowAgentDefinition(AgentDefinition, discriminator="workflow"): """The workflow agent definition. :ivar rai_config: Configuration for Responsible AI (RAI) content filtering and safety features. :vartype rai_config: ~azure.ai.projects.models.RaiConfig - :ivar kind: Required. + :ivar kind: Required. WORKFLOW. :vartype kind: str or ~azure.ai.projects.models.WORKFLOW :ivar workflow: The CSDL YAML definition of the workflow. :vartype workflow: str """ kind: Literal[AgentKind.WORKFLOW] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """Required.""" + """Required. WORKFLOW.""" workflow: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The CSDL YAML definition of the workflow.""" 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 5ae1225f30fa..1a1c0ffec86c 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 @@ -12,36 +12,26 @@ if TYPE_CHECKING: from ._patch import * # pylint: disable=unused-wildcard-import +from ._operations import BetaOperations # type: ignore from ._operations import AgentsOperations # type: ignore -from ._operations import MemoryStoresOperations # type: ignore +from ._operations import EvaluationRulesOperations # type: ignore from ._operations import ConnectionsOperations # type: ignore from ._operations import DatasetsOperations # type: ignore -from ._operations import IndexesOperations # type: ignore from ._operations import DeploymentsOperations # type: ignore -from ._operations import RedTeamsOperations # type: ignore -from ._operations import EvaluationRulesOperations # type: ignore -from ._operations import EvaluationTaxonomiesOperations # type: ignore -from ._operations import EvaluatorsOperations # type: ignore -from ._operations import InsightsOperations # type: ignore -from ._operations import SchedulesOperations # type: ignore +from ._operations import IndexesOperations # type: ignore from ._patch import __all__ as _patch_all from ._patch import * from ._patch import patch_sdk as _patch_sdk __all__ = [ + "BetaOperations", "AgentsOperations", - "MemoryStoresOperations", + "EvaluationRulesOperations", "ConnectionsOperations", "DatasetsOperations", - "IndexesOperations", "DeploymentsOperations", - "RedTeamsOperations", - "EvaluationRulesOperations", - "EvaluationTaxonomiesOperations", - "EvaluatorsOperations", - "InsightsOperations", - "SchedulesOperations", + "IndexesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore _patch_sdk() 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 3def1c5f7d71..b60ba85837e5 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 @@ -1,4 +1,4 @@ -# pylint: disable=line-too-long,useless-suppression,too-many-lines +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -37,6 +37,7 @@ from .._configuration import AIProjectClientConfiguration from .._utils.model_base import SdkJSONEncoder, _deserialize, _failsafe_deserialize from .._utils.serialization import Deserializer, Serializer +from ..models._enums import FoundryFeaturesOptInKeys JSON = MutableMapping[str, Any] _Unset: Any = object() @@ -52,7 +53,7 @@ def build_agents_get_request(agent_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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -72,12 +73,22 @@ def build_agents_get_request(agent_name: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_request(**kwargs: Any) -> HttpRequest: +def build_agents_create_agent_request( + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = 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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -87,6 +98,8 @@ def build_agents_create_request(**kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -94,12 +107,23 @@ def build_agents_create_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_update_request(agent_name: str, **kwargs: Any) -> HttpRequest: +def build_agents_update_agent_request( + agent_name: str, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = 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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,6 +138,8 @@ def build_agents_update_request(agent_name: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -121,12 +147,12 @@ def build_agents_update_request(agent_name: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_from_manifest_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long +def build_agents_create_agent_from_manifest_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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,14 +169,14 @@ def build_agents_create_from_manifest_request(**kwargs: Any) -> HttpRequest: # return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_update_from_manifest_request( # pylint: disable=name-too-long +def build_agents_update_agent_from_manifest_request( # pylint: disable=name-too-long agent_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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -176,7 +202,7 @@ def build_agents_delete_request(agent_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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -208,14 +234,13 @@ def build_agents_list_request( _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = "/agents" # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if kind is not None: _params["kind"] = _SERIALIZER.query("kind", kind, "str") if limit is not None: @@ -226,6 +251,7 @@ def build_agents_list_request( _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") @@ -233,12 +259,23 @@ def build_agents_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_agents_create_version_request(agent_name: str, **kwargs: Any) -> HttpRequest: +def build_agents_create_version_request( + agent_name: str, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = 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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -253,6 +290,8 @@ def build_agents_create_version_request(agent_name: str, **kwargs: Any) -> HttpR _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -267,7 +306,7 @@ def build_agents_create_version_from_manifest_request( # pylint: disable=name-t _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -293,7 +332,7 @@ def build_agents_get_version_request(agent_name: str, agent_version: str, **kwar _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -318,7 +357,7 @@ def build_agents_delete_version_request(agent_name: str, agent_version: str, **k _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -351,7 +390,7 @@ def build_agents_list_versions_request( _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -363,7 +402,6 @@ def build_agents_list_versions_request( _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") if order is not None: @@ -372,80 +410,25 @@ def build_agents_list_versions_request( _params["after"] = _SERIALIZER.query("after", after, "str") if before is not None: _params["before"] = _SERIALIZER.query("before", before, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_agents_stream_agent_container_logs_request( # pylint: disable=name-too-long - agent_name: str, - agent_version: str, - *, - kind: Optional[Union[str, _models.ContainerLogKind]] = None, - replica_name: Optional[str] = None, - tail: Optional[int] = None, - **kwargs: Any -) -> HttpRequest: - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-11-15-preview")) - # Construct URL - _url = "/agents/{agent_name}/versions/{agent_version}/containers/default:logstream" - path_format_arguments = { - "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), - "agent_version": _SERIALIZER.url("agent_version", agent_version, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if kind is not None: - _params["kind"] = _SERIALIZER.query("kind", kind, "str") - if replica_name is not None: - _params["replica_name"] = _SERIALIZER.query("replica_name", replica_name, "str") - if tail is not None: - _params["tail"] = _SERIALIZER.query("tail", tail, "int") - - return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - - -def build_memory_stores_create_request(**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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores" - - # 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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_memory_stores_update_request(name: str, **kwargs: Any) -> HttpRequest: +def build_evaluation_rules_get_request(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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores/{name}" + _url = "/evaluationrules/{id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "id": _SERIALIZER.url("id", id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -454,24 +437,19 @@ def build_memory_stores_update_request(name: str, **kwargs: Any) -> HttpRequest: _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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_memory_stores_get_request(name: str, **kwargs: Any) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) +def build_evaluation_rules_delete_request(id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/memory_stores/{name}" + _url = "/evaluationrules/{id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "id": _SERIALIZER.url("id", id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -479,84 +457,26 @@ def build_memory_stores_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_memory_stores_list_request( +def build_evaluation_rules_create_or_update_request( # pylint: disable=name-too-long + id: str, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, **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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "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") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_memory_stores_delete_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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_memory_stores_search_memories_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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores/{name}:search_memories" + _url = "/evaluationrules/{id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "id": _SERIALIZER.url("id", id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -565,74 +485,51 @@ def build_memory_stores_search_memories_request( # pylint: disable=name-too-lon _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if foundry_features is not None: + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_memory_stores_update_memories_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_evaluation_rules_list_request( + *, + action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, + agent_name: Optional[str] = None, + enabled: 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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/memory_stores/{name}:update_memories" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "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 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_memory_stores_delete_scope_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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores/{name}:delete_scope" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/evaluationrules" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if action_type is not None: + _params["actionType"] = _SERIALIZER.query("action_type", action_type, "str") + if agent_name is not None: + _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") + if enabled is not None: + _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") # 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) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) 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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -658,7 +555,7 @@ def build_connections_get_with_credentials_request( # pylint: disable=name-too- _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -687,7 +584,7 @@ def build_connections_list_request( _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -710,7 +607,7 @@ def build_datasets_list_versions_request(name: str, **kwargs: Any) -> HttpReques _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -734,7 +631,7 @@ def build_datasets_list_request(**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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -753,7 +650,7 @@ def build_datasets_get_request(name: str, version: str, **kwargs: Any) -> HttpRe _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -777,7 +674,7 @@ def build_datasets_get_request(name: str, version: str, **kwargs: Any) -> HttpRe def build_datasets_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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL _url = "/datasets/{name}/versions/{version}" path_format_arguments = { @@ -798,7 +695,7 @@ def build_datasets_create_or_update_request(name: str, version: str, **kwargs: A _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -826,7 +723,7 @@ def build_datasets_pending_upload_request(name: str, version: str, **kwargs: Any _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -853,7 +750,7 @@ def build_datasets_get_credentials_request(name: str, version: str, **kwargs: An _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -874,11 +771,66 @@ def build_datasets_get_credentials_request(name: str, version: str, **kwargs: An return HttpRequest(method="POST", 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"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # 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) + + +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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _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 + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", 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 {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -902,7 +854,7 @@ def build_indexes_list_request(**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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -921,7 +873,7 @@ def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpReq _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -945,7 +897,7 @@ def build_indexes_get_request(name: str, version: str, **kwargs: Any) -> HttpReq 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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL _url = "/indexes/{name}/versions/{version}" path_format_arguments = { @@ -966,7 +918,7 @@ def build_indexes_create_or_update_request(name: str, version: str, **kwargs: An _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -989,15 +941,17 @@ def build_indexes_create_or_update_request(name: str, version: str, **kwargs: An return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/deployments/{name}" + _url = "/evaluationtaxonomies/{name}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), } @@ -1008,247 +962,27 @@ def build_deployments_get_request(name: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_deployments_list_request( +def build_beta_evaluation_taxonomies_list_request( # pylint: disable=name-too-long *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + input_name: Optional[str] = None, + input_type: Optional[str] = None, **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_red_teams_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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/redTeams/runs/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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) - - -def build_red_teams_list_request(**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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/redTeams/runs" - - # 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) - - -def build_red_teams_create_request(**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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/redTeams/runs:run" - - # 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_evaluation_rules_get_request(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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluationrules/{id}" - path_format_arguments = { - "id": _SERIALIZER.url("id", 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 - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_evaluation_rules_delete_request(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", "2025-11-15-preview")) - # Construct URL - _url = "/evaluationrules/{id}" - path_format_arguments = { - "id": _SERIALIZER.url("id", 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 - - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_evaluation_rules_create_or_update_request( # pylint: disable=name-too-long - 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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluationrules/{id}" - path_format_arguments = { - "id": _SERIALIZER.url("id", 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 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="PUT", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_evaluation_rules_list_request( - *, - action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluationrules" - - # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if action_type is not None: - _params["actionType"] = _SERIALIZER.query("action_type", action_type, "str") - if agent_name is not None: - _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") - if enabled is not None: - _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") - - # Construct headers - _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - - -def build_evaluation_taxonomies_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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluationtaxonomies/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore - - # 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) - - -def build_evaluation_taxonomies_list_request( - *, input_name: Optional[str] = None, input_type: Optional[str] = None, **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", "2025-11-15-preview")) - accept = _headers.pop("Accept", "application/json") - - # Construct URL - _url = "/evaluationtaxonomies" + _url = "/evaluationtaxonomies" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -1258,18 +992,19 @@ def build_evaluation_taxonomies_list_request( _params["inputType"] = _SERIALIZER.query("input_type", input_type, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluation_taxonomies_delete_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_evaluation_taxonomies_delete_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL _url = "/evaluationtaxonomies/{name}" path_format_arguments = { @@ -1282,18 +1017,19 @@ def build_evaluation_taxonomies_delete_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluation_taxonomies_create_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_evaluation_taxonomies_create_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1308,6 +1044,7 @@ def build_evaluation_taxonomies_create_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1315,14 +1052,14 @@ def build_evaluation_taxonomies_create_request( # pylint: disable=name-too-long return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluation_taxonomies_update_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_evaluation_taxonomies_update_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1337,6 +1074,7 @@ def build_evaluation_taxonomies_update_request( # pylint: disable=name-too-long _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1344,9 +1082,10 @@ def build_evaluation_taxonomies_update_request( # pylint: disable=name-too-long return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_list_versions_request( +def build_beta_evaluators_list_versions_request( # pylint: disable=name-too-long name: str, *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, **kwargs: Any @@ -1354,7 +1093,7 @@ def build_evaluators_list_versions_request( _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1373,13 +1112,15 @@ def build_evaluators_list_versions_request( _params["limit"] = _SERIALIZER.query("limit", limit, "int") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_list_latest_versions_request( # pylint: disable=name-too-long +def build_beta_evaluators_list_latest_versions_request( # pylint: disable=name-too-long *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, **kwargs: Any @@ -1387,7 +1128,7 @@ def build_evaluators_list_latest_versions_request( # pylint: disable=name-too-l _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1401,16 +1142,23 @@ def build_evaluators_list_latest_versions_request( # pylint: disable=name-too-l _params["limit"] = _SERIALIZER.query("limit", limit, "int") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") 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_beta_evaluators_get_version_request( # pylint: disable=name-too-long + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1426,15 +1174,23 @@ def build_evaluators_get_version_request(name: str, version: str, **kwargs: Any) _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_delete_version_request(name: str, version: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_delete_version_request( # pylint: disable=name-too-long + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { @@ -1447,15 +1203,20 @@ 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["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_evaluators_create_version_request(name: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_create_version_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1470,6 +1231,7 @@ def build_evaluators_create_version_request(name: str, **kwargs: Any) -> HttpReq _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1477,12 +1239,18 @@ def build_evaluators_create_version_request(name: str, **kwargs: Any) -> HttpReq 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_beta_evaluators_update_version_request( # pylint: disable=name-too-long + name: str, + version: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW], + **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1498,6 +1266,7 @@ def build_evaluators_update_version_request(name: str, version: str, **kwargs: A _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1505,12 +1274,14 @@ def build_evaluators_update_version_request(name: str, version: str, **kwargs: A return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_insights_generate_request(**kwargs: Any) -> HttpRequest: +def build_beta_insights_generate_request( + *, foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1520,6 +1291,7 @@ def build_insights_generate_request(**kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") if "Repeatability-Request-ID" not in _headers: _headers["Repeatability-Request-ID"] = str(uuid.uuid4()) if "Repeatability-First-Sent" not in _headers: @@ -1533,11 +1305,17 @@ def build_insights_generate_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_insights_get_request(id: str, *, include_coordinates: Optional[bool] = None, **kwargs: Any) -> HttpRequest: +def build_beta_insights_get_request( + id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW], + include_coordinates: Optional[bool] = None, + **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1554,13 +1332,15 @@ def build_insights_get_request(id: str, *, include_coordinates: Optional[bool] = _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_insights_list_request( +def build_beta_insights_list_request( *, + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW], type: Optional[Union[str, _models.InsightType]] = None, eval_id: Optional[str] = None, run_id: Optional[str] = None, @@ -1571,7 +1351,7 @@ def build_insights_list_request( _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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -1591,43 +1371,51 @@ def build_insights_list_request( _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_schedules_delete_request(id: str, **kwargs: Any) -> HttpRequest: +def build_beta_memory_stores_create_request( + *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **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", "2025-11-15-preview")) - # Construct URL - _url = "/schedules/{id}" - path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), - } + 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") - _url: str = _url.format(**path_format_arguments) # type: ignore + # Construct URL + _url = "/memory_stores" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "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="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_schedules_get_request(id: str, **kwargs: Any) -> HttpRequest: +def build_beta_memory_stores_update_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **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", "2025-11-15-preview")) + 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 = "/schedules/{id}" + _url = "/memory_stores/{name}" path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1636,42 +1424,118 @@ def build_schedules_get_request(id: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "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_schedules_list_request(**kwargs: Any) -> HttpRequest: +def build_beta_memory_stores_get_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/schedules" - + _url = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_list_request( + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + 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 {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores" + # 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 + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_schedules_create_or_update_request(id: str, **kwargs: Any) -> HttpRequest: +def build_beta_memory_stores_delete_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **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 = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_search_memories_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **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", "2025-11-15-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/schedules/{id}" + _url = "/memory_stores/{name}:search_memories" path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1680,25 +1544,28 @@ def build_schedules_create_or_update_request(id: str, **kwargs: Any) -> HttpRequ _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_schedules_get_run_request(schedule_id: str, run_id: str, **kwargs: Any) -> HttpRequest: +def build_beta_memory_stores_update_memories_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **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", "2025-11-15-preview")) + 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 = "/schedules/{scheduleId}/runs/{runId}" + _url = "/memory_stores/{name}:update_memories" path_format_arguments = { - "scheduleId": _SERIALIZER.url("schedule_id", schedule_id, "str"), - "runId": _SERIALIZER.url("run_id", run_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1707,22 +1574,28 @@ def build_schedules_get_run_request(schedule_id: str, run_id: str, **kwargs: Any _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "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_schedules_list_runs_request(id: str, **kwargs: Any) -> HttpRequest: +def build_beta_memory_stores_delete_scope_request( # pylint: disable=name-too-long + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], **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", "2025-11-15-preview")) + 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 = "/schedules/{id}/runs" + _url = "/memory_stores/{name}:delete_scope" path_format_arguments = { - "id": _SERIALIZER.url("id", id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1731,194 +1604,317 @@ def build_schedules_list_runs_request(id: str, **kwargs: Any) -> HttpRequest: _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "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) -class AgentsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. +def build_beta_red_teams_get_request( + name: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`agents` attribute. - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") - 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") + # Construct URL + _url = "/redTeams/runs/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } - @distributed_trace - def get(self, agent_name: str, **kwargs: Any) -> _models.AgentDetails: - """Retrieves the agent. + _url: str = _url.format(**path_format_arguments) # type: ignore - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - cls: ClsType[_models.AgentDetails] = kwargs.pop("cls", None) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - _request = build_agents_get_request( - 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) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) +def build_beta_red_teams_list_request( + *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - response = pipeline_response.http_response + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") - 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) + # Construct URL + _url = "/redTeams/runs" - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.AgentDetails, response.json()) + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return deserialized # type: ignore + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - @overload - def create( - self, - *, - name: str, - definition: _models.AgentDefinition, - content_type: str = "application/json", - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> _models.AgentDetails: - """Creates the agent. - :keyword name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. +def build_beta_red_teams_create_request( + *, foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :paramtype name: str - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :paramtype definition: ~azure.ai.projects.models.AgentDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. + 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") - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + # Construct URL + _url = "/redTeams/runs:run" - @overload - def create(self, body: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentDetails: - """Creates the agent. + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - @overload - def create(self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.AgentDetails: - """Creates the agent. + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - :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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - @distributed_trace - def create( - self, - body: Union[JSON, IO[bytes]] = _Unset, - *, - name: str = _Unset, - definition: _models.AgentDefinition = _Unset, - metadata: Optional[dict[str, str]] = None, - description: Optional[str] = None, - **kwargs: Any - ) -> _models.AgentDetails: - """Creates the agent. +def build_beta_schedules_delete_request( + id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + # Construct URL + _url = "/schedules/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("id", id, "str"), + } - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :paramtype name: str - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :paramtype definition: ~azure.ai.projects.models.AgentDefinition - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. + _url: str = _url.format(**path_format_arguments) # type: ignore - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_get_request( + id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **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 = "/schedules/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("id", 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 + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_list_request( + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[Union[str, _models.ScheduleTaskType]] = None, + enabled: Optional[bool] = None, + **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 = "/schedules" + + # 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 enabled is not None: + _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_create_or_update_request( # pylint: disable=name-too-long + id: str, *, foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], **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 = "/schedules/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("id", 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 + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "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="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_get_run_request( + schedule_id: str, + run_id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + **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 = "/schedules/{schedule_id}/runs/{run_id}" + path_format_arguments = { + "schedule_id": _SERIALIZER.url("schedule_id", schedule_id, "str"), + "run_id": _SERIALIZER.url("run_id", run_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 + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_schedules_list_runs_request( + id: str, + *, + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW], + type: Optional[Union[str, _models.ScheduleTaskType]] = None, + enabled: Optional[bool] = None, + **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 = "/schedules/{id}/runs" + path_format_arguments = { + "id": _SERIALIZER.url("id", 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 enabled is not None: + _params["enabled"] = _SERIALIZER.query("enabled", enabled, "bool") + + # Construct headers + _headers["Foundry-Features"] = _SERIALIZER.header("foundry_features", foundry_features, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class BetaOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`beta` 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") + + self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.evaluators = BetaEvaluatorsOperations(self._client, self._config, self._serialize, self._deserialize) + self.insights = BetaInsightsOperations(self._client, self._config, self._serialize, self._deserialize) + self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) + self.red_teams = BetaRedTeamsOperations(self._client, self._config, self._serialize, self._deserialize) + self.schedules = BetaSchedulesOperations(self._client, self._config, self._serialize, self._deserialize) + + +class AgentsOperations: + """ + .. 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 get(self, agent_name: str, **kwargs: Any) -> _models.AgentDetails: + """Retrieves the agent. + + :param agent_name: The name of the agent to retrieve. Required. + :type agent_name: str :return: AgentDetails. The AgentDetails is compatible with MutableMapping :rtype: ~azure.ai.projects.models.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: @@ -1931,30 +1927,14 @@ def create( } 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.AgentDetails] = kwargs.pop("cls", None) - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata, "name": name} - 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_agents_create_request( - content_type=content_type, + _request = build_agents_get_request( + agent_name=agent_name, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -1994,28 +1974,95 @@ def create( return deserialized # type: ignore @overload - def update( + def _create_agent( self, - agent_name: str, *, + name: str, definition: _models.AgentDefinition, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, content_type: str = "application/json", metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. + ) -> _models.AgentDetails: ... + @overload + def _create_agent( + self, + body: JSON, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... + @overload + def _create_agent( + self, + body: IO[bytes], + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... - :param agent_name: The name of the agent to retrieve. Required. - :type agent_name: str - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. - :paramtype definition: ~azure.ai.projects.models.AgentDefinition - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be + @distributed_trace + def _create_agent( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: str = _Unset, + definition: _models.AgentDefinition = _Unset, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> _models.AgentDetails: + """Creates the agent. + + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: The unique name that identifies the agent. Name can be used to + retrieve/update/delete the agent. + + * Must start and end with alphanumeric characters, + * Can contain hyphens in the middle + * Must not exceed 63 characters. Required. + :paramtype name: str + :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple + agent definition. Required. + :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW + :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. @@ -2028,58 +2075,148 @@ def update( :rtype: ~azure.ai.projects.models.AgentDetails :raises ~azure.core.exceptions.HttpResponseError: """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def update( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - :param agent_name: The name of the agent to retrieve. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentDetails] = kwargs.pop("cls", None) - @overload - def update( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata, "name": name} + 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 - :param agent_name: The name of the agent to retrieve. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + _request = build_agents_create_agent_request( + foundry_features=foundry_features, + 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) + + _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() + else: + deserialized = _deserialize(_models.AgentDetails, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def _update_agent( + self, + agent_name: str, + *, + definition: _models.AgentDefinition, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + metadata: Optional[dict[str, str]] = None, + description: Optional[str] = None, + **kwargs: Any + ) -> _models.AgentDetails: ... + @overload + def _update_agent( + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... + @overload + def _update_agent( + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AgentDetails: ... @distributed_trace - def update( + def _update_agent( self, agent_name: str, body: Union[JSON, IO[bytes]] = _Unset, *, definition: _models.AgentDefinition = _Unset, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any ) -> _models.AgentDetails: - """Updates the agent by adding a new version if there are any changes to the agent definition. - If no changes, returns the existing agent version. + """Updates the agent by adding a new version if there are any changes to the agent definition. If + no changes, returns the existing agent version. :param agent_name: The name of the agent to retrieve. Required. :type agent_name: str @@ -2088,6 +2225,14 @@ def update( :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. @@ -2127,8 +2272,9 @@ def update( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_update_request( + _request = build_agents_update_agent_request( agent_name=agent_name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -2171,7 +2317,7 @@ def update( return deserialized # type: ignore @overload - def create_from_manifest( + def _create_agent_from_manifest( self, *, name: str, @@ -2181,72 +2327,18 @@ def create_from_manifest( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any - ) -> _models.AgentDetails: - """Creates an agent from a manifest. - - :keyword name: The unique name that identifies the agent. Name can be used to - retrieve/update/delete the agent. - - * Must start and end with alphanumeric characters, - * Can contain hyphens in the middle - * Must not exceed 63 characters. Required. - :paramtype name: str - :keyword manifest_id: The manifest ID to import the agent version from. Required. - :paramtype manifest_id: str - :keyword parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :paramtype parameter_values: dict[str, any] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - def create_from_manifest( + def _create_agent_from_manifest( self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Creates an agent from a manifest. - - :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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - def create_from_manifest( + def _create_agent_from_manifest( self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Creates an agent from a manifest. - - :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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> _models.AgentDetails: ... @distributed_trace - def create_from_manifest( + def _create_agent_from_manifest( self, body: Union[JSON, IO[bytes]] = _Unset, *, @@ -2322,7 +2414,7 @@ def create_from_manifest( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_create_from_manifest_request( + _request = build_agents_create_agent_from_manifest_request( content_type=content_type, api_version=self._config.api_version, content=_content, @@ -2365,7 +2457,7 @@ def create_from_manifest( return deserialized # type: ignore @overload - def update_from_manifest( + def _update_agent_from_manifest( self, agent_name: str, *, @@ -2375,77 +2467,18 @@ def update_from_manifest( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_name: str - :keyword manifest_id: The manifest ID to import the agent version from. Required. - :paramtype manifest_id: str - :keyword parameter_values: The inputs to the manifest that will result in a fully materialized - Agent. Required. - :paramtype parameter_values: dict[str, any] - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be - useful for storing additional information about the object in a structured - format, and querying for objects via API or the dashboard. - - Keys are strings with a maximum length of 64 characters. Values are strings - with a maximum length of 512 characters. Default value is None. - :paramtype metadata: dict[str, str] - :keyword description: A human-readable description of the agent. Default value is None. - :paramtype description: str - :return: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - def update_from_manifest( + def _update_agent_from_manifest( self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ - + ) -> _models.AgentDetails: ... @overload - def update_from_manifest( + def _update_agent_from_manifest( self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.AgentDetails: - """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. - - :param agent_name: The name of the agent to update. Required. - :type agent_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: AgentDetails. The AgentDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.AgentDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + ) -> _models.AgentDetails: ... @distributed_trace - def update_from_manifest( + def _update_agent_from_manifest( self, agent_name: str, body: Union[JSON, IO[bytes]] = _Unset, @@ -2457,8 +2490,7 @@ def update_from_manifest( **kwargs: Any ) -> _models.AgentDetails: """Updates the agent from a manifest by adding a new version if there are any changes to the agent - definition. - If no changes, returns the existing agent version. + definition. If no changes, returns the existing agent version. :param agent_name: The name of the agent to update. Required. :type agent_name: str @@ -2515,7 +2547,7 @@ def update_from_manifest( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_update_from_manifest_request( + _request = build_agents_update_agent_from_manifest_request( agent_name=agent_name, content_type=content_type, api_version=self._config.api_version, @@ -2720,6 +2752,13 @@ def create_version( agent_name: str, *, definition: _models.AgentDefinition, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, content_type: str = "application/json", metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, @@ -2737,6 +2776,14 @@ def create_version( :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2756,7 +2803,19 @@ def create_version( @overload def create_version( - self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + agent_name: str, + body: JSON, + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AgentVersionDetails: """Create a new agent version. @@ -2769,6 +2828,14 @@ def create_version( :type agent_name: str :param body: Required. :type body: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -2779,7 +2846,19 @@ def create_version( @overload def create_version( - self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, + agent_name: str, + body: IO[bytes], + *, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, + content_type: str = "application/json", + **kwargs: Any ) -> _models.AgentVersionDetails: """Create a new agent version. @@ -2792,6 +2871,14 @@ def create_version( :type agent_name: str :param body: Required. :type body: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -2807,6 +2894,13 @@ def create_version( body: Union[JSON, IO[bytes]] = _Unset, *, definition: _models.AgentDefinition = _Unset, + foundry_features: Optional[ + Union[ + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW], + ] + ] = None, metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, **kwargs: Any @@ -2825,6 +2919,14 @@ def create_version( :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. Is one of the following types: + Literal[FoundryFeaturesOptInKeys.CONTAINER_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.HOSTED_AGENTS_V1_PREVIEW], + Literal[FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW] Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.CONTAINER_AGENTS_V1_PREVIEW or + str or ~azure.ai.projects.models.HOSTED_AGENTS_V1_PREVIEW or str or + ~azure.ai.projects.models.WORKFLOW_AGENTS_V1_PREVIEW :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard. @@ -2866,6 +2968,7 @@ def create_version( _request = build_agents_create_version_request( agent_name=agent_name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -3339,58 +3442,32 @@ def get_next(_continuation_token=None): return ItemPaged(get_next, extract_data) + +class EvaluationRulesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`evaluation_rules` 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 stream_agent_container_logs( # pylint: disable=inconsistent-return-statements - self, - agent_name: str, - agent_version: str, - *, - kind: Optional[Union[str, _models.ContainerLogKind]] = None, - replica_name: Optional[str] = None, - tail: Optional[int] = None, - **kwargs: Any - ) -> None: - """Container log entry streamed from the container as text chunks. - Each chunk is a UTF-8 string that may be either a plain text log line - or a JSON-formatted log entry, depending on the type of container log being streamed. - Clients should treat each chunk as opaque text and, if needed, attempt - to parse it as JSON based on their logging requirements. - - For system logs, the format is JSON with the following structure: - {"TimeStamp":"2025-12-15T16:51:33Z","Type":"Normal","ContainerAppName":null,"RevisionName":null,"ReplicaName":null,"Msg":"Connecting - to the events - collector...","Reason":"StartingGettingEvents","EventSource":"ContainerAppController","Count":1} - {"TimeStamp":"2025-12-15T16:51:34Z","Type":"Normal","ContainerAppName":null,"RevisionName":null,"ReplicaName":null,"Msg":"Successfully - connected to events - server","Reason":"ConnectedToEventsServer","EventSource":"ContainerAppController","Count":1} - - For console logs, the format is plain text as emitted by the container's stdout/stderr. - 2025-12-15T08:43:48.72656 Connecting to the container 'agent-container'... - 2025-12-15T08:43:48.75451 Successfully Connected to container: 'agent-container' [Revision: - 'je90fe655aa742ef9a188b9fd14d6764--7tca06b', Replica: - 'je90fe655aa742ef9a188b9fd14d6764--7tca06b-6898b9c89f-mpkjc'] - 2025-12-15T08:33:59.0671054Z stdout F INFO: 127.0.0.1:42588 - "GET /readiness HTTP/1.1" 200 - OK - 2025-12-15T08:34:29.0649033Z stdout F INFO: 127.0.0.1:60246 - "GET /readiness HTTP/1.1" 200 - OK - 2025-12-15T08:34:59.0644467Z stdout F INFO: 127.0.0.1:43994 - "GET /readiness HTTP/1.1" 200 - OK. - - :param agent_name: The name of the agent. Required. - :type agent_name: str - :param agent_version: The version of the agent. Required. - :type agent_version: str - :keyword kind: console returns container stdout/stderr, system returns container app event - stream. defaults to console. Known values are: "console" and "system". Default value is None. - :paramtype kind: str or ~azure.ai.projects.models.ContainerLogKind - :keyword replica_name: When omitted, the server chooses the first replica for console logs. - Required to target a specific replica. Default value is None. - :paramtype replica_name: str - :keyword tail: Number of trailing lines returned. Enforced to 1-300. Defaults to 20. Default - value is None. - :paramtype tail: int - :return: None - :rtype: None + def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: + """Get an evaluation rule. + + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3404,14 +3481,10 @@ def stream_agent_container_logs( # pylint: disable=inconsistent-return-statemen _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - _request = build_agents_stream_agent_container_logs_request( - agent_name=agent_name, - agent_version=agent_version, - kind=kind, - replica_name=replica_name, - tail=tail, + _request = build_evaluation_rules_get_request( + id=id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3421,7 +3494,7 @@ def stream_agent_container_logs( # pylint: disable=inconsistent-return-statemen } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) @@ -3429,122 +3502,174 @@ def stream_agent_container_logs( # pylint: disable=inconsistent-return-statemen 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) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.EvaluationRule, response.json()) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized # type: ignore -class MemoryStoresOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @distributed_trace + def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete an evaluation rule. - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`memory_stores` attribute. - """ + :param id: Unique identifier for the evaluation rule. Required. + :type id: 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 __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") + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_evaluation_rules_delete_request( + id=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) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore @overload - def create( + def create_or_update( self, + id: str, + evaluation_rule: _models.EvaluationRule, *, - name: str, - definition: _models.MemoryStoreDefinition, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :keyword name: The name of the memory store. Required. - :paramtype name: str - :keyword definition: The memory store definition. Required. - :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create( - self, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. + def create_or_update( + self, + id: str, + evaluation_rule: JSON, + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :param body: Required. - :type body: JSON + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: JSON + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create( - self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. + def create_or_update( + self, + id: str, + evaluation_rule: IO[bytes], + *, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :param body: Required. - :type body: IO[bytes] + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create( + def create_or_update( self, - body: Union[JSON, IO[bytes]] = _Unset, + id: str, + evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], *, - name: str = _Unset, - definition: _models.MemoryStoreDefinition = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, + foundry_features: Optional[Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW]] = None, **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Create a memory store. + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword name: The name of the memory store. Required. - :paramtype name: str - :keyword definition: The memory store definition. Required. - :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition - :keyword description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Is one of the following types: + EvaluationRule, JSON, IO[bytes] Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] + :keyword foundry_features: A feature flag opt-in required when using preview operations or + modifying persisted preview resources. EVALUATIONS_V1_PREVIEW. Default value is None. + :paramtype foundry_features: str or ~azure.ai.projects.models.EVALUATIONS_V1_PREVIEW + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3559,23 +3684,18 @@ def create( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - if body is _Unset: - if name is _Unset: - raise TypeError("missing required argument: name") - if definition is _Unset: - raise TypeError("missing required argument: definition") - body = {"definition": definition, "description": description, "metadata": metadata, "name": name} - 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(evaluation_rule, (IOBase, bytes)): + _content = evaluation_rule else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_memory_stores_create_request( + _request = build_evaluation_rules_create_or_update_request( + id=id, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -3594,115 +3714,150 @@ def create( 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() else: - deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) + deserialized = _deserialize(_models.EvaluationRule, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def update( + @distributed_trace + def list( self, - name: str, *, - content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, + action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, + agent_name: Optional[str] = None, + enabled: Optional[bool] = None, **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + ) -> ItemPaged["_models.EvaluationRule"]: + """List all evaluation rules. - :param name: The name of the memory store to update. Required. - :type 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 description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :keyword action_type: Filter by the type of evaluation rule. Known values are: + "continuousEvaluation" and "humanEvaluationPreview". Default value is None. + :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of EvaluationRule + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluationRule] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def update( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + cls: ClsType[List[_models.EvaluationRule]] = kwargs.pop("cls", None) - :param name: The name of the memory store 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: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def update( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + def prepare_request(next_link=None): + if not next_link: - :param name: The name of the memory store 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: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails - :raises ~azure.core.exceptions.HttpResponseError: - """ + _request = build_evaluation_rules_list_request( + action_type=action_type, + agent_name=agent_name, + enabled=enabled, + 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), 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) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.EvaluationRule], 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 ConnectionsOperations: + """ + .. 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 update( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - **kwargs: Any - ) -> _models.MemoryStoreDetails: - """Update a memory store. + def _get(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection by name, without populating connection credentials. - :param name: The name of the memory store to update. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword description: A human-readable description of the memory store. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default - value is None. - :paramtype metadata: dict[str, str] - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3713,27 +3868,14 @@ def update( } 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.MemoryStoreDetails] = kwargs.pop("cls", None) - - if body is _Unset: - body = {"description": description, "metadata": metadata} - 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 + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_memory_stores_update_request( + _request = build_connections_get_request( name=name, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -3756,30 +3898,31 @@ 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) + + 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() else: - deserialized = _deserialize(_models.MemoryStoreDetails, 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 @distributed_trace - def get(self, name: str, **kwargs: Any) -> _models.MemoryStoreDetails: - """Retrieve a memory store. + def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection by name, with its connection credentials. - :param name: The name of the memory store to retrieve. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3793,9 +3936,9 @@ def get(self, name: str, **kwargs: Any) -> _models.MemoryStoreDetails: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_memory_stores_get_request( + _request = build_connections_get_with_credentials_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -3820,19 +3963,20 @@ def get(self, name: str, **kwargs: Any) -> _models.MemoryStoreDetails: 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) + + 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() else: - deserialized = _deserialize(_models.MemoryStoreDetails, 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 @@ -3840,35 +3984,27 @@ def get(self, name: str, **kwargs: Any) -> _models.MemoryStoreDetails: def list( self, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, + connection_type: Optional[Union[str, _models.ConnectionType]] = None, + default_connection: Optional[bool] = None, **kwargs: Any - ) -> ItemPaged["_models.MemoryStoreDetails"]: - """List all memory stores. + ) -> ItemPaged["_models.Connection"]: + """List all connections in the project, without populating connection credentials. - :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 MemoryStoreDetails - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.MemoryStoreDetails] + :keyword connection_type: List connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. + :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType + :keyword default_connection: List 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 {} - cls: ClsType[List[_models.MemoryStoreDetails]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3878,32 +4014,54 @@ 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_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) + + 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), 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_memory_stores_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.MemoryStoreDetails], deserialized.get("data", [])) + list_of_elem = _deserialize(List[_models.Connection], 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 @@ -3913,26 +4071,45 @@ 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) + +class DatasetsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`datasets` 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(self, name: str, **kwargs: Any) -> _models.DeleteMemoryStoreResult: - """Delete a memory store. + def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: + """List all versions of the given DatasetVersion. - :param name: The name of the memory store to delete. Required. + :param name: The name of the resource. Required. :type name: str - :return: DeleteMemoryStoreResult. The DeleteMemoryStoreResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DeleteMemoryStoreResult + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3941,152 +4118,161 @@ def delete(self, name: str, **kwargs: Any) -> _models.DeleteMemoryStoreResult: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[_models.DeleteMemoryStoreResult] = kwargs.pop("cls", None) + _request = build_datasets_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) - _request = build_memory_stores_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) + 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), 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) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DatasetVersion], deserialized.get("value", [])) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) - 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 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 ) - raise HttpResponseError(response=response, model=error) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.DeleteMemoryStoreResult, response.json()) + 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, deserialized, {}) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) - @overload - def search_memories( - self, - name: str, - *, - scope: str, - content_type: str = "application/json", - items: Optional[List[_models.InputItem]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_models.MemorySearchOptions] = None, - **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: + """List the latest version of each DatasetVersion. - :param name: The name of the memory store to search. Required. - :type name: str - :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :paramtype scope: str - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :keyword items: Items for which to search for relevant memories. Default value is None. - :paramtype items: list[~azure.ai.projects.models.InputItem] - :keyword previous_search_id: The unique ID of the previous search request, enabling incremental - memory search from where the last operation left off. Default value is None. - :paramtype previous_search_id: str - :keyword options: Memory search options. Default value is None. - :paramtype options: ~azure.ai.projects.models.MemorySearchOptions - :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def search_memories( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. + cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) - :param name: The name of the memory store to search. 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: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def search_memories( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. + def prepare_request(next_link=None): + if not next_link: - :param name: The name of the memory store to search. 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: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult - :raises ~azure.core.exceptions.HttpResponseError: - """ + _request = build_datasets_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), 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) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize(List[_models.DatasetVersion], 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) @distributed_trace - def search_memories( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - scope: str = _Unset, - items: Optional[List[_models.InputItem]] = None, - previous_search_id: Optional[str] = None, - options: Optional[_models.MemorySearchOptions] = None, - **kwargs: Any - ) -> _models.MemoryStoreSearchResult: - """Search for relevant memories from a memory store based on conversation context. + def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: + """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the + DatasetVersion does not exist. - :param name: The name of the memory store to search. 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 scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :paramtype scope: str - :keyword items: Items for which to search for relevant memories. Default value is None. - :paramtype items: list[~azure.ai.projects.models.InputItem] - :keyword previous_search_id: The unique ID of the previous search request, enabling incremental - memory search from where the last operation left off. Default value is None. - :paramtype previous_search_id: str - :keyword options: Memory search options. Default value is None. - :paramtype options: ~azure.ai.projects.models.MemorySearchOptions - :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult + :param version: The specific version id of the DatasetVersion to retrieve. Required. + :type version: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4097,34 +4283,15 @@ def search_memories( } 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.MemoryStoreSearchResult] = kwargs.pop("cls", None) - - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = { - "items": items, - "options": options, - "previous_search_id": previous_search_id, - "scope": scope, - } - 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 + cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) - _request = build_memory_stores_search_memories_request( + _request = build_datasets_get_request( name=name, - content_type=content_type, + version=version, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -4147,33 +4314,31 @@ def search_memories( 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() else: - deserialized = _deserialize(_models.MemoryStoreSearchResult, response.json()) + deserialized = _deserialize(_models.DatasetVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - def _update_memories_initial( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - scope: str = _Unset, - items: Optional[List[_models.InputItem]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, - **kwargs: Any - ) -> Iterator[bytes]: + @distributed_trace + def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the + DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the DatasetVersion to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4182,34 +4347,15 @@ def _update_memories_initial( } 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[Iterator[bytes]] = kwargs.pop("cls", None) - - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = { - "items": items, - "previous_update_id": previous_update_id, - "scope": scope, - "update_delay": update_delay, - } - 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 + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_memory_stores_update_memories_request( + _request = build_datasets_delete_request( name=name, - content_type=content_type, + version=version, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -4218,228 +4364,274 @@ def _update_memories_initial( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = True + _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 [202]: - 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, - response, - ) - raise HttpResponseError(response=response, model=error) - - response_headers = {} - response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) - - deserialized = response.iter_bytes() + raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @overload - def _begin_update_memories( + def create_or_update( self, name: str, + version: str, + dataset_version: _models.DatasetVersion, *, - scope: str, - content_type: str = "application/json", - items: Optional[List[_models.InputItem]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: ... - @overload - def _begin_update_memories( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion + :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: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload - def _begin_update_memories( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + def create_or_update( + self, + name: str, + version: str, + dataset_version: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. - @distributed_trace - def _begin_update_memories( + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: 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: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( self, name: str, - body: Union[JSON, IO[bytes]] = _Unset, + version: str, + dataset_version: IO[bytes], *, - scope: str = _Unset, - items: Optional[List[_models.InputItem]] = None, - previous_update_id: Optional[str] = None, - update_delay: Optional[int] = None, + content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: - """Update memory store with conversation memories. + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. - :param name: The name of the memory store 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 scope: The namespace that logically groups and isolates memories, such as a user ID. - Required. - :paramtype scope: str - :keyword items: Conversation items from which to extract memories. Default value is None. - :paramtype items: list[~azure.ai.projects.models.InputItem] - :keyword previous_update_id: The unique ID of the previous update request, enabling incremental - memory updates from where the last operation left off. Default value is None. - :paramtype previous_update_id: str - :keyword update_delay: Timeout period before processing the memory update in seconds. - If a new update request is received during this period, it will cancel the current request and - reset the timeout. - Set to 0 to immediately trigger the update without delay. - Defaults to 300 (5 minutes). Default value is None. - :paramtype update_delay: int - :return: An instance of LROPoller that returns MemoryStoreUpdateCompletedResult. The - MemoryStoreUpdateCompletedResult is compatible with MutableMapping - :rtype: - ~azure.core.polling.LROPoller[~azure.ai.projects.models.MemoryStoreUpdateCompletedResult] + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: 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: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.DatasetVersion: + """Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Is one of the following types: + DatasetVersion, JSON, IO[bytes] Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion :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.MemoryStoreUpdateCompletedResult] = 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._update_memories_initial( - name=name, - body=body, - scope=scope, - items=items, - previous_update_id=previous_update_id, - update_delay=update_delay, - 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") - ) + cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) - deserialized = _deserialize(_models.MemoryStoreUpdateCompletedResult, response.json().get("result", {})) - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(dataset_version, (IOBase, bytes)): + _content = dataset_version + else: + _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _request = build_datasets_create_or_update_request( + name=name, + version=version, + 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) - 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.MemoryStoreUpdateCompletedResult].from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, - ) - return LROPoller[_models.MemoryStoreUpdateCompletedResult]( - self._client, raw_result, get_long_running_output, polling_method # type: ignore + _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, 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) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.DatasetVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + @overload - def delete_scope( - self, name: str, *, scope: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: _models.PendingUploadRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. Required. + :param name: The name of the resource. Required. :type name: str - :keyword scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :paramtype scope: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def delete_scope( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. 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 DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def delete_scope( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. 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 DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: 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: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def delete_scope( - self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, scope: str = _Unset, **kwargs: Any - ) -> _models.MemoryStoreDeleteScopeResult: - """Delete all memories associated with a specific scope from a memory store. + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a new or get an existing pending upload of a dataset for a specific version. - :param name: The name of the memory store. 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 scope: The namespace that logically groups and isolates memories to delete, such as a - user ID. Required. - :paramtype scope: str - :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with - MutableMapping - :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Is one of the following + types: PendingUploadRequest, JSON, IO[bytes] Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or + IO[bytes] + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4454,22 +4646,18 @@ def delete_scope( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) + cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) - if body is _Unset: - if scope is _Unset: - raise TypeError("missing required argument: scope") - body = {"scope": scope} - 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(pending_upload_request, (IOBase, bytes)): + _content = pending_upload_request else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_memory_stores_delete_scope_request( + _request = build_datasets_pending_upload_request( name=name, + version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -4495,48 +4683,28 @@ def delete_scope( 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() else: - deserialized = _deserialize(_models.MemoryStoreDeleteScopeResult, response.json()) + deserialized = _deserialize(_models.PendingUploadResponse, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class ConnectionsOperations: - """ - .. 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 _get(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection by name, without populating connection credentials. + def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: + """Get the SAS credential to access the storage account associated with a Dataset version. - :param name: The friendly name of the connection, provided by the user. Required. + :param name: The name of the resource. Required. :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetCredential :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4550,10 +4718,11 @@ def _get(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.DatasetCredential] = kwargs.pop("cls", None) - _request = build_connections_get_request( + _request = build_datasets_get_credentials_request( name=name, + version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4579,29 +4748,42 @@ def _get(self, name: str, **kwargs: Any) -> _models.Connection: 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() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.DatasetCredential, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class DeploymentsOperations: + """ + .. 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 _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection by name, with its connection credentials. + def get(self, name: str, **kwargs: Any) -> _models.Deployment: + """Get a deployed model. - :param name: The friendly name of the connection, provided by the user. Required. + :param name: Name of the deployment. Required. :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Deployment :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4615,9 +4797,9 @@ 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.Deployment] = kwargs.pop("cls", None) - _request = build_connections_get_with_credentials_request( + _request = build_deployments_get_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -4652,7 +4834,7 @@ def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.Deployment, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore @@ -4663,27 +4845,29 @@ def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: def list( self, *, - connection_type: Optional[Union[str, _models.ConnectionType]] = None, - default_connection: Optional[bool] = None, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[Union[str, _models.DeploymentType]] = None, **kwargs: Any - ) -> ItemPaged["_models.Connection"]: - """List all connections in the project, without populating connection credentials. + ) -> ItemPaged["_models.Deployment"]: + """List all deployed models in the project. - :keyword connection_type: List connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool". Default value is None. - :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType - :keyword default_connection: List 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] + :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 {} - cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4696,9 +4880,10 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, + _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, @@ -4734,7 +4919,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Connection], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Deployment], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -4757,14 +4942,14 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) -class DatasetsOperations: +class IndexesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`datasets` attribute. + :attr:`indexes` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -4775,19 +4960,19 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: - """List all versions of the given DatasetVersion. + def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: + """List all versions of the given Index. :param name: The name of the resource. Required. :type name: str - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] + :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.DatasetVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4800,7 +4985,7 @@ def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.DatasetV def prepare_request(next_link=None): if not next_link: - _request = build_datasets_list_versions_request( + _request = build_indexes_list_versions_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -4837,7 +5022,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.DatasetVersion], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -4860,17 +5045,17 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: - """List the latest version of each DatasetVersion. - - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] + def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: + """List the latest version of each Index. + + :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.DatasetVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4883,7 +5068,7 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: def prepare_request(next_link=None): if not next_link: - _request = build_datasets_list_request( + _request = build_indexes_list_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -4919,7 +5104,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.DatasetVersion], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -4942,16 +5127,16 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: - """Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the - DatasetVersion does not exist. + def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: + """Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. :param name: The name of the resource. Required. :type name: str - :param version: The specific version id of the DatasetVersion to retrieve. Required. + :param version: The specific version id of the Index to retrieve. Required. :type version: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4965,9 +5150,9 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - _request = build_datasets_get_request( + _request = build_indexes_get_request( name=name, version=version, api_version=self._config.api_version, @@ -4998,7 +5183,7 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5007,12 +5192,12 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: @distributed_trace def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete the specific version of the DatasetVersion. The service returns 204 No Content if the - DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + """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 name: The name of the resource. Required. :type name: str - :param version: The version of the DatasetVersion to delete. Required. + :param version: The version of the Index to delete. Required. :type version: str :return: None :rtype: None @@ -5031,7 +5216,7 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_datasets_delete_request( + _request = build_indexes_delete_request( name=name, version=version, api_version=self._config.api_version, @@ -5062,50 +5247,44 @@ def create_or_update( self, name: str, version: str, - dataset_version: _models.DatasetVersion, + index: _models.Index, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. + ) -> _models.Index: + """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 DatasetVersion to create or update. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion + :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: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion + :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, - dataset_version: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. + self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.Index: + """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 DatasetVersion to create or update. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: JSON + :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: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: """ @@ -5114,203 +5293,42 @@ def create_or_update( self, name: str, version: str, - dataset_version: IO[bytes], + index: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. + ) -> _models.Index: + """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 DatasetVersion to create or update. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: IO[bytes] + :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: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any - ) -> _models.DatasetVersion: - """Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Is one of the following types: - DatasetVersion, JSON, IO[bytes] Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :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.DatasetVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _content = None - if isinstance(dataset_version, (IOBase, bytes)): - _content = dataset_version - else: - _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - - _request = build_datasets_create_or_update_request( - name=name, - version=version, - 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) - - _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, 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) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: _models.PendingUploadRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: 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: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a new or get an existing pending upload of a dataset for a specific version. + """ + + @distributed_trace + def create_or_update( + self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Index: + """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 DatasetVersion to operate on. Required. + :param version: The specific version id of the Index to create or update. Required. :type version: str - :param pending_upload_request: The pending upload request parameters. Is one of the following - types: PendingUploadRequest, JSON, IO[bytes] Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or - IO[bytes] - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :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 = { @@ -5325,16 +5343,16 @@ def pending_upload( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(pending_upload_request, (IOBase, bytes)): - _content = pending_upload_request + if isinstance(index, (IOBase, bytes)): + _content = index else: - _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_datasets_pending_upload_request( + _request = build_indexes_create_or_update_request( name=name, version=version, content_type=content_type, @@ -5355,7 +5373,7 @@ def pending_upload( 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 @@ -5367,25 +5385,44 @@ def pending_upload( if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.PendingUploadResponse, response.json()) + deserialized = _deserialize(_models.Index, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class BetaEvaluationTaxonomiesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`evaluation_taxonomies` 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_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: - """Get the SAS credential to access the storage account associated with a Dataset version. + def get(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: + """Get an evaluation run by name. :param name: The name of the resource. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetCredential + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5397,11 +5434,11 @@ def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.Dat _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.DatasetCredential] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) - _request = build_datasets_get_credentials_request( + _request = build_beta_evaluation_taxonomies_get_request( name=name, - version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5430,45 +5467,34 @@ def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.Dat if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.DatasetCredential, response.json()) + deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class IndexesOperations: - """ - .. 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 list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: - """List all versions of the given Index. + def list( + self, *, input_name: Optional[str] = None, input_type: Optional[str] = None, **kwargs: Any + ) -> ItemPaged["_models.EvaluationTaxonomy"]: + """List evaluation taxonomies. - :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] + :keyword input_name: Filter by the evaluation input name. Default value is None. + :paramtype input_name: str + :keyword input_type: Filter by taxonomy input type. Default value is None. + :paramtype input_type: str + :return: An iterator like instance of EvaluationTaxonomy + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluationTaxonomy] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluationTaxonomy]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5481,8 +5507,10 @@ def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: def prepare_request(next_link=None): if not next_link: - _request = build_indexes_list_versions_request( - name=name, + _request = build_beta_evaluation_taxonomies_list_request( + foundry_features=foundry_features, + input_name=input_name, + input_type=input_type, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5518,7 +5546,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Index], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.EvaluationTaxonomy], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -5541,18 +5569,18 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: - """List the latest version of each Index. + def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete an evaluation taxonomy by name. - :return: An iterator like instance of Index - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] + :param name: The name of the resource. Required. + :type name: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) - + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5561,80 +5589,109 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: } 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_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) + 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), 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_beta_evaluation_taxonomies_delete_request( + name=name, + foundry_features=foundry_features, + 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.Index], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + response = pipeline_response.http_response - def get_next(next_link=None): - _request = prepare_request(next_link) + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - _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, None, {}) # 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) + @overload + def create( + self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. - return pipeline_response + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.projects.models.EvaluationTaxonomy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + """ - return ItemPaged(get_next, extract_data) + @overload + def create( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. - @distributed_trace - def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: - """Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. 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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. Required. + :type name: str + :param body: The evaluation taxonomy. 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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param name: The name of the resource. Required. + @distributed_trace + def create( + self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Create an evaluation taxonomy. + + :param name: The name of the evaluation taxonomy. 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 body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, JSON, + IO[bytes] Required. + :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5643,15 +5700,25 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: } 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.Index] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) - _request = build_indexes_get_request( + 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_beta_evaluation_taxonomies_create_request( name=name, - version=version, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -5667,7 +5734,7 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: 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 @@ -5679,154 +5746,85 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """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 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: - """ - 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_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 a new or update an existing Index with the given version id. + def update( + self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. 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 + :param body: The evaluation taxonomy. Required. + :type body: ~azure.ai.projects.models.EvaluationTaxonomy :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: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :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 a new or update an existing Index with the given version id. + def update( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. 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 + :param body: The evaluation taxonomy. 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: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :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 a new or update an existing Index with the given version id. + def update( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. 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] + :param body: The evaluation taxonomy. 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: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :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 a new or update an existing Index with the given version id. + def update( + self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluationTaxonomy: + """Update an evaluation taxonomy. - :param name: The name of the resource. Required. + :param name: The name of the evaluation taxonomy. 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, + :param body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, 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 + :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] + :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationTaxonomy :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -5839,18 +5837,18 @@ def create_or_update( _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) + cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) - content_type = content_type or "application/merge-patch+json" + content_type = content_type or "application/json" _content = None - if isinstance(index, (IOBase, bytes)): - _content = index + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_indexes_create_or_update_request( + _request = build_beta_evaluation_taxonomies_update_request( name=name, - version=version, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -5869,7 +5867,7 @@ 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 @@ -5881,7 +5879,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5889,14 +5887,14 @@ def create_or_update( return deserialized # type: ignore -class DeploymentsOperations: +class BetaEvaluatorsOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`deployments` attribute. + :attr:`evaluators` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -5907,15 +5905,37 @@ 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.Deployment: - """Get a deployed model. + def list_versions( + self, + name: str, + *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, + **kwargs: Any + ) -> ItemPaged["_models.EvaluatorVersion"]: + """List all versions of the given evaluator. - :param name: Name of the deployment. Required. + :param name: The name of the resource. Required. :type name: str - :return: Deployment. The Deployment is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Deployment + :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] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) + _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, @@ -5924,80 +5944,99 @@ def get(self, name: str, **kwargs: Any) -> _models.Deployment: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + _request = build_beta_evaluators_list_versions_request( + name=name, + foundry_features=foundry_features, + 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) - _request = build_deployments_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) + 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), 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) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) + return _request - response = pipeline_response.http_response + 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) - 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) + def get_next(next_link=None): + _request = prepare_request(next_link) - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.Deployment, response.json()) + 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, deserialized, response_headers) # type: ignore + return pipeline_response - return deserialized # type: ignore + return ItemPaged(get_next, extract_data) @distributed_trace - def list( + def list_latest_versions( self, *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, **kwargs: Any - ) -> ItemPaged["_models.Deployment"]: - """List all deployed models in the project. + ) -> ItemPaged["_models.EvaluatorVersion"]: + """List the latest version of each evaluator. - :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 + :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 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] + :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] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6010,10 +6049,10 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, + _request = build_beta_evaluators_list_latest_versions_request( + foundry_features=foundry_features, + type=type, + limit=limit, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6049,7 +6088,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Deployment], deserialized.get("value", [])) + 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) @@ -6071,34 +6110,22 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - -class RedTeamsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`red_teams` 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(self, name: str, **kwargs: Any) -> _models.RedTeam: - """Get a redteam by name. + def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: + """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if + the EvaluatorVersion does not exist. - :param name: Identifier of the red team run. Required. + :param name: The name of the resource. Required. :type name: str - :return: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam + :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 :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6110,10 +6137,12 @@ def get(self, name: str, **kwargs: Any) -> _models.RedTeam: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) - _request = build_red_teams_get_request( + _request = build_beta_evaluators_get_version_request( name=name, + version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6139,34 +6168,34 @@ def get(self, name: str, **kwargs: Any) -> _models.RedTeam: 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() else: - deserialized = _deserialize(_models.RedTeam, response.json()) + 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 @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.RedTeam"]: - """List a redteam by name. + def delete_version( # pylint: disable=inconsistent-return-statements + self, name: str, version: str, **kwargs: Any + ) -> None: + """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the + EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. - :return: An iterator like instance of RedTeam - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.RedTeam] + :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: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.RedTeam]] = kwargs.pop("cls", None) - + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6175,122 +6204,115 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.RedTeam"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_red_teams_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), 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) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.RedTeam], deserialized.get("value", [])) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - def get_next(next_link=None): - _request = prepare_request(next_link) + 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_beta_evaluators_delete_version_request( + name=name, + version=version, + foundry_features=foundry_features, + 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) - raise HttpResponseError(response=response) + _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) + raise HttpResponseError(response=response) - @overload - def create( - self, red_team: _models.RedTeam, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.RedTeam: - """Creates a redteam run. + if cls: + return cls(pipeline_response, None, {}) # type: ignore - :param red_team: Redteam to be run. Required. - :type red_team: ~azure.ai.projects.models.RedTeam + @overload + def create_version( + self, + name: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. + + :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: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create(self, red_team: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.RedTeam: - """Creates a redteam run. + def create_version( + self, name: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. - :param red_team: Redteam to be run. Required. - :type red_team: JSON + :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: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create(self, red_team: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.RedTeam: - """Creates a redteam run. + def create_version( + self, name: str, evaluator_version: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. - :param red_team: Redteam to be run. Required. - :type red_team: IO[bytes] + :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: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam + :return: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluatorVersion :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwargs: Any) -> _models.RedTeam: - """Creates a redteam run. + def create_version( + self, name: str, evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluatorVersion: + """Create a new EvaluatorVersion with auto incremented version id. - :param red_team: Redteam to be run. Is one of the following types: RedTeam, JSON, IO[bytes] + :param name: The name of the resource. Required. + :type name: str + :param evaluator_version: Is one of the following types: EvaluatorVersion, JSON, IO[bytes] Required. - :type red_team: ~azure.ai.projects.models.RedTeam or JSON or IO[bytes] - :return: RedTeam. The RedTeam is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.RedTeam + :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: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6303,16 +6325,18 @@ def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwargs: An _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None - if isinstance(red_team, (IOBase, bytes)): - _content = red_team + if isinstance(evaluator_version, (IOBase, bytes)): + _content = evaluator_version else: - _content = json.dumps(red_team, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_red_teams_create_request( + _request = build_beta_evaluators_create_version_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -6343,41 +6367,109 @@ def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwargs: An if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.RedTeam, response.json()) + deserialized = _deserialize(_models.EvaluatorVersion, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def update_version( + self, + name: str, + version: str, + evaluator_version: _models.EvaluatorVersion, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. -class EvaluationRulesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + :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 + :raises ~azure.core.exceptions.HttpResponseError: + """ - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`evaluation_rules` attribute. - """ + @overload + def update_version( + self, name: str, version: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. - 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 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: + """ + + @overload + def update_version( + self, + name: str, + version: str, + evaluator_version: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. + + :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: + """ @distributed_trace - def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: - """Get an evaluation rule. + def update_version( + self, + name: str, + version: str, + evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.EvaluatorVersion: + """Update an existing EvaluatorVersion with the given version id. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :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. 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: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6386,14 +6478,26 @@ def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: } 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.EvaluationRule] = 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) - _request = build_evaluation_rules_get_request( - id=id, + 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_beta_evaluators_update_version_request( + name=name, + version=version, + foundry_features=foundry_features, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -6418,143 +6522,95 @@ def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: 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() else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + 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 - @distributed_trace - def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete an evaluation rule. - - :param id: Unique identifier for the evaluation rule. Required. - :type id: 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_evaluation_rules_delete_request( - id=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) - raise HttpResponseError(response=response) +class BetaInsightsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`insights` attribute. + """ - if cls: - return cls(pipeline_response, None, response_headers) # 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") @overload - def create_or_update( - self, id: str, evaluation_rule: _models.EvaluationRule, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + def generate( + self, insight: _models.Insight, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Insight: + """Generate Insights. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: ~azure.ai.projects.models.Insight :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( - self, id: str, evaluation_rule: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + def generate(self, insight: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.Insight: + """Generate Insights. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: JSON + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( - self, id: str, evaluation_rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + def generate(self, insight: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.Insight: + """Generate Insights. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: IO[bytes] + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Required. + :type insight: 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: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def create_or_update( - self, id: str, evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + def generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwargs: Any) -> _models.Insight: + """Generate Insights. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Is one of the following types: - EvaluationRule, JSON, IO[bytes] Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :param insight: Complete evaluation configuration including data source, evaluators, and result + settings. Is one of the following types: Insight, JSON, IO[bytes] Required. + :type insight: ~azure.ai.projects.models.Insight or JSON or IO[bytes] + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6567,17 +6623,17 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) + cls: ClsType[_models.Insight] = kwargs.pop("cls", None) content_type = content_type or "application/json" _content = None - if isinstance(evaluation_rule, (IOBase, bytes)): - _content = evaluation_rule + if isinstance(insight, (IOBase, bytes)): + _content = insight else: - _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(insight, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluation_rules_create_or_update_request( - id=id, + _request = build_beta_insights_generate_request( + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -6596,7 +6652,7 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -6608,7 +6664,7 @@ def create_or_update( if _stream: deserialized = response.iter_bytes() else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + deserialized = _deserialize(_models.Insight, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6616,132 +6672,21 @@ def create_or_update( return deserialized # type: ignore @distributed_trace - def list( - self, - *, - action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_models.EvaluationRule"]: - """List all evaluation rules. - - :keyword action_type: Filter by the type of evaluation rule. Known values are: - "continuousEvaluation" and "humanEvaluation". Default value is None. - :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of EvaluationRule - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluationRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.EvaluationRule]] = 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_evaluation_rules_list_request( - action_type=action_type, - agent_name=agent_name, - enabled=enabled, - 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), 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) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.EvaluationRule], 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 EvaluationTaxonomiesOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`evaluation_taxonomies` 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(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: - """Get an evaluation run by name. + def get(self, id: str, *, include_coordinates: Optional[bool] = None, **kwargs: Any) -> _models.Insight: + """Get a specific insight by Id. - :param name: The name of the resource. Required. - :type name: str - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :param id: The unique identifier for the insights report. Required. + :type id: str + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: Insight. The Insight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Insight :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6753,10 +6698,12 @@ def get(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.Insight] = kwargs.pop("cls", None) - _request = build_evaluation_taxonomies_get_request( - name=name, + _request = build_beta_insights_get_request( + id=id, + foundry_features=foundry_features, + include_coordinates=include_coordinates, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6782,39 +6729,52 @@ def get(self, name: str, **kwargs: Any) -> _models.EvaluationTaxonomy: 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() else: - deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) + deserialized = _deserialize(_models.Insight, 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, *, input_name: Optional[str] = None, input_type: Optional[str] = None, **kwargs: Any - ) -> ItemPaged["_models.EvaluationTaxonomy"]: - """List evaluation taxonomies. + self, + *, + type: Optional[Union[str, _models.InsightType]] = None, + eval_id: Optional[str] = None, + run_id: Optional[str] = None, + agent_name: Optional[str] = None, + include_coordinates: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.Insight"]: + """List all insights in reverse chronological order (newest first). - :keyword input_name: Filter by the evaluation input name. Default value is None. - :paramtype input_name: str - :keyword input_type: Filter by taxonomy input type. Default value is None. - :paramtype input_type: str - :return: An iterator like instance of EvaluationTaxonomy - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluationTaxonomy] + :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", + "AgentClusterInsight", and "EvaluationComparison". Default value is None. + :paramtype type: str or ~azure.ai.projects.models.InsightType + :keyword eval_id: Filter by the evaluation ID. Default value is None. + :paramtype eval_id: str + :keyword run_id: Filter by the evaluation run ID. Default value is None. + :paramtype run_id: str + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword include_coordinates: Whether to include coordinates for visualization in the response. + Defaults to false. Default value is None. + :paramtype include_coordinates: bool + :return: An iterator like instance of Insight + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Insight] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.EvaluationTaxonomy]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.Insight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6827,9 +6787,13 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_evaluation_taxonomies_list_request( - input_name=input_name, - input_type=input_type, + _request = build_beta_insights_list_request( + foundry_features=foundry_features, + type=type, + eval_id=eval_id, + run_id=run_id, + agent_name=agent_name, + include_coordinates=include_coordinates, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6865,7 +6829,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.EvaluationTaxonomy], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.Insight], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -6887,257 +6851,117 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - @distributed_trace - def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete an evaluation taxonomy by name. - - :param name: The name of the resource. 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_evaluation_taxonomies_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) - 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 cls: - return cls(pipeline_response, None, response_headers) # type: ignore +class BetaMemoryStoresOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - @overload - def create( - self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`memory_stores` attribute. + """ - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - """ + 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( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. + self, + *, + name: str, + definition: _models.MemoryStoreDefinition, + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: JSON + :keyword name: The name of the memory store. Required. + :paramtype name: str + :keyword definition: The memory store definition. Required. + :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :keyword description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default + value is None. + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @overload def create( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. 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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create( - self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Create an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, JSON, - IO[bytes] Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy - :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.EvaluationTaxonomy] = kwargs.pop("cls", 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_evaluation_taxonomies_create_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) - - _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, 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) - - if _stream: - deserialized = response.iter_bytes() - else: - deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @overload - def update( - self, name: str, body: _models.EvaluationTaxonomy, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. - - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. + self, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. + :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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. + def create( + self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Required. + :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: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( - self, name: str, body: Union[_models.EvaluationTaxonomy, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationTaxonomy: - """Update an evaluation taxonomy. + def create( + self, + body: Union[JSON, IO[bytes]] = _Unset, + *, + name: str = _Unset, + definition: _models.MemoryStoreDefinition = _Unset, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Create a memory store. - :param name: The name of the evaluation taxonomy. Required. - :type name: str - :param body: The evaluation taxonomy. Is one of the following types: EvaluationTaxonomy, JSON, - IO[bytes] Required. - :type body: ~azure.ai.projects.models.EvaluationTaxonomy or JSON or IO[bytes] - :return: EvaluationTaxonomy. The EvaluationTaxonomy is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationTaxonomy + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword name: The name of the memory store. Required. + :paramtype name: str + :keyword definition: The memory store definition. Required. + :paramtype definition: ~azure.ai.projects.models.MemoryStoreDefinition + :keyword description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default + value is None. + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7150,8 +6974,15 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluationTaxonomy] = kwargs.pop("cls", None) + cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) + if body is _Unset: + if name is _Unset: + raise TypeError("missing required argument: name") + if definition is _Unset: + raise TypeError("missing required argument: definition") + body = {"definition": definition, "description": description, "metadata": metadata, "name": name} + 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)): @@ -7159,8 +6990,8 @@ def update( else: _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluation_taxonomies_update_request( - name=name, + _request = build_beta_memory_stores_create_request( + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -7186,163 +7017,113 @@ def update( 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() else: - deserialized = _deserialize(_models.EvaluationTaxonomy, response.json()) + deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class EvaluatorsOperations: - """ - .. 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( + @overload + def update( self, name: str, *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> ItemPaged["_models.EvaluatorVersion"]: - """List all versions of the given evaluator. + ) -> _models.MemoryStoreDetails: + """Update a memory store. - :param name: The name of the resource. Required. + :param name: The name of the memory store to update. 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 + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. 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] + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :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, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - 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), 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) - return _request - - 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) - - 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 + @overload + def update( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Update a memory store. - 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 name: The name of the memory store 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: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :raises ~azure.core.exceptions.HttpResponseError: + """ - return pipeline_response + @overload + def update( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDetails: + """Update a memory store. - return ItemPaged(get_next, extract_data) + :param name: The name of the memory store 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: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def list_latest_versions( + def update( self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, **kwargs: Any - ) -> ItemPaged["_models.EvaluatorVersion"]: - """List the latest version of each evaluator. + ) -> _models.MemoryStoreDetails: + """Update a memory store. - :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 name: The name of the memory store 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 description: A human-readable description of the memory store. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the memory store. Default + value is None. + :paramtype metadata: dict[str, str] + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.EvaluatorVersion]] = kwargs.pop("cls", None) - + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7351,82 +7132,79 @@ def list_latest_versions( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _request = build_evaluators_list_latest_versions_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) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MemoryStoreDetails] = 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), 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) + if body is _Unset: + body = {"description": description, "metadata": metadata} + 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 - return _request + _request = build_beta_memory_stores_update_request( + name=name, + foundry_features=foundry_features, + 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) - 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) + _stream = kwargs.pop("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 [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, ) - 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 _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) - return pipeline_response + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - return ItemPaged(get_next, extract_data) + return deserialized # type: ignore @distributed_trace - def get_version(self, name: str, version: str, **kwargs: Any) -> _models.EvaluatorVersion: - """Get the specific version of the EvaluatorVersion. The service returns 404 Not Found error if - the EvaluatorVersion does not exist. + def get(self, name: str, **kwargs: Any) -> _models.MemoryStoreDetails: + """Retrieve a memory store. - :param name: The name of the resource. Required. + :param name: The name of the memory store to retrieve. 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 + :return: MemoryStoreDetails. The MemoryStoreDetails is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDetails :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7438,11 +7216,11 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Evaluat _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluatorVersion] = kwargs.pop("cls", None) + cls: ClsType[_models.MemoryStoreDetails] = kwargs.pop("cls", None) - _request = build_evaluators_get_version_request( + _request = build_beta_memory_stores_get_request( name=name, - version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7466,12 +7244,16 @@ 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() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.MemoryStoreDetails, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7479,20 +7261,109 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Evaluat return deserialized # type: ignore @distributed_trace - def delete_version( # pylint: disable=inconsistent-return-statements - self, name: str, version: str, **kwargs: Any - ) -> None: - """Delete the specific version of the EvaluatorVersion. The service returns 204 No Content if the - EvaluatorVersion was deleted successfully or if the EvaluatorVersion does not exist. + def list( + self, + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.MemoryStoreDetails"]: + """List all memory stores. - :param name: The name of the resource. Required. + :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 MemoryStoreDetails + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.MemoryStoreDetails] + :raises ~azure.core.exceptions.HttpResponseError: + """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.MemoryStoreDetails]] = 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_beta_memory_stores_list_request( + foundry_features=foundry_features, + 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.MemoryStoreDetails], 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) + + @distributed_trace + def delete(self, name: str, **kwargs: Any) -> _models.DeleteMemoryStoreResult: + """Delete a memory store. + + :param name: The name of the memory store to delete. Required. :type name: str - :param version: The version of the EvaluatorVersion to delete. Required. - :type version: str - :return: None - :rtype: None + :return: DeleteMemoryStoreResult. The DeleteMemoryStoreResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DeleteMemoryStoreResult :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7504,11 +7375,11 @@ 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.DeleteMemoryStoreResult] = kwargs.pop("cls", None) - _request = build_evaluators_delete_version_request( + _request = build_beta_memory_stores_delete_request( name=name, - version=version, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7518,94 +7389,141 @@ def delete_version( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _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]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=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() + else: + deserialized = _deserialize(_models.DeleteMemoryStoreResult, response.json()) if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @overload - def create_version( + def search_memories( self, name: str, - evaluator_version: _models.EvaluatorVersion, *, + scope: str, content_type: str = "application/json", + items: Optional[List[_models.InputItem]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_models.MemorySearchOptions] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Create a new EvaluatorVersion with auto incremented version id. + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: ~azure.ai.projects.models.EvaluatorVersion + :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :paramtype scope: str :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 items: Items for which to search for relevant memories. Default value is None. + :paramtype items: list[~azure.ai.projects.models.InputItem] + :keyword previous_search_id: The unique ID of the previous search request, enabling incremental + memory search from where the last operation left off. Default value is None. + :paramtype previous_search_id: str + :keyword options: Memory search options. Default value is None. + :paramtype options: ~azure.ai.projects.models.MemorySearchOptions + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :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 a new EvaluatorVersion with auto incremented version id. + def search_memories( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: JSON + :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: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :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 a new EvaluatorVersion with auto incremented version id. + def search_memories( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: str - :param evaluator_version: Evaluator resource. Required. - :type evaluator_version: IO[bytes] + :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: EvaluatorVersion. The EvaluatorVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluatorVersion + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :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 a new EvaluatorVersion with auto incremented version id. + def search_memories( + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + scope: str = _Unset, + items: Optional[List[_models.InputItem]] = None, + previous_search_id: Optional[str] = None, + options: Optional[_models.MemorySearchOptions] = None, + **kwargs: Any + ) -> _models.MemoryStoreSearchResult: + """Search for relevant memories from a memory store based on conversation context. - :param name: The name of the resource. Required. + :param name: The name of the memory store to search. Required. :type name: 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 + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :paramtype scope: str + :keyword items: Items for which to search for relevant memories. Default value is None. + :paramtype items: list[~azure.ai.projects.models.InputItem] + :keyword previous_search_id: The unique ID of the previous search request, enabling incremental + memory search from where the last operation left off. Default value is None. + :paramtype previous_search_id: str + :keyword options: Memory search options. Default value is None. + :paramtype options: ~azure.ai.projects.models.MemorySearchOptions + :return: MemoryStoreSearchResult. The MemoryStoreSearchResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreSearchResult :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7618,17 +7536,28 @@ def create_version( _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) + cls: ClsType[_models.MemoryStoreSearchResult] = kwargs.pop("cls", None) + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = { + "items": items, + "options": options, + "previous_search_id": previous_search_id, + "scope": scope, + } + 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(evaluator_version, (IOBase, bytes)): - _content = evaluator_version + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluators_create_version_request( + _request = build_beta_memory_stores_search_memories_request( name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -7647,118 +7576,41 @@ 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 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() else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + deserialized = _deserialize(_models.MemoryStoreSearchResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @overload - def update_version( - self, - name: str, - version: str, - evaluator_version: _models.EvaluatorVersion, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :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 - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @overload - def update_version( - self, name: str, version: str, evaluator_version: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :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: - """ - - @overload - def update_version( + def _update_memories_initial( self, name: str, - version: str, - evaluator_version: IO[bytes], + body: Union[JSON, IO[bytes]] = _Unset, *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :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: - """ - - @distributed_trace - def update_version( - self, - name: str, - version: str, - evaluator_version: Union[_models.EvaluatorVersion, JSON, IO[bytes]], + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW], + scope: str = _Unset, + items: Optional[List[_models.InputItem]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, **kwargs: Any - ) -> _models.EvaluatorVersion: - """Update an existing EvaluatorVersion with the given version id. - - :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. 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: - """ + ) -> Iterator[bytes]: error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7771,18 +7623,28 @@ def update_version( _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) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = { + "items": items, + "previous_update_id": previous_update_id, + "scope": scope, + "update_delay": update_delay, + } + 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(evaluator_version, (IOBase, bytes)): - _content = evaluator_version + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(evaluator_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_evaluators_update_version_request( + _request = build_beta_memory_stores_update_memories_request( name=name, - version=version, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -7794,108 +7656,237 @@ def update_version( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = kwargs.pop("stream", False) + _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 [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 [202]: + 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() - else: - deserialized = _deserialize(_models.EvaluatorVersion, response.json()) + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + + deserialized = response.iter_bytes() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore + @overload + def _begin_update_memories( + self, + name: str, + *, + scope: str, + content_type: str = "application/json", + items: Optional[List[_models.InputItem]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + **kwargs: Any + ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + @overload + def _begin_update_memories( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: ... + @overload + def _begin_update_memories( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: ... -class InsightsOperations: - """ - .. warning:: - **DO NOT** instantiate this class directly. + @distributed_trace + def _begin_update_memories( + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + scope: str = _Unset, + items: Optional[List[_models.InputItem]] = None, + previous_update_id: Optional[str] = None, + update_delay: Optional[int] = None, + **kwargs: Any + ) -> LROPoller[_models.MemoryStoreUpdateCompletedResult]: + """Update memory store with conversation memories. - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`insights` attribute. - """ + :param name: The name of the memory store 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 scope: The namespace that logically groups and isolates memories, such as a user ID. + Required. + :paramtype scope: str + :keyword items: Conversation items from which to extract memories. Default value is None. + :paramtype items: list[~azure.ai.projects.models.InputItem] + :keyword previous_update_id: The unique ID of the previous update request, enabling incremental + memory updates from where the last operation left off. Default value is None. + :paramtype previous_update_id: str + :keyword update_delay: Timeout period before processing the memory update in seconds. + If a new update request is received during this period, it will cancel the current request and + reset the timeout. + Set to 0 to immediately trigger the update without delay. + Defaults to 300 (5 minutes). Default value is None. + :paramtype update_delay: int + :return: An instance of LROPoller that returns MemoryStoreUpdateCompletedResult. The + MemoryStoreUpdateCompletedResult is compatible with MutableMapping + :rtype: + ~azure.core.polling.LROPoller[~azure.ai.projects.models.MemoryStoreUpdateCompletedResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - 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") + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.MemoryStoreUpdateCompletedResult] = 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._update_memories_initial( + name=name, + body=body, + foundry_features=foundry_features, + scope=scope, + items=items, + previous_update_id=previous_update_id, + update_delay=update_delay, + 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") + ) + + deserialized = _deserialize(_models.MemoryStoreUpdateCompletedResult, 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.MemoryStoreUpdateCompletedResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.MemoryStoreUpdateCompletedResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @overload - def generate( - self, insight: _models.Insight, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.Insight: - """Generate Insights. + def delete_scope( + self, name: str, *, scope: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: ~azure.ai.projects.models.Insight + :param name: The name of the memory store. Required. + :type name: str + :keyword scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :paramtype scope: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def generate(self, insight: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.Insight: - """Generate Insights. + def delete_scope( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: JSON + :param name: The name of the memory store. 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: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def generate(self, insight: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.Insight: - """Generate Insights. + def delete_scope( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Required. - :type insight: IO[bytes] + :param name: The name of the memory store. 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: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwargs: Any) -> _models.Insight: - """Generate Insights. + def delete_scope( + self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, scope: str = _Unset, **kwargs: Any + ) -> _models.MemoryStoreDeleteScopeResult: + """Delete all memories associated with a specific scope from a memory store. - :param insight: Complete evaluation configuration including data source, evaluators, and result - settings. Is one of the following types: Insight, JSON, IO[bytes] Required. - :type insight: ~azure.ai.projects.models.Insight or JSON or IO[bytes] - :return: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :param name: The name of the memory store. Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword scope: The namespace that logically groups and isolates memories to delete, such as a + user ID. Required. + :paramtype scope: str + :return: MemoryStoreDeleteScopeResult. The MemoryStoreDeleteScopeResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.MemoryStoreDeleteScopeResult :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7908,16 +7899,23 @@ def generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwargs: A _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Insight] = kwargs.pop("cls", None) + cls: ClsType[_models.MemoryStoreDeleteScopeResult] = kwargs.pop("cls", None) + if body is _Unset: + if scope is _Unset: + raise TypeError("missing required argument: scope") + body = {"scope": scope} + 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(insight, (IOBase, bytes)): - _content = insight + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(insight, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_insights_generate_request( + _request = build_beta_memory_stores_delete_scope_request( + name=name, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -7936,38 +7934,60 @@ def generate(self, insight: Union[_models.Insight, JSON, IO[bytes]], **kwargs: A 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 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() else: - deserialized = _deserialize(_models.Insight, response.json()) + deserialized = _deserialize(_models.MemoryStoreDeleteScopeResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + +class BetaRedTeamsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`red_teams` 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(self, id: str, *, include_coordinates: Optional[bool] = None, **kwargs: Any) -> _models.Insight: - """Get a specific insight by Id. + def get(self, name: str, **kwargs: Any) -> _models.RedTeam: + """Get a redteam by name. - :param id: The unique identifier for the insights report. Required. - :type id: str - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: Insight. The Insight is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Insight + :param name: Identifier of the red team run. Required. + :type name: str + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7979,11 +7999,11 @@ def get(self, id: str, *, include_coordinates: Optional[bool] = None, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Insight] = kwargs.pop("cls", None) + cls: ClsType[_models.RedTeam] = kwargs.pop("cls", None) - _request = build_insights_get_request( - id=id, - include_coordinates=include_coordinates, + _request = build_beta_red_teams_get_request( + name=name, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8009,54 +8029,31 @@ def get(self, id: str, *, include_coordinates: Optional[bool] = None, **kwargs: 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() else: - deserialized = _deserialize(_models.Insight, response.json()) + deserialized = _deserialize(_models.RedTeam, 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, - *, - type: Optional[Union[str, _models.InsightType]] = None, - eval_id: Optional[str] = None, - run_id: Optional[str] = None, - agent_name: Optional[str] = None, - include_coordinates: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_models.Insight"]: - """List all insights in reverse chronological order (newest first). + def list(self, **kwargs: Any) -> ItemPaged["_models.RedTeam"]: + """List a redteam by name. - :keyword type: Filter by the type of analysis. Known values are: "EvaluationRunClusterInsight", - "AgentClusterInsight", and "EvaluationComparison". Default value is None. - :paramtype type: str or ~azure.ai.projects.models.InsightType - :keyword eval_id: Filter by the evaluation ID. Default value is None. - :paramtype eval_id: str - :keyword run_id: Filter by the evaluation run ID. Default value is None. - :paramtype run_id: str - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword include_coordinates: Whether to include coordinates for visualization in the response. - Defaults to false. Default value is None. - :paramtype include_coordinates: bool - :return: An iterator like instance of Insight - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Insight] + :return: An iterator like instance of RedTeam + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.RedTeam] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Insight]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.RedTeam]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8069,12 +8066,8 @@ def list( def prepare_request(next_link=None): if not next_link: - _request = build_insights_list_request( - type=type, - eval_id=eval_id, - run_id=run_id, - agent_name=agent_name, - include_coordinates=include_coordinates, + _request = build_beta_red_teams_list_request( + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8110,7 +8103,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize(List[_models.Insight], deserialized.get("value", [])) + list_of_elem = _deserialize(List[_models.RedTeam], deserialized.get("value", [])) if cls: list_of_elem = cls(list_of_elem) # type: ignore return deserialized.get("nextLink") or None, iter(list_of_elem) @@ -8132,8 +8125,130 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + @overload + def create( + self, red_team: _models.RedTeam, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: ~azure.ai.projects.models.RedTeam + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create(self, red_team: JSON, *, content_type: str = "application/json", **kwargs: Any) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create(self, red_team: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Required. + :type red_team: 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: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create(self, red_team: Union[_models.RedTeam, JSON, IO[bytes]], **kwargs: Any) -> _models.RedTeam: + """Creates a redteam run. + + :param red_team: Redteam to be run. Is one of the following types: RedTeam, JSON, IO[bytes] + Required. + :type red_team: ~azure.ai.projects.models.RedTeam or JSON or IO[bytes] + :return: RedTeam. The RedTeam is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.RedTeam + :raises ~azure.core.exceptions.HttpResponseError: + """ + foundry_features: Literal[FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.RED_TEAMS_V1_PREVIEW + ) + 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.RedTeam] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(red_team, (IOBase, bytes)): + _content = red_team + else: + _content = json.dumps(red_team, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_beta_red_teams_create_request( + foundry_features=foundry_features, + 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) + + _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) + + if _stream: + deserialized = response.iter_bytes() + else: + deserialized = _deserialize(_models.RedTeam, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + -class SchedulesOperations: +class BetaSchedulesOperations: """ .. warning:: **DO NOT** instantiate this class directly. @@ -8160,6 +8275,9 @@ def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsisten :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8173,8 +8291,9 @@ def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsisten cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_schedules_delete_request( + _request = build_beta_schedules_delete_request( id=id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8195,13 +8314,8 @@ def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsisten 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 cls: - return cls(pipeline_response, None, response_headers) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def get(self, id: str, **kwargs: Any) -> _models.Schedule: @@ -8213,6 +8327,9 @@ def get(self, id: str, **kwargs: Any) -> _models.Schedule: :rtype: ~azure.ai.projects.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8226,8 +8343,9 @@ def get(self, id: str, **kwargs: Any) -> _models.Schedule: cls: ClsType[_models.Schedule] = kwargs.pop("cls", None) - _request = build_schedules_get_request( + _request = build_beta_schedules_get_request( id=id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8253,29 +8371,38 @@ def get(self, id: str, **kwargs: Any) -> _models.Schedule: 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() else: deserialized = _deserialize(_models.Schedule, 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, **kwargs: Any) -> ItemPaged["_models.Schedule"]: + def list( + self, + *, + type: Optional[Union[str, _models.ScheduleTaskType]] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.Schedule"]: """List all schedules. + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + Default value is None. + :paramtype type: str or ~azure.ai.projects.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool :return: An iterator like instance of Schedule :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Schedule] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -8292,7 +8419,10 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Schedule"]: def prepare_request(next_link=None): if not next_link: - _request = build_schedules_list_request( + _request = build_beta_schedules_list_request( + foundry_features=foundry_features, + type=type, + enabled=enabled, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8354,11 +8484,11 @@ def get_next(next_link=None): def create_or_update( self, id: str, schedule: _models.Schedule, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Required. + :param schedule: The resource instance. Required. :type schedule: ~azure.ai.projects.models.Schedule :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -8372,11 +8502,11 @@ def create_or_update( def create_or_update( self, id: str, schedule: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Required. + :param schedule: The resource instance. Required. :type schedule: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -8390,11 +8520,11 @@ def create_or_update( def create_or_update( self, id: str, schedule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Required. + :param schedule: The resource instance. Required. :type schedule: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -8408,17 +8538,20 @@ def create_or_update( def create_or_update( self, id: str, schedule: Union[_models.Schedule, JSON, IO[bytes]], **kwargs: Any ) -> _models.Schedule: - """Create or update a schedule by id. + """Create or update operation template. :param id: Identifier of the schedule. Required. :type id: str - :param schedule: Schedule resource. Is one of the following types: Schedule, JSON, IO[bytes] - Required. + :param schedule: The resource instance. Is one of the following types: Schedule, JSON, + IO[bytes] Required. :type schedule: ~azure.ai.projects.models.Schedule or JSON or IO[bytes] :return: Schedule. The Schedule is compatible with MutableMapping :rtype: ~azure.ai.projects.models.Schedule :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8440,8 +8573,9 @@ def create_or_update( else: _content = json.dumps(schedule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_schedules_create_or_update_request( + _request = build_beta_schedules_create_or_update_request( id=id, + foundry_features=foundry_features, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -8483,14 +8617,17 @@ def create_or_update( def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models.ScheduleRun: """Get a schedule run by id. - :param schedule_id: Identifier of the schedule. Required. + :param schedule_id: The unique identifier of the schedule. Required. :type schedule_id: str - :param run_id: Identifier of the schedule run. Required. + :param run_id: The unique identifier of the schedule run. Required. :type run_id: str :return: ScheduleRun. The ScheduleRun is compatible with MutableMapping :rtype: ~azure.ai.projects.models.ScheduleRun :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -8504,9 +8641,10 @@ def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models.Sched cls: ClsType[_models.ScheduleRun] = kwargs.pop("cls", None) - _request = build_schedules_get_run_request( + _request = build_beta_schedules_get_run_request( schedule_id=schedule_id, run_id=run_id, + foundry_features=foundry_features, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8530,7 +8668,11 @@ def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models.Sched 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() @@ -8543,15 +8685,30 @@ def get_run(self, schedule_id: str, run_id: str, **kwargs: Any) -> _models.Sched return deserialized # type: ignore @distributed_trace - def list_runs(self, id: str, **kwargs: Any) -> ItemPaged["_models.ScheduleRun"]: + def list_runs( + self, + id: str, + *, + type: Optional[Union[str, _models.ScheduleTaskType]] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.ScheduleRun"]: """List all schedule runs. :param id: Identifier of the schedule. Required. :type id: str + :keyword type: Filter by the type of schedule. Known values are: "Evaluation" and "Insight". + Default value is None. + :paramtype type: str or ~azure.ai.projects.models.ScheduleTaskType + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool :return: An iterator like instance of ScheduleRun :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ScheduleRun] :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.SCHEDULES_V1_PREVIEW + ) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} @@ -8568,8 +8725,11 @@ def list_runs(self, id: str, **kwargs: Any) -> ItemPaged["_models.ScheduleRun"]: def prepare_request(next_link=None): if not next_link: - _request = build_schedules_list_runs_request( + _request = build_beta_schedules_list_runs_request( id=id, + foundry_features=foundry_features, + type=type, + enabled=enabled, api_version=self._config.api_version, headers=_headers, params=_params, 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 105063e2d4ee..e6e2ccb68e57 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 @@ -11,13 +11,46 @@ from ._patch_datasets import DatasetsOperations from ._patch_telemetry import TelemetryOperations from ._patch_connections import ConnectionsOperations -from ._patch_memories import MemoryStoresOperations +from ._patch_memories import BetaMemoryStoresOperations +from ._operations import ( + BetaEvaluationTaxonomiesOperations, + BetaEvaluatorsOperations, + BetaInsightsOperations, + BetaOperations as GenerateBetaOperations, + BetaRedTeamsOperations, + BetaSchedulesOperations, +) + + +class BetaOperations(GenerateBetaOperations): + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`beta` attribute. + """ + + memory_stores: BetaMemoryStoresOperations # type override for mypy + + def __init__(self, *args, **kwargs) -> None: + super().__init__(*args, **kwargs) + # Override memory_stores with the patched version that has begin_update_memories + self.memory_stores = BetaMemoryStoresOperations(self._client, self._config, self._serialize, self._deserialize) + __all__: List[str] = [ - "TelemetryOperations", - "DatasetsOperations", + "BetaEvaluationTaxonomiesOperations", + "BetaEvaluatorsOperations", + "BetaInsightsOperations", + "BetaMemoryStoresOperations", + "BetaOperations", + "BetaRedTeamsOperations", + "BetaSchedulesOperations", "ConnectionsOperations", - "MemoryStoresOperations", + "DatasetsOperations", + "TelemetryOperations", ] # Add all objects you want publicly available to users at this package level diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_memories.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_memories.py index ca25e90aa008..bd4ba95b4fb7 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_memories.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_memories.py @@ -7,12 +7,13 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ -from typing import Union, Optional, Any, List, overload, IO, cast +from typing import Union, Optional, Any, List, overload, IO, cast, Literal from azure.core.tracing.decorator import distributed_trace from azure.core.polling import NoPolling from azure.core.utils import case_insensitive_dict from .. import models as _models from ..models import ( + FoundryFeaturesOptInKeys, MemoryStoreOperationUsage, ResponseUsageInputTokensDetails, ResponseUsageOutputTokensDetails, @@ -20,12 +21,12 @@ UpdateMemoriesLROPoller, UpdateMemoriesLROPollingMethod, ) -from ._operations import JSON, _Unset, ClsType, MemoryStoresOperations as GenerateMemoryStoresOperations +from ._operations import JSON, _Unset, ClsType, BetaMemoryStoresOperations as GenerateBetaMemoryStoresOperations from .._validation import api_version_validation from .._utils.model_base import _deserialize -class MemoryStoresOperations(GenerateMemoryStoresOperations): +class BetaMemoryStoresOperations(GenerateBetaMemoryStoresOperations): @overload def begin_update_memories( @@ -69,7 +70,12 @@ def begin_update_memories( @overload def begin_update_memories( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + self, + name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, ) -> UpdateMemoriesLROPoller: """Update memory store with conversation memories. @@ -89,7 +95,12 @@ def begin_update_memories( @overload def begin_update_memories( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + self, + name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, ) -> UpdateMemoriesLROPoller: """Update memory store with conversation memories. @@ -109,9 +120,9 @@ def begin_update_memories( @distributed_trace @api_version_validation( - method_added_on="2025-11-15-preview", - params_added_on={"2025-11-15-preview": ["api_version", "name", "content_type", "accept"]}, - api_versions_list=["2025-11-15-preview"], + method_added_on="v1", + params_added_on={"v1": ["api_version", "name", "content_type", "accept"]}, + api_versions_list=["v1"], ) def begin_update_memories( self, @@ -150,6 +161,10 @@ def begin_update_memories( ~azure.ai.projects.models.UpdateMemoriesLROPoller :raises ~azure.core.exceptions.HttpResponseError: """ + foundry_features: Literal[FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW] = ( + FoundryFeaturesOptInKeys.MEMORY_STORES_V1_PREVIEW + ) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} @@ -160,6 +175,7 @@ def begin_update_memories( cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._update_memories_initial( + foundry_features=foundry_features, name=name, body=body, scope=scope, diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_ai_project_instrumentor.py b/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_ai_project_instrumentor.py index 7eb57786fbff..bd35a2a34881 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_ai_project_instrumentor.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/telemetry/_ai_project_instrumentor.py @@ -13,10 +13,7 @@ from enum import Enum from typing import Any, Callable, Dict, List, Optional, Tuple, Union, TYPE_CHECKING from urllib.parse import urlparse -from azure.ai.projects.models._models import ( - Tool, - ItemResource, -) +from azure.ai.projects.models._models import Tool from azure.core import CaseInsensitiveEnumMeta # type: ignore from azure.core.settings import settings from azure.core.tracing import AbstractSpan @@ -715,7 +712,7 @@ def start_create_agent_span( # pylint: disable=too-many-locals description: Optional[str] = None, instructions: Optional[str] = None, _tools: Optional[List[Tool]] = None, - _tool_resources: Optional[ItemResource] = None, + _tool_resources: Optional[Any] = None, # TODO: Used to be: _tool_resources: Optional[ItemResource] = None, # _toolset: Optional["ToolSet"] = None, temperature: Optional[float] = None, top_p: Optional[float] = None, @@ -925,7 +922,7 @@ def _create_agent_span_from_parameters( if text: # Handle different types of text objects if hasattr(text, "format"): - # Azure AI Agents PromptAgentDefinitionText model object + # Azure AI Agents PromptAgentDefinitionTextOptions model object format_info = getattr(text, "format", None) if format_info: if hasattr(format_info, "type"): diff --git a/sdk/ai/azure-ai-projects/post-emitter-fixes.cmd b/sdk/ai/azure-ai-projects/post-emitter-fixes.cmd index 6826a3a15591..dc9d68cdc36b 100644 --- a/sdk/ai/azure-ai-projects/post-emitter-fixes.cmd +++ b/sdk/ai/azure-ai-projects/post-emitter-fixes.cmd @@ -1,7 +1,7 @@ REM REM To emit from TypeSpec, run this in the current folder: REM -REM tsp-client update --debug --local-spec-repo e:\src\azure-rest-api-specs-pr\specification\ai\Azure.AI.Projects +REM tsp-client update --debug --local-spec-repo e:\src\azure-rest-api-specs\specification\ai-foundry\data-plane\Foundry REM REM (replace `e:\src\...` with the local folder containing up to date TypeSpec) REM @@ -10,7 +10,8 @@ REM REM Revert this, as we want to keep some edits to these file. git restore pyproject.toml -git restore azure\ai\projects\_version.py +REM Looks like this is no longer needed: +REM git restore azure\ai\projects\_version.py REM Rename "A2_A_PREVIEW" to "A2A_PREVIEW". Since this value is an extension to OpenAI.ToolType enum, we can't use @className in client.tsp to do the rename. powershell -Command "(Get-Content azure\ai\projects\models\_models.py) -replace 'A2_A_PREVIEW', 'A2A_PREVIEW' | Set-Content azure\ai\projects\models\_models.py" @@ -20,14 +21,36 @@ REM Rename `"items_property": items`, to `"items": items` in search_memories and powershell -Command "(Get-Content azure\ai\projects\aio\operations\_operations.py) -replace '\"items_property\": items', '\"items\": items' | Set-Content azure\ai\projects\aio\operations\_operations.py" powershell -Command "(Get-Content azure\ai\projects\operations\_operations.py) -replace '\"items_property\": items', '\"items\": items' | Set-Content azure\ai\projects\operations\_operations.py" +REM Fix Sphinx issue in class ToolChoiceAllowed, in "tools" property doc string. Everything should be aligned including JSON example, like this: +REM """A list of tool definitions that the model should be allowed to call. For the Responses API, the +REM list of tool definitions might look like: +REM .. code-block:: json +REM [ +REM { \"type\": \"function\", \"name\": \"get_weather\" }, +REM { \"type\": \"mcp\", \"server_label\": \"deepwiki\" }, +REM { \"type\": \"image_generation\" } +REM ]. Required.""" + +REM Fix Sphinx issue: docstring of azure.ai.projects.models.WorkflowPreviewActionOutputItem.type:2: WARNING: Duplicate explicit target name: "learn more". [docutils] +REM Turns out this has nothing to do with doc string of class WorkflowPreviewActionOutputItem. Search for "learn more" +REM and change them to "learn more about ..." (e.g. "learn more about content safety"). + REM Fix type annotations by replacing "_types.Filters" with proper union type to fix Pyright errors -powershell -Command "(Get-Content azure\ai\projects\models\_models.py) -replace '\"_types\.Filters\"', 'Union[\"_models.ComparisonFilter\", \"_models.CompoundFilter\"]' | Set-Content azure\ai\projects\models\_models.py" +REM powershell -Command "(Get-Content azure\ai\projects\models\_models.py) -replace '\"_types\.Filters\"', 'Union[\"_models.ComparisonFilter\", \"_models.CompoundFilter\"]' | Set-Content azure\ai\projects\models\_models.py" REM Add additional pylint disables to the model_base.py file -powershell -Command "(Get-Content azure\ai\projects\_utils\model_base.py) -replace '# pylint: disable=protected-access, broad-except', '# pylint: disable=protected-access, broad-except, import-error, no-value-for-parameter' | Set-Content azure\ai\projects\_utils\model_base.py" +REM powershell -Command "(Get-Content azure\ai\projects\_utils\model_base.py) -replace '# pylint: disable=protected-access, broad-except', '# pylint: disable=protected-access, broad-except, import-error, no-value-for-parameter' | Set-Content azure\ai\projects\_utils\model_base.py" REM Add pyright ignore comment to created_by fields to suppress reportIncompatibleVariableOverride errors -powershell -Command "(Get-Content azure\ai\projects\models\_models.py) -replace 'created_by: Optional\[str\] = rest_field\(visibility=\[\"read\", \"create\", \"update\", \"delete\", \"query\"\]\)', 'created_by: Optional[str] = rest_field(visibility=[\"read\", \"create\", \"update\", \"delete\", \"query\"]) # pyright: ignore[reportIncompatibleVariableOverride]' | Set-Content azure\ai\projects\models\_models.py" +REM powershell -Command "(Get-Content azure\ai\projects\models\_models.py) -replace 'created_by: Optional\[str\] = rest_field\(visibility=\[\"read\", \"create\", \"update\", \"delete\", \"query\"\]\)', 'created_by: Optional[str] = rest_field(visibility=[\"read\", \"create\", \"update\", \"delete\", \"query\"]) # pyright: ignore[reportIncompatibleVariableOverride]' | Set-Content azure\ai\projects\models\_models.py" echo Now do these additional changes manually, if you want the "Generate docs" job to succeed in PR pipeline REM Remove `generate_summary` from class `Reasoning`. It's deprecated but causes two types of errors. Consider removing it from TypeSpec. + +REM Remove required 'foundry_features' from public API surface +copy agent-scripts\patch_foundry_features_args.py . +python patch_foundry_features_args.py +del patch_foundry_features_args.py + +echo Finishing by running 'black' tool to format code. +black --config ../../../eng/black-pyproject.toml . diff --git a/sdk/ai/azure-ai-projects/pyproject.toml b/sdk/ai/azure-ai-projects/pyproject.toml index 73bf11ce0688..e2ae27e26534 100644 --- a/sdk/ai/azure-ai-projects/pyproject.toml +++ b/sdk/ai/azure-ai-projects/pyproject.toml @@ -33,7 +33,7 @@ keywords = ["azure", "azure sdk"] dependencies = [ "isodate>=0.6.1", - "azure-core>=1.36.0", + "azure-core>=1.37.0", "typing-extensions>=4.11", "azure-identity>=1.15.0", "openai>=2.8.0", @@ -52,13 +52,14 @@ readme = {file = ["README.md", "CHANGELOG.md"], content-type = "text/markdown"} [tool.setuptools.packages.find] exclude = [ - "tests*", + "agent-scripts*", + "azure.ai", + "azure", + "doc*", + "generated_samples*", "generated_tests*", "samples*", - "generated_samples*", - "doc*", - "azure", - "azure.ai", + "tests*", ] [tool.setuptools.package-data] diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic.py b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic.py index a3f87dcdeb81..a3da6b6cc721 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -59,8 +59,7 @@ response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -72,8 +71,7 @@ response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic_async.py b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic_async.py index 5894722ed72d..16492bca4bc1 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_basic_async.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -61,8 +61,7 @@ async def main() -> None: response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -74,8 +73,7 @@ async def main() -> None: response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic.py b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic.py index 1102d326b2f3..e4c065f8b9e1 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic.py @@ -18,7 +18,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -61,6 +61,8 @@ print(f"Added a user message to the conversation") response = openai_client.responses.create( - conversation=conversation.id, extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, input="" + conversation=conversation.id, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + input="", ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic_async.py b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic_async.py index 5cae332aa01f..7925a87f5f8b 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_retrieve_basic_async.py @@ -18,7 +18,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" aiohttp python-dotenv + pip install "azure-ai-projects>=2.0.0b4" aiohttp python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -64,8 +64,7 @@ async def main(): response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_stream_events.py b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_stream_events.py index 2e90a148bf9c..aee3058b1d13 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_stream_events.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_stream_events.py @@ -18,7 +18,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -59,8 +59,7 @@ with openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) as response_stream_events: diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output.py b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output.py index 31d84821591e..94492b9f5d71 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -22,7 +21,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv pydantic + pip install "azure-ai-projects>=2.0.0b4" python-dotenv pydantic Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -37,7 +36,7 @@ from azure.ai.projects import AIProjectClient from azure.ai.projects.models import ( PromptAgentDefinition, - PromptAgentDefinitionText, + PromptAgentDefinitionTextOptions, TextResponseFormatJsonSchema, ) from pydantic import BaseModel, Field @@ -64,7 +63,7 @@ class CalendarEvent(BaseModel): agent_name="MyAgent", definition=PromptAgentDefinition( model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema(name="CalendarEvent", schema=CalendarEvent.model_json_schema()) ), instructions=""" @@ -88,8 +87,7 @@ class CalendarEvent(BaseModel): response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output_async.py b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output_async.py index beb96d3800a9..c74900ccf423 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_agent_structured_output_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -22,7 +21,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp pydantic + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp pydantic Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -38,7 +37,7 @@ from azure.ai.projects.aio import AIProjectClient from azure.ai.projects.models import ( PromptAgentDefinition, - PromptAgentDefinitionText, + PromptAgentDefinitionTextOptions, TextResponseFormatJsonSchema, ) from pydantic import BaseModel, Field @@ -65,7 +64,7 @@ async def main() -> None: agent_name="MyAgent", definition=PromptAgentDefinition( model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema(name="CalendarEvent", schema=CalendarEvent.model_json_schema()) ), instructions=""" @@ -89,8 +88,7 @@ async def main() -> None: response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent.py b/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent.py index 65e51a97aa6c..61fd40e27700 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -29,9 +29,9 @@ from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient from azure.ai.projects.models import ( + FoundryFeaturesOptInKeys, PromptAgentDefinition, WorkflowAgentDefinition, - ItemResourceType, ) load_dotenv() @@ -138,6 +138,7 @@ workflow = project_client.agents.create_version( agent_name="student-teacher-workflow", definition=WorkflowAgentDefinition(workflow=workflow_yaml), + foundry_features=FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW, ) print(f"Agent created (id: {workflow.id}, name: {workflow.name}, version: {workflow.version})") @@ -147,17 +148,17 @@ stream = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": workflow.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=True, - metadata={"x-ms-debug-mode-enabled": "1"}, + # REMOVE ME? metadata={"x-ms-debug-mode-enabled": "1"}, ) for event in stream: print(f"Event {event.sequence_number} type '{event.type}'", end="") if ( event.type == "response.output_item.added" or event.type == "response.output_item.done" - ) and event.item.type == ItemResourceType.WORKFLOW_ACTION: + ) and event.item.type == "workflow_action": print( f": item action ID '{event.item.action_id}' is '{event.item.status}' (previous action ID: '{event.item.previous_action_id}')", end="", diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_async.py b/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_async.py index 293fbcf5fa09..9a89e2cc49d1 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_async.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -27,12 +27,12 @@ import asyncio from dotenv import load_dotenv +from azure.ai.projects.models._enums import FoundryFeaturesOptInKeys from azure.identity.aio import DefaultAzureCredential from azure.ai.projects.aio import AIProjectClient from azure.ai.projects.models import ( PromptAgentDefinition, WorkflowAgentDefinition, - ItemResourceType, ) load_dotenv() @@ -140,6 +140,7 @@ async def main(): workflow = await project_client.agents.create_version( agent_name="student-teacher-workflow-async", definition=WorkflowAgentDefinition(workflow=workflow_yaml), + foundry_features=FoundryFeaturesOptInKeys.WORKFLOW_AGENTS_V1_PREVIEW, ) print(f"Agent created (id: {workflow.id}, name: {workflow.name}, version: {workflow.version})") @@ -149,17 +150,17 @@ async def main(): stream = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": workflow.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=True, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) async for event in stream: print(f"Event {event.sequence_number} type '{event.type}'", end="") if ( event.type == "response.output_item.added" or event.type == "response.output_item.done" - ) and event.item.type == ItemResourceType.WORKFLOW_ACTION: + ) and event.item.type == "workflow_action": print( f": item action ID '{event.item.action_id}' is '{event.item.status}' (previous action ID: '{event.item.previous_action_id}')", end="", diff --git a/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_azure_monitor_tracing.py b/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_azure_monitor_tracing.py index 5ceede581e59..dc8675c9ba59 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_azure_monitor_tracing.py +++ b/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_azure_monitor_tracing.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv azure-monitor-opentelemetry + pip install "azure-ai-projects>=2.0.0b4" python-dotenv azure-monitor-opentelemetry Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -72,7 +72,7 @@ response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, input="What is the size of France in square miles?", ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing.py b/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing.py index 85e844cc5c27..b49a3ef32fb6 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing.py +++ b/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv opentelemetry-sdk azure-core-tracing-opentelemetry + pip install "azure-ai-projects>=2.0.0b4" python-dotenv opentelemetry-sdk azure-core-tracing-opentelemetry Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -106,7 +105,7 @@ def display_conversation_item(item: Any) -> None: request = "Hello, tell me a joke." response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, input=request, ) print(f"Answer: {response.output}") @@ -114,7 +113,7 @@ def display_conversation_item(item: Any) -> None: response = openai_client.responses.create( conversation=conversation.id, input="Tell another one about computers.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Answer: {response.output}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing_custom_attributes.py b/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing_custom_attributes.py index 0864fcc3f9d9..f402ab25cab3 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing_custom_attributes.py +++ b/sdk/ai/azure-ai-projects/samples/agents/telemetry/sample_agent_basic_with_console_tracing_custom_attributes.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv opentelemetry-sdk azure-core-tracing-opentelemetry + pip install "azure-ai-projects>=2.0.0b4" python-dotenv opentelemetry-sdk azure-core-tracing-opentelemetry Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/get_weather_func_app.py b/sdk/ai/azure-ai-projects/samples/agents/tools/get_weather_func_app.py new file mode 100644 index 000000000000..bf2885acc8cd --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/get_weather_func_app.py @@ -0,0 +1,39 @@ +# pylint: disable=line-too-long,useless-suppression +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +This is a sample Azure Function app used by sample_agent_azure_function.py +to demonstrate how to integrate Azure Functions with AI Agents using queue triggers. +""" + +# import azure.functions as func +# import logging +# import json + +# app = func.FunctionApp() + +# @app.queue_trigger(arg_name="msg", queue_name="input", connection="STORAGE_CONNECTION") +# @app.queue_output(arg_name="outputQueue", queue_name="output", connection="STORAGE_CONNECTION") +# def queue_trigger(msg: func.QueueMessage, outputQueue: func.Out[str]): +# try: +# messagepayload: dict = json.loads(msg.get_body().decode("utf-8")) +# logging.info(f"The function receives the following message: {json.dumps(messagepayload)}") + +# function_args: dict = messagepayload.get("function_args", {}) +# location: str = function_args.get("location") + + +# weather_result = f"Weather is {len(location)} degrees and sunny in {location}" +# response_message = { +# "Value": weather_result, +# "CorrelationId": messagepayload["CorrelationId"] +# } +# logging.info(f"The function returns the following message through the {outputQueue} queue: {json.dumps(response_message)}") + +# outputQueue.set(json.dumps(response_message)) + +# except Exception as e: +# logging.error(f"Error processing message: {e}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_ai_search.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_ai_search.py index 876ed221a2fe..8783568fa4f0 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_ai_search.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_ai_search.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -84,7 +84,7 @@ stream=True, tool_choice="required", input=user_input, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_azure_function.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_azure_function.py new file mode 100644 index 000000000000..2af4eee4fb46 --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_azure_function.py @@ -0,0 +1,104 @@ +# pylint: disable=line-too-long,useless-suppression +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + This sample demonstrates how to create an AI agent with Microsoft Fabric capabilities + using the MicrosoftFabricPreviewTool and synchronous Azure AI Projects client. The agent can query + Fabric data sources and provide responses based on data analysis. + +USAGE: + python sample_agent_fabric.py + + Before running the sample: + + pip install "azure-ai-projects>=2.0.0b1" python-dotenv + + Set these environment variables with your own values: + 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview + page of your Microsoft Foundry portal. + 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in + the "Models + endpoints" tab in your Microsoft Foundry project. + 3) STORAGE_INPUT_QUEUE_NAME - The name of the Azure Storage Queue to use for input and output in the Azure Function tool. + 4) STORAGE_OUTPUT_QUEUE_NAME - The name of the Azure Storage Queue to use for output in the Azure Function tool. + 5) STORAGE_QUEUE_SERVICE_ENDPOINT - The endpoint of the Azure Storage Queue service. +""" + +import os +from dotenv import load_dotenv +from azure.identity import DefaultAzureCredential +from azure.ai.projects import AIProjectClient +from azure.ai.projects.models import ( + AzureFunctionBinding, + AzureFunctionDefinition, + AzureFunctionStorageQueue, + AzureFunctionDefinitionFunction, + AzureFunctionTool, + PromptAgentDefinition, +) + +load_dotenv() + +agent = None + +endpoint = os.environ["AZURE_AI_PROJECT_ENDPOINT"] + +with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential) as project_client, + project_client.get_openai_client() as openai_client, +): + + # [START tool_declaration] + tool = AzureFunctionTool( + azure_function=AzureFunctionDefinition( + input_binding=AzureFunctionBinding( + storage_queue=AzureFunctionStorageQueue( + queue_name=os.environ["STORAGE_INPUT_QUEUE_NAME"], + queue_service_endpoint=os.environ["STORAGE_QUEUE_SERVICE_ENDPOINT"], + ) + ), + output_binding=AzureFunctionBinding( + storage_queue=AzureFunctionStorageQueue( + queue_name=os.environ["STORAGE_OUTPUT_QUEUE_NAME"], + queue_service_endpoint=os.environ["STORAGE_QUEUE_SERVICE_ENDPOINT"], + ) + ), + function=AzureFunctionDefinitionFunction( + name="queue_trigger", + description="Get weather for a given location", + parameters={ + "type": "object", + "properties": {"location": {"type": "string", "description": "location to determine weather for"}}, + }, + ), + ) + ) + # [END tool_declaration] + + agent = project_client.agents.create_version( + agent_name="MyAgent", + definition=PromptAgentDefinition( + model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], + instructions="You are a helpful assistant.", + tools=[tool], + ), + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + user_input = "What is the weather in Seattle?" + + response = openai_client.responses.create( + tool_choice="required", + input=user_input, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + ) + + print(f"Response output: {response.output_text}") + + print("\nCleaning up...") + project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) + print("Agent deleted") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_custom_search.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_custom_search.py index ea15b1c331a5..f352972b8138 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_custom_search.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_custom_search.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -79,7 +78,7 @@ stream_response = openai_client.responses.create( stream=True, input=user_input, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_grounding.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_grounding.py index b09aa64347ee..e6a122d4b4db 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_grounding.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_bing_grounding.py @@ -22,7 +22,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -78,7 +78,7 @@ stream=True, tool_choice="required", input="What is today's date and whether in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_browser_automation.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_browser_automation.py index 5156baa55fd3..21c111adbde7 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_browser_automation.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_browser_automation.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -79,7 +79,7 @@ Enter the value 'MSFT', to get information about the Microsoft stock price. At the top of the resulting page you will see a default chart of Microsoft stock price. Click on 'YTD' at the top of that chart, and report the percent value that shows up just below it.""", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter.py index 443f736d5cff..8e704d684dec 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter.py @@ -7,14 +7,14 @@ """ DESCRIPTION: This sample demonstrates how to run Prompt Agent operations - using the Code Interpreter Tool and a synchronous client followed by downloading the generated file. + using the Code Interpreter Tool and a synchronous client. USAGE: python sample_agent_code_interpreter.py Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -24,11 +24,10 @@ """ import os -import tempfile from dotenv import load_dotenv from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient -from azure.ai.projects.models import PromptAgentDefinition, CodeInterpreterTool, CodeInterpreterContainerAuto +from azure.ai.projects.models import PromptAgentDefinition, CodeInterpreterTool load_dotenv() @@ -41,18 +40,9 @@ ): # [START tool_declaration] - # Load the CSV file to be processed - asset_file_path = os.path.abspath( - os.path.join(os.path.dirname(__file__), "../assets/synthetic_500_quarterly_results.csv") - ) - - # Upload the CSV file for the code interpreter - file = openai_client.files.create(purpose="assistants", file=open(asset_file_path, "rb")) - tool = CodeInterpreterTool(container=CodeInterpreterContainerAuto(file_ids=[file.id])) + tool = CodeInterpreterTool() # [END tool_declaration] - print(f"File uploaded (id: {file.id})") - # Create agent with code interpreter tool agent = project_client.agents.create_version( agent_name="MyAgent", @@ -69,45 +59,25 @@ conversation = openai_client.conversations.create() print(f"Created conversation (id: {conversation.id})") - # Send request to create a chart and generate a file + # Send request for the agent to generate a multiplication chart. response = openai_client.responses.create( conversation=conversation.id, - input="Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + input="Could you please generate a multiplication chart showing the products for 1-10 multiplied by 1-10 (a 10x10 times table)?", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + tool_choice="required", ) print(f"Response completed (id: {response.id})") - # Extract file information from response annotations - file_id = "" - filename = "" - container_id = "" - - # Get the last message which should contain file citations - last_message = response.output[-1] # ResponseOutputMessage - if ( - last_message.type == "message" - and last_message.content - and last_message.content[-1].type == "output_text" - and last_message.content[-1].annotations - ): - file_citation = last_message.content[-1].annotations[-1] # AnnotationContainerFileCitation - if file_citation.type == "container_file_citation": - file_id = file_citation.file_id - filename = file_citation.filename - container_id = file_citation.container_id - print(f"Found generated file: {filename} (ID: {file_id})") + # Print code executed by the code interpreter tool. + # [START code_output_extraction] + code = next((output.code for output in response.output if output.type == "code_interpreter_call"), "") + print(f"Code Interpreter code:") + print(code) + # [END code_output_extraction] + + # Print final assistant text output. + print(f"Agent response: {response.output_text}") print("\nCleaning up...") project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) print("Agent deleted") - - # Download the generated file if available - if file_id and filename: - file_content = openai_client.containers.files.content.retrieve(file_id=file_id, container_id=container_id) - print(f"File ready for download: {filename}") - file_path = os.path.join(tempfile.gettempdir(), filename) - with open(file_path, "wb") as f: - f.write(file_content.read()) - print(f"File downloaded successfully: {file_path}") - else: - print("No file generated in response") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_async.py index 0f8f8eacf6ee..6a1c0f03b990 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_async.py @@ -7,14 +7,14 @@ """ DESCRIPTION: This sample demonstrates how to run Prompt Agent operations - using the Code Interpreter Tool and an asynchronous client followed by downloading the generated file. + using the Code Interpreter Tool and an asynchronous client. USAGE: python sample_agent_code_interpreter_async.py Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -23,13 +23,12 @@ the "Models + endpoints" tab in your Microsoft Foundry project. """ -import os -import tempfile import asyncio +import os from dotenv import load_dotenv from azure.identity.aio import DefaultAzureCredential from azure.ai.projects.aio import AIProjectClient -from azure.ai.projects.models import PromptAgentDefinition, CodeInterpreterTool, CodeInterpreterContainerAuto +from azure.ai.projects.models import PromptAgentDefinition, CodeInterpreterTool load_dotenv() @@ -37,90 +36,51 @@ async def main() -> None: - """Main async function to demonstrate code interpreter with async client and credential management.""" - async with ( DefaultAzureCredential() as credential, AIProjectClient(endpoint=endpoint, credential=credential) as project_client, project_client.get_openai_client() as openai_client, ): - try: - # Load the CSV file to be processed - asset_file_path = os.path.abspath( - os.path.join(os.path.dirname(__file__), "../assets/synthetic_500_quarterly_results.csv") - ) - - # Upload the CSV file for the code interpreter to use - with open(asset_file_path, "rb") as file_data: - file = await openai_client.files.create(purpose="assistants", file=file_data) - print(f"File uploaded (id: {file.id})") - - # Create agent with code interpreter tool - agent = await project_client.agents.create_version( - agent_name="MyAgent", - definition=PromptAgentDefinition( - model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], - instructions="You are a helpful assistant.", - tools=[CodeInterpreterTool(container=CodeInterpreterContainerAuto(file_ids=[file.id]))], - ), - description="Code interpreter agent for data analysis and visualization.", - ) - print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") - - # Create a conversation for the agent interaction - conversation = await openai_client.conversations.create() - print(f"Created conversation (id: {conversation.id})") - - # Send request to create a chart and generate a file - response = await openai_client.responses.create( - conversation=conversation.id, - input="Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - ) - print(f"Response completed (id: {response.id})") - - # Extract file information from response annotations - file_id = "" - filename = "" - container_id = "" - - # Get the last message which should contain file citations - last_message = response.output[-1] # ResponseOutputMessage - if ( - last_message.type == "message" - and last_message.content - and last_message.content[-1].type == "output_text" - and last_message.content[-1].annotations - ): - file_citation = last_message.content[-1].annotations[-1] # AnnotationContainerFileCitation - if file_citation.type == "container_file_citation": - file_id = file_citation.file_id - filename = file_citation.filename - container_id = file_citation.container_id - print(f"Found generated file: {filename} (ID: {file_id})") - - print("\nCleaning up...") - await project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) - print("Agent deleted") - - # Download the generated file if available - if file_id and filename: - file_content = await openai_client.containers.files.content.retrieve( - file_id=file_id, container_id=container_id - ) - print(f"File ready for download: {filename}") - file_path = os.path.join(tempfile.gettempdir(), filename) - with open(file_path, "wb") as f: - f.write(file_content.read()) - print(f"File downloaded successfully: {file_path}") - else: - print("No file generated in response") - - except Exception as e: - print(f"Error occurred: {str(e)}") - raise + + tool = CodeInterpreterTool() + + # Create agent with code interpreter tool + agent = await project_client.agents.create_version( + agent_name="MyAgent", + definition=PromptAgentDefinition( + model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], + instructions="You are a helpful assistant.", + tools=[tool], + ), + description="Code interpreter agent for data analysis and visualization.", + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + # Create a conversation for the agent interaction + conversation = await openai_client.conversations.create() + print(f"Created conversation (id: {conversation.id})") + + # Send request for the agent to generate a multiplication chart. + response = await openai_client.responses.create( + conversation=conversation.id, + input="Could you please generate a multiplication chart showing the products for 1-10 multiplied by 1-10 (a 10x10 times table)?", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + tool_choice="required", + ) + print(f"Response completed (id: {response.id})") + + # Print code executed by the code interpreter tool. + code = next((output.code for output in response.output if output.type == "code_interpreter_call"), None) + if code: + print(f"Code Interpreter code:\n {code}") + + # Print final assistant text output. + print(f"Agent response: {response.output_text}") + + print("\nCleaning up...") + await project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) + print("Agent deleted") if __name__ == "__main__": - # Run the async main function asyncio.run(main()) diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_with_files.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_with_files.py new file mode 100644 index 000000000000..1cbb7decf773 --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_with_files.py @@ -0,0 +1,112 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + This sample demonstrates how to run Prompt Agent operations + using the Code Interpreter Tool and a synchronous client followed by downloading the generated file. + +USAGE: + python sample_agent_code_interpreter_with_files.py + + Before running the sample: + + pip install "azure-ai-projects>=2.0.0b4" python-dotenv + + Set these environment variables with your own values: + 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview + page of your Microsoft Foundry portal. + 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in + the "Models + endpoints" tab in your Microsoft Foundry project. +""" + +import os +import tempfile +from dotenv import load_dotenv +from azure.identity import DefaultAzureCredential +from azure.ai.projects import AIProjectClient +from azure.ai.projects.models import PromptAgentDefinition, CodeInterpreterTool, CodeInterpreterContainerAuto + +load_dotenv() + +endpoint = os.environ["AZURE_AI_PROJECT_ENDPOINT"] + +with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential) as project_client, + project_client.get_openai_client() as openai_client, +): + + # [START tool_declaration] + # Load the CSV file to be processed + asset_file_path = os.path.abspath( + os.path.join(os.path.dirname(__file__), "../assets/synthetic_500_quarterly_results.csv") + ) + + # Upload the CSV file for the code interpreter + file = openai_client.files.create(purpose="assistants", file=open(asset_file_path, "rb")) + tool = CodeInterpreterTool(container=CodeInterpreterContainerAuto(file_ids=[file.id])) + # [END tool_declaration] + + print(f"File uploaded (id: {file.id})") + + # Create agent with code interpreter tool + agent = project_client.agents.create_version( + agent_name="MyAgent", + definition=PromptAgentDefinition( + model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], + instructions="You are a helpful assistant.", + tools=[tool], + ), + description="Code interpreter agent for data analysis and visualization.", + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + # Create a conversation for the agent interaction + conversation = openai_client.conversations.create() + print(f"Created conversation (id: {conversation.id})") + + # Send request to create a chart and generate a file + response = openai_client.responses.create( + conversation=conversation.id, + input="Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + ) + print(f"Response completed (id: {response.id})") + + # Extract file information from response annotations + file_id = "" + filename = "" + container_id = "" + + # Get the last message which should contain file citations + last_message = response.output[-1] # ResponseOutputMessage + if ( + last_message.type == "message" + and last_message.content + and last_message.content[-1].type == "output_text" + and last_message.content[-1].annotations + ): + file_citation = last_message.content[-1].annotations[-1] # AnnotationContainerFileCitation + if file_citation.type == "container_file_citation": + file_id = file_citation.file_id + filename = file_citation.filename + container_id = file_citation.container_id + print(f"Found generated file: {filename} (ID: {file_id})") + + print("\nCleaning up...") + project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) + print("Agent deleted") + + # Download the generated file if available + if file_id and filename: + file_content = openai_client.containers.files.content.retrieve(file_id=file_id, container_id=container_id) + print(f"File ready for download: {filename}") + file_path = os.path.join(tempfile.gettempdir(), filename) + with open(file_path, "wb") as f: + f.write(file_content.read()) + print(f"File downloaded successfully: {file_path}") + else: + print("No file generated in response") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_with_files_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_with_files_async.py new file mode 100644 index 000000000000..c20330a39cab --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_code_interpreter_with_files_async.py @@ -0,0 +1,125 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + This sample demonstrates how to run Prompt Agent operations + using the Code Interpreter Tool and an asynchronous client followed by downloading the generated file. + +USAGE: + python sample_agent_code_interpreter_async.py + + Before running the sample: + + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp + + Set these environment variables with your own values: + 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview + page of your Microsoft Foundry portal. + 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in + the "Models + endpoints" tab in your Microsoft Foundry project. +""" + +import os +import tempfile +import asyncio +from dotenv import load_dotenv +from azure.identity.aio import DefaultAzureCredential +from azure.ai.projects.aio import AIProjectClient +from azure.ai.projects.models import PromptAgentDefinition, CodeInterpreterTool, CodeInterpreterContainerAuto + +load_dotenv() + +endpoint = os.environ["AZURE_AI_PROJECT_ENDPOINT"] + + +async def main() -> None: + """Main async function to demonstrate code interpreter with async client and credential management.""" + + async with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential) as project_client, + project_client.get_openai_client() as openai_client, + ): + try: + # Load the CSV file to be processed + asset_file_path = os.path.abspath( + os.path.join(os.path.dirname(__file__), "../assets/synthetic_500_quarterly_results.csv") + ) + + # Upload the CSV file for the code interpreter to use + with open(asset_file_path, "rb") as file_data: + file = await openai_client.files.create(purpose="assistants", file=file_data) + print(f"File uploaded (id: {file.id})") + + # Create agent with code interpreter tool + agent = await project_client.agents.create_version( + agent_name="MyAgent", + definition=PromptAgentDefinition( + model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], + instructions="You are a helpful assistant.", + tools=[CodeInterpreterTool(container=CodeInterpreterContainerAuto(file_ids=[file.id]))], + ), + description="Code interpreter agent for data analysis and visualization.", + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + # Create a conversation for the agent interaction + conversation = await openai_client.conversations.create() + print(f"Created conversation (id: {conversation.id})") + + # Send request to create a chart and generate a file + response = await openai_client.responses.create( + conversation=conversation.id, + input="Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + ) + print(f"Response completed (id: {response.id})") + + # Extract file information from response annotations + file_id = "" + filename = "" + container_id = "" + + # Get the last message which should contain file citations + last_message = response.output[-1] # ResponseOutputMessage + if ( + last_message.type == "message" + and last_message.content + and last_message.content[-1].type == "output_text" + and last_message.content[-1].annotations + ): + file_citation = last_message.content[-1].annotations[-1] # AnnotationContainerFileCitation + if file_citation.type == "container_file_citation": + file_id = file_citation.file_id + filename = file_citation.filename + container_id = file_citation.container_id + print(f"Found generated file: {filename} (ID: {file_id})") + + print("\nCleaning up...") + await project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) + print("Agent deleted") + + # Download the generated file if available + if file_id and filename: + file_content = await openai_client.containers.files.content.retrieve( + file_id=file_id, container_id=container_id + ) + print(f"File ready for download: {filename}") + file_path = os.path.join(tempfile.gettempdir(), filename) + with open(file_path, "wb") as f: + f.write(file_content.read()) + print(f"File downloaded successfully: {file_path}") + else: + print("No file generated in response") + + except Exception as e: + print(f"Error occurred: {str(e)}") + raise + + +if __name__ == "__main__": + # Run the async main function + asyncio.run(main()) diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use.py index 04c0a336bd39..dd0dcfd8080a 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use.py @@ -20,7 +20,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -68,7 +68,7 @@ # [END tool_declaration] agent = project_client.agents.create_version( - agent_name="ComputerUseAgent", + agent_name="MyAgent", definition=PromptAgentDefinition( model=os.environ.get("COMPUTER_USE_MODEL_DEPLOYMENT_NAME", "computer-use-preview"), instructions=""" @@ -101,7 +101,7 @@ ], } ], - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, truncation="auto", ) @@ -151,7 +151,7 @@ }, } ], - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, truncation="auto", ) diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use_async.py index 33d33ef33be6..b0123554212e 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_computer_use_async.py @@ -20,7 +20,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -70,7 +70,7 @@ async def main(): computer_use_tool = ComputerUsePreviewTool(display_width=1026, display_height=769, environment="windows") agent = await project_client.agents.create_version( - agent_name="ComputerUseAgent", + agent_name="MyAgent", definition=PromptAgentDefinition( model=os.environ.get("COMPUTER_USE_MODEL_DEPLOYMENT_NAME", "computer-use-preview"), instructions=""" @@ -103,7 +103,7 @@ async def main(): ], } ], - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, truncation="auto", ) @@ -155,7 +155,7 @@ async def main(): }, } ], - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, truncation="auto", ) diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_fabric.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_fabric.py index 3107cfe87e23..5b0d401d6113 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_fabric.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_fabric.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -68,13 +68,35 @@ user_input = os.environ.get("FABRIC_USER_INPUT") or input("Enter your question: \n") - response = openai_client.responses.create( + stream_response = openai_client.responses.create( tool_choice="required", + stream=True, input=user_input, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) - print(f"Response output: {response.output_text}") + for event in stream_response: + if event.type == "response.created": + print(f"Follow-up response created with ID: {event.response.id}") + elif event.type == "response.output_text.delta": + print(f"Delta: {event.delta}") + elif event.type == "response.text.done": + print(f"\nFollow-up response done!") + elif event.type == "response.output_item.done": + if event.item.type == "message": + item = event.item + if item.content[-1].type == "output_text": + text_content = item.content[-1] + for annotation in text_content.annotations: + if annotation.type == "url_citation": + print( + f"URL Citation: {annotation.url}, " + f"Start index: {annotation.start_index}, " + f"End index: {annotation.end_index}" + ) + elif event.type == "response.completed": + print(f"\nFollow-up completed!") + print(f"Full response: {event.response.output_text}") print("\nCleaning up...") project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search.py index 9351a29a8977..c008a3f1339e 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search.py @@ -13,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -76,7 +76,7 @@ response = openai_client.responses.create( conversation=conversation.id, input="Tell me about Contoso products", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Agent response: {response.output_text}") print("\nCleaning up...") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream.py index 21c04ba22bf6..e95d03aa3df9 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -89,7 +89,7 @@ "content": "Tell me about Contoso products and their features in detail. Please search through the available documentation.", }, ], - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print("Processing streaming file search results...\n") @@ -117,7 +117,7 @@ input=[ {"role": "user", "content": "Tell me about Smart Eyewear and its features."}, ], - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print("Processing follow-up streaming response...\n") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream_async.py index 31280352ac7c..22a30e9fe085 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_file_search_in_stream_async.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -90,7 +90,7 @@ async def main() -> None: }, ], tool_choice="required", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print("Processing streaming file search results...\n") @@ -122,7 +122,7 @@ async def main() -> None: }, ], tool_choice="required", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print("Processing follow-up streaming response...\n") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool.py index cfa1dad9ba7f..39e3065039c7 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -78,7 +78,7 @@ def get_horoscope(sign: str) -> str: # Prompt the model with tools defined response = openai_client.responses.create( input="What is my horoscope? I am an Aquarius.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -105,7 +105,7 @@ def get_horoscope(sign: str) -> str: response = openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Agent response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool_async.py index 9a70726fb2cf..0f76b0d18ebe 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_function_tool_async.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -79,7 +79,7 @@ async def main(): # Prompt the model with tools defined response = await openai_client.responses.create( input="What is my horoscope? I am an Aquarius.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -106,7 +106,7 @@ async def main(): response = await openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Agent response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation.py index 3fd58f5aa926..d752ce9f375f 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation.py @@ -6,38 +6,40 @@ """ DESCRIPTION: - This sample demonstrates how to create an AI agent with image generation capabilities - using the ImageGenTool and synchronous Azure AI Projects client. The agent can generate + This sample demonstrates how to create an AI Agent with image generation capabilities + using the ImageGenTool and synchronous Azure AI Projects client. The Agent can generate images based on text prompts and save them to files. The sample shows: - - Creating an agent with ImageGenTool configured for image generation + - Creating an Agent with ImageGenTool configured for image generation - Making requests to generate images from text prompts - Extracting base64-encoded image data from the response - Decoding and saving the generated image to a local file - Proper cleanup of created resources + For more information on Image Generations and what models are supported, see: + https://learn.microsoft.com/azure/ai-foundry/agents/how-to/tools/image-generation?pivots=python + USAGE: python sample_agent_image_generation.py Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview page of your Microsoft Foundry portal. 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the chat model (e.g., gpt-4o, gpt-4o-mini, gpt-5o, gpt-5o-mini) - used by the agent for understanding and responding to prompts. This is NOT the image generation model. - 3) IMAGE_GENERATION_MODEL_DEPLOYMENT_NAME - The deployment name of the image generation model (e.g., gpt-image-1-mini) + used by the Agent for understanding and responding to prompts. This is NOT the image generation model. + 3) IMAGE_GENERATION_MODEL_DEPLOYMENT_NAME - The deployment name of the image generation model (e.g. gpt-image-1) used by the ImageGenTool. NOTE: - - Image generation requires a separate "gpt-image-1-mini" deployment which is specified when constructing + - Image generation requires a separate (e.g. gpt-image-1) deployment which is specified when constructing the `ImageGenTool`, as well as providing it in the `x-ms-oai-image-generation-deployment` header when calling `.responses.create`. - - AZURE_AI_MODEL_DEPLOYMENT_NAME should be set to your chat model (e.g., gpt-4o), NOT "gpt-image-1-mini". - - The generated image will be saved as "microsoft.png" in the OS temporary directory. + - The generated image will be saved as "happy-dogs.png" in the OS temporary directory. """ import base64 @@ -61,8 +63,8 @@ image_generation_model = os.environ["IMAGE_GENERATION_MODEL_DEPLOYMENT_NAME"] # [START tool_declaration] - tool = ImageGenTool( # type: ignore[call-overload] - model=image_generation_model, # Model such as "gpt-image-1-mini" # type: ignore + tool = ImageGenTool( + model=image_generation_model, # Model such as "gpt-image-1" quality="low", size="1024x1024", ) @@ -80,11 +82,13 @@ print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") response = openai_client.responses.create( - input="Generate an image of Microsoft logo.", + input="""Generate an image showing four Labrador Retriever dogs, with the Microsoft Logo in the + background, such that each dog is placed sitting inside one of the four logo squares. Add the + text 'Happy dogs!' at the bottom of the image.""", extra_headers={ "x-ms-oai-image-generation-deployment": image_generation_model }, # this is required at the moment for image generation - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response created: {response.id}") @@ -96,7 +100,7 @@ image_data = [output.result for output in response.output if output.type == "image_generation_call"] if image_data and image_data[0]: print("Downloading generated image...") - filename = "microsoft.png" + filename = "happy-dogs.png" file_path = os.path.join(tempfile.gettempdir(), filename) with open(file_path, "wb") as f: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation_async.py index 0ad945453783..78595d6c6bd0 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_image_generation_async.py @@ -6,38 +6,40 @@ """ DESCRIPTION: - This sample demonstrates how to create an AI agent with image generation capabilities - using the ImageGenTool and asynchronous Azure AI Projects client. The agent can generate + This sample demonstrates how to create an AI Agent with image generation capabilities + using the ImageGenTool and asynchronous Azure AI Projects client. The Agent can generate images based on text prompts and save them to files. The sample shows: - - Creating an agent with ImageGenTool configured for image generation + - Creating an Agent with ImageGenTool configured for image generation - Making requests to generate images from text prompts - Extracting base64-encoded image data from the response - Decoding and saving the generated image to a local file - Proper cleanup of created resources + For more information on Image Generations and what models are supported, see: + https://learn.microsoft.com/azure/ai-foundry/agents/how-to/tools/image-generation?pivots=python + USAGE: python sample_agent_image_generation_async.py Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview page of your Microsoft Foundry portal. - 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in - the "Models + endpoints" tab in your Microsoft Foundry project. - 3) IMAGE_GENERATION_MODEL_DEPLOYMENT_NAME - The deployment name of the image generation model (e.g., gpt-image-1-mini) + 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the chat model (e.g., gpt-4o, gpt-4o-mini, gpt-5o, gpt-5o-mini) + used by the Agent for understanding and responding to prompts. This is NOT the image generation model. + 3) IMAGE_GENERATION_MODEL_DEPLOYMENT_NAME - The deployment name of the image generation model (e.g. gpt-image-1) used by the ImageGenTool. NOTE: - - Image generation requires a separate "gpt-image-1-mini" deployment which is specified when constructing + - Image generation requires a separate (e.g. gpt-image-1) deployment which is specified when constructing the `ImageGenTool`, as well as providing it in the `x-ms-oai-image-generation-deployment` header when calling `.responses.create`. - - AZURE_AI_MODEL_DEPLOYMENT_NAME should be set to your chat model (e.g., gpt-4o), NOT "gpt-image-1-mini". - - The generated image will be saved as "microsoft.png" in the OS temporary directory. + - The generated image will be saved as "happy-dogs.png" in the OS temporary directory. """ import asyncio @@ -68,18 +70,20 @@ async def main(): definition=PromptAgentDefinition( model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], instructions="Generate images based on user prompts", - tools=[ImageGenTool(model=image_generation_model, quality="low", size="1024x1024")], # type: ignore + tools=[ImageGenTool(model=image_generation_model, quality="low", size="1024x1024")], ), description="Agent for image generation.", ) print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") response = await openai_client.responses.create( - input="Generate an image of Microsoft logo.", + input="""Generate an image showing four Labrador Retriever dogs, with the Microsoft Logo in the + background, such that each dog is placed sitting inside one of the four logo squares. Add the + text 'Happy dogs!' at the bottom of the image.""", extra_headers={ "x-ms-oai-image-generation-deployment": image_generation_model }, # this is required at the moment for image generation - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response created: {response.id}") @@ -91,7 +95,7 @@ async def main(): image_data = [output.result for output in response.output if output.type == "image_generation_call"] if image_data and image_data[0]: print("Downloading generated image...") - filename = "microsoft.png" + filename = "happy-dogs.png" file_path = os.path.join(tempfile.gettempdir(), filename) with open(file_path, "wb") as f: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp.py index 17fcbe97df6f..758abe9ddd44 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -66,7 +66,7 @@ response = openai_client.responses.create( conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Process any MCP approval requests that were generated @@ -92,7 +92,7 @@ response = openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Agent response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_async.py index ddcbc3e4614c..56cb3420308c 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_async.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -70,7 +70,7 @@ async def main(): response = await openai_client.responses.create( conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Process any MCP approval requests that were generated @@ -96,7 +96,7 @@ async def main(): response = await openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Agent response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection.py index 3534a00ae3eb..35272ac2625b 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -72,7 +71,7 @@ response = openai_client.responses.create( conversation=conversation.id, input="What is my username in Github profile?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Process any MCP approval requests that were generated @@ -98,7 +97,7 @@ response = openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection_async.py index 2ccad0ca0a03..7161c0a1e297 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_mcp_with_project_connection_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -74,7 +73,7 @@ async def main(): response = await openai_client.responses.create( conversation=conversation.id, input="What is my username in GitHub profile?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Process any MCP approval requests that were generated @@ -99,7 +98,7 @@ async def main(): response = await openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search.py index dd08e302693d..babd595c8d6f 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -18,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Deploy a chat model (e.g. gpt-4.1) and an embedding model (e.g. text-embedding-3-small). Once you have deployed models, set the deployment name in the variables below. @@ -60,7 +59,7 @@ # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - project_client.memory_stores.delete(memory_store_name) + project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -73,7 +72,7 @@ user_profile_enabled=True, chat_summary_enabled=True ), # Note: This line will not be needed once the service is fixed to use correct defaults ) - memory_store = project_client.memory_stores.create( + memory_store = project_client.beta.memory_stores.create( name=memory_store_name, description="Example memory store for conversations", definition=definition, @@ -112,7 +111,7 @@ response = openai_client.responses.create( input="I prefer dark roast coffee", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -128,7 +127,7 @@ new_response = openai_client.responses.create( input="Please order my usual coffee", conversation=new_conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {new_response.output_text}") @@ -140,5 +139,5 @@ project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) print("Agent deleted") - project_client.memory_stores.delete(memory_store.name) + project_client.beta.memory_stores.delete(memory_store.name) print("Memory store deleted") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search_async.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search_async.py index 4a54942a9f7a..7ed02461f05b 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search_async.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_memory_search_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -18,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Deploy a chat model (e.g. gpt-4.1) and an embedding model (e.g. text-embedding-3-small). Once you have deployed models, set the deployment name in the variables below. @@ -63,7 +62,7 @@ async def main() -> None: # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - await project_client.memory_stores.delete(memory_store_name) + await project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -76,7 +75,7 @@ async def main() -> None: user_profile_enabled=True, chat_summary_enabled=True ), # Note: This line will not be needed once the service is fixed to use correct defaults ) - memory_store = await project_client.memory_stores.create( + memory_store = await project_client.beta.memory_stores.create( name=memory_store_name, description="Example memory store for conversations", definition=definition, @@ -113,7 +112,7 @@ async def main() -> None: response = await openai_client.responses.create( input="I prefer dark roast coffee", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -129,7 +128,7 @@ async def main() -> None: new_response = await openai_client.responses.create( input="Please order my usual coffee", conversation=new_conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {new_response.output_text}") @@ -141,7 +140,7 @@ async def main() -> None: await project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) print("Agent deleted") - await project_client.memory_stores.delete(memory_store.name) + await project_client.beta.memory_stores.delete(memory_store.name) print("Memory store deleted") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi.py index 94f71a6b4634..bf398a3de250 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv jsonref + pip install "azure-ai-projects>=2.0.0b4" python-dotenv jsonref Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -26,7 +26,7 @@ import os import jsonref from dotenv import load_dotenv - +from typing import Any, cast from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient from azure.ai.projects.models import ( @@ -50,7 +50,7 @@ # [START tool_declaration] with open(weather_asset_file_path, "r") as f: - openapi_weather = jsonref.loads(f.read()) + openapi_weather = cast(dict[str, Any], jsonref.loads(f.read())) tool = OpenApiTool( openapi=OpenApiFunctionDefinition( @@ -74,7 +74,7 @@ response = openai_client.responses.create( input="Use the OpenAPI tool to print out, what is the weather in Seattle, WA today.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Agent response: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi_with_project_connection.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi_with_project_connection.py index b1f4e2022321..b8b9dbb5308c 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi_with_project_connection.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_openapi_with_project_connection.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv jsonref + pip install "azure-ai-projects>=2.0.0b4" python-dotenv jsonref Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -29,7 +29,7 @@ import os import jsonref from dotenv import load_dotenv - +from typing import Any, cast from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient from azure.ai.projects.models import ( @@ -56,7 +56,7 @@ # [START tool_declaration] with open(tripadvisor_asset_file_path, "r") as f: - openapi_tripadvisor = jsonref.loads(f.read()) + openapi_tripadvisor = cast(dict[str, Any], jsonref.loads(f.read())) tool = OpenApiTool( openapi=OpenApiFunctionDefinition( @@ -84,7 +84,7 @@ response = openai_client.responses.create( input="Recommend me 5 top hotels in paris, France", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # The response to the question may contain non ASCII letters. To avoid error, encode and re decode them. print(f"Response created: {response.output_text.encode().decode('ascii', errors='ignore')}") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_sharepoint.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_sharepoint.py index 4388b73f3f53..7c28af7d0cf0 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_sharepoint.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_sharepoint.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -77,7 +76,7 @@ stream_response = openai_client.responses.create( stream=True, input=user_input, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_to_agent.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_to_agent.py index b190090f9cf3..3bc2b36ab620 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_to_agent.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_to_agent.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -68,13 +68,15 @@ ) print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") - user_input = input("Enter your question (e.g., 'What can the secondary agent do?'): \n") + user_input = os.environ.get("A2A_USER_INPUT") or input( + "Enter your question (e.g., 'What can the secondary agent do?'): \n" + ) stream_response = openai_client.responses.create( stream=True, tool_choice="required", input=user_input, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search.py index 7ef45abec3dd..5bd603f0a529 100644 --- a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search.py +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search.py @@ -13,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -27,7 +27,11 @@ from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient -from azure.ai.projects.models import PromptAgentDefinition, WebSearchPreviewTool, ApproximateLocation +from azure.ai.projects.models import ( + PromptAgentDefinition, + WebSearchTool, + WebSearchApproximateLocation, +) load_dotenv() @@ -40,9 +44,10 @@ project_client.get_openai_client() as openai_client, ): # [START tool_declaration] - tool = WebSearchPreviewTool(user_location=ApproximateLocation(country="GB", city="London", region="London")) + tool = WebSearchTool( + user_location=WebSearchApproximateLocation(type="approximate", country="GB", city="London", region="London") + ) # [END tool_declaration] - # Create Agent with web search tool agent = project_client.agents.create_version( agent_name="MyAgent", @@ -60,13 +65,36 @@ print(f"Created conversation (id: {conversation.id})") # Send a query to search the web - response = openai_client.responses.create( - conversation=conversation.id, - input="Show me the latest London Underground service updates", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + user_input = "Show me the latest London Underground service updates" + stream_response = openai_client.responses.create( + stream=True, + input=user_input, + tool_choice="required", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) - print(f"Agent response: {response.output_text}") + for event in stream_response: + if event.type == "response.created": + print(f"Follow-up response created with ID: {event.response.id}") + elif event.type == "response.output_text.delta": + print(f"Delta: {event.delta}") + elif event.type == "response.text.done": + print(f"\nFollow-up response done!") + elif event.type == "response.output_item.done": + if event.item.type == "message": + item = event.item + if item.content[-1].type == "output_text": + text_content = item.content[-1] + for annotation in text_content.annotations: + if annotation.type == "url_citation": + print( + f"URL Citation: {annotation.url}, " + f"Start index: {annotation.start_index}, " + f"End index: {annotation.end_index}" + ) + elif event.type == "response.completed": + print(f"\nFollow-up completed!") + print(f"Full response: {event.response.output_text}") print("\nCleaning up...") project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) print("Agent deleted") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_preview.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_preview.py new file mode 100644 index 000000000000..fdc7352baa97 --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_preview.py @@ -0,0 +1,95 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + This sample demonstrates how to run Prompt Agent operations + using the Web Search Preview Tool and a synchronous client. + +USAGE: + python sample_agent_web_search_preview.py + + Before running the sample: + + pip install "azure-ai-projects>=2.0.0b4" python-dotenv + + Set these environment variables with your own values: + 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview + page of your Microsoft Foundry portal. + 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in + the "Models + endpoints" tab in your Microsoft Foundry project. +""" + +import os +from dotenv import load_dotenv + +from azure.identity import DefaultAzureCredential +from azure.ai.projects import AIProjectClient +from azure.ai.projects.models import PromptAgentDefinition, WebSearchPreviewTool, ApproximateLocation + +load_dotenv() + + +endpoint = os.environ["AZURE_AI_PROJECT_ENDPOINT"] + +with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential) as project_client, + project_client.get_openai_client() as openai_client, +): + # [START tool_declaration] + tool = WebSearchPreviewTool(user_location=ApproximateLocation(country="GB", city="London", region="London")) + # [END tool_declaration] + # Create Agent with web search tool + agent = project_client.agents.create_version( + agent_name="MyAgent105", + definition=PromptAgentDefinition( + model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], + instructions="You are a helpful assistant that can search the web", + tools=[tool], + ), + description="Agent for web search.", + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + # Create a conversation for the agent interaction + conversation = openai_client.conversations.create() + print(f"Created conversation (id: {conversation.id})") + + # Send a query to search the web + user_input = "Show me the latest London Underground service updates" + stream_response = openai_client.responses.create( + stream=True, + input=user_input, + tool_choice="required", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + ) + + for event in stream_response: + if event.type == "response.created": + print(f"Follow-up response created with ID: {event.response.id}") + elif event.type == "response.output_text.delta": + print(f"Delta: {event.delta}") + elif event.type == "response.text.done": + print(f"\nFollow-up response done!") + elif event.type == "response.output_item.done": + if event.item.type == "message": + item = event.item + if item.content[-1].type == "output_text": + text_content = item.content[-1] + for annotation in text_content.annotations: + if annotation.type == "url_citation": + print( + f"URL Citation: {annotation.url}, " + f"Start index: {annotation.start_index}, " + f"End index: {annotation.end_index}" + ) + elif event.type == "response.completed": + print(f"\nFollow-up completed!") + print(f"Full response: {event.response.output_text}") + + print("\nCleaning up...") + project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) + print("Agent deleted") diff --git a/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_with_custom_search.py b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_with_custom_search.py new file mode 100644 index 000000000000..6db6a8cfe171 --- /dev/null +++ b/sdk/ai/azure-ai-projects/samples/agents/tools/sample_agent_web_search_with_custom_search.py @@ -0,0 +1,111 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ + +""" +DESCRIPTION: + Demonstrates Prompt Agent operations that use the Web Search Tool configured + with a Bing Custom Search connection. The agent runs synchronously and + pulls results from your specified custom search instance. + +USAGE: + python sample_agent_web_search_with_custom_search.py + + Before running the sample: + + pip install "azure-ai-projects>=2.0.0b4" python-dotenv + + Set these environment variables with your own values: + 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview + page of your Microsoft Foundry portal. + 2) AZURE_AI_MODEL_DEPLOYMENT_NAME - The deployment name of the AI model, as found under the "Name" column in + the "Models + endpoints" tab in your Microsoft Foundry project. + 3) BING_CUSTOM_SEARCH_PROJECT_CONNECTION_ID - The Bing Custom Search project connection ID, + as found in the "Connections" tab in your Microsoft Foundry project. + 4) BING_CUSTOM_SEARCH_INSTANCE_NAME - The Bing Custom Search instance name + 5) BING_CUSTOM_USER_INPUT - (Optional) The question to ask. If not set, you will be prompted. +""" + +import os +from dotenv import load_dotenv + +from azure.identity import DefaultAzureCredential +from azure.ai.projects import AIProjectClient +from azure.ai.projects.models import ( + PromptAgentDefinition, + WebSearchTool, + WebSearchConfiguration, +) + +load_dotenv() + + +endpoint = os.environ["AZURE_AI_PROJECT_ENDPOINT"] + +with ( + DefaultAzureCredential() as credential, + AIProjectClient(endpoint=endpoint, credential=credential) as project_client, + project_client.get_openai_client() as openai_client, +): + # [START tool_declaration] + tool = WebSearchTool( + custom_search_configuration=WebSearchConfiguration( + project_connection_id=os.environ["BING_CUSTOM_SEARCH_PROJECT_CONNECTION_ID"], + instance_name=os.environ["BING_CUSTOM_SEARCH_INSTANCE_NAME"], + ) + ) + # [END tool_declaration] + # Create Agent with web search tool + agent = project_client.agents.create_version( + agent_name="MyAgent", + definition=PromptAgentDefinition( + model=os.environ["AZURE_AI_MODEL_DEPLOYMENT_NAME"], + instructions="You are a helpful assistant that can search the web and bing", + tools=[tool], + ), + description="Agent for web search.", + ) + print(f"Agent created (id: {agent.id}, name: {agent.name}, version: {agent.version})") + + # Create a conversation for the agent interaction + conversation = openai_client.conversations.create() + print(f"Created conversation (id: {conversation.id})") + + user_input = os.environ.get("BING_CUSTOM_USER_INPUT") or input("Enter your question: \n") + + # Send a query to search the web + # Send initial request that will trigger the Bing Custom Search tool + stream_response = openai_client.responses.create( + stream=True, + input=user_input, + tool_choice="required", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, + ) + + for event in stream_response: + if event.type == "response.created": + print(f"Follow-up response created with ID: {event.response.id}") + elif event.type == "response.output_text.delta": + print(f"Delta: {event.delta}") + elif event.type == "response.text.done": + print(f"\nFollow-up response done!") + elif event.type == "response.output_item.done": + if event.item.type == "message": + item = event.item + if item.content[-1].type == "output_text": + text_content = item.content[-1] + for annotation in text_content.annotations: + if annotation.type == "url_citation": + print( + f"URL Citation: {annotation.url}, " + f"Start index: {annotation.start_index}, " + f"End index: {annotation.end_index}" + ) + elif event.type == "response.completed": + print(f"\nFollow-up completed!") + print(f"Full response: {event.response.output_text}") + + print("\nCleaning up...") + project_client.agents.delete_version(agent_name=agent.name, agent_version=agent.version) + print("Agent deleted") diff --git a/sdk/ai/azure-ai-projects/samples/connections/sample_connections.py b/sdk/ai/azure-ai-projects/samples/connections/sample_connections.py index 33266e030587..6a075b23b96c 100644 --- a/sdk/ai/azure-ai-projects/samples/connections/sample_connections.py +++ b/sdk/ai/azure-ai-projects/samples/connections/sample_connections.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/connections/sample_connections_async.py b/sdk/ai/azure-ai-projects/samples/connections/sample_connections_async.py index f199e86ba35c..2e115e18aaf2 100644 --- a/sdk/ai/azure-ai-projects/samples/connections/sample_connections_async.py +++ b/sdk/ai/azure-ai-projects/samples/connections/sample_connections_async.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets.py b/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets.py index 5521931ed21c..a2c2c30c9e0b 100644 --- a/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets.py +++ b/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_async.py b/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_async.py index 4c36b4518c79..d159fea9e2af 100644 --- a/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_async.py +++ b/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_async.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_download.py b/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_download.py index dc701ca81b81..2600f864c365 100644 --- a/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_download.py +++ b/sdk/ai/azure-ai-projects/samples/datasets/sample_datasets_download.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments.py b/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments.py index 295e713d1846..70a3a981e015 100644 --- a/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments.py +++ b/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments.py @@ -13,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments_async.py b/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments_async.py index cd0c322c6fbc..bbc5db10b6d4 100644 --- a/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments_async.py +++ b/sdk/ai/azure-ai-projects/samples/deployments/sample_deployments_async.py @@ -13,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/README.md b/sdk/ai/azure-ai-projects/samples/evaluations/README.md index ef774d201eaa..6a8897879a9c 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/README.md +++ b/sdk/ai/azure-ai-projects/samples/evaluations/README.md @@ -7,7 +7,7 @@ This folder contains samples demonstrating how to use Azure AI Foundry's evaluat Before running any sample: ```bash -pip install "azure-ai-projects>=2.0.0b1" python-dotenv +pip install "azure-ai-projects>=2.0.0b4" python-dotenv ``` Set these environment variables: diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_coherence.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_coherence.py index 4f3b93813bb4..7cc8638693e5 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_coherence.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_coherence.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_fluency.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_fluency.py index fc51bf844426..cd4dce1ce152 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_fluency.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_fluency.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/agent_utils.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/agent_utils.py index bf96688d496a..b26362f7d7be 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/agent_utils.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/agent_utils.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/sample_generic_agentic_evaluator.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/sample_generic_agentic_evaluator.py index b4cd599e684d..a21b770b777b 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/sample_generic_agentic_evaluator.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/sample_generic_agentic_evaluator.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/schema_mappings.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/schema_mappings.py index b4cc19dad3fd..e3ca39d2a119 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/schema_mappings.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_generic_agentic_evaluator/schema_mappings.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_groundedness.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_groundedness.py index e59ae572009a..ab22619ee672 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_groundedness.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_groundedness.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_intent_resolution.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_intent_resolution.py index 176733e9894e..97b23e78e02f 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_intent_resolution.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_intent_resolution.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_relevance.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_relevance.py index c6046938fc63..2010cb056409 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_relevance.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_relevance.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_response_completeness.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_response_completeness.py index e63911bfbb9a..e009731db128 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_response_completeness.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_response_completeness.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_adherence.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_adherence.py index 0cbc213e475a..67c2dad71fbb 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_adherence.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_adherence.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_completion.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_completion.py index e91915fd67ad..87804396d05b 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_completion.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_completion.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_navigation_efficiency.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_navigation_efficiency.py index cac84b1c9750..f1f9353d3e77 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_navigation_efficiency.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_task_navigation_efficiency.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_accuracy.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_accuracy.py index c70261d52d9e..7903ae929512 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_accuracy.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_accuracy.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_success.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_success.py index 9e9ed9d042bb..84211c2cf320 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_success.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_call_success.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_input_accuracy.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_input_accuracy.py index c6479709cda7..f3d0f6a688a7 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_input_accuracy.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_input_accuracy.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_output_utilization.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_output_utilization.py index 172cb4fa9f3c..6ee61ee717f6 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_output_utilization.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_output_utilization.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_selection.py b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_selection.py index 571f2060c2cc..8ab24c315d0e 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_selection.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/agentic_evaluators/sample_tool_selection.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_evaluation.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_evaluation.py index af587d75b6b7..b2590349893a 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_evaluation.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_evaluation.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation.py index 3ae0c4b4db98..e139c416d856 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -63,8 +63,7 @@ response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text} (id: {response.id})") diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation_with_function_tool.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation_with_function_tool.py index 64b7099abf1e..769c3e84104c 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation_with_function_tool.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_agent_response_evaluation_with_function_tool.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -87,7 +87,7 @@ def get_horoscope(sign: str) -> str: # Prompt the model with tools defined response = openai_client.responses.create( input="What is my horoscope? I am an Aquarius.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -114,7 +114,7 @@ def get_horoscope(sign: str) -> str: response = openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text} (id: {response.id})") diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_continuous_evaluation_rule.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_continuous_evaluation_rule.py index 9a9972678e0c..8187edf8c274 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_continuous_evaluation_rule.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_continuous_evaluation_rule.py @@ -25,7 +25,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -106,8 +106,7 @@ response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") @@ -123,8 +122,7 @@ response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response output: {response.output_text}") diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog.py index f00b953f6c37..354981c054e0 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -96,7 +96,7 @@ }, ), ) - prompt_evaluator = project_client.evaluators.create_version( + prompt_evaluator = project_client.beta.evaluators.create_version( name="my_custom_evaluator_code_prompt_based", evaluator_version=evaluator_version, ) @@ -133,27 +133,28 @@ }, ), ) - code_evaluator = project_client.evaluators.create_version( - name="my_custom_evaluator_code_based", evaluator_version=evaluator_version + code_evaluator = project_client.beta.evaluators.create_version( + name="my_custom_evaluator_code_based", + evaluator_version=evaluator_version, ) pprint(code_evaluator) print("Get code based evaluator version") - code_evaluator_latest = project_client.evaluators.get_version( + code_evaluator_latest = project_client.beta.evaluators.get_version( name=code_evaluator.name, version=code_evaluator.version, ) pprint(code_evaluator_latest) print("Get prompt based evaluator version") - prompt_evaluator_latest = project_client.evaluators.get_version( + prompt_evaluator_latest = project_client.beta.evaluators.get_version( name=prompt_evaluator.name, version=prompt_evaluator.version, ) pprint(prompt_evaluator_latest) print("Updating code based evaluator version") - updated_evaluator = project_client.evaluators.update_version( + updated_evaluator = project_client.beta.evaluators.update_version( name=code_evaluator.name, version=code_evaluator.version, evaluator_version={ @@ -165,24 +166,24 @@ pprint(updated_evaluator) print("Deleting code based evaluator version") - project_client.evaluators.delete_version( + project_client.beta.evaluators.delete_version( name=code_evaluator_latest.name, version=code_evaluator_latest.version, ) - project_client.evaluators.delete_version( + project_client.beta.evaluators.delete_version( name=prompt_evaluator_latest.name, version=prompt_evaluator_latest.version, ) print("Getting list of builtin evaluator versions") - evaluators = project_client.evaluators.list_latest_versions(type="builtin") + evaluators = project_client.beta.evaluators.list_latest_versions(type="builtin") print("List of builtin evaluator versions") for evaluator in evaluators: pprint(evaluator) print("Getting list of custom evaluator versions") - evaluators = project_client.evaluators.list_latest_versions(type="custom") + evaluators = project_client.beta.evaluators.list_latest_versions(type="custom") print("List of custom evaluator versions") for evaluator in evaluators: pprint(evaluator) diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_code_based_evaluators.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_code_based_evaluators.py index d4dec7209354..7e3028bad04b 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_code_based_evaluators.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_code_based_evaluators.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -52,7 +52,7 @@ ): print("Creating a single evaluator version - Code based (json style)") - code_evaluator = project_client.evaluators.create_version( + code_evaluator = project_client.beta.evaluators.create_version( name="my_custom_evaluator_code", evaluator_version={ "name": "my_custom_evaluator_code", @@ -199,7 +199,7 @@ print("Waiting for evaluation run to complete...") print("Deleting the created evaluator version") - project_client.evaluators.delete_version( + project_client.beta.evaluators.delete_version( name=code_evaluator.name, version=code_evaluator.version, ) diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_prompt_based_evaluators.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_prompt_based_evaluators.py index 9c13d93b3d29..b8038190d484 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_prompt_based_evaluators.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_eval_catalog_prompt_based_evaluators.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -85,7 +85,7 @@ ): print("Creating a single evaluator version - Prompt based (json style)") - prompt_evaluator = project_client.evaluators.create_version( + prompt_evaluator = project_client.beta.evaluators.create_version( name="my_custom_evaluator_prompt", evaluator_version={ "name": "my_custom_evaluator_prompt", @@ -265,7 +265,7 @@ print("Waiting for eval run to complete...") print("Deleting the created evaluator version") - project_client.evaluators.delete_version( + project_client.beta.evaluators.delete_version( name=prompt_evaluator.name, version=prompt_evaluator.version, ) diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_cluster_insight.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_cluster_insight.py index d0ff775ca3bf..ef1e4c9377d8 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_cluster_insight.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_cluster_insight.py @@ -18,7 +18,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -32,8 +32,12 @@ from typing import Union from pprint import pprint from dotenv import load_dotenv -from azure.ai.projects.models._enums import OperationState -from azure.ai.projects.models._models import EvaluationRunClusterInsightsRequest, Insight, InsightModelConfiguration +from azure.ai.projects.models import ( + OperationState, + EvaluationRunClusterInsightRequest, + Insight, + InsightModelConfiguration, +) from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient from openai.types.eval_create_params import DataSourceConfigCustom, TestingCriterionLabelModel @@ -118,21 +122,21 @@ print("\n✓ Evaluation run completed successfully!") print(f"Evaluation run result counts: {eval_run.result_counts}") - clusterInsight = project_client.insights.generate( - Insight( + clusterInsight = project_client.beta.insights.generate( + insight=Insight( display_name="Cluster analysis", - request=EvaluationRunClusterInsightsRequest( + request=EvaluationRunClusterInsightRequest( eval_id=eval_object.id, run_ids=[eval_run.id], model_configuration=InsightModelConfiguration(model_deployment_name=model_deployment_name), ), - ) + ), ) print(f"Started insight generation (id: {clusterInsight.id})") while clusterInsight.state not in [OperationState.SUCCEEDED, OperationState.FAILED]: - print("Waiting for insight to be generated...") - clusterInsight = project_client.insights.get(id=clusterInsight.id) + print(f"Waiting for insight to be generated...") + clusterInsight = project_client.beta.insights.get(id=clusterInsight.id) print(f"Insight status: {clusterInsight.state}") time.sleep(5) diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_compare_insight.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_compare_insight.py index 953003de1ce1..0d7e6065a124 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_compare_insight.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluation_compare_insight.py @@ -18,7 +18,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -31,8 +31,11 @@ import time from pprint import pprint from dotenv import load_dotenv -from azure.ai.projects.models._enums import OperationState -from azure.ai.projects.models._models import EvaluationComparisonRequest, Insight +from azure.ai.projects.models import ( + OperationState, + EvaluationComparisonInsightRequest, + Insight, +) from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient from openai.types.eval_create_params import DataSourceConfigCustom, TestingCriterionLabelModel @@ -131,18 +134,18 @@ print("\n✓ Both evaluation runs completed successfully!") # Generate comparison insights - compareInsight = project_client.insights.generate( - Insight( + compareInsight = project_client.beta.insights.generate( + insight=Insight( display_name="Comparison of Evaluation Runs", - request=EvaluationComparisonRequest( + request=EvaluationComparisonInsightRequest( eval_id=eval_object.id, baseline_run_id=eval_run_1.id, treatment_run_ids=[eval_run_2.id] ), - ) + ), ) print(f"Started insight generation (id: {compareInsight.id})") while compareInsight.state not in [OperationState.SUCCEEDED, OperationState.FAILED]: - compareInsight = project_client.insights.get(id=compareInsight.id) + compareInsight = project_client.beta.insights.get(id=compareInsight.id) print(f"Waiting for insight to be generated...current status: {compareInsight.state}") time.sleep(5) diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_ai_assisted.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_ai_assisted.py index 4312245c1b12..efa8af0ba58f 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_ai_assisted.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_ai_assisted.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_dataset_id.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_dataset_id.py index 209f26daf171..a1998429e8b0 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_dataset_id.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_dataset_id.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data.py index 642ec007ce7e..0ce61c5b6186 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data_oai.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data_oai.py index ef8a44ba47d4..f69a7c8d19b4 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data_oai.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_inline_data_oai.py @@ -43,8 +43,7 @@ client = OpenAI( api_key=get_bearer_token_provider(DefaultAzureCredential(), "https://ai.azure.com/.default"), - base_url=os.environ["AZURE_AI_PROJECT_ENDPOINT"].rstrip("/") + "/openai", - default_query={"api-version": "2025-11-15-preview"}, + base_url=os.environ["AZURE_AI_PROJECT_ENDPOINT"].rstrip("/") + "/openai/v1", ) model_deployment_name = os.environ.get("AZURE_AI_MODEL_DEPLOYMENT_NAME", "") # Sample : gpt-4o-mini diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py index 8658a605498f..249705035cb5 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv azure-monitor-query + pip install "azure-ai-projects>=2.0.0b4" python-dotenv azure-monitor-query Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_graders.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_graders.py index d8c89f72666c..5138132c6bd2 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_graders.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_graders.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_model_evaluation.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_model_evaluation.py index 91e45ecf3355..38a4e921d118 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_model_evaluation.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_model_evaluation.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py index 4773ae76102c..a5c8f8d5b99d 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_redteam_evaluations.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -93,7 +93,7 @@ def main() -> None: description="Taxonomy for red teaming evaluation", taxonomy_input=agent_taxonomy_input ) - taxonomy = project_client.evaluation_taxonomies.create(name=agent_name, body=eval_taxonomy_input) + taxonomy = project_client.beta.evaluation_taxonomies.create(name=agent_name, body=eval_taxonomy_input) taxonomy_path = os.path.join(tempfile.gettempdir(), f"taxonomy_{agent_name}.json") with open(taxonomy_path, "w") as f: f.write(json.dumps(_to_json_primitive(taxonomy), indent=2)) diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py index 18ba9481a951..afbe2f0bc10d 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv azure-mgmt-authorization azure-mgmt-resource + pip install "azure-ai-projects>=2.0.0b4" python-dotenv azure-mgmt-authorization azure-mgmt-resource Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -301,7 +301,7 @@ def schedule_dataset_evaluation() -> None: trigger=RecurrenceTrigger(interval=1, schedule=DailyRecurrenceSchedule(hours=[9])), # Every day at 9 AM task=EvaluationScheduleTask(eval_id=eval_object.id, eval_run=eval_run_object), ) - schedule_response = project_client.schedules.create_or_update( + schedule_response = project_client.beta.schedules.create_or_update( id="dataset-eval-run-schedule-9am", schedule=schedule ) @@ -309,12 +309,12 @@ def schedule_dataset_evaluation() -> None: pprint(schedule_response) time.sleep(5) # Wait for schedule to be fully created - schedule_runs = project_client.schedules.list_runs(schedule_response.id) + schedule_runs = project_client.beta.schedules.list_runs(schedule_response.id) print(f"Listing schedule runs for schedule id: {schedule_response.id}") for run in schedule_runs: pprint(run) - project_client.schedules.delete(schedule_response.id) + project_client.beta.schedules.delete(schedule_response.id) print("Schedule deleted") client.evals.delete(eval_id=eval_object.id) @@ -380,7 +380,7 @@ def schedule_redteam_evaluation() -> None: description="Taxonomy for red teaming evaluation", taxonomy_input=agent_taxonomy_input ) - taxonomy = project_client.evaluation_taxonomies.create(name=agent_name, body=eval_taxonomy_input) + taxonomy = project_client.beta.evaluation_taxonomies.create(name=agent_name, body=eval_taxonomy_input) taxonomy_path = os.path.join(data_folder, f"taxonomy_{agent_name}.json") # Create the data folder if it doesn't exist os.makedirs(data_folder, exist_ok=True) @@ -409,7 +409,7 @@ def schedule_redteam_evaluation() -> None: trigger=RecurrenceTrigger(interval=1, schedule=DailyRecurrenceSchedule(hours=[9])), # Every day at 9 AM task=EvaluationScheduleTask(eval_id=eval_object.id, eval_run=eval_run_object), ) - schedule_response = project_client.schedules.create_or_update( + schedule_response = project_client.beta.schedules.create_or_update( id="redteam-eval-run-schedule-9am", schedule=schedule ) @@ -417,12 +417,12 @@ def schedule_redteam_evaluation() -> None: pprint(schedule_response) time.sleep(5) # Wait for schedule to be fully created - schedule_runs = project_client.schedules.list_runs(schedule_response.id) + schedule_runs = project_client.beta.schedules.list_runs(schedule_response.id) print(f"Listing schedule runs for schedule id: {schedule_response.id}") for run in schedule_runs: pprint(run) - project_client.schedules.delete(schedule_response.id) + project_client.beta.schedules.delete(schedule_response.id) print("Schedule deleted") client.evals.delete(eval_id=eval_object.id) diff --git a/sdk/ai/azure-ai-projects/samples/files/sample_files.py b/sdk/ai/azure-ai-projects/samples/files/sample_files.py index 7b70bf34c9ea..41e2b544ac49 100644 --- a/sdk/ai/azure-ai-projects/samples/files/sample_files.py +++ b/sdk/ai/azure-ai-projects/samples/files/sample_files.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/files/sample_files_async.py b/sdk/ai/azure-ai-projects/samples/files/sample_files_async.py index e417171ed002..1b3e61b64af3 100644 --- a/sdk/ai/azure-ai-projects/samples/files/sample_files_async.py +++ b/sdk/ai/azure-ai-projects/samples/files/sample_files_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job.py index 6e619bcd84b9..5d76a9b7de0b 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job_async.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job_async.py index 5b2064b284e1..50d6cb2c4432 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job_async.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_dpo_job_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job.py index 6e7b4d26cea8..0d504adc1d93 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job.py @@ -15,7 +15,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -75,7 +75,7 @@ "trainingType": "GlobalStandard" }, # Recommended approach to set trainingType. Omitting this field may lead to unsupported behavior. # Preferred trainingtype is GlobalStandard. Note: Global training offers cost savings , but copies data and weights outside the current resource region. - # Learn more - https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/ and https://azure.microsoft.com/en-us/explore/global-infrastructure/data-residency/ + # Learn more - https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/ and https://azure.microsoft.com/explore/global-infrastructure/data-residency/ ) print(fine_tuning_job) # [END finetuning_oss_model_supervised_job_sample] diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job_async.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job_async.py index 0335e45febe9..87ab3df3fb3b 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job_async.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_oss_models_supervised_job_async.py @@ -15,7 +15,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -78,7 +78,7 @@ async def main(): "trainingType": "GlobalStandard" }, # Recommended approach to set trainingType. Omitting this field may lead to unsupported behavior. # Preferred trainingtype is GlobalStandard. Note: Global training offers cost savings , but copies data and weights outside the current resource region. - # Learn more - https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/ and https://azure.microsoft.com/en-us/explore/global-infrastructure/data-residency/ + # Learn more - https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/ and https://azure.microsoft.com/explore/global-infrastructure/data-residency/ ) print(fine_tuning_job) diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job.py index 064f4c36e4d6..c34023825f6a 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job_async.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job_async.py index 81cbade07c75..ebddbc37452c 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job_async.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_reinforcement_job_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job.py index 78131c9b9f8f..a48a613f919b 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job.py @@ -18,7 +18,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv azure-mgmt-cognitiveservices + pip install "azure-ai-projects>=2.0.0b4" python-dotenv azure-mgmt-cognitiveservices Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job_async.py b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job_async.py index 7ed68304bc17..86d67171429b 100644 --- a/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job_async.py +++ b/sdk/ai/azure-ai-projects/samples/finetuning/sample_finetuning_supervised_job_async.py @@ -18,7 +18,7 @@ Before running the sample: - pip install azure-ai-projects>=2.0.0b1 python-dotenv aiohttp azure-mgmt-cognitiveservices + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp azure-mgmt-cognitiveservices Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes.py b/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes.py index d8429f8d1ff1..9534aae7e309 100644 --- a/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes.py +++ b/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes_async.py b/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes_async.py index ce37089d20d6..1c7745863c20 100644 --- a/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes_async.py +++ b/sdk/ai/azure-ai-projects/samples/indexes/sample_indexes_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -15,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/mcp_client/sample_mcp_tool_async.py b/sdk/ai/azure-ai-projects/samples/mcp_client/sample_mcp_tool_async.py index de76f3097ceb..216fd54a7057 100644 --- a/sdk/ai/azure-ai-projects/samples/mcp_client/sample_mcp_tool_async.py +++ b/sdk/ai/azure-ai-projects/samples/mcp_client/sample_mcp_tool_async.py @@ -26,7 +26,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv mcp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv mcp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced.py b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced.py index 93d2a41866e4..c26b282e46e6 100644 --- a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced.py +++ b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced.py @@ -18,7 +18,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Deploy a chat model (e.g. gpt-4.1) and an embedding model (e.g. text-embedding-3-small). Once you have deployed models, set the deployment name in the variables below. @@ -56,7 +56,7 @@ # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - project_client.memory_stores.delete(memory_store_name) + project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -72,7 +72,7 @@ embedding_model=os.environ["MEMORY_STORE_EMBEDDING_MODEL_DEPLOYMENT_NAME"], options=options, ) - memory_store = project_client.memory_stores.create( + memory_store = project_client.beta.memory_stores.create( name=memory_store_name, description="Example memory store for conversations", definition=definition, @@ -84,8 +84,10 @@ scope = "user_123" # Extract memories from messages and add them to the memory store - user_message = EasyInputMessage(role="user", content="I prefer dark roast coffee and usually drink it in the morning") - update_poller = project_client.memory_stores.begin_update_memories( + user_message = EasyInputMessage( + role="user", content="I prefer dark roast coffee and usually drink it in the morning" + ) + update_poller = project_client.beta.memory_stores.begin_update_memories( name=memory_store.name, scope=scope, items=[user_message], # Pass conversation items that you want to add to memory @@ -95,7 +97,7 @@ # Extend the previous update with another update and more messages new_message = EasyInputMessage(role="user", content="I also like cappuccinos in the afternoon") - new_update_poller = project_client.memory_stores.begin_update_memories( + new_update_poller = project_client.beta.memory_stores.begin_update_memories( name=memory_store.name, scope=scope, items=[new_message], @@ -122,17 +124,22 @@ # Retrieve memories from the memory store query_message = EasyInputMessage(role="user", content="What are my morning coffee preferences?") - search_response = project_client.memory_stores.search_memories( - name=memory_store.name, scope=scope, items=[query_message], options=MemorySearchOptions(max_memories=5) + search_response = project_client.beta.memory_stores.search_memories( + name=memory_store.name, + scope=scope, + items=[query_message], + options=MemorySearchOptions(max_memories=5), ) print(f"Found {len(search_response.memories)} memories") for memory in search_response.memories: print(f" - Memory ID: {memory.memory_item.memory_id}, Content: {memory.memory_item.content}") # Perform another search using the previous search as context - agent_message = EasyInputMessage(role="assistant", content="You previously indicated a preference for dark roast coffee in the morning.") + agent_message = EasyInputMessage( + role="assistant", content="You previously indicated a preference for dark roast coffee in the morning." + ) followup_query = EasyInputMessage(role="user", content="What about afternoon?") - followup_search_response = project_client.memory_stores.search_memories( + followup_search_response = project_client.beta.memory_stores.search_memories( name=memory_store.name, scope=scope, items=[agent_message, followup_query], @@ -144,9 +151,9 @@ print(f" - Memory ID: {memory.memory_item.memory_id}, Content: {memory.memory_item.content}") # Delete memories for the current scope - project_client.memory_stores.delete_scope(name=memory_store.name, scope=scope) + project_client.beta.memory_stores.delete_scope(name=memory_store.name, scope=scope) print(f"Deleted memories for scope '{scope}'") # Delete memory store - project_client.memory_stores.delete(memory_store.name) + project_client.beta.memory_stores.delete(memory_store.name) print(f"Deleted memory store `{memory_store.name}`") diff --git a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced_async.py b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced_async.py index 0f607302208e..2cb1867498a5 100644 --- a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced_async.py +++ b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_advanced_async.py @@ -18,7 +18,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Deploy a chat model (e.g. gpt-4.1) and an embedding model (e.g. text-embedding-3-small). Once you have deployed models, set the deployment name in the variables below. @@ -60,7 +60,7 @@ async def main() -> None: # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - await project_client.memory_stores.delete(memory_store_name) + await project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -76,7 +76,7 @@ async def main() -> None: embedding_model=os.environ["MEMORY_STORE_EMBEDDING_MODEL_DEPLOYMENT_NAME"], options=options, ) - memory_store = await project_client.memory_stores.create( + memory_store = await project_client.beta.memory_stores.create( name=memory_store_name, description="Example memory store for conversations", definition=definition, @@ -88,8 +88,10 @@ async def main() -> None: scope = "user_123" # Extract memories from messages and add them to the memory store - user_message = EasyInputMessage(role="user", content="I prefer dark roast coffee and usually drink it in the morning") - update_poller = await project_client.memory_stores.begin_update_memories( + user_message = EasyInputMessage( + role="user", content="I prefer dark roast coffee and usually drink it in the morning" + ) + update_poller = await project_client.beta.memory_stores.begin_update_memories( name=memory_store.name, scope=scope, items=[user_message], # Pass conversation items that you want to add to memory @@ -101,7 +103,7 @@ async def main() -> None: # Extend the previous update with another update and more messages new_message = EasyInputMessage(role="user", content="I also like cappuccinos in the afternoon") - new_update_poller = await project_client.memory_stores.begin_update_memories( + new_update_poller = await project_client.beta.memory_stores.begin_update_memories( name=memory_store.name, scope=scope, items=[new_message], @@ -128,17 +130,22 @@ async def main() -> None: # Retrieve memories from the memory store query_message = EasyInputMessage(role="user", content="What are my morning coffee preferences?") - search_response = await project_client.memory_stores.search_memories( - name=memory_store.name, scope=scope, items=[query_message], options=MemorySearchOptions(max_memories=5) + search_response = await project_client.beta.memory_stores.search_memories( + name=memory_store.name, + scope=scope, + items=[query_message], + options=MemorySearchOptions(max_memories=5), ) print(f"Found {len(search_response.memories)} memories") for memory in search_response.memories: print(f" - Memory ID: {memory.memory_item.memory_id}, Content: {memory.memory_item.content}") # Perform another search using the previous search as context - agent_message = EasyInputMessage(role="assistant", content="You previously indicated a preference for dark roast coffee in the morning.") + agent_message = EasyInputMessage( + role="assistant", content="You previously indicated a preference for dark roast coffee in the morning." + ) followup_query = EasyInputMessage(role="user", content="What about afternoon?") - followup_search_response = await project_client.memory_stores.search_memories( + followup_search_response = await project_client.beta.memory_stores.search_memories( name=memory_store.name, scope=scope, items=[agent_message, followup_query], @@ -150,11 +157,11 @@ async def main() -> None: print(f" - Memory ID: {memory.memory_item.memory_id}, Content: {memory.memory_item.content}") # Delete memories for the current scope - await project_client.memory_stores.delete_scope(name=memory_store.name, scope=scope) + await project_client.beta.memory_stores.delete_scope(name=memory_store.name, scope=scope) print(f"Deleted memories for scope '{scope}'") # Delete memory store - await project_client.memory_stores.delete(memory_store.name) + await project_client.beta.memory_stores.delete(memory_store.name) print(f"Deleted memory store `{memory_store.name}`") diff --git a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic.py b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic.py index 3969e8ffb779..13be2c2ac935 100644 --- a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic.py +++ b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Deploy a chat model (e.g. gpt-4.1) and an embedding model (e.g. text-embedding-3-small). Once you have deployed models, set the deployment name in the variables below. @@ -54,7 +54,7 @@ # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - project_client.memory_stores.delete(memory_store_name) + project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -67,7 +67,7 @@ user_profile_enabled=True, chat_summary_enabled=True ), # Note: This line will not be needed once the service is fixed to use correct defaults ) - memory_store = project_client.memory_stores.create( + memory_store = project_client.beta.memory_stores.create( name=memory_store_name, description="Example memory store for conversations", definition=definition, @@ -82,8 +82,10 @@ scope = "user_123" # Add a memory to the memory store - user_message = EasyInputMessage(role="user", content="I prefer dark roast coffee and usually drink it in the morning") - update_poller = project_client.memory_stores.begin_update_memories( + user_message = EasyInputMessage( + role="user", content="I prefer dark roast coffee and usually drink it in the morning" + ) + update_poller = project_client.beta.memory_stores.begin_update_memories( name=memory_store.name, scope=scope, items=[user_message], # Pass conversation items that you want to add to memory @@ -100,17 +102,20 @@ # Retrieve memories from the memory store query_message = EasyInputMessage(role="user", content="What are my coffee preferences?") - search_response = project_client.memory_stores.search_memories( - name=memory_store.name, scope=scope, items=[query_message], options=MemorySearchOptions(max_memories=5) + search_response = project_client.beta.memory_stores.search_memories( + name=memory_store.name, + scope=scope, + items=[query_message], + options=MemorySearchOptions(max_memories=5), ) print(f"Found {len(search_response.memories)} memories") for memory in search_response.memories: print(f" - Memory ID: {memory.memory_item.memory_id}, Content: {memory.memory_item.content}") # Delete memories for a specific scope - project_client.memory_stores.delete_scope(name=memory_store.name, scope=scope) + project_client.beta.memory_stores.delete_scope(name=memory_store.name, scope=scope) print(f"Deleted memories for scope '{scope}'") # Delete memory store - project_client.memory_stores.delete(memory_store.name) + project_client.beta.memory_stores.delete(memory_store.name) print(f"Deleted memory store `{memory_store.name}`") diff --git a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic_async.py b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic_async.py index 6cf110c3a932..9ccceb86995b 100644 --- a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic_async.py +++ b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_basic_async.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Deploy a chat model (e.g. gpt-4.1) and an embedding model (e.g. text-embedding-3-small). Once you have deployed models, set the deployment name in the variables below. @@ -59,7 +59,7 @@ async def main() -> None: # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - await project_client.memory_stores.delete(memory_store_name) + await project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -72,7 +72,7 @@ async def main() -> None: user_profile_enabled=True, chat_summary_enabled=True ), # Note: This line will not be needed once the service is fixed to use correct defaults ) - memory_store = await project_client.memory_stores.create( + memory_store = await project_client.beta.memory_stores.create( name=memory_store_name, description="Example memory store for conversations", definition=definition, @@ -87,8 +87,10 @@ async def main() -> None: scope = "user_123" # Add a memory to the memory store - user_message = EasyInputMessage(role="user", content="I prefer dark roast coffee and usually drink it in the morning") - update_poller = await project_client.memory_stores.begin_update_memories( + user_message = EasyInputMessage( + role="user", content="I prefer dark roast coffee and usually drink it in the morning" + ) + update_poller = await project_client.beta.memory_stores.begin_update_memories( name=memory_store.name, scope=scope, items=[user_message], # Pass conversation items that you want to add to memory @@ -105,19 +107,22 @@ async def main() -> None: # Retrieve memories from the memory store query_message = EasyInputMessage(role="user", content="What are my coffee preferences?") - search_response = await project_client.memory_stores.search_memories( - name=memory_store.name, scope=scope, items=[query_message], options=MemorySearchOptions(max_memories=5) + search_response = await project_client.beta.memory_stores.search_memories( + name=memory_store.name, + scope=scope, + items=[query_message], + options=MemorySearchOptions(max_memories=5), ) print(f"Found {len(search_response.memories)} memories") for memory in search_response.memories: print(f" - Memory ID: {memory.memory_item.memory_id}, Content: {memory.memory_item.content}") # Delete memories for a specific scope - await project_client.memory_stores.delete_scope(name=memory_store.name, scope=scope) + await project_client.beta.memory_stores.delete_scope(name=memory_store.name, scope=scope) print(f"Deleted memories for scope '{scope}'") # Delete memory store - await project_client.memory_stores.delete(memory_store.name) + await project_client.beta.memory_stores.delete(memory_store.name) print(f"Deleted memory store `{memory_store.name}`") diff --git a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud.py b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud.py index 3101976e7c34..484af1e12131 100644 --- a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud.py +++ b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -47,7 +47,7 @@ # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - project_client.memory_stores.delete(memory_store_name) + project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -57,25 +57,30 @@ chat_model=os.environ["MEMORY_STORE_CHAT_MODEL_DEPLOYMENT_NAME"], embedding_model=os.environ["MEMORY_STORE_EMBEDDING_MODEL_DEPLOYMENT_NAME"], ) - memory_store = project_client.memory_stores.create( - name=memory_store_name, description="Example memory store for conversations", definition=definition + memory_store = project_client.beta.memory_stores.create( + name=memory_store_name, + description="Example memory store for conversations", + definition=definition, ) print(f"Created memory store: {memory_store.name} ({memory_store.id}): {memory_store.description}") # Get Memory Store - get_store = project_client.memory_stores.get(memory_store.name) + get_store = project_client.beta.memory_stores.get(memory_store.name) print(f"Retrieved: {get_store.name} ({get_store.id}): {get_store.description}") # Update Memory Store - updated_store = project_client.memory_stores.update(name=memory_store.name, description="Updated description") + updated_store = project_client.beta.memory_stores.update( + name=memory_store.name, + description="Updated description", + ) print(f"Updated: {updated_store.name} ({updated_store.id}): {updated_store.description}") # List Memory Store - memory_stores = list(project_client.memory_stores.list(limit=10)) + memory_stores = list(project_client.beta.memory_stores.list(limit=10)) print(f"Found {len(memory_stores)} memory stores") for store in memory_stores: print(f" - {store.name} ({store.id}): {store.description}") # Delete Memory Store - delete_response = project_client.memory_stores.delete(memory_store.name) + delete_response = project_client.beta.memory_stores.delete(memory_store.name) print(f"Deleted: {delete_response.deleted}") diff --git a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud_async.py b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud_async.py index 6d96c5d23aba..4761345ce126 100644 --- a/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud_async.py +++ b/sdk/ai/azure-ai-projects/samples/memories/sample_memory_crud_async.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview @@ -51,7 +51,7 @@ async def main() -> None: # Delete memory store, if it already exists memory_store_name = "my_memory_store" try: - await project_client.memory_stores.delete(memory_store_name) + await project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -61,31 +61,34 @@ async def main() -> None: chat_model=os.environ["MEMORY_STORE_CHAT_MODEL_DEPLOYMENT_NAME"], embedding_model=os.environ["MEMORY_STORE_EMBEDDING_MODEL_DEPLOYMENT_NAME"], ) - memory_store = await project_client.memory_stores.create( - name=memory_store_name, description="Example memory store for conversations", definition=definition + memory_store = await project_client.beta.memory_stores.create( + name=memory_store_name, + description="Example memory store for conversations", + definition=definition, ) print(f"Created memory store: {memory_store.name} ({memory_store.id}): {memory_store.description}") # Get Memory Store - get_store = await project_client.memory_stores.get(memory_store.name) + get_store = await project_client.beta.memory_stores.get(memory_store.name) print(f"Retrieved: {get_store.name} ({get_store.id}): {get_store.description}") # Update Memory Store - updated_store = await project_client.memory_stores.update( - name=memory_store.name, description="Updated description" + updated_store = await project_client.beta.memory_stores.update( + name=memory_store.name, + description="Updated description", ) print(f"Updated: {updated_store.name} ({updated_store.id}): {updated_store.description}") # List Memory Store memory_stores = [] - async for store in project_client.memory_stores.list(limit=10): + async for store in project_client.beta.memory_stores.list(limit=10): memory_stores.append(store) print(f"Found {len(memory_stores)} memory stores") for store in memory_stores: print(f" - {store.name} ({store.id}): {store.description}") # Delete Memory Store - delete_response = await project_client.memory_stores.delete(memory_store.name) + delete_response = await project_client.beta.memory_stores.delete(memory_store.name) print(f"Deleted: {delete_response.deleted}") diff --git a/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team.py b/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team.py index e5e2252501e5..45805f24eb95 100644 --- a/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team.py +++ b/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -64,7 +63,7 @@ ) # Create and run the Red Team scan - red_team_response = project_client.red_teams.create( + red_team_response = project_client.beta.red_teams.create( red_team=red_team, headers={ "model-endpoint": model_endpoint, @@ -75,10 +74,10 @@ print("Getting Red Team scan details") # Use the name returned by the create operation for the get call - get_red_team_response = project_client.red_teams.get(name=red_team_response.name) + get_red_team_response = project_client.beta.red_teams.get(name=red_team_response.name) print(f"Red Team scan status: {get_red_team_response.status}") print("Listing all Red Team scans") - for scan in project_client.red_teams.list(): + for scan in project_client.beta.red_teams.list(): print(f"Found scan: {scan.name}, Status: {scan.status}") # [END red_team_sample] diff --git a/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team_async.py b/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team_async.py index 34b4580ee80c..daee53cdbd52 100644 --- a/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team_async.py +++ b/sdk/ai/azure-ai-projects/samples/red_team/sample_red_team_async.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -14,7 +13,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - Required. The Azure AI Project endpoint, as found in the overview page of your @@ -69,7 +68,7 @@ async def sample_red_team_async() -> None: ) # Create and run the Red Team scan - red_team_response = await project_client.red_teams.create( + red_team_response = await project_client.beta.red_teams.create( red_team=red_team, headers={ "model-endpoint": model_endpoint, @@ -80,11 +79,11 @@ async def sample_red_team_async() -> None: print("Getting Red Team scan details") # Use the name returned by the create operation for the get call - get_red_team_response = await project_client.red_teams.get(name=red_team_response.name) + get_red_team_response = await project_client.beta.red_teams.get(name=red_team_response.name) print(f"Red Team scan status: {get_red_team_response.status}") print("Listing all Red Team scans") - async for scan in project_client.red_teams.list(): + async for scan in project_client.beta.red_teams.list(): print(f"Found scan: {scan.name}, Status: {scan.status}") # [END red_team_sample] diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic.py index 5dd5e86d385e..1bb5d52fcdbf 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" openai azure-identity python-dotenv + pip install "azure-ai-projects>=2.0.0b4" openai azure-identity python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_async.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_async.py index 590c85480b27..752ddbf40b78 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_async.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_async.py @@ -15,7 +15,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient.py index 12ca5a99fe68..9c5d8b656bd7 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient.py @@ -34,8 +34,7 @@ openai = OpenAI( api_key=get_bearer_token_provider(DefaultAzureCredential(), "https://ai.azure.com/.default"), - base_url=os.environ["AZURE_AI_PROJECT_ENDPOINT"].rstrip("/") + "/openai", - default_query={"api-version": "2025-11-15-preview"}, + base_url=os.environ["AZURE_AI_PROJECT_ENDPOINT"].rstrip("/") + "/openai/v1", ) response = openai.responses.create( diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient_async.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient_async.py index 4eb408389364..8a2934ff7418 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient_async.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_basic_without_aiprojectclient_async.py @@ -42,8 +42,7 @@ async def main() -> None: openai = AsyncOpenAI( api_key=get_bearer_token_provider(credential, "https://ai.azure.com/.default"), - base_url=os.environ["AZURE_AI_PROJECT_ENDPOINT"].rstrip("/") + "/openai", - default_query={"api-version": "2025-11-15-preview"}, + base_url=os.environ["AZURE_AI_PROJECT_ENDPOINT"].rstrip("/") + "/openai/v1", ) async with openai: diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_image_input.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_image_input.py index d75a83c8feaf..ffede4ef3b58 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_image_input.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_image_input.py @@ -16,7 +16,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_events.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_events.py index 6c4ab37c17a7..7068a2fd24f5 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_events.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_events.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_manager.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_manager.py index 31368d285576..b3ab4ecac13f 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_manager.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_stream_manager.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_structured_output.py b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_structured_output.py index e45bbdd5f8a5..0e081799afb0 100644 --- a/sdk/ai/azure-ai-projects/samples/responses/sample_responses_structured_output.py +++ b/sdk/ai/azure-ai-projects/samples/responses/sample_responses_structured_output.py @@ -17,7 +17,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview diff --git a/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry.py b/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry.py index 697a2e78d614..cf35d6d3cad7 100644 --- a/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry.py +++ b/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv + pip install "azure-ai-projects>=2.0.0b4" python-dotenv Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry_async.py b/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry_async.py index bb5a5c55dac4..5c53760c58f6 100644 --- a/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry_async.py +++ b/sdk/ai/azure-ai-projects/samples/telemetry/sample_telemetry_async.py @@ -14,7 +14,7 @@ Before running the sample: - pip install "azure-ai-projects>=2.0.0b1" python-dotenv aiohttp + pip install "azure-ai-projects>=2.0.0b4" python-dotenv aiohttp Set these environment variables with your own values: 1) AZURE_AI_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the overview page of your diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor.py index 02dc9fc82114..a93fd426f8f7 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor.py @@ -10,7 +10,7 @@ from azure.ai.projects.telemetry import AIProjectInstrumentor, _utils from azure.core.settings import settings from gen_ai_trace_verifier import GenAiTraceVerifier -from azure.ai.projects.models import PromptAgentDefinition, PromptAgentDefinitionText +from azure.ai.projects.models import PromptAgentDefinition, PromptAgentDefinitionTextOptions from azure.ai.projects.models import ( Reasoning, @@ -61,6 +61,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAiAgentsInstrumentor(TestAiAgentsInstrumentorBase): """Tests for AI agents instrumentor.""" @@ -548,7 +551,7 @@ def _test_agent_with_structured_output_with_instructions_impl( agent_definition = PromptAgentDefinition( model=model, instructions="You are a helpful assistant that extracts person information.", - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema( name="PersonInfo", schema=test_schema, @@ -734,7 +737,7 @@ def _test_agent_with_structured_output_without_instructions_impl( agent_definition = PromptAgentDefinition( model=model, - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema( name="Result", schema=test_schema, diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor_async.py index 65343a24fc24..14313a31ae36 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_agents_instrumentor_async.py @@ -9,7 +9,7 @@ from azure.ai.projects.telemetry import AIProjectInstrumentor, _utils from azure.core.settings import settings from gen_ai_trace_verifier import GenAiTraceVerifier -from azure.ai.projects.models import PromptAgentDefinition, PromptAgentDefinitionText +from azure.ai.projects.models import PromptAgentDefinition, PromptAgentDefinitionTextOptions from azure.ai.projects.models import ( Reasoning, FunctionTool, @@ -58,6 +58,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAiAgentsInstrumentor(TestAiAgentsInstrumentorBase): """Tests for AI agents instrumentor.""" @@ -420,7 +423,7 @@ async def _test_agent_with_structured_output_with_instructions_impl( agent_definition = PromptAgentDefinition( model=model, instructions="You are a helpful assistant that extracts person information.", - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema( name="PersonInfo", schema=test_schema, @@ -604,7 +607,7 @@ async def _test_agent_with_structured_output_without_instructions_impl( agent_definition = PromptAgentDefinition( model=model, # No instructions provided - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema( name="Result", schema=test_schema, diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_instrumentor_base.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_instrumentor_base.py index 55dff7d9a421..8e9e580de5e5 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_instrumentor_base.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_ai_instrumentor_base.py @@ -31,6 +31,9 @@ class MessageCreationMode(IntEnum): ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAiAgentsInstrumentorBase(TestBase): """The utility methods, used by AI Instrumentor test.""" diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor.py index 0bfb3ed6af46..409556e5db59 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor.py @@ -53,6 +53,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentor(TestAiAgentsInstrumentorBase): """Tests for ResponsesInstrumentor with real endpoints.""" @@ -1021,7 +1024,7 @@ def _test_sync_function_tool_with_content_recording_non_streaming_impl( response = client.responses.create( conversation=conversation.id, input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) function_calls = [item for item in response.output if item.type == "function_call"] @@ -1044,7 +1047,7 @@ def _test_sync_function_tool_with_content_recording_non_streaming_impl( response2 = client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) assert hasattr(response2, "output") @@ -1280,7 +1283,7 @@ def _test_sync_function_tool_with_content_recording_streaming_impl( stream = client.responses.create( conversation=conversation.id, input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the stream and collect function calls @@ -1318,7 +1321,7 @@ def _test_sync_function_tool_with_content_recording_streaming_impl( stream2 = client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the second stream @@ -1604,7 +1607,7 @@ def _test_sync_function_tool_without_content_recording_non_streaming_impl( response = client.responses.create( conversation=conversation.id, input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) function_calls = [item for item in response.output if item.type == "function_call"] @@ -1627,7 +1630,7 @@ def _test_sync_function_tool_without_content_recording_non_streaming_impl( response2 = client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) assert hasattr(response2, "output") @@ -1840,7 +1843,7 @@ def _test_sync_function_tool_without_content_recording_streaming_impl( stream = client.responses.create( conversation=conversation.id, input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the stream and collect function calls @@ -1879,7 +1882,7 @@ def _test_sync_function_tool_without_content_recording_streaming_impl( stream2 = client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the second stream @@ -2158,7 +2161,7 @@ def test_sync_function_tool_list_conversation_items_with_content_recording(self, response = client.responses.create( conversation=conversation.id, input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) @@ -2179,7 +2182,7 @@ def test_sync_function_tool_list_conversation_items_with_content_recording(self, response2 = client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) @@ -2308,7 +2311,7 @@ def test_sync_function_tool_list_conversation_items_without_content_recording(se response = client.responses.create( conversation=conversation.id, input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) @@ -2329,7 +2332,7 @@ def test_sync_function_tool_list_conversation_items_without_content_recording(se response2 = client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=False, ) @@ -4936,7 +4939,6 @@ def test_workflow_agent_non_streaming_with_content_recording(self, **kwargs): """Test workflow agent with non-streaming and content recording enabled.""" from azure.ai.projects.models import ( WorkflowAgentDefinition, - AgentReference, PromptAgentDefinition, ) @@ -5053,7 +5055,7 @@ def test_workflow_agent_non_streaming_with_content_recording(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=False, ) @@ -5137,7 +5139,7 @@ def test_workflow_agent_non_streaming_with_content_recording(self, **kwargs): @recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX) def test_workflow_agent_non_streaming_without_content_recording(self, **kwargs): """Test workflow agent with non-streaming and content recording disabled.""" - from azure.ai.projects.models import WorkflowAgentDefinition, AgentReference + from azure.ai.projects.models import WorkflowAgentDefinition self.cleanup() os.environ.update( @@ -5173,7 +5175,7 @@ def test_workflow_agent_non_streaming_without_content_recording(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="Test workflow", stream=False, ) @@ -5253,7 +5255,6 @@ def test_workflow_agent_streaming_with_content_recording(self, **kwargs): """Test workflow agent with streaming and content recording enabled.""" from azure.ai.projects.models import ( WorkflowAgentDefinition, - AgentReference, PromptAgentDefinition, ) @@ -5370,7 +5371,7 @@ def test_workflow_agent_streaming_with_content_recording(self, **kwargs): stream = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=True, ) @@ -5457,7 +5458,7 @@ def test_workflow_agent_streaming_with_content_recording(self, **kwargs): @recorded_by_proxy(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX) def test_workflow_agent_streaming_without_content_recording(self, **kwargs): """Test workflow agent with streaming and content recording disabled.""" - from azure.ai.projects.models import WorkflowAgentDefinition, AgentReference + from azure.ai.projects.models import WorkflowAgentDefinition self.cleanup() os.environ.update( @@ -5493,7 +5494,7 @@ def test_workflow_agent_streaming_without_content_recording(self, **kwargs): stream = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="Test workflow", stream=True, ) @@ -5604,7 +5605,7 @@ def test_prompt_agent_with_responses_non_streaming(self, **kwargs): # Create response with agent name and id response = client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, input="What is the capital of France?", ) @@ -5674,7 +5675,7 @@ def test_prompt_agent_with_responses_streaming(self, **kwargs): # Create streaming response with agent name and id stream = client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, input="What is the capital of France?", stream=True, ) diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_async.py index 80c055a015dd..b68aa26aeabb 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_async.py @@ -37,6 +37,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentor(TestAiAgentsInstrumentorBase): """Tests for ResponsesInstrumentor with real endpoints (async).""" @@ -454,7 +457,7 @@ async def _test_async_function_tool_with_content_recording_streaming_impl( stream = await client.responses.create( conversation=conversation.id, input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the stream and collect function calls @@ -492,7 +495,7 @@ async def _test_async_function_tool_with_content_recording_streaming_impl( stream2 = await client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the second stream @@ -715,7 +718,7 @@ async def _test_async_function_tool_without_content_recording_streaming_impl( stream = await client.responses.create( conversation=conversation.id, input="What\\'s the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the stream and collect function calls @@ -754,7 +757,7 @@ async def _test_async_function_tool_without_content_recording_streaming_impl( stream2 = await client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, stream=True, ) # Consume the second stream @@ -3200,7 +3203,7 @@ async def test_async_responses_stream_method_with_tools_without_content_recordin @recorded_by_proxy_async(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX) async def test_async_workflow_agent_non_streaming_with_content_recording(self, **kwargs): """Test async workflow agent with non-streaming and content recording enabled.""" - from azure.ai.projects.models import WorkflowAgentDefinition, AgentReference + from azure.ai.projects.models import WorkflowAgentDefinition self.cleanup() os.environ.update( @@ -3238,7 +3241,7 @@ async def test_async_workflow_agent_non_streaming_with_content_recording(self, * response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="Test workflow", stream=False, ) @@ -3317,7 +3320,7 @@ async def test_async_workflow_agent_non_streaming_with_content_recording(self, * @recorded_by_proxy_async(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX) async def test_async_workflow_agent_non_streaming_without_content_recording(self, **kwargs): """Test async workflow agent with non-streaming and content recording disabled.""" - from azure.ai.projects.models import WorkflowAgentDefinition, AgentReference + from azure.ai.projects.models import WorkflowAgentDefinition self.cleanup() os.environ.update( @@ -3354,7 +3357,7 @@ async def test_async_workflow_agent_non_streaming_without_content_recording(self response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="Test workflow", stream=False, ) @@ -3440,7 +3443,7 @@ async def test_async_workflow_agent_non_streaming_without_content_recording(self @recorded_by_proxy_async(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX) async def test_async_workflow_agent_streaming_with_content_recording(self, **kwargs): """Test async workflow agent with streaming and content recording enabled.""" - from azure.ai.projects.models import WorkflowAgentDefinition, AgentReference + from azure.ai.projects.models import WorkflowAgentDefinition self.cleanup() os.environ.update( @@ -3477,7 +3480,7 @@ async def test_async_workflow_agent_streaming_with_content_recording(self, **kwa stream = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="Test workflow", stream=True, ) @@ -3561,7 +3564,7 @@ async def test_async_workflow_agent_streaming_with_content_recording(self, **kwa @recorded_by_proxy_async(RecordedTransport.AZURE_CORE, RecordedTransport.HTTPX) async def test_async_workflow_agent_streaming_without_content_recording(self, **kwargs): """Test async workflow agent with streaming and content recording disabled.""" - from azure.ai.projects.models import WorkflowAgentDefinition, AgentReference + from azure.ai.projects.models import WorkflowAgentDefinition self.cleanup() os.environ.update( @@ -3598,7 +3601,7 @@ async def test_async_workflow_agent_streaming_without_content_recording(self, ** stream = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow_agent.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow_agent.name, "type": "agent_reference"}}, input="Test workflow", stream=True, ) @@ -3727,7 +3730,7 @@ async def _test_async_prompt_agent_with_responses_non_streaming_impl( # Create response with agent name and id response = await client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, input="What is the capital of France?", ) @@ -3865,7 +3868,7 @@ async def _test_async_prompt_agent_with_responses_streaming_impl( # Create streaming response with agent name and id stream = await client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "id": agent.id, "type": "agent_reference"}}, input="What is the capital of France?", stream=True, ) diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation.py index 323a43dd0c6f..cb3036dd3ef3 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation.py @@ -30,6 +30,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorBrowserAutomation(TestAiAgentsInstrumentorBase): """Tests for ResponsesInstrumentor with browser automation agents.""" @@ -98,7 +101,7 @@ def test_sync_browser_automation_non_streaming_with_content_recording(self, **kw news stories and provide a summary of the most recent one. """, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response.output is not None @@ -233,7 +236,7 @@ def test_sync_browser_automation_non_streaming_without_content_recording(self, * news stories and provide a summary of the most recent one. """, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.exporter.force_flush() @@ -356,7 +359,7 @@ def test_sync_browser_automation_streaming_with_content_recording(self, **kwargs news stories and provide a summary of the most recent one. """, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for _ in stream: pass @@ -482,7 +485,7 @@ def test_sync_browser_automation_streaming_without_content_recording(self, **kwa news stories and provide a summary of the most recent one. """, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for _ in stream: pass diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation_async.py index 87b89d8343f6..a4abc6aa33f9 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_browser_automation_async.py @@ -33,6 +33,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorBrowserAutomationAsync(TestAiAgentsInstrumentorBase): """Async tests for ResponsesInstrumentor with browser automation agents.""" @@ -101,7 +104,7 @@ async def test_async_browser_automation_non_streaming_with_content_recording(sel news stories and provide a summary of the most recent one. """, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response.output is not None @@ -232,7 +235,7 @@ async def test_async_browser_automation_non_streaming_without_content_recording( news stories and provide a summary of the most recent one. """, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.exporter.force_flush() @@ -351,7 +354,7 @@ async def test_async_browser_automation_streaming_with_content_recording(self, * news stories and provide a summary of the most recent one. """, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) async for _ in stream: pass @@ -474,7 +477,7 @@ async def test_async_browser_automation_streaming_without_content_recording(self news stories and provide a summary of the most recent one. """, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) async for _ in stream: pass diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter.py index df073393af8c..b01e31055f07 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter.py @@ -35,6 +35,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorCodeInterpreter(TestAiAgentsInstrumentorBase): """ Test suite for Code Interpreter agent telemetry instrumentation. @@ -103,7 +106,7 @@ def test_sync_code_interpreter_non_streaming_with_content_recording(self, **kwar response = openai_client.responses.create( conversation=conversation.id, input="Calculate the average operating profit from the transportation data", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Explicitly call and iterate through conversation items @@ -290,7 +293,7 @@ def test_sync_code_interpreter_non_streaming_without_content_recording(self, **k response = openai_client.responses.create( conversation=conversation.id, input="Calculate the average operating profit from the transportation data", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Explicitly call and iterate through conversation items @@ -482,7 +485,7 @@ def test_sync_code_interpreter_streaming_with_content_recording(self, **kwargs): conversation=conversation.id, input="Calculate the average operating profit from the transportation data", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream @@ -673,7 +676,7 @@ def test_sync_code_interpreter_streaming_without_content_recording(self, **kwarg conversation=conversation.id, input="Calculate the average operating profit from the transportation data", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter_async.py index 850a2eb6e542..0eaa37a37ec2 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_code_interpreter_async.py @@ -36,6 +36,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorCodeInterpreterAsync(TestAiAgentsInstrumentorBase): """ Test suite for Code Interpreter agent telemetry instrumentation (async). @@ -103,7 +106,7 @@ async def test_async_code_interpreter_non_streaming_with_content_recording(self, response = await openai_client.responses.create( conversation=conversation.id, input="Calculate the average operating profit from the transportation data", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Explicitly call and iterate through conversation items @@ -290,7 +293,7 @@ async def test_async_code_interpreter_non_streaming_without_content_recording(se response = await openai_client.responses.create( conversation=conversation.id, input="Calculate the average operating profit from the transportation data", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Explicitly call and iterate through conversation items @@ -482,7 +485,7 @@ async def test_async_code_interpreter_streaming_with_content_recording(self, **k conversation=conversation.id, input="Calculate the average operating profit from the transportation data", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream @@ -673,7 +676,7 @@ async def test_async_code_interpreter_streaming_without_content_recording(self, conversation=conversation.id, input="Calculate the average operating profit from the transportation data", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search.py index 773f7c60614f..319c7f7d65e6 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search.py @@ -31,6 +31,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorFileSearch(TestAiAgentsInstrumentorBase): """Tests for ResponsesInstrumentor with File Search tool.""" @@ -105,7 +108,7 @@ def test_sync_file_search_non_streaming_with_content_recording(self, **kwargs): conversation=conversation.id, input="Tell me about Contoso products", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response.output_text is not None @@ -314,7 +317,7 @@ def test_sync_file_search_non_streaming_without_content_recording(self, **kwargs conversation=conversation.id, input="Tell me about Contoso products", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response.output_text is not None @@ -521,7 +524,7 @@ def test_sync_file_search_streaming_with_content_recording(self, **kwargs): conversation=conversation.id, input="Tell me about Contoso products", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream @@ -726,7 +729,7 @@ def test_sync_file_search_streaming_without_content_recording(self, **kwargs): conversation=conversation.id, input="Tell me about Contoso products", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search_async.py index 4e3e94308413..c415d627da71 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_file_search_async.py @@ -32,6 +32,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorFileSearchAsync(TestAiAgentsInstrumentorBase): """Async tests for ResponsesInstrumentor with File Search tool.""" @@ -106,7 +109,7 @@ async def test_async_file_search_non_streaming_with_content_recording(self, **kw conversation=conversation.id, input="Tell me about Contoso products", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response.output_text is not None @@ -315,7 +318,7 @@ async def test_async_file_search_non_streaming_without_content_recording(self, * conversation=conversation.id, input="Tell me about Contoso products", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response.output_text is not None @@ -522,7 +525,7 @@ async def test_async_file_search_streaming_with_content_recording(self, **kwargs conversation=conversation.id, input="Tell me about Contoso products", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream @@ -727,7 +730,7 @@ async def test_async_file_search_streaming_without_content_recording(self, **kwa conversation=conversation.id, input="Tell me about Contoso products", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume the stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp.py index a0640b93e62d..6d438e026518 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp.py @@ -31,6 +31,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorMCP(TestAiAgentsInstrumentorBase): """Tests for ResponsesInstrumentor with MCP agents.""" @@ -88,7 +91,7 @@ def _test_sync_mcp_non_streaming_with_content_recording_impl(self, use_events, * conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests @@ -109,7 +112,7 @@ def _test_sync_mcp_non_streaming_with_content_recording_impl(self, use_events, * conversation=conversation.id, input=input_list, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response2.output_text is not None @@ -418,7 +421,7 @@ def _test_sync_mcp_non_streaming_without_content_recording_impl(self, use_events conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests @@ -439,7 +442,7 @@ def _test_sync_mcp_non_streaming_without_content_recording_impl(self, use_events conversation=conversation.id, input=input_list, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response2.output_text is not None @@ -735,7 +738,7 @@ def _test_sync_mcp_streaming_with_content_recording_impl(self, use_events, **kwa conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests from stream @@ -759,7 +762,7 @@ def _test_sync_mcp_streaming_with_content_recording_impl(self, use_events, **kwa conversation=conversation.id, input=input_list, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume second stream @@ -1011,7 +1014,7 @@ def _test_sync_mcp_streaming_without_content_recording_impl(self, use_events, ** conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests from stream @@ -1035,7 +1038,7 @@ def _test_sync_mcp_streaming_without_content_recording_impl(self, use_events, ** conversation=conversation.id, input=input_list, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume second stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp_async.py index d0d4fb384984..1394018e1950 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_mcp_async.py @@ -32,6 +32,9 @@ _utils._span_impl_type = settings.tracing_implementation() +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorMCPAsync(TestAiAgentsInstrumentorBase): """Async tests for ResponsesInstrumentor with MCP agents.""" @@ -89,7 +92,7 @@ async def _test_async_mcp_non_streaming_with_content_recording_impl(self, use_ev conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests @@ -110,7 +113,7 @@ async def _test_async_mcp_non_streaming_with_content_recording_impl(self, use_ev conversation=conversation.id, input=input_list, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response2.output_text is not None @@ -418,7 +421,7 @@ async def _test_async_mcp_non_streaming_without_content_recording_impl(self, use conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests @@ -439,7 +442,7 @@ async def _test_async_mcp_non_streaming_without_content_recording_impl(self, use conversation=conversation.id, input=input_list, stream=False, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) assert response2.output_text is not None @@ -737,7 +740,7 @@ async def _test_async_mcp_streaming_with_content_recording_impl(self, use_events conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests from stream @@ -761,7 +764,7 @@ async def _test_async_mcp_streaming_with_content_recording_impl(self, use_events conversation=conversation.id, input=input_list, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume second stream @@ -1016,7 +1019,7 @@ async def _test_async_mcp_streaming_without_content_recording_impl(self, use_eve conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect approval requests from stream @@ -1040,7 +1043,7 @@ async def _test_async_mcp_streaming_without_content_recording_impl(self, use_eve conversation=conversation.id, input=input_list, stream=True, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Consume second stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_metrics.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_metrics.py index a198327679c3..4a285d42482b 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_metrics.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_metrics.py @@ -29,6 +29,9 @@ metrics.set_meter_provider(global_meter_provider) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorMetrics(TestAiAgentsInstrumentorBase): """Tests for ResponsesInstrumentor metrics functionality with real endpoints.""" diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow.py index 5d9254d23c80..926b384e111b 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow.py @@ -19,7 +19,6 @@ from gen_ai_trace_verifier import GenAiTraceVerifier from devtools_testutils import recorded_by_proxy, RecordedTransport from azure.ai.projects.models import ( - AgentReference, PromptAgentDefinition, WorkflowAgentDefinition, ) @@ -105,6 +104,9 @@ def checkInputMessageEventContents(content, content_recording_enabled): assert found_text, "No text part found in input message event" +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorWorkflow(TestAiAgentsInstrumentorBase): """Tests for ResponsesInstrumentor with workflow agents.""" @@ -243,10 +245,10 @@ def test_sync_workflow_non_streaming_with_content_recording(self, **kwargs): # Non-streaming request response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=False, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Verify response has output @@ -408,10 +410,10 @@ def test_sync_workflow_non_streaming_without_content_recording(self, **kwargs): # Non-streaming request response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=False, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Verify response has output @@ -575,10 +577,10 @@ def test_sync_workflow_streaming_with_content_recording(self, **kwargs): # Streaming request stream = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=True, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Consume stream @@ -743,10 +745,10 @@ def test_sync_workflow_streaming_without_content_recording(self, **kwargs): # Streaming request stream = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=True, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Consume stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow_async.py index 494c29e71fd3..b9baf72fe610 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_responses_instrumentor_workflow_async.py @@ -20,7 +20,6 @@ from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport from azure.ai.projects.models import ( - AgentReference, PromptAgentDefinition, WorkflowAgentDefinition, ) @@ -104,6 +103,9 @@ def checkInputMessageEventContents(content, content_recording_enabled): assert found_text, "No text part found in input message event" +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestResponsesInstrumentorWorkflowAsync(TestAiAgentsInstrumentorBase): """Async tests for ResponsesInstrumentor with workflow agents.""" @@ -242,10 +244,10 @@ async def test_async_workflow_non_streaming_with_content_recording(self, **kwarg # Non-streaming request response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=False, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Verify response has output @@ -403,10 +405,10 @@ async def test_async_workflow_non_streaming_without_content_recording(self, **kw # Non-streaming request response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=False, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Verify response has output @@ -568,10 +570,10 @@ async def test_async_workflow_streaming_with_content_recording(self, **kwargs): # Streaming request stream = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=True, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Consume stream @@ -734,10 +736,10 @@ async def test_async_workflow_streaming_without_content_recording(self, **kwargs # Streaming request stream = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=workflow.name).as_dict()}, + extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, input="1 + 1 = ?", stream=True, - metadata={"x-ms-debug-mode-enabled": "1"}, + # Remove me? metadata={"x-ms-debug-mode-enabled": "1"}, ) # Consume stream diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator.py index 18a96fd8eae3..af3838e205fb 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator.py @@ -12,6 +12,9 @@ from memory_trace_exporter import MemoryTraceExporter +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestTraceFunctionDecorator: """Tests for trace_function decorator with synchronous functions.""" diff --git a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator_async.py b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator_async.py index dd7d92bed63c..a7f671e20691 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/telemetry/test_trace_function_decorator_async.py @@ -12,6 +12,9 @@ from memory_trace_exporter import MemoryTraceExporter +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestTraceFunctionDecoratorAsync: """Tests for trace_function decorator with asynchronous functions.""" diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud.py b/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud.py index 98f4ada367df..fa4cb60012f1 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud.py @@ -11,10 +11,14 @@ from azure.ai.projects.models import ( PromptAgentDefinition, TextResponseFormatJsonSchema, - PromptAgentDefinitionText, + PromptAgentDefinitionTextOptions, ) +import pytest +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentResponsesCrud(TestBase): # To run this test: @@ -69,8 +73,7 @@ def test_agent_responses_crud(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", # TODO: Remove 'input' once service is fixed + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert "5280" in response.output_text or "5,280" in response.output_text @@ -109,8 +112,7 @@ def test_agent_responses_crud(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", # TODO: Remove 'input' once service is fixed + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert "1609" in response.output_text or "1,609" in response.output_text @@ -137,7 +139,7 @@ def test_agent_responses_crud(self, **kwargs): # response = openai_client.responses.create( # conversation=conversation.id, - # extra_body={"agent": AgentReference(name=agent.name).as_dict()} + # extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}} # ) # print(f"Response id: {response.id}, output text: {response.output_text}") @@ -175,7 +177,7 @@ class CalendarEvent(BaseModel): agent_name="MyAgent", definition=PromptAgentDefinition( model=model, - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema(name="CalendarEvent", schema=CalendarEvent.model_json_schema()) ), instructions=""" @@ -199,8 +201,7 @@ class CalendarEvent(BaseModel): response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", # TODO: Remove 'input' once service is fixed + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert response.output_text == '{"name":"Science Fair","date":"2025-11-07","participants":["Alice","Bob"]}' diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud_async.py b/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud_async.py index 9a73410e6821..56ffb4820c7b 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_agent_responses_crud_async.py @@ -12,10 +12,14 @@ from azure.ai.projects.models import ( PromptAgentDefinition, TextResponseFormatJsonSchema, - PromptAgentDefinitionText, + PromptAgentDefinitionTextOptions, ) +import pytest +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentResponsesCrudAsync(TestBase): @servicePreparer() @@ -46,8 +50,7 @@ async def test_agent_responses_crud_async(self, **kwargs): response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", # TODO: Remove 'input' once service is fixed + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert "5280" in response.output_text or "5,280" in response.output_text @@ -80,8 +83,7 @@ async def test_agent_responses_crud_async(self, **kwargs): response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", # TODO: Remove 'input' once service is fixed + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert "1609" in response.output_text or "1,609" in response.output_text @@ -108,7 +110,7 @@ async def test_agent_responses_crud_async(self, **kwargs): # response = await project_client.agents.responses.create( # conversation=conversation.id, - # extra_body={"agent": AgentReference(name=agent.name).as_dict()} + # extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}} # ) # print(f"Response id: {response.id}, output text: {response.output_text}") @@ -148,7 +150,7 @@ class CalendarEvent(BaseModel): agent_name="MyAgent", definition=PromptAgentDefinition( model=model, - text=PromptAgentDefinitionText( + text=PromptAgentDefinitionTextOptions( format=TextResponseFormatJsonSchema( name="CalendarEvent", schema=CalendarEvent.model_json_schema() ) @@ -174,8 +176,7 @@ class CalendarEvent(BaseModel): response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, - input="", # TODO: Remove 'input' once service is fixed + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert response.output_text == '{"name":"Science Fair","date":"2025-11-07","participants":["Alice","Bob"]}' diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud.py b/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud.py index 56f87bc64d01..ef113dfca20d 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud.py @@ -9,8 +9,12 @@ from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy from azure.ai.projects.models import PromptAgentDefinition, AgentDetails, AgentVersionDetails +import pytest +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentCrud(TestBase): # To run this test: @@ -67,17 +71,6 @@ def test_agents_crud(self, **kwargs): ) self._validate_agent_version(agent2_version1) - # Create another version of the same Agent, by updating the existing one - # TODO: Uncomment the lines below, and the delete lines at the end, once the service is fixed (at the moment returns 500 InternalServiceError) - # agent2_version2: AgentVersionDetails = project_client.agents.update( - # agent_name=second_agent_name, - # definition=PromptAgentDefinition( - # model=model, - # instructions="Third set of instructions here", - # ), - # ) - # self._validate_agent_version(agent2_version2) - # Get the first Agent retrieved_agent: AgentDetails = project_client.agents.get(agent_name=first_agent_name) self._validate_agent( diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud_async.py b/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud_async.py index bd03ed0299ab..de9dddfcf5db 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_agents_crud_async.py @@ -9,8 +9,12 @@ from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from azure.ai.projects.models import PromptAgentDefinition, AgentDetails, AgentVersionDetails +import pytest +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentCrudAsync(TestBase): @servicePreparer() @@ -55,17 +59,6 @@ async def test_agents_crud_async(self, **kwargs): ) self._validate_agent_version(agent2_version1) - # Create another version of the same Agent, by updating the existing one - # TODO: Uncomment the lines below, and the delete lines at the end, once the service is fixed (at the moment returns 500 InternalServiceError) - # agent2_version2: AgentVersionDetails = await project_client.agents.update( - # agent_name=second_agent_name, - # definition=PromptAgentDefinition( - # model=model, - # instructions="Third set of instructions here", - # ), - # ) - # self._validate_agent_version(agent2_version2) - # Retrieve the first Agent retrieved_agent: AgentDetails = await project_client.agents.get(agent_name=first_agent_name) self._validate_agent( diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents.py b/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents.py index 1b304d401dd1..8b172e7fc9c4 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents.py @@ -11,9 +11,12 @@ from devtools_testutils import is_live_and_not_recording # from azure.ai.projects.models import ResponsesUserMessageItemParam -from azure.ai.projects.models import AgentReference, ContainerAppAgentDefinition, ProtocolVersionRecord, AgentProtocol +from azure.ai.projects.models import ContainerAppAgentDefinition, ProtocolVersionRecord, AgentProtocol +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestContainerAppAgents(TestBase): @servicePreparer() @@ -49,7 +52,7 @@ def test_container_app_agent(self, **kwargs): try: response = openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=agent_version.name).as_dict()}, + extra_body={"agent_reference": {"name": agent_version.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert "5280" in response.output_text or "5,280" in response.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents_async.py b/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents_async.py index 27a163db1757..75343bc6b533 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_container_app_agents_async.py @@ -11,9 +11,12 @@ from devtools_testutils import is_live_and_not_recording # from azure.ai.projects.models import ResponsesUserMessageItemParam -from azure.ai.projects.models import AgentReference, ContainerAppAgentDefinition, ProtocolVersionRecord, AgentProtocol +from azure.ai.projects.models import ContainerAppAgentDefinition, ProtocolVersionRecord, AgentProtocol +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestContainerAppAgentsAsync(TestBase): @servicePreparer() @@ -49,7 +52,7 @@ async def test_container_app_agent_async(self, **kwargs): try: response = await openai_client.responses.create( conversation=conversation.id, - extra_body={"agent": AgentReference(name=agent_version.name).as_dict()}, + extra_body={"agent_reference": {"name": agent_version.name, "type": "agent_reference"}}, ) print(f"Response id: {response.id}, output text: {response.output_text}") assert "5280" in response.output_text or "5,280" in response.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud.py b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud.py index 636d1a012e51..83a6cc0dcc69 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud.py @@ -7,11 +7,15 @@ from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy, RecordedTransport +import pytest # from azure.ai.projects.models import ResponsesUserMessageItemParam, ItemContentInputText # TODO: Emitter did not produce the output class OpenAI.ConversationResource. Validating service response as Dict for now. +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestConversationCrud(TestBase): # To run only this test: diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud_async.py b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud_async.py index 9905b34b5c16..29520fabc727 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_crud_async.py @@ -8,10 +8,14 @@ from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport +import pytest # from azure.ai.projects.models import ResponsesUserMessageItemParam, ItemContentInputText +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestConversationCrudAsync(TestBase): # To run only this test: diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud.py b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud.py index 95aff3fac063..c510b7210ce2 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud.py @@ -7,8 +7,12 @@ from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy, RecordedTransport +import pytest +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestConversationItemsCrud(TestBase): @servicePreparer() diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud_async.py b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud_async.py index f6b0379aeab8..703154357d1a 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_conversation_items_crud_async.py @@ -8,8 +8,12 @@ from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport +import pytest +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestConversationItemsCrudAsync(TestBase): @servicePreparer() diff --git a/sdk/ai/azure-ai-projects/tests/agents/test_hosted_agents.py b/sdk/ai/azure-ai-projects/tests/agents/test_hosted_agents.py index 9959c9df10fd..11b2012cc7b7 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/test_hosted_agents.py +++ b/sdk/ai/azure-ai-projects/tests/agents/test_hosted_agents.py @@ -6,39 +6,17 @@ # cSpell:disable from test_base import TestBase # , servicePreparer +import pytest # from devtools_testutils import recorded_by_proxy -# from azure.ai.projects.models import AgentReference, PromptAgentDefinition +# from azure.ai.projects.models import PromptAgentDefinition +@pytest.mark.skip(reason="Not yet implemented") class TestHostedAgents(TestBase): # @servicePreparer() # @recorded_by_proxy def test_hosted_agent(self, **kwargs): - """ - Test Hosted Agents and all container operations. - - Routes used in this test: - - Action REST API Route Client Method - ------+---------------------------------------------------------------------------+----------------------------------- - - # Setup: - - # Test focus: - GET /agents/{agent_name}/operations list_container_operations - GET /agents/{agent_name}/operations/{operation_id} retrieve_container_operation - GET /agents/{agent_name}/versions/{agent_version}/containers/default retrieve_container - GET /agents/{agent_name}/versions/{agent_version}/containers/default/operations list_version_container_operations - POST /agents/{agent_name}/versions/{agent_version}/containers/default:start start_container - POST /agents/{agent_name}/versions/{agent_version}/containers/default:stop stop_container - POST /agents/{agent_name}/versions/{agent_version}/containers/default:update update_container - POST /agents/{agent_name}/versions/{agent_version}/containers/default:delete delete_container - - # Teardown: - - """ - # TODO: Add tests! pass diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_code_interpreter_and_function.py b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_code_interpreter_and_function.py index 2601424c4a1b..7e5265244802 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_code_interpreter_and_function.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_code_interpreter_and_function.py @@ -5,6 +5,8 @@ # ------------------------------------ # cSpell:disable +import pytest + """ Multi-Tool Tests: Code Interpreter + Function Tool @@ -24,6 +26,9 @@ from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentCodeInterpreterAndFunction(TestBase): """Tests for agents using Code Interpreter + Function Tool combination.""" @@ -79,7 +84,7 @@ def test_calculate_and_save(self, **kwargs): # 17^4 = 83521 - not something easily computed mentally response = openai_client.responses.create( input="Calculate 17 to the power of 4 using code, then save the result.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) print("✓ Code Interpreter + Function Tool works!") @@ -140,7 +145,7 @@ def test_generate_data_and_report(self, **kwargs): # Request data generation and report - use a fixed seed for reproducibility in verification response = openai_client.responses.create( input="Using Python with random.seed(42), generate exactly 10 random integers between 1 and 100, calculate their average, and create a report with the results.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_code_interpreter.py b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_code_interpreter.py index a60340a6571b..90cd78ac0bf3 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_code_interpreter.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_code_interpreter.py @@ -5,6 +5,8 @@ # ------------------------------------ # cSpell:disable +import pytest + """ Multi-Tool Tests: File Search + Code Interpreter @@ -23,6 +25,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFileSearchAndCodeInterpreter(TestBase): """Tests for agents using File Search + Code Interpreter combination.""" @@ -98,7 +103,7 @@ def test_find_and_analyze_data(self, **kwargs): # Request that requires both tools: find data AND calculate response = openai_client.responses.create( input="Find the sensor readings file and use code to calculate the average temperature. Show me the result.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) assert len(response.output_text) > 20 @@ -168,7 +173,7 @@ def fibonacci(n): # Request that requires both tools: find code AND execute it response = openai_client.responses.create( input="Find the fibonacci code file and run it to calculate fibonacci(15). What is the result?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_text = response.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_function.py b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_function.py index 6bf4a5e9a5a9..de33f1db0c5a 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_function.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_and_function.py @@ -5,6 +5,8 @@ # ------------------------------------ # cSpell:disable +import pytest + """ Multi-Tool Tests: File Search + Function Tool @@ -20,6 +22,9 @@ from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFileSearchAndFunction(TestBase): """Tests for agents using File Search + Function Tool combination.""" @@ -106,7 +111,7 @@ def test_data_analysis_workflow(self, **kwargs): response = openai_client.responses.create( input="Analyze the sales data and calculate the total revenue for each product. Then save the results.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Initial response completed (id: {response.id})") @@ -143,7 +148,7 @@ def test_data_analysis_workflow(self, **kwargs): response = openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Final response: {response.output_text[:200]}...") @@ -209,7 +214,7 @@ def test_empty_vector_store_handling(self, **kwargs): response = openai_client.responses.create( input="Find and analyze the quarterly sales report.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_text = response.output_text @@ -307,7 +312,7 @@ def calculate_sum(numbers): response = openai_client.responses.create( input="Find the Python code file, explain what the calculate_sum function does, and save your code review findings.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Verify function call is made (both tools should be used) @@ -346,7 +351,7 @@ def calculate_sum(numbers): response = openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_text = response.output_text print(f"Final response: {response_text[:200] if response_text else '(confirmation)'}...") @@ -453,7 +458,7 @@ def test_multi_turn_search_and_save_workflow(self, **kwargs): print("\n--- Turn 1: Initial search query ---") response_1 = openai_client.responses.create( input="What does the research say about machine learning in healthcare?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -465,7 +470,7 @@ def test_multi_turn_search_and_save_workflow(self, **kwargs): response_2 = openai_client.responses.create( input="What specific applications are mentioned?", previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -478,7 +483,7 @@ def test_multi_turn_search_and_save_workflow(self, **kwargs): response_3 = openai_client.responses.create( input="Please save that finding about ML accuracy.", previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -509,7 +514,7 @@ def test_multi_turn_search_and_save_workflow(self, **kwargs): response_3 = openai_client.responses.create( input=input_list, previous_response_id=response_3.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response 3: {response_3.output_text[:150]}...") @@ -518,7 +523,7 @@ def test_multi_turn_search_and_save_workflow(self, **kwargs): response_4 = openai_client.responses.create( input="Now tell me about AI ethics concerns mentioned in the research.", previous_response_id=response_3.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_4_text = response_4.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_code_interpreter_function.py b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_code_interpreter_function.py index 1b4bd4462be5..4562c426d7fc 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_code_interpreter_function.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_agent_file_search_code_interpreter_function.py @@ -5,6 +5,8 @@ # ------------------------------------ # cSpell:disable +import pytest + """ Multi-Tool Tests: File Search + Code Interpreter + Function Tool @@ -26,6 +28,9 @@ from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFileSearchCodeInterpreterFunction(TestBase): """Tests for agents using File Search + Code Interpreter + Function Tool.""" @@ -115,7 +120,7 @@ def test_complete_analysis_workflow(self, **kwargs): # Request that requires all three tools response = openai_client.responses.create( input="Find the sales report, use code to calculate the total and average of all monthly sales figures, then save the analysis results.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) print("✓ Three-tool combination works!") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_multitool_with_conversations.py b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_multitool_with_conversations.py index 607acbb678ad..85cd9a7fbf4e 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_multitool_with_conversations.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/multitool/test_multitool_with_conversations.py @@ -3,6 +3,8 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest + """ Test agents using multiple tools within conversations. @@ -22,6 +24,9 @@ from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestMultiToolWithConversations(TestBase): @servicePreparer() @@ -100,7 +105,7 @@ def test_file_search_and_function_with_conversation(self, **kwargs): response_1 = openai_client.responses.create( input="What was the total revenue in Q1 2024?", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response 1: {response_1.output_text[:150]}...") @@ -111,7 +116,7 @@ def test_file_search_and_function_with_conversation(self, **kwargs): response_2 = openai_client.responses.create( input="Which product had the highest sales?", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response 2: {response_2.output_text[:150]}...") @@ -122,7 +127,7 @@ def test_file_search_and_function_with_conversation(self, **kwargs): response_3 = openai_client.responses.create( input="Save a summary report of these Q1 results", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -145,7 +150,7 @@ def test_file_search_and_function_with_conversation(self, **kwargs): response_3 = openai_client.responses.create( input=input_list, conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response 3: {response_3.output_text[:150]}...") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search.py index 0668d960b8ad..56d9ac3ea579 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search.py @@ -20,6 +20,9 @@ # https://arxiv.org/pdf/2508.03680 +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentAISearch(TestBase): # Test questions with expected answers @@ -148,7 +151,7 @@ def test_agent_ai_search_question_answering(self, **kwargs): stream=True, tool_choice="required", input=f"Answer this question with only 'True' or 'False': {question}", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search_async.py index a6f25b30a756..184b9ceb402d 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_ai_search_async.py @@ -21,6 +21,9 @@ # https://arxiv.org/pdf/2508.03680 +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentAISearchAsync(TestBase): # Test questions with expected answers @@ -74,7 +77,7 @@ async def _ask_question_async( stream=True, tool_choice="required", input=f"Answer this question with only 'True' or 'False': {question}", - extra_body={"agent": {"name": agent_name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent_name, "type": "agent_reference"}}, ) async for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_bing_grounding.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_bing_grounding.py index 9881a1a4a6d0..951bebf915fd 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_bing_grounding.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_bing_grounding.py @@ -16,6 +16,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentBingGrounding(TestBase): @servicePreparer() @@ -90,7 +93,7 @@ def test_agent_bing_grounding(self, **kwargs): stream=True, tool_choice="required", input="What is the current weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: @@ -193,7 +196,7 @@ def test_agent_bing_grounding_multiple_queries(self, **kwargs): stream=True, tool_choice="required", input=query, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) for event in stream_response: diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter.py index 13337934bfd4..e31506e6df82 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter.py @@ -16,6 +16,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentCodeInterpreter(TestBase): @servicePreparer() @@ -67,7 +70,7 @@ def test_agent_code_interpreter_simple_math(self, **kwargs): response = openai_client.responses.create( input="Calculate this using Python: First, find the sum of cubes from 1 to 50 (1³ + 2³ + ... + 50³). Then add 12 factorial divided by 8 factorial (12!/8!). What is the final result?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) @@ -168,7 +171,7 @@ def test_agent_code_interpreter_file_generation(self, **kwargs): response = openai_client.responses.create( input="Create a bar chart showing operating profit by sector from the uploaded CSV file. Save it as a PNG file.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter_async.py index 6932f282830b..0a679f8e2509 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_code_interpreter_async.py @@ -5,6 +5,7 @@ # ------------------------------------ # cSpell:disable +import pytest from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport @@ -15,6 +16,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentCodeInterpreterAsync(TestBase): @servicePreparer() @@ -53,7 +57,7 @@ async def test_agent_code_interpreter_simple_math_async(self, **kwargs): response = await openai_client.responses.create( input="Calculate this using Python: First, find the sum of cubes from 1 to 50 (1³ + 2³ + ... + 50³). Then add 12 factorial divided by 8 factorial (12!/8!). What is the final result?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search.py index d3b56c75e710..c1a93eee1552 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search.py @@ -13,6 +13,9 @@ from azure.ai.projects.models import PromptAgentDefinition, FileSearchTool +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFileSearch(TestBase): # To only run this test: @@ -93,7 +96,7 @@ def test_agent_file_search(self, **kwargs): response = openai_client.responses.create( input="What products are mentioned in the document?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response completed (id: {response.id})") @@ -260,7 +263,7 @@ def test_agent_file_search_multi_turn_conversation(self, **kwargs): print("\n--- Turn 1: Initial query ---") response_1 = openai_client.responses.create( input="What is the price of Widget B?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -272,7 +275,7 @@ def test_agent_file_search_multi_turn_conversation(self, **kwargs): response_2 = openai_client.responses.create( input="What about its stock level?", previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -286,7 +289,7 @@ def test_agent_file_search_multi_turn_conversation(self, **kwargs): response_3 = openai_client.responses.create( input="How does that compare to Widget A's stock?", previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text @@ -300,7 +303,7 @@ def test_agent_file_search_multi_turn_conversation(self, **kwargs): response_4 = openai_client.responses.create( input="Which widget has the highest rating?", previous_response_id=response_3.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_4_text = response_4.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_async.py index e249222339f7..54be6f9e1188 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_async.py @@ -6,6 +6,7 @@ # cSpell:disable import os +import pytest from io import BytesIO from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -13,6 +14,9 @@ from azure.ai.projects.models import PromptAgentDefinition, FileSearchTool +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFileSearchAsync(TestBase): @servicePreparer() @@ -67,7 +71,7 @@ async def test_agent_file_search_async(self, **kwargs): response = await openai_client.responses.create( input="What products are mentioned in the document?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response completed (id: {response.id})") @@ -162,7 +166,7 @@ async def test_agent_file_search_multi_turn_conversation_async(self, **kwargs): print("\n--- Turn 1: Initial query ---") response_1 = await openai_client.responses.create( input="What is the price of Widget B?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -174,7 +178,7 @@ async def test_agent_file_search_multi_turn_conversation_async(self, **kwargs): response_2 = await openai_client.responses.create( input="What about its stock level?", previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -188,7 +192,7 @@ async def test_agent_file_search_multi_turn_conversation_async(self, **kwargs): response_3 = await openai_client.responses.create( input="How does that compare to Widget A's stock?", previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text @@ -202,7 +206,7 @@ async def test_agent_file_search_multi_turn_conversation_async(self, **kwargs): response_4 = await openai_client.responses.create( input="Which widget has the highest rating?", previous_response_id=response_3.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_4_text = response_4.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream.py index 6ebbf719a9a4..489b3870d6f5 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream.py @@ -6,11 +6,15 @@ # cSpell:disable import os +import pytest from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy, RecordedTransport from azure.ai.projects.models import PromptAgentDefinition, FileSearchTool +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFileSearchStream(TestBase): @servicePreparer() @@ -90,7 +94,7 @@ def test_agent_file_search_stream(self, **kwargs): stream_response = openai_client.responses.create( stream=True, input="What products are mentioned in the document? Please provide a brief summary.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect streamed response diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream_async.py index afa42b523b70..57b8674aeb69 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_file_search_stream_async.py @@ -6,12 +6,16 @@ # cSpell:disable import os +import pytest from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport from azure.ai.projects.models import PromptAgentDefinition, FileSearchTool +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFileSearchStreamAsync(TestBase): @servicePreparer() @@ -67,7 +71,7 @@ async def test_agent_file_search_stream_async(self, **kwargs): stream_response = await openai_client.responses.create( stream=True, input="What products are mentioned in the document? Please provide a brief summary.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Collect streamed response diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool.py index a4a4ced9ee1f..a67b35472845 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool.py @@ -6,12 +6,16 @@ # cSpell:disable import json +import pytest from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy, RecordedTransport from azure.ai.projects.models import PromptAgentDefinition, FunctionTool from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFunctionTool(TestBase): @servicePreparer() @@ -82,7 +86,7 @@ def test_agent_function_tool(self, **kwargs): response = openai_client.responses.create( input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Initial response completed") @@ -135,7 +139,7 @@ def test_agent_function_tool(self, **kwargs): response = openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Final response completed") @@ -228,7 +232,7 @@ def test_agent_function_tool_multi_turn_with_multiple_calls(self, **kwargs): print("\n--- Turn 1: Current weather query ---") response_1 = openai_client.responses.create( input="What's the weather in New York?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -252,7 +256,7 @@ def test_agent_function_tool_multi_turn_with_multiple_calls(self, **kwargs): response_1 = openai_client.responses.create( input=input_list, previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -264,7 +268,7 @@ def test_agent_function_tool_multi_turn_with_multiple_calls(self, **kwargs): response_2 = openai_client.responses.create( input="What about the forecast for the next few days?", previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle forecast function call @@ -299,7 +303,7 @@ def test_agent_function_tool_multi_turn_with_multiple_calls(self, **kwargs): response_2 = openai_client.responses.create( input=input_list, previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -311,7 +315,7 @@ def test_agent_function_tool_multi_turn_with_multiple_calls(self, **kwargs): response_3 = openai_client.responses.create( input="How does that compare to Seattle's weather?", previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function calls for Seattle (agent might call both weather and forecast) @@ -353,7 +357,7 @@ def test_agent_function_tool_multi_turn_with_multiple_calls(self, **kwargs): response_3 = openai_client.responses.create( input=input_list, previous_response_id=response_3.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text @@ -420,7 +424,7 @@ def test_agent_function_tool_context_dependent_followup(self, **kwargs): print("\n--- Turn 1: Get temperature ---") response_1 = openai_client.responses.create( input="What's the temperature in Boston?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -439,7 +443,7 @@ def test_agent_function_tool_context_dependent_followup(self, **kwargs): response_1 = openai_client.responses.create( input=input_list, previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -451,7 +455,7 @@ def test_agent_function_tool_context_dependent_followup(self, **kwargs): response_2 = openai_client.responses.create( input="What is that in Celsius?", # "that" refers to the 72°F from previous response previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -472,7 +476,7 @@ def test_agent_function_tool_context_dependent_followup(self, **kwargs): response_3 = openai_client.responses.create( input="Is that warmer or colder than 25°C?", # "that" refers to the Celsius value just mentioned previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool_async.py index 5102005b2656..3413d03d8baf 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_function_tool_async.py @@ -6,6 +6,7 @@ # cSpell:disable import json +import pytest from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport @@ -13,6 +14,9 @@ from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentFunctionToolAsync(TestBase): @servicePreparer() @@ -70,7 +74,7 @@ async def test_agent_function_tool_async(self, **kwargs): response = await openai_client.responses.create( input="What's the weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Initial response completed") @@ -123,7 +127,7 @@ async def test_agent_function_tool_async(self, **kwargs): response = await openai_client.responses.create( input=input_list, previous_response_id=response.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Final response completed") @@ -217,7 +221,7 @@ async def test_agent_function_tool_multi_turn_with_multiple_calls_async(self, ** print("\n--- Turn 1: Current weather query ---") response_1 = await openai_client.responses.create( input="What's the weather in New York?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -241,7 +245,7 @@ async def test_agent_function_tool_multi_turn_with_multiple_calls_async(self, ** response_1 = await openai_client.responses.create( input=input_list, previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -253,7 +257,7 @@ async def test_agent_function_tool_multi_turn_with_multiple_calls_async(self, ** response_2 = await openai_client.responses.create( input="What about the forecast for the next few days?", previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle forecast function call @@ -288,7 +292,7 @@ async def test_agent_function_tool_multi_turn_with_multiple_calls_async(self, ** response_2 = await openai_client.responses.create( input=input_list, previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -300,7 +304,7 @@ async def test_agent_function_tool_multi_turn_with_multiple_calls_async(self, ** response_3 = await openai_client.responses.create( input="How does that compare to Seattle's weather?", previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function calls for Seattle (agent might call both weather and forecast) @@ -342,7 +346,7 @@ async def test_agent_function_tool_multi_turn_with_multiple_calls_async(self, ** response_3 = await openai_client.responses.create( input=input_list, previous_response_id=response_3.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text @@ -410,7 +414,7 @@ async def test_agent_function_tool_context_dependent_followup_async(self, **kwar print("\n--- Turn 1: Get temperature ---") response_1 = await openai_client.responses.create( input="What's the temperature in Boston?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -429,7 +433,7 @@ async def test_agent_function_tool_context_dependent_followup_async(self, **kwar response_1 = await openai_client.responses.create( input=input_list, previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -441,7 +445,7 @@ async def test_agent_function_tool_context_dependent_followup_async(self, **kwar response_2 = await openai_client.responses.create( input="What is that in Celsius?", # "that" refers to the 72°F from previous response previous_response_id=response_1.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -462,7 +466,7 @@ async def test_agent_function_tool_context_dependent_followup_async(self, **kwar response_3 = await openai_client.responses.create( input="Is that warmer or colder than 25°C?", # "that" refers to the Celsius value just mentioned previous_response_id=response_2.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation.py index 6d5ae36d069e..ac29ee0a30d7 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation.py @@ -14,6 +14,9 @@ from azure.core.exceptions import ResourceNotFoundError +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentImageGeneration(TestBase): @servicePreparer() @@ -79,7 +82,7 @@ def test_agent_image_generation(self, **kwargs): response = openai_client.responses.create( input="Generate an image of a blue circle on a white background.", extra_headers={"x-ms-oai-image-generation-deployment": image_model}, # Required for image generation - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response created (id: {response.id})") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation_async.py index ab31ff0cc827..5c70d312c2ab 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_image_generation_async.py @@ -15,6 +15,9 @@ from azure.core.exceptions import ResourceNotFoundError +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentImageGenerationAsync(TestBase): @servicePreparer() @@ -60,7 +63,7 @@ async def test_agent_image_generation_async(self, **kwargs): response = await openai_client.responses.create( input="Generate an image of a blue circle on a white background.", extra_headers={"x-ms-oai-image-generation-deployment": image_model}, # Required for image generation - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response created (id: {response.id})") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp.py index d202c31aa34e..7029d25f4be7 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp.py @@ -13,6 +13,9 @@ from openai.types.responses.response_input_param import McpApprovalResponse, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentMCP(TestBase): # To run only this test: @@ -87,7 +90,7 @@ def test_agent_mcp_basic(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Initial response completed") @@ -125,7 +128,7 @@ def test_agent_mcp_basic(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Final response completed") @@ -230,7 +233,7 @@ def test_agent_mcp_with_project_connection(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, input="What is my username in Github profile?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Initial response completed") @@ -268,7 +271,7 @@ def test_agent_mcp_with_project_connection(self, **kwargs): response = openai_client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Final response completed") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp_async.py index adc9bbde3419..5f27d42becd4 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_mcp_async.py @@ -5,6 +5,7 @@ # ------------------------------------ # cSpell:disable +import pytest from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport @@ -12,6 +13,9 @@ from openai.types.responses.response_input_param import McpApprovalResponse, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentMCPAsync(TestBase): # To run only this test: @@ -59,7 +63,7 @@ async def test_agent_mcp_basic_async(self, **kwargs): response = await openai_client.responses.create( conversation=conversation.id, input="Please summarize the Azure REST API specifications Readme", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Initial response completed") @@ -97,7 +101,7 @@ async def test_agent_mcp_basic_async(self, **kwargs): response = await openai_client.responses.create( conversation=conversation.id, input=input_list, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response, print_message="Final response completed") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search.py index bef4555d04fb..0bc7f8f54b1c 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search.py @@ -5,6 +5,7 @@ # ------------------------------------ # cSpell:disable +import pytest import time from typing import Final from test_base import TestBase, servicePreparer @@ -18,6 +19,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentMemorySearch(TestBase): @servicePreparer() @@ -37,7 +41,7 @@ def test_agent_memory_search(self, **kwargs): Action REST API Route Client Method ------+---------------------------------------------+----------------------------------- # Setup: - POST /memory_stores project_client.memory_stores.create() + POST /memory_stores project_client.beta.memory_stores.create() POST /agents/{agent_name}/versions project_client.agents.create_version() POST /conversations openai_client.conversations.create() @@ -47,7 +51,7 @@ def test_agent_memory_search(self, **kwargs): # Teardown: DELETE /conversations/{conversation_id} openai_client.conversations.delete() DELETE /agents/{agent_name}/versions/{agent_version} project_client.agents.delete_version() - DELETE /memory_stores/{memory_store_name} project_client.memory_stores.delete() + DELETE /memory_stores/{memory_store_name} project_client.beta.memory_stores.delete() """ model = kwargs.get("azure_ai_model_deployment_name") @@ -81,7 +85,7 @@ def test_agent_memory_search(self, **kwargs): # in live mode so we don't get logs of this call in test recordings. if is_live_and_not_recording(): try: - project_client.memory_stores.delete(memory_store_name) + project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -93,7 +97,7 @@ def test_agent_memory_search(self, **kwargs): embedding_model=embedding_model, options=MemoryStoreDefaultOptions(user_profile_enabled=True, chat_summary_enabled=True), ) - memory_store = project_client.memory_stores.create( + memory_store = project_client.beta.memory_stores.create( name=memory_store_name, description="Test memory store for agent conversations", definition=definition, @@ -132,7 +136,7 @@ def test_agent_memory_search(self, **kwargs): response = openai_client.responses.create( input="I prefer dark roast coffee", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) @@ -157,7 +161,7 @@ def test_agent_memory_search(self, **kwargs): new_response = openai_client.responses.create( input="Please order my usual coffee", conversation=new_conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(new_response) @@ -206,7 +210,7 @@ def test_agent_memory_search(self, **kwargs): if memory_store: try: - project_client.memory_stores.delete(memory_store.name) + project_client.beta.memory_stores.delete(memory_store.name) print("Memory store deleted") except Exception as e: print(f"Failed to delete memory store: {e}") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search_async.py index 4b9e64c8ce02..fd7a5719a873 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_memory_search_async.py @@ -6,6 +6,7 @@ # cSpell:disable import asyncio +import pytest from typing import Final from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async @@ -19,6 +20,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentMemorySearchAsync(TestBase): @servicePreparer() @@ -56,7 +60,7 @@ async def test_agent_memory_search_async(self, **kwargs): # in live mode so we don't get logs of this call in test recordings. if is_live_and_not_recording(): try: - await project_client.memory_stores.delete(memory_store_name) + await project_client.beta.memory_stores.delete(memory_store_name) print(f"Memory store `{memory_store_name}` deleted") except ResourceNotFoundError: pass @@ -68,7 +72,7 @@ async def test_agent_memory_search_async(self, **kwargs): embedding_model=embedding_model, options=MemoryStoreDefaultOptions(user_profile_enabled=True, chat_summary_enabled=True), ) - memory_store = await project_client.memory_stores.create( + memory_store = await project_client.beta.memory_stores.create( name=memory_store_name, description="Test memory store for agent conversations", definition=definition, @@ -107,7 +111,7 @@ async def test_agent_memory_search_async(self, **kwargs): response = await openai_client.responses.create( input="I prefer dark roast coffee", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) @@ -132,7 +136,7 @@ async def test_agent_memory_search_async(self, **kwargs): new_response = await openai_client.responses.create( input="Please order my usual coffee", conversation=new_conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(new_response) @@ -181,7 +185,7 @@ async def test_agent_memory_search_async(self, **kwargs): if memory_store: try: - await project_client.memory_stores.delete(memory_store.name) + await project_client.beta.memory_stores.delete(memory_store.name) print("Memory store deleted") except Exception as e: print(f"Failed to delete memory store: {e}") diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi.py index 4a862ff31b5a..de8b85f19723 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi.py @@ -19,6 +19,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentOpenApi(TestBase): # To run this test: @@ -94,7 +97,7 @@ def test_agent_openapi(self, **kwargs): response = openai_client.responses.create( input="Use the OpenAPI tool to print out, what is the weather in Seattle, WA today.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi_async.py index d56ea15d7c52..1b3e87ef063a 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_openapi_async.py @@ -20,6 +20,9 @@ ) +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentOpenApiAsync(TestBase): # To run this test: @@ -74,7 +77,7 @@ async def test_agent_openapi_async(self, **kwargs): response = await openai_client.responses.create( input="Use the OpenAPI tool to print out, what is the weather in Seattle, WA today.", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_tools_with_conversations.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_tools_with_conversations.py index 636e85370bb4..1d8a94bb44c7 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_tools_with_conversations.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_tools_with_conversations.py @@ -12,6 +12,7 @@ """ import json +import pytest from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy, RecordedTransport from azure.ai.projects.models import ( @@ -24,6 +25,9 @@ from openai.types.responses.response_input_param import FunctionCallOutput, ResponseInputParam +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentToolsWithConversations(TestBase): @servicePreparer() @@ -87,7 +91,7 @@ def test_function_tool_with_conversation(self, **kwargs): response_1 = openai_client.responses.create( input="What is 15 plus 27?", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -116,7 +120,7 @@ def test_function_tool_with_conversation(self, **kwargs): response_1 = openai_client.responses.create( input=input_list, conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response 1: {response_1.output_text[:100]}...") assert "42" in response_1.output_text @@ -126,7 +130,7 @@ def test_function_tool_with_conversation(self, **kwargs): response_2 = openai_client.responses.create( input="Now multiply that result by 2", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) # Handle function call @@ -152,7 +156,7 @@ def test_function_tool_with_conversation(self, **kwargs): response_2 = openai_client.responses.create( input=input_list, conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) print(f"Response 2: {response_2.output_text[:100]}...") assert "84" in response_2.output_text @@ -264,7 +268,7 @@ def test_file_search_with_conversation(self, **kwargs): response_1 = openai_client.responses.create( input="Which widget has the highest rating?", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -276,7 +280,7 @@ def test_file_search_with_conversation(self, **kwargs): response_2 = openai_client.responses.create( input="What is its price?", # "its" refers to Widget B from previous turn conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -288,7 +292,7 @@ def test_file_search_with_conversation(self, **kwargs): response_3 = openai_client.responses.create( input="Which widget is in the Home Goods category?", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text @@ -344,7 +348,7 @@ def test_code_interpreter_with_conversation(self, **kwargs): response_1 = openai_client.responses.create( input="Calculate the average of these numbers: 10, 20, 30, 40, 50", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text @@ -356,7 +360,7 @@ def test_code_interpreter_with_conversation(self, **kwargs): response_2 = openai_client.responses.create( input="Now calculate the standard deviation of those same numbers", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_2_text = response_2.output_text @@ -369,7 +373,7 @@ def test_code_interpreter_with_conversation(self, **kwargs): response_3 = openai_client.responses.create( input="Create a list of squares from 1 to 5", conversation=conversation.id, - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_3_text = response_3.output_text @@ -443,7 +447,7 @@ def test_code_interpreter_with_file_in_conversation(self, **kwargs): response_1 = openai_client.responses.create( conversation=conversation.id, input="Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) response_1_text = response_1.output_text diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search.py index b93038521e1d..673863ba877a 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search.py @@ -5,11 +5,15 @@ # ------------------------------------ # cSpell:disable +import pytest from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy, RecordedTransport from azure.ai.projects.models import PromptAgentDefinition, WebSearchPreviewTool, ApproximateLocation +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentWebSearch(TestBase): @servicePreparer() @@ -66,7 +70,7 @@ def test_agent_web_search(self, **kwargs): response = openai_client.responses.create( input="What is the current weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) diff --git a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search_async.py b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search_async.py index 5c7c0ff5b46b..700196858a1c 100644 --- a/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search_async.py +++ b/sdk/ai/azure-ai-projects/tests/agents/tools/test_agent_web_search_async.py @@ -5,12 +5,16 @@ # ------------------------------------ # cSpell:disable +import pytest from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async from devtools_testutils import RecordedTransport from azure.ai.projects.models import PromptAgentDefinition, WebSearchPreviewTool, ApproximateLocation +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestAgentWebSearchAsync(TestBase): @servicePreparer() @@ -46,7 +50,7 @@ async def test_agent_web_search_async(self, **kwargs): response = await openai_client.responses.create( input="What is the current weather in Seattle?", - extra_body={"agent": {"name": agent.name, "type": "agent_reference"}}, + extra_body={"agent_reference": {"name": agent.name, "type": "agent_reference"}}, ) self.validate_response(response) diff --git a/sdk/ai/azure-ai-projects/tests/connections/test_connections.py b/sdk/ai/azure-ai-projects/tests/connections/test_connections.py index 968fe4d7a503..f916f2d1b94f 100644 --- a/sdk/ai/azure-ai-projects/tests/connections/test_connections.py +++ b/sdk/ai/azure-ai-projects/tests/connections/test_connections.py @@ -3,10 +3,14 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestConnections(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/connections/test_connections_async.py b/sdk/ai/azure-ai-projects/tests/connections/test_connections_async.py index b98cdacad711..12fce861fb5d 100644 --- a/sdk/ai/azure-ai-projects/tests/connections/test_connections_async.py +++ b/sdk/ai/azure-ai-projects/tests/connections/test_connections_async.py @@ -3,11 +3,15 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.projects.aio import AIProjectClient from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestConnectionsAsync(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/datasets/test_datasets.py b/sdk/ai/azure-ai-projects/tests/datasets/test_datasets.py index ea816d596fc9..a64874ec090f 100644 --- a/sdk/ai/azure-ai-projects/tests/datasets/test_datasets.py +++ b/sdk/ai/azure-ai-projects/tests/datasets/test_datasets.py @@ -20,6 +20,9 @@ data_file2 = os.path.join(data_folder, "data_file2.txt") +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestDatasets(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/datasets/test_datasets_async.py b/sdk/ai/azure-ai-projects/tests/datasets/test_datasets_async.py index 6400df3c369d..3aafccd1f837 100644 --- a/sdk/ai/azure-ai-projects/tests/datasets/test_datasets_async.py +++ b/sdk/ai/azure-ai-projects/tests/datasets/test_datasets_async.py @@ -21,6 +21,9 @@ data_file2 = os.path.join(data_folder, "data_file2.txt") +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestDatasetsAsync(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/deployments/test_deployments.py b/sdk/ai/azure-ai-projects/tests/deployments/test_deployments.py index 8bc90ee53a4c..549e91e220b9 100644 --- a/sdk/ai/azure-ai-projects/tests/deployments/test_deployments.py +++ b/sdk/ai/azure-ai-projects/tests/deployments/test_deployments.py @@ -3,11 +3,15 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.projects import AIProjectClient from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestDeployments(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/deployments/test_deployments_async.py b/sdk/ai/azure-ai-projects/tests/deployments/test_deployments_async.py index 92549800faa2..54bea9b8d3cf 100644 --- a/sdk/ai/azure-ai-projects/tests/deployments/test_deployments_async.py +++ b/sdk/ai/azure-ai-projects/tests/deployments/test_deployments_async.py @@ -3,11 +3,15 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.projects.aio import AIProjectClient from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestDeploymentsAsync(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/files/test_files.py b/sdk/ai/azure-ai-projects/tests/files/test_files.py index f934ce955547..27661719fa00 100644 --- a/sdk/ai/azure-ai-projects/tests/files/test_files.py +++ b/sdk/ai/azure-ai-projects/tests/files/test_files.py @@ -10,6 +10,9 @@ from devtools_testutils import recorded_by_proxy, RecordedTransport +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestFiles(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/files/test_files_async.py b/sdk/ai/azure-ai-projects/tests/files/test_files_async.py index cc85b778e1a5..f9fe2f7acb59 100644 --- a/sdk/ai/azure-ai-projects/tests/files/test_files_async.py +++ b/sdk/ai/azure-ai-projects/tests/files/test_files_async.py @@ -11,6 +11,9 @@ from devtools_testutils import RecordedTransport +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestFilesAsync(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning.py b/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning.py index 6a265f3ada48..d8e28452557f 100644 --- a/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning.py +++ b/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning.py @@ -60,6 +60,9 @@ def _wrapper(test_class, job_type, expected_method_type, **kwargs): return _wrapper +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestFineTuning(TestBase): def _create_sft_finetuning_job(self, openai_client, train_file_id, validation_file_id, training_type, model_type): diff --git a/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning_async.py b/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning_async.py index 06838474a2c9..be0cc2de95dc 100644 --- a/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning_async.py +++ b/sdk/ai/azure-ai-projects/tests/finetuning/test_finetuning_async.py @@ -63,6 +63,9 @@ async def _wrapper(test_class, job_type, expected_method_type, **kwargs): return _wrapper +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestFineTuningAsync(TestBase): async def _create_sft_finetuning_job_async( diff --git a/sdk/ai/azure-ai-projects/tests/indexes/test_indexes.py b/sdk/ai/azure-ai-projects/tests/indexes/test_indexes.py index eb22ca9ff27b..1210c6142926 100644 --- a/sdk/ai/azure-ai-projects/tests/indexes/test_indexes.py +++ b/sdk/ai/azure-ai-projects/tests/indexes/test_indexes.py @@ -4,12 +4,16 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.projects import AIProjectClient from azure.ai.projects.models import AzureAISearchIndex, IndexType from test_base import TestBase, servicePreparer from devtools_testutils import recorded_by_proxy +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestIndexes(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/indexes/test_indexes_async.py b/sdk/ai/azure-ai-projects/tests/indexes/test_indexes_async.py index eb88e0d9a915..70b7b73fb3b3 100644 --- a/sdk/ai/azure-ai-projects/tests/indexes/test_indexes_async.py +++ b/sdk/ai/azure-ai-projects/tests/indexes/test_indexes_async.py @@ -4,12 +4,16 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.projects.aio import AIProjectClient from azure.ai.projects.models import AzureAISearchIndex, IndexType from test_base import TestBase, servicePreparer from devtools_testutils.aio import recorded_by_proxy_async +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestIndexesAsync(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/redteams/test_redteams.py b/sdk/ai/azure-ai-projects/tests/redteams/test_redteams.py index 2aefc6cef437..425bc89e98ee 100644 --- a/sdk/ai/azure-ai-projects/tests/redteams/test_redteams.py +++ b/sdk/ai/azure-ai-projects/tests/redteams/test_redteams.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.projects import AIProjectClient from azure.ai.projects.models import ( RedTeam, @@ -14,6 +15,9 @@ from devtools_testutils import recorded_by_proxy +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestRedTeams(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: @@ -44,7 +48,7 @@ def test_red_teams(self, **kwargs): ) # Create and run the Red Team scan - red_team_response = project_client.red_teams.create(red_team=red_team) + red_team_response = project_client.beta.red_teams.create(red_team=red_team) print(f"Red Team scan created with scan name: {red_team_response.name}") TestBase.validate_red_team_response( red_team_response, expected_attack_strategies=1, expected_risk_categories=1 @@ -52,13 +56,13 @@ def test_red_teams(self, **kwargs): print("Getting Red Team scan details") # Use the name returned by the create operation for the get call - get_red_team_response = project_client.red_teams.get(name=red_team_response.name) + get_red_team_response = project_client.beta.red_teams.get(name=red_team_response.name) print(f"Red Team scan status: {get_red_team_response.status}") TestBase.validate_red_team_response( get_red_team_response, expected_attack_strategies=1, expected_risk_categories=1 ) print("Listing all Red Team scans") - for scan in project_client.red_teams.list(): + for scan in project_client.beta.red_teams.list(): print(f"Found scan: {scan.name}, Status: {scan.status}") TestBase.validate_red_team_response(scan) diff --git a/sdk/ai/azure-ai-projects/tests/redteams/test_redteams_async.py b/sdk/ai/azure-ai-projects/tests/redteams/test_redteams_async.py index d6809d2d785b..65dc52989320 100644 --- a/sdk/ai/azure-ai-projects/tests/redteams/test_redteams_async.py +++ b/sdk/ai/azure-ai-projects/tests/redteams/test_redteams_async.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.projects.aio import AIProjectClient from azure.ai.projects.models import ( RedTeam, @@ -14,6 +15,9 @@ from devtools_testutils.aio import recorded_by_proxy_async +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestRedTeams(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: @@ -44,7 +48,7 @@ async def test_red_teams_async(self, **kwargs): ) # Create and run the Red Team scan - red_team_response = await project_client.red_teams.create(red_team=red_team) + red_team_response = await project_client.beta.red_teams.create(red_team=red_team) print(f"Red Team scan created with scan name: {red_team_response.name}") TestBase.validate_red_team_response( red_team_response, expected_attack_strategies=1, expected_risk_categories=1 @@ -52,13 +56,13 @@ async def test_red_teams_async(self, **kwargs): print("Getting Red Team scan details") # Use the name returned by the create operation for the get call - get_red_team_response = await project_client.red_teams.get(name=red_team_response.name) + get_red_team_response = await project_client.beta.red_teams.get(name=red_team_response.name) print(f"Red Team scan status: {get_red_team_response.status}") TestBase.validate_red_team_response( get_red_team_response, expected_attack_strategies=1, expected_risk_categories=1 ) print("Listing all Red Team scans") - async for scan in project_client.red_teams.list(): + async for scan in project_client.beta.red_teams.list(): print(f"Found scan: {scan.name}, Status: {scan.status}") TestBase.validate_red_team_response(scan) diff --git a/sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides.py b/sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides.py new file mode 100644 index 000000000000..2aacdfe74707 --- /dev/null +++ b/sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides.py @@ -0,0 +1,136 @@ +# pylint: disable=line-too-long,useless-suppression +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +""" +Tests to verify that a custom http_client can be passed to get_openai_client() +and that the returned OpenAI client uses it instead of the default one. +""" + +import os +import pytest +import httpx +from typing import Any +from azure.core.credentials import TokenCredential +from azure.ai.projects import AIProjectClient + + +class DummyTokenCredential(TokenCredential): + """A dummy credential that returns None for testing purposes.""" + + def get_token(self, *scopes: str, **kwargs: Any): # type: ignore[override] + return None + + +@pytest.fixture(autouse=True) +def patch_openai(monkeypatch): + """Ensure no real network/token calls are made during the test.""" + monkeypatch.setattr("azure.ai.projects._patch.get_bearer_token_provider", lambda *_, **__: "token-provider") + + +class TestGetOpenAIClientWithOverrides: + """Tests for custom http_client override in get_openai_client().""" + + @pytest.mark.skipif( + os.environ.get("AZURE_AI_PROJECTS_CONSOLE_LOGGING", "false").lower() == "true", + reason="Test skipped because AZURE_AI_PROJECTS_CONSOLE_LOGGING is set to 'true'", + ) + def test_http_client_override(self): + """ + Test that a custom http_client passed to get_openai_client() is actually used + by the returned OpenAI client when making API calls. + """ + # Track whether our custom http_client was invoked + request_intercepted = {"called": False, "request": None} + + class TrackingTransport(httpx.BaseTransport): + """Custom transport that tracks requests and returns mock responses.""" + + def handle_request(self, request: httpx.Request) -> httpx.Response: + # Mark that our custom transport was called + request_intercepted["called"] = True + request_intercepted["request"] = request + + # Return a mock response for the OpenAI responses.create() call + return httpx.Response( + 200, + request=request, + json={ + "id": "resp_test_123", + "output": [ + { + "type": "message", + "id": "msg_test_123", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "This is a test response from the mock.", + } + ], + } + ], + }, + ) + + # Create a custom http_client with our tracking transport + custom_http_client = httpx.Client(transport=TrackingTransport()) + + # Create the AIProjectClient + project_client = AIProjectClient( + endpoint="https://example.com/api/projects/test", + credential=DummyTokenCredential(), + ) + + # Get an OpenAI client with our custom http_client + openai_client = project_client.get_openai_client(http_client=custom_http_client) + + # Make an API call + response = openai_client.responses.create( + model="gpt-4o", + input="Test input", + ) + + # Verify the custom http_client was used + assert request_intercepted["called"], "Custom http_client was not used for the request" + assert request_intercepted["request"] is not None, "Request was not captured" + + # Verify the request was made to the expected endpoint + assert "/openai/v1/responses" in str(request_intercepted["request"].url) + + # Verify we got a valid response + assert response.id == "resp_test_123" + assert response.output_text == "This is a test response from the mock." + + # To run this test: pytest tests/responses/test_responses_with_http_client_override.py::TestResponsesWithHttpClientOverride::test_api_key_and_base_url_overrides -s + def test_api_key_and_base_url_overrides(self): + """ + Test that api_key and base_url passed to get_openai_client() are used + by the returned OpenAI client instead of the default values. + """ + # Create the AIProjectClient + with AIProjectClient( + endpoint="https://example.com/api/projects/test", + credential=DummyTokenCredential(), + ) as project_client: + + # Define custom values + custom_api_key = "my-custom-api-key" + custom_base_url = "https://my.custom.endpoint.com/path1/path2" + + # Get an OpenAI client with custom api_key and base_url + with project_client.get_openai_client( + api_key=custom_api_key, + base_url=custom_base_url, + ) as openai_client: + + # Verify the custom api_key was used + assert ( + openai_client.api_key == custom_api_key + ), f"Expected api_key '{custom_api_key}', got '{openai_client.api_key}'" + + # Verify the custom base_url was used + assert ( + str(openai_client.base_url) == custom_base_url + "/" + ), f"Expected base_url '{custom_base_url}/', got '{openai_client.base_url}'" diff --git a/sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides_async.py b/sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides_async.py new file mode 100644 index 000000000000..0abf63f41963 --- /dev/null +++ b/sdk/ai/azure-ai-projects/tests/responses/test_openai_client_overrides_async.py @@ -0,0 +1,140 @@ +# pylint: disable=line-too-long,useless-suppression +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +""" +Tests to verify that a custom http_client can be passed to get_openai_client() +and that the returned AsyncOpenAI client uses it instead of the default one. +""" + +import os +import pytest +import httpx +from typing import Any +from azure.core.credentials_async import AsyncTokenCredential +from azure.ai.projects.aio import AIProjectClient + + +class DummyAsyncTokenCredential(AsyncTokenCredential): + """A dummy async credential that returns None for testing purposes.""" + + async def get_token(self, *scopes: str, **kwargs: Any): # type: ignore[override] + return None + + async def close(self) -> None: + pass + + +@pytest.fixture(autouse=True) +def patch_openai(monkeypatch): + """Ensure no real network/token calls are made during the test.""" + monkeypatch.setattr("azure.ai.projects.aio._patch.get_bearer_token_provider", lambda *_, **__: "token-provider") + + +class TestGetOpenAIClientWithOverridesAsync: + """Tests for custom http_client override in async get_openai_client().""" + + @pytest.mark.skipif( + os.environ.get("AZURE_AI_PROJECTS_CONSOLE_LOGGING", "false").lower() == "true", + reason="Test skipped because AZURE_AI_PROJECTS_CONSOLE_LOGGING is set to 'true'", + ) + @pytest.mark.asyncio + async def test_http_client_override_async(self): + """ + Test that a custom http_client passed to get_openai_client() is actually used + by the returned AsyncOpenAI client when making API calls. + """ + # Track whether our custom http_client was invoked + request_intercepted = {"called": False, "request": None} + + class TrackingTransport(httpx.AsyncBaseTransport): + """Custom async transport that tracks requests and returns mock responses.""" + + async def handle_async_request(self, request: httpx.Request) -> httpx.Response: + # Mark that our custom transport was called + request_intercepted["called"] = True + request_intercepted["request"] = request + + # Return a mock response for the OpenAI responses.create() call + return httpx.Response( + 200, + request=request, + json={ + "id": "resp_test_123", + "output": [ + { + "type": "message", + "id": "msg_test_123", + "role": "assistant", + "content": [ + { + "type": "output_text", + "text": "This is a test response from the mock.", + } + ], + } + ], + }, + ) + + # Create a custom http_client with our tracking transport + custom_http_client = httpx.AsyncClient(transport=TrackingTransport()) + + # Create the AIProjectClient + project_client = AIProjectClient( + endpoint="https://example.com/api/projects/test", + credential=DummyAsyncTokenCredential(), + ) + + # Get an AsyncOpenAI client with our custom http_client + openai_client = project_client.get_openai_client(http_client=custom_http_client) + + # Make an API call + response = await openai_client.responses.create( + model="gpt-4o", + input="Test input", + ) + + # Verify the custom http_client was used + assert request_intercepted["called"], "Custom http_client was not used for the request" + assert request_intercepted["request"] is not None, "Request was not captured" + + # Verify the request was made to the expected endpoint + assert "/openai/v1/responses" in str(request_intercepted["request"].url) + + # Verify we got a valid response + assert response.id == "resp_test_123" + assert response.output_text == "This is a test response from the mock." + + @pytest.mark.asyncio + async def test_api_key_and_base_url_overrides_async(self): + """ + Test that api_key and base_url passed to get_openai_client() are used + by the returned AsyncOpenAI client instead of the default values. + """ + # Define custom values + custom_api_key = "my-custom-api-key" + custom_base_url = "https://my.custom.endpoint.com/path1/path2" + + # Create the AIProjectClient using async with pattern + async with AIProjectClient( + endpoint="https://example.com/api/projects/test", + credential=DummyAsyncTokenCredential(), + ) as project_client: + + # Get an AsyncOpenAI client with custom api_key and base_url + async with project_client.get_openai_client( + api_key=custom_api_key, + base_url=custom_base_url, + ) as openai_client: + + # Verify the custom api_key was used + assert ( + openai_client.api_key == custom_api_key + ), f"Expected api_key '{custom_api_key}', got '{openai_client.api_key}'" + + # Verify the custom base_url was used + assert ( + str(openai_client.base_url) == custom_base_url + "/" + ), f"Expected base_url '{custom_base_url}/', got '{openai_client.base_url}'" diff --git a/sdk/ai/azure-ai-projects/tests/responses/test_responses.py b/sdk/ai/azure-ai-projects/tests/responses/test_responses.py index a41d3d7505d6..c8129bedc624 100644 --- a/sdk/ai/azure-ai-projects/tests/responses/test_responses.py +++ b/sdk/ai/azure-ai-projects/tests/responses/test_responses.py @@ -45,6 +45,9 @@ class TestResponses(TestBase): # To run this test: # pytest tests\responses\test_responses.py::TestResponses::test_responses -s + @pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" + ) @servicePreparer() @recorded_by_proxy(RecordedTransport.HTTPX) def test_responses(self, **kwargs): diff --git a/sdk/ai/azure-ai-projects/tests/responses/test_responses_async.py b/sdk/ai/azure-ai-projects/tests/responses/test_responses_async.py index bf7252962dad..2bfbaa92926b 100644 --- a/sdk/ai/azure-ai-projects/tests/responses/test_responses_async.py +++ b/sdk/ai/azure-ai-projects/tests/responses/test_responses_async.py @@ -41,6 +41,9 @@ class TestResponsesAsync(TestBase): # To run this test: # pytest tests\responses\test_responses_async.py::TestResponsesAsync::test_responses_async -s + @pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" + ) @servicePreparer() @recorded_by_proxy_async(RecordedTransport.HTTPX) async def test_responses_async(self, **kwargs): diff --git a/sdk/ai/azure-ai-projects/tests/samples/README.md b/sdk/ai/azure-ai-projects/tests/samples/README.md index 53cf0320b96d..0f81c31288ad 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/README.md +++ b/sdk/ai/azure-ai-projects/tests/samples/README.md @@ -9,6 +9,25 @@ Use recorded tests to validate samples with `SyncSampleExecutor` and `AsyncSampl **VS Code tip (record a single sample):** Open the **Testing** tab, expand the pytest tree to find the specific sample test case (for example, one parameterized case for a particular `sample_path`), then right-click it and choose **Run Test** (or **Debug Test**). Make sure your `.env` (or your test run environment) includes `AZURE_TEST_RUN_LIVE=true` and `AZURE_SKIP_LIVE_RECORDING=false` so that run captures a new recording for just that sample. +## Sample test logging + +Optionally enable logging to capture sample execution results in log files (useful for monitoring and alerting): + +```bash +# In .env - uncomment to enable logging +SAMPLE_TEST_ERROR_LOG=_errors_.log +SAMPLE_TEST_FAILED_LOG=_failed_.log +SAMPLE_TEST_PASSED_LOG=_success_.log +``` + +Log types: + +- **`SAMPLE_TEST_ERROR_LOG`**: Sample crashed with an exception during execution +- **`SAMPLE_TEST_FAILED_LOG`**: Sample ran successfully but LLM validation failed (incorrect output) +- **`SAMPLE_TEST_PASSED_LOG`**: Sample ran successfully and LLM validation passed (correct output) + +Logs are written to the system's temp directory with the specified filename format. Each log includes the sample path, status/error details, exception traceback (for errors), and all captured print statements. + ## Sync example ```python @@ -187,4 +206,37 @@ Notes: - If omitted, the id is auto-generated from the sample filename and env-var keys (for example, `sample_agent_computer_use-[COMPUTER_USE_MODEL_DEPLOYMENT_NAME]`). - If provided, it becomes the full parameter id for that variant (no filename prefix). - If the auto-generated id makes the recording file path too long (most commonly on Windows), the recording file may fail to generate; set a short `test_id` (and keep it unique across all parametrized cases). -- In VS Code’s **Testing** tab, these show up as additional parameterized cases for the same test, using the parameter id. +- In VS Code's **Testing** tab, these show up as additional parameterized cases for the same test, using the parameter id. + +## Allowing LLM validation failures + +LLM validation may produce false alarms when it doesn't understand sample output well enough, incorrectly flagging correct samples as failed. To keep the CI pipeline green while monitoring these validation issues, you can specify samples that are allowed to pass despite LLM validation failures. + +Define an allowlist at the top of your test file: + +```python +# Samples that are allowed to pass even when LLM validation fails +ALLOWED_LLM_VALIDATION_FAILURES = { + "sample_agent_basic.py", + "sample_workflow_multi_agent.py", +} +``` + +Pass the allowlist to the executor: + +```python +executor = SyncSampleExecutor( + self, + sample_path, + allowed_llm_validation_failures=ALLOWED_LLM_VALIDATION_FAILURES, + **kwargs, +) +``` + +Behavior: + +- **Samples in the allowlist:** Pass the test even when LLM validation fails. A warning message is printed to the console, and a failed report is still generated (if `SAMPLE_TEST_FAILED_LOG` is configured in `.env`). +- **Samples not in the allowlist:** Fail the test when LLM validation fails (existing behavior). +- **All samples:** Execution errors (exceptions) always fail the test, regardless of the allowlist. + +This allows you to dismiss false alarms from LLM validation while keeping the CI pipeline green. Failed reports are still generated for monitoring purposes. diff --git a/sdk/ai/azure-ai-projects/tests/samples/sample_executor.py b/sdk/ai/azure-ai-projects/tests/samples/sample_executor.py index 46f62c506efc..e0affa38c5fe 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/sample_executor.py +++ b/sdk/ai/azure-ai-projects/tests/samples/sample_executor.py @@ -7,10 +7,17 @@ import os import sys import re +import logging +import importlib import pytest import inspect import importlib.util import functools +import traceback +import tempfile +from datetime import datetime +from contextlib import contextmanager + from dataclasses import dataclass, field from typing import overload, Union, Optional @@ -173,12 +180,14 @@ def __init__( sample_path: str, *, env_var_mapping: dict[str, str] = {}, + allowed_llm_validation_failures: Optional[set[str]] = None, **kwargs, ): self.test_instance = test_instance self.sample_path = sample_path self.print_calls: list[str] = [] self._original_print = print + self.allowed_llm_validation_failures = allowed_llm_validation_failures or set() # Prepare environment variables self.env_vars = {} @@ -219,6 +228,190 @@ def _capture_print(self, *args, **kwargs): self.print_calls.append(" ".join(str(arg) for arg in args)) self._original_print(*args, **kwargs) + @contextmanager + def _capture_debug_logs(self): + """Capture logger DEBUG output into the same array used for print capture.""" + + bearer_token_pattern = re.compile(r"(?i)(Bearer\s+)([^\s\"',;]+)") + + def _sanitize_log_message(message: str) -> str: + return bearer_token_pattern.sub(r"\1", message) + + class _PrintCaptureLogHandler(logging.Handler): + def __init__(self, sink: list[str]): + super().__init__(level=logging.DEBUG) + self._sink = sink + self._included_logger_prefixes = ( + "azure", + "msrest", + "openai", + "httpx", + ) + + def emit(self, record: logging.LogRecord) -> None: + if not any(record.name.startswith(prefix) for prefix in self._included_logger_prefixes): + return + try: + message = self.format(record) + except Exception: # pylint: disable=broad-exception-caught + message = record.getMessage() + self._sink.append(_sanitize_log_message(message)) + + root_logger = logging.getLogger() + previous_root_level = root_logger.level + + target_loggers = [ + "azure", + "azure.core", + "azure.core.pipeline.policies.http_logging_policy", + "msrest", + "msrest.http_logger", + "httpx", + "openai", + ] + + previous_logger_levels: dict[str, int] = {} + for logger_name in target_loggers: + logger_instance = logging.getLogger(logger_name) + previous_logger_levels[logger_name] = logger_instance.level + logger_instance.setLevel(logging.DEBUG) + + patched_is_enabled_for = [] + for module_name in ["msrest.http_logger", "azure.core.pipeline.policies._universal"]: + try: + module = importlib.import_module(module_name) + module_logger = getattr(module, "_LOGGER", None) + if module_logger and hasattr(module_logger, "isEnabledFor"): + original_is_enabled_for = module_logger.isEnabledFor + + def _always_true(_level, _logger=module_logger): + return True + + module_logger.isEnabledFor = _always_true + patched_is_enabled_for.append((module_logger, original_is_enabled_for)) + except Exception: # pylint: disable=broad-exception-caught + continue + + capture_handler = _PrintCaptureLogHandler(self.print_calls) + capture_handler.setFormatter(logging.Formatter("[%(name)s] %(message)s")) + + root_logger.setLevel(logging.DEBUG) + root_logger.addHandler(capture_handler) + + try: + yield + finally: + root_logger.removeHandler(capture_handler) + root_logger.setLevel(previous_root_level) + + for logger_name, logger_level in previous_logger_levels.items(): + logging.getLogger(logger_name).setLevel(logger_level) + + for module_logger, original_is_enabled_for in patched_is_enabled_for: + module_logger.isEnabledFor = original_is_enabled_for + + def _get_log_file_path(self, log_env_var: str) -> Optional[str]: + """Get and prepare log file path based on environment variable. + + Args: + log_env_var: Environment variable name to check for log format + + Returns: + Path to the log file (cleaned up and ready to write), or None if logging is disabled + """ + # Only create logs in live mode + if not _is_live_mode(): + return None + + # Only log if environment variable is set + log_format = os.environ.get(log_env_var) + if not log_format: + return None + + timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") + sample_filename = os.path.basename(self.sample_path).replace(".py", "") + + # Replace placeholders in the format template + log_filename = log_format.replace("", sample_filename).replace("", timestamp) + log_file = os.path.join(tempfile.gettempdir(), log_filename) + + # Remove existing file if present to ensure clean overwrite + if os.path.exists(log_file): + os.remove(log_file) + + return log_file + + def _write_error_log(self, reason: str, exception_info: str) -> Optional[str]: + """Write captured print statements to a log file for execution errors. + + Args: + reason: Description of the exception + exception_info: Traceback or exception details to include in log + + Returns: + Path to the created log file, or None if logging is disabled + """ + log_file = self._get_log_file_path("SAMPLE_TEST_ERROR_LOG") + if not log_file: + return None + + with open(log_file, "w", encoding="utf-8") as f: + f.write(f"Sample: {self.sample_path}\n") + f.write(f"Execution Error:\n{reason}\n\n") + f.write("Exception Details:\n") + f.write("=" * 80 + "\n") + f.write(exception_info) + f.write("\n" + "=" * 80 + "\n\n") + f.write("Print Statements:\n") + f.write("=" * 80 + "\n") + for i, print_call in enumerate(self.print_calls, 1): + f.write(f"{i}. {print_call}\n") + return log_file + + def _write_failed_log(self, reason: str) -> Optional[str]: + """Write captured print statements to a log file for validation failures. + + Args: + reason: Description of why validation failed + + Returns: + Path to the created log file, or None if logging is disabled + """ + log_file = self._get_log_file_path("SAMPLE_TEST_FAILED_LOG") + if not log_file: + return None + + with open(log_file, "w", encoding="utf-8") as f: + f.write(f"Sample: {self.sample_path}\n") + f.write(f"Validation Failed: {reason}\n\n") + f.write("Print Statements:\n") + f.write("=" * 80 + "\n") + for i, print_call in enumerate(self.print_calls, 1): + f.write(f"{i}. {print_call}\n") + return log_file + + def _write_passed_log(self, reason: str = "Validation passed") -> Optional[str]: + """Write captured print statements to a log file for validation passes. + + Args: + reason: Description of successful validation + + Returns: + Path to the created log file, or None if logging is disabled + """ + log_file = self._get_log_file_path("SAMPLE_TEST_PASSED_LOG") + if not log_file: + return None + + with open(log_file, "w", encoding="utf-8") as f: + f.write(f"Sample: {self.sample_path}\n") + f.write(f"Validation Passed: {reason}\n\n") + f.write("Print Statements:\n") + f.write("=" * 80 + "\n") + for i, print_call in enumerate(self.print_calls, 1): + f.write(f"{i}. {print_call}\n") + return log_file + def _get_validation_request_params(self, instructions: str, model: str = "gpt-4o") -> dict: """Get common parameters for validation request.""" return { @@ -240,23 +433,26 @@ def _get_validation_request_params(self, instructions: str, model: str = "gpt-4o def _assert_validation_result(self, test_report: dict) -> None: """Assert validation result and print reason.""" + sample_filename = os.path.basename(self.sample_path) + is_allowed_to_fail = sample_filename in self.allowed_llm_validation_failures + if not test_report["correct"]: - # Write print statements to log file in temp folder for debugging - import tempfile - from datetime import datetime - - timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") - log_file = os.path.join(tempfile.gettempdir(), f"sample_validation_error_{timestamp}.log") - with open(log_file, "w", encoding="utf-8") as f: - f.write(f"Sample: {self.sample_path}\n") - f.write(f"Validation Error: {test_report['reason']}\n\n") - f.write("Print Statements:\n") - f.write("=" * 80 + "\n") - for i, print_call in enumerate(self.print_calls, 1): - f.write(f"{i}. {print_call}\n") - print(f"\nValidation failed! Print statements logged to: {log_file}") - assert test_report["correct"], f"Error is identified: {test_report['reason']}" - print(f"Reason: {test_report['reason']}") + log_file = self._write_failed_log(test_report["reason"]) + if log_file: + print(f"\nValidation failed! Print statements logged to: {log_file}") + + if is_allowed_to_fail: + print( + f"\nWARNING: '{sample_filename}' is in allowed_llm_validation_failures - test passing despite validation failure" + ) + print(f"Reason: {test_report['reason']}") + else: + assert False, f"Error is identified: {test_report['reason']}" + else: + log_file = self._write_passed_log(test_report["reason"]) + if log_file: + print(f"\nValidation passed! Print statements logged to: {log_file}") + print(f"Reason: {test_report['reason']}") class SamplePathPasser: @@ -280,8 +476,22 @@ def _wrapper_sync(test_class, sample_path, **kwargs): class SyncSampleExecutor(BaseSampleExecutor): """Synchronous sample executor that only uses sync credentials.""" - def __init__(self, test_instance, sample_path: str, *, env_var_mapping: dict[str, str] = {}, **kwargs): - super().__init__(test_instance, sample_path, env_var_mapping=env_var_mapping, **kwargs) + def __init__( + self, + test_instance, + sample_path: str, + *, + env_var_mapping: dict[str, str] = {}, + allowed_llm_validation_failures: Optional[set[str]] = None, + **kwargs, + ): + super().__init__( + test_instance, + sample_path, + env_var_mapping=env_var_mapping, + allowed_llm_validation_failures=allowed_llm_validation_failures, + **kwargs, + ) self.tokenCredential: Optional[TokenCredential | FakeTokenCredential] = None def _get_mock_credential(self): @@ -308,26 +518,38 @@ def execute(self, patched_open_fn=None): MonkeyPatch.context() as mp, self._get_mock_credential(), ): + mp.setenv("AZURE_AI_PROJECTS_CONSOLE_LOGGING", "true") for var_name, var_value in self.env_vars.items(): mp.setenv(var_name, var_value) if self.spec.loader is None: raise ImportError(f"Could not load module {self.spec.name} from {self.sample_path}") with ( + self._capture_debug_logs(), mock.patch("builtins.print", side_effect=self._capture_print), mock.patch("builtins.open", side_effect=patched_open_fn), ): - self.spec.loader.exec_module(self.module) - # In playback mode, patch time functions on the module: - # - time.sleep: avoid waiting for polling loops (instant) - # - time.time: return fixed value for deterministic request bodies - # Must be done after exec_module so the module's 'time' reference can be patched. - if not is_live() and hasattr(self.module, "time"): - self.module.time.sleep = lambda _: None - self.module.time.time = lambda: PLAYBACK_TIMESTAMP - # Call main() if it exists (samples wrap their code in main()) - if hasattr(self.module, "main") and callable(self.module.main): - self.module.main() + try: + self.spec.loader.exec_module(self.module) + # In playback mode, patch time functions on the module: + # - time.sleep: avoid waiting for polling loops (instant) + # - time.time: return fixed value for deterministic request bodies + # Must be done after exec_module so the module's 'time' reference can be patched. + if not is_live() and hasattr(self.module, "time"): + self.module.time.sleep = lambda _: None + self.module.time.time = lambda: PLAYBACK_TIMESTAMP + # Call main() if it exists (samples wrap their code in main()) + if hasattr(self.module, "main") and callable(self.module.main): + self.module.main() + except Exception as e: + # Log print statements with exception details before re-raising + exception_info = traceback.format_exc() + log_file = self._write_error_log( + reason=f"{type(e).__name__}: {str(e)}", exception_info=exception_info + ) + if log_file: + print(f"\nSample execution failed! Print statements logged to: {log_file}") + raise def validate_print_calls_by_llm( self, @@ -348,7 +570,7 @@ def validate_print_calls_by_llm( ) with ( AIProjectClient( - endpoint=endpoint, credential=cast(TokenCredential, self.tokenCredential) + endpoint=endpoint, credential=cast(TokenCredential, self.tokenCredential), logging_enable=True ) as project_client, project_client.get_openai_client() as openai_client, ): @@ -360,8 +582,22 @@ def validate_print_calls_by_llm( class AsyncSampleExecutor(BaseSampleExecutor): """Asynchronous sample executor that uses async credentials.""" - def __init__(self, test_instance, sample_path: str, *, env_var_mapping: dict[str, str] = {}, **kwargs): - super().__init__(test_instance, sample_path, env_var_mapping=env_var_mapping, **kwargs) + def __init__( + self, + test_instance, + sample_path: str, + *, + env_var_mapping: dict[str, str] = {}, + allowed_llm_validation_failures: Optional[set[str]] = None, + **kwargs, + ): + super().__init__( + test_instance, + sample_path, + env_var_mapping=env_var_mapping, + allowed_llm_validation_failures=allowed_llm_validation_failures, + **kwargs, + ) self.tokenCredential: Optional[AsyncTokenCredential | AsyncFakeCredential] = None def _get_mock_credential(self): @@ -387,24 +623,34 @@ async def execute_async(self, patched_open_fn=None): with ( MonkeyPatch.context() as mp, self._get_mock_credential(), + self._capture_debug_logs(), mock.patch("builtins.print", side_effect=self._capture_print), mock.patch("builtins.open", side_effect=patched_open_fn), ): + mp.setenv("AZURE_AI_PROJECTS_CONSOLE_LOGGING", "true") for var_name, var_value in self.env_vars.items(): mp.setenv(var_name, var_value) if self.spec.loader is None: raise ImportError(f"Could not load module {self.spec.name} from {self.sample_path}") - self.spec.loader.exec_module(self.module) - # In playback mode, patch time functions on the module: - # - time.sleep: avoid waiting for polling loops (instant) - # - time.time: return fixed value for deterministic request bodies - # Must be done after exec_module so the module's 'time' reference can be patched. - if not is_live() and hasattr(self.module, "time"): - self.module.time.sleep = lambda _: None - self.module.time.time = lambda: PLAYBACK_TIMESTAMP - # Call main() if it exists (samples wrap their code in main()) - if hasattr(self.module, "main") and callable(self.module.main): - await self.module.main() + try: + self.spec.loader.exec_module(self.module) + # In playback mode, patch time functions on the module: + # - time.sleep: avoid waiting for polling loops (instant) + # - time.time: return fixed value for deterministic request bodies + # Must be done after exec_module so the module's 'time' reference can be patched. + if not is_live() and hasattr(self.module, "time"): + self.module.time.sleep = lambda _: None + self.module.time.time = lambda: PLAYBACK_TIMESTAMP + # Call main() if it exists (samples wrap their code in main()) + if hasattr(self.module, "main") and callable(self.module.main): + await self.module.main() # type: ignore[misc] + except Exception as e: + # Log print statements with exception details before re-raising + exception_info = traceback.format_exc() + log_file = self._write_error_log(reason=f"{type(e).__name__}: {str(e)}", exception_info=exception_info) + if log_file: + print(f"\nSample execution failed! Print statements logged to: {log_file}") + raise async def validate_print_calls_by_llm_async( self, @@ -425,7 +671,7 @@ async def validate_print_calls_by_llm_async( ) async with ( AsyncAIProjectClient( - endpoint=endpoint, credential=cast(AsyncTokenCredential, self.tokenCredential) + endpoint=endpoint, credential=cast(AsyncTokenCredential, self.tokenCredential), logging_enable=True ) as project_client, project_client.get_openai_client() as openai_client, ): diff --git a/sdk/ai/azure-ai-projects/tests/samples/test_samples.py b/sdk/ai/azure-ai-projects/tests/samples/test_samples.py index 999b884f865e..b6370b91ba8e 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/test_samples.py +++ b/sdk/ai/azure-ai-projects/tests/samples/test_samples.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -16,6 +15,9 @@ from test_samples_helpers import agent_tools_instructions, get_sample_environment_variables_map +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestSamples(AzureRecordedTestCase): # To run this test with a specific sample, use: @@ -24,8 +26,13 @@ class TestSamples(AzureRecordedTestCase): @additionalSampleTests( [ AdditionalSampleTestDetail( - sample_filename="sample_agent_computer_use.py", - env_vars={"COMPUTER_USE_MODEL_DEPLOYMENT_NAME": "sanitized_model"}, + test_id="sample_agent_azure_function", + sample_filename="sample_agent_azure_function.py", + env_vars={ + "STORAGE_INPUT_QUEUE_NAME": "sanitized_input_queue_name", + "STORAGE_OUTPUT_QUEUE_NAME": "sanitized_output_queue_name", + "STORAGE_QUEUE_SERVICE_ENDPOINT": "sanitized_queue_service_endpoint", + }, ), ] ) @@ -41,6 +48,10 @@ class TestSamples(AzureRecordedTestCase): "sample_agent_mcp_with_project_connection.py", "sample_agent_openapi_with_project_connection.py", "sample_agent_to_agent.py", + "sample_agent_web_search.py", + "sample_agent_web_search_preview.py", + "sample_agent_web_search_with_custom_search.py", + "sample_agent_azure_function.py", ], ), ) @@ -53,4 +64,5 @@ def test_agent_tools_samples(self, sample_path: str, **kwargs) -> None: executor.validate_print_calls_by_llm( instructions=agent_tools_instructions, project_endpoint=kwargs["azure_ai_project_endpoint"], + model=kwargs["azure_ai_model_deployment_name"], ) diff --git a/sdk/ai/azure-ai-projects/tests/samples/test_samples_async.py b/sdk/ai/azure-ai-projects/tests/samples/test_samples_async.py index d836afd2351e..69b5b2cbd45b 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/test_samples_async.py +++ b/sdk/ai/azure-ai-projects/tests/samples/test_samples_async.py @@ -15,6 +15,9 @@ from test_samples_helpers import agent_tools_instructions, get_sample_environment_variables_map +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestSamplesAsync(AzureRecordedTestCase): """Async test cases for samples.""" @@ -25,7 +28,7 @@ class TestSamplesAsync(AzureRecordedTestCase): "sample_path", get_async_sample_paths( "agents/tools", - samples_to_skip=["sample_agent_mcp_with_project_connection_async.py"], + samples_to_skip=[], ), ) @SamplePathPasser() @@ -42,4 +45,5 @@ async def test_agent_tools_samples_async(self, sample_path: str, **kwargs) -> No await executor.validate_print_calls_by_llm_async( instructions=agent_tools_instructions, project_endpoint=kwargs["azure_ai_project_endpoint"], + model=kwargs["azure_ai_model_deployment_name"], ) diff --git a/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py b/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py index d3370ffebb19..09dcdd61e73c 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py +++ b/sdk/ai/azure-ai-projects/tests/samples/test_samples_evaluations.py @@ -41,6 +41,9 @@ Always respond with `reason` indicating the reason for the response.""" +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestSamplesEvaluations(AzureRecordedTestCase): """ Tests for evaluation samples. diff --git a/sdk/ai/azure-ai-projects/tests/samples/test_samples_helpers.py b/sdk/ai/azure-ai-projects/tests/samples/test_samples_helpers.py index a6f246a08855..9d48b4e830ad 100644 --- a/sdk/ai/azure-ai-projects/tests/samples/test_samples_helpers.py +++ b/sdk/ai/azure-ai-projects/tests/samples/test_samples_helpers.py @@ -1,4 +1,3 @@ -# pylint: disable=line-too-long,useless-suppression # ------------------------------------ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. @@ -7,24 +6,31 @@ from typing import Optional, Mapping, Any -agent_tools_instructions = """We just run Python code and captured a Python array of print statements. -Validating the printed content to determine if correct or not: -Respond false if any entries show: -- Error messages or exception text -- Empty or null results where data is expected -- Malformed or corrupted data -- Timeout or connection errors -- Warning messages indicating failures -- Failure to retrieve or process data -- Statements saying documents/information didn't provide relevant data -- Statements saying unable to find/retrieve information -- Asking the user to specify, clarify, or provide more details -- Suggesting to use other tools or sources -- Asking follow-up questions to complete the task -- Indicating lack of knowledge or missing information -- Responses that defer answering or redirect the question -Respond with true only if the result provides a complete, substantive answer with actual data/information. -Always respond with `reason` indicating the reason for the response.""" +agent_tools_instructions = """We just ran Python code and captured a Python array of print statements. +Validate whether sample execution/output is correct for a tool-driven assistant workflow. + +Prefer matched/substantive data in the final output when available. + +Mark `correct = false` for: +- Exceptions, stack traces, explicit error/failure messages. +- Timeout/auth/connection/service errors that prevent normal completion. +- Malformed/corrupted output indicating broken processing. +- Tool invocation failures where the sample cannot proceed as designed. + +Follow-up questions are allowed, but only as supplementary behavior. +If the output mainly asks follow-up questions without providing matched/substantive data, mark false. + +Important false-alarm guard: +- If the run completed successfully (for example HTTP/tool calls succeeded and workflow finished cleanly) + but the tool returned empty/no-result output (for example `[]`) or the assistant reports no results from the tool, + this can still be a valid outcome. Do not fail solely for missing matched data in that case. + +Mark `correct = true` when execution succeeds and the output includes matched/substantive data, +even if it also asks follow-up questions. + +Also mark `correct = true` for successful no-result outcomes as described above. + +Always include `reason` with a concise explanation tied to the observed print output.""" def get_sample_environment_variables_map(env_kwargs: Mapping[str, Any]) -> dict[str, str]: diff --git a/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry.py b/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry.py index 9ade1692ae0a..6e74aafa4016 100644 --- a/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry.py +++ b/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry.py @@ -9,6 +9,9 @@ from devtools_testutils import recorded_by_proxy, is_live +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestTelemetry(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry_async.py b/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry_async.py index d0aee2d61e4b..1273bf410413 100644 --- a/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry_async.py +++ b/sdk/ai/azure-ai-projects/tests/telemetry/test_telemetry_async.py @@ -10,6 +10,9 @@ from devtools_testutils import is_live +@pytest.mark.skip( + reason="Skipped until re-enabled and recorded on Foundry endpoint that supports the new versioning schema" +) class TestTelemetryAsync(TestBase): # To run this test, use the following command in the \sdk\ai\azure-ai-projects folder: diff --git a/sdk/ai/azure-ai-projects/tests/test_base.py b/sdk/ai/azure-ai-projects/tests/test_base.py index b1b7e0e1d668..fe6b6fbcb0aa 100644 --- a/sdk/ai/azure-ai-projects/tests/test_base.py +++ b/sdk/ai/azure-ai-projects/tests/test_base.py @@ -25,7 +25,6 @@ Index, IndexType, InputContentType, - ItemResource, InputItemType, ModelDeployment, ) diff --git a/sdk/ai/azure-ai-projects/tsp-location.yaml b/sdk/ai/azure-ai-projects/tsp-location.yaml new file mode 100644 index 000000000000..ff33144b10ca --- /dev/null +++ b/sdk/ai/azure-ai-projects/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/ai-foundry/data-plane/Foundry +commit: 332d97dc13fe64b2e11b9a6f47f32d9f212b912b +repo: Azure/azure-rest-api-specs +additionalDirectories: