diff --git a/sdk/ai/ai-projects/CHANGELOG.md b/sdk/ai/ai-projects/CHANGELOG.md deleted file mode 100644 index 54aaa903dfdc..000000000000 --- a/sdk/ai/ai-projects/CHANGELOG.md +++ /dev/null @@ -1,51 +0,0 @@ -# Release History - -## 1.0.0-beta.5 (2025-04-18) - -### Features Added - -- Adding image input support with samples -- Adding list threads support and sample -- Adding sharepoint sample - -### Bugs Fixed - -- fixed an issue with tool_calls naming in convertOutputModelsFromWire - -### Other Changes - -- OpenAPI schema updates -- Using MODEL_DEPLOYMENT_NAME environment variable in samples - -## 1.0.0-beta.4 (2025-03-31) - -### Features Added - -- Adding Fabric support and sample. -- Adding token usage sample - -## 1.0.0-beta.3 (2025-03-21) - -### Features Added - -- Adding Azure Functions and OpenAPI tool support -- Upgrading core-lro package -- Adding Fabric support and sample. - -### Bugs Fixed - -- Addresses issue in search tool deserialization step during streaming. -- Addresses issue running samples - -## 1.0.0-beta.2 (2024-12-19) - -### Bugs Fixed - -- Address issue creating tool definition from connection. -- Improve Error handling api call failure. - -## 1.0.0-beta.1 (2024-12-19) - -### Features Added - -- This is the initial beta release for the Azure AI Projects SDK diff --git a/sdk/ai/ai-projects/LICENSE b/sdk/ai/ai-projects/LICENSE deleted file mode 100644 index b2f52a2bad4e..000000000000 --- a/sdk/ai/ai-projects/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) Microsoft Corporation. - -MIT License - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/sdk/ai/ai-projects/README.md b/sdk/ai/ai-projects/README.md deleted file mode 100644 index 81ba4100e421..000000000000 --- a/sdk/ai/ai-projects/README.md +++ /dev/null @@ -1,951 +0,0 @@ -# Azure AI Projects client library for JavaScript - -Use the AI Projects client library (in preview) to: - -- **Enumerate connections** in your Azure AI Foundry project and get connection properties. - For example, get the inference endpoint URL and credentials associated with your Azure OpenAI connection. -- **Develop Agents using the Azure AI Agent Service**, leveraging an extensive ecosystem of models, tools, and capabilities from OpenAI, Microsoft, and other LLM providers. The Azure AI Agent Service enables the building of Agents for a wide range of generative AI use cases. The package is currently in private preview. -- **Enable OpenTelemetry tracing**. - -[Product documentation](https://aka.ms/azsdk/azure-ai-projects/product-doc) - -| [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) -| [Package (npm)](https://www.npmjs.com/package/@azure/ai-projects) -| [API reference documentation](https://learn.microsoft.com/javascript/api/overview/azure/ai-projects-readme?view=azure-node-preview) - -## Table of contents - -- [Getting started](#getting-started) - - [Prerequisite](#prerequisite) - - [Install the package](#install-the-package) -- [Key concepts](#key-concepts) - - [Create and authenticate the client](#create-and-authenticate-the-client) -- [Examples](#examples) - - [Enumerate connections](#enumerate-connections) - - [Get properties of all connections](#get-properties-of-all-connections) - - [Get properties of all connections of a particular type](#get-properties-of-all-connections-of-a-particular-type) - - [Get properties of a default connection](#get-properties-of-a-default-connection) - - [Get properties of a connection by its connection name](#get-properties-of-a-connection-by-its-connection-name) - - [Agents (Preview)](#agents-private-preview) - - [Create an Agent](#create-agent) with: - - [File Search](#create-agent-with-file-search) - - [Code interpreter](#create-agent-with-code-interpreter) - - [Bing grounding](#create-agent-with-bing-grounding) - - [Azure AI Search](#create-agent-with-azure-ai-search) - - [Function call](#create-agent-with-function-call) - - [Fabric Data](#create-an-agent-with-fabric) - - [Create thread](#create-thread) with - - [Tool resource](#create-thread-with-tool-resource) - - [Create message](#create-message) with: - - [File search attachment](#create-message-with-file-search-attachment) - - [Code interpreter attachment](#create-message-with-code-interpreter-attachment) - - [Execute Run, Create Thread and Run, or Stream](#create-run-run_and_process-or-stream) - - [Retrieve message](#retrieve-message) - - [Retrieve file](#retrieve-file) - - [Tear down by deleting resource](#teardown) - - [Tracing](#tracing) - - [Tracing](#tracing) - - [Installation](#installation) - - [Tracing example](#tracing-example) -- [Troubleshooting](#troubleshooting) - - [Exceptions](#exceptions) - - [Reporting issues](#reporting-issues) - - [Next steps](#next-steps) -- [Contributing](#contributing) - -## Getting started - -### Prerequisite - -- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) -- An [Azure subscription][azure_sub]. -- A [project in Azure AI Foundry](https://learn.microsoft.com/azure/ai-studio/how-to/create-projects?tabs=ai-studio). -- The project connection string. It can be found in your Azure AI Foundry project overview page, under "Project details". Below we will assume the environment variable `AZURE_AI_PROJECTS_CONNECTION_STRING` was defined to hold this value. -- Entra ID is needed to authenticate the client. Your application needs an object that implements the [TokenCredential](https://learn.microsoft.com/javascript/api/@azure/core-auth/tokencredential) interface. Code samples here use [DefaultAzureCredential](https://learn.microsoft.com/javascript/api/@azure/identity/defaultazurecredential?view=azure-node-latest). To get that working, you will need: - - The `Contributor` role. Role assigned can be done via the "Access Control (IAM)" tab of your Azure AI Project resource in the Azure portal. - - [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli) installed. - - You are logged into your Azure account by running `az login`. - - Note that if you have multiple Azure subscriptions, the subscription that contains your Azure AI Project resource must be your default subscription. Run `az account list --output table` to list all your subscription and see which one is the default. Run `az account set --subscription "Your Subscription ID or Name"` to change your default subscription. - -### Install the package - -```bash -npm install @azure/ai-projects @azure/identity -``` - -## Key concepts - -### Create and authenticate the client - -The class factory method `fromConnectionString` is used to construct the client. To construct a client: - -```ts snippet:setup -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING ?? ""; -const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), -); -``` - -## Examples - -### Enumerate connections - -Your Azure AI Foundry project has a "Management center". When you enter it, you will see a tab named "Connected resources" under your project. The `.connections` operations on the client allow you to enumerate the connections and get connection properties. Connection properties include the resource URL and authentication credentials, among other things. - -Below are code examples of the connection operations. Full samples can be found under the "connections" folder in the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples). - -#### Get properties of all connections - -To list the properties of all the connections in the Azure AI Foundry project: - -```ts snippet:listConnections -const connections = await client.connections.listConnections(); -for (const connection of connections) { - console.log(connection); -} -``` - -#### Get properties of all connections of a particular type - -To list the properties of connections of a certain type (here Azure OpenAI): - -```ts snippet:filterConnections -const connections = await client.connections.listConnections({ category: "AzureOpenAI" }); -for (const connection of connections) { - console.log(connection); -} -``` - -#### Get properties of a connection by its connection name - -To get the connection properties of a connection named `connectionName`: - -```ts snippet:getConnection -const connection = await client.connections.getConnection("connectionName"); -console.log(connection); -``` - -To get the connection properties with its authentication credentials: - -```ts snippet:getConnectionWithSecrets -const connection = await client.connections.getConnectionWithSecrets("connectionName"); -console.log(connection); -``` - -### Agents (Preview) - -Agents in the Azure AI Projects client library are designed to facilitate various interactions and operations within your AI projects. They serve as the core components that manage and execute tasks, leveraging different tools and resources to achieve specific goals. The following steps outline the typical sequence for interacting with Agents. See the "agents" folder in the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) for additional Agent samples. - -Agents are actively being developed. A sign-up form for private preview is coming soon. - -#### Create Agent - -Here is an example of how to create an Agent: - -```ts snippet:createAgent -const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful assistant", -}); -``` - -To allow Agents to access your resources or custom functions, you need tools. You can pass tools to `createAgent` through the `tools` and `toolResources` arguments. - -You can use `ToolSet` to do this: - -```ts snippet:toolSet -import { ToolSet } from "@azure/ai-projects"; - -const toolSet = new ToolSet(); -toolSet.addFileSearchTool([vectorStore.id]); -toolSet.addCodeInterpreterTool([codeInterpreterFile.id]); -const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: toolSet.toolDefinitions, - toolResources: toolSet.toolResources, -}); -console.log(`Created agent, agent ID: ${agent.id}`); -``` - -#### Create Agent with File Search - -To perform file search by an Agent, we first need to upload a file, create a vector store, and associate the file to the vector store. Here is an example: - -```ts snippet:fileSearch -import { ToolUtility } from "@azure/ai-projects"; - -const localFileStream = fs.createReadStream(filePath); -const file = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "sample_file_for_upload.txt", -}); -console.log(`Uploaded file, ID: ${file.id}`); -const vectorStore = await client.agents.createVectorStore({ - fileIds: [file.id], - name: "my_vector_store", -}); -console.log(`Created vector store, ID: ${vectorStore.id}`); -const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]); -const agent = await client.agents.createAgent("gpt-4o", { - name: "SDK Test Agent - Retrieval", - instructions: "You are helpful agent that can help fetch data from files you know about.", - tools: [fileSearchTool.definition], - toolResources: fileSearchTool.resources, -}); -console.log(`Created agent, agent ID : ${agent.id}`); -``` - -#### Create Agent with Code Interpreter - -Here is an example to upload a file and use it for code interpreter by an Agent: - -```ts snippet:codeInterpreter -import { ToolUtility } from "@azure/ai-projects"; - -const localFileStream = fs.createReadStream(filePath); -const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "localFile", -}); -console.log(`Uploaded local file, file ID : ${localFile.id}`); -const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); -// Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment -const agent = await client.agents.createAgent("gpt-4o-mini", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, -}); -console.log(`Created agent, agent ID: ${agent.id}`); -``` - -#### Create Agent with Bing Grounding - -To enable your Agent to perform search through Bing search API, you use `ToolUtility.createConnectionTool()` along with a connection. - -Here is an example: - -```ts snippet:bingGrounding -import { ToolUtility, connectionToolType } from "@azure/ai-projects"; - -const bingConnection = await client.connections.getConnection( - process.env.BING_CONNECTION_NAME ?? "", -); -const connectionId = bingConnection.id; -const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [connectionId]); -const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], -}); -console.log(`Created agent, agent ID : ${agent.id}`); -``` - -#### Create Agent with Azure AI Search - -Azure AI Search is an enterprise search system for high-performance applications. It integrates with Azure OpenAI Service and Azure Machine Learning, offering advanced search technologies like vector search and full-text search. Ideal for knowledge base insights, information discovery, and automation - -Here is an example to integrate Azure AI Search: - -```ts snippet:AISearch -import { ToolUtility } from "@azure/ai-projects"; - -const connectionName = - process.env.AZURE_AI_SEARCH_CONNECTION_NAME ?? ""; -const connection = await client.connections.getConnection(connectionName); -const azureAISearchTool = ToolUtility.createAzureAISearchTool(connection.id, connection.name); -const agent = await client.agents.createAgent("gpt-4-0125-preview", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [azureAISearchTool.definition], - toolResources: azureAISearchTool.resources, -}); -console.log(`Created agent, agent ID : ${agent.id}`); -``` - -#### Create Agent with Function Call - -You can enhance your Agents by defining callback functions as function tools. These can be provided to `createAgent` via the combination of `tools` and `toolResources`. Only the function definitions and descriptions are provided to `createAgent`, without the implementations. The `Run` or `event handler of stream` will raise a `requires_action` status based on the function definitions. Your code must handle this status and call the appropriate functions. - -Here is an example: - -```ts snippet:functionTools -import { - FunctionToolDefinition, - ToolUtility, - RequiredToolCallOutput, - FunctionToolDefinitionOutput, - ToolOutput, -} from "@azure/ai-projects"; - -class FunctionToolExecutor { - private functionTools: { - func: Function; - definition: FunctionToolDefinition; - }[]; - constructor() { - this.functionTools = [ - { - func: this.getUserFavoriteCity, - ...ToolUtility.createFunctionTool({ - name: "getUserFavoriteCity", - description: "Gets the user's favorite city.", - parameters: {}, - }), - }, - { - func: this.getCityNickname, - ...ToolUtility.createFunctionTool({ - name: "getCityNickname", - description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - }, - }, - }), - }, - { - func: this.getWeather, - ...ToolUtility.createFunctionTool({ - name: "getWeather", - description: "Gets the weather for a location.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - unit: { type: "string", enum: ["c", "f"] }, - }, - }, - }), - }, - ]; - } - private getUserFavoriteCity(): {} { - return { location: "Seattle, WA" }; - } - private getCityNickname(location: string): {} { - return { nickname: "The Emerald City" }; - } - private getWeather(location: string, unit: string): {} { - return { weather: unit === "f" ? "72f" : "22c" }; - } - public invokeTool( - toolCall: RequiredToolCallOutput & FunctionToolDefinitionOutput, - ): ToolOutput | undefined { - console.log(`Function tool call - ${toolCall.function.name}`); - const args = []; - if (toolCall.function.parameters) { - try { - const params = JSON.parse(toolCall.function.parameters); - for (const key in params) { - if (Object.prototype.hasOwnProperty.call(params, key)) { - args.push(params[key]); - } - } - } catch (error) { - console.error(`Failed to parse parameters: ${toolCall.function.parameters}`, error); - return undefined; - } - } - const result = this.functionTools - .find((tool) => tool.definition.function.name === toolCall.function.name) - ?.func(...args); - return result - ? { - toolCallId: toolCall.id, - output: JSON.stringify(result), - } - : undefined; - } - public getFunctionDefinitions(): FunctionToolDefinition[] { - return this.functionTools.map((tool) => { - return tool.definition; - }); - } -} -const functionToolExecutor = new FunctionToolExecutor(); -const functionTools = functionToolExecutor.getFunctionDefinitions(); -const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: - "You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.", - tools: functionTools, -}); -console.log(`Created agent, agent ID: ${agent.id}`); -``` - -#### Create Agent With OpenAPI - -OpenAPI specifications describe REST operations against a specific endpoint. Agents SDK can read an OpenAPI spec, create a function from it, and call that function against the REST endpoint without additional client-side execution. -Here is an example creating an OpenAPI tool (using anonymous authentication): - -```ts snippet:createAgentWithOpenApi -import { ToolUtility } from "@azure/ai-projects"; - -// Read in OpenApi spec -const filePath = "./data/weatherOpenApi.json"; -const openApiSpec = JSON.parse(fs.readFileSync(filePath, "utf-8")); -// Define OpenApi function -const openApiFunction = { - name: "getWeather", - spec: openApiSpec, - description: "Retrieve weather information for a location", - auth: { - type: "anonymous", - }, - default_params: ["format"], // optional -}; -// Create OpenApi tool -const openApiTool = ToolUtility.createOpenApiTool(openApiFunction); -// Create agent with OpenApi tool -const agent = await client.agents.createAgent("gpt-4o-mini", { - name: "myAgent", - instructions: "You are a helpful agent", - tools: [openApiTool.definition], -}); -console.log(`Created agent, agent ID: ${agent.id}`); -``` - -#### Create an Agent with Fabric - -To enable your Agent to answer queries using Fabric data, use `FabricTool` along with a connection to the Fabric resource. - -Here is an example: - -```ts snippet:createAgentWithFabric -import { ToolUtility } from "@azure/ai-projects"; - -const fabricConnection = await client.connections.getConnection( - process.env["FABRIC_CONNECTION_NAME"] || "", -); -const connectionId = fabricConnection.id; -// Initialize agent Microsoft Fabric tool with the connection id -const fabricTool = ToolUtility.createFabricTool(connectionId); -// Create agent with the Microsoft Fabric tool and process assistant run -const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [fabricTool.definition], -}); -console.log(`Created agent, agent ID : ${agent.id}`); -``` - -#### Create Thread - -For each session or conversation, a thread is required. Here is an example: - -```ts snippet:createThread -const thread = await client.agents.createThread(); -``` - -#### Create Thread with Tool Resource - -In some scenarios, you might need to assign specific resources to individual threads. To achieve this, you provide the `toolResources` argument to `createThread`. In the following example, you create a vector store and upload a file, enable an Agent for file search using the `tools` argument, and then associate the file with the thread using the `toolResources` argument. - -```ts snippet:threadWithTool -import { ToolUtility } from "@azure/ai-projects"; - -const localFileStream = fs.createReadStream(filePath); -const file = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "sample_file_for_upload.csv", -}); -console.log(`Uploaded file, ID: ${file.id}`); -const vectorStore = await client.agents.createVectorStore({ - fileIds: [file.id], -}); -console.log(`Created vector store, ID: ${vectorStore.id}`); -const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]); -const agent = await client.agents.createAgent("gpt-4o", { - name: "myAgent", - instructions: "You are helpful agent that can help fetch data from files you know about.", - tools: [fileSearchTool.definition], -}); -console.log(`Created agent, agent ID : ${agent.id}`); -// Create thread with file resources. -// If the agent has multiple threads, only this thread can search this file. -const thread = await client.agents.createThread({ toolResources: fileSearchTool.resources }); -``` - -#### List Threads - -To list all threads attached to a given agent, use the list_threads API: - -```ts snippet:listThreads -const threads = await client.agents.listThreads(); -console.log(`Threads for agent ${agent.id}:`); -for await (const t of (await threads).data) { - console.log(`Thread ID: ${t.id}`); - console.log(`Created at: ${t.createdAt}`); - console.log(`Metadata: ${t.metadata}`); - console.log(`---- `); -} -``` - -#### Create Message - -To create a message for assistant to process, you pass `user` as `role` and a question as `content`: - -```ts snippet:createMessage -const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", -}); -console.log(`Created message, message ID: ${message.id}`); -``` - -#### Create Message with File Search Attachment - -To attach a file to a message for content searching, you use `ToolUtility.createFileSearchTool()` and the `attachments` argument: - -```ts snippet:messageWithFileSearch -import { ToolUtility } from "@azure/ai-projects"; - -const fileSearchTool = ToolUtility.createFileSearchTool(); -const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What feature does Smart Eyewear offer?", - attachments: { - fileId: file.id, - tools: [fileSearchTool.definition], - }, -}); -``` - -#### Create Message with Code Interpreter Attachment - -To attach a file to a message for data analysis, you use `ToolUtility.createCodeInterpreterTool()` and the `attachment` argument. - -Here is an example: - -```ts snippet:messageWithCodeInterpreter -import { ToolUtility } from "@azure/ai-projects"; - -// notice that CodeInterpreter must be enabled in the agent creation, -// otherwise the agent will not be able to see the file attachment for code interpretation -const codeInterpreterTool = ToolUtility.createCodeInterpreterTool(); -const agent = await client.agents.createAgent("gpt-4-1106-preview", { - name: "my-assistant", - instructions: "You are helpful assistant", - tools: [codeInterpreterTool.definition], -}); -console.log(`Created agent, agent ID: ${agent.id}`); -const thread = await client.agents.createThread(); -console.log(`Created thread, thread ID: ${thread.id}`); -const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?", - attachments: { - fileId: file.id, - tools: [codeInterpreterTool.definition], - }, -}); -console.log(`Created message, message ID: ${message.id}`); -``` - -#### Create Message with Image Inputs - -You can send messages to Azure agents with image inputs in following ways: - -- **Using an image stored as a uploaded file** -- **Using a public image accessible via URL** -- **Using a base64 encoded image string** - -The following examples demonstrate each method: - -##### Create message using uploaded image file - -```ts snippet:imageInputWithFile -// Upload the local image file -const fileStream = fs.createReadStream(imagePath); -const imageFile = await client.agents.uploadFile(fileStream, "assistants", { - fileName: "image_file.png", -}); -console.log(`Uploaded file, file ID: ${imageFile.id}`); -// Create a message with both text and image content -console.log("Creating message with image content..."); -const inputMessage = "Hello, what is in the image?"; -const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_file", - image_file: { - file_id: imageFile.id, - detail: "high", - }, - }, -]; -const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, -}); -console.log(`Created message, message ID: ${message.id}`); -``` - -##### Create message with an image URL input - -```ts snippet:imageInputWithUrl -// Specify the public image URL -const imageUrl = - "https://github.com/Azure/azure-sdk-for-js/blob/0aa88ceb18d865726d423f73b8393134e783aea6/sdk/ai/ai-projects/data/image_file.png?raw=true"; -// Create content directly referencing image URL -const inputMessage = "Hello, what is in the image?"; -const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageUrl, - detail: "high", - }, - }, -]; -const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, -}); -console.log(`Created message, message ID: ${message.id}`); -``` - -##### Create message with base64-encoded image input - -```ts snippet:imageInputWithBase64 -function imageToBase64DataUrl(imagePath: string, mimeType: string): string { - try { - // Read the image file as binary - const imageBuffer = fs.readFileSync(imagePath); - // Convert to base64 - const base64Data = imageBuffer.toString("base64"); - // Format as a data URL - return `data:${mimeType};base64,${base64Data}`; - } catch (error) { - console.error(`Error reading image file at ${imagePath}:`, error); - throw error; - } -} -// Convert your image file to base64 format -const imageDataUrl = imageToBase64DataUrl(filePath, "image/png"); -// Create a message with both text and image content -const inputMessage = "Hello, what is in the image?"; -const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageDataUrl, - detail: "high", - }, - }, -]; -const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, -}); -console.log(`Created message, message ID: ${message.id}`); -``` - -#### Create Run, Run_and_Process, or Stream - -Here is an example of `createRun` and poll until the run is completed: - -```ts snippet:createRun -let run = await client.agents.createRun(thread.id, agent.id); -// Poll the run as long as run status is queued or in progress -while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" -) { - // Wait for a second - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); -} -``` - -To have the SDK poll on your behalf, use the `createThreadAndRun` method. - -Here is an example: - -```ts snippet:createThreadAndRun -const run = await client.agents.createThreadAndRun(agent.id, { - thread: { - messages: [ - { - role: "user", - content: "hello, world!", - }, - ], - }, -}); -``` - -With streaming, polling also need not be considered. - -Here is an example: - -```ts snippet:createRunStream -const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); -``` - -Event handling can be done as follows: - -```ts snippet:eventHandling -import { - RunStreamEvent, - ThreadRunOutput, - MessageStreamEvent, - MessageDeltaChunk, - MessageDeltaTextContent, - DoneEvent, -} from "@azure/ai-projects"; - -const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); -for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } -} -``` - -#### Retrieve Message - -To retrieve messages from agents, use the following example: - -```ts snippet:listMessages -import { MessageContentOutput, isOutputOfType, MessageTextContentOutput } from "@azure/ai-projects"; - -const messages = await client.agents.listMessages(thread.id); -while (messages.hasMore) { - const nextMessages = await client.agents.listMessages(currentRun.threadId, { - after: messages.lastId, - }); - messages.data = messages.data.concat(nextMessages.data); - messages.hasMore = nextMessages.hasMore; - messages.lastId = nextMessages.lastId; -} -// The messages are following in the reverse order, -// we will iterate them and output only text contents. -for (const dataPoint of messages.data.reverse()) { - const lastMessageContent: MessageContentOutput = dataPoint.content[dataPoint.content.length - 1]; - console.log(lastMessageContent); - if (isOutputOfType(lastMessageContent, "text")) { - console.log( - `${dataPoint.role}: ${(lastMessageContent as MessageTextContentOutput).text.value}`, - ); - } -} -``` - -### Retrieve File - -Files uploaded by Agents cannot be retrieved back. If your use case needs to access the file content uploaded by the Agents, you are advised to keep an additional copy accessible by your application. However, files generated by Agents are retrievable by `getFileContent`. - -Here is an example retrieving file ids from messages: - -```ts snippet:retrieveFile -import { - isOutputOfType, - MessageTextContentOutput, - MessageImageFileContentOutput, -} from "@azure/ai-projects"; - -const messages = await client.agents.listMessages(thread.id); -// Get most recent message from the assistant -const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); -if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } -} -const imageFile = (messages.data[0].content[0] as MessageImageFileContentOutput).imageFile; -const imageFileName = (await client.agents.getFile(imageFile.fileId)).filename; -const fileContent = await ( - await client.agents.getFileContent(imageFile.fileId).asNodeStream() -).body; -if (fileContent) { - const chunks: Buffer[] = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); -} else { - console.error("Failed to retrieve file content: fileContent is undefined"); -} -console.log(`Saved image file to: ${imageFileName}`); -``` - -#### Teardown - -To remove resources after completing tasks, use the following functions: - -```ts snippet:teardown -await client.agents.deleteVectorStore(vectorStore.id); -console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -await client.agents.deleteFile(file.id); -console.log(`Deleted file, file ID: ${file.id}`); -client.agents.deleteAgent(agent.id); -console.log(`Deleted agent, agent ID: ${agent.id}`); -``` - -### Tracing - -You can add an Application Insights Azure resource to your Azure AI Foundry project. See the Tracing tab in your studio. If one was enabled, you can get the Application Insights connection string, configure your Agents, and observe the full execution path through Azure Monitor. Typically, you might want to start tracing before you create an Agent. - -#### Installation - -Make sure to install OpenTelemetry and the Azure SDK tracing plugin via - -```bash -npm install @opentelemetry/api \ - @opentelemetry/instrumentation \ - @opentelemetry/sdk-trace-node \ - @azure/opentelemetry-instrumentation-azure-sdk \ - @azure/monitor-opentelemetry-exporter -``` - -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). - -To connect to Aspire Dashboard or another OpenTelemetry compatible backend, install OTLP exporter: - -```bash -npm install @opentelemetry/exporter-trace-otlp-proto \ - @opentelemetry/exporter-metrics-otlp-proto -``` - -#### Tracing example - -Here is a code sample to be included above `createAgent`: - -```ts snippet:tracing -import { - NodeTracerProvider, - SimpleSpanProcessor, - ConsoleSpanExporter, -} from "@opentelemetry/sdk-trace-node"; -import { trace } from "@opentelemetry/api"; -import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter"; - -const provider = new NodeTracerProvider(); -provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); -provider.register(); -const tracer = trace.getTracer("Agents Sample", "1.0.0"); -let appInsightsConnectionString = - process.env.APP_INSIGHTS_CONNECTION_STRING ?? ""; -if (appInsightsConnectionString == "") { - appInsightsConnectionString = await client.telemetry.getConnectionString(); -} -if (appInsightsConnectionString) { - const exporter = new AzureMonitorTraceExporter({ - connectionString: appInsightsConnectionString, - }); - provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); -} -await tracer.startActiveSpan("main", async (span) => { - client.telemetry.updateSettings({ enableContentRecording: true }); - // ... -}); -``` - -## Troubleshooting - -### Exceptions - -Client methods that make service calls raise an [RestError](https://learn.microsoft.com/javascript/api/%40azure/core-rest-pipeline/resterror) for a non-success HTTP status code response from the service. The exception's `code` will hold the HTTP response status code. The exception's `error.message` contains a detailed message that may be helpful in diagnosing the issue: - -```ts snippet:exceptions -import { RestError } from "@azure/core-rest-pipeline"; - -try { - const result = await client.connections.listConnections(); -} catch (e) { - if (e instanceof RestError) { - console.log(`Status code: ${e.code}`); - console.log(e.message); - } else { - console.error(e); - } -} -``` - -For example, when you provide wrong credentials: - -```text -Status code: 401 (Unauthorized) -Operation returned an invalid status 'Unauthorized' -``` - -### Reporting issues - -To report issues with the client library, or request additional features, please open a GitHub issue [here](https://github.com/Azure/azure-sdk-for-js/issues) - -## Next steps - -Have a look at the [package samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/samples) folder, containing fully runnable code. - -## Contributing - -This project welcomes contributions and suggestions. Most contributions require -you to agree to a Contributor License Agreement (CLA) declaring that you have -the right to, and actually do, grant us the rights to use your contribution. -For details, visit https://cla.microsoft.com. - -When you submit a pull request, a CLA-bot will automatically determine whether -you need to provide a CLA and decorate the PR appropriately (e.g., label, -comment). Simply follow the instructions provided by the bot. You will only -need to do this once across all repos using our CLA. - -This project has adopted the -[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information, -see the Code of Conduct FAQ or contact opencode@microsoft.com with any -additional questions or comments. - - - -[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/ -[entra_id]: https://learn.microsoft.com/azure/ai-services/authentication?tabs=powershell#authenticate-with-microsoft-entra-id -[azure_identity_npm]: https://www.npmjs.com/package/@azure/identity -[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential -[azure_sub]: https://azure.microsoft.com/free/ -[evaluators]: https://learn.microsoft.com/azure/ai-studio/how-to/develop/evaluate-sdk -[evaluator_library]: https://learn.microsoft.com/azure/ai-studio/how-to/evaluate-generative-ai-app#view-and-manage-the-evaluators-in-the-evaluator-library diff --git a/sdk/ai/ai-projects/api-extractor.json b/sdk/ai/ai-projects/api-extractor.json deleted file mode 100644 index d61912ac5bee..000000000000 --- a/sdk/ai/ai-projects/api-extractor.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - "mainEntryPointFilePath": "./dist/esm/index.d.ts", - "docModel": { "enabled": true }, - "apiReport": { "enabled": true, "reportFolder": "./review" }, - "dtsRollup": { - "enabled": true, - "untrimmedFilePath": "", - "publicTrimmedFilePath": "./types/ai-projects.d.ts" - }, - "messages": { - "tsdocMessageReporting": { "default": { "logLevel": "none" } }, - "extractorMessageReporting": { - "ae-missing-release-tag": { "logLevel": "none" }, - "ae-unresolved-link": { "logLevel": "none" } - } - } -} diff --git a/sdk/ai/ai-projects/assets.json b/sdk/ai/ai-projects/assets.json deleted file mode 100644 index 0a421951c43a..000000000000 --- a/sdk/ai/ai-projects/assets.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "AssetsRepo": "Azure/azure-sdk-assets", - "AssetsRepoPrefixPath": "js", - "TagPrefix": "js/ai/ai-projects", - "Tag": "js/ai/ai-projects_7f86b6f75f" -} diff --git a/sdk/ai/ai-projects/data/image_file.png b/sdk/ai/ai-projects/data/image_file.png deleted file mode 100644 index 50ae6c65367a..000000000000 Binary files a/sdk/ai/ai-projects/data/image_file.png and /dev/null differ diff --git a/sdk/ai/ai-projects/data/localFile.txt b/sdk/ai/ai-projects/data/localFile.txt deleted file mode 100644 index 8ab686eafeb1..000000000000 --- a/sdk/ai/ai-projects/data/localFile.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, World! diff --git a/sdk/ai/ai-projects/data/nifty500QuarterlyResults.csv b/sdk/ai/ai-projects/data/nifty500QuarterlyResults.csv deleted file mode 100644 index e02068e09042..000000000000 --- a/sdk/ai/ai-projects/data/nifty500QuarterlyResults.csv +++ /dev/null @@ -1,502 +0,0 @@ -name,NSE_code,BSE_code,sector,industry,revenue,operating_expenses,operating_profit,operating_profit_margin,depreciation,interest,profit_before_tax,tax,net_profit,EPS,profit_TTM,EPS_TTM -3M India Ltd.,3MINDIA,523395,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"1,057",847.4,192.1,18.48%,12.9,0.7,195.9,49.8,146.1,129.7,535.9,475.7 -ACC Ltd.,ACC,500410,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"4,644.8","3,885.4",549.3,12.39%,212.8,28.9,517.7,131.5,387.9,20.7,"1,202.7",64 -AIA Engineering Ltd.,AIAENG,532683,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,"1,357.1",912.7,382.1,29.51%,24.5,7.4,412.5,88.4,323.1,34.3,"1,216.1",128.9 -APL Apollo Tubes Ltd.,APLAPOLLO,533758,METALS & MINING,IRON & STEEL PRODUCTS,"4,65","4,305.4",325,7.02%,41.3,26.6,276.7,73.8,202.9,7.3,767.5,27.7 -Au Small Finance Bank Ltd.,AUBANK,540611,BANKING AND FINANCE,BANKS,"2,956.5","1,026.7",647.7,25.59%,0,"1,282.1",533.4,131.5,401.8,6,"1,606.2",24 -Adani Ports & Special Economic Zone Ltd.,ADANIPORTS,532921,TRANSPORTATION,MARINE PORT & SERVICES,"6,951.9","2,982.4","3,664",55.13%,974.5,520.1,"2,474.9",759,"1,747.8",8.1,"6,337",29.3 -Adani Energy Solutions Ltd.,ADANIENSOL,ASM,UTILITIES,ELECTRIC UTILITIES,"3,766.5","2,169.3","1,504.6",40.95%,432.1,640.8,369.9,84.9,275.9,2.5,"1,315.1",11.8 -Aditya Birla Fashion and Retail Ltd.,ABFRL,535755,RETAILING,DEPARTMENT STORES,"3,272.2","2,903.6",322.9,10.01%,388.8,208.4,-228.6,-28.2,-179.2,-1.9,-491.7,-5.2 -Aegis Logistics Ltd.,AEGISCHEM,500003,OIL & GAS,OIL MARKETING & DISTRIBUTION,"1,279.3","1,026.5",208.3,16.87%,34.1,26.6,192,42,127,3.6,509,14.5 -Ajanta Pharma Ltd.,AJANTPHARM,532331,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,049.8",737.8,290.7,28.26%,33.7,2.3,275.9,80.6,195.3,15.5,660.2,52.3 -Alembic Pharmaceuticals Ltd.,APLLTD,533573,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,605.1","1,386.7",208.2,13.06%,67.6,15.7,135.1,-1.9,136.6,7,531.7,27 -Alkem Laboratories Ltd.,ALKEM,539523,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"3,503.4","2,693.4",746.7,21.71%,73.9,30.3,648,33.1,620.5,51.9,"1,432.9",119.9 -Amara Raja Energy & Mobility Ltd.,ARE&M,500008,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,988.6","2,556.9",402.5,13.60%,115.7,6.2,309.8,83.5,226.3,13.2,779.8,45.7 -Ambuja Cements Ltd.,AMBUJACEM,500425,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"7,9","6,122.1","1,301.8",17.54%,380.9,61.2,"1,335.7",352.5,793,4,"2,777.9",14 -Apollo Hospitals Enterprise Ltd.,APOLLOHOSP,508869,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"4,869.1","4,219.4",627.5,12.95%,163.4,111.3,376.9,130.2,232.9,16.2,697.5,48.5 -Apollo Tyres Ltd.,APOLLOTYRE,500877,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"6,304.9","5,119.8","1,159.8",18.47%,360.3,132.8,679.9,205.8,474.3,7.5,"1,590.7",25 -Ashok Leyland Ltd.,ASHOKLEY,500477,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"11,463","9,558.6","1,870.4",16.37%,226.6,715.1,924.4,358,526,1.8,"2,141.5",7.3 -Asian Paints Ltd.,ASIANPAINT,500820,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"8,643.8","6,762.3","1,716.2",20.24%,208.7,50.9,"1,621.8",418.6,"1,205.4",12.6,"5,062.6",52.8 -Astral Ltd.,ASTRAL,532830,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,"1,376.4","1,142.9",220.1,16.15%,48.7,8,176.8,45.1,131.2,4.9,549.7,20.4 -Atul Ltd.,ATUL,500027,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,215.8","1,038.5",155.2,13.00%,54,1.9,121.5,32.5,90.3,30.6,392.3,132.9 -Aurobindo Pharma Ltd.,AUROPHARMA,524804,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"7,406.4","5,846","1,373.4",19.02%,417.5,68.2,"1,074.7",323.7,757.2,12.8,"2,325.5",39.7 -Avanti Feeds Ltd.,AVANTIFEED,512573,FOOD BEVERAGES & TOBACCO,OTHER FOOD PRODUCTS,"1,312","1,184.5",94,7.35%,14.3,0.2,113,30.5,74.2,5.5,336.4,24.7 -Avenue Supermarts Ltd.,DMART,540376,RETAILING,DEPARTMENT STORES,"12,661.3","11,619.4","1,005",7.96%,174.4,15.6,851.9,228.6,623.6,9.6,"2,332.1",35.8 -Axis Bank Ltd.,AXISBANK,532215,BANKING AND FINANCE,BANKS,"33,122.2","9,207.3","9,166",33.43%,0,"14,749","8,313.8","2,096.1","6,204.1",20.1,"13,121",42.6 -Bajaj Auto Ltd.,BAJAJ-AUTO,532977,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"11,206.8","8,708.1","2,130.1",19.65%,91.8,6.5,"2,400.4",564,"2,02",71.4,"6,841.6",241.8 -Bajaj Finance Ltd.,BAJFINANCE,500034,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"13,381.8","2,851.5","9,449.7",70.63%,158.5,"4,537.1","4,757.6","1,207","3,550.8",58.7,"13,118.5",216.7 -Bajaj Finserv Ltd.,BAJAJFINSV,532978,DIVERSIFIED,HOLDING COMPANIES,"26,022.7","14,992.2","9,949.9",38.24%,208.8,"4,449.1","5,292","1,536.5","1,929",12.1,"7,422.6",46.6 -Bajaj Holdings & Investment Ltd.,BAJAJHLDNG,500490,DIVERSIFIED,HOLDING COMPANIES,240.1,33.5,191.2,85.08%,8.4,0.2,197.9,73.9,"1,491.2",134,"5,545.1",498.3 -Balkrishna Industries Ltd.,BALKRISIND,502355,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"2,360.3","1,720.5",532.7,23.64%,160.4,23.9,455.5,108.1,347.4,18,"1,047.5",54.2 -Balrampur Chini Mills Ltd.,BALRAMCHIN,500038,FOOD BEVERAGES & TOBACCO,SUGAR,"1,649","1,374.6",164.9,10.71%,41.2,17.2,215.9,56.6,166.3,8.2,540.5,26.8 -Bank of Baroda,BANKBARODA,532134,BANKING AND FINANCE,BANKS,"35,766","8,430.4","9,807.9",33.52%,0,"17,527.7","6,022.8","1,679.7","4,458.4",8.5,"18,602.9",35.9 -Bank of India,BANKINDIA,532149,BANKING AND FINANCE,BANKS,"16,779.4","3,704.9","3,818.8",25.35%,0,"9,255.7","2,977.4","1,488.6","1,498.5",3.6,"5,388.7",13.1 -Bata India Ltd.,BATAINDIA,500043,RETAILING,FOOTWEAR,834.6,637.5,181.7,22.18%,81.7,28.4,46.1,12.1,34,2.6,289.7,22.5 -Berger Paints (India) Ltd.,BERGEPAINT,509480,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"2,782.6","2,293.7",473.6,17.12%,82.9,21.1,385,96.7,291.6,2.5,"1,032.6",8.9 -Bharat Electronics Ltd.,BEL,500049,GENERAL INDUSTRIALS,DEFENCE,"4,146.1","2,994.9","1,014.2",25.30%,108.3,1.5,"1,041.5",260.7,789.4,1.1,"3,323",4.5 -Bharat Forge Ltd.,BHARATFORG,500493,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"3,826.7","3,152.8",621.4,16.47%,211.3,124.3,336.1,121.8,227.2,4.9,783.7,16.8 -Bharat Heavy Electricals Ltd.,BHEL,500103,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"5,305.4","5,513",-387.7,-7.56%,59.9,180.4,-447.9,-197.9,-238.1,-0.7,71.3,0.2 -Bharat Petroleum Corporation Ltd.,BPCL,500547,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"103,72","90,103.9","12,940.5",12.56%,"1,605.3",973.2,"10,755.7","2,812.2","8,243.5",38.7,"27,505.3",129.2 -Bharti Airtel Ltd.,BHARTIARTL,532454,TELECOM SERVICES,TELECOM SERVICES,"37,374.2","17,530.1","19,513.7",52.68%,"9,734.3","5,185.8","3,353.7","1,846.5","1,340.7",2.4,"7,547",13.2 -Indus Towers Ltd.,INDUSTOWER,534816,TELECOM SERVICES,OTHER TELECOM SERVICES,"7,229.7","3,498.8","3,633.7",50.95%,"1,525.6",458.6,"1,746.7",452,"1,294.7",4.8,"3,333.5",12.4 -Biocon Ltd.,BIOCON,532523,PHARMACEUTICALS & BIOTECHNOLOGY,BIOTECHNOLOGY,"3,620.2","2,720.7",741.6,21.42%,389.3,247.7,238.5,41.6,125.6,1.1,498.4,4.2 -Birla Corporation Ltd.,BIRLACORPN,500335,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,313.2","1,997",288.9,12.64%,143.5,95.4,77.1,18.8,58.4,7.6,153.1,19.9 -Blue Dart Express Ltd.,BLUEDART,526612,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"1,329.7","1,101.8",222.7,16.82%,110.6,19.5,97.9,24.8,73.1,30.8,292.4,123.2 -Blue Star Ltd.,BLUESTARCO,500067,CONSUMER DURABLES,CONSUMER ELECTRONICS,"1,903.4","1,767.7",122.7,6.49%,23,17.6,95,24.3,70.7,3.6,437.7,21.3 -Bombay Burmah Trading Corporation Ltd.,BBTC,501425,FOOD BEVERAGES & TOBACCO,TEA & COFFEE,"4,643.5","3,664.7",859.2,18.99%,74.7,154.6,697.1,212.6,122,17.5,"-1,499.5",-214.8 -Bosch Ltd.,BOSCHLTD,500530,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"4,284.3","3,638.8",491.3,11.90%,101.3,12.2,"1,317",318.1,999.8,339,"2,126.9",721 -Brigade Enterprises Ltd.,BRIGADE,532929,REALTY,REALTY,"1,407.9","1,041.8",324.8,23.77%,75.7,110,180.3,67.8,133.5,5.8,298.2,12.9 -Britannia Industries Ltd.,BRITANNIA,500825,FMCG,PACKAGED FOODS,"4,485.2","3,560.5",872.4,19.68%,71.7,53.4,799.7,212.1,587.6,24.4,"2,536.2",105.3 -CCL Products India Ltd.,CCL,519600,FOOD BEVERAGES & TOBACCO,TEA & COFFEE,608.3,497.7,109.9,18.09%,22.6,18.4,69.7,8.8,60.9,4.6,279.9,21 -Crisil Ltd.,CRISIL,500092,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,771.8,544.2,191.7,26.05%,26.5,0.8,200.3,48.3,152,20.8,606.3,82.9 -Zydus Lifesciences Ltd.,ZYDUSLIFE,532321,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"4,422.8","3,222.7","1,146.1",26.23%,184.2,8.7,"1,007.2",226.4,800.7,7.9,"2,807.1",27.7 -Can Fin Homes Ltd.,CANFINHOME,511196,BANKING AND FINANCE,HOUSING FINANCE,871,49.7,749.2,86.01%,2.8,548.4,198,39.9,158.1,11.9,658.8,49.5 -Canara Bank,CANBK,532483,BANKING AND FINANCE,BANKS,"33,891.2","8,250.3","7,706.6",28.24%,0,"17,934.3","5,098","1,420.6","3,86",20.9,"13,968.4",77 -Carborundum Universal Ltd.,CARBORUNIV,513375,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"1,166",978.8,167.5,14.61%,45.9,4.9,136.4,43.7,101.9,5.4,461.3,24.3 -Castrol India Ltd.,CASTROLIND,500870,OIL & GAS,OIL MARKETING & DISTRIBUTION,"1,203.2",914.4,268.6,22.70%,22.9,2.4,263.5,69.1,194.4,2,815.5,8.2 -Ceat Ltd.,CEATLTD,500878,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"3,063.8","2,597.2",456.1,14.94%,124.5,71.7,270.4,68.3,208,51.4,521.7,129 -Central Bank of India,CENTRALBK,532885,BANKING AND FINANCE,BANKS,"8,438.5","2,565.4","1,535.4",20.81%,0,"4,337.7",567.2,-41.5,622,0.7,"2,181.4",2.5 -Century Plyboards (India) Ltd.,CENTURYPLY,532548,FOREST MATERIALS,FOREST PRODUCTS,"1,011.4",852.5,144.3,14.47%,23.4,6.1,129.4,32.2,96.9,4.4,380.7,17.1 -Cera Sanitaryware Ltd.,CERA,532443,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,476.2,387.2,76.5,16.49%,8.9,1.4,77.2,19.8,56.9,43.8,232.4,178.7 -Chambal Fertilisers & Chemicals Ltd.,CHAMBLFERT,500085,FERTILIZERS,FERTILIZERS,"5,467.3","4,770.5",615,11.42%,78.4,45.8,572.6,200.2,381,9.2,"1,137.7",27.3 -Cholamandalam Investment & Finance Company Ltd.,CHOLAFIN,511243,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"4,695.2",987.6,"3,235.1",69.99%,38.5,"2,204.2","1,065",288.8,772.9,9.4,"3,022.8",36.7 -Cipla Ltd.,CIPLA,500087,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"6,854.5","4,944.4","1,733.8",25.96%,290,25.8,"1,594.2",438.4,"1,130.9",14,"3,449.1",42.7 -City Union Bank Ltd.,CUB,532210,BANKING AND FINANCE,BANKS,"1,486.1",333.9,386.6,29.65%,0,765.6,330.6,50,280.6,3.8,943.8,12.7 -Coal India Ltd.,COALINDIA,533278,METALS & MINING,COAL,"34,760.3","24,639.4","8,137",24.83%,"1,178.2",182.5,"8,760.2","2,036.5","6,799.8",11,"28,059.6",45.5 -Colgate-Palmolive (India) Ltd.,COLPAL,500830,FMCG,PERSONAL PRODUCTS,"1,492.1",989,482.1,32.77%,44.3,1.1,457.8,117.8,340.1,12.5,"1,173.2",43.1 -Container Corporation of India Ltd.,CONCOR,531344,COMMERCIAL SERVICES & SUPPLIES,WAREHOUSING AND LOGISTICS,"2,299.8","1,648.4",546.5,24.90%,153.1,16.5,481.8,119,367.4,6,"1,186.2",19.5 -Coromandel International Ltd.,COROMANDEL,506395,FERTILIZERS,FERTILIZERS,"7,032.9","5,929.4","1,058.7",15.15%,54,46.2,"1,003.3",245,756.9,25.7,"2,024.2",68.8 -Crompton Greaves Consumer Electricals Ltd.,CROMPTON,539876,CONSUMER DURABLES,HOUSEHOLD APPLIANCES,"1,797.2","1,607.8",174.5,9.79%,32.1,21.5,135.8,34.9,97.2,1.5,432,6.7 -Cummins India Ltd.,CUMMINSIND,500480,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"2,011.3","1,575.4",346.2,18.02%,38.3,6.8,390.9,99.6,329.1,11.9,"1,445.5",52.1 -Cyient Ltd.,CYIENT,532175,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,792","1,452.7",325.8,18.32%,65.8,27,240.3,56.7,178.3,16.3,665.6,60.1 -DCM Shriram Ltd.,DCMSHRIRAM,523367,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"2,73","2,593.9",114.1,4.21%,74,14.7,47.5,15.2,32.2,2.1,617.6,39.4 -DLF Ltd.,DLF,532868,REALTY,REALTY,"1,476.4",885.3,462.4,34.31%,37,90.2,464,112.2,622.8,2.5,"2,239",9 -Dabur India Ltd.,DABUR,500096,FMCG,PERSONAL PRODUCTS,"3,320.2","2,543",660.9,20.63%,98.3,28.1,650.8,144.3,515,2.9,"1,755.7",9.9 -Delta Corp Ltd.,DELTACORP,532848,COMMERCIAL SERVICES & SUPPLIES,MISC. COMMERCIAL SERVICES,282.6,170.5,100.1,36.99%,16.9,2.7,92.4,23,69.4,2.6,273.3,10.2 -Divi's Laboratories Ltd.,DIVISLAB,532488,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,995","1,43",479,25.09%,95,1,469,121,348,13.1,"1,331.8",50.3 -Dr. Lal Pathlabs Ltd.,LALPATHLAB,539524,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,619.4,423.5,177.8,29.57%,35.9,7.8,152.2,41.5,109.3,13.2,301.4,36.1 -Dr. Reddy's Laboratories Ltd.,DRREDDY,500124,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"7,217.6","4,888.8","2,008.3",29.09%,375.5,35.3,"1,912.5",434.5,"1,482.2",89.1,"5,091.2",305.2 -EID Parry (India) Ltd.,EIDPARRY,500125,FOOD BEVERAGES & TOBACCO,OTHER FOOD PRODUCTS,"9,210.3","8,002","1,057.5",11.67%,101.2,74.2,"1,032.8",246.8,452.3,25.5,991,55.8 -Eicher Motors Ltd.,EICHERMOT,505200,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"4,388.3","3,027.4","1,087.2",26.42%,142.5,12.7,"1,205.7",291.1,"1,016.2",37.1,"3,581",130.8 -Emami Ltd.,EMAMILTD,531162,FMCG,PERSONAL PRODUCTS,876,631.2,233.7,27.02%,46.1,2.2,196.4,15.8,178.5,4.1,697.8,16 -Endurance Technologies Ltd.,ENDURANCE,540153,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,560.5","2,226.7",318.3,12.51%,118.4,9.8,205.6,51.1,154.6,11,562.8,40 -Engineers India Ltd.,ENGINERSIN,532178,COMMERCIAL SERVICES & SUPPLIES,CONSULTING SERVICES,833.6,691.3,98.5,12.47%,8.3,0.4,133.6,32.2,127.5,2.3,472.7,8.4 -Escorts Kubota Ltd.,ESCORTS,500495,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"2,154.4","1,798.6",260.7,12.66%,40.8,3.1,311.9,79.7,223.3,20.6,910.5,82.4 -Exide Industries Ltd.,EXIDEIND,500086,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"4,408.9","3,872.4",499.1,11.42%,141.5,29.7,365.3,95.2,269.4,3.2,872.7,10.3 -Federal Bank Ltd.,FEDERALBNK,500469,BANKING AND FINANCE,BANKS,"6,548.2","1,603.8","1,400.3",24.18%,0,"3,544.1","1,342.7",342.6,994.1,4.3,"3,671.4",15.6 -Finolex Cables Ltd.,FINCABLES,500144,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,229.3","1,041.3",146.1,12.30%,10.8,0.4,176.7,52.3,154.2,10.1,643.9,42.1 -Finolex Industries Ltd.,FINPIPE,500940,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,944.5,780.2,103,11.66%,27.4,12.5,124.5,35.4,98,1.6,459.3,7.4 -Firstsource Solutions Ltd.,FSL,532809,SOFTWARE & SERVICES,BPO/KPO,"1,556.9","1,311.2",228.8,14.86%,65.4,26.1,154.3,27.8,126.5,1.9,551.7,7.9 -GAIL (India) Ltd.,GAIL,532155,UTILITIES,UTILITIES,"33,191","29,405.5","3,580.2",10.85%,837.3,199.6,"2,748.7",696.3,"2,444.1",3.7,"5,283.8",8 -GlaxoSmithKline Pharmaceuticals Ltd.,GLAXO,500660,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,985.2,667.5,289.5,30.25%,18.1,0.4,299.2,81.7,217.5,12.8,647.8,38.2 -Glenmark Pharmaceuticals Ltd.,GLENMARK,532296,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"3,209.1","2,745.1",462.3,14.41%,141.5,121.5,-124.4,55.9,-81.9,-2.9,-196.3,-7 -Godrej Consumer Products Ltd.,GODREJCP,532424,FMCG,PERSONAL PRODUCTS,"3,667.9","2,897.8",704.2,19.55%,60.9,77.3,619.4,186.6,432.8,4.2,"1,750.1",17.1 -Godrej Industries Ltd.,GODREJIND,500164,DIVERSIFIED,DIVERSIFIED,"4,256.9","3,672.1",265.5,6.74%,89.3,333.1,162.4,75.9,87.3,2.6,880,26.1 -Godrej Properties Ltd.,GODREJPROP,533150,REALTY,REALTY,605.1,404.7,-61.7,-17.98%,7.4,48,145.1,38.8,66.8,2.4,662.6,23.8 -Granules India Ltd.,GRANULES,532482,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,191",976.5,213,17.90%,52.5,26,136,33.9,102.1,4.2,393.9,16.3 -Great Eastern Shipping Company Ltd.,GESHIP,500620,TRANSPORTATION,SHIPPING,"1,461.5",585.6,643.4,52.35%,186.7,77.1,611.9,17.3,594.7,41.6,"2,520.1",176.5 -Gujarat Alkalies & Chemicals Ltd.,GUJALKALI,530001,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"1,042.3",926.1,45.2,4.65%,95.2,10.8,10.2,-0.1,-18.4,-2.5,82.7,11.3 -Gujarat Gas Ltd.,GUJGASLTD,539336,UTILITIES,UTILITIES,"4,019.3","3,494.5",496.6,12.44%,117.9,7.8,399.1,102.9,296.2,4.3,"1,254.3",18.2 -Gujarat Narmada Valley Fertilizers & Chemicals Ltd.,GNFC,500670,FERTILIZERS,FERTILIZERS,"2,232","1,911",169,8.12%,78,1,242,64,182,11.7,932,60.1 -Gujarat Pipavav Port Ltd.,GPPL,533248,TRANSPORTATION,MARINE PORT & SERVICES,270.4,102,150.6,59.64%,28.8,2.2,141.1,53.4,92.3,1.9,341.8,7.1 -Gujarat State Fertilizer & Chemicals Ltd.,GSFC,500690,FERTILIZERS,FERTILIZERS,"3,313.2","2,881.4",237.3,7.61%,45.7,1.6,387,78.1,308.9,7.8,"1,056.2",26.5 -Gujarat State Petronet Ltd.,GSPL,532702,UTILITIES,UTILITIES,"4,455.9","3,497.2",913.7,20.72%,165,14.5,779.2,198.7,454.6,8.1,"1,522",27 -HCL Technologies Ltd.,HCLTECH,532281,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"27,037","20,743","5,929",22.23%,"1,01",156,"5,128","1,295","3,832",14.2,"15,445",56.9 -HDFC Bank Ltd.,HDFCBANK,500180,BANKING AND FINANCE,BANKS,"107,566.6","42,037.6","24,279.1",32.36%,0,"41,249.9","20,967.4","3,655","16,811.4",22.2,"54,474.6",71.8 -Havells India Ltd.,HAVELLS,517354,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"3,952.8","3,527",373.4,9.57%,81.2,9.3,335.3,86.2,249.1,4,"1,177.7",18.8 -Hero MotoCorp Ltd.,HEROMOTOCO,500182,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"9,741.2","8,173.5","1,359.5",14.26%,187.1,25,"1,355.6",353.1,"1,006.3",50.3,"3,247.6",162.5 -HFCL Ltd.,HFCL,500183,TELECOMMUNICATIONS EQUIPMENT,TELECOM CABLES,"1,128.7",978.9,132.6,11.93%,21.4,34.8,93.5,24,69.4,0.5,305.5,2.1 -Hindalco Industries Ltd.,HINDALCO,500440,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"54,632","48,557","5,612",10.36%,"1,843","1,034","3,231","1,035","2,196",9.9,"8,423",37.9 -Hindustan Copper Ltd.,HINDCOPPER,513599,METALS & MINING,COPPER,392.6,260.2,121.2,31.77%,45.6,4.1,82.6,21.9,60.7,0.6,320.5,3.3 -Hindustan Petroleum Corporation Ltd.,HINDPETRO,500104,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"96,093.4","87,512","8,24",8.61%,"1,247.3",590,"6,744.1","1,616","5,827",41.1,"16,645",117.3 -Hindustan Unilever Ltd.,HINDUNILVR,500696,FMCG,PERSONAL PRODUCTS,"15,806","11,826","3,797",24.30%,297,88,"3,59",931,"2,656",11.3,"10,284",43.8 -Hindustan Zinc Ltd.,HINDZINC,500188,METALS & MINING,ZINC,"7,014","3,652","3,139",46.22%,825,232,"2,305",576,"1,729",4.1,"8,432",20 -Housing and Urban Development Corporation Ltd.,HUDCO,540530,BANKING AND FINANCE,HOUSING FINANCE,"1,880.8",82.7,"1,809.6",97.04%,2.4,"1,216.8",606.4,154.7,451.6,2.3,"1,790.7",8.9 -ITC Ltd.,ITC,500875,FOOD BEVERAGES & TOBACCO,CIGARETTES-TOBACCO PRODUCTS,"18,439.3","11,320.2","6,454.2",36.31%,453,9.9,"6,656.2","1,700.3","4,898.1",3.9,"20,185.1",16.2 -ICICI Bank Ltd.,ICICIBANK,532174,BANKING AND FINANCE,BANKS,"57,292.3","23,911","15,473.2",39.74%,0,"17,908","14,824.2","3,808.8","11,805.6",15.6,"41,086.8",58.7 -ICICI Prudential Life Insurance Company Ltd.,ICICIPRULI,540133,BANKING AND FINANCE,LIFE INSURANCE,"17,958.1","17,612.3",-229.6,-1.32%,0,0,340.2,32.5,243.9,1.7,906.9,6.3 -IDBI Bank Ltd.,IDBI,500116,BANKING AND FINANCE,BANKS,"7,063.7","1,922.3","2,175.3",36.02%,0,"2,966.1","2,396.9","1,003.7","1,385.4",1.3,"4,776.3",4.4 -IDFC First Bank Ltd.,IDFCFIRSTB,539437,BANKING AND FINANCE,BANKS,"8,765.8","3,849","1,511.2",20.54%,0,"3,405.6",982.8,236,746.9,1.1,"2,911.1",4.3 -IDFC Ltd.,IDFC,532659,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),36.7,6,30.6,83.56%,0,0,30.6,6.6,223.5,1.4,"4,147.1",25.9 -IRB Infrastructure Developers Ltd.,IRB,532947,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,874.5",950.4,794.6,45.54%,232.7,434.6,256.9,85.8,95.7,0.2,501,0.8 -ITI Ltd.,ITI,523610,TELECOMMUNICATIONS EQUIPMENT,TELECOM EQUIPMENT,256.1,299.3,-52.8,-21.42%,13.3,69.3,-125.8,0,-126,-1.3,-388.4,-4 -Vodafone Idea Ltd.,IDEA,532822,TELECOM SERVICES,TELECOM SERVICES,"10,750.8","6,433.5","4,282.8",39.97%,"5,667.3","6,569","-7,919",817.7,"-8,737.9",-1.8,"-30,986.8",-6.4 -India Cements Ltd.,INDIACEM,530005,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,272.4","1,26",4.4,0.35%,55,60.4,-103,-17.4,-80.1,-2.6,-261.1,-8.4 -Indiabulls Housing Finance Ltd.,IBULHSGFIN,535789,BANKING AND FINANCE,HOUSING FINANCE,"2,242.3",190.6,"1,779.2",79.88%,22.9,"1,349.8",421.6,123.6,298,6.5,"1,146",24.3 -Indian Bank,INDIANB,532814,BANKING AND FINANCE,BANKS,"15,929.4","3,599.1","4,327.7",31.44%,0,"8,002.6","2,776.7",768.6,"2,068.5",16.6,"6,893.3",55.3 -Indian Hotels Company Ltd.,INDHOTEL,500850,HOTELS RESTAURANTS & TOURISM,HOTELS,"1,480.9","1,078.4",354.8,24.75%,111.2,59,232.2,72.3,166.9,1.2,"1,100.3",7.7 -Indian Oil Corporation Ltd.,IOC,530965,OIL & GAS,OIL MARKETING & DISTRIBUTION,"179,752.1","156,013.1","23,328.4",13.01%,"3,609.6","2,135","18,090.2","4,699.7","13,114.3",9.5,"38,614.3",27.3 -Indian Overseas Bank,IOB,532388,BANKING AND FINANCE,BANKS,"6,941.5","1,785.1","1,679.8",28.84%,0,"3,476.6",635.5,8.3,627.2,0.3,"2,341.9",1.2 -Indraprastha Gas Ltd.,IGL,532514,UTILITIES,UTILITIES,"3,520.2","2,801.6",656.9,18.99%,102.2,2.5,613.9,151.4,552.7,7.9,"1,806.2",25.8 -IndusInd Bank Ltd.,INDUSINDBK,532187,BANKING AND FINANCE,BANKS,"13,529.7","3,449.9","3,908.7",34.75%,0,"6,171.1","2,934.9",732.9,"2,202.2",28.4,"8,333.7",107.2 -Info Edge (India) Ltd.,NAUKRI,532777,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,792,421.2,204.7,32.70%,25.9,8.2,382.8,68.7,205.1,15.9,-25.6,-2 -InterGlobe Aviation Ltd.,INDIGO,539448,TRANSPORTATION,AIRLINES,"15,502.9","12,743.6","2,200.3",14.72%,"1,549","1,021.3",189.1,0.2,188.9,4.9,"5,621.3",145.7 -Ipca Laboratories Ltd.,IPCALAB,524494,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,072.5","1,712.7",321.3,15.80%,90.3,44.1,225.4,87.9,145.1,5.7,492.2,19.4 -J B Chemicals & Pharmaceuticals Ltd.,JBCHEPHARM,506943,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,889.4,638.2,243.5,27.62%,32.2,10.4,208.7,58.1,150.6,9.7,486.6,31.4 -JK Cement Ltd.,JKCEMENT,532644,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,782.1","2,285.8",467,16.96%,137.1,115,244.2,65.7,178.1,23.1,444,57.5 -JK Lakshmi Cement Ltd.,JKLAKSHMI,500380,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,588.5","1,357.3",217.3,13.80%,56.6,33.6,141,45.1,92.7,7.9,357.6,30.4 -JM Financial Ltd.,JMFINANCIL,523405,DIVERSIFIED,HOLDING COMPANIES,"1,214",407.9,662.6,55.34%,13.2,388.1,277.9,72.4,194.9,2,608.1,6.4 -JSW Energy Ltd.,JSWENERGY,533148,UTILITIES,ELECTRIC UTILITIES,"3,387.4","1,379","1,880.4",57.69%,408.7,513.7,"1,085.9",235.1,850.2,5.2,"1,591.7",9.7 -JSW Steel Ltd.,JSWSTEEL,500228,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"44,821","36,698","7,886",17.69%,"2,019","2,084","4,609","1,812","2,76",11.4,"9,252",38.1 -Jindal Stainless Ltd.,JSL,532508,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"9,829","8,566.5","1,230.6",12.56%,221.9,155.6,985.7,229.1,774.3,9.4,"2,600.2",31.6 -Jindal Steel & Power Ltd.,JINDALSTEL,532286,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"12,282","9,964.5","2,285.7",18.66%,603.7,329.4,"1,384.5",-5.8,"1,387.8",13.8,"4,056",40.4 -Jubilant Foodworks Ltd.,JUBLFOOD,533155,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,"1,375.7","1,091.4",277.2,20.25%,141.9,56.8,85.5,23.3,97.2,1.5,235,3.6 -Just Dial Ltd.,JUSTDIAL,535648,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,318.5,211.8,48.8,18.71%,12.2,2.4,92.1,20.3,71.8,8.4,314.1,36.9 -Jyothy Labs Ltd.,JYOTHYLAB,532926,FMCG,PERSONAL PRODUCTS,745.6,597,135.4,18.48%,12.3,1.2,135.1,31.1,104.2,2.8,326.9,8.9 -KRBL Ltd.,KRBL,530813,FMCG,PACKAGED FOODS,"1,246.5","1,018.9",194.5,16.03%,19.9,0.8,206.8,53.6,153.3,6.5,671.4,29.3 -Kajaria Ceramics Ltd.,KAJARIACER,500233,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"1,129.9",941.9,179.7,16.02%,36.1,4.3,147.7,36.6,108,6.8,397.8,25 -Kalpataru Projects International Ltd.,KPIL,522287,UTILITIES,ELECTRIC UTILITIES,"4,53","4,148",370,8.19%,113,137,132,42,89,5.5,478,29.9 -Kansai Nerolac Paints Ltd.,KANSAINER,500165,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"1,978.6","1,683.3",273.2,13.97%,47.4,7.6,240.3,64.8,177.2,2.2,"1,118.8",13.8 -Karur Vysya Bank Ltd.,KARURVYSYA,590003,BANKING AND FINANCE,BANKS,"2,336",616.4,637.9,31.94%,0,"1,081.7",511.5,133.1,378.4,4.7,"1,364.2",17 -KEC International Ltd.,KEC,532714,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"4,514.9","4,224.7",274.3,6.10%,46.5,177.8,65.8,9.9,55.8,2.2,187.9,7.3 -Kotak Mahindra Bank Ltd.,KOTAKBANK,500247,BANKING AND FINANCE,BANKS,"21,559.5","9,681","6,343",46.24%,0,"5,535.5","5,888.3","1,465.5","4,461",22.4,"17,172.7",86.4 -L&T Finance Holdings Ltd.,L&TFH,533519,DIVERSIFIED,HOLDING COMPANIES,"3,482.1",935.3,"1,882.4",58.57%,28.3,"1,324.9",797.4,203.2,595.1,2.4,"2,080.8",8.4 -L&T Technology Services Ltd.,LTTS,540115,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,427.7","1,910.9",475.6,19.93%,68.1,12.6,436.1,120.2,315.4,29.8,"1,239.7",117.5 -LIC Housing Finance Ltd.,LICHSGFIN,500253,BANKING AND FINANCE,HOUSING FINANCE,"6,765.9",250.6,"6,095.7",90.10%,13.2,"4,599.9","1,483",291.2,"1,193.5",21.7,"4,164.5",75.7 -Lakshmi Machine Works Ltd.,LAXMIMACH,500252,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"1,355.5","1,184.5",136,10.30%,23.6,0,147.4,32.3,115.1,107.8,416,389.5 -Laurus Labs Ltd.,LAURUSLABS,540222,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,226.2","1,036.6",187.9,15.34%,93.4,42.4,53.9,14.6,37,0.7,367.8,6.8 -Lupin Ltd.,LUPIN,500257,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"5,079","4,120.8",917.8,18.21%,247.8,80.6,629.7,134.3,489.5,10.8,"1,331.2",29.2 -MMTC Ltd.,MMTC,513377,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,-167.2,-180.1,-30.4,14.42%,0.8,1.1,12.1,1.5,52,0.3,174.1,1.2 -MRF Ltd.,MRF,500290,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"6,287.8","5,060.2","1,156.9",18.61%,351.5,85.5,790.6,203.9,586.7,1383.3,"1,690.9",3988 -Mahanagar Gas Ltd.,MGL,539957,UTILITIES,UTILITIES,"1,772.7","1,250.1",478.9,27.70%,65.8,2.5,454.3,115.8,338.5,34.3,"1,147.8",116.2 -Mahindra & Mahindra Financial Services Ltd.,M&MFIN,532720,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"3,863.5","1,077.5","2,109.3",55.03%,67.1,"1,703.4",369.1,96,281.1,2.3,"1,982.5",16 -Mahindra & Mahindra Ltd.,M&M,500520,AUTOMOBILES & AUTO COMPONENTS,CARS & UTILITY VEHICLES,"35,027.2","28,705.9","5,729.6",16.64%,"1,138.6","1,835.2","3,347.5","1,083.7","2,347.8",21.1,"11,169.4",100.2 -Mahindra Holidays & Resorts India Ltd.,MHRIL,533088,HOTELS RESTAURANTS & TOURISM,HOTELS,672.2,519.3,136,20.76%,83.8,33.3,35.8,14,21.3,1.1,66,3.3 -Manappuram Finance Ltd.,MANAPPURAM,531213,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"2,174",555.6,"1,481.3",68.68%,62.5,689.4,746.7,186.1,558.4,6.6,"1,859.8",22 -Mangalore Refinery And Petrochemicals Ltd.,MRPL,500109,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"22,904.7","20,705.6","2,138.2",9.36%,296,311.2,"1,592",546.2,"1,051.7",6,"3,784.9",21.6 -Marico Ltd.,MARICO,531642,FMCG,PERSONAL PRODUCTS,"2,514","1,979",497,20.07%,39,20,476,116,353,2.7,"1,41",10.9 -Maruti Suzuki India Ltd.,MARUTI,532500,AUTOMOBILES & AUTO COMPONENTS,CARS & UTILITY VEHICLES,"37,902.1","32,282.5","4,790.3",12.92%,794.4,35.1,"4,790.1","1,083.8","3,764.3",124.6,"11,351.8",375.9 -Max Financial Services Ltd.,MFSL,500271,BANKING AND FINANCE,LIFE INSURANCE,"10,189.1","10,024.6",143.9,1.42%,0.8,9.4,158.2,-12.1,147.9,4.3,506.4,14.7 -UNO Minda Ltd.,UNOMINDA,532539,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"3,630.2","3,219.8",401.6,11.09%,125.4,27.2,257.9,73.3,225,3.9,742.4,13 -Motilal Oswal Financial Services Ltd.,MOTILALOFS,532892,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,"1,650.7",724.1,904.5,55.18%,17.3,241.1,657.6,124.2,531.2,35.9,"1,449.3",97.8 -MphasiS Ltd.,MPHASIS,526299,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"3,325.5","2,680.9",595.6,18.18%,89,34,521.7,129.7,391.9,20.8,"1,605.6",85.1 -Muthoot Finance Ltd.,MUTHOOTFIN,533398,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"3,631.9",723.4,"2,801.6",77.69%,22.2,"1,335","1,470.2",374.9,"1,059.6",26.4,"3,982.9",99.2 -Natco Pharma Ltd.,NATCOPHARM,524816,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,060.8",573.4,458,44.41%,43.6,4.2,439.6,70.6,369,20.6,"1,127.4",63 -NBCC (India) Ltd.,NBCC,534309,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"2,129.1","1,957.7",95.5,4.65%,1.3,0,104.6,22.9,79.6,0.4,332.2,1.8 -NCC Ltd.,NCC,500294,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"4,746.4","4,415.9",303.7,6.44%,53.2,153.5,123.8,38.8,77.3,1.2,599.4,9.5 -NHPC Ltd.,NHPC,533098,UTILITIES,ELECTRIC UTILITIES,"3,113.8","1,173.9","1,757.4",59.95%,294.9,104.8,"1,618.3",-75,"1,545.8",1.5,"3,897.8",3.9 -Coforge Ltd.,COFORGE,532541,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,285.1","1,935.3",340.9,14.98%,77.2,31.9,240.7,52.8,187.9,29.6,696.2,113.2 -NLC India Ltd.,NLCINDIA,513683,UTILITIES,ELECTRIC UTILITIES,"3,234","2,143",834.6,28.03%,455.1,213.9,"1,700.6",614.7,"1,084.7",7.8,"1,912.3",13.8 -NTPC Ltd.,NTPC,532555,UTILITIES,ELECTRIC UTILITIES,"45,384.6","32,303.2","12,680.2",28.19%,"4,037.7","2,920.5","6,342.9","2,019.7","4,614.6",4.8,"19,125.2",19.7 -Narayana Hrudayalaya Ltd.,NH,539551,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,323.6",997.1,308.1,23.61%,55.3,22.9,248.4,21.7,226.6,11.2,737.5,36.1 -National Aluminium Company Ltd.,NATIONALUM,532234,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"3,112","2,646.9",396.5,13.03%,186.2,4,275,68.7,187.3,1,"1,272.4",6.9 -Navin Fluorine International Ltd.,NAVINFLUOR,532504,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,494.9,373.4,98.3,20.84%,24.2,20,77.2,16.6,60.6,12.2,365,73.7 -Oberoi Realty Ltd.,OBEROIRLTY,533273,REALTY,REALTY,"1,243.8",579.2,638.2,52.42%,11.3,56.5,596.8,142.1,456.8,12.6,"1,961.3",53.9 -Oil And Natural Gas Corporation Ltd.,ONGC,500312,OIL & GAS,EXPLORATION & PRODUCTION,"149,388.5","118,618.4","28,255.3",19.24%,"6,698.1","2,603.3","21,564.9","5,633.6","13,734.1",10.9,"43,072.5",34.2 -Oil India Ltd.,OIL,533106,OIL & GAS,EXPLORATION & PRODUCTION,"9,200.1","5,293.3","3,523.2",39.96%,499,278.9,762,67.6,420.7,3.9,"5,874.5",54.2 -Oracle Financial Services Software Ltd.,OFSS,532466,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,509.6",886.4,558.1,38.64%,19,8,596.2,178.8,417.4,48.2,"1,835.1",211.9 -PI Industries Ltd.,PIIND,523642,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"2,163.8","1,565.5",551.4,26.05%,80.3,7.8,510.2,31.7,480.5,31.7,"1,495.8",98.4 -PNB Housing Finance Ltd.,PNBHOUSING,540173,BANKING AND FINANCE,HOUSING FINANCE,"1,779.4",158.8,"1,574.1",88.54%,11.3,"1,057.3",507.1,124.1,383,14.8,"1,278.7",49.3 -PNC Infratech Ltd.,PNCINFRA,539150,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,932.4","1,511.6",399.8,20.92%,40.9,161.3,218.6,70.7,147.9,5.8,614.3,23.9 -PVR INOX Ltd.,PVRINOX,532689,RETAILING,SPECIALTY RETAIL,"2,023.7","1,293.1",706.8,35.34%,308.6,200.3,221.7,55.5,166.3,17,-232.5,-23.7 -Page Industries Ltd.,PAGEIND,532827,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,"1,126.8",891.6,233.5,20.76%,24.6,11.2,199.4,49.1,150.3,134.7,510.7,457.9 -Persistent Systems Ltd.,PERSISTENT,533179,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,449","2,006.5",405.2,16.80%,74.4,12.3,355.8,92.5,263.3,35,981.5,127.6 -Petronet LNG Ltd.,PETRONET,532522,OIL & GAS,OIL MARKETING & DISTRIBUTION,"12,686.2","11,317.9","1,214.7",9.69%,194.8,74.7,"1,098.8",283.9,855.7,5.7,"3,490.3",23.3 -Pfizer Ltd.,PFIZER,500680,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,611.3,392.6,182.6,31.75%,15.4,2.7,200.5,51.6,149,32.6,522.8,114.3 -Phoenix Mills Ltd.,PHOENIXLTD,503100,REALTY,REALTY,906.6,361.2,506,57.82%,65.9,96.5,375.2,71.4,252.6,14.2,923.6,51.7 -Pidilite Industries Ltd.,PIDILITIND,500331,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"3,107.6","2,396.3",679.7,22.10%,75.2,13.1,623,163.1,450.1,8.8,"1,505.5",29.6 -Power Finance Corporation Ltd.,PFC,532810,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"22,403.7",315.4,"22,941.9",102.46%,12.7,"14,313.1","8,628.8","2,000.6","4,833.1",14.7,"17,946.4",54.4 -Power Grid Corporation of India Ltd.,POWERGRID,532898,UTILITIES,ELECTRIC UTILITIES,"11,530.4","1,358.7","9,908.4",87.94%,"3,277","2,341.3","4,393.4",573.7,"3,781.4",4.1,"15,344.4",16.5 -Prestige Estates Projects Ltd.,PRESTIGE,ASM,REALTY,REALTY,"3,256","1,643.9",592.5,26.49%,174.1,263.9,"1,174.1",256.4,850.9,21.2,"1,714",42.8 -Prism Johnson Ltd.,PRSMJOHNSN,500338,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,846","1,745.4",92.4,5.03%,95.2,43.5,210,30.4,182.7,3.6,154.2,3.1 -Procter & Gamble Hygiene & Healthcare Ltd.,PGHH,500459,FMCG,PERSONAL PRODUCTS,"1,154.1",853.5,284.9,25.03%,14.3,1.9,284.5,73.8,210.7,64.9,734.4,226.3 -Punjab National Bank,PNB,532461,BANKING AND FINANCE,BANKS,"29,857","6,798.1","6,239.1",23.23%,0,"16,819.8","2,778.3","1,013.8","1,990.2",1.8,"5,904.8",5.4 -Quess Corp Ltd.,QUESS,539978,SOFTWARE & SERVICES,BPO/KPO,"4,763.5","4,584.8",163.6,3.44%,69.7,28.1,79.3,8.3,71.9,4.8,240.9,16.2 -RBL Bank Ltd.,RBLBANK,540065,BANKING AND FINANCE,BANKS,"3,720.6","1,422.6",765.4,25.45%,0,"1,532.6",125,-206.1,331.1,5.5,"1,173.9",19.5 -Radico Khaitan Ltd.,RADICO,532497,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,925.7,803.8,121.2,13.10%,26.1,12.5,83.3,21.4,64.8,4.8,237,17.7 -Rain Industries Ltd.,RAIN,500339,CHEMICALS & PETROCHEMICALS,PETROCHEMICALS,"4,208.9","3,794.3",366,8.80%,192.5,241.7,-19.5,46.2,-90.2,-2.7,270.4,8 -Rajesh Exports Ltd.,RAJESHEXPO,531500,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"38,079.4","38,015.8",50.1,0.13%,10.7,0,53,7.7,45.3,1.5,"1,142.2",38.7 -Rallis India Ltd.,RALLIS,500355,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,837,699,133,15.99%,26,3,110,28,82,4.2,98.4,5.2 -Rashtriya Chemicals & Fertilizers Ltd.,RCF,524230,FERTILIZERS,FERTILIZERS,"4,222.1","4,049.3",105.9,2.55%,56.1,44,72.8,21.1,51,0.9,523.6,9.5 -Redington Ltd.,REDINGTON,532805,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,"22,296.6","21,738.7",481.4,2.17%,43.7,105.8,408.3,96.7,303.5,3.9,"1,242",15.9 -Relaxo Footwears Ltd.,RELAXO,530517,RETAILING,FOOTWEAR,725.9,623.8,91.5,12.79%,36.9,4.7,60.4,16.2,44.2,1.8,193.9,7.8 -Reliance Industries Ltd.,RELIANCE,500325,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"238,797","193,988","40,968",17.44%,"12,585","5,731","26,493","6,673","17,394",25.7,"68,496",101.2 -REC Ltd.,RECLTD,532955,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"11,701.3",275.1,"12,180.5",104.21%,6.1,"7,349.8","4,837.6","1,047.7","3,789.9",14.4,"12,738.6",48.4 -SJVN Ltd.,SJVN,533206,UTILITIES,ELECTRIC UTILITIES,951.6,172.2,706.2,80.40%,101.9,124.2,567.7,129.2,439.6,1.1,"1,016",2.6 -SKF India Ltd.,SKFINDIA,500472,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,"1,145.5","1,003.7",121.5,10.80%,19.3,0.5,122,31.7,90,18.2,484,97.9 -SRF Ltd.,SRF,503806,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"3,206.5","2,551.2",626.2,19.71%,161.2,79.3,414.8,114,300.8,10.2,"1,733.4",58.5 -Sanofi India Ltd.,SANOFI,500674,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,726.4,506.1,208.5,29.17%,9.9,0.3,210.1,57.9,152.1,66.1,596.3,259.3 -Schaeffler India Ltd.,SCHAEFFLER,505790,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,879.2","1,506.3",342,18.50%,55.6,1.6,315.7,80.7,235,15,922.6,59 -Shree Cements Ltd.,SHREECEM,500387,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"4,932.1","3,914.1",886,18.46%,411.7,67,539.2,92.6,446.6,123.8,"1,826.8",506.3 -Shriram Finance Ltd.,SHRIRAMFIN,511218,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"8,893","1,409.4","6,334.3",71.30%,141.4,"3,798","2,404.2",614.9,"1,786.1",47.6,"6,575.4",175.2 -Siemens Ltd.,SIEMENS,500550,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"5,953.2","5,107.5",700.2,12.06%,78.6,4.9,762.2,190.5,571.3,16.1,"1,960.9",55.1 -Sobha Ltd.,SOBHA,532784,REALTY,REALTY,773.6,665.8,75.4,10.18%,19.3,63.9,24.7,9.7,14.9,1.6,107.4,11.3 -Solar Industries India Ltd.,SOLARINDS,532725,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"1,355.2","1,011.3",336.1,24.95%,33.7,24.9,285.3,75.5,200.1,22.1,808.2,89.3 -Sonata Software Ltd.,SONATSOFTW,532221,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,935.8","1,715.2",197.3,10.32%,33.3,20.7,166.5,42.3,124.2,9,475.7,34.3 -State Bank of India,SBIN,500112,BANKING AND FINANCE,BANKS,"144,256.1","58,597.6","22,703.3",21.14%,0,"62,955.2","21,935.7","5,552.5","17,196.2",18,"69,304.1",77.7 -Steel Authority of India (SAIL) Ltd.,SAIL,500113,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"29,858.2","25,836.7","3,875.4",13.04%,"1,326.6",605.2,"1,674.7",464.2,"1,305.6",3.2,"3,219.5",7.8 -Sun Pharma Advanced Research Company Ltd.,SPARC,532872,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,29.7,112.7,-91.5,-431.87%,3.2,0.3,-86.4,0,-86.4,-2.7,-253.6,-7.8 -Sun Pharmaceutical Industries Ltd.,SUNPHARMA,524715,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"12,486","9,013","3,179.4",26.08%,632.8,49.3,"2,790.9",390.1,"2,375.5",9.9,"8,548.5",35.6 -Sun TV Network Ltd.,SUNTV,532733,MEDIA,BROADCASTING & CABLE TV,"1,160.2",320.6,727.8,69.42%,218.8,1.7,619.1,154.4,464.7,11.8,"1,861.8",47.2 -Sundram Fasteners Ltd.,SUNDRMFAST,500403,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,429.1","1,191.1",230.7,16.23%,54.5,7.4,176.2,43.1,131.9,6.3,502.9,23.9 -Sunteck Realty Ltd.,SUNTECK,512179,REALTY,REALTY,36.2,39.1,-14.1,-56.70%,2.2,15.8,-20.9,-6.4,-13.9,-1,-46.5,-3.3 -Supreme Industries Ltd.,SUPREMEIND,509930,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,"2,321.4","1,952.5",356.2,15.43%,71.9,1.6,295.4,76.3,243.2,19.1,"1,028.2",80.9 -Suzlon Energy Ltd.,SUZLON,ASM,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"1,428.7","1,196.4",225,15.83%,51.2,43.7,102.4,0.1,102.3,0.1,561.4,0.4 -Syngene International Ltd.,SYNGENE,539268,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,931.7,656,254.1,27.92%,104.6,13,150.7,34.2,116.5,2.9,498.3,12.4 -TTK Prestige Ltd.,TTKPRESTIG,517506,CONSUMER DURABLES,HOUSEWARE,747.2,648.6,80.8,11.08%,15.9,3.1,79.5,20.5,59.3,4.3,224.3,16.2 -TV18 Broadcast Ltd.,TV18BRDCST,532800,MEDIA,BROADCASTING & CABLE TV,"1,989","1,992.2",-198.1,-11.04%,50.1,33.8,-87.1,-6.5,-28.9,-0.2,92.2,0.5 -TVS Motor Company Ltd.,TVSMOTOR,532343,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"9,983.8","8,576.9","1,355.9",13.65%,237.1,483.3,686.4,259.8,386.3,8.1,"1,457.6",30.7 -Tata Consultancy Services Ltd.,TCS,532540,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"60,698","43,946","15,746",26.38%,"1,263",159,"15,33","3,95","11,342",31,"44,654",122 -Tata Elxsi Ltd.,TATAELXSI,500408,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,912.8,618.2,263.5,29.89%,25,5.8,263.9,63.8,200,32.1,785.1,126.1 -Tata Consumer Products Ltd.,TATACONSUM,500800,FMCG,PACKAGED FOODS,"3,823.6","3,196.7",537.1,14.38%,93.9,27.6,490.9,131.7,338.2,3.6,"1,275.2",13.7 -Tata Motors Limited (DVR),TATAMTRDVR,570001,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,,,,,,,,,,,, -Tata Motors Ltd.,TATAMOTORS,500570,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"106,759","91,361.3","13,766.9",13.10%,"6,636.4","2,651.7","5,985.9","2,202.8","3,764",9.8,"15,332.3",40 -Tata Power Company Ltd.,TATAPOWER,500400,UTILITIES,ELECTRIC UTILITIES,"16,029.5","12,647","3,091",19.64%,925.9,"1,181.8",979.2,213.3,875.5,2.7,"3,570.8",11.2 -Tata Steel Ltd.,TATASTEEL,500470,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"55,910.2","51,414.1","4,267.8",7.66%,"2,479.8","1,959.4","-6,842.1",-228,"-6,196.2",-5.1,"-6,081.3",-5 -Tech Mahindra Ltd.,TECHM,532755,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"13,128.1","11,941.1",922.8,7.17%,465.7,97.5,623.8,110,493.9,5.6,"3,600.7",40.9 -The Ramco Cements Ltd.,RAMCOCEM,500260,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,352.1","1,935",405.6,17.33%,162.8,116.5,137.8,37,72,3.1,348.9,14.8 -Thermax Ltd.,THERMAX,500411,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,368.3","2,097.8",204.6,8.89%,33,19.8,217.7,58.9,157.7,14,498.8,44.3 -Timken India Ltd.,TIMKEN,522113,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,692.1,546.5,135.5,19.87%,21.1,0.9,123.6,30.6,93,12.4,358.3,47.6 -Titan Company Ltd.,TITAN,500114,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"12,653","11,118","1,411",11.26%,144,140,"1,251",336,915,10.3,"3,302",37.1 -Torrent Pharmaceuticals Ltd.,TORNTPHARM,500420,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,686","1,835",825,31.02%,201,91,559,173,386,11.4,"1,334",39.4 -Torrent Power Ltd.,TORNTPOWER,532779,UTILITIES,ELECTRIC UTILITIES,"7,069.1","5,739.5","1,221.4",17.55%,341.7,247.2,740.7,198.1,525.9,10.9,"2,176.8",45.3 -Trent Ltd.,TRENT,500251,RETAILING,DEPARTMENT STORES,"3,062.5","2,525.8",456.6,15.31%,152.2,95.5,288.9,86.3,234.7,6.6,629.4,17.7 -Trident Ltd.,TRIDENT,521064,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,812","1,557.3",240.3,13.37%,89.4,35,130.4,40.1,90.7,0.2,458.1,0.9 -UPL Ltd.,UPL,512070,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"10,275","8,807","1,325",13.03%,657,871,-185,-96,-189,-2.5,"1,856",24.7 -UltraTech Cement Ltd.,ULTRACEMCO,532538,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"16,179.3","13,461.2","2,550.9",15.93%,797.8,233.9,"1,686.2",409.4,"1,281.5",44.5,"5,694.1",197.2 -Union Bank of India,UNIONBANK,532477,BANKING AND FINANCE,BANKS,"28,952.5","6,189.3","7,265",29.38%,0,"15,498.2","5,492.3","1,944","3,571.8",5.1,"11,918.9",16.1 -United Breweries Ltd.,UBL,532478,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,"1,902.1","1,705.8",184.3,9.75%,50.9,1.4,144,36.9,107.3,4.1,251.3,9.5 -United Spirits Ltd.,MCDOWELL-N,532432,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,"6,776.6","6,269.8",466.7,6.93%,65.3,26.2,446,106.3,339.3,4.8,"1,133",15.6 -V-Guard Industries Ltd.,VGUARD,532953,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,147.9","1,041.3",92.5,8.16%,19.8,9.3,77.5,18.6,59,1.4,215.2,5 -Vardhman Textiles Ltd.,VTL,502986,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,487","2,192.1",205.4,8.57%,103.7,22,169.2,41.7,134.3,4.7,531.9,18.7 -Varun Beverages Ltd.,VBL,540180,FOOD BEVERAGES & TOBACCO,NON-ALCOHOLIC BEVERAGES,"3,889","2,988.4",882.1,22.79%,170.8,62.5,667.3,152.9,501.1,3.9,"1,998.7",15.4 -Vinati Organics Ltd.,VINATIORGA,524200,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,464.4,337.3,110.8,24.73%,13.7,0.3,113,28.9,84.2,8.2,408.2,39.7 -Voltas Ltd.,VOLTAS,500575,CONSUMER DURABLES,CONSUMER ELECTRONICS,"2,363.7","2,222.5",70.3,3.06%,11.7,11.4,118.1,49.3,36.7,1.1,199.5,6 -ZF Commercial Vehicle Control Systems India Ltd.,ZFCVINDIA,533023,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,015.8",846.2,145.5,14.67%,27.1,1.3,141.2,35.5,105.7,55.7,392,206.7 -Welspun Corp Ltd.,WELCORP,ASM,METALS & MINING,IRON & STEEL PRODUCTS,"4,161.4","3,659.9",399.5,9.84%,85.7,75,340.8,79,384.7,14.7,809.2,30.9 -Welspun Living Ltd.,WELSPUNLIV,514162,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,542.4","2,151.1",358,14.27%,98.5,33.8,258.9,58.7,196.7,2,526.1,5.4 -Whirlpool of India Ltd.,WHIRLPOOL,500238,CONSUMER DURABLES,CONSUMER ELECTRONICS,"1,555.5","1,448.4",73.2,4.81%,49.2,5.6,52.3,14.1,36.6,2.9,198.8,15.7 -Wipro Ltd.,WIPRO,507685,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"23,255.7","18,543.2","3,972.7",17.64%,897,303.3,"3,512.2",841.9,"2,646.3",5.1,"11,643.8",22.3 -Zee Entertainment Enterprises Ltd.,ZEEL,505537,MEDIA,BROADCASTING & CABLE TV,"2,509.6","2,105",332.8,13.65%,77.2,23.4,184.2,54.4,123,1.3,-102.2,-1.1 -eClerx Services Ltd.,ECLERX,532927,SOFTWARE & SERVICES,BPO/KPO,735.9,517,204.7,28.37%,30.3,6.1,182.4,46.3,136,28.2,506,105 -Sterlite Technologies Ltd.,STLTECH,532374,TELECOMMUNICATIONS EQUIPMENT,TELECOM CABLES,"1,497","1,281",213,14.26%,85,95,36,12,34,0.9,203,5.1 -HEG Ltd.,HEG,509631,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,642.2,512.3,101.9,16.58%,38.5,8.5,82.9,21.7,96,24.9,439.5,113.9 -SBI Life Insurance Company Ltd.,SBILIFE,540719,BANKING AND FINANCE,LIFE INSURANCE,"28,816.2","28,183.8",609.9,2.12%,0,0,621.5,43.9,380.2,3.8,"1,842.2",18.4 -General Insurance Corporation of India,GICRE,540755,BANKING AND FINANCE,GENERAL INSURANCE,"13,465.9","11,574","1,464.6",11.20%,0,0,"1,855.4",243.7,"1,689",15.2,"6,628",37.8 -Tube Investments of India Ltd.,TIINDIA,540762,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,005.4","1,718.2",251.4,12.76%,34.6,7.7,244.8,63.4,181.4,9.4,717.5,37.1 -Honeywell Automation India Ltd.,HONAUT,517174,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,144.3",965.9,138.3,12.52%,13.8,0.7,163.9,42,121.9,137.8,443.4,503.9 -Indian Energy Exchange Ltd.,IEX,540750,BANKING AND FINANCE,EXCHANGE,133,16.6,92,84.73%,5.1,0.7,110.6,27.9,86.5,1,327.8,3.7 -ICICI Lombard General Insurance Company Ltd.,ICICIGI,540716,BANKING AND FINANCE,GENERAL INSURANCE,"5,271.1","4,612.4",743.5,14.16%,0,0,763.6,186.4,577.3,11.8,"1,757.1",35.8 -Aster DM Healthcare Ltd.,ASTERDM,540975,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"3,325.2","2,939.4",377.3,11.38%,227.2,101.9,2.1,10.2,-30.8,-0.6,284.3,5.7 -Central Depository Services (India) Ltd.,CDSL,CDSL,OTHERS,INVESTMENT COMPANIES,230.1,77.9,129.4,62.40%,6.5,0,145.6,35.8,108.9,10.4,320.2,30.6 -Graphite India Ltd.,GRAPHITE,509488,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,884,823,-30,-3.78%,19,4,992,190,804,41.1,856,43.9 -Grasim Industries Ltd.,GRASIM,500300,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"30,505.3","25,995.9","4,224.8",13.98%,"1,245.2",397.8,"2,866.4",837.7,"1,163.8",17.7,"6,624.9",100.6 -KNR Constructions Ltd.,KNRCON,532942,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"1,043.8",806.9,231.6,22.30%,39.2,20.6,177.1,34.6,147.4,5.2,537.5,19.1 -Aditya Birla Capital Ltd.,ABCAPITAL,540691,DIVERSIFIED,HOLDING COMPANIES,"7,730.4","4,550.1","2,821.9",36.55%,48,"1,827",956.8,284.1,705,2.7,"5,231.9",20.1 -Dixon Technologies (India) Ltd.,DIXON,540699,CONSUMER DURABLES,CONSUMER ELECTRONICS,"4,943.9","4,744.3",198.9,4.02%,36.4,17.1,146.1,35.2,107.3,19,308.7,51.8 -Cholamandalam Financial Holdings Ltd.,CHOLAHLDNG,504973,DIVERSIFIED,HOLDING COMPANIES,"6,372.2","2,495.1","3,404.8",54.05%,52.1,"2,209.4","1,215.8",324.6,420.9,22.4,"1,532.3",81.6 -Cochin Shipyard Ltd.,COCHINSHIP,540678,TRANSPORTATION,MARINE PORT & SERVICES,"1,100.4",820.5,191.2,18.90%,18.9,9.6,251.4,69.9,181.5,13.8,429.9,32.7 -Bharat Dynamics Ltd.,BDL,541143,GENERAL INDUSTRIALS,DEFENCE,694.1,481.8,134,21.77%,17.4,0.8,194.1,47,147.1,8,425.4,23.2 -Lux Industries Ltd.,LUXIND,539542,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,643.6,584.2,55,8.61%,5.9,5.4,48,12.1,37.1,12.3,103.1,32.9 -Zensar Technologies Ltd.,ZENSARTECH,504067,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,277.1","1,009.9",230.9,18.61%,36.6,5.7,224.9,51,173.9,7.7,525.8,23.2 -PCBL Ltd.,PCBL,506590,CHEMICALS & PETROCHEMICALS,CARBON BLACK,"1,489.4","1,248.6",238.1,16.02%,48.2,21,171.6,48.8,122.6,3.2,431.6,11.4 -Zydus Wellness Ltd.,ZYDUSWELL,531335,FMCG,PACKAGED FOODS,444,423.1,16.8,3.82%,5.8,6.5,8.6,2.7,5.9,0.9,281.2,44.2 -Linde India Ltd.,LINDEINDIA,523457,GENERAL INDUSTRIALS,INDUSTRIAL GASES,729.9,537.7,173.6,24.41%,49.7,1.2,141.3,34.6,108.7,12.8,417.9,49 -FDC Ltd.,FDC,531599,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,513.6,409.9,76.4,15.71%,9.9,1.1,92.7,22.9,69.8,4.2,251.2,15.4 -The New India Assurance Company Ltd.,NIACL,540769,BANKING AND FINANCE,GENERAL INSURANCE,"10,571","10,773.4",-246.5,-2.33%,0,0,-242,-46.7,-176.1,-1.1,947,5.7 -Sundaram Finance Ltd.,SUNDARMFIN,590071,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"1,710.6",322.5,"1,332.1",77.98%,43.6,820.3,470.6,142.8,365.4,33.2,"1,506.7",135.6 -TeamLease Services Ltd.,TEAMLEASE,539658,COMMERCIAL SERVICES & SUPPLIES,MISC. COMMERCIAL SERVICES,"2,285.6","2,240.8",31.8,1.40%,12.9,2.5,29.4,1.8,27.3,16.3,106.6,63.5 -Galaxy Surfactants Ltd.,GALAXYSURF,540935,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,985.8,858.2,124.9,12.70%,24.7,5.4,97.5,20.1,77.4,21.8,349.3,98.5 -Bandhan Bank Ltd.,BANDHANBNK,541153,BANKING AND FINANCE,BANKS,"5,032.2","1,400.2","1,583.4",35.25%,0,"2,048.6",947.2,226.1,721.2,4.5,"2,541.1",15.8 -ICICI Securities Ltd.,ISEC,541179,BANKING AND FINANCE,CAPITAL MARKETS,"1,249",433.5,810.2,64.87%,25.8,215.1,569.4,145.7,423.6,13.1,"1,238.1",38.3 -V-Mart Retail Ltd.,VMART,534976,RETAILING,DEPARTMENT STORES,551.4,548.8,0.7,0.12%,53.2,35.9,-86.4,-22.3,-64.1,-32.4,-103.1,-52.1 -Nippon Life India Asset Management Ltd.,NAM-INDIA,540767,BANKING AND FINANCE,ASSET MANAGEMENT COS.,475.4,156.1,241.4,60.73%,7.2,1.7,310.4,66.1,244.4,3.9,883.3,14.1 -Grindwell Norton Ltd.,GRINDWELL,506076,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,690,536,131.4,19.69%,16.9,1.8,135.3,33.1,101.9,9.2,378.3,34.2 -HDFC Life Insurance Company Ltd.,HDFCLIFE,540777,BANKING AND FINANCE,LIFE INSURANCE,"23,276.6","23,659.3",-508.1,-2.20%,0,0,-373.1,-657.5,378.2,1.8,"1,472.8",6.9 -Elgi Equipments Ltd.,ELGIEQUIP,522074,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,817.8,663.4,142.7,17.71%,18.7,6.6,129.2,38.8,91.3,2.9,401.9,12.7 -Hindustan Aeronautics Ltd.,HAL,541154,GENERAL INDUSTRIALS,DEFENCE,"6,105.1","4,108.1","1,527.6",27.11%,349.6,0.3,"1,647",414.8,"1,236.7",18.5,"6,037.3",90.3 -BSE Ltd.,BSE,BSE,BANKING AND FINANCE,EXCHANGE,367,172.8,189.2,52.26%,22.7,8.5,163,63.6,120.5,8.8,706,52.1 -Rites Ltd.,RITES,541556,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,608.8,444.5,137.8,23.67%,14.1,1.4,148.8,40.1,101.2,4.2,488.1,20.3 -Fortis Healthcare Ltd.,FORTIS,532843,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,783.5","1,439.8",330.2,18.65%,84.1,31.8,231.4,48.8,173.7,2.3,547.6,7.3 -Varroc Engineering Ltd.,VARROC,541578,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,893.5","1,692.6",194.3,10.30%,84.9,50.3,65.9,18.2,54.2,3.5,146.5,9.6 -Adani Green Energy Ltd.,ADANIGREEN,ASM,UTILITIES,ELECTRIC UTILITIES,"2,589",521,"1,699",76.53%,474,"1,165",413,119,372,2.2,"1,305",8.2 -VIP Industries Ltd.,VIPIND,507880,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,548.7,493.2,52.9,9.68%,23.8,12.4,19.3,6,13.3,0.9,110.9,7.8 -CreditAccess Grameen Ltd.,CREDITACC,541770,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"1,247.6",248.8,902.3,72.36%,12.3,423.9,466.8,119.7,347,21.8,"1,204.2",75.7 -CESC Ltd.,CESC,500084,UTILITIES,ELECTRIC UTILITIES,"4,414","3,706",646,14.84%,303,305,461,98,348,2.6,"1,447",10.9 -Jamna Auto Industries Ltd.,JAMNAAUTO,520051,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,608.7,528.2,79.1,13.03%,10.9,0.8,68.7,18.6,50.1,2.4,189.3,4.7 -Suprajit Engineering Ltd.,SUPRAJIT,532509,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,727.6,639.1,69.8,9.85%,25.7,13.6,49.2,14.5,34.8,2.5,146.9,10.6 -JK Paper Ltd.,JKPAPER,532162,COMMERCIAL SERVICES & SUPPLIES,PAPER & PAPER PRODUCTS,"1,708.8","1,242.8",407.3,24.68%,83.5,42,340.6,34.9,302.4,17.9,"1,220.6",72.1 -Bank of Maharashtra,MAHABANK,532525,BANKING AND FINANCE,BANKS,"5,735.5","1,179.4","1,920.5",37.90%,0,"2,635.7",935.7,16,919.8,1.3,"3,420.8",4.8 -Aavas Financiers Ltd.,AAVAS,541988,BANKING AND FINANCE,HOUSING FINANCE,497.6,123.5,367.8,74.03%,7.6,203.6,157.4,35.7,121.7,15.4,465.4,58.8 -HDFC Asset Management Company Ltd.,HDFCAMC,541729,BANKING AND FINANCE,ASSET MANAGEMENT COS.,765.4,162,481.1,74.81%,13,2.3,588.1,151.6,436.5,20.4,"1,659.3",77.7 -KEI Industries Ltd.,KEI,517569,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,954.2","1,742.7",203.9,10.47%,15.6,7.5,188.4,48.2,140.2,15.5,528.3,58.5 -Orient Electric Ltd.,ORIENTELEC,541301,CONSUMER DURABLES,CONSUMER ELECTRONICS,570.3,546.2,20.7,3.65%,14.2,5.2,23.4,4.9,18.4,0.9,95.3,4.5 -Deepak Nitrite Ltd.,DEEPAKNTR,506401,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"1,795.1","1,475.8",302.3,17.00%,39.4,2.7,277.2,72.1,205.1,15,797.9,58.5 -Fine Organic Industries Ltd.,FINEORG,541557,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,557.6,409.4,131.1,24.25%,14.4,0.7,133.1,28.9,103.4,33.7,458.8,149.6 -LTIMindtree Ltd.,LTIM,540005,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"9,048.6","7,274.1","1,631.3",18.32%,208.2,47,"1,519.3",357,"1,161.8",39.3,"4,427.5",149.6 -Dalmia Bharat Ltd.,DALBHARAT,542216,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"3,234","2,56",589,18.70%,401,101,172,48,118,6.3,"1,041",54.8 -Godfrey Phillips India Ltd.,GODFRYPHLP,500163,FOOD BEVERAGES & TOBACCO,CIGARETTES-TOBACCO PRODUCTS,"1,412.5","1,151",223.6,16.27%,36.5,6.6,218.5,55.5,202.1,38.9,802.9,154.4 -Vaibhav Global Ltd.,VAIBHAVGBL,532156,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,708.4,641.5,63.5,9.01%,22.6,2.9,41.4,12.4,29.4,1.8,121.3,7.3 -Abbott India Ltd.,ABBOTINDIA,500488,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,549.7","1,113.3",380.9,25.49%,17.8,3.1,415.4,102.5,312.9,147.3,"1,081.4",508.9 -Adani Total Gas Ltd.,ATGL,ASM,UTILITIES,UTILITIES,"1,104.8",815.7,279.9,25.55%,37.6,27.3,224.2,57.2,172.7,1.6,571,5.2 -Nestle India Ltd.,NESTLEIND,500790,FMCG,PACKAGED FOODS,"5,070.1","3,811.9","1,224.9",24.32%,111.2,31.4,"1,222",313.9,908.1,94.2,"2,971.1",308.2 -Bayer Cropscience Ltd.,BAYERCROP,506285,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"1,633.3","1,312.3",304.9,18.85%,11.6,3.7,305.7,82.8,222.9,49.6,844.4,188.1 -Amber Enterprises India Ltd.,AMBER,540902,CONSUMER DURABLES,CONSUMER ELECTRONICS,939.8,867.5,59.6,6.43%,45.2,36.6,-9.5,-3.8,-6.9,-2.1,156.8,46.5 -Rail Vikas Nigam Ltd.,RVNL,542649,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"5,210.3","4,616",298.3,6.07%,6.2,132.7,455.4,85.2,394.3,1.9,"1,478.8",7.1 -Metropolis Healthcare Ltd.,METROPOLIS,542650,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,309.7,233.7,74.8,24.25%,22.2,5.7,48.1,12.5,35.5,6.9,133.4,26 -Polycab India Ltd.,POLYCAB,542652,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"4,253","3,608.8",608.9,14.44%,60.3,26.8,557.2,127.4,425.6,28.4,"1,607.2",107.1 -Multi Commodity Exchange of India Ltd.,MCX,534091,BANKING AND FINANCE,EXCHANGE,184,193.8,-28.7,-17.38%,6.6,0.1,-16.4,1.6,-19.1,-3.7,44.8,8.8 -IIFL Finance Ltd.,IIFL,532636,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,"2,533.7",788.3,"1,600.8",64.66%,43.3,932.1,683.5,158,474.3,12.4,"1,690.7",44.4 -Ratnamani Metals & Tubes Ltd.,RATNAMANI,520111,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"1,141.9",886.3,244.9,21.65%,23.6,10.8,221.1,56.8,163.9,23.4,622.6,88.8 -RHI Magnesita India Ltd.,RHIM,534076,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,989.7,839,147.9,14.98%,44.2,8.5,97.9,26.3,71.3,3.5,-502.2,-24.3 -Birlasoft Ltd.,BSOFT,532400,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,325.4","1,102.7",207.1,15.81%,21.5,5.7,195.5,50.4,145.1,5.2,378.4,13.7 -EIH Ltd.,EIHOTEL,500840,HOTELS RESTAURANTS & TOURISM,HOTELS,552.5,387.6,142.9,26.94%,33.2,5.6,126.1,36.2,93.1,1.5,424.1,6.8 -Affle (India) Ltd.,AFFLE,542752,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,441.2,344.1,87.2,20.22%,18.4,5.5,73.2,6.4,66.8,5,264.3,19.8 -Westlife Foodworld Ltd.,WESTLIFE,505533,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,618,516.5,98.2,15.98%,43.9,27.4,30.2,7.8,22.4,1.4,107.7,6.9 -IndiaMART InterMESH Ltd.,INDIAMART,542726,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,329.3,214.7,80,27.15%,8,2.3,104.3,23.9,69.4,11.4,321.1,53.6 -Infosys Ltd.,INFY,500209,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"39,626","29,554","9,44",24.21%,"1,166",138,"8,768","2,553","6,212",15,"24,871",60.1 -Sterling and Wilson Renewable Energy Ltd.,SWSOLAR,542760,COMMERCIAL SERVICES & SUPPLIES,CONSULTING SERVICES,776.7,758,1.5,0.19%,4.3,64.3,-50,4.6,-54.2,-2.9,-668.4,-35.2 -ABB India Ltd.,ABB,500002,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,846","2,330.7",438.5,15.84%,30.3,0.9,484.2,122.2,362.9,17.1,"1,208.7",57 -Poly Medicure Ltd.,POLYMED,531768,HEALTHCARE EQUIPMENT & SUPPLIES,HEALTHCARE SUPPLIES,351.4,253.1,84.2,24.97%,16,2.2,80.9,18.8,62.2,6.5,233.7,24.4 -GMM Pfaudler Ltd.,GMMPFAUDLR,505255,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,946,795.5,142,15.15%,32.2,21.5,96.8,26.5,71.1,15.8,183.2,40.8 -Gujarat Fluorochemicals Ltd.,FLUOROCHEM,542812,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,960.3,783.7,163.1,17.23%,67.5,34.2,74.8,22.1,52.7,4.8,915.2,83.3 -360 One Wam Ltd.,360ONE,542772,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,617.1,235.6,317.8,57.31%,13.7,139.9,226.8,40.8,186,5.2,696.8,19.5 -Tata Communications Ltd.,TATACOMM,500483,TELECOM SERVICES,OTHER TELECOM SERVICES,"4,897.9","3,857.1","1,015.5",20.84%,605.1,137.4,298.3,77.9,220.7,7.7,"1,322.3",46.4 -Alkyl Amines Chemicals Ltd.,ALKYLAMINE,506767,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,354.5,303.9,48.3,13.71%,12.5,1.7,36.4,9.2,27.2,5.3,171.3,33.5 -CSB Bank Ltd.,CSBBANK,542867,BANKING AND FINANCE,BANKS,835.8,317.5,174.6,25.41%,0,343.6,178,44.8,133.2,7.7,577.7,33.3 -Indian Railway Catering & Tourism Corporation Ltd.,IRCTC,542830,DIVERSIFIED CONSUMER SERVICES,TRAVEL SUPPORT SERVICES,"1,042.4",628.8,366.6,36.83%,14,4.4,395.2,100.5,294.7,3.7,"1,061.2",13.3 -Sumitomo Chemical India Ltd.,SUMICHEM,542920,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,928,715.5,187.9,20.80%,15.8,1.2,195.5,52,143.4,2.9,367.7,7.4 -Century Textiles & Industries Ltd.,CENTURYTEX,500040,COMMERCIAL SERVICES & SUPPLIES,PAPER & PAPER PRODUCTS,"1,114.9","1,069.2",33.8,3.07%,59.2,17,-30.5,-3.3,-30.4,-2.8,117.7,10.5 -SBI Cards and Payment Services Ltd.,SBICARD,543066,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"4,221.4","2,018.8","1,327",32.47%,46.8,604.9,809.4,206.4,603,6.4,"2,302.2",24.3 -Hitachi Energy India Ltd.,POWERINDIA,543187,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"1,228.2","1,162.6",65.3,5.32%,22.5,10.7,32.4,7.6,24.7,5.8,82.5,19.5 -Suven Pharmaceuticals Ltd.,SUVENPHAR,543064,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,250.9,133.1,98,42.40%,11.9,0.5,105.4,25.8,79.6,3.1,431.8,17 -Tata Chemicals Ltd.,TATACHEM,500770,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"4,083","3,179",819,20.49%,234,145,627,120,428,16.8,"2,06",80.8 -Aarti Drugs Ltd.,AARTIDRUGS,524348,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,642.2,565.1,76.4,11.92%,12.6,8.2,56.3,16.7,39.6,4.3,180.2,19.6 -Gujarat Ambuja Exports Ltd.,GAEL,524226,FMCG,EDIBLE OILS,"1,157.7","1,012.2",103.3,9.26%,30.5,5.9,109.1,26.3,82.8,3.6,305.1,13.3 -Polyplex Corporation Ltd.,POLYPLEX,524051,COMMERCIAL SERVICES & SUPPLIES,CONTAINERS & PACKAGING,"1,595.7","1,451.5",120.6,7.67%,75.1,9.9,59.1,10.9,27.9,8.9,71.1,22.6 -Chalet Hotels Ltd.,CHALET,542399,HOTELS RESTAURANTS & TOURISM,HOTELS,318.2,188.6,126,40.04%,35,50.1,44.5,8,36.4,1.8,266.7,13 -Adani Enterprises Ltd.,ADANIENT,512599,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,"23,066","20,087.2","2,430.1",10.79%,757,"1,342.8",791,397.8,227.8,2,"2,444.3",21.4 -YES Bank Ltd.,YESBANK,532648,BANKING AND FINANCE,BANKS,"7,980.6","2,377.1",810,12.06%,0,"4,793.6",304.4,75.7,228.6,0.1,836.6,0.3 -EPL Ltd.,EPL,500135,COMMERCIAL SERVICES & SUPPLIES,CONTAINERS & PACKAGING,"1,011.2",820.6,181,18.07%,83.6,30.6,76.4,25.4,50.5,1.6,251.9,7.9 -Network18 Media & Investments Ltd.,NETWORK18,532798,MEDIA,BROADCASTING & CABLE TV,"2,052.2","2,083.8",-218.3,-11.70%,56.8,66.2,-154.5,-6.5,-61,-0.6,-144.2,-1.4 -CIE Automotive India Ltd.,CIEINDIA,532756,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,299.4","1,934",345.4,15.15%,78.3,31,256.1,69.1,375.4,9.9,298.4,7.9 -Vedanta Ltd.,VEDL,500295,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"39,585","27,466","11,479",29.47%,"2,642","2,523","8,177","9,092","-1,783",-4.8,"5,202",14 -Rossari Biotech Ltd.,ROSSARI,543213,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,484.8,419.9,63.6,13.15%,15.1,5,44.8,11.9,32.9,6,116.8,21.2 -KPIT Technologies Ltd.,KPITTECH,542651,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,208.6",959.2,239.9,20.01%,48.1,13.6,187.7,46.3,140.9,5.2,486.9,18 -Intellect Design Arena Ltd.,INTELLECT,538835,SOFTWARE & SERVICES,IT SOFTWARE PRODUCTS,631.7,497.2,121.9,19.69%,33.7,0.8,96.5,25.7,70.4,5.2,316.6,23.2 -Balaji Amines Ltd.,BALAMINES,530999,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,387.3,326.8,53.8,14.13%,10.8,1.8,48,11.6,34.7,10.7,197.3,60.9 -UTI Asset Management Company Ltd.,UTIAMC,543238,BANKING AND FINANCE,ASSET MANAGEMENT COS.,405.6,172.5,231.5,57.30%,10.4,2.8,219.8,37,182.8,14.4,562.9,44.3 -Mazagon Dock Shipbuilders Ltd.,MAZDOCK,543237,TRANSPORTATION,SHIPPING,"2,079.2","1,651.1",176.6,9.66%,20.2,1.3,406.6,102.8,332.9,16.5,"1,327.6",65.8 -Computer Age Management Services Ltd.,CAMS,543232,BANKING AND FINANCE,CAPITAL MARKETS,284.7,153,122.1,44.39%,17.4,2,112.4,28.6,84.5,17.2,309.2,62.9 -Happiest Minds Technologies Ltd.,HAPPSTMNDS,543227,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,428.8,324,82.6,20.32%,14.6,11.2,79.1,20.7,58.5,3.9,232,15.6 -Triveni Turbine Ltd.,TRITURBINE,533655,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,402.3,313.4,74.3,19.17%,5.1,0.6,83.2,19,64.2,2,233.1,7.3 -Angel One Ltd.,ANGELONE,ASM,BANKING AND FINANCE,CAPITAL MARKETS,"1,049.3",602.6,443.4,42.31%,11.2,26.4,407.2,102.7,304.5,36.3,"1,020.2",121.7 -Tanla Platforms Ltd.,TANLA,532790,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,014.9",811.8,196.8,19.51%,22.6,1.8,178.7,36.2,142.5,10.6,514.7,38.3 -Max Healthcare Institute Ltd.,MAXHEALTH,543220,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,408.6",975.8,387.4,28.42%,57.9,8.5,366.4,89.7,276.7,2.9,990.1,10.2 -Asahi India Glass Ltd.,ASAHIINDIA,515030,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,122.6",934,185.6,16.58%,43,34.4,111.3,30.2,86.9,3.6,343.5,14.1 -Prince Pipes & Fittings Ltd.,PRINCEPIPE,542907,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,660.4,562.3,94.2,14.35%,22.5,0.7,92.8,22.2,70.6,5.2,219.8,19.9 -Route Mobile Ltd.,ROUTE,543228,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,018.3",886.5,128.1,12.63%,21.4,6.5,103.8,15.5,88.8,14.2,365.3,58.3 -KPR Mill Ltd.,KPRMILL,532889,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,533","1,212.9",298,19.72%,46,18.1,256,54.2,201.8,5.9,788.8,23.1 -Infibeam Avenues Ltd.,INFIBEAM,539807,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,792.6,719.7,70.2,8.89%,17.1,0.5,55.2,14.7,41,0.1,142.2,0.5 -Restaurant Brands Asia Ltd.,RBA,543248,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,628.2,568.7,56.2,9.00%,78.6,31.5,-50.7,0,-46,-0.9,-220.3,-4.5 -Larsen & Toubro Ltd.,LT,500510,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"52,157","45,392.1","5,632",11.04%,909.9,864,"4,991.1","1,135.5","3,222.6",22.9,"12,255.3",89.2 -Gland Pharma Ltd.,GLAND,543245,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,426.6","1,049.3",324.1,23.60%,81.3,6,289.9,95.8,194.1,11.8,698.8,42.4 -Macrotech Developers Ltd.,LODHA,543287,REALTY,REALTY,"1,755.1","1,333.5",416.1,23.78%,29.3,123.1,269.2,62.4,201.9,2.1,"1,529.2",15.9 -Poonawalla Fincorp Ltd.,POONAWALLA,524000,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),745.3,178.9,531.7,71.98%,14.7,215.5,"1,124.6",270,860.2,11.2,"1,466.4",19.1 -The Fertilisers and Chemicals Travancore Ltd.,FACT,590024,FERTILIZERS,FERTILIZERS,"1,713.6","1,530.8",132.4,7.96%,5.3,61.2,105.2,0,105.2,1.6,508.4,7.9 -Home First Finance Company India Ltd.,HOMEFIRST,543259,BANKING AND FINANCE,HOUSING FINANCE,278,53.7,211.6,77.43%,2.8,117,96.4,22.1,74.3,8.4,266.2,30.2 -CG Power and Industrial Solutions Ltd.,CGPOWER,500093,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,019","1,692.9",308.6,15.42%,22.9,0.4,329.9,86.2,242.3,1.6,"1,1",7.2 -Laxmi Organic Industries Ltd.,LXCHEM,543277,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,660.5,613.3,38.9,5.97%,27.5,2.1,17.5,6.8,10.7,0.4,100.6,3.8 -Anupam Rasayan India Ltd.,ANURAS,543275,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,395.6,284.7,107.5,27.41%,19.8,20.4,70.7,22,40.7,3.8,178.9,16.6 -Kalyan Jewellers India Ltd.,KALYANKJIL,ASM,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"4,427.7","4,100.9",313.7,7.11%,66.9,81.7,178.1,43.3,135.2,1.3,497.9,4.8 -Jubilant Pharmova Ltd.,JUBLPHARMA,530019,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,690.2","1,438.5",241.8,14.39%,96.6,66.1,89,35.9,62.5,3.9,-44.6,-2.8 -Indigo Paints Ltd.,INDIGOPNTS,543258,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,273.4,228.7,41.8,15.45%,10,0.5,34.3,8.2,26.1,5.5,132.4,27.8 -Indian Railway Finance Corporation Ltd.,IRFC,543257,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"6,767.5",33.5,"6,732.4",99.50%,2.1,"5,181.5","1,549.9",0,"1,549.9",1.2,"6,067.6",4.6 -Mastek Ltd.,MASTEK,523704,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,770.4,642.5,123,16.07%,20.9,12.6,90.3,25,62.8,20.5,269.7,88 -Equitas Small Finance Bank Ltd.,EQUITASBNK,543243,BANKING AND FINANCE,BANKS,"1,540.4",616.8,330.2,24.30%,0,593.4,267,68.9,198.1,1.8,749.5,6.7 -Tata Teleservices (Maharashtra) Ltd.,TTML,532371,TELECOM SERVICES,TELECOM SERVICES,288.6,159.3,127.5,44.45%,36.3,403.2,-310.2,0,-310.2,-1.6,"-1,168.3",-6 -Praj Industries Ltd.,PRAJIND,522205,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,893.3,798.4,84,9.52%,9.1,1,84.8,22.4,62.4,3.4,271.4,14.8 -Nazara Technologies Ltd.,NAZARA,543280,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,309.5,269.4,26.7,8.98%,15.1,2.7,21.2,-1.3,19.8,3,60,9.1 -Jubilant Ingrevia Ltd.,JUBLINGREA,543271,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,028.5",902.3,117.7,11.54%,33.9,12.5,79.8,22.4,57.5,3.6,258.9,16.4 -Sona BLW Precision Forgings Ltd.,SONACOMS,543300,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,796.9,567.5,223.3,28.24%,53.4,6,164.1,40.1,123.8,2.1,462.8,7.9 -Chemplast Sanmar Ltd.,CHEMPLASTS,543336,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,025",941.8,46,4.65%,35.3,38.6,9.2,-16.8,26.1,1.6,35.3,2.2 -Aptus Value Housing Finance India Ltd.,APTUS,543335,BANKING AND FINANCE,HOUSING FINANCE,344.5,50.6,277.5,83.18%,2.6,96.1,189.6,41.5,148,3,551.1,11.1 -Clean Science & Technology Ltd.,CLEAN,543318,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,187.1,106.3,74.8,41.32%,11.1,0.3,69.5,17.3,52.2,4.9,275.5,25.9 -Medplus Health Services Ltd.,MEDPLUS,543427,HEALTHCARE EQUIPMENT & SUPPLIES,HEALTHCARE SUPPLIES,"1,419","1,323.5",85.1,6.04%,55.5,23.5,16.4,1.9,14.6,1.2,58.3,4.9 -Nuvoco Vistas Corporation Ltd.,NUVOCO,543334,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,578.9","2,243",329.9,12.82%,225.6,139.9,-29.6,-31.1,1.5,0,141.8,4 -Star Health and Allied Insurance Company Ltd.,STARHEALTH,543412,BANKING AND FINANCE,GENERAL INSURANCE,"3,463.2","3,295.8",165.7,4.79%,0,0,167.1,41.8,125.3,2.1,725.4,12.4 -Go Fashion (India) Ltd.,GOCOLORS,543401,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,192.8,132.2,56.6,29.98%,25.8,8.9,25.8,5.7,20,3.7,85.4,15.8 -PB Fintech Ltd.,POLICYBZR,543390,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,909.1,900.7,-89.1,-10.98%,22.3,7.2,-21.1,-0.3,-20.2,-0.5,-127.9,-2.8 -FSN E-Commerce Ventures Ltd.,NYKAA,543384,SOFTWARE & SERVICES,INTERNET & CATALOGUE RETAIL,"1,515.6","1,426.4",80.6,5.35%,54.6,21.3,13.3,4,5.8,0,19.8,0.1 -Krishna Institute of Medical Sciences Ltd.,KIMS,543308,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,655.4,475.2,177.3,27.17%,32.6,8.9,138.6,37.3,92,11.5,342.1,42.7 -Zomato Ltd.,ZOMATO,543320,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"3,06","2,895",-47,-1.65%,128,16,21,-15,36,0,-496.8,-0.6 -Brightcom Group Ltd.,BCG,532368,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,690.5","1,172.3",518,30.65%,72.3,0.1,445.8,124.3,321.5,1.6,"1,415.2",7 -Shyam Metalics and Energy Ltd.,SHYAMMETL,543299,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"2,978.9","2,633.6",307.1,10.44%,176.5,35.4,133.4,-348.6,484.1,18.9,"1,049.9",41.2 -G R Infraprojects Ltd.,GRINFRA,543317,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,909.2","1,415.7",467.1,24.81%,61.7,144.6,287.1,69.9,217.2,22.5,"1,240.3",128.3 -RattanIndia Enterprises Ltd.,RTNINDIA,534597,UTILITIES,ELECTRIC UTILITIES,"1,618.1","1,392.8",1.5,0.11%,4.3,28.8,142.2,1.7,140.9,1,147.6,1.1 -Borosil Renewables Ltd.,BORORENEW,502219,CONSUMER DURABLES,HOUSEWARE,406.3,369.2,32.5,8.09%,31,9.6,28.9,-1.1,25.1,1.9,32.1,2.5 -HLE Glascoat Ltd.,HLEGLAS,522215,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,227.8,198,26.5,11.79%,6.1,5.8,16.1,5.3,10,1.6,54.4,8 -Tata Investment Corporation Ltd.,TATAINVEST,501301,DIVERSIFIED,HOLDING COMPANIES,125,10.1,113.8,91.88%,0.2,4.7,110.1,-1.3,124.4,24.6,326.1,64.4 -Sapphire Foods India Ltd.,SAPPHIRE,543397,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,650.1,527.5,115.1,17.91%,76.8,24.5,21.4,6.2,15.3,2.4,208.5,32.7 -Devyani International Ltd.,DEVYANI,543330,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,826,665,154.4,18.84%,86.3,41.7,19,-16.8,33.4,0.3,177.5,1.5 -Vijaya Diagnostic Centre Ltd.,VIJAYA,543350,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,145.6,81.5,57.4,41.31%,13.7,5.9,44.6,11,33.3,3.3,103.4,10.1 -C.E. Info Systems Ltd.,MAPMYINDIA,543425,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,99.3,50.1,41,44.98%,3.7,0.7,44.7,11.1,33,6.1,122.9,22.7 -Latent View Analytics Ltd.,LATENTVIEW,543398,SOFTWARE & SERVICES,DATA PROCESSING SERVICES,172.7,124.9,30.8,19.78%,2.3,0.8,44.7,10.6,34,1.7,153.6,7.5 -Metro Brands Ltd.,METROBRAND,543426,RETAILING,FOOTWEAR,571.9,400.3,155.4,27.96%,57.2,19.7,94.7,27.5,66.7,2.5,340,12.5 -Easy Trip Planners Ltd.,EASEMYTRIP,543272,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,144.6,76.9,64.8,45.71%,1,2,64.7,17.7,47.2,0.3,146,0.8 -Shree Renuka Sugars Ltd.,RENUKA,532670,FOOD BEVERAGES & TOBACCO,SUGAR,"2,564.7","2,491",63.7,2.49%,64.1,216.8,-207.2,-1.6,-204.9,-1,-286,-1.3 -One97 Communications Ltd.,PAYTM,543396,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"2,662.5","2,749.6",-231,-9.17%,180.1,7,-279.9,12.7,-290.5,-5,"-1,207.9",-19 -MTAR Technologies Ltd.,MTARTECH,543270,GENERAL INDUSTRIALS,DEFENCE,167.7,130.7,36.1,21.64%,5.8,5.5,25.7,5.2,20.5,6.7,103.3,33.6 -Capri Global Capital Ltd.,CGCL,531595,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),557.4,229.3,304.8,54.70%,23.1,195.8,86,20.8,65.2,3.2,231.2,11.2 -GMR Airports Infrastructure Ltd.,GMRINFRA,ASM,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"2,185","1,336.8",726.7,35.22%,373,695.8,-252,54.9,-91,-0.1,-370.9,-0.6 -Triveni Engineering & Industries Ltd.,TRIVENI,532356,FOOD BEVERAGES & TOBACCO,SUGAR,"1,629.7","1,554.5",62.9,3.89%,25.8,10.2,39.3,10.1,29.1,1.3,434.3,19.8 -Delhivery Ltd.,DELHIVERY,543529,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"2,043","1,957.3",-15.6,-0.80%,171.2,19.6,-105.2,-2.1,-102.9,-1.4,-546.7,-7.5 -Life Insurance Corporation of India,LICI,543526,BANKING AND FINANCE,LIFE INSURANCE,"202,394.9","193,612.5","8,445",4.18%,0,0,"8,696.5","1,083.9","8,030.3",12.7,"37,204.8",58.8 -Campus Activewear Ltd.,CAMPUS,543523,RETAILING,FOOTWEAR,259.1,234.2,24.5,9.46%,18.1,6.5,0.4,0.1,0.3,0,103.1,3.4 -Motherson Sumi Wiring India Ltd.,MSUMI,543498,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,110.2","1,856.5",248.1,11.79%,36.4,7.4,210,54.1,155.9,0.3,523.6,1.2 -Olectra Greentech Ltd.,OLECTRA,532439,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,310.3,266.6,40.5,13.20%,8.8,9.7,25.2,8,18.6,2.2,78.5,9.6 -Patanjali Foods Ltd.,PATANJALI,500368,FMCG,EDIBLE OILS,"7,845.8","7,426.6",395.3,5.05%,60.1,24,335.1,80.5,254.5,7,875.2,24.2 -Raymond Ltd.,RAYMOND,500330,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,320.7","1,938.8",314.6,13.96%,65.4,89.3,204.2,50.7,159.8,24,"1,514.2",227.5 -Swan Energy Ltd.,SWANENERGY,503310,REALTY,REALTY,"1,230.1",966.3,257,21.01%,27.1,58.3,178.4,12.8,84.6,6.7,308.4,11.7 -Samvardhana Motherson International Ltd.,MOTHERSON,517334,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"23,639.2","21,585","1,888.8",8.05%,867.4,487.9,449.5,229.2,201.6,0.3,"1,910.3",2.8 -Vedant Fashions Ltd.,MANYAVAR,543463,RETAILING,SPECIALTY RETAIL,233.4,125.5,92.8,42.51%,32.5,10.7,64.8,16.1,48.7,2,399.9,16.5 -Adani Wilmar Ltd.,AWL,543458,FMCG,EDIBLE OILS,"12,331.2","12,123.5",143.7,1.17%,95.7,220.2,-161.8,-31.5,-130.7,-1,130.1,1 -Mahindra Lifespace Developers Ltd.,MAHLIFE,532313,REALTY,REALTY,25.7,52.7,-34.9,-196.45%,3.1,0.2,-30.3,-10.8,-18.9,-1.2,10.5,0.7 -Tejas Networks Ltd.,TEJASNET,540595,TELECOM SERVICES,OTHER TELECOM SERVICES,413.9,383,13,3.28%,41.7,7,-17.7,-5.1,-12.6,-0.7,-61.3,-3.5 -Aether Industries Ltd.,AETHER,543534,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,178.3,118.2,46,28.00%,9.7,1.6,48.7,12.1,36.7,2.8,139.1,10.5 -JBM Auto Ltd.,JBMA,ASM,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,238.8","1,091.3",139.7,11.35%,41.2,47.9,58.3,11.3,44.2,3.7,136.8,11.6 -Deepak Fertilisers & Petrochemicals Corporation Ltd.,DEEPAKFERT,500645,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"2,443.2","2,138.1",286.1,11.80%,81.2,107.1,116.8,53.3,60.1,4.8,674.5,53.4 -Sharda Cropchem Ltd.,SHARDACROP,538666,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,604.3,559.6,21.2,3.65%,74,4.6,-33.8,-6.3,-27.6,-3.1,191,21.2 -Shoppers Stop Ltd.,SHOPERSTOP,532638,RETAILING,DEPARTMENT STORES,"1,049.7",878.2,160.9,15.49%,108.2,54.9,3.5,0.8,2.7,0.2,94.2,8.6 -BEML Ltd.,BEML,500048,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,924,855.3,61.5,6.70%,15.8,10.8,42.2,-9.6,51.8,12.4,200.8,48.2 -Lemon Tree Hotels Ltd.,LEMONTREE,541233,HOTELS RESTAURANTS & TOURISM,HOTELS,230.1,125.3,101.9,44.84%,22.6,47.3,34.8,8.6,22.6,0.3,130.1,1.6 -Rainbow Childrens Medicare Ltd.,RAINBOW,543524,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,340.5,215.1,117.6,35.34%,26.8,13.3,85.2,22.1,62.9,6.2,215.4,21.2 -UCO Bank,UCOBANK,532505,BANKING AND FINANCE,BANKS,"5,865.6","1,581.5",981.9,18.81%,0,"3,302.3",639.8,238.1,403.5,0.3,"1,84",1.5 -Piramal Pharma Ltd.,PPLPHARMA,543635,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,960.6","1,645.7",265.6,13.90%,184.5,109.9,20.4,34.5,5,0,-133.6,-1 -KSB Ltd.,KSB,500249,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,572.2,493.4,70.3,12.47%,12.3,2,64.5,17.1,50.1,14.4,209.7,60.3 -Data Patterns (India) Ltd.,DATAPATTNS,543428,GENERAL INDUSTRIALS,DEFENCE,119.2,67.5,40.8,37.63%,3.1,2.3,46.3,12.5,33.8,6,148.3,26.5 -Global Health Ltd.,MEDANTA,543654,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,864.7,631.1,212.9,25.22%,42.9,20.1,170.6,45.4,125.2,4.7,408.9,15.2 -Aarti Industries Ltd.,AARTIIND,524208,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,454","1,221.2",232.8,16.01%,93,58.2,81.6,-9.1,90.7,2.5,446.2,12.3 -BLS International Services Ltd.,BLS,540073,DIVERSIFIED CONSUMER SERVICES,TRAVEL SUPPORT SERVICES,416.4,321,86.7,21.27%,7.3,1,87.2,5.2,78.7,1.9,267.6,6.5 -Archean Chemical Industries Ltd.,ACI,543657,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,301.7,195,95.5,32.86%,17.5,1.9,87.3,21.3,66,5.4,394.4,32.1 -Adani Power Ltd.,ADANIPOWER,ASM,UTILITIES,ELECTRIC UTILITIES,"14,935.7","7,819.2","5,171.4",39.81%,"1,004.5",888.4,"5,223.6","-1,370.6","6,594.2",16.5,"20,604.8",53.4 -Craftsman Automation Ltd.,CRAFTSMAN,543276,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,183.8",941.6,237.5,20.14%,66.8,41.6,133.8,29.6,94.5,44.1,298.3,141.2 -NMDC Ltd.,NMDC,526371,METALS & MINING,MINING,"4,335","2,823.6","1,190.4",29.66%,88.8,18.6,"1,404.1",379,"1,026.2",3.5,"5,862.2",20 -Epigral Ltd.,EPIGRAL,543332,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,479.1,370.2,107.9,22.57%,31.5,21.3,56.1,17.9,38,9.1,223.4,53.8 -Apar Industries Ltd.,APARINDS,532259,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"3,944.7","3,576.2",349.8,8.91%,28.2,103.1,237.3,62.9,173.9,45.4,783.9,204.8 -Bikaji Foods International Ltd.,BIKAJI,543653,FMCG,PACKAGED FOODS,614.7,521,87.7,14.41%,15.6,2.9,75.2,15.4,61.2,2.5,173.6,6.9 -Five-Star Business Finance Ltd.,FIVESTAR,543663,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),522.4,133.2,375,72.28%,5.7,105.9,267,67.6,199.4,6.8,703,24.1 -Ingersoll-Rand (India) Ltd.,INGERRAND,500210,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,282.8,210.7,65.7,23.76%,4.6,0.6,67,17.2,49.7,15.8,218.5,69.2 -KFIN Technologies Ltd.,KFINTECH,543720,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,215.3,115.3,93.7,44.82%,12.6,3.2,84.2,22.3,61.4,3.6,215.1,12.6 -Piramal Enterprises Ltd.,PEL,500302,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"2,205.2","1,320.1","1,117.9",50.97%,38.3,"1,038.9",-11.8,10.7,48.2,2,"3,906.5",173.9 -NMDC Steel Ltd.,NSLNISP,543768,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,290.3,349.6,-72.2,-26.04%,74.5,40.8,-174.7,-43.6,-131.1,-0.5,, -Eris Lifesciences Ltd.,ERIS,540596,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,508.8,324.2,181.1,35.85%,42.1,16.3,126.2,3.9,123.4,9.1,385.6,28.3 -Mankind Pharma Ltd.,MANKIND,543904,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,768.1","2,025.5",682.6,25.21%,96.5,8.6,637.5,129.8,501,12.5,"1,564.8",39.1 -Kaynes Technology India Ltd.,KAYNES,ASM,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,369.8,312.1,48.8,13.52%,6.5,11.8,39.4,7.1,32.3,5.5,143.2,24.6 -Safari Industries (India) Ltd.,SAFARI,523025,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,372.9,306.6,63.5,17.15%,12.2,2.2,51.9,12.1,39.8,16.7,162.3,68.2 -Saregama India Ltd.,SAREGAMA,532163,MEDIA,MOVIES & ENTERTAINMENT,185.6,111.5,60.9,35.32%,8.2,0.2,65.6,17.6,48.1,2.5,193.4,10 -Syrma SGS Technology Ltd.,SYRMA,543573,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,720.6,662.7,49,6.88%,11.6,8,37,6.4,28.3,1.6,132.4,7.5 -Jindal Saw Ltd.,JINDALSAW,ASM,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"5,488.9","4,662",804.2,14.71%,142.5,188.7,495.6,139.6,375.7,11.8,"1,135.8",35.5 -Godawari Power & Ispat Ltd.,GPIL,532734,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"1,314.2",929.6,361.4,28.00%,34.8,10.2,339.6,86.1,256.9,20.6,785.5,63 -Gillette India Ltd.,GILLETTE,507815,FMCG,PERSONAL PRODUCTS,676.2,530.8,136.7,20.48%,20.1,0.1,125.2,32.5,92.7,28.4,361.6,111 -Symphony Ltd.,SYMPHONY,517385,CONSUMER DURABLES,CONSUMER ELECTRONICS,286,234,41,14.91%,7,2,43,8,35,5.1,114,16.5 -Glenmark Life Sciences Ltd.,GLS,543322,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,600.7,428.3,167.1,28.06%,13.1,0.4,158.9,40.2,118.7,9.7,505.5,41.3 -Usha Martin Ltd.,USHAMART,517146,METALS & MINING,IRON & STEEL PRODUCTS,806,640.4,144.3,18.39%,18,6.4,141.2,35,109.5,3.6,399.4,13.1 -Ircon International Ltd.,IRCON,541956,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"3,136.3","2,771.2",215.7,7.22%,27.1,36.9,301.2,77.6,250.7,2.7,884.6,9.4 -Ujjivan Small Finance Bank Ltd.,UJJIVANSFB,542904,BANKING AND FINANCE,BANKS,"1,579.8",528.6,483.4,34.75%,0,567.8,436.4,108.7,327.7,1.7,"1,254.5",6.4 -Procter & Gamble Health Ltd.,PGHL,500126,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,311,216.3,88.7,29.08%,6.5,0.2,88,22.5,65.6,39.5,231.4,139.4 -Allcargo Logistics Ltd.,ALLCARGO,532749,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"3,336.3","3,188.8",118,3.57%,106.7,36.7,14.2,1.3,21.8,0.9,361.9,14.7 -Sheela Foam Ltd.,SFL,540203,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,637.6,547,66.2,10.80%,21.9,8.6,60.2,15.6,44,4.5,192.4,17.7 -Alok Industries Ltd.,ALOKINDS,521070,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,369.3","1,323.1",35.9,2.64%,78.6,142.2,-174.6,0,-174.8,-0.3,-948.4,-1.9 -Minda Corporation Ltd.,MINDACORP,538962,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,197.9","1,064.5",131.3,10.98%,41.4,14.9,77,18.7,58.8,2.5,278.2,11.6 -Concord Biotech Ltd.,CONCORDBIO,543960,PHARMACEUTICALS & BIOTECHNOLOGY,BIOTECHNOLOGY,270.5,143.2,119.2,45.43%,13.3,0.8,113.2,28.7,81,7.7,, \ No newline at end of file diff --git a/sdk/ai/ai-projects/data/sampleFileForUpload.txt b/sdk/ai/ai-projects/data/sampleFileForUpload.txt deleted file mode 100644 index ab553b3304c1..000000000000 --- a/sdk/ai/ai-projects/data/sampleFileForUpload.txt +++ /dev/null @@ -1 +0,0 @@ -The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457. diff --git a/sdk/ai/ai-projects/data/weatherOpenApi.json b/sdk/ai/ai-projects/data/weatherOpenApi.json deleted file mode 100644 index df0192590adb..000000000000 --- a/sdk/ai/ai-projects/data/weatherOpenApi.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "openapi": "3.1.0", - "info": { - "title": "get weather data", - "description": "Retrieves current weather data for a location based on wttr.in.", - "version": "v1.0.0" - }, - "servers": [ - { - "url": "https://wttr.in" - } - ], - "auth": [], - "paths": { - "/{location}": { - "get": { - "description": "Get weather information for a specific location", - "operationId": "GetCurrentWeather", - "parameters": [ - { - "name": "location", - "in": "path", - "description": "City or location to retrieve the weather for", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "format", - "in": "query", - "description": "Always use j1 value for this parameter", - "required": true, - "schema": { - "type": "string", - "default": "j1" - } - } - ], - "responses": { - "200": { - "description": "Successful response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "Location not found" - } - }, - "deprecated": false - } - } - }, - "components": { - "schemes": {} - } -} \ No newline at end of file diff --git a/sdk/ai/ai-projects/eslint.config.mjs b/sdk/ai/ai-projects/eslint.config.mjs deleted file mode 100644 index 52be04401c47..000000000000 --- a/sdk/ai/ai-projects/eslint.config.mjs +++ /dev/null @@ -1,17 +0,0 @@ -import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; - -export default azsdkEslint.config([ - { - rules: { - "@azure/azure-sdk/ts-modules-only-named": "warn", - }, - }, - { - files: ["**/*.ts", "**/*.cts", "**/*.mts"], - languageOptions: { - parserOptions: { - project: ["./tsconfig.test.json"], - }, - }, - }, -]); diff --git a/sdk/ai/ai-projects/package.json b/sdk/ai/ai-projects/package.json deleted file mode 100644 index a06af525e2bb..000000000000 --- a/sdk/ai/ai-projects/package.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "name": "@azure/ai-projects", - "version": "1.0.0-beta.5", - "description": "A generated SDK for ProjectsClient.", - "engines": { - "node": ">=18.0.0" - }, - "sideEffects": false, - "autoPublish": false, - "tshy": { - "exports": { - "./package.json": "./package.json", - ".": "./src/index.ts" - }, - "dialects": [ - "esm", - "commonjs" - ], - "esmDialects": [ - "browser", - "react-native" - ], - "selfLink": false, - "project": "./tsconfig.src.json" - }, - "type": "module", - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "files": [ - "dist", - "README.md", - "LICENSE" - ], - "sdk-type": "client", - "repository": "github:Azure/azure-sdk-for-js", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", - "//metadata": { - "constantPaths": [ - { - "path": "src/generated/src/projectsClient.ts", - "prefix": "userAgentInfo" - }, - { - "path": "src/constants.ts", - "prefix": "SDK_VERSION" - } - ] - }, - "dependencies": { - "@azure-rest/core-client": "^2.1.0", - "@azure/abort-controller": "^2.1.2", - "@azure/core-auth": "^1.6.0", - "@azure/core-rest-pipeline": "^1.5.0", - "@azure/core-util": "^1.9.0", - "@azure/logger": "^1.1.4", - "@azure/core-lro": "^3.0.0", - "tslib": "^2.6.2", - "@azure/core-paging": "^1.5.0", - "@azure/core-sse": "^2.1.3", - "@azure/core-tracing": "^1.2.0" - }, - "devDependencies": { - "@azure/dev-tool": "^1.0.0", - "@azure/eslint-plugin-azure-sdk": "^3.0.0", - "@azure/identity": "^4.3.0", - "@azure/opentelemetry-instrumentation-azure-sdk": "^1.0.0-beta.7", - "@azure/monitor-opentelemetry-exporter": "^1.0.0-beta.31", - "@azure-tools/test-credential": "^2.0.0", - "@azure-tools/test-recorder": "^4.1.0", - "@azure-tools/test-utils-vitest": "^1.0.0", - "@opentelemetry/api": "^1.9.0", - "@opentelemetry/instrumentation": "0.57.0", - "@opentelemetry/sdk-trace-node": "^1.30.0", - "@vitest/browser": "^3.0.9", - "@vitest/coverage-istanbul": "^3.0.9", - "@types/node": "^18.0.0", - "dotenv": "^16.0.0", - "eslint": "^9.9.0", - "prettier": "^3.2.5", - "playwright": "^1.41.2", - "typescript": "~5.8.2", - "vitest": "^3.0.9" - }, - "scripts": { - "build": "npm run clean && dev-tool run build-package && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", - "build:samples": "echo skipped", - "build:test": "npm run clean && dev-tool run build-package && dev-tool run build-test", - "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"samples-dev/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", - "clean": "dev-tool run vendored rimraf --glob dist dist-* test-dist temp types *.tgz *.log", - "copy:yaml": "copy tsp-location.yaml .\\src\\generated\\tsp-location.yaml", - "execute:samples": "dev-tool samples run samples-dev", - "extract-api": "dev-tool run vendored rimraf review && dev-tool run vendored mkdirp ./review && dev-tool run extract-api", - "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"samples-dev/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\" ", - "generate": "dev-tool run vendored rimraf ./src/generated && dev-tool run vendored mkdirp ./src/generated && npm run copy:yaml && npm run tsp:update && dev-tool run vendored rimraf ./src/generated/test && dev-tool run vendored rimraf ./src/generated/tsp-location.yaml", - "integration-test": "npm run integration-test:node && npm run integration-test:browser", - "integration-test:browser": "npm run unit-test:browser --no-test-proxy", - "integration-test:node": "npm run unit-test:node --no-test-proxy", - "lint": "eslint package.json api-extractor.json src test", - "lint:fix": "eslint package.json api-extractor.json src test --fix --fix-type [problem,suggestion]", - "pack": "npm pack 2>&1", - "test": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run unit-test:browser && npm run integration-test", - "test:browser": "npm run clean && npm run unit-test:browser && npm run integration-test:browser", - "test:node": "npm run clean && dev-tool run build-package && npm run unit-test:node && npm run integration-test:node", - "tsp:update": "tsp-client update -o ./src/generated", - "unit-test": "npm run unit-test:node && npm run unit-test:browser", - "unit-test:browser": "npm run build:test && dev-tool run test:vitest --browser", - "unit-test:node": "dev-tool run test:vitest", - "update-snippets": "dev-tool run update-snippets", - "generate-samples": "dev-tool samples publish -f" - }, - "exports": { - "./package.json": "./package.json", - ".": { - "browser": { - "types": "./dist/browser/index.d.ts", - "default": "./dist/browser/index.js" - }, - "react-native": { - "types": "./dist/react-native/index.d.ts", - "default": "./dist/react-native/index.js" - }, - "import": { - "types": "./dist/esm/index.d.ts", - "default": "./dist/esm/index.js" - }, - "require": { - "types": "./dist/commonjs/index.d.ts", - "default": "./dist/commonjs/index.js" - } - } - }, - "//sampleConfiguration": { - "productName": "Azure AI Projects", - "productSlugs": [ - "azure" - ], - "extraFiles": { - "./data": [ - "javascript/data", - "typescript/data" - ] - }, - "apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/ai-projects" - }, - "main": "./dist/commonjs/index.js", - "types": "./dist/commonjs/index.d.ts", - "module": "./dist/esm/index.js" -} diff --git a/sdk/ai/ai-projects/review/ai-projects.api.md b/sdk/ai/ai-projects/review/ai-projects.api.md deleted file mode 100644 index a4a17c55fd7b..000000000000 --- a/sdk/ai/ai-projects/review/ai-projects.api.md +++ /dev/null @@ -1,2230 +0,0 @@ -## API Report File for "@azure/ai-projects" - -> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). - -```ts - -import type { ClientOptions } from '@azure-rest/core-client'; -import type { OperationOptions } from '@azure-rest/core-client'; -import type { OperationState } from '@azure/core-lro'; -import type { PollerLike } from '@azure/core-lro'; -import { StreamableMethod } from '@azure-rest/core-client'; -import type { TokenCredential } from '@azure/core-auth'; - -// @public -export interface AgentDeletionStatusOutput { - deleted: boolean; - id: string; - object: "assistant.deleted"; -} - -// @public -export interface AgentEventMessage { - data: AgentEventStreamDataOutput; - event: AgentStreamEventType | string; -} - -// @public -export interface AgentEventMessageStream extends AsyncDisposable, AsyncIterable { -} - -// @public -export type AgentEventStreamDataOutput = AgentThreadOutput | ThreadRunOutput | RunStepOutput | ThreadMessageOutput | MessageDeltaChunk | RunStepDeltaChunk | string; - -// @public -export interface AgentOutput { - createdAt: Date; - description: string | null; - id: string; - instructions: string | null; - metadata: Record | null; - model: string; - name: string | null; - object: "assistant"; - responseFormat?: AgentsApiResponseFormatOptionOutput | null; - temperature: number | null; - toolResources: ToolResourcesOutput | null; - tools: Array; - topP: number | null; -} - -// @public -export type AgentRunResponse = PromiseLike & { - stream: () => Promise; -}; - -// @public -export interface AgentsApiResponseFormat { - type?: ResponseFormat; -} - -// @public -export type AgentsApiResponseFormatMode = string; - -// @public -export type AgentsApiResponseFormatModeOutput = string; - -// @public -export type AgentsApiResponseFormatOption = string | AgentsApiResponseFormatMode | AgentsApiResponseFormat | ResponseFormatJsonSchemaType; - -// @public -export type AgentsApiResponseFormatOptionOutput = string | AgentsApiResponseFormatModeOutput | AgentsApiResponseFormatOutput | ResponseFormatJsonSchemaTypeOutput; - -// @public -export interface AgentsApiResponseFormatOutput { - type?: ResponseFormatOutput; -} - -// @public -export type AgentsApiToolChoiceOption = string | AgentsApiToolChoiceOptionMode | AgentsNamedToolChoice; - -// @public -export type AgentsApiToolChoiceOptionMode = string; - -// @public -export type AgentsApiToolChoiceOptionModeOutput = string; - -// @public -export type AgentsApiToolChoiceOptionOutput = string | AgentsApiToolChoiceOptionModeOutput | AgentsNamedToolChoiceOutput; - -// @public -export interface AgentsNamedToolChoice { - function?: FunctionName; - type: AgentsNamedToolChoiceType; -} - -// @public -export interface AgentsNamedToolChoiceOutput { - function?: FunctionNameOutput; - type: AgentsNamedToolChoiceTypeOutput; -} - -// @public -export type AgentsNamedToolChoiceType = string; - -// @public -export type AgentsNamedToolChoiceTypeOutput = string; - -// @public -export interface AgentsOperations { - cancelRun: (threadId: string, runId: string, options?: CancelRunOptionalParams) => Promise; - cancelVectorStoreFileBatch: (vectorStoreId: string, batchId: string, options?: CancelVectorStoreFileBatchOptionalParams) => Promise; - createAgent: (model: string, options?: CreateAgentOptionalParams) => Promise; - createMessage: (threadId: string, messageOptions: ThreadMessageOptions, options?: CreateMessageOptionalParams) => Promise; - createRun: (threadId: string, assistantId: string, options?: CreateRunOptionalParams) => AgentRunResponse; - createThread: (options?: CreateAgentThreadOptionalParams) => Promise; - createThreadAndRun: (assistantId: string, options?: CreateAndRunThreadOptionalParams) => AgentRunResponse; - createVectorStore: (options?: CreateVectorStoreOptionalParams) => PollerLike, VectorStoreOutput>; - createVectorStoreAndPoll: (options?: CreateVectorStoreOptionalParams) => PollerLike, VectorStoreOutput>; - createVectorStoreFile: (vectorStoreId: string, options?: CreateVectorStoreFileOptionalParams) => PollerLike, VectorStoreFileOutput>; - createVectorStoreFileAndPoll: (vectorStoreId: string, options?: CreateVectorStoreFileOptionalParams) => PollerLike, VectorStoreFileOutput>; - createVectorStoreFileBatch: (vectorStoreId: string, options?: CreateVectorStoreFileBatchOptionalParams) => PollerLike, VectorStoreFileBatchOutput>; - createVectorStoreFileBatchAndPoll: (vectorStoreId: string, options?: CreateVectorStoreFileBatchOptionalParams) => PollerLike, VectorStoreFileBatchOutput>; - deleteAgent: (assistantId: string, options?: DeleteAgentOptionalParams) => Promise; - deleteFile: (fileId: string, options?: DeleteFileOptionalParams) => Promise; - deleteThread: (threadId: string, options?: DeleteAgentThreadOptionalParams) => Promise; - deleteVectorStore: (vectorStoreId: string, options?: DeleteVectorStoreOptionalParams) => Promise; - deleteVectorStoreFile: (vectorStoreId: string, fileId: string, options?: DeleteVectorStoreFileOptionalParams) => Promise; - getAgent: (assistantId: string, options?: GetAgentOptionalParams) => Promise; - getFile: (fileId: string, options?: GetFileOptionalParams) => Promise; - getFileContent: (fileId: string, options?: GetFileContentOptionalParams) => StreamableMethod; - getRun: (threadId: string, runId: string, options?: GetRunOptionalParams) => Promise; - getRunStep: (threadId: string, runId: string, stepId: string, options?: GetRunStepOptionalParams) => Promise; - getThread: (threadId: string, options?: GetAgentThreadOptionalParams) => Promise; - getVectorStore: (vectorStoreId: string, options?: GetVectorStoreOptionalParams) => Promise; - getVectorStoreFile: (vectorStoreId: string, fileId: string, options?: GetVectorStoreFileOptionalParams) => Promise; - getVectorStoreFileBatch: (vectorStoreId: string, batchId: string, options?: GetVectorStoreFileBatchOptionalParams) => Promise; - listAgents: (options?: ListAgentsOptionalParams) => Promise; - listFiles: (options?: ListFilesOptionalParams) => Promise; - listMessages: (threadId: string, options?: ListMessagesOptionalParams) => Promise; - listRuns: (threadId: string, options?: ListRunQueryOptionalParams) => Promise; - listRunSteps: (threadId: string, runId: string, options?: ListRunQueryOptionalParams) => Promise; - listThreads: (options?: ListAgentThreadOptionalParams) => Promise; - listVectorStoreFileBatchFiles: (vectorStoreId: string, batchId: string, options?: ListVectorStoreFileBatchFilesOptionalParams) => Promise; - listVectorStoreFiles: (vectorStoreId: string, options?: ListVectorStoreFilesOptionalParams) => Promise; - listVectorStores: (options?: ListVectorStoresOptionalParams) => Promise; - modifyVectorStore: (vectorStoreId: string, options?: UpdateVectorStoreOptionalParams) => Promise; - submitToolOutputsToRun: (threadId: string, runId: string, toolOutputs: Array, options?: SubmitToolOutputsToRunOptionalParams) => AgentRunResponse; - updateAgent: (assistantId: string, options: UpdateAgentOptionalParams) => Promise; - updateMessage: (threadId: string, messageId: string, options?: UpdateMessageOptionalParams) => Promise; - updateRun: (threadId: string, runId: string, options?: UpdateRunOptionalParams) => Promise; - updateThread: (threadId: string, options?: UpdateAgentThreadOptionalParams) => Promise; - uploadFile: (data: ReadableStream | NodeJS.ReadableStream, purpose: FilePurpose, options?: UploadFileOptionalParams) => PollerLike, OpenAIFileOutput>; - uploadFileAndPoll: (data: ReadableStream | NodeJS.ReadableStream, purpose: FilePurpose, options?: UploadFileOptionalParams) => PollerLike, OpenAIFileOutput>; -} - -// @public -export type AgentStreamEventType = ThreadStreamEvent | RunStreamEvent | RunStepStreamEvent | MessageStreamEvent | ErrorEvent_2 | DoneEvent; - -// @public -export interface AgentThreadCreationOptions { - messages?: Array; - metadata?: Record | null; - toolResources?: ToolResources | null; -} - -// @public -export interface AgentThreadOutput { - createdAt: Date; - id: string; - metadata: Record | null; - object: "thread"; - toolResources: ToolResourcesOutput | null; -} - -// @public -export class AIProjectsClient { - constructor(endpointParam: string, subscriptionId: string, resourceGroupName: string, projectName: string, credential: TokenCredential, options?: AIProjectsClientOptions); - readonly agents: AgentsOperations; - readonly connections: ConnectionsOperations; - static fromConnectionString(connectionString: string, credential: TokenCredential, options?: AIProjectsClientOptions): AIProjectsClient; - readonly telemetry: TelemetryOperations; -} - -// @public -export interface AIProjectsClientOptions extends ProjectsClientOptions { -} - -// @public -export type AuthenticationTypeOutput = "ApiKey" | "AAD" | "SAS"; - -// @public -export type AzureAISearchQueryType = string; - -// @public -export interface AzureAISearchResource { - indexes?: Array; -} - -// @public -export interface AzureAISearchResourceOutput { - indexes?: Array; -} - -// @public -export interface AzureAISearchToolDefinition extends ToolDefinitionParent { - type: "azure_ai_search"; -} - -// @public -export interface AzureAISearchToolDefinitionOutput extends ToolDefinitionOutputParent { - type: "azure_ai_search"; -} - -// @public -export interface AzureFunctionBinding { - storageQueue: AzureFunctionStorageQueue; - type: "storage_queue"; -} - -// @public -export interface AzureFunctionBindingOutput { - storageQueue: AzureFunctionStorageQueueOutput; - type: "storage_queue"; -} - -// @public -export interface AzureFunctionDefinition { - function: FunctionDefinition; - inputBinding: AzureFunctionBinding; - outputBinding: AzureFunctionBinding; -} - -// @public -export interface AzureFunctionDefinitionOutput { - function: FunctionDefinitionOutput; - inputBinding: AzureFunctionBindingOutput; - outputBinding: AzureFunctionBindingOutput; -} - -// @public -export interface AzureFunctionStorageQueue { - queueName: string; - queueServiceEndpoint: string; -} - -// @public -export interface AzureFunctionStorageQueueOutput { - queueName: string; - queueServiceEndpoint: string; -} - -// @public -export interface AzureFunctionToolDefinition extends ToolDefinitionParent { - azureFunction: AzureFunctionDefinition; - type: "azure_function"; -} - -// @public -export interface AzureFunctionToolDefinitionOutput extends ToolDefinitionOutputParent { - azureFunction: AzureFunctionDefinitionOutput; - type: "azure_function"; -} - -// @public (undocumented) -export interface AzureFunctionToolResource { - description: string; - // (undocumented) - inputQueue: AzureFunctionStorageQueue; - name: string; - // (undocumented) - outputQueue: AzureFunctionStorageQueue; - parameters: unknown; -} - -// @public -export interface BingCustomSearchToolDefinition extends ToolDefinitionParent { - bingCustomSearch?: SearchConfigurationList; - type: "bing_custom_search"; -} - -// @public -export interface BingCustomSearchToolDefinitionOutput extends ToolDefinitionOutputParent { - bingCustomSearch?: SearchConfigurationListOutput; - type: "bing_custom_search"; -} - -// @public -export interface BingGroundingToolDefinition extends ToolDefinitionParent { - bingGrounding: ToolConnectionList; - type: "bing_grounding"; -} - -// @public -export interface BingGroundingToolDefinitionOutput extends ToolDefinitionOutputParent { - bingGrounding: ToolConnectionListOutput; - type: "bing_grounding"; -} - -// @public -export interface CancelRunOptionalParams extends OperationOptions { -} - -// @public -export interface CancelVectorStoreFileBatchOptionalParams extends OperationOptions { -} - -// @public -export interface CodeInterpreterToolDefinition extends ToolDefinitionParent { - type: "code_interpreter"; -} - -// @public -export interface CodeInterpreterToolDefinitionOutput extends ToolDefinitionOutputParent { - type: "code_interpreter"; -} - -// @public -export interface CodeInterpreterToolResource { - dataSources?: Array; - fileIds?: string[]; -} - -// @public -export interface CodeInterpreterToolResourceOutput { - dataSources?: Array; - fileIds?: string[]; -} - -// @public -export interface ConnectionsOperations { - getConnection: (connectionName: string, options?: GetConnectionOptionalParams) => Promise; - getConnectionWithSecrets: (connectionName: string, options?: GetConnectionWithSecretsOptionalParams) => Promise; - listConnections: (options?: ListConnectionsOptionalParams) => Promise>; -} - -// @public -export enum connectionToolType { - AzureFunction = "azure_function", - BingCustomSearch = "bing_custom_search", - BingGrounding = "bing_grounding", - MicrosoftFabric = "fabric_dataagent", - SharepointGrounding = "sharepoint_grounding" -} - -// @public -export type ConnectionType = string; - -// @public -export type ConnectionTypeOutput = "AzureOpenAI" | "Serverless" | "AzureBlob" | "AIServices" | "CognitiveSearch"; - -// @public -export interface CreateAgentOptionalParams extends Omit, OperationOptions { -} - -// @public -export interface CreateAgentOptions { - description?: string | null; - instructions?: string | null; - metadata?: Record | null; - model: string; - name?: string | null; - responseFormat?: AgentsApiResponseFormatOption | null; - temperature?: number | null; - toolResources?: ToolResources | null; - tools?: Array; - topP?: number | null; -} - -// @public -export interface CreateAgentThreadOptionalParams extends AgentThreadCreationOptions, OperationOptions { -} - -// @public -export type CreateAndRunThreadOptionalParams = Omit & OperationOptions; - -// @public -export interface CreateAndRunThreadOptions { - assistantId: string; - instructions?: string | null; - maxCompletionTokens?: number | null; - maxPromptTokens?: number | null; - metadata?: Record | null; - model?: string | null; - parallelToolCalls?: boolean; - responseFormat?: AgentsApiResponseFormatOption | null; - stream?: boolean; - temperature?: number | null; - thread?: AgentThreadCreationOptions; - toolChoice?: AgentsApiToolChoiceOption | null; - toolResources?: UpdateToolResourcesOptions | null; - tools?: Array | null; - topP?: number | null; - truncationStrategy?: TruncationObject | null; -} - -// @public -export interface CreateAzureAISearchToolOptions { - filter?: string; - queryType?: AzureAISearchQueryType; - topK?: number; -} - -// @public -export type CreateMessageContent = string | Array; - -// @public -export interface CreateMessageOptionalParams extends OperationOptions { -} - -// @public -export type CreateRunOptionalParams = Omit & OperationOptions; - -// @public -export interface CreateRunOptions { - additionalInstructions?: string | null; - additionalMessages?: Array | null; - assistantId: string; - instructions?: string | null; - maxCompletionTokens?: number | null; - maxPromptTokens?: number | null; - metadata?: Record | null; - model?: string | null; - parallelToolCalls?: boolean; - responseFormat?: AgentsApiResponseFormatOption | null; - stream?: boolean; - temperature?: number | null; - toolChoice?: AgentsApiToolChoiceOption | null; - tools?: Array | null; - topP?: number | null; - truncationStrategy?: TruncationObject | null; -} - -// @public -export interface CreateVectorStoreFileBatchOptionalParams extends CreateVectorStoreFileBatchOptions, OperationOptions, PollingOptionsParams { -} - -// @public -export interface CreateVectorStoreFileBatchOptions { - chunkingStrategy?: VectorStoreChunkingStrategyRequest; - dataSources?: VectorStoreDataSource[]; - fileIds?: string[]; -} - -// @public -export interface CreateVectorStoreFileOptionalParams extends CreateVectorStoreFileOptions, OperationOptions, PollingOptionsParams { -} - -// @public -export interface CreateVectorStoreFileOptions { - chunkingStrategy?: VectorStoreChunkingStrategyRequest; - dataSources?: Array; - fileId?: string; -} - -// @public -export interface CreateVectorStoreOptionalParams extends VectorStoreOptions, OperationOptions, PollingOptionsParams { -} - -// @public -export interface CredentialsApiKeyAuthOutput { - key: string; -} - -// @public -export interface CredentialsSASAuthOutput { - SAS: string; -} - -// @public -export interface DeleteAgentOptionalParams extends OperationOptions { -} - -// @public -export interface DeleteAgentThreadOptionalParams extends OperationOptions { -} - -// @public -export interface DeleteFileOptionalParams extends OperationOptions { -} - -// @public -export interface DeleteVectorStoreFileOptionalParams extends OperationOptions { -} - -// @public -export interface DeleteVectorStoreOptionalParams extends OperationOptions { -} - -// @public -export enum DoneEvent { - Done = "done" -} - -// @public -enum ErrorEvent_2 { - Error = "error" -} -export { ErrorEvent_2 as ErrorEvent } - -// @public -export interface FileDeletionStatusOutput { - deleted: boolean; - id: string; - object: "file"; -} - -// @public -export interface FileListResponseOutput { - data: Array; - object: "list"; -} - -// @public -export type FilePurpose = string; - -// @public -export type FilePurposeOutput = string; - -// @public -export interface FileSearchRankingOptions { - ranker: string; - scoreThreshold: number; -} - -// @public -export interface FileSearchRankingOptionsOutput { - ranker: string; - scoreThreshold: number; -} - -// @public -export interface FileSearchToolCallContentOutput { - text: string; - type: "text"; -} - -// @public -export interface FileSearchToolDefinition extends ToolDefinitionParent { - fileSearch?: FileSearchToolDefinitionDetails; - type: "file_search"; -} - -// @public -export interface FileSearchToolDefinitionDetails { - maxNumResults?: number; - rankingOptions?: FileSearchRankingOptions; -} - -// @public -export interface FileSearchToolDefinitionDetailsOutput { - maxNumResults?: number; - rankingOptions?: FileSearchRankingOptionsOutput; -} - -// @public -export interface FileSearchToolDefinitionOutput extends ToolDefinitionOutputParent { - fileSearch?: FileSearchToolDefinitionDetailsOutput; - type: "file_search"; -} - -// @public -export interface FileSearchToolResource { - vectorStoreIds?: string[]; - vectorStores?: Array; -} - -// @public -export interface FileSearchToolResourceOutput { - vectorStoreIds?: string[]; - vectorStores?: Array; -} - -// @public -export type FileStateOutput = string; - -// @public -export interface FileStatusFilter { - filter?: VectorStoreFileStatusFilter; -} - -// @public -export interface FunctionDefinition { - description?: string; - name: string; - parameters: unknown; -} - -// @public -export interface FunctionDefinitionOutput { - description?: string; - name: string; - parameters: any; -} - -// @public -export interface FunctionName { - name: string; -} - -// @public -export interface FunctionNameOutput { - name: string; -} - -// @public -export interface FunctionToolDefinition extends ToolDefinitionParent { - function: FunctionDefinition; - type: "function"; -} - -// @public -export interface FunctionToolDefinitionOutput extends ToolDefinitionOutputParent { - function: FunctionDefinitionOutput; - type: "function"; -} - -// @public -export interface GetAgentOptionalParams extends OperationOptions { -} - -// @public -export interface GetAgentThreadOptionalParams extends OperationOptions { -} - -// @public -export interface GetConnectionOptionalParams extends OperationOptions { -} - -// @public -export interface GetConnectionResponseOutput { - id: string; - name: string; - properties: InternalConnectionPropertiesOutput; -} - -// @public -export interface GetConnectionWithSecretsOptionalParams extends OperationOptions { -} - -// @public -export interface GetFileContentOptionalParams extends OperationOptions { -} - -// @public -export interface GetFileOptionalParams extends OperationOptions { -} - -// @public -export interface GetRunOptionalParams extends OperationOptions { -} - -// @public -export interface GetRunStepOptionalParams extends OperationOptions { -} - -// @public -export interface GetVectorStoreFileBatchOptionalParams extends OperationOptions { -} - -// @public -export interface GetVectorStoreFileOptionalParams extends OperationOptions { -} - -// @public -export interface GetVectorStoreOptionalParams extends OperationOptions { -} - -// @public -export interface GetWorkspaceOptionalParams extends OperationOptions { -} - -// @public -export type ImageDetailLevel = string; - -// @public -export type IncompleteDetailsReasonOutput = string; - -// @public -export interface IncompleteRunDetailsOutput { - reason: IncompleteDetailsReasonOutput; -} - -// @public -export interface IndexResource { - filter?: string; - indexConnectionId: string; - indexName: string; - queryType?: AzureAISearchQueryType; - topK?: number; -} - -// @public -export interface IndexResourceOutput { - indexConnectionId: string; - indexName: string; -} - -// @public -export interface InternalConnectionPropertiesAADAuthOutput extends InternalConnectionPropertiesOutputParent { - authType: "AAD"; -} - -// @public -export interface InternalConnectionPropertiesApiKeyAuthOutput extends InternalConnectionPropertiesOutputParent { - authType: "ApiKey"; - credentials: CredentialsApiKeyAuthOutput; -} - -// @public -export type InternalConnectionPropertiesOutput = InternalConnectionPropertiesOutputParent | InternalConnectionPropertiesApiKeyAuthOutput | InternalConnectionPropertiesAADAuthOutput | InternalConnectionPropertiesSASAuthOutput; - -// @public -export interface InternalConnectionPropertiesOutputParent { - // (undocumented) - authType: AuthenticationTypeOutput; - category: ConnectionTypeOutput; - target: string; -} - -// @public -export interface InternalConnectionPropertiesSASAuthOutput extends InternalConnectionPropertiesOutputParent { - authType: "SAS"; - credentials: CredentialsSASAuthOutput; -} - -// @public -export function isOutputOfType(output: RequiredActionOutput | RequiredToolCallOutput | ToolDefinitionOutputParent, type: string): output is T; - -// @public -export interface ListAgentsOptionalParams extends ListQueryParameters, OperationOptions { -} - -// @public -export interface ListAgentThreadOptionalParams extends ListThreadsQueryParamProperties, OperationOptions { -} - -// @public -export interface ListConnectionsOptionalParams extends ListConnectionsQueryParamProperties, OperationOptions { -} - -// @public (undocumented) -export interface ListConnectionsQueryParamProperties { - category?: ConnectionType; - includeAll?: boolean; - target?: string; -} - -// @public -export interface ListFilesOptionalParams extends ListFilesQueryParamProperties, OperationOptions { -} - -// @public (undocumented) -export interface ListFilesQueryParamProperties { - purpose?: FilePurpose; -} - -// @public -export interface ListMessagesOptionalParams extends ListMessagesQueryParamProperties, OperationOptions { -} - -// @public (undocumented) -export interface ListMessagesQueryParamProperties { - after?: string; - before?: string; - limit?: number; - order?: ListSortOrder; - runId?: string; -} - -// @public -export interface ListQueryParameters { - after?: string; - before?: string; - limit?: number; - order?: "asc" | "desc"; -} - -// @public -export interface ListRunQueryOptionalParams extends ListQueryParameters, OperationOptions { -} - -// @public -export interface ListRunStepsOptionalParams extends ListQueryParameters, OperationOptions { -} - -// @public -export type ListSortOrder = string; - -// @public (undocumented) -export interface ListThreadsQueryParamProperties { - after?: string; - before?: string; - limit?: number; - order?: ListSortOrder; -} - -// @public -export interface ListVectorStoreFileBatchFilesOptionalParams extends ListQueryParameters, OperationOptions { - filter?: VectorStoreFileStatusFilter; -} - -// @public -export interface ListVectorStoreFilesOptionalParams extends ListQueryParameters, OperationOptions { -} - -// @public -export interface ListVectorStoresOptionalParams extends ListQueryParameters, OperationOptions { -} - -// @public -export interface MessageAttachment { - dataSource?: VectorStoreDataSource; - fileId?: string; - tools: MessageAttachmentToolDefinition[]; -} - -// @public -export interface MessageAttachmentOutput { - dataSource?: VectorStoreDataSourceOutput; - fileId?: string; - tools: MessageAttachmentToolDefinitionOutput[]; -} - -// @public -export type MessageAttachmentToolDefinition = CodeInterpreterToolDefinition | FileSearchToolDefinition; - -// @public -export type MessageAttachmentToolDefinitionOutput = CodeInterpreterToolDefinitionOutput | FileSearchToolDefinitionOutput; - -// @public -export type MessageBlockType = string; - -// @public -export type MessageContentBlockInput = MessageContentBlockInputParent | MessageTextBlockInput | MessageImageFileBlockInput | MessageImageUrlBlockInput; - -// @public -export interface MessageContentBlockInputParent { - // (undocumented) - type: MessageBlockType; -} - -// @public -export type MessageContentOutput = MessageContentOutputParent | MessageTextContentOutput | MessageImageFileContentOutput; - -// @public -export interface MessageContentOutputParent { - // (undocumented) - type: string; -} - -// @public -export interface MessageDelta { - content: Array; - role: MessageRole; -} - -// @public -export interface MessageDeltaChunk { - delta: MessageDelta; - id: string; - object: "thread.message.delta"; -} - -// @public -export type MessageDeltaContent = MessageDeltaContentParent | MessageDeltaTextContent | MessageDeltaImageFileContent; - -// @public -export interface MessageDeltaContentParent { - index: number; - type: string; -} - -// @public -export interface MessageDeltaImageFileContent extends MessageDeltaContentParent { - imageFile?: MessageDeltaImageFileContentObject; - type: "image_file"; -} - -// @public -export interface MessageDeltaImageFileContentObject { - fileId?: string; -} - -// @public -export type MessageDeltaTextAnnotation = MessageDeltaTextAnnotationParent | MessageDeltaTextFileCitationAnnotation | MessageDeltaTextFilePathAnnotation; - -// @public -export interface MessageDeltaTextAnnotationParent { - index: number; - type: string; -} - -// @public -export interface MessageDeltaTextContent extends MessageDeltaContentParent { - text?: MessageDeltaTextContentObject; - type: "text"; -} - -// @public -export interface MessageDeltaTextContentObject { - annotations?: Array; - value?: string; -} - -// @public -export interface MessageDeltaTextFileCitationAnnotation extends MessageDeltaTextAnnotationParent { - endIndex?: number; - fileCitation?: MessageDeltaTextFileCitationAnnotationObject; - startIndex?: number; - text?: string; - type: "file_citation"; -} - -// @public -export interface MessageDeltaTextFileCitationAnnotationObject { - fileId?: string; - quote?: string; -} - -// @public -export interface MessageDeltaTextFilePathAnnotation extends MessageDeltaTextAnnotationParent { - endIndex?: number; - filePath?: MessageDeltaTextFilePathAnnotationObject; - startIndex?: number; - text?: string; - type: "file_path"; -} - -// @public -export interface MessageDeltaTextFilePathAnnotationObject { - fileId?: string; -} - -// @public -export interface MessageDeltaTextUrlCitationDetails { - title?: string; - url?: string; -} - -// @public -export interface MessageImageFileBlockInput extends MessageContentBlockInputParent { - imageFile: MessageImageFileParam; - type: "image_file"; -} - -// @public -export interface MessageImageFileContentOutput extends MessageContentOutputParent { - imageFile: MessageImageFileDetailsOutput; - type: "image_file"; -} - -// @public -export interface MessageImageFileDetailsOutput { - fileId: string; -} - -// @public -export interface MessageImageFileParam { - detail?: ImageDetailLevel; - fileId: string; -} - -// @public -export interface MessageImageUrlBlockInput extends MessageContentBlockInputParent { - imageUrl: MessageImageUrlParam; - type: "image_url"; -} - -// @public -export interface MessageImageUrlParam { - detail?: ImageDetailLevel; - url: string; -} - -// @public -export interface MessageIncompleteDetailsOutput { - reason: MessageIncompleteDetailsReasonOutput; -} - -// @public -export type MessageIncompleteDetailsReasonOutput = string; - -// @public -export type MessageRole = string; - -// @public -export type MessageRoleOutput = string; - -// @public -export type MessageStatusOutput = string; - -// @public -export enum MessageStreamEvent { - ThreadMessageCompleted = "thread.message.completed", - ThreadMessageCreated = "thread.message.created", - ThreadMessageDelta = "thread.message.delta", - ThreadMessageIncomplete = "thread.message.incomplete", - ThreadMessageInProgress = "thread.message.in_progress" -} - -// @public -export type MessageTextAnnotationOutput = MessageTextAnnotationOutputParent | MessageTextFileCitationAnnotationOutput | MessageTextFilePathAnnotationOutput; - -// @public -export interface MessageTextAnnotationOutputParent { - text: string; - // (undocumented) - type: string; -} - -// @public -export interface MessageTextBlockInput extends MessageContentBlockInputParent { - text: string; - type: "text"; -} - -// @public -export interface MessageTextContentOutput extends MessageContentOutputParent { - text: MessageTextDetailsOutput; - type: "text"; -} - -// @public -export interface MessageTextDetailsOutput { - annotations: Array; - value: string; -} - -// @public -export interface MessageTextFileCitationAnnotationOutput extends MessageTextAnnotationOutputParent { - endIndex?: number; - fileCitation: MessageTextFileCitationDetailsOutput; - startIndex?: number; - type: "file_citation"; -} - -// @public -export interface MessageTextFileCitationDetailsOutput { - fileId: string; - quote: string; -} - -// @public -export interface MessageTextFilePathAnnotationOutput extends MessageTextAnnotationOutputParent { - endIndex?: number; - filePath: MessageTextFilePathDetailsOutput; - startIndex?: number; - type: "file_path"; -} - -// @public -export interface MessageTextFilePathDetailsOutput { - fileId: string; -} - -// @public -export interface MicrosoftFabricToolDefinition extends ToolDefinitionParent { - fabricDataAgent: ToolConnectionList; - type: "fabric_dataagent"; -} - -// @public -export interface MicrosoftFabricToolDefinitionOutput extends ToolDefinitionOutputParent { - fabricDataAgent: ToolConnectionListOutput; - type: "fabric_dataagent"; -} - -// @public -export interface OpenAIFileOutput { - bytes: number; - createdAt: Date; - filename: string; - id: string; - object: "file"; - purpose: FilePurposeOutput; - status?: FileStateOutput; - statusDetails?: string; -} - -// @public -export interface OpenAIPageableListOfAgentOutput { - data: Array; - firstId: string; - hasMore: boolean; - lastId: string; - object: "list"; -} - -// @public -export interface OpenAIPageableListOfAgentThreadOutput { - data: Array; - firstId: string; - hasMore: boolean; - lastId: string; - object: "list"; -} - -// @public -export interface OpenAIPageableListOfRunStepOutput { - data: Array; - firstId: string; - hasMore: boolean; - lastId: string; - object: "list"; -} - -// @public -export interface OpenAIPageableListOfThreadMessageOutput { - data: Array; - firstId: string; - hasMore: boolean; - lastId: string; - object: "list"; -} - -// @public -export interface OpenAIPageableListOfThreadRunOutput { - data: Array; - firstId: string; - hasMore: boolean; - lastId: string; - object: "list"; -} - -// @public -export interface OpenAIPageableListOfVectorStoreFileOutput { - data: Array; - firstId: string; - hasMore: boolean; - lastId: string; - object: "list"; -} - -// @public -export interface OpenAIPageableListOfVectorStoreOutput { - data: Array; - firstId: string; - hasMore: boolean; - lastId: string; - object: "list"; -} - -// @public -export interface OpenApiAnonymousAuthDetails extends OpenApiAuthDetailsParent { - type: "anonymous"; -} - -// @public -export interface OpenApiAnonymousAuthDetailsOutput extends OpenApiAuthDetailsOutputParent { - type: "anonymous"; -} - -// @public -export type OpenApiAuthDetails = OpenApiAuthDetailsParent | OpenApiAnonymousAuthDetails | OpenApiConnectionAuthDetails | OpenApiManagedAuthDetails; - -// @public -export type OpenApiAuthDetailsOutput = OpenApiAuthDetailsOutputParent | OpenApiAnonymousAuthDetailsOutput | OpenApiConnectionAuthDetailsOutput | OpenApiManagedAuthDetailsOutput; - -// @public -export interface OpenApiAuthDetailsOutputParent { - // (undocumented) - type: OpenApiAuthTypeOutput; -} - -// @public -export interface OpenApiAuthDetailsParent { - // (undocumented) - type: OpenApiAuthType; -} - -// @public -export type OpenApiAuthType = string; - -// @public -export type OpenApiAuthTypeOutput = string; - -// @public -export interface OpenApiConnectionAuthDetails extends OpenApiAuthDetailsParent { - securityScheme: OpenApiConnectionSecurityScheme; - type: "connection"; -} - -// @public -export interface OpenApiConnectionAuthDetailsOutput extends OpenApiAuthDetailsOutputParent { - securityScheme: OpenApiConnectionSecuritySchemeOutput; - type: "connection"; -} - -// @public -export interface OpenApiConnectionSecurityScheme { - connectionId: string; -} - -// @public -export interface OpenApiConnectionSecuritySchemeOutput { - connectionId: string; -} - -// @public -export interface OpenApiFunctionDefinition { - auth: OpenApiAuthDetails; - defaultParams?: string[]; - description?: string; - functions?: Array; - name: string; - spec: unknown; -} - -// @public -export interface OpenApiFunctionDefinitionOutput { - auth: OpenApiAuthDetailsOutput; - description?: string; - name: string; - spec: any; -} - -// @public -export interface OpenApiManagedAuthDetails extends OpenApiAuthDetailsParent { - securityScheme: OpenApiManagedSecurityScheme; - type: "managed_identity"; -} - -// @public -export interface OpenApiManagedAuthDetailsOutput extends OpenApiAuthDetailsOutputParent { - securityScheme: OpenApiManagedSecuritySchemeOutput; - type: "managed_identity"; -} - -// @public -export interface OpenApiManagedSecurityScheme { - audience: string; -} - -// @public -export interface OpenApiManagedSecuritySchemeOutput { - audience: string; -} - -// @public -export interface OpenApiToolDefinition extends ToolDefinitionParent { - openapi: OpenApiFunctionDefinition; - type: "openapi"; -} - -// @public -export interface OpenApiToolDefinitionOutput extends ToolDefinitionOutputParent { - openapi: OpenApiFunctionDefinitionOutput; - type: "openapi"; -} - -// @public -export interface PollingOptions { - sleepIntervalInMs?: number; -} - -// @public -export interface PollingOptionsParams { - pollingOptions?: PollingOptions; -} - -// @public -export interface ProjectsClientOptions extends ClientOptions { - apiVersion?: string; -} - -// @public -export type RequiredActionOutput = RequiredActionOutputParent | SubmitToolOutputsActionOutput; - -// @public -export interface RequiredActionOutputParent { - // (undocumented) - type: string; -} - -// @public -export interface RequiredFunctionToolCallDetailsOutput { - arguments: string; - name: string; -} - -// @public -export interface RequiredFunctionToolCallOutput extends RequiredToolCallOutputParent { - function: RequiredFunctionToolCallDetailsOutput; - type: "function"; -} - -// @public -export type RequiredToolCallOutput = RequiredToolCallOutputParent | RequiredFunctionToolCallOutput; - -// @public -export interface RequiredToolCallOutputParent { - id: string; - // (undocumented) - type: string; -} - -// @public -export type ResponseFormat = string; - -// @public -export interface ResponseFormatJsonSchema { - description?: string; - name: string; - schema: unknown; -} - -// @public -export interface ResponseFormatJsonSchemaOutput { - description?: string; - name: string; - schema: any; -} - -// @public -export interface ResponseFormatJsonSchemaType { - jsonSchema: ResponseFormatJsonSchema; - type: "json_schema"; -} - -// @public -export interface ResponseFormatJsonSchemaTypeOutput { - jsonSchema: ResponseFormatJsonSchemaOutput; - type: "json_schema"; -} - -// @public -export type ResponseFormatOutput = string; - -// @public -export interface RunCompletionUsageOutput { - completionTokens: number; - promptTokens: number; - totalTokens: number; -} - -// @public -export interface RunErrorOutput { - code: string; - message: string; -} - -// @public -export type RunStatusOutput = string; - -// @public -export interface RunStepAzureAISearchToolCallOutput extends RunStepToolCallOutputParent { - azureAISearch: Record; - type: "azure_ai_search"; -} - -// @public -export interface RunStepBingGroundingToolCallOutput extends RunStepToolCallOutputParent { - bingGrounding: Record; - type: "bing_grounding"; -} - -// @public -export interface RunStepCodeInterpreterImageOutputOutput extends RunStepCodeInterpreterToolCallOutputOutputParent { - image: RunStepCodeInterpreterImageReferenceOutput; - type: "image"; -} - -// @public -export interface RunStepCodeInterpreterImageReferenceOutput { - fileId: string; -} - -// @public -export interface RunStepCodeInterpreterLogOutputOutput extends RunStepCodeInterpreterToolCallOutputOutputParent { - logs: string; - type: "logs"; -} - -// @public -export interface RunStepCodeInterpreterToolCallDetailsOutput { - input: string; - outputs: Array; -} - -// @public -export interface RunStepCodeInterpreterToolCallOutput extends RunStepToolCallOutputParent { - codeInterpreter: RunStepCodeInterpreterToolCallDetailsOutput; - type: "code_interpreter"; -} - -// @public -export type RunStepCodeInterpreterToolCallOutputOutput = RunStepCodeInterpreterToolCallOutputOutputParent | RunStepCodeInterpreterLogOutputOutput | RunStepCodeInterpreterImageOutputOutput; - -// @public -export interface RunStepCodeInterpreterToolCallOutputOutputParent { - // (undocumented) - type: string; -} - -// @public -export interface RunStepCompletionUsageOutput { - completionTokens: number; - promptTokens: number; - totalTokens: number; -} - -// @public -export interface RunStepDelta { - stepDetails?: RunStepDeltaDetail; -} - -// @public -export interface RunStepDeltaChunk { - delta: RunStepDelta; - id: string; - object: "thread.run.step.delta"; -} - -// @public -export interface RunStepDeltaCodeInterpreterDetailItemObject { - input?: string; - outputs?: Array; -} - -// @public -export interface RunStepDeltaCodeInterpreterImageOutput extends RunStepDeltaCodeInterpreterOutputParent { - image?: RunStepDeltaCodeInterpreterImageOutputObject; - type: "image"; -} - -// @public -export interface RunStepDeltaCodeInterpreterImageOutputObject { - fileId?: string; -} - -// @public -export interface RunStepDeltaCodeInterpreterLogOutput extends RunStepDeltaCodeInterpreterOutputParent { - logs?: string; - type: "logs"; -} - -// @public -export type RunStepDeltaCodeInterpreterOutput = RunStepDeltaCodeInterpreterOutputParent | RunStepDeltaCodeInterpreterLogOutput | RunStepDeltaCodeInterpreterImageOutput; - -// @public -export interface RunStepDeltaCodeInterpreterOutputParent { - index: number; - type: string; -} - -// @public -export interface RunStepDeltaCodeInterpreterToolCall extends RunStepDeltaToolCallParent { - codeInterpreter?: RunStepDeltaCodeInterpreterDetailItemObject; - type: "code_interpreter"; -} - -// @public -export interface RunStepDeltaDetail { - type: string; -} - -// @public -export interface RunStepDeltaFileSearchToolCall extends RunStepDeltaToolCallParent { - fileSearch?: RunStepFileSearchToolCallResultsOutput; - type: "file_search"; -} - -// @public -export interface RunStepDeltaFunction { - arguments?: string; - name?: string; - output?: string | null; -} - -// @public -export interface RunStepDeltaFunctionToolCall extends RunStepDeltaToolCallParent { - function?: RunStepDeltaFunction; - type: "function"; -} - -// @public -export interface RunStepDeltaMessageCreation extends RunStepDeltaDetail { - messageCreation?: RunStepDeltaMessageCreationObject; - type: "message_creation"; -} - -// @public -export interface RunStepDeltaMessageCreationObject { - messageId?: string; -} - -// @public -export type RunStepDeltaToolCall = RunStepDeltaToolCallParent | RunStepDeltaFunctionToolCall | RunStepDeltaFileSearchToolCall | RunStepDeltaCodeInterpreterToolCall; - -// @public -export interface RunStepDeltaToolCallObject extends RunStepDeltaDetail { - toolCalls?: Array; - type: "tool_calls"; -} - -// @public -export interface RunStepDeltaToolCallParent { - id: string; - index: number; - type: string; -} - -// @public -export type RunStepDetailsOutput = RunStepDetailsOutputParent | RunStepMessageCreationDetailsOutput | RunStepToolCallDetailsOutput; - -// @public -export interface RunStepDetailsOutputParent { - // (undocumented) - type: RunStepTypeOutput; -} - -// @public -export type RunStepErrorCodeOutput = string; - -// @public -export interface RunStepErrorOutput { - code: RunStepErrorCodeOutput; - message: string; -} - -// @public -export interface RunStepFileSearchToolCallOutput extends RunStepToolCallOutputParent { - fileSearch: RunStepFileSearchToolCallResultsOutput; - id: string; - type: "file_search"; -} - -// @public -export interface RunStepFileSearchToolCallResultOutput { - content?: Array; - fileId: string; - fileName: string; - score: number; -} - -// @public -export interface RunStepFileSearchToolCallResultsOutput { - rankingOptions?: FileSearchRankingOptionsOutput; - results: Array; -} - -// @public -export interface RunStepFunctionToolCallDetailsOutput { - arguments: string; - name: string; - output: string | null; -} - -// @public -export interface RunStepFunctionToolCallOutput extends RunStepToolCallOutputParent { - function: RunStepFunctionToolCallDetailsOutput; - type: "function"; -} - -// @public -export interface RunStepMessageCreationDetailsOutput extends RunStepDetailsOutputParent { - messageCreation: RunStepMessageCreationReferenceOutput; - type: "message_creation"; -} - -// @public -export interface RunStepMessageCreationReferenceOutput { - messageId: string; -} - -// @public -export interface RunStepMicrosoftFabricToolCallOutput extends RunStepToolCallOutputParent { - fabricDataAgent: Record; - type: "fabric_dataagent"; -} - -// @public -export interface RunStepOutput { - assistantId: string; - cancelledAt: Date | null; - completedAt: Date | null; - createdAt: Date; - expiredAt: Date | null; - failedAt: Date | null; - id: string; - lastError: RunStepErrorOutput | null; - metadata: Record | null; - object: "thread.run.step"; - runId: string; - status: RunStepStatusOutput; - stepDetails: RunStepDetailsOutput; - threadId: string; - type: RunStepTypeOutput; - usage?: RunStepCompletionUsageOutput | null; -} - -// @public -export interface RunStepSharepointToolCallOutput extends RunStepToolCallOutputParent { - sharepointGrounding: Record; - type: "sharepoint_grounding"; -} - -// @public -export type RunStepStatusOutput = string; - -// @public -export enum RunStepStreamEvent { - ThreadRunStepCancelled = "thread.run.step.cancelled", - ThreadRunStepCompleted = "thread.run.step.completed", - ThreadRunStepCreated = "thread.run.step.created", - ThreadRunStepDelta = "thread.run.step.delta", - ThreadRunStepExpired = "thread.run.step.expired", - ThreadRunStepFailed = "thread.run.step.failed", - ThreadRunStepInProgress = "thread.run.step.in_progress" -} - -// @public -export interface RunStepToolCallDetailsOutput extends RunStepDetailsOutputParent { - toolCalls: Array; - type: "tool_calls"; -} - -// @public -export type RunStepToolCallOutput = RunStepToolCallOutputParent | RunStepCodeInterpreterToolCallOutput | RunStepFileSearchToolCallOutput | RunStepBingGroundingToolCallOutput | RunStepAzureAISearchToolCallOutput | RunStepSharepointToolCallOutput | RunStepMicrosoftFabricToolCallOutput | RunStepFunctionToolCallOutput; - -// @public -export interface RunStepToolCallOutputParent { - id: string; - // (undocumented) - type: string; -} - -// @public -export type RunStepTypeOutput = string; - -// @public -export enum RunStreamEvent { - ThreadRunCancelled = "thread.run.cancelled", - ThreadRunCancelling = "thread.run.cancelling", - ThreadRunCompleted = "thread.run.completed", - ThreadRunCreated = "thread.run.created", - ThreadRunExpired = "thread.run.expired", - ThreadRunFailed = "thread.run.failed", - ThreadRunInProgress = "thread.run.in_progress", - ThreadRunQueued = "thread.run.queued", - ThreadRunRequiresAction = "thread.run.requires_action" -} - -// @public -export interface SearchConfiguration { - connectionId: string; - instanceName: string; -} - -// @public -export interface SearchConfiguration { - connectionId: string; - instanceName: string; -} - -// @public -export interface SearchConfigurationList { - searchConfigurations: Array; -} - -// @public -export interface SearchConfigurationList { - searchConfigurations: Array; -} - -// @public -export interface SearchConfigurationListOutput { - searchConfigurations?: Array; -} - -// @public -export interface SearchConfigurationOutput { - connectionId: string; - instanceName: string; -} - -// @public -export interface SharepointToolDefinition extends ToolDefinitionParent { - sharepointGrounding: ToolConnectionList; - type: "sharepoint_grounding"; -} - -// @public -export interface SharepointToolDefinitionOutput extends ToolDefinitionOutputParent { - sharepointGrounding: ToolConnectionListOutput; - type: "sharepoint_grounding"; -} - -// @public -export interface SubmitToolOutputsActionOutput extends RequiredActionOutputParent { - submitToolOutputs: SubmitToolOutputsDetailsOutput; - type: "submit_tool_outputs"; -} - -// @public -export interface SubmitToolOutputsDetailsOutput { - toolCalls: Array; -} - -// @public -export interface SubmitToolOutputsToRunOptionalParams extends OperationOptions { - stream?: boolean; -} - -// @public -export interface TelemetryOperations { - getConnectionString(): Promise; - getSettings(): TelemetryOptions; - updateSettings(options: TelemetryOptions): void; -} - -// @public -export interface TelemetryOptions { - enableContentRecording: boolean; -} - -// @public -export interface ThreadDeletionStatusOutput { - deleted: boolean; - id: string; - object: "thread.deleted"; -} - -// @public -export interface ThreadMessageOptions { - attachments?: Array | null; - content: CreateMessageContent; - metadata?: Record | null; - role: MessageRole; -} - -// @public -export interface ThreadMessageOutput { - assistantId: string | null; - attachments: Array | null; - completedAt: Date | null; - content: Array; - createdAt: Date; - id: string; - incompleteAt: Date | null; - incompleteDetails: MessageIncompleteDetailsOutput | null; - metadata: Record | null; - object: "thread.message"; - role: MessageRoleOutput; - runId: string | null; - status: MessageStatusOutput; - threadId: string; -} - -// @public -export interface ThreadRunOutput { - assistantId: string; - cancelledAt: Date | null; - completedAt: Date | null; - createdAt: Date; - expiresAt: Date | null; - failedAt: Date | null; - id: string; - incompleteDetails: IncompleteRunDetailsOutput | null; - instructions: string; - lastError: RunErrorOutput | null; - maxCompletionTokens: number | null; - maxPromptTokens: number | null; - metadata: Record | null; - model: string; - object: "thread.run"; - parallelToolCalls: boolean; - requiredAction?: RequiredActionOutput | null; - responseFormat: AgentsApiResponseFormatOptionOutput | null; - startedAt: Date | null; - status: RunStatusOutput; - temperature?: number | null; - threadId: string; - toolChoice: AgentsApiToolChoiceOptionOutput | null; - toolResources?: UpdateToolResourcesOptionsOutput | null; - tools: Array; - topP?: number | null; - truncationStrategy: TruncationObjectOutput | null; - usage: RunCompletionUsageOutput | null; -} - -// @public -export enum ThreadStreamEvent { - ThreadCreated = "thread.created" -} - -// @public -export interface ToolConnection { - connectionId: string; -} - -// @public -export interface ToolConnectionList { - connections?: Array; -} - -// @public -export interface ToolConnectionListOutput { - connections?: Array; -} - -// @public -export interface ToolConnectionOutput { - connectionId: string; -} - -// @public -export type ToolDefinition = ToolDefinitionParent | CodeInterpreterToolDefinition | FileSearchToolDefinition | FunctionToolDefinition | BingGroundingToolDefinition | MicrosoftFabricToolDefinition | SharepointToolDefinition | AzureAISearchToolDefinition | OpenApiToolDefinition | BingCustomSearchToolDefinition | AzureFunctionToolDefinition; - -// @public -export type ToolDefinitionOutput = ToolDefinitionOutputParent | CodeInterpreterToolDefinitionOutput | FileSearchToolDefinitionOutput | FunctionToolDefinitionOutput | BingGroundingToolDefinitionOutput | MicrosoftFabricToolDefinitionOutput | SharepointToolDefinitionOutput | AzureAISearchToolDefinitionOutput | OpenApiToolDefinitionOutput | BingCustomSearchToolDefinitionOutput | AzureFunctionToolDefinitionOutput; - -// @public -export interface ToolDefinitionOutputParent { - // (undocumented) - type: string; -} - -// @public -export interface ToolDefinitionParent { - // (undocumented) - type: string; -} - -// @public -export interface ToolOutput { - output?: string; - toolCallId?: string; -} - -// @public -export interface ToolResources { - azureAISearch?: AzureAISearchResource; - azureFunction?: AzureFunctionToolResource; - codeInterpreter?: CodeInterpreterToolResource; - fileSearch?: FileSearchToolResource; -} - -// @public -export interface ToolResourcesOutput { - azureAISearch?: AzureAISearchResourceOutput; - codeInterpreter?: CodeInterpreterToolResourceOutput; - fileSearch?: FileSearchToolResourceOutput; -} - -// @public -export class ToolSet { - addAzureAISearchTool(indexConnectionId: string, indexName: string): { - definition: AzureAISearchToolDefinition; - resources: ToolResources; - }; - addAzureFunctionTool(name: string, description: string, parameters: unknown, inputQueue: AzureFunctionStorageQueue, outputQueue: AzureFunctionStorageQueue, definitionDetails: AzureFunctionDefinition): { - definition: AzureFunctionToolDefinition; - resources: ToolResources; - }; - addCodeInterpreterTool(fileIds?: string[], dataSources?: Array): { - definition: CodeInterpreterToolDefinition; - resources: ToolResources; - }; - addConnectionTool(toolType: connectionToolType, connectionIds: string[]): { - definition: ToolDefinition; - }; - addFabricTool(connectionId: string): { - definition: ToolDefinition; - }; - addFileSearchTool(vectorStoreIds?: string[], vectorStores?: Array, definitionDetails?: FileSearchToolDefinitionDetails): { - definition: FileSearchToolDefinition; - resources: ToolResources; - }; - addOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): { - definition: OpenApiToolDefinition; - }; - toolDefinitions: ToolDefinition[]; - toolResources: ToolResources; -} - -// @public -export class ToolUtility { - static createAzureAISearchTool(indexConnectionId: string, indexName: string, options?: CreateAzureAISearchToolOptions): { - definition: AzureAISearchToolDefinition; - resources: ToolResources; - }; - static createAzureFunctionTool(name: string, description: string, parameters: unknown, inputQueue: AzureFunctionStorageQueue, outputQueue: AzureFunctionStorageQueue, definitionDetails: AzureFunctionDefinition): { - definition: AzureFunctionToolDefinition; - resources: ToolResources; - }; - static createBingCustomSearchTool(searchConfigurations: SearchConfigurationOutput[]): { - definition: ToolDefinition; - }; - static createCodeInterpreterTool(fileIds?: string[], dataSources?: Array): { - definition: CodeInterpreterToolDefinition; - resources: ToolResources; - }; - static createConnectionTool(toolType: connectionToolType, connectionIds: string[]): { - definition: ToolDefinition; - }; - static createFabricTool(connectionId: string): { - definition: ToolDefinition; - }; - static createFileSearchTool(vectorStoreIds?: string[], vectorStores?: Array, definitionDetails?: FileSearchToolDefinitionDetails): { - definition: FileSearchToolDefinition; - resources: ToolResources; - }; - static createFunctionTool(functionDefinition: FunctionDefinition): { - definition: FunctionToolDefinition; - }; - static createOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): { - definition: OpenApiToolDefinition; - }; -} - -// @public -export interface TruncationObject { - lastMessages?: number | null; - type: TruncationStrategy; -} - -// @public -export interface TruncationObjectOutput { - lastMessages?: number | null; - type: TruncationStrategyOutput; -} - -// @public -export type TruncationStrategy = string; - -// @public -export type TruncationStrategyOutput = string; - -// @public -export interface UpdateAgentOptionalParams extends UpdateAgentOptions, OperationOptions { -} - -// @public -export interface UpdateAgentOptions { - description?: string | null; - instructions?: string | null; - metadata?: Record | null; - model?: string; - name?: string | null; - responseFormat?: AgentsApiResponseFormatOption | null; - temperature?: number | null; - toolResources?: ToolResources; - tools?: Array; - topP?: number | null; -} - -// @public -export interface UpdateAgentThreadOptionalParams extends UpdateAgentThreadOptions, OperationOptions { -} - -// @public -export interface UpdateAgentThreadOptions { - metadata?: Record | null; - toolResources?: ToolResources | null; -} - -// @public -export interface UpdateCodeInterpreterToolResourceOptions { - fileIds?: string[]; -} - -// @public -export interface UpdateCodeInterpreterToolResourceOptionsOutput { - fileIds?: string[]; -} - -// @public -export interface UpdateFileSearchToolResourceOptions { - vectorStoreIds?: string[]; -} - -// @public -export interface UpdateFileSearchToolResourceOptionsOutput { - vectorStoreIds?: string[]; -} - -// @public -export interface UpdateMessageOptionalParams extends OperationOptions { - metadata?: Record | null; -} - -// @public -export interface UpdateRunOptionalParams extends OperationOptions { - metadata?: Record | null; -} - -// @public -export interface UpdateToolResourcesOptions { - azureAISearch?: AzureAISearchResource; - azureFunction?: AzureFunctionToolResource; - codeInterpreter?: UpdateCodeInterpreterToolResourceOptions; - fileSearch?: UpdateFileSearchToolResourceOptions; -} - -// @public -export interface UpdateToolResourcesOptionsOutput { - azureAISearch?: AzureAISearchResourceOutput; - codeInterpreter?: UpdateCodeInterpreterToolResourceOptionsOutput; - fileSearch?: UpdateFileSearchToolResourceOptionsOutput; -} - -// @public -export interface UpdateVectorStoreOptionalParams extends VectorStoreUpdateOptions, OperationOptions { -} - -// @public -export interface UploadFileOptionalParams extends OperationOptions, PollingOptionsParams { - fileName?: string; -} - -// @public -export interface VectorStoreAutoChunkingStrategyRequest extends VectorStoreChunkingStrategyRequestParent { - type: "auto"; -} - -// @public -export interface VectorStoreAutoChunkingStrategyResponseOutput extends VectorStoreChunkingStrategyResponseOutputParent { - type: "other"; -} - -// @public -export type VectorStoreChunkingStrategyRequest = VectorStoreChunkingStrategyRequestParent | VectorStoreAutoChunkingStrategyRequest | VectorStoreStaticChunkingStrategyRequest; - -// @public -export interface VectorStoreChunkingStrategyRequestParent { - // (undocumented) - type: VectorStoreChunkingStrategyRequestType; -} - -// @public -export type VectorStoreChunkingStrategyRequestType = string; - -// @public -export type VectorStoreChunkingStrategyResponseOutput = VectorStoreChunkingStrategyResponseOutputParent | VectorStoreAutoChunkingStrategyResponseOutput | VectorStoreStaticChunkingStrategyResponseOutput; - -// @public -export interface VectorStoreChunkingStrategyResponseOutputParent { - // (undocumented) - type: VectorStoreChunkingStrategyResponseTypeOutput; -} - -// @public -export type VectorStoreChunkingStrategyResponseTypeOutput = string; - -// @public -export interface VectorStoreConfiguration { - dataSources: Array; -} - -// @public -export interface VectorStoreConfigurationOutput { - dataSources: Array; -} - -// @public -export interface VectorStoreConfigurations { - configuration: VectorStoreConfiguration; - name: string; -} - -// @public -export interface VectorStoreConfigurationsOutput { - configuration: VectorStoreConfigurationOutput; - name: string; -} - -// @public -export interface VectorStoreDataSource { - type: VectorStoreDataSourceAssetType; - uri: string; -} - -// @public -export type VectorStoreDataSourceAssetType = string; - -// @public -export type VectorStoreDataSourceAssetTypeOutput = string; - -// @public -export interface VectorStoreDataSourceOutput { - type: VectorStoreDataSourceAssetTypeOutput; - uri: string; -} - -// @public -export interface VectorStoreDeletionStatusOutput { - deleted: boolean; - id: string; - object: "vector_store.deleted"; -} - -// @public -export interface VectorStoreExpirationPolicy { - anchor: VectorStoreExpirationPolicyAnchor; - days: number; -} - -// @public -export type VectorStoreExpirationPolicyAnchor = string; - -// @public -export type VectorStoreExpirationPolicyAnchorOutput = string; - -// @public -export interface VectorStoreExpirationPolicyOutput { - anchor: VectorStoreExpirationPolicyAnchorOutput; - days: number; -} - -// @public -export interface VectorStoreFileBatchOutput { - createdAt: Date; - fileCounts: VectorStoreFileCountOutput; - id: string; - object: "vector_store.files_batch"; - status: VectorStoreFileBatchStatusOutput; - vectorStoreId: string; -} - -// @public -export type VectorStoreFileBatchStatusOutput = string; - -// @public -export interface VectorStoreFileCountOutput { - cancelled: number; - completed: number; - failed: number; - inProgress: number; - total: number; -} - -// @public -export interface VectorStoreFileDeletionStatusOutput { - deleted: boolean; - id: string; - object: "vector_store.file.deleted"; -} - -// @public -export type VectorStoreFileErrorCodeOutput = string; - -// @public -export interface VectorStoreFileErrorOutput { - code: VectorStoreFileErrorCodeOutput; - message: string; -} - -// @public -export interface VectorStoreFileOutput { - chunkingStrategy: VectorStoreChunkingStrategyResponseOutput; - createdAt: Date; - id: string; - lastError: VectorStoreFileErrorOutput | null; - object: "vector_store.file"; - status: VectorStoreFileStatusOutput; - usageBytes: number; - vectorStoreId: string; -} - -// @public -export type VectorStoreFileStatusFilter = string; - -// @public -export type VectorStoreFileStatusOutput = string; - -// @public -export interface VectorStoreOptions { - chunkingStrategy?: VectorStoreChunkingStrategyRequest; - configuration?: VectorStoreConfiguration; - expiresAfter?: VectorStoreExpirationPolicy; - fileIds?: string[]; - metadata?: Record | null; - name?: string; -} - -// @public -export interface VectorStoreOutput { - createdAt: Date; - expiresAfter?: VectorStoreExpirationPolicyOutput; - expiresAt?: Date | null; - fileCounts: VectorStoreFileCountOutput; - id: string; - lastActiveAt: Date | null; - metadata: Record | null; - name: string; - object: "vector_store"; - status: VectorStoreStatusOutput; - usageBytes: number; -} - -// @public -export interface VectorStoreStaticChunkingStrategyOptions { - chunkOverlapTokens: number; - maxChunkSizeTokens: number; -} - -// @public -export interface VectorStoreStaticChunkingStrategyOptionsOutput { - chunkOverlapTokens: number; - maxChunkSizeTokens: number; -} - -// @public -export interface VectorStoreStaticChunkingStrategyRequest extends VectorStoreChunkingStrategyRequestParent { - static: VectorStoreStaticChunkingStrategyOptions; - type: "static"; -} - -// @public -export interface VectorStoreStaticChunkingStrategyResponseOutput extends VectorStoreChunkingStrategyResponseOutputParent { - static: VectorStoreStaticChunkingStrategyOptionsOutput; - type: "static"; -} - -// @public -export type VectorStoreStatusOutput = string; - -// @public -export interface VectorStoreUpdateOptions { - expiresAfter?: VectorStoreExpirationPolicy | null; - metadata?: Record | null; - name?: string | null; -} - -// (No @packageDocumentation comment for this package) - -``` diff --git a/sdk/ai/ai-projects/sample.env b/sdk/ai/ai-projects/sample.env deleted file mode 100644 index 0d9bbe518d6f..000000000000 --- a/sdk/ai/ai-projects/sample.env +++ /dev/null @@ -1,3 +0,0 @@ -AZURE_AI_PROJECTS_CONNECTION_STRING="" - -APPLICATIONINSIGHTS_CONNECTION_STRING="" diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentCreateWithTracingConsole.ts b/sdk/ai/ai-projects/samples-dev/agents/agentCreateWithTracingConsole.ts deleted file mode 100644 index f76ac5c171a5..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentCreateWithTracingConsole.ts +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * Demonstrates How to instrument and get tracing using open telemetry. - * - * @summary Create Agent and instrument using open telemetry. - */ - -import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter"; -import { createAzureSdkInstrumentation } from "@azure/opentelemetry-instrumentation-azure-sdk"; -import { context, trace } from "@opentelemetry/api"; -import { registerInstrumentations } from "@opentelemetry/instrumentation"; -import { - ConsoleSpanExporter, - NodeTracerProvider, - SimpleSpanProcessor, -} from "@opentelemetry/sdk-trace-node"; - -import "dotenv/config"; - -const provider = new NodeTracerProvider(); -provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); -provider.register(); - -registerInstrumentations({ - instrumentations: [createAzureSdkInstrumentation()], -}); - -import { AIProjectsClient } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -let appInsightsConnectionString = process.env["APPLICATIONINSIGHTS_CONNECTION_STRING"]; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const tracer = trace.getTracer("Agents Sample", "1.0.0"); - - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - if (!appInsightsConnectionString) { - appInsightsConnectionString = await client.telemetry.getConnectionString(); - } - - if (appInsightsConnectionString) { - const exporter = new AzureMonitorTraceExporter({ - connectionString: appInsightsConnectionString, - }); - provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); - } - - await tracer.startActiveSpan("main", async (span) => { - client.telemetry.updateSettings({ enableContentRecording: true }); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - tracingOptions: { tracingContext: context.active() }, - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - const thread = await client.agents.createThread(); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - console.log(`Created message, message ID ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created Run, Run ID: ${run.id}`); - - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - } - - await client.agents.deleteAgent(agent.id); - - console.log(`Deleted agent`); - - await client.agents.listMessages(thread.id); - - span.end(); - }); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentTokenUsage.ts b/sdk/ai/ai-projects/samples-dev/agents/agentTokenUsage.ts deleted file mode 100644 index 4714802d5278..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentTokenUsage.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to track the token usage of an Agent in the Azure Agents service. - * - * @summary demonstrates how to track the token usage of an Agent. - */ -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create an Agent - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - }); - - // Create a thread - const thread = await client.agents.createThread(); - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - // the usage should be null at this point - console.log(`usage for run ${run.id}:`, JSON.stringify(run.usage, null, 2)); - // Wait for run to complete - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Run status: ${run.status}`); - } - - // token usage should be like this: - // { - // "completionTokens": 16, - // "promptTokens": 56, - // "totalTokens": 72 - // } - console.log(`usage for run ${run.id}:`, JSON.stringify(run.usage, null, 2)); - - // Delete the Agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted Agent, Agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsAzureAiSearch.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsAzureAiSearch.ts deleted file mode 100644 index c05ef31ce1eb..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsAzureAiSearch.ts +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Azure AI Search tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Azure AI Search tool. - * - */ - -import type { - MessageContentOutput, - MessageTextContentOutput, - RunStepToolCallDetailsOutput, - RunStepAzureAISearchToolCallOutput, -} from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const connectionName = process.env["AZURE_AI_SEARCH_CONNECTION_NAME"] || ""; - const connection = await client.connections.getConnection(connectionName); - - // Initialize Azure AI Search tool - const azureAISearchTool = ToolUtility.createAzureAISearchTool(connection.id, "ai-search-sample", { - queryType: "simple", - topK: 3, - filter: "", - }); - - // Create agent with the Azure AI search tool - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [azureAISearchTool.definition], - toolResources: azureAISearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What is the temperature rating of the cozynights sleeping bag?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed:`, JSON.stringify(run, null, 2)); - } - console.log(`Run finished with status: ${run.status}`); - - // Fetch run steps to get the details of agent run - const { data: runSteps } = await client.agents.listRunSteps(thread.id, run.id); - - for (const step of runSteps) { - console.log(`Step ID: ${step.id}, Status: ${step.status}`); - const stepDetails = step.stepDetails; - if (isOutputOfType(stepDetails, "tool_calls")) { - const toolCalls = stepDetails.toolCalls; - for (const toolCall of toolCalls) { - console.log(`Tool Call ID: ${toolCall.id}, Tool type: ${toolCall.type}`); - if (isOutputOfType(toolCall, "azure_ai_search")) { - { - const azureAISearch = toolCall.azureAISearch; - if (azureAISearch) { - console.log(`Azure AI Search Tool Call input: ${azureAISearch.input}`); - console.log(`Azure AI Search Tool Call output: ${azureAISearch.output}`); - } - } - } - } - } - } - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsAzureFunctions.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsAzureFunctions.ts deleted file mode 100644 index 0ff1d2bc3af3..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsAzureFunctions.ts +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use azure function agent operations from the Azure Agents service - * - * @summary demonstrates how to use azure function agent operations from the Azure Agents service - * - */ - -import { AIProjectsClient, ToolUtility } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const storageServiceEndpoint = - process.env["STORAGE_SERVICE_ENDPOINT"] || ""; - - // create azure function tool - const azureFunctionTool = ToolUtility.createAzureFunctionTool( - "azure-function-tool", - "azure function tool", - { - type: "object", - properties: { - query: { type: "string", description: "The question to ask." }, - outputqueueuri: { type: "string", description: "The full output queue uri." }, - }, - }, - { - queueServiceEndpoint: storageServiceEndpoint, - queueName: "input-queue", - }, - { - queueServiceEndpoint: storageServiceEndpoint, - queueName: "output-queue", - }, - { - function: { - name: "azure-function-tool", - description: "Azure function", - parameters: { - type: "object", - properties: { - query: { type: "string", description: "The question to ask." }, - outputqueueuri: { type: "string", description: "The full output queue uri." }, - }, - }, - }, - inputBinding: { - type: "storage_queue", - storageQueue: { - queueName: "input-queue", - queueServiceEndpoint: storageServiceEndpoint, - }, - }, - outputBinding: { - type: "storage_queue", - storageQueue: { - queueName: "output-queue", - queueServiceEndpoint: storageServiceEndpoint, - }, - }, - }, - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "azure-function-agent", - instructions: `You are a helpful support agent. Use the provided function any time the prompt contains the string 'What would foo say?'. When you invoke the function, ALWAYS specify the output queue uri parameter as '${storageServiceEndpoint}/azure-function-tool-output'. Always responds with "Foo says" and then the response from the tool.`, - tools: [azureFunctionTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What is the most prevalent element in the universe? What would foo say?", - }); - console.log(`Created message, message ID: ${message.id}`); - - const run = await client.agents.createRun(thread.id, agent.id); - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - - // Get messages from the thread - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages: ${messages}`); - - // Get the last message from the sender - const messagesArray: any[] = [messages]; - const lastMsg = messagesArray.find((msg) => msg.role === "agent"); - if (lastMsg) { - console.log(`Last Message: ${lastMsg.content}`); - } - - // Delete the agent once done - const result = await client.agents.deleteAgent(agent.id); - if (result.deleted) { - console.log(`Deleted agent ${result.id}`); - } else { - console.log(`Failed to delete agent ${result.id}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsBasics.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsBasics.ts deleted file mode 100644 index e3219969a378..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsBasics.ts +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic agent operations. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID : ${thread.id}`); - - // List all threads for the agent - const threads = await client.agents.listThreads(); - console.log(`Threads for agent ${agent.id}:`); - for await (const t of (await threads).data) { - console.log(`Thread ID: ${t.id}`); - console.log(`Created at: ${t.createdAt}`); - console.log(`Metadata: ${t.metadata}`); - console.log(`---- `); - } - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - console.log(`Created message, message ID : ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run status: ${run.status}`); - - await client.agents.deleteAgent(agent.id); - - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsBingCustomSearch.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsBingCustomSearch.ts deleted file mode 100644 index d3bf169c00d8..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsBingCustomSearch.ts +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Customer Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Bing Customer Search tool. - * - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, ToolUtility, isOutputOfType } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const bingCustomSearchInstanceName = - process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || ""; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingCustomSearchConnection = await client.connections.getConnection( - process.env["BING_CUSTOM_SEARCH"] || "", - ); - console.log(`Bing custom search connection ID:`, bingCustomSearchConnection.id); - - // Initialize agent bing custom search tool with the connection id - const bingCustomSearchTool = ToolUtility.createBingCustomSearchTool([ - { - connectionId: bingCustomSearchConnection.id, - // please do not use bingCustomSearchConnection.name here - instanceName: bingCustomSearchInstanceName, - }, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: - "You are a customer support chatbot. Use the tools provided and your knowledge base to best respond to customer queries", - tools: [bingCustomSearchTool.definition], - requestOptions: { - headers: { - "x-ms-enable-preview": true, - }, - }, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${JSON.stringify(run, null, 2)}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsBingGrounding.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsBingGrounding.ts deleted file mode 100644 index b9a85a0ce044..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsBingGrounding.ts +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Grounding with Bing Search tool. - * - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { - AIProjectsClient, - ToolUtility, - connectionToolType, - isOutputOfType, -} from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingConnection = await client.connections.getConnection( - process.env["BING_CONNECTION_NAME"] || "", - ); - const connectionId = bingConnection.id; - - // Initialize agent bing tool with the connection id - const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [ - connectionId, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsBingGroundingWithStreaming.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsBingGroundingWithStreaming.ts deleted file mode 100644 index 398078d12172..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsBingGroundingWithStreaming.ts +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Grounding with Bing Search tool using streaming. - * - */ - -import type { - MessageContentOutput, - MessageDeltaChunk, - MessageDeltaTextContent, - MessageTextContentOutput, - ThreadRunOutput, -} from "@azure/ai-projects"; -import { - AIProjectsClient, - DoneEvent, - ErrorEvent, - MessageStreamEvent, - RunStreamEvent, - ToolUtility, - connectionToolType, - isOutputOfType, -} from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingConnection = await client.connections.getConnection( - process.env["BING_CONNECTION_NAME"] || "", - ); - const connectionId = bingConnection.id; - - const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [ - connectionId, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run with streaming in thread with tools - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsFabric.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsFabric.ts deleted file mode 100644 index f3733c913ae1..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsFabric.ts +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Microsoft Fabric tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Microsoft Fabric tool. - * - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, ToolUtility, isOutputOfType } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Studio project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const fabricConnection = await client.connections.getConnection( - process.env["FABRIC_CONNECTION_NAME"] || "", - ); - - const connectionId = fabricConnection.id; - - // Initialize agent Microsoft Fabric tool with the connection id - const fabricTool = ToolUtility.createFabricTool(connectionId); - - // Create agent with the Microsoft Fabric tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [fabricTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What are the top 3 weather events with the highest property damage?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the agent when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithBase64.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithBase64.ts deleted file mode 100644 index 50dc1c3e10e1..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithBase64.ts +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations with image input (base64 encoded) for the Azure Agents service. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const filePath = "./data/image_file.png"; - -/** - * Convert an image file to a Base64-encoded data URL. - * @param imagePath - The path to the image file - * @param mimeType - The MIME type of the image (e.g., 'image/png', 'image/jpeg') - * @returns A data URL with the Base64-encoded image - */ -function imageToBase64DataUrl(imagePath: string, mimeType: string): string { - try { - // Read the image file as binary - const imageBuffer = fs.readFileSync(imagePath); - // Convert to base64 - const base64Data = imageBuffer.toString("base64"); - // Format as a data URL - return `data:${mimeType};base64,${base64Data}`; - } catch (error) { - console.error(`Error reading image file at ${imagePath}:`, error); - throw error; - } -} - -export async function main(): Promise { - console.log("== AI Projects Agent with Base64 Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message with text and image content using base64 - console.log("Converting image to base64..."); - const imageDataUrl = imageToBase64DataUrl(filePath, "image/png"); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageDataUrl, - detail: "high", - }, - }, - ]; - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithFile.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithFile.ts deleted file mode 100644 index ab84a3332758..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithFile.ts +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations using image file input for the - * Azure Agents service. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const imagePath = "./data/image_file.png"; - -export async function main(): Promise { - console.log("== AI Projects Agent with Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Upload an image file - console.log("Uploading image file..."); - const fileStream = fs.createReadStream(imagePath); - const imageFile = await client.agents.uploadFile(fileStream, "assistants", { - fileName: "image_file.png", - }); - console.log(`Uploaded file, file ID: ${imageFile.id}`); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_file", - image_file: { - file_id: imageFile.id, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithUrl.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithUrl.ts deleted file mode 100644 index 269c27e07df9..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsImageInputWithUrl.ts +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations using image url input for the - * Azure Agents service. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const imageUrl = - "https://github.com/Azure/azure-sdk-for-js/blob/0aa88ceb18d865726d423f73b8393134e783aea6/sdk/ai/ai-projects/data/image_file.png?raw=true"; - -export async function main(): Promise { - console.log("== AI Projects Agent with Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageUrl, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsSharepoint.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsSharepoint.ts deleted file mode 100644 index f22f1ec5e74f..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsSharepoint.ts +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Sharepoint tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Sharepoint tool. - * - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { - AIProjectsClient, - ToolUtility, - connectionToolType, - isOutputOfType, -} from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as dotenv from "dotenv"; -dotenv.config(); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - // Create an an Azure AI Project client from a connection string, copied from your AI Foundry project web page. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const sharepointConnection = await client.connections.getConnection( - process.env["SHAREPOINT_CONNECTION_NAME"] || "", - ); - const connectionId = sharepointConnection.id; - - // Initialize agent Sharepoint tool with the connection id - const sharepointTool = ToolUtility.createConnectionTool(connectionToolType.SharepointGrounding, [ - connectionId, - ]); - - // Create agent with the Sharepoint tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [sharepointTool.definition], - }); - console.log(connectionId); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me about my health insurance options", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsWithFunctionTool.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsWithFunctionTool.ts deleted file mode 100644 index bcceb54c90c6..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsWithFunctionTool.ts +++ /dev/null @@ -1,206 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/* eslint-disable @typescript-eslint/no-unsafe-function-type */ - -/** - * This sample demonstrates how to use basic agent operations with function tool from the Azure Agents service. - * - * @summary demonstrates how to use basic agent operations using function tool. - * - */ - -import type { - FunctionToolDefinition, - FunctionToolDefinitionOutput, - MessageContentOutput, - MessageImageFileContentOutput, - MessageTextContentOutput, - RequiredToolCallOutput, - SubmitToolOutputsActionOutput, - ToolOutput, -} from "@azure/ai-projects"; -import { AIProjectsClient, ToolUtility, isOutputOfType } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const agents = client.agents; - class FunctionToolExecutor { - private functionTools: { func: Function; definition: FunctionToolDefinition }[]; - - constructor() { - this.functionTools = [ - { - func: this.getUserFavoriteCity, - ...ToolUtility.createFunctionTool({ - name: "getUserFavoriteCity", - description: "Gets the user's favorite city.", - parameters: {}, - }), - }, - { - func: this.getCityNickname, - ...ToolUtility.createFunctionTool({ - name: "getCityNickname", - description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - }, - }, - }), - }, - { - func: this.getWeather, - ...ToolUtility.createFunctionTool({ - name: "getWeather", - description: "Gets the weather for a location.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - unit: { type: "string", enum: ["c", "f"] }, - }, - }, - }), - }, - ]; - } - - private getUserFavoriteCity(): {} { - return { location: "Seattle, WA" }; - } - - private getCityNickname(_location: string): {} { - return { nickname: "The Emerald City" }; - } - - private getWeather(_location: string, unit: string): {} { - return { weather: unit === "f" ? "72f" : "22c" }; - } - - public invokeTool( - toolCall: RequiredToolCallOutput & FunctionToolDefinitionOutput, - ): ToolOutput | undefined { - console.log(`Function tool call - ${toolCall.function.name}`); - const args = []; - if (toolCall.function.parameters) { - try { - const params = JSON.parse(toolCall.function.parameters); - for (const key in params) { - if (Object.prototype.hasOwnProperty.call(params, key)) { - args.push(params[key]); - } - } - } catch (error) { - console.error(`Failed to parse parameters: ${toolCall.function.parameters}`, error); - return undefined; - } - } - const result = this.functionTools - .find((tool) => tool.definition.function.name === toolCall.function.name) - ?.func(...args); - return result - ? { - toolCallId: toolCall.id, - output: JSON.stringify(result), - } - : undefined; - } - - public getFunctionDefinitions(): FunctionToolDefinition[] { - return this.functionTools.map((tool) => { - return tool.definition; - }); - } - } - - const functionToolExecutor = new FunctionToolExecutor(); - const functionTools = functionToolExecutor.getFunctionDefinitions(); - const agent = await agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: - "You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.", - tools: functionTools, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "What's the weather like in my favorite city?", - }); - console.log(`Created message, message ID ${message.id}`); - - // Create run - let run = await agents.createRun(thread.id, agent.id); - console.log(`Created Run, Run ID: ${run.id}`); - - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - if (run.status === "requires_action" && run.requiredAction) { - console.log(`Run requires action - ${run.requiredAction}`); - if ( - isOutputOfType(run.requiredAction, "submit_tool_outputs") - ) { - const submitToolOutputsActionOutput = run.requiredAction as SubmitToolOutputsActionOutput; - const toolCalls = submitToolOutputsActionOutput.submitToolOutputs.toolCalls; - const toolResponses = []; - for (const toolCall of toolCalls) { - if (isOutputOfType(toolCall, "function")) { - const toolResponse = functionToolExecutor.invokeTool(toolCall); - if (toolResponse) { - toolResponses.push(toolResponse); - } - } - } - if (toolResponses.length > 0) { - run = await agents.submitToolOutputsToRun(thread.id, run.id, toolResponses); - console.log(`Submitted tool response - ${run.status}`); - } - } - } - } - - console.log(`Run status - ${run.status}, run ID: ${run.id}`); - const messages = await agents.listMessages(thread.id); - await messages.data.forEach((threadMessage) => { - console.log( - `Thread Message Created at - ${threadMessage.createdAt} - Role - ${threadMessage.role}`, - ); - threadMessage.content.forEach((content: MessageContentOutput) => { - if (isOutputOfType(content, "text")) { - const textContent = content as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } else if (isOutputOfType(content, "image_file")) { - const imageContent = content as MessageImageFileContentOutput; - console.log(`Image Message Content - ${imageContent.imageFile.fileId}`); - } - }); - }); - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsWithOpenApi.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsWithOpenApi.ts deleted file mode 100644 index dbdbf1ea4134..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsWithOpenApi.ts +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with an OpenApi tool. - * - * @summary demonstrates how to use agent operations with an OpenApi tool. - * - */ - -import type { MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Read in OpenApi spec - const filePath = "./data/weatherOpenApi.json"; - const openApiSpec = JSON.parse(fs.readFileSync(filePath, "utf-8")); - - // Define OpenApi function - const openApiFunction = { - name: "getWeather", - spec: openApiSpec, - description: "Retrieve weather information for a location", - auth: { - type: "anonymous", - }, - default_params: ["format"], // optional - }; - - // Create OpenApi tool - const openApiTool = ToolUtility.createOpenApiTool(openApiFunction); - - // Create agent with OpenApi tool - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "myAgent", - instructions: "You are a helpful agent", - tools: [openApiTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What's the weather in Seattle?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - // Check if you got "Rate limit is exceeded.", then you want to get more quota - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Get most recent message from the assistant - const messages = await client.agents.listMessages(thread.id); - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/agentsWithToolset.ts b/sdk/ai/ai-projects/samples-dev/agents/agentsWithToolset.ts deleted file mode 100644 index 743f5feb9438..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/agentsWithToolset.ts +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with toolset and iteration in streaming - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with toolset. - * - */ - -import { AIProjectsClient, ToolSet } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file for code interpreter tool - const filePath1 = "./data/nifty500QuarterlyResults.csv"; - const fileStream1 = fs.createReadStream(filePath1); - const codeInterpreterFile = await client.agents.uploadFile(fileStream1, "assistants", { - fileName: "myLocalFile", - }); - - console.log(`Uploaded local file, file ID : ${codeInterpreterFile.id}`); - - // Upload file for file search tool - const filePath2 = "./data/sampleFileForUpload.txt"; - const fileStream2 = fs.createReadStream(filePath2); - const fileSearchFile = await client.agents.uploadFile(fileStream2, "assistants", { - fileName: "sampleFileForUpload.txt", - }); - console.log(`Uploaded file, file ID: ${fileSearchFile.id}`); - - // Create vector store for file search tool - const vectorStore = await client.agents - .createVectorStoreAndPoll({ - fileIds: [fileSearchFile.id], - }) - .pollUntilDone(); - - // Create tool set - const toolSet = new ToolSet(); - await toolSet.addFileSearchTool([vectorStore.id]); - await toolSet.addCodeInterpreterTool([codeInterpreterFile.id]); - - // Create agent with tool set - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: toolSet.toolDefinitions, - toolResources: toolSet.toolResources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create threads, messages, and runs to interact with agent as desired - - // Delete agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/batchVectorStoreWithFiles.ts b/sdk/ai/ai-projects/samples-dev/agents/batchVectorStoreWithFiles.ts deleted file mode 100644 index 10511e17fd45..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/batchVectorStoreWithFiles.ts +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the batch vector store with the list of files. - * - * @summary demonstrates how to create the batch vector store with the list of files. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload first file - const file1Content = "Hello, Vector Store!"; - const readable1 = new Readable(); - await readable1.push(file1Content); - await readable1.push(null); // end the stream - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "vectorFile1.txt", - }); - console.log(`Uploaded file1, file ID: ${file1.id}`); - - // Create and upload second file - const file2Content = "This is another file for the Vector Store!"; - const readable2 = new Readable(); - await readable2.push(file2Content); - await readable2.push(null); // end the stream - const file2 = await client.agents.uploadFile(readable2, "assistants", { - fileName: "vectorFile2.txt", - }); - console.log(`Uploaded file2, file ID: ${file2.id}`); - - // Create vector store file batch - const vectorStoreFileBatch = await client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - console.log( - `Created vector store file batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Retrieve vector store file batch - const _vectorStoreFileBatch = await client.agents.getVectorStoreFileBatch( - vectorStore.id, - vectorStoreFileBatch.id, - ); - console.log( - `Retrieved vector store file batch, vector store file batch ID: ${_vectorStoreFileBatch.id}`, - ); - - // List vector store files in the batch - const vectorStoreFiles = await client.agents.listVectorStoreFileBatchFiles( - vectorStore.id, - vectorStoreFileBatch.id, - ); - console.log( - `List of vector store files in the batch: ${vectorStoreFiles.data.map((f) => f.id).join(", ")}`, - ); - - // Delete files - await client.agents.deleteFile(file1.id); - console.log(`Deleted file1, file ID: ${file1.id}`); - await client.agents.deleteFile(file2.id); - console.log(`Deleted file2, file ID: ${file2.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/batchVectorStoreWithFilesAndPolling.ts b/sdk/ai/ai-projects/samples-dev/agents/batchVectorStoreWithFilesAndPolling.ts deleted file mode 100644 index 418757852e1a..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/batchVectorStoreWithFilesAndPolling.ts +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the batch vector store with the list of files using polling operation. - * - * @summary demonstrates how to create the batch vector store with the list of files using polling operation. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload first file - const file1Content = "Hello, Vector Store!"; - const readable1 = new Readable(); - await readable1.push(file1Content); - await readable1.push(null); // end the stream - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "vectorFile1.txt", - }); - console.log(`Uploaded file1, file ID: ${file1.id}`); - - // Create and upload second file - const file2Content = "This is another file for the Vector Store!"; - const readable2 = new Readable(); - await readable2.push(file2Content); - await readable2.push(null); // end the stream - const file2 = await client.agents.uploadFile(readable2, "assistants", { - fileName: "vectorFile2.txt", - }); - console.log(`Uploaded file2, file ID: ${file2.id}`); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create vector store file batch, which will automatically poll until the operation is complete - const vectorStoreFileBatch1 = await client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - onResponse: onResponse, - }); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch1.status}, vector store file batch ID: ${vectorStoreFileBatch1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStoreFileBatchPoller = client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - onResponse: onResponse, - }); - const vectorStoreFileBatch2 = await vectorStoreFileBatchPoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch2.status}, vector store file batch ID: ${vectorStoreFileBatch2.id}`, - ); - - // Delete files - await client.agents.deleteFile(file1.id); - await client.agents.deleteFile(file2.id); - console.log(`Deleted files, file IDs: ${file1.id} & ${file2.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/codeInterpreter.ts b/sdk/ai/ai-projects/samples-dev/agents/codeInterpreter.ts deleted file mode 100644 index afd7edbfeaf2..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/codeInterpreter.ts +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with code interpreter from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with code interpreter. - * - */ - -import type { MessageImageFileContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; -import path from "node:path"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file and wait for it to be processed - const filePath = "./data/nifty500QuarterlyResults.csv"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "localFile", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Create code interpreter tool - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); - - // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create a bar chart in the TRANSPORTATION sector for the operating profit from the uploaded CSV file and provide the file to me?", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - // Check if you got "Rate limit is exceeded.", then you want to get more quota - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the original file from the agent to free up space (note: this does not delete your version of the file) - await client.agents.deleteFile(localFile.id); - console.log(`Deleted file, file ID: ${localFile.id}`); - - // Print the messages from the agent - const messages = await client.agents.listMessages(thread.id); - console.log("Messages:", messages); - - // Get most recent message from the assistant - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - - // Save the newly created file - console.log(`Saving new files...`); - const imageFile = (messages.data[0].content[0] as MessageImageFileContentOutput).imageFile; - console.log(`Image file ID : ${imageFile.fileId}`); - const imageFileName = path.resolve( - "./data/" + (await client.agents.getFile(imageFile.fileId)).filename + "ImageFile.png", - ); - - const fileContent = await ( - await client.agents.getFileContent(imageFile.fileId).asNodeStream() - ).body; - if (fileContent) { - const chunks: Buffer[] = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); - } else { - console.error("Failed to retrieve file content: fileContent is undefined"); - } - console.log(`Saved image file to: ${imageFileName}`); - - // Iterate through messages and print details for each annotation - console.log(`Message Details:`); - await messages.data.forEach((m) => { - console.log(`File Paths:`); - console.log(`Type: ${m.content[0].type}`); - if (isOutputOfType(m.content[0], "text")) { - const textContent = m.content[0] as MessageTextContentOutput; - console.log(`Text: ${textContent.text.value}`); - } - console.log(`File ID: ${m.id}`); - console.log(`Start Index: ${messages.firstId}`); - console.log(`End Index: ${messages.lastId}`); - }); - - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/codeInterpreterWithStreaming.ts b/sdk/ai/ai-projects/samples-dev/agents/codeInterpreterWithStreaming.ts deleted file mode 100644 index b6a5681f5673..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/codeInterpreterWithStreaming.ts +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with code interpreter from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with code interpreter. - * @azsdk-weight 100 - * - */ - -import type { - MessageDeltaChunk, - MessageDeltaTextContent, - MessageImageFileContentOutput, - MessageTextContentOutput, - ThreadRunOutput, -} from "@azure/ai-projects"; -import { - AIProjectsClient, - DoneEvent, - ErrorEvent, - isOutputOfType, - MessageStreamEvent, - RunStreamEvent, - ToolUtility, -} from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as fs from "fs"; -import path from "node:path"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file and wait for it to be processed - const filePath = "./data/nifty500QuarterlyResults.csv"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "myLocalFile", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Create code interpreter tool - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); - - // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create a bar chart in the TRANSPORTATION sector for the operating profit from the uploaded CSV file and provide the file to me?", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - // Delete the original file from the agent to free up space (note: this does not delete your version of the file) - await client.agents.deleteFile(localFile.id); - console.log(`Deleted file, file ID : ${localFile.id}`); - - // Print the messages from the agent - const messages = await client.agents.listMessages(thread.id); - console.log("Messages:", messages); - - // Get most recent message from the assistant - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - - // Save the newly created file - console.log(`Saving new files...`); - const imageFileOutput = messages.data[0].content[0] as MessageImageFileContentOutput; - const imageFile = imageFileOutput.imageFile.fileId; - const imageFileName = path.resolve( - "./data/" + (await client.agents.getFile(imageFile)).filename + "ImageFile.png", - ); - console.log(`Image file name : ${imageFileName}`); - - const fileContent = await (await client.agents.getFileContent(imageFile).asNodeStream()).body; - if (fileContent) { - const chunks: Buffer[] = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); - } else { - console.error("Failed to retrieve file content: fileContent is undefined"); - } - console.log(`Saved image file to: ${imageFileName}`); - - // Iterate through messages and print details for each annotation - console.log(`Message Details:`); - await messages.data.forEach((m) => { - console.log(`File Paths:`); - console.log(`Type: ${m.content[0].type}`); - if (isOutputOfType(m.content[0], "text")) { - const textContent = m.content[0] as MessageTextContentOutput; - console.log(`Text: ${textContent.text.value}`); - } - console.log(`File ID: ${m.id}`); - console.log(`Start Index: ${messages.firstId}`); - console.log(`End Index: ${messages.lastId}`); - }); - - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/fileSearch.ts b/sdk/ai/ai-projects/samples-dev/agents/fileSearch.ts deleted file mode 100644 index 1188a1ed430f..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/fileSearch.ts +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with file searching from the Azure Agents service. - * - * @summary This sample demonstrates how to use agent operations with file searching. - * - */ - -import type { - MessageContentOutput, - MessageImageFileContentOutput, - MessageTextContentOutput, -} from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as fs from "fs"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file - const filePath = "./data/sampleFileForUpload.txt"; - const localFileStream = fs.createReadStream(filePath); - const file = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "sampleFileForUpload.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store - const vectorStore = await client.agents.createVectorStore({ - fileIds: [file.id], - name: "myVectorStore", - }); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Initialize file search tool - const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]); - - // Create agent with files - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "SDK Test Agent - Retrieval", - instructions: "You are helpful agent that can help fetch data from files you know about.", - tools: [fileSearchTool.definition], - toolResources: fileSearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Can you give me the documented codes for 'banana' and 'orange'?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - while (["queued", "in_progress"].includes(run.status)) { - await delay(500); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - } - - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - const messages = await client.agents.listMessages(thread.id); - await messages.data.forEach((threadMessage) => { - console.log( - `Thread Message Created at - ${threadMessage.createdAt} - Role - ${threadMessage.role}`, - ); - threadMessage.content.forEach((content: MessageContentOutput) => { - if (isOutputOfType(content, "text")) { - const textContent = content as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } else if (isOutputOfType(content, "image_file")) { - const imageContent = content as MessageImageFileContentOutput; - console.log(`Image Message Content - ${imageContent.imageFile.fileId}`); - } - }); - }); - - // Delete agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/files.ts b/sdk/ai/ai-projects/samples-dev/agents/files.ts deleted file mode 100644 index e130f2eb5590..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/files.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic files agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic files agent operations. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import { Readable } from "node:stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create and upload file - const fileContent = "Hello, World!"; - // Create a readable stream from the string content - const readable = Readable.from(Buffer.from(fileContent)); - const file = await client.agents.uploadFile(readable, "assistants", { fileName: "myFile.txt" }); - console.log(`Uploaded file, file ID : ${file.id}`); - - // List uploaded files - const files = await client.agents.listFiles(); - - console.log(`List of files : ${files.data[0].filename}`); - - // Retrieve file - const _file = await client.agents.getFile(file.id); - - console.log(`Retrieved file, file ID : ${_file.id}`); - - // Delete file - await client.agents.deleteFile(file.id); - - console.log(`Deleted file, file ID : ${file.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/filesWithLocalUpload.ts b/sdk/ai/ai-projects/samples-dev/agents/filesWithLocalUpload.ts deleted file mode 100644 index 0f6f99400116..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/filesWithLocalUpload.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic files agent operations with local file upload from the Azure Agents service. - * - * @summary demonstrates how to use basic files agent operations with local file upload. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as fs from "fs"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload local file - const filePath = "./data/localFile.txt"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "myLocalFile.txt", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Retrieve local file - const retrievedLocalFile = await client.agents.getFile(localFile.id); - - console.log(`Retrieved local file, file ID : ${retrievedLocalFile.id}`); - - // Delete local file - await client.agents.deleteFile(localFile.id); - - console.log(`Deleted local file, file ID : ${localFile.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/filesWithPolling.ts b/sdk/ai/ai-projects/samples-dev/agents/filesWithPolling.ts deleted file mode 100644 index 96065bcce37f..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/filesWithPolling.ts +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to upload a file and poll for its status. - * - * @summary demonstrates how to upload a file and poll for its status. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create file content - const fileContent1 = "Hello, World!"; - const readable1 = new Readable(); - readable1.push(fileContent1); - readable1.push(null); // end the stream - - const fileContent2 = "How are you?"; - const readable2 = new Readable(); - readable2.push(fileContent2); - readable2.push(null); // end the stream - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Upload file, which will automatically poll until the operation is complete - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "myPollingFile.txt", - onResponse: onResponse, - }); - console.log(`Uploaded file with status ${file1.status}, file ID : ${file1.id}`); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const filePoller = client.agents.uploadFile(readable2, "assistants", { - fileName: "myPollingFile.txt", - onResponse: onResponse, - }); - const file2 = await filePoller.pollUntilDone({ abortSignal: abortController.signal }); - console.log(`Uploaded file with status ${file2.status}, file ID: ${file2.id}`); - - // Delete file - await client.agents.deleteFile(file1.id); - await client.agents.deleteFile(file2.id); - console.log(`Deleted files, file IDs: ${file1.id} & ${file2.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/messages.ts b/sdk/ai/ai-projects/samples-dev/agents/messages.ts deleted file mode 100644 index 5e8a1c498941..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/messages.ts +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic message agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic message agent operations. - * - */ - -import type { MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - }); - const thread = await client.agents.createThread(); - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - const messages = await client.agents.listMessages(thread.id); - console.log( - `Message ${message.id} contents: ${(messages.data[0].content[0] as MessageTextContentOutput).text.value}`, - ); - - const updatedMessage = await client.agents.updateMessage(thread.id, message.id, { - metadata: { introduction: "true" }, - }); - console.log(`Updated message metadata - introduction: ${updatedMessage.metadata?.introduction}`); - - await client.agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID : ${thread.id}`); - - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID : ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/runSteps.ts b/sdk/ai/ai-projects/samples-dev/agents/runSteps.ts deleted file mode 100644 index 85b21188188b..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/runSteps.ts +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic run agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic run agent operations. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create agent - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - - // Wait for run to complete - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Run status: ${run.status}`); - } - - // List run steps - const runSteps = await client.agents.listRunSteps(thread.id, run.id); - console.log(`Listed run steps, run ID: ${run.id}`); - - // Get specific run step - const stepId = runSteps.data[0].id; - const step = await client.agents.getRunStep(thread.id, run.id, stepId); - console.log(`Retrieved run step, step ID: ${step.id}`); - - // Clean up - await client.agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/streaming.ts b/sdk/ai/ai-projects/samples-dev/agents/streaming.ts deleted file mode 100644 index 9b41275fc95c..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/streaming.ts +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations in streaming from the Azure Agents service. - * - * @summary demonstrates how to use agent operations in streaming. - * - */ - -import type { - MessageDeltaChunk, - MessageDeltaTextContent, - ThreadRunOutput, -} from "@azure/ai-projects"; -import { - AIProjectsClient, - DoneEvent, - ErrorEvent, - MessageStreamEvent, - RunStreamEvent, -} from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-assistant", - instructions: "You are helpful agent", - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - const thread = await client.agents.createThread(); - - console.log(`Created thread, thread ID : ${agent.id}`); - - await client.agents.createMessage(thread.id, { role: "user", content: "Hello, tell me a joke" }); - - console.log(`Created message, thread ID : ${agent.id}`); - - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - await client.agents.deleteAgent(agent.id); - console.log(`Delete agent, agent ID : ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/threads.ts b/sdk/ai/ai-projects/samples-dev/agents/threads.ts deleted file mode 100644 index a59b34f2f506..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/threads.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic thread agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic thread agent operations. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const thread = await client.agents.createThread(); - - console.log(`Created thread, thread ID : ${thread.id}`); - - const _thread = await client.agents.getThread(thread.id); - - console.log(`Retrieved thread, thread ID : ${_thread.id}`); - - await client.agents.deleteThread(thread.id); - - console.log(`Deleted thread, thread ID : ${_thread.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/vectorStoreWithFiles.ts b/sdk/ai/ai-projects/samples-dev/agents/vectorStoreWithFiles.ts deleted file mode 100644 index 37693aa05ccf..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/vectorStoreWithFiles.ts +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store with the list of files. - * - * @summary demonstrates how to create the vector store with the list of files. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload file - const fileContent = "Hello, Vector Store!"; - const readable = new Readable(); - await readable.push(fileContent); - await readable.push(null); // end the stream - const file = await client.agents.uploadFile(readable, "assistants", { - fileName: "vectorFile.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file - const vectorStoreFile = await client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - }); - console.log(`Created vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Retrieve vector store file - const _vectorStoreFile = await client.agents.getVectorStoreFile( - vectorStore.id, - vectorStoreFile.id, - ); - console.log(`Retrieved vector store file, vector store file ID: ${_vectorStoreFile.id}`); - - // List vector store files - const vectorStoreFiles = await client.agents.listVectorStoreFiles(vectorStore.id); - console.log(`List of vector store files: ${vectorStoreFiles.data.map((f) => f.id).join(", ")}`); - - // Delete vector store file - await client.agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Delete file - await client.agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/vectorStoreWithFilesAndPolling.ts b/sdk/ai/ai-projects/samples-dev/agents/vectorStoreWithFilesAndPolling.ts deleted file mode 100644 index 1c80a0b95c78..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/vectorStoreWithFilesAndPolling.ts +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store with the list of files using polling operation. - * - * @summary demonstrates how to create the vector store with the list of files using polling operation. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload file - const fileContent = "Hello, Vector Store!"; - const readable = new Readable(); - await readable.push(fileContent); - await readable.push(null); // end the stream - const file = await client.agents.uploadFile(readable, "assistants", { - fileName: "vectorFile.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create vector store file, which will automatically poll until the operation is complete - const vectorStoreFile1 = await client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - console.log( - `Created vector store file with status ${vectorStoreFile1.status}, vector store file ID: ${vectorStoreFile1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStoreFilePoller = client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - const vectorStoreFile2 = await vectorStoreFilePoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store file with status ${vectorStoreFile2.status}, vector store file ID: ${vectorStoreFile2.id}`, - ); - - // Delete file - await client.agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/vectorStores.ts b/sdk/ai/ai-projects/samples-dev/agents/vectorStores.ts deleted file mode 100644 index 180499d6d9b6..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/vectorStores.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store. - * - * @summary demonstrates how to create the vector store. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create a vector store - const vectorStore = await client.agents.createVectorStore({ name: "myVectorStore" }); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // List vector stores - const vectorStores = await client.agents.listVectorStores(); - console.log("List of vector stores:", vectorStores); - - // Modify the vector store - const updatedVectorStore = await client.agents.modifyVectorStore(vectorStore.id, { - name: "updatedVectorStore", - }); - console.log(`Updated vector store, vector store ID: ${updatedVectorStore.id}`); - - // Get a specific vector store - const retrievedVectorStore = await client.agents.getVectorStore(vectorStore.id); - console.log(`Retrieved vector store, vector store ID: ${retrievedVectorStore.id}`); - - // Delete the vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/agents/vectorStoresWithPolling.ts b/sdk/ai/ai-projects/samples-dev/agents/vectorStoresWithPolling.ts deleted file mode 100644 index 9feeb4f90335..000000000000 --- a/sdk/ai/ai-projects/samples-dev/agents/vectorStoresWithPolling.ts +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store using polling operation. - * - * @summary demonstrates how to create the vector store using polling operation. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create a vector, which will automatically poll until the operation is complete - const vectorStore1 = await client.agents.createVectorStore({ - name: "myVectorStore", - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - console.log( - `Created vector store with status ${vectorStore1.status}, vector store ID: ${vectorStore1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStorePoller = client.agents.createVectorStore({ - name: "myVectorStore", - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - const vectorStore2 = await vectorStorePoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store with status ${vectorStore2.status}, vector store ID: ${vectorStore2.id}`, - ); - - // Delete the vector store - await client.agents.deleteVectorStore(vectorStore1.id); - await client.agents.deleteVectorStore(vectorStore2.id); - console.log(`Deleted vector stores, vector store IDs: ${vectorStore1.id} & ${vectorStore2.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples-dev/connections/connectionsBasics.ts b/sdk/ai/ai-projects/samples-dev/connections/connectionsBasics.ts deleted file mode 100644 index f014f8321582..000000000000 --- a/sdk/ai/ai-projects/samples-dev/connections/connectionsBasics.ts +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to how to use basic connections operations. - * - * @summary Given an AIProjectClient, this sample demonstrates how to enumerate the properties of all connections, - * get the properties of a default connection, and get the properties of a connection by its name. - * - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as dotenv from "dotenv"; -dotenv.config(); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // List the details of all the connections - const connections = await client.connections.listConnections(); - console.log(`Retrieved ${connections.length} connections`); - - // Get the details of a connection, without credentials - const connectionName = connections[0].name; - const connection = await client.connections.getConnection(connectionName); - console.log(`Retrieved connection, connection name: ${connection.name}`); - - // Get the details of a connection, including credentials (if available) - const connectionWithSecrets = await client.connections.getConnectionWithSecrets(connectionName); - console.log(`Retrieved connection with secrets, connection name: ${connectionWithSecrets.name}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/README.md b/sdk/ai/ai-projects/samples/v1-beta/javascript/README.md deleted file mode 100644 index 26cc021af082..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/README.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -page_type: sample -languages: - - javascript -products: - - azure -urlFragment: ai-projects-javascript-beta ---- - -# Azure AI Projects client library samples for JavaScript (Beta) - -These sample programs show how to use the JavaScript client libraries for Azure AI Projects in some common scenarios. - -| **File Name** | **Description** | -| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [agents/codeInterpreterWithStreaming.js][agents_codeinterpreterwithstreaming] | demonstrates how to use agent operations with code interpreter. | -| [agents/agentCreateWithTracingConsole.js][agents_agentcreatewithtracingconsole] | Create Agent and instrument using open telemetry. | -| [agents/agentTokenUsage.js][agents_agenttokenusage] | demonstrates how to track the token usage of an Agent. | -| [agents/agentsAzureAiSearch.js][agents_agentsazureaisearch] | demonstrates how to use agent operations with the Azure AI Search tool. | -| [agents/agentsAzureFunctions.js][agents_agentsazurefunctions] | demonstrates how to use azure function agent operations from the Azure Agents service | -| [agents/agentsBasics.js][agents_agentsbasics] | demonstrates how to use basic agent operations. | -| [agents/agentsBingCustomSearch.js][agents_agentsbingcustomsearch] | demonstrates how to use agent operations with the Bing Customer Search tool. | -| [agents/agentsBingGrounding.js][agents_agentsbinggrounding] | demonstrates how to use agent operations with the Grounding with Bing Search tool. | -| [agents/agentsBingGroundingWithStreaming.js][agents_agentsbinggroundingwithstreaming] | demonstrates how to use agent operations with the Grounding with Bing Search tool using streaming. | -| [agents/agentsFabric.js][agents_agentsfabric] | demonstrates how to use agent operations with the Microsoft Fabric tool. | -| [agents/agentsImageInputWithBase64.js][agents_agentsimageinputwithbase64] | This sample demonstrates how to use basic agent operations with image input (base64 encoded) for the Azure Agents service. | -| [agents/agentsImageInputWithFile.js][agents_agentsimageinputwithfile] | This sample demonstrates how to use basic agent operations using image file input for the Azure Agents service. | -| [agents/agentsImageInputWithUrl.js][agents_agentsimageinputwithurl] | This sample demonstrates how to use basic agent operations using image url input for the Azure Agents service. | -| [agents/agentsSharepoint.js][agents_agentssharepoint] | demonstrates how to use agent operations with the Sharepoint tool. | -| [agents/agentsWithFunctionTool.js][agents_agentswithfunctiontool] | demonstrates how to use basic agent operations using function tool. | -| [agents/agentsWithOpenApi.js][agents_agentswithopenapi] | demonstrates how to use agent operations with an OpenApi tool. | -| [agents/agentsWithToolset.js][agents_agentswithtoolset] | demonstrates how to use agent operations with toolset. | -| [agents/batchVectorStoreWithFiles.js][agents_batchvectorstorewithfiles] | demonstrates how to create the batch vector store with the list of files. | -| [agents/batchVectorStoreWithFilesAndPolling.js][agents_batchvectorstorewithfilesandpolling] | demonstrates how to create the batch vector store with the list of files using polling operation. | -| [agents/codeInterpreter.js][agents_codeinterpreter] | demonstrates how to use agent operations with code interpreter. | -| [agents/fileSearch.js][agents_filesearch] | This sample demonstrates how to use agent operations with file searching. | -| [agents/files.js][agents_files] | demonstrates how to use basic files agent operations. | -| [agents/filesWithLocalUpload.js][agents_fileswithlocalupload] | demonstrates how to use basic files agent operations with local file upload. | -| [agents/filesWithPolling.js][agents_fileswithpolling] | demonstrates how to upload a file and poll for its status. | -| [agents/messages.js][agents_messages] | demonstrates how to use basic message agent operations. | -| [agents/runSteps.js][agents_runsteps] | demonstrates how to use basic run agent operations. | -| [agents/streaming.js][agents_streaming] | demonstrates how to use agent operations in streaming. | -| [agents/threads.js][agents_threads] | demonstrates how to use basic thread agent operations. | -| [agents/vectorStoreWithFiles.js][agents_vectorstorewithfiles] | demonstrates how to create the vector store with the list of files. | -| [agents/vectorStoreWithFilesAndPolling.js][agents_vectorstorewithfilesandpolling] | demonstrates how to create the vector store with the list of files using polling operation. | -| [agents/vectorStores.js][agents_vectorstores] | demonstrates how to create the vector store. | -| [agents/vectorStoresWithPolling.js][agents_vectorstoreswithpolling] | demonstrates how to create the vector store using polling operation. | -| [connections/connectionsBasics.js][connections_connectionsbasics] | Given an AIProjectClient, this sample demonstrates how to enumerate the properties of all connections, get the properties of a default connection, and get the properties of a connection by its name. | - -## Prerequisites - -The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). - -You need [an Azure subscription][freesub] to run these sample programs. - -Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -3. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node agents\codeInterpreterWithStreaming.js -``` - -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): - -```bash -npx dev-tool run vendored cross-env AZURE_AI_PROJECTS_CONNECTION_STRING="" MODEL_DEPLOYMENT_NAME="" node agents\codeInterpreterWithStreaming.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[agents_codeinterpreterwithstreaming]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreterWithStreaming.js -[agents_agentcreatewithtracingconsole]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentCreateWithTracingConsole.js -[agents_agenttokenusage]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentTokenUsage.js -[agents_agentsazureaisearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureAiSearch.js -[agents_agentsazurefunctions]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureFunctions.js -[agents_agentsbasics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBasics.js -[agents_agentsbingcustomsearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingCustomSearch.js -[agents_agentsbinggrounding]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGrounding.js -[agents_agentsbinggroundingwithstreaming]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGroundingWithStreaming.js -[agents_agentsfabric]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsFabric.js -[agents_agentsimageinputwithbase64]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithBase64.js -[agents_agentsimageinputwithfile]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithFile.js -[agents_agentsimageinputwithurl]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithUrl.js -[agents_agentssharepoint]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsSharepoint.js -[agents_agentswithfunctiontool]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithFunctionTool.js -[agents_agentswithopenapi]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithOpenApi.js -[agents_agentswithtoolset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithToolset.js -[agents_batchvectorstorewithfiles]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFiles.js -[agents_batchvectorstorewithfilesandpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFilesAndPolling.js -[agents_codeinterpreter]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreter.js -[agents_filesearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/fileSearch.js -[agents_files]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/files.js -[agents_fileswithlocalupload]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithLocalUpload.js -[agents_fileswithpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithPolling.js -[agents_messages]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/messages.js -[agents_runsteps]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/runSteps.js -[agents_streaming]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/streaming.js -[agents_threads]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/threads.js -[agents_vectorstorewithfiles]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFiles.js -[agents_vectorstorewithfilesandpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFilesAndPolling.js -[agents_vectorstores]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStores.js -[agents_vectorstoreswithpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoresWithPolling.js -[connections_connectionsbasics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/javascript/connections/connectionsBasics.js -[apiref]: https://learn.microsoft.com/javascript/api/@azure/ai-projects -[freesub]: https://azure.microsoft.com/free/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/README.md diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentCreateWithTracingConsole.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentCreateWithTracingConsole.js deleted file mode 100644 index 67693b8453eb..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentCreateWithTracingConsole.js +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * Demonstrates How to instrument and get tracing using open telemetry. - * - * @summary Create Agent and instrument using open telemetry. - */ - -const { AzureMonitorTraceExporter } = require("@azure/monitor-opentelemetry-exporter"); -const { createAzureSdkInstrumentation } = require("@azure/opentelemetry-instrumentation-azure-sdk"); -const { context, trace } = require("@opentelemetry/api"); -const { registerInstrumentations } = require("@opentelemetry/instrumentation"); -const { - ConsoleSpanExporter, - NodeTracerProvider, - SimpleSpanProcessor, -} = require("@opentelemetry/sdk-trace-node"); - -require("dotenv/config"); - -const provider = new NodeTracerProvider(); -provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); -provider.register(); - -registerInstrumentations({ - instrumentations: [createAzureSdkInstrumentation()], -}); - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -let appInsightsConnectionString = process.env["APPLICATIONINSIGHTS_CONNECTION_STRING"]; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const tracer = trace.getTracer("Agents Sample", "1.0.0"); - - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - if (!appInsightsConnectionString) { - appInsightsConnectionString = await client.telemetry.getConnectionString(); - } - - if (appInsightsConnectionString) { - const exporter = new AzureMonitorTraceExporter({ - connectionString: appInsightsConnectionString, - }); - provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); - } - - await tracer.startActiveSpan("main", async (span) => { - client.telemetry.updateSettings({ enableContentRecording: true }); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - tracingOptions: { tracingContext: context.active() }, - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - const thread = await client.agents.createThread(); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - console.log(`Created message, message ID ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created Run, Run ID: ${run.id}`); - - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - } - - await client.agents.deleteAgent(agent.id); - - console.log(`Deleted agent`); - - await client.agents.listMessages(thread.id); - - span.end(); - }); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentTokenUsage.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentTokenUsage.js deleted file mode 100644 index d7c3aae45053..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentTokenUsage.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to track the token usage of an Agent in the Azure Agents service. - * - * @summary demonstrates how to track the token usage of an Agent. - */ -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create an Agent - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - }); - - // Create a thread - const thread = await client.agents.createThread(); - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - // the usage should be null at this point - console.log(`usage for run ${run.id}:`, JSON.stringify(run.usage, null, 2)); - // Wait for run to complete - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Run status: ${run.status}`); - } - - // token usage should be like this: - // { - // "completionTokens": 16, - // "promptTokens": 56, - // "totalTokens": 72 - // } - console.log(`usage for run ${run.id}:`, JSON.stringify(run.usage, null, 2)); - - // Delete the Agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted Agent, Agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureAiSearch.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureAiSearch.js deleted file mode 100644 index 0869b158372a..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureAiSearch.js +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Azure AI Search tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Azure AI Search tool. - */ - -const { AIProjectsClient, isOutputOfType, ToolUtility } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const connectionName = process.env["AZURE_AI_SEARCH_CONNECTION_NAME"] || ""; - const connection = await client.connections.getConnection(connectionName); - - // Initialize Azure AI Search tool - const azureAISearchTool = ToolUtility.createAzureAISearchTool(connection.id, "ai-search-sample", { - queryType: "simple", - topK: 3, - filter: "", - }); - - // Create agent with the Azure AI search tool - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [azureAISearchTool.definition], - toolResources: azureAISearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What is the temperature rating of the cozynights sleeping bag?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed:`, JSON.stringify(run, null, 2)); - } - console.log(`Run finished with status: ${run.status}`); - - // Fetch run steps to get the details of agent run - const { data: runSteps } = await client.agents.listRunSteps(thread.id, run.id); - - for (const step of runSteps) { - console.log(`Step ID: ${step.id}, Status: ${step.status}`); - const stepDetails = step.stepDetails; - if (isOutputOfType(stepDetails, "tool_calls")) { - const toolCalls = stepDetails.toolCalls; - for (const toolCall of toolCalls) { - console.log(`Tool Call ID: ${toolCall.id}, Tool type: ${toolCall.type}`); - if (isOutputOfType(toolCall, "azure_ai_search")) { - { - const azureAISearch = toolCall.azureAISearch; - if (azureAISearch) { - console.log(`Azure AI Search Tool Call input: ${azureAISearch.input}`); - console.log(`Azure AI Search Tool Call output: ${azureAISearch.output}`); - } - } - } - } - } - } - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureFunctions.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureFunctions.js deleted file mode 100644 index 6a19841c99d2..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsAzureFunctions.js +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use azure function agent operations from the Azure Agents service - * - * @summary demonstrates how to use azure function agent operations from the Azure Agents service - */ - -const { AIProjectsClient, ToolUtility } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const storageServiceEndpoint = - process.env["STORAGE_SERVICE_ENDPOINT"] || ""; - - // create azure function tool - const azureFunctionTool = ToolUtility.createAzureFunctionTool( - "azure-function-tool", - "azure function tool", - { - type: "object", - properties: { - query: { type: "string", description: "The question to ask." }, - outputqueueuri: { type: "string", description: "The full output queue uri." }, - }, - }, - { - queueServiceEndpoint: storageServiceEndpoint, - queueName: "input-queue", - }, - { - queueServiceEndpoint: storageServiceEndpoint, - queueName: "output-queue", - }, - { - function: { - name: "azure-function-tool", - description: "Azure function", - parameters: { - type: "object", - properties: { - query: { type: "string", description: "The question to ask." }, - outputqueueuri: { type: "string", description: "The full output queue uri." }, - }, - }, - }, - inputBinding: { - type: "storage_queue", - storageQueue: { - queueName: "input-queue", - queueServiceEndpoint: storageServiceEndpoint, - }, - }, - outputBinding: { - type: "storage_queue", - storageQueue: { - queueName: "output-queue", - queueServiceEndpoint: storageServiceEndpoint, - }, - }, - }, - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "azure-function-agent", - instructions: `You are a helpful support agent. Use the provided function any time the prompt contains the string 'What would foo say?'. When you invoke the function, ALWAYS specify the output queue uri parameter as '${storageServiceEndpoint}/azure-function-tool-output'. Always responds with "Foo says" and then the response from the tool.`, - tools: [azureFunctionTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What is the most prevalent element in the universe? What would foo say?", - }); - console.log(`Created message, message ID: ${message.id}`); - - const run = await client.agents.createRun(thread.id, agent.id); - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - - // Get messages from the thread - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages: ${messages}`); - - // Get the last message from the sender - const messagesArray = [messages]; - const lastMsg = messagesArray.find((msg) => msg.role === "agent"); - if (lastMsg) { - console.log(`Last Message: ${lastMsg.content}`); - } - - // Delete the agent once done - const result = await client.agents.deleteAgent(agent.id); - if (result.deleted) { - console.log(`Deleted agent ${result.id}`); - } else { - console.log(`Failed to delete agent ${result.id}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBasics.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBasics.js deleted file mode 100644 index af1b8604394e..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBasics.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic agent operations. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID : ${thread.id}`); - - // List all threads for the agent - const threads = await client.agents.listThreads(); - console.log(`Threads for agent ${agent.id}:`); - for await (const t of (await threads).data) { - console.log(`Thread ID: ${t.id}`); - console.log(`Created at: ${t.createdAt}`); - console.log(`Metadata: ${t.metadata}`); - console.log(`---- `); - } - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - console.log(`Created message, message ID : ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run status: ${run.status}`); - - await client.agents.deleteAgent(agent.id); - - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingCustomSearch.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingCustomSearch.js deleted file mode 100644 index 58928f49d916..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingCustomSearch.js +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Customer Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Bing Customer Search tool. - */ - -const { AIProjectsClient, ToolUtility, isOutputOfType } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const bingCustomSearchInstanceName = - process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || ""; - -async function main() { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingCustomSearchConnection = await client.connections.getConnection( - process.env["BING_CUSTOM_SEARCH"] || "", - ); - console.log(`Bing custom search connection ID:`, bingCustomSearchConnection.id); - - // Initialize agent bing custom search tool with the connection id - const bingCustomSearchTool = ToolUtility.createBingCustomSearchTool([ - { - connectionId: bingCustomSearchConnection.id, - // please do not use bingCustomSearchConnection.name here - instanceName: bingCustomSearchInstanceName, - }, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: - "You are a customer support chatbot. Use the tools provided and your knowledge base to best respond to customer queries", - tools: [bingCustomSearchTool.definition], - requestOptions: { - headers: { - "x-ms-enable-preview": true, - }, - }, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${JSON.stringify(run, null, 2)}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGrounding.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGrounding.js deleted file mode 100644 index fb5aecfa0a39..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGrounding.js +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Grounding with Bing Search tool. - */ - -const { - AIProjectsClient, - ToolUtility, - connectionToolType, - isOutputOfType, -} = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingConnection = await client.connections.getConnection( - process.env["BING_CONNECTION_NAME"] || "", - ); - const connectionId = bingConnection.id; - - // Initialize agent bing tool with the connection id - const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [ - connectionId, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGroundingWithStreaming.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGroundingWithStreaming.js deleted file mode 100644 index e603de822cfa..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsBingGroundingWithStreaming.js +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Grounding with Bing Search tool using streaming. - */ - -const { - AIProjectsClient, - DoneEvent, - ErrorEvent, - MessageStreamEvent, - RunStreamEvent, - ToolUtility, - connectionToolType, - isOutputOfType, -} = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingConnection = await client.connections.getConnection( - process.env["BING_CONNECTION_NAME"] || "", - ); - const connectionId = bingConnection.id; - - const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [ - connectionId, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run with streaming in thread with tools - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${eventMessage.data.status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsFabric.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsFabric.js deleted file mode 100644 index e4e037984ee6..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsFabric.js +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Microsoft Fabric tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Microsoft Fabric tool. - */ - -const { AIProjectsClient, ToolUtility, isOutputOfType } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - // Create an Azure AI Client from a connection string, copied from your AI Studio project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const fabricConnection = await client.connections.getConnection( - process.env["FABRIC_CONNECTION_NAME"] || "", - ); - - const connectionId = fabricConnection.id; - - // Initialize agent Microsoft Fabric tool with the connection id - const fabricTool = ToolUtility.createFabricTool(connectionId); - - // Create agent with the Microsoft Fabric tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [fabricTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What are the top 3 weather events with the highest property damage?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the agent when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithBase64.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithBase64.js deleted file mode 100644 index 673430b30940..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithBase64.js +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations with image input (base64 encoded) for the Azure Agents service. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const fs = require("fs"); - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const filePath = "./data/image_file.png"; - -/** - * Convert an image file to a Base64-encoded data URL. - * @param imagePath - The path to the image file - * @param mimeType - The MIME type of the image (e.g., 'image/png', 'image/jpeg') - * @returns A data URL with the Base64-encoded image - */ -function imageToBase64DataUrl(imagePath, mimeType) { - try { - // Read the image file as binary - const imageBuffer = fs.readFileSync(imagePath); - // Convert to base64 - const base64Data = imageBuffer.toString("base64"); - // Format as a data URL - return `data:${mimeType};base64,${base64Data}`; - } catch (error) { - console.error(`Error reading image file at ${imagePath}:`, error); - throw error; - } -} - -async function main() { - console.log("== AI Projects Agent with Base64 Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message with text and image content using base64 - console.log("Converting image to base64..."); - const imageDataUrl = imageToBase64DataUrl(filePath, "image/png"); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageDataUrl, - detail: "high", - }, - }, - ]; - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithFile.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithFile.js deleted file mode 100644 index 4a1782da09e8..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithFile.js +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations using image file input for the - * Azure Agents service. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const fs = require("fs"); - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const imagePath = "./data/image_file.png"; - -async function main() { - console.log("== AI Projects Agent with Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Upload an image file - console.log("Uploading image file..."); - const fileStream = fs.createReadStream(imagePath); - const imageFile = await client.agents.uploadFile(fileStream, "assistants", { - fileName: "image_file.png", - }); - console.log(`Uploaded file, file ID: ${imageFile.id}`); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_file", - image_file: { - file_id: imageFile.id, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithUrl.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithUrl.js deleted file mode 100644 index dc3d67c40244..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsImageInputWithUrl.js +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations using image url input for the - * Azure Agents service. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const imageUrl = - "https://github.com/Azure/azure-sdk-for-js/blob/0aa88ceb18d865726d423f73b8393134e783aea6/sdk/ai/ai-projects/data/image_file.png?raw=true"; - -async function main() { - console.log("== AI Projects Agent with Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageUrl, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsSharepoint.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsSharepoint.js deleted file mode 100644 index 2d9eafebcf44..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsSharepoint.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Sharepoint tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Sharepoint tool. - */ - -const { - AIProjectsClient, - ToolUtility, - connectionToolType, - isOutputOfType, -} = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv").config(); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - // Create an an Azure AI Project client from a connection string, copied from your AI Foundry project web page. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const sharepointConnection = await client.connections.getConnection( - process.env["SHAREPOINT_CONNECTION_NAME"] || "", - ); - const connectionId = sharepointConnection.id; - - // Initialize agent Sharepoint tool with the connection id - const sharepointTool = ToolUtility.createConnectionTool(connectionToolType.SharepointGrounding, [ - connectionId, - ]); - - // Create agent with the Sharepoint tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [sharepointTool.definition], - }); - console.log(connectionId); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me about my health insurance options", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithFunctionTool.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithFunctionTool.js deleted file mode 100644 index 7b9255764342..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithFunctionTool.js +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/* eslint-disable @typescript-eslint/no-unsafe-function-type - */ - -/** - * This sample demonstrates how to use basic agent operations with function tool from the Azure Agents service. - * - * @summary demonstrates how to use basic agent operations using function tool. - * - */ - -const { AIProjectsClient, ToolUtility, isOutputOfType } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const agents = client.agents; - class FunctionToolExecutor { - functionTools; - - constructor() { - this.functionTools = [ - { - func: this.getUserFavoriteCity, - ...ToolUtility.createFunctionTool({ - name: "getUserFavoriteCity", - description: "Gets the user's favorite city.", - parameters: {}, - }), - }, - { - func: this.getCityNickname, - ...ToolUtility.createFunctionTool({ - name: "getCityNickname", - description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - }, - }, - }), - }, - { - func: this.getWeather, - ...ToolUtility.createFunctionTool({ - name: "getWeather", - description: "Gets the weather for a location.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - unit: { type: "string", enum: ["c", "f"] }, - }, - }, - }), - }, - ]; - } - - getUserFavoriteCity() { - return { location: "Seattle, WA" }; - } - - getCityNickname(_location) { - return { nickname: "The Emerald City" }; - } - - getWeather(_location, unit) { - return { weather: unit === "f" ? "72f" : "22c" }; - } - - invokeTool(toolCall) { - console.log(`Function tool call - ${toolCall.function.name}`); - const args = []; - if (toolCall.function.parameters) { - try { - const params = JSON.parse(toolCall.function.parameters); - for (const key in params) { - if (Object.prototype.hasOwnProperty.call(params, key)) { - args.push(params[key]); - } - } - } catch (error) { - console.error(`Failed to parse parameters: ${toolCall.function.parameters}`, error); - return undefined; - } - } - const result = this.functionTools - .find((tool) => tool.definition.function.name === toolCall.function.name) - ?.func(...args); - return result - ? { - toolCallId: toolCall.id, - output: JSON.stringify(result), - } - : undefined; - } - - getFunctionDefinitions() { - return this.functionTools.map((tool) => { - return tool.definition; - }); - } - } - - const functionToolExecutor = new FunctionToolExecutor(); - const functionTools = functionToolExecutor.getFunctionDefinitions(); - const agent = await agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: - "You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.", - tools: functionTools, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "What's the weather like in my favorite city?", - }); - console.log(`Created message, message ID ${message.id}`); - - // Create run - let run = await agents.createRun(thread.id, agent.id); - console.log(`Created Run, Run ID: ${run.id}`); - - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - if (run.status === "requires_action" && run.requiredAction) { - console.log(`Run requires action - ${run.requiredAction}`); - if (isOutputOfType(run.requiredAction, "submit_tool_outputs")) { - const submitToolOutputsActionOutput = run.requiredAction; - const toolCalls = submitToolOutputsActionOutput.submitToolOutputs.toolCalls; - const toolResponses = []; - for (const toolCall of toolCalls) { - if (isOutputOfType(toolCall, "function")) { - const toolResponse = functionToolExecutor.invokeTool(toolCall); - if (toolResponse) { - toolResponses.push(toolResponse); - } - } - } - if (toolResponses.length > 0) { - run = await agents.submitToolOutputsToRun(thread.id, run.id, toolResponses); - console.log(`Submitted tool response - ${run.status}`); - } - } - } - } - - console.log(`Run status - ${run.status}, run ID: ${run.id}`); - const messages = await agents.listMessages(thread.id); - await messages.data.forEach((threadMessage) => { - console.log( - `Thread Message Created at - ${threadMessage.createdAt} - Role - ${threadMessage.role}`, - ); - threadMessage.content.forEach((content) => { - if (isOutputOfType(content, "text")) { - const textContent = content; - console.log(`Text Message Content - ${textContent.text.value}`); - } else if (isOutputOfType(content, "image_file")) { - const imageContent = content; - console.log(`Image Message Content - ${imageContent.imageFile.fileId}`); - } - }); - }); - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithOpenApi.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithOpenApi.js deleted file mode 100644 index 5b5747ab556f..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithOpenApi.js +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with an OpenApi tool. - * - * @summary demonstrates how to use agent operations with an OpenApi tool. - */ - -const { AIProjectsClient, isOutputOfType, ToolUtility } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); -const fs = require("fs"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Read in OpenApi spec - const filePath = "./data/weatherOpenApi.json"; - const openApiSpec = JSON.parse(fs.readFileSync(filePath, "utf-8")); - - // Define OpenApi function - const openApiFunction = { - name: "getWeather", - spec: openApiSpec, - description: "Retrieve weather information for a location", - auth: { - type: "anonymous", - }, - default_params: ["format"], // optional - }; - - // Create OpenApi tool - const openApiTool = ToolUtility.createOpenApiTool(openApiFunction); - - // Create agent with OpenApi tool - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "myAgent", - instructions: "You are a helpful agent", - tools: [openApiTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What's the weather in Seattle?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - // Check if you got "Rate limit is exceeded.", then you want to get more quota - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Get most recent message from the assistant - const messages = await client.agents.listMessages(thread.id); - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => isOutputOfType(content, "text")); - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithToolset.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithToolset.js deleted file mode 100644 index ce2faeb8774d..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/agentsWithToolset.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with toolset and iteration in streaming - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with toolset. - */ - -const { AIProjectsClient, ToolSet } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const fs = require("fs"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file for code interpreter tool - const filePath1 = "./data/nifty500QuarterlyResults.csv"; - const fileStream1 = fs.createReadStream(filePath1); - const codeInterpreterFile = await client.agents.uploadFile(fileStream1, "assistants", { - fileName: "myLocalFile", - }); - - console.log(`Uploaded local file, file ID : ${codeInterpreterFile.id}`); - - // Upload file for file search tool - const filePath2 = "./data/sampleFileForUpload.txt"; - const fileStream2 = fs.createReadStream(filePath2); - const fileSearchFile = await client.agents.uploadFile(fileStream2, "assistants", { - fileName: "sampleFileForUpload.txt", - }); - console.log(`Uploaded file, file ID: ${fileSearchFile.id}`); - - // Create vector store for file search tool - const vectorStore = await client.agents - .createVectorStoreAndPoll({ - fileIds: [fileSearchFile.id], - }) - .pollUntilDone(); - - // Create tool set - const toolSet = new ToolSet(); - await toolSet.addFileSearchTool([vectorStore.id]); - await toolSet.addCodeInterpreterTool([codeInterpreterFile.id]); - - // Create agent with tool set - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: toolSet.toolDefinitions, - toolResources: toolSet.toolResources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create threads, messages, and runs to interact with agent as desired - - // Delete agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFiles.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFiles.js deleted file mode 100644 index 9c849a0600b2..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFiles.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the batch vector store with the list of files. - * - * @summary demonstrates how to create the batch vector store with the list of files. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { Readable } = require("stream"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload first file - const file1Content = "Hello, Vector Store!"; - const readable1 = new Readable(); - await readable1.push(file1Content); - await readable1.push(null); // end the stream - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "vectorFile1.txt", - }); - console.log(`Uploaded file1, file ID: ${file1.id}`); - - // Create and upload second file - const file2Content = "This is another file for the Vector Store!"; - const readable2 = new Readable(); - await readable2.push(file2Content); - await readable2.push(null); // end the stream - const file2 = await client.agents.uploadFile(readable2, "assistants", { - fileName: "vectorFile2.txt", - }); - console.log(`Uploaded file2, file ID: ${file2.id}`); - - // Create vector store file batch - const vectorStoreFileBatch = await client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - console.log( - `Created vector store file batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Retrieve vector store file batch - const _vectorStoreFileBatch = await client.agents.getVectorStoreFileBatch( - vectorStore.id, - vectorStoreFileBatch.id, - ); - console.log( - `Retrieved vector store file batch, vector store file batch ID: ${_vectorStoreFileBatch.id}`, - ); - - // List vector store files in the batch - const vectorStoreFiles = await client.agents.listVectorStoreFileBatchFiles( - vectorStore.id, - vectorStoreFileBatch.id, - ); - console.log( - `List of vector store files in the batch: ${vectorStoreFiles.data.map((f) => f.id).join(", ")}`, - ); - - // Delete files - await client.agents.deleteFile(file1.id); - console.log(`Deleted file1, file ID: ${file1.id}`); - await client.agents.deleteFile(file2.id); - console.log(`Deleted file2, file ID: ${file2.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFilesAndPolling.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFilesAndPolling.js deleted file mode 100644 index 08b559504c25..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/batchVectorStoreWithFilesAndPolling.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the batch vector store with the list of files using polling operation. - * - * @summary demonstrates how to create the batch vector store with the list of files using polling operation. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { Readable } = require("stream"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload first file - const file1Content = "Hello, Vector Store!"; - const readable1 = new Readable(); - await readable1.push(file1Content); - await readable1.push(null); // end the stream - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "vectorFile1.txt", - }); - console.log(`Uploaded file1, file ID: ${file1.id}`); - - // Create and upload second file - const file2Content = "This is another file for the Vector Store!"; - const readable2 = new Readable(); - await readable2.push(file2Content); - await readable2.push(null); // end the stream - const file2 = await client.agents.uploadFile(readable2, "assistants", { - fileName: "vectorFile2.txt", - }); - console.log(`Uploaded file2, file ID: ${file2.id}`); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response) { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create vector store file batch, which will automatically poll until the operation is complete - const vectorStoreFileBatch1 = await client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - onResponse: onResponse, - }); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch1.status}, vector store file batch ID: ${vectorStoreFileBatch1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStoreFileBatchPoller = client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - onResponse: onResponse, - }); - const vectorStoreFileBatch2 = await vectorStoreFileBatchPoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch2.status}, vector store file batch ID: ${vectorStoreFileBatch2.id}`, - ); - - // Delete files - await client.agents.deleteFile(file1.id); - await client.agents.deleteFile(file2.id); - console.log(`Deleted files, file IDs: ${file1.id} & ${file2.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreter.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreter.js deleted file mode 100644 index 7366dcaaaa0c..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreter.js +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with code interpreter from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with code interpreter. - */ - -const { AIProjectsClient, isOutputOfType, ToolUtility } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); -const fs = require("fs"); -const path = require("node:path"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file and wait for it to be processed - const filePath = "./data/nifty500QuarterlyResults.csv"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "localFile", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Create code interpreter tool - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); - - // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create a bar chart in the TRANSPORTATION sector for the operating profit from the uploaded CSV file and provide the file to me?", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - // Check if you got "Rate limit is exceeded.", then you want to get more quota - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the original file from the agent to free up space (note: this does not delete your version of the file) - await client.agents.deleteFile(localFile.id); - console.log(`Deleted file, file ID: ${localFile.id}`); - - // Print the messages from the agent - const messages = await client.agents.listMessages(thread.id); - console.log("Messages:", messages); - - // Get most recent message from the assistant - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => isOutputOfType(content, "text")); - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - - // Save the newly created file - console.log(`Saving new files...`); - const imageFile = messages.data[0].content[0].imageFile; - console.log(`Image file ID : ${imageFile.fileId}`); - const imageFileName = path.resolve( - "./data/" + (await client.agents.getFile(imageFile.fileId)).filename + "ImageFile.png", - ); - - const fileContent = await ( - await client.agents.getFileContent(imageFile.fileId).asNodeStream() - ).body; - if (fileContent) { - const chunks = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); - } else { - console.error("Failed to retrieve file content: fileContent is undefined"); - } - console.log(`Saved image file to: ${imageFileName}`); - - // Iterate through messages and print details for each annotation - console.log(`Message Details:`); - await messages.data.forEach((m) => { - console.log(`File Paths:`); - console.log(`Type: ${m.content[0].type}`); - if (isOutputOfType(m.content[0], "text")) { - const textContent = m.content[0]; - console.log(`Text: ${textContent.text.value}`); - } - console.log(`File ID: ${m.id}`); - console.log(`Start Index: ${messages.firstId}`); - console.log(`End Index: ${messages.lastId}`); - }); - - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreterWithStreaming.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreterWithStreaming.js deleted file mode 100644 index 7d792861bcb2..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/codeInterpreterWithStreaming.js +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with code interpreter from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with code interpreter. - */ - -const { - AIProjectsClient, - DoneEvent, - ErrorEvent, - isOutputOfType, - MessageStreamEvent, - RunStreamEvent, - ToolUtility, -} = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -const fs = require("fs"); -const path = require("node:path"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file and wait for it to be processed - const filePath = "./data/nifty500QuarterlyResults.csv"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "myLocalFile", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Create code interpreter tool - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); - - // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create a bar chart in the TRANSPORTATION sector for the operating profit from the uploaded CSV file and provide the file to me?", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${eventMessage.data.status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - // Delete the original file from the agent to free up space (note: this does not delete your version of the file) - await client.agents.deleteFile(localFile.id); - console.log(`Deleted file, file ID : ${localFile.id}`); - - // Print the messages from the agent - const messages = await client.agents.listMessages(thread.id); - console.log("Messages:", messages); - - // Get most recent message from the assistant - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => isOutputOfType(content, "text")); - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - - // Save the newly created file - console.log(`Saving new files...`); - const imageFileOutput = messages.data[0].content[0]; - const imageFile = imageFileOutput.imageFile.fileId; - const imageFileName = path.resolve( - "./data/" + (await client.agents.getFile(imageFile)).filename + "ImageFile.png", - ); - console.log(`Image file name : ${imageFileName}`); - - const fileContent = await (await client.agents.getFileContent(imageFile).asNodeStream()).body; - if (fileContent) { - const chunks = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); - } else { - console.error("Failed to retrieve file content: fileContent is undefined"); - } - console.log(`Saved image file to: ${imageFileName}`); - - // Iterate through messages and print details for each annotation - console.log(`Message Details:`); - await messages.data.forEach((m) => { - console.log(`File Paths:`); - console.log(`Type: ${m.content[0].type}`); - if (isOutputOfType(m.content[0], "text")) { - const textContent = m.content[0]; - console.log(`Text: ${textContent.text.value}`); - } - console.log(`File ID: ${m.id}`); - console.log(`Start Index: ${messages.firstId}`); - console.log(`End Index: ${messages.lastId}`); - }); - - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/fileSearch.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/fileSearch.js deleted file mode 100644 index 8a383f597811..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/fileSearch.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with file searching from the Azure Agents service. - * - * @summary This sample demonstrates how to use agent operations with file searching. - */ - -const { AIProjectsClient, isOutputOfType, ToolUtility } = require("@azure/ai-projects"); -const { delay } = require("@azure/core-util"); -const { DefaultAzureCredential } = require("@azure/identity"); - -const fs = require("fs"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file - const filePath = "./data/sampleFileForUpload.txt"; - const localFileStream = fs.createReadStream(filePath); - const file = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "sampleFileForUpload.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store - const vectorStore = await client.agents.createVectorStore({ - fileIds: [file.id], - name: "myVectorStore", - }); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Initialize file search tool - const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]); - - // Create agent with files - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "SDK Test Agent - Retrieval", - instructions: "You are helpful agent that can help fetch data from files you know about.", - tools: [fileSearchTool.definition], - toolResources: fileSearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Can you give me the documented codes for 'banana' and 'orange'?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - while (["queued", "in_progress"].includes(run.status)) { - await delay(500); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - } - - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - const messages = await client.agents.listMessages(thread.id); - await messages.data.forEach((threadMessage) => { - console.log( - `Thread Message Created at - ${threadMessage.createdAt} - Role - ${threadMessage.role}`, - ); - threadMessage.content.forEach((content) => { - if (isOutputOfType(content, "text")) { - const textContent = content; - console.log(`Text Message Content - ${textContent.text.value}`); - } else if (isOutputOfType(content, "image_file")) { - const imageContent = content; - console.log(`Image Message Content - ${imageContent.imageFile.fileId}`); - } - }); - }); - - // Delete agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/files.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/files.js deleted file mode 100644 index f4a041d5f453..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/files.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic files agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic files agent operations. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -const { Readable } = require("node:stream"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create and upload file - const fileContent = "Hello, World!"; - // Create a readable stream from the string content - const readable = Readable.from(Buffer.from(fileContent)); - const file = await client.agents.uploadFile(readable, "assistants", { fileName: "myFile.txt" }); - console.log(`Uploaded file, file ID : ${file.id}`); - - // List uploaded files - const files = await client.agents.listFiles(); - - console.log(`List of files : ${files.data[0].filename}`); - - // Retrieve file - const _file = await client.agents.getFile(file.id); - - console.log(`Retrieved file, file ID : ${_file.id}`); - - // Delete file - await client.agents.deleteFile(file.id); - - console.log(`Deleted file, file ID : ${file.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithLocalUpload.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithLocalUpload.js deleted file mode 100644 index 7d32276a8eda..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithLocalUpload.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic files agent operations with local file upload from the Azure Agents service. - * - * @summary demonstrates how to use basic files agent operations with local file upload. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -const fs = require("fs"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload local file - const filePath = "./data/localFile.txt"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "myLocalFile.txt", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Retrieve local file - const retrievedLocalFile = await client.agents.getFile(localFile.id); - - console.log(`Retrieved local file, file ID : ${retrievedLocalFile.id}`); - - // Delete local file - await client.agents.deleteFile(localFile.id); - - console.log(`Deleted local file, file ID : ${localFile.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithPolling.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithPolling.js deleted file mode 100644 index bae03523cabc..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/filesWithPolling.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to upload a file and poll for its status. - * - * @summary demonstrates how to upload a file and poll for its status. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { Readable } = require("stream"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create file content - const fileContent1 = "Hello, World!"; - const readable1 = new Readable(); - readable1.push(fileContent1); - readable1.push(null); // end the stream - - const fileContent2 = "How are you?"; - const readable2 = new Readable(); - readable2.push(fileContent2); - readable2.push(null); // end the stream - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response) { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Upload file, which will automatically poll until the operation is complete - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "myPollingFile.txt", - onResponse: onResponse, - }); - console.log(`Uploaded file with status ${file1.status}, file ID : ${file1.id}`); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const filePoller = client.agents.uploadFile(readable2, "assistants", { - fileName: "myPollingFile.txt", - onResponse: onResponse, - }); - const file2 = await filePoller.pollUntilDone({ abortSignal: abortController.signal }); - console.log(`Uploaded file with status ${file2.status}, file ID: ${file2.id}`); - - // Delete file - await client.agents.deleteFile(file1.id); - await client.agents.deleteFile(file2.id); - console.log(`Deleted files, file IDs: ${file1.id} & ${file2.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/messages.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/messages.js deleted file mode 100644 index 06524a080f57..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/messages.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic message agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic message agent operations. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - }); - const thread = await client.agents.createThread(); - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - const messages = await client.agents.listMessages(thread.id); - console.log(`Message ${message.id} contents: ${messages.data[0].content[0].text.value}`); - - const updatedMessage = await client.agents.updateMessage(thread.id, message.id, { - metadata: { introduction: "true" }, - }); - console.log(`Updated message metadata - introduction: ${updatedMessage.metadata?.introduction}`); - - await client.agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID : ${thread.id}`); - - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID : ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/runSteps.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/runSteps.js deleted file mode 100644 index 40fb453fcd31..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/runSteps.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic run agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic run agent operations. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create agent - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - - // Wait for run to complete - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Run status: ${run.status}`); - } - - // List run steps - const runSteps = await client.agents.listRunSteps(thread.id, run.id); - console.log(`Listed run steps, run ID: ${run.id}`); - - // Get specific run step - const stepId = runSteps.data[0].id; - const step = await client.agents.getRunStep(thread.id, run.id, stepId); - console.log(`Retrieved run step, step ID: ${step.id}`); - - // Clean up - await client.agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/streaming.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/streaming.js deleted file mode 100644 index 7251d8fcd902..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/streaming.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations in streaming from the Azure Agents service. - * - * @summary demonstrates how to use agent operations in streaming. - */ - -const { - AIProjectsClient, - DoneEvent, - ErrorEvent, - MessageStreamEvent, - RunStreamEvent, -} = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-assistant", - instructions: "You are helpful agent", - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - const thread = await client.agents.createThread(); - - console.log(`Created thread, thread ID : ${agent.id}`); - - await client.agents.createMessage(thread.id, { role: "user", content: "Hello, tell me a joke" }); - - console.log(`Created message, thread ID : ${agent.id}`); - - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${eventMessage.data.status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - await client.agents.deleteAgent(agent.id); - console.log(`Delete agent, agent ID : ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/threads.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/threads.js deleted file mode 100644 index 0b2265ed3359..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/threads.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic thread agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic thread agent operations. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const thread = await client.agents.createThread(); - - console.log(`Created thread, thread ID : ${thread.id}`); - - const _thread = await client.agents.getThread(thread.id); - - console.log(`Retrieved thread, thread ID : ${_thread.id}`); - - await client.agents.deleteThread(thread.id); - - console.log(`Deleted thread, thread ID : ${_thread.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFiles.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFiles.js deleted file mode 100644 index b49345635865..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFiles.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store with the list of files. - * - * @summary demonstrates how to create the vector store with the list of files. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { Readable } = require("stream"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload file - const fileContent = "Hello, Vector Store!"; - const readable = new Readable(); - await readable.push(fileContent); - await readable.push(null); // end the stream - const file = await client.agents.uploadFile(readable, "assistants", { - fileName: "vectorFile.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file - const vectorStoreFile = await client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - }); - console.log(`Created vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Retrieve vector store file - const _vectorStoreFile = await client.agents.getVectorStoreFile( - vectorStore.id, - vectorStoreFile.id, - ); - console.log(`Retrieved vector store file, vector store file ID: ${_vectorStoreFile.id}`); - - // List vector store files - const vectorStoreFiles = await client.agents.listVectorStoreFiles(vectorStore.id); - console.log(`List of vector store files: ${vectorStoreFiles.data.map((f) => f.id).join(", ")}`); - - // Delete vector store file - await client.agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Delete file - await client.agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFilesAndPolling.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFilesAndPolling.js deleted file mode 100644 index 64951dbba8a2..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoreWithFilesAndPolling.js +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store with the list of files using polling operation. - * - * @summary demonstrates how to create the vector store with the list of files using polling operation. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -const { Readable } = require("stream"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload file - const fileContent = "Hello, Vector Store!"; - const readable = new Readable(); - await readable.push(fileContent); - await readable.push(null); // end the stream - const file = await client.agents.uploadFile(readable, "assistants", { - fileName: "vectorFile.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response) { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create vector store file, which will automatically poll until the operation is complete - const vectorStoreFile1 = await client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - console.log( - `Created vector store file with status ${vectorStoreFile1.status}, vector store file ID: ${vectorStoreFile1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStoreFilePoller = client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - const vectorStoreFile2 = await vectorStoreFilePoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store file with status ${vectorStoreFile2.status}, vector store file ID: ${vectorStoreFile2.id}`, - ); - - // Delete file - await client.agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStores.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStores.js deleted file mode 100644 index a1260c7e88d7..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStores.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store. - * - * @summary demonstrates how to create the vector store. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create a vector store - const vectorStore = await client.agents.createVectorStore({ name: "myVectorStore" }); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // List vector stores - const vectorStores = await client.agents.listVectorStores(); - console.log("List of vector stores:", vectorStores); - - // Modify the vector store - const updatedVectorStore = await client.agents.modifyVectorStore(vectorStore.id, { - name: "updatedVectorStore", - }); - console.log(`Updated vector store, vector store ID: ${updatedVectorStore.id}`); - - // Get a specific vector store - const retrievedVectorStore = await client.agents.getVectorStore(vectorStore.id); - console.log(`Retrieved vector store, vector store ID: ${retrievedVectorStore.id}`); - - // Delete the vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoresWithPolling.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoresWithPolling.js deleted file mode 100644 index 36dd29fa25a8..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/agents/vectorStoresWithPolling.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store using polling operation. - * - * @summary demonstrates how to create the vector store using polling operation. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv/config"); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response) { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create a vector, which will automatically poll until the operation is complete - const vectorStore1 = await client.agents.createVectorStore({ - name: "myVectorStore", - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - console.log( - `Created vector store with status ${vectorStore1.status}, vector store ID: ${vectorStore1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStorePoller = client.agents.createVectorStore({ - name: "myVectorStore", - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - const vectorStore2 = await vectorStorePoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store with status ${vectorStore2.status}, vector store ID: ${vectorStore2.id}`, - ); - - // Delete the vector store - await client.agents.deleteVectorStore(vectorStore1.id); - await client.agents.deleteVectorStore(vectorStore2.id); - console.log(`Deleted vector stores, vector store IDs: ${vectorStore1.id} & ${vectorStore2.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/connections/connectionsBasics.js b/sdk/ai/ai-projects/samples/v1-beta/javascript/connections/connectionsBasics.js deleted file mode 100644 index bbe5baec7d90..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/connections/connectionsBasics.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to how to use basic connections operations. - * - * @summary Given an AIProjectClient, this sample demonstrates how to enumerate the properties of all connections, - * get the properties of a default connection, and get the properties of a connection by its name. - */ - -const { AIProjectsClient } = require("@azure/ai-projects"); -const { DefaultAzureCredential } = require("@azure/identity"); - -require("dotenv").config(); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -async function main() { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // List the details of all the connections - const connections = await client.connections.listConnections(); - console.log(`Retrieved ${connections.length} connections`); - - // Get the details of a connection, without credentials - const connectionName = connections[0].name; - const connection = await client.connections.getConnection(connectionName); - console.log(`Retrieved connection, connection name: ${connection.name}`); - - // Get the details of a connection, including credentials (if available) - const connectionWithSecrets = await client.connections.getConnectionWithSecrets(connectionName); - console.log(`Retrieved connection with secrets, connection name: ${connectionWithSecrets.name}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); - -module.exports = { main }; diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/image_file.png b/sdk/ai/ai-projects/samples/v1-beta/javascript/data/image_file.png deleted file mode 100644 index 50ae6c65367a..000000000000 Binary files a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/image_file.png and /dev/null differ diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/localFile.txt b/sdk/ai/ai-projects/samples/v1-beta/javascript/data/localFile.txt deleted file mode 100644 index 8ab686eafeb1..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/localFile.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, World! diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/nifty500QuarterlyResults.csv b/sdk/ai/ai-projects/samples/v1-beta/javascript/data/nifty500QuarterlyResults.csv deleted file mode 100644 index e02068e09042..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/nifty500QuarterlyResults.csv +++ /dev/null @@ -1,502 +0,0 @@ -name,NSE_code,BSE_code,sector,industry,revenue,operating_expenses,operating_profit,operating_profit_margin,depreciation,interest,profit_before_tax,tax,net_profit,EPS,profit_TTM,EPS_TTM -3M India Ltd.,3MINDIA,523395,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"1,057",847.4,192.1,18.48%,12.9,0.7,195.9,49.8,146.1,129.7,535.9,475.7 -ACC Ltd.,ACC,500410,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"4,644.8","3,885.4",549.3,12.39%,212.8,28.9,517.7,131.5,387.9,20.7,"1,202.7",64 -AIA Engineering Ltd.,AIAENG,532683,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,"1,357.1",912.7,382.1,29.51%,24.5,7.4,412.5,88.4,323.1,34.3,"1,216.1",128.9 -APL Apollo Tubes Ltd.,APLAPOLLO,533758,METALS & MINING,IRON & STEEL PRODUCTS,"4,65","4,305.4",325,7.02%,41.3,26.6,276.7,73.8,202.9,7.3,767.5,27.7 -Au Small Finance Bank Ltd.,AUBANK,540611,BANKING AND FINANCE,BANKS,"2,956.5","1,026.7",647.7,25.59%,0,"1,282.1",533.4,131.5,401.8,6,"1,606.2",24 -Adani Ports & Special Economic Zone Ltd.,ADANIPORTS,532921,TRANSPORTATION,MARINE PORT & SERVICES,"6,951.9","2,982.4","3,664",55.13%,974.5,520.1,"2,474.9",759,"1,747.8",8.1,"6,337",29.3 -Adani Energy Solutions Ltd.,ADANIENSOL,ASM,UTILITIES,ELECTRIC UTILITIES,"3,766.5","2,169.3","1,504.6",40.95%,432.1,640.8,369.9,84.9,275.9,2.5,"1,315.1",11.8 -Aditya Birla Fashion and Retail Ltd.,ABFRL,535755,RETAILING,DEPARTMENT STORES,"3,272.2","2,903.6",322.9,10.01%,388.8,208.4,-228.6,-28.2,-179.2,-1.9,-491.7,-5.2 -Aegis Logistics Ltd.,AEGISCHEM,500003,OIL & GAS,OIL MARKETING & DISTRIBUTION,"1,279.3","1,026.5",208.3,16.87%,34.1,26.6,192,42,127,3.6,509,14.5 -Ajanta Pharma Ltd.,AJANTPHARM,532331,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,049.8",737.8,290.7,28.26%,33.7,2.3,275.9,80.6,195.3,15.5,660.2,52.3 -Alembic Pharmaceuticals Ltd.,APLLTD,533573,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,605.1","1,386.7",208.2,13.06%,67.6,15.7,135.1,-1.9,136.6,7,531.7,27 -Alkem Laboratories Ltd.,ALKEM,539523,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"3,503.4","2,693.4",746.7,21.71%,73.9,30.3,648,33.1,620.5,51.9,"1,432.9",119.9 -Amara Raja Energy & Mobility Ltd.,ARE&M,500008,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,988.6","2,556.9",402.5,13.60%,115.7,6.2,309.8,83.5,226.3,13.2,779.8,45.7 -Ambuja Cements Ltd.,AMBUJACEM,500425,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"7,9","6,122.1","1,301.8",17.54%,380.9,61.2,"1,335.7",352.5,793,4,"2,777.9",14 -Apollo Hospitals Enterprise Ltd.,APOLLOHOSP,508869,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"4,869.1","4,219.4",627.5,12.95%,163.4,111.3,376.9,130.2,232.9,16.2,697.5,48.5 -Apollo Tyres Ltd.,APOLLOTYRE,500877,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"6,304.9","5,119.8","1,159.8",18.47%,360.3,132.8,679.9,205.8,474.3,7.5,"1,590.7",25 -Ashok Leyland Ltd.,ASHOKLEY,500477,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"11,463","9,558.6","1,870.4",16.37%,226.6,715.1,924.4,358,526,1.8,"2,141.5",7.3 -Asian Paints Ltd.,ASIANPAINT,500820,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"8,643.8","6,762.3","1,716.2",20.24%,208.7,50.9,"1,621.8",418.6,"1,205.4",12.6,"5,062.6",52.8 -Astral Ltd.,ASTRAL,532830,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,"1,376.4","1,142.9",220.1,16.15%,48.7,8,176.8,45.1,131.2,4.9,549.7,20.4 -Atul Ltd.,ATUL,500027,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,215.8","1,038.5",155.2,13.00%,54,1.9,121.5,32.5,90.3,30.6,392.3,132.9 -Aurobindo Pharma Ltd.,AUROPHARMA,524804,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"7,406.4","5,846","1,373.4",19.02%,417.5,68.2,"1,074.7",323.7,757.2,12.8,"2,325.5",39.7 -Avanti Feeds Ltd.,AVANTIFEED,512573,FOOD BEVERAGES & TOBACCO,OTHER FOOD PRODUCTS,"1,312","1,184.5",94,7.35%,14.3,0.2,113,30.5,74.2,5.5,336.4,24.7 -Avenue Supermarts Ltd.,DMART,540376,RETAILING,DEPARTMENT STORES,"12,661.3","11,619.4","1,005",7.96%,174.4,15.6,851.9,228.6,623.6,9.6,"2,332.1",35.8 -Axis Bank Ltd.,AXISBANK,532215,BANKING AND FINANCE,BANKS,"33,122.2","9,207.3","9,166",33.43%,0,"14,749","8,313.8","2,096.1","6,204.1",20.1,"13,121",42.6 -Bajaj Auto Ltd.,BAJAJ-AUTO,532977,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"11,206.8","8,708.1","2,130.1",19.65%,91.8,6.5,"2,400.4",564,"2,02",71.4,"6,841.6",241.8 -Bajaj Finance Ltd.,BAJFINANCE,500034,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"13,381.8","2,851.5","9,449.7",70.63%,158.5,"4,537.1","4,757.6","1,207","3,550.8",58.7,"13,118.5",216.7 -Bajaj Finserv Ltd.,BAJAJFINSV,532978,DIVERSIFIED,HOLDING COMPANIES,"26,022.7","14,992.2","9,949.9",38.24%,208.8,"4,449.1","5,292","1,536.5","1,929",12.1,"7,422.6",46.6 -Bajaj Holdings & Investment Ltd.,BAJAJHLDNG,500490,DIVERSIFIED,HOLDING COMPANIES,240.1,33.5,191.2,85.08%,8.4,0.2,197.9,73.9,"1,491.2",134,"5,545.1",498.3 -Balkrishna Industries Ltd.,BALKRISIND,502355,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"2,360.3","1,720.5",532.7,23.64%,160.4,23.9,455.5,108.1,347.4,18,"1,047.5",54.2 -Balrampur Chini Mills Ltd.,BALRAMCHIN,500038,FOOD BEVERAGES & TOBACCO,SUGAR,"1,649","1,374.6",164.9,10.71%,41.2,17.2,215.9,56.6,166.3,8.2,540.5,26.8 -Bank of Baroda,BANKBARODA,532134,BANKING AND FINANCE,BANKS,"35,766","8,430.4","9,807.9",33.52%,0,"17,527.7","6,022.8","1,679.7","4,458.4",8.5,"18,602.9",35.9 -Bank of India,BANKINDIA,532149,BANKING AND FINANCE,BANKS,"16,779.4","3,704.9","3,818.8",25.35%,0,"9,255.7","2,977.4","1,488.6","1,498.5",3.6,"5,388.7",13.1 -Bata India Ltd.,BATAINDIA,500043,RETAILING,FOOTWEAR,834.6,637.5,181.7,22.18%,81.7,28.4,46.1,12.1,34,2.6,289.7,22.5 -Berger Paints (India) Ltd.,BERGEPAINT,509480,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"2,782.6","2,293.7",473.6,17.12%,82.9,21.1,385,96.7,291.6,2.5,"1,032.6",8.9 -Bharat Electronics Ltd.,BEL,500049,GENERAL INDUSTRIALS,DEFENCE,"4,146.1","2,994.9","1,014.2",25.30%,108.3,1.5,"1,041.5",260.7,789.4,1.1,"3,323",4.5 -Bharat Forge Ltd.,BHARATFORG,500493,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"3,826.7","3,152.8",621.4,16.47%,211.3,124.3,336.1,121.8,227.2,4.9,783.7,16.8 -Bharat Heavy Electricals Ltd.,BHEL,500103,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"5,305.4","5,513",-387.7,-7.56%,59.9,180.4,-447.9,-197.9,-238.1,-0.7,71.3,0.2 -Bharat Petroleum Corporation Ltd.,BPCL,500547,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"103,72","90,103.9","12,940.5",12.56%,"1,605.3",973.2,"10,755.7","2,812.2","8,243.5",38.7,"27,505.3",129.2 -Bharti Airtel Ltd.,BHARTIARTL,532454,TELECOM SERVICES,TELECOM SERVICES,"37,374.2","17,530.1","19,513.7",52.68%,"9,734.3","5,185.8","3,353.7","1,846.5","1,340.7",2.4,"7,547",13.2 -Indus Towers Ltd.,INDUSTOWER,534816,TELECOM SERVICES,OTHER TELECOM SERVICES,"7,229.7","3,498.8","3,633.7",50.95%,"1,525.6",458.6,"1,746.7",452,"1,294.7",4.8,"3,333.5",12.4 -Biocon Ltd.,BIOCON,532523,PHARMACEUTICALS & BIOTECHNOLOGY,BIOTECHNOLOGY,"3,620.2","2,720.7",741.6,21.42%,389.3,247.7,238.5,41.6,125.6,1.1,498.4,4.2 -Birla Corporation Ltd.,BIRLACORPN,500335,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,313.2","1,997",288.9,12.64%,143.5,95.4,77.1,18.8,58.4,7.6,153.1,19.9 -Blue Dart Express Ltd.,BLUEDART,526612,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"1,329.7","1,101.8",222.7,16.82%,110.6,19.5,97.9,24.8,73.1,30.8,292.4,123.2 -Blue Star Ltd.,BLUESTARCO,500067,CONSUMER DURABLES,CONSUMER ELECTRONICS,"1,903.4","1,767.7",122.7,6.49%,23,17.6,95,24.3,70.7,3.6,437.7,21.3 -Bombay Burmah Trading Corporation Ltd.,BBTC,501425,FOOD BEVERAGES & TOBACCO,TEA & COFFEE,"4,643.5","3,664.7",859.2,18.99%,74.7,154.6,697.1,212.6,122,17.5,"-1,499.5",-214.8 -Bosch Ltd.,BOSCHLTD,500530,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"4,284.3","3,638.8",491.3,11.90%,101.3,12.2,"1,317",318.1,999.8,339,"2,126.9",721 -Brigade Enterprises Ltd.,BRIGADE,532929,REALTY,REALTY,"1,407.9","1,041.8",324.8,23.77%,75.7,110,180.3,67.8,133.5,5.8,298.2,12.9 -Britannia Industries Ltd.,BRITANNIA,500825,FMCG,PACKAGED FOODS,"4,485.2","3,560.5",872.4,19.68%,71.7,53.4,799.7,212.1,587.6,24.4,"2,536.2",105.3 -CCL Products India Ltd.,CCL,519600,FOOD BEVERAGES & TOBACCO,TEA & COFFEE,608.3,497.7,109.9,18.09%,22.6,18.4,69.7,8.8,60.9,4.6,279.9,21 -Crisil Ltd.,CRISIL,500092,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,771.8,544.2,191.7,26.05%,26.5,0.8,200.3,48.3,152,20.8,606.3,82.9 -Zydus Lifesciences Ltd.,ZYDUSLIFE,532321,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"4,422.8","3,222.7","1,146.1",26.23%,184.2,8.7,"1,007.2",226.4,800.7,7.9,"2,807.1",27.7 -Can Fin Homes Ltd.,CANFINHOME,511196,BANKING AND FINANCE,HOUSING FINANCE,871,49.7,749.2,86.01%,2.8,548.4,198,39.9,158.1,11.9,658.8,49.5 -Canara Bank,CANBK,532483,BANKING AND FINANCE,BANKS,"33,891.2","8,250.3","7,706.6",28.24%,0,"17,934.3","5,098","1,420.6","3,86",20.9,"13,968.4",77 -Carborundum Universal Ltd.,CARBORUNIV,513375,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"1,166",978.8,167.5,14.61%,45.9,4.9,136.4,43.7,101.9,5.4,461.3,24.3 -Castrol India Ltd.,CASTROLIND,500870,OIL & GAS,OIL MARKETING & DISTRIBUTION,"1,203.2",914.4,268.6,22.70%,22.9,2.4,263.5,69.1,194.4,2,815.5,8.2 -Ceat Ltd.,CEATLTD,500878,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"3,063.8","2,597.2",456.1,14.94%,124.5,71.7,270.4,68.3,208,51.4,521.7,129 -Central Bank of India,CENTRALBK,532885,BANKING AND FINANCE,BANKS,"8,438.5","2,565.4","1,535.4",20.81%,0,"4,337.7",567.2,-41.5,622,0.7,"2,181.4",2.5 -Century Plyboards (India) Ltd.,CENTURYPLY,532548,FOREST MATERIALS,FOREST PRODUCTS,"1,011.4",852.5,144.3,14.47%,23.4,6.1,129.4,32.2,96.9,4.4,380.7,17.1 -Cera Sanitaryware Ltd.,CERA,532443,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,476.2,387.2,76.5,16.49%,8.9,1.4,77.2,19.8,56.9,43.8,232.4,178.7 -Chambal Fertilisers & Chemicals Ltd.,CHAMBLFERT,500085,FERTILIZERS,FERTILIZERS,"5,467.3","4,770.5",615,11.42%,78.4,45.8,572.6,200.2,381,9.2,"1,137.7",27.3 -Cholamandalam Investment & Finance Company Ltd.,CHOLAFIN,511243,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"4,695.2",987.6,"3,235.1",69.99%,38.5,"2,204.2","1,065",288.8,772.9,9.4,"3,022.8",36.7 -Cipla Ltd.,CIPLA,500087,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"6,854.5","4,944.4","1,733.8",25.96%,290,25.8,"1,594.2",438.4,"1,130.9",14,"3,449.1",42.7 -City Union Bank Ltd.,CUB,532210,BANKING AND FINANCE,BANKS,"1,486.1",333.9,386.6,29.65%,0,765.6,330.6,50,280.6,3.8,943.8,12.7 -Coal India Ltd.,COALINDIA,533278,METALS & MINING,COAL,"34,760.3","24,639.4","8,137",24.83%,"1,178.2",182.5,"8,760.2","2,036.5","6,799.8",11,"28,059.6",45.5 -Colgate-Palmolive (India) Ltd.,COLPAL,500830,FMCG,PERSONAL PRODUCTS,"1,492.1",989,482.1,32.77%,44.3,1.1,457.8,117.8,340.1,12.5,"1,173.2",43.1 -Container Corporation of India Ltd.,CONCOR,531344,COMMERCIAL SERVICES & SUPPLIES,WAREHOUSING AND LOGISTICS,"2,299.8","1,648.4",546.5,24.90%,153.1,16.5,481.8,119,367.4,6,"1,186.2",19.5 -Coromandel International Ltd.,COROMANDEL,506395,FERTILIZERS,FERTILIZERS,"7,032.9","5,929.4","1,058.7",15.15%,54,46.2,"1,003.3",245,756.9,25.7,"2,024.2",68.8 -Crompton Greaves Consumer Electricals Ltd.,CROMPTON,539876,CONSUMER DURABLES,HOUSEHOLD APPLIANCES,"1,797.2","1,607.8",174.5,9.79%,32.1,21.5,135.8,34.9,97.2,1.5,432,6.7 -Cummins India Ltd.,CUMMINSIND,500480,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"2,011.3","1,575.4",346.2,18.02%,38.3,6.8,390.9,99.6,329.1,11.9,"1,445.5",52.1 -Cyient Ltd.,CYIENT,532175,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,792","1,452.7",325.8,18.32%,65.8,27,240.3,56.7,178.3,16.3,665.6,60.1 -DCM Shriram Ltd.,DCMSHRIRAM,523367,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"2,73","2,593.9",114.1,4.21%,74,14.7,47.5,15.2,32.2,2.1,617.6,39.4 -DLF Ltd.,DLF,532868,REALTY,REALTY,"1,476.4",885.3,462.4,34.31%,37,90.2,464,112.2,622.8,2.5,"2,239",9 -Dabur India Ltd.,DABUR,500096,FMCG,PERSONAL PRODUCTS,"3,320.2","2,543",660.9,20.63%,98.3,28.1,650.8,144.3,515,2.9,"1,755.7",9.9 -Delta Corp Ltd.,DELTACORP,532848,COMMERCIAL SERVICES & SUPPLIES,MISC. COMMERCIAL SERVICES,282.6,170.5,100.1,36.99%,16.9,2.7,92.4,23,69.4,2.6,273.3,10.2 -Divi's Laboratories Ltd.,DIVISLAB,532488,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,995","1,43",479,25.09%,95,1,469,121,348,13.1,"1,331.8",50.3 -Dr. Lal Pathlabs Ltd.,LALPATHLAB,539524,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,619.4,423.5,177.8,29.57%,35.9,7.8,152.2,41.5,109.3,13.2,301.4,36.1 -Dr. Reddy's Laboratories Ltd.,DRREDDY,500124,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"7,217.6","4,888.8","2,008.3",29.09%,375.5,35.3,"1,912.5",434.5,"1,482.2",89.1,"5,091.2",305.2 -EID Parry (India) Ltd.,EIDPARRY,500125,FOOD BEVERAGES & TOBACCO,OTHER FOOD PRODUCTS,"9,210.3","8,002","1,057.5",11.67%,101.2,74.2,"1,032.8",246.8,452.3,25.5,991,55.8 -Eicher Motors Ltd.,EICHERMOT,505200,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"4,388.3","3,027.4","1,087.2",26.42%,142.5,12.7,"1,205.7",291.1,"1,016.2",37.1,"3,581",130.8 -Emami Ltd.,EMAMILTD,531162,FMCG,PERSONAL PRODUCTS,876,631.2,233.7,27.02%,46.1,2.2,196.4,15.8,178.5,4.1,697.8,16 -Endurance Technologies Ltd.,ENDURANCE,540153,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,560.5","2,226.7",318.3,12.51%,118.4,9.8,205.6,51.1,154.6,11,562.8,40 -Engineers India Ltd.,ENGINERSIN,532178,COMMERCIAL SERVICES & SUPPLIES,CONSULTING SERVICES,833.6,691.3,98.5,12.47%,8.3,0.4,133.6,32.2,127.5,2.3,472.7,8.4 -Escorts Kubota Ltd.,ESCORTS,500495,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"2,154.4","1,798.6",260.7,12.66%,40.8,3.1,311.9,79.7,223.3,20.6,910.5,82.4 -Exide Industries Ltd.,EXIDEIND,500086,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"4,408.9","3,872.4",499.1,11.42%,141.5,29.7,365.3,95.2,269.4,3.2,872.7,10.3 -Federal Bank Ltd.,FEDERALBNK,500469,BANKING AND FINANCE,BANKS,"6,548.2","1,603.8","1,400.3",24.18%,0,"3,544.1","1,342.7",342.6,994.1,4.3,"3,671.4",15.6 -Finolex Cables Ltd.,FINCABLES,500144,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,229.3","1,041.3",146.1,12.30%,10.8,0.4,176.7,52.3,154.2,10.1,643.9,42.1 -Finolex Industries Ltd.,FINPIPE,500940,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,944.5,780.2,103,11.66%,27.4,12.5,124.5,35.4,98,1.6,459.3,7.4 -Firstsource Solutions Ltd.,FSL,532809,SOFTWARE & SERVICES,BPO/KPO,"1,556.9","1,311.2",228.8,14.86%,65.4,26.1,154.3,27.8,126.5,1.9,551.7,7.9 -GAIL (India) Ltd.,GAIL,532155,UTILITIES,UTILITIES,"33,191","29,405.5","3,580.2",10.85%,837.3,199.6,"2,748.7",696.3,"2,444.1",3.7,"5,283.8",8 -GlaxoSmithKline Pharmaceuticals Ltd.,GLAXO,500660,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,985.2,667.5,289.5,30.25%,18.1,0.4,299.2,81.7,217.5,12.8,647.8,38.2 -Glenmark Pharmaceuticals Ltd.,GLENMARK,532296,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"3,209.1","2,745.1",462.3,14.41%,141.5,121.5,-124.4,55.9,-81.9,-2.9,-196.3,-7 -Godrej Consumer Products Ltd.,GODREJCP,532424,FMCG,PERSONAL PRODUCTS,"3,667.9","2,897.8",704.2,19.55%,60.9,77.3,619.4,186.6,432.8,4.2,"1,750.1",17.1 -Godrej Industries Ltd.,GODREJIND,500164,DIVERSIFIED,DIVERSIFIED,"4,256.9","3,672.1",265.5,6.74%,89.3,333.1,162.4,75.9,87.3,2.6,880,26.1 -Godrej Properties Ltd.,GODREJPROP,533150,REALTY,REALTY,605.1,404.7,-61.7,-17.98%,7.4,48,145.1,38.8,66.8,2.4,662.6,23.8 -Granules India Ltd.,GRANULES,532482,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,191",976.5,213,17.90%,52.5,26,136,33.9,102.1,4.2,393.9,16.3 -Great Eastern Shipping Company Ltd.,GESHIP,500620,TRANSPORTATION,SHIPPING,"1,461.5",585.6,643.4,52.35%,186.7,77.1,611.9,17.3,594.7,41.6,"2,520.1",176.5 -Gujarat Alkalies & Chemicals Ltd.,GUJALKALI,530001,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"1,042.3",926.1,45.2,4.65%,95.2,10.8,10.2,-0.1,-18.4,-2.5,82.7,11.3 -Gujarat Gas Ltd.,GUJGASLTD,539336,UTILITIES,UTILITIES,"4,019.3","3,494.5",496.6,12.44%,117.9,7.8,399.1,102.9,296.2,4.3,"1,254.3",18.2 -Gujarat Narmada Valley Fertilizers & Chemicals Ltd.,GNFC,500670,FERTILIZERS,FERTILIZERS,"2,232","1,911",169,8.12%,78,1,242,64,182,11.7,932,60.1 -Gujarat Pipavav Port Ltd.,GPPL,533248,TRANSPORTATION,MARINE PORT & SERVICES,270.4,102,150.6,59.64%,28.8,2.2,141.1,53.4,92.3,1.9,341.8,7.1 -Gujarat State Fertilizer & Chemicals Ltd.,GSFC,500690,FERTILIZERS,FERTILIZERS,"3,313.2","2,881.4",237.3,7.61%,45.7,1.6,387,78.1,308.9,7.8,"1,056.2",26.5 -Gujarat State Petronet Ltd.,GSPL,532702,UTILITIES,UTILITIES,"4,455.9","3,497.2",913.7,20.72%,165,14.5,779.2,198.7,454.6,8.1,"1,522",27 -HCL Technologies Ltd.,HCLTECH,532281,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"27,037","20,743","5,929",22.23%,"1,01",156,"5,128","1,295","3,832",14.2,"15,445",56.9 -HDFC Bank Ltd.,HDFCBANK,500180,BANKING AND FINANCE,BANKS,"107,566.6","42,037.6","24,279.1",32.36%,0,"41,249.9","20,967.4","3,655","16,811.4",22.2,"54,474.6",71.8 -Havells India Ltd.,HAVELLS,517354,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"3,952.8","3,527",373.4,9.57%,81.2,9.3,335.3,86.2,249.1,4,"1,177.7",18.8 -Hero MotoCorp Ltd.,HEROMOTOCO,500182,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"9,741.2","8,173.5","1,359.5",14.26%,187.1,25,"1,355.6",353.1,"1,006.3",50.3,"3,247.6",162.5 -HFCL Ltd.,HFCL,500183,TELECOMMUNICATIONS EQUIPMENT,TELECOM CABLES,"1,128.7",978.9,132.6,11.93%,21.4,34.8,93.5,24,69.4,0.5,305.5,2.1 -Hindalco Industries Ltd.,HINDALCO,500440,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"54,632","48,557","5,612",10.36%,"1,843","1,034","3,231","1,035","2,196",9.9,"8,423",37.9 -Hindustan Copper Ltd.,HINDCOPPER,513599,METALS & MINING,COPPER,392.6,260.2,121.2,31.77%,45.6,4.1,82.6,21.9,60.7,0.6,320.5,3.3 -Hindustan Petroleum Corporation Ltd.,HINDPETRO,500104,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"96,093.4","87,512","8,24",8.61%,"1,247.3",590,"6,744.1","1,616","5,827",41.1,"16,645",117.3 -Hindustan Unilever Ltd.,HINDUNILVR,500696,FMCG,PERSONAL PRODUCTS,"15,806","11,826","3,797",24.30%,297,88,"3,59",931,"2,656",11.3,"10,284",43.8 -Hindustan Zinc Ltd.,HINDZINC,500188,METALS & MINING,ZINC,"7,014","3,652","3,139",46.22%,825,232,"2,305",576,"1,729",4.1,"8,432",20 -Housing and Urban Development Corporation Ltd.,HUDCO,540530,BANKING AND FINANCE,HOUSING FINANCE,"1,880.8",82.7,"1,809.6",97.04%,2.4,"1,216.8",606.4,154.7,451.6,2.3,"1,790.7",8.9 -ITC Ltd.,ITC,500875,FOOD BEVERAGES & TOBACCO,CIGARETTES-TOBACCO PRODUCTS,"18,439.3","11,320.2","6,454.2",36.31%,453,9.9,"6,656.2","1,700.3","4,898.1",3.9,"20,185.1",16.2 -ICICI Bank Ltd.,ICICIBANK,532174,BANKING AND FINANCE,BANKS,"57,292.3","23,911","15,473.2",39.74%,0,"17,908","14,824.2","3,808.8","11,805.6",15.6,"41,086.8",58.7 -ICICI Prudential Life Insurance Company Ltd.,ICICIPRULI,540133,BANKING AND FINANCE,LIFE INSURANCE,"17,958.1","17,612.3",-229.6,-1.32%,0,0,340.2,32.5,243.9,1.7,906.9,6.3 -IDBI Bank Ltd.,IDBI,500116,BANKING AND FINANCE,BANKS,"7,063.7","1,922.3","2,175.3",36.02%,0,"2,966.1","2,396.9","1,003.7","1,385.4",1.3,"4,776.3",4.4 -IDFC First Bank Ltd.,IDFCFIRSTB,539437,BANKING AND FINANCE,BANKS,"8,765.8","3,849","1,511.2",20.54%,0,"3,405.6",982.8,236,746.9,1.1,"2,911.1",4.3 -IDFC Ltd.,IDFC,532659,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),36.7,6,30.6,83.56%,0,0,30.6,6.6,223.5,1.4,"4,147.1",25.9 -IRB Infrastructure Developers Ltd.,IRB,532947,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,874.5",950.4,794.6,45.54%,232.7,434.6,256.9,85.8,95.7,0.2,501,0.8 -ITI Ltd.,ITI,523610,TELECOMMUNICATIONS EQUIPMENT,TELECOM EQUIPMENT,256.1,299.3,-52.8,-21.42%,13.3,69.3,-125.8,0,-126,-1.3,-388.4,-4 -Vodafone Idea Ltd.,IDEA,532822,TELECOM SERVICES,TELECOM SERVICES,"10,750.8","6,433.5","4,282.8",39.97%,"5,667.3","6,569","-7,919",817.7,"-8,737.9",-1.8,"-30,986.8",-6.4 -India Cements Ltd.,INDIACEM,530005,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,272.4","1,26",4.4,0.35%,55,60.4,-103,-17.4,-80.1,-2.6,-261.1,-8.4 -Indiabulls Housing Finance Ltd.,IBULHSGFIN,535789,BANKING AND FINANCE,HOUSING FINANCE,"2,242.3",190.6,"1,779.2",79.88%,22.9,"1,349.8",421.6,123.6,298,6.5,"1,146",24.3 -Indian Bank,INDIANB,532814,BANKING AND FINANCE,BANKS,"15,929.4","3,599.1","4,327.7",31.44%,0,"8,002.6","2,776.7",768.6,"2,068.5",16.6,"6,893.3",55.3 -Indian Hotels Company Ltd.,INDHOTEL,500850,HOTELS RESTAURANTS & TOURISM,HOTELS,"1,480.9","1,078.4",354.8,24.75%,111.2,59,232.2,72.3,166.9,1.2,"1,100.3",7.7 -Indian Oil Corporation Ltd.,IOC,530965,OIL & GAS,OIL MARKETING & DISTRIBUTION,"179,752.1","156,013.1","23,328.4",13.01%,"3,609.6","2,135","18,090.2","4,699.7","13,114.3",9.5,"38,614.3",27.3 -Indian Overseas Bank,IOB,532388,BANKING AND FINANCE,BANKS,"6,941.5","1,785.1","1,679.8",28.84%,0,"3,476.6",635.5,8.3,627.2,0.3,"2,341.9",1.2 -Indraprastha Gas Ltd.,IGL,532514,UTILITIES,UTILITIES,"3,520.2","2,801.6",656.9,18.99%,102.2,2.5,613.9,151.4,552.7,7.9,"1,806.2",25.8 -IndusInd Bank Ltd.,INDUSINDBK,532187,BANKING AND FINANCE,BANKS,"13,529.7","3,449.9","3,908.7",34.75%,0,"6,171.1","2,934.9",732.9,"2,202.2",28.4,"8,333.7",107.2 -Info Edge (India) Ltd.,NAUKRI,532777,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,792,421.2,204.7,32.70%,25.9,8.2,382.8,68.7,205.1,15.9,-25.6,-2 -InterGlobe Aviation Ltd.,INDIGO,539448,TRANSPORTATION,AIRLINES,"15,502.9","12,743.6","2,200.3",14.72%,"1,549","1,021.3",189.1,0.2,188.9,4.9,"5,621.3",145.7 -Ipca Laboratories Ltd.,IPCALAB,524494,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,072.5","1,712.7",321.3,15.80%,90.3,44.1,225.4,87.9,145.1,5.7,492.2,19.4 -J B Chemicals & Pharmaceuticals Ltd.,JBCHEPHARM,506943,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,889.4,638.2,243.5,27.62%,32.2,10.4,208.7,58.1,150.6,9.7,486.6,31.4 -JK Cement Ltd.,JKCEMENT,532644,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,782.1","2,285.8",467,16.96%,137.1,115,244.2,65.7,178.1,23.1,444,57.5 -JK Lakshmi Cement Ltd.,JKLAKSHMI,500380,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,588.5","1,357.3",217.3,13.80%,56.6,33.6,141,45.1,92.7,7.9,357.6,30.4 -JM Financial Ltd.,JMFINANCIL,523405,DIVERSIFIED,HOLDING COMPANIES,"1,214",407.9,662.6,55.34%,13.2,388.1,277.9,72.4,194.9,2,608.1,6.4 -JSW Energy Ltd.,JSWENERGY,533148,UTILITIES,ELECTRIC UTILITIES,"3,387.4","1,379","1,880.4",57.69%,408.7,513.7,"1,085.9",235.1,850.2,5.2,"1,591.7",9.7 -JSW Steel Ltd.,JSWSTEEL,500228,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"44,821","36,698","7,886",17.69%,"2,019","2,084","4,609","1,812","2,76",11.4,"9,252",38.1 -Jindal Stainless Ltd.,JSL,532508,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"9,829","8,566.5","1,230.6",12.56%,221.9,155.6,985.7,229.1,774.3,9.4,"2,600.2",31.6 -Jindal Steel & Power Ltd.,JINDALSTEL,532286,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"12,282","9,964.5","2,285.7",18.66%,603.7,329.4,"1,384.5",-5.8,"1,387.8",13.8,"4,056",40.4 -Jubilant Foodworks Ltd.,JUBLFOOD,533155,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,"1,375.7","1,091.4",277.2,20.25%,141.9,56.8,85.5,23.3,97.2,1.5,235,3.6 -Just Dial Ltd.,JUSTDIAL,535648,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,318.5,211.8,48.8,18.71%,12.2,2.4,92.1,20.3,71.8,8.4,314.1,36.9 -Jyothy Labs Ltd.,JYOTHYLAB,532926,FMCG,PERSONAL PRODUCTS,745.6,597,135.4,18.48%,12.3,1.2,135.1,31.1,104.2,2.8,326.9,8.9 -KRBL Ltd.,KRBL,530813,FMCG,PACKAGED FOODS,"1,246.5","1,018.9",194.5,16.03%,19.9,0.8,206.8,53.6,153.3,6.5,671.4,29.3 -Kajaria Ceramics Ltd.,KAJARIACER,500233,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"1,129.9",941.9,179.7,16.02%,36.1,4.3,147.7,36.6,108,6.8,397.8,25 -Kalpataru Projects International Ltd.,KPIL,522287,UTILITIES,ELECTRIC UTILITIES,"4,53","4,148",370,8.19%,113,137,132,42,89,5.5,478,29.9 -Kansai Nerolac Paints Ltd.,KANSAINER,500165,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"1,978.6","1,683.3",273.2,13.97%,47.4,7.6,240.3,64.8,177.2,2.2,"1,118.8",13.8 -Karur Vysya Bank Ltd.,KARURVYSYA,590003,BANKING AND FINANCE,BANKS,"2,336",616.4,637.9,31.94%,0,"1,081.7",511.5,133.1,378.4,4.7,"1,364.2",17 -KEC International Ltd.,KEC,532714,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"4,514.9","4,224.7",274.3,6.10%,46.5,177.8,65.8,9.9,55.8,2.2,187.9,7.3 -Kotak Mahindra Bank Ltd.,KOTAKBANK,500247,BANKING AND FINANCE,BANKS,"21,559.5","9,681","6,343",46.24%,0,"5,535.5","5,888.3","1,465.5","4,461",22.4,"17,172.7",86.4 -L&T Finance Holdings Ltd.,L&TFH,533519,DIVERSIFIED,HOLDING COMPANIES,"3,482.1",935.3,"1,882.4",58.57%,28.3,"1,324.9",797.4,203.2,595.1,2.4,"2,080.8",8.4 -L&T Technology Services Ltd.,LTTS,540115,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,427.7","1,910.9",475.6,19.93%,68.1,12.6,436.1,120.2,315.4,29.8,"1,239.7",117.5 -LIC Housing Finance Ltd.,LICHSGFIN,500253,BANKING AND FINANCE,HOUSING FINANCE,"6,765.9",250.6,"6,095.7",90.10%,13.2,"4,599.9","1,483",291.2,"1,193.5",21.7,"4,164.5",75.7 -Lakshmi Machine Works Ltd.,LAXMIMACH,500252,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"1,355.5","1,184.5",136,10.30%,23.6,0,147.4,32.3,115.1,107.8,416,389.5 -Laurus Labs Ltd.,LAURUSLABS,540222,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,226.2","1,036.6",187.9,15.34%,93.4,42.4,53.9,14.6,37,0.7,367.8,6.8 -Lupin Ltd.,LUPIN,500257,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"5,079","4,120.8",917.8,18.21%,247.8,80.6,629.7,134.3,489.5,10.8,"1,331.2",29.2 -MMTC Ltd.,MMTC,513377,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,-167.2,-180.1,-30.4,14.42%,0.8,1.1,12.1,1.5,52,0.3,174.1,1.2 -MRF Ltd.,MRF,500290,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"6,287.8","5,060.2","1,156.9",18.61%,351.5,85.5,790.6,203.9,586.7,1383.3,"1,690.9",3988 -Mahanagar Gas Ltd.,MGL,539957,UTILITIES,UTILITIES,"1,772.7","1,250.1",478.9,27.70%,65.8,2.5,454.3,115.8,338.5,34.3,"1,147.8",116.2 -Mahindra & Mahindra Financial Services Ltd.,M&MFIN,532720,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"3,863.5","1,077.5","2,109.3",55.03%,67.1,"1,703.4",369.1,96,281.1,2.3,"1,982.5",16 -Mahindra & Mahindra Ltd.,M&M,500520,AUTOMOBILES & AUTO COMPONENTS,CARS & UTILITY VEHICLES,"35,027.2","28,705.9","5,729.6",16.64%,"1,138.6","1,835.2","3,347.5","1,083.7","2,347.8",21.1,"11,169.4",100.2 -Mahindra Holidays & Resorts India Ltd.,MHRIL,533088,HOTELS RESTAURANTS & TOURISM,HOTELS,672.2,519.3,136,20.76%,83.8,33.3,35.8,14,21.3,1.1,66,3.3 -Manappuram Finance Ltd.,MANAPPURAM,531213,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"2,174",555.6,"1,481.3",68.68%,62.5,689.4,746.7,186.1,558.4,6.6,"1,859.8",22 -Mangalore Refinery And Petrochemicals Ltd.,MRPL,500109,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"22,904.7","20,705.6","2,138.2",9.36%,296,311.2,"1,592",546.2,"1,051.7",6,"3,784.9",21.6 -Marico Ltd.,MARICO,531642,FMCG,PERSONAL PRODUCTS,"2,514","1,979",497,20.07%,39,20,476,116,353,2.7,"1,41",10.9 -Maruti Suzuki India Ltd.,MARUTI,532500,AUTOMOBILES & AUTO COMPONENTS,CARS & UTILITY VEHICLES,"37,902.1","32,282.5","4,790.3",12.92%,794.4,35.1,"4,790.1","1,083.8","3,764.3",124.6,"11,351.8",375.9 -Max Financial Services Ltd.,MFSL,500271,BANKING AND FINANCE,LIFE INSURANCE,"10,189.1","10,024.6",143.9,1.42%,0.8,9.4,158.2,-12.1,147.9,4.3,506.4,14.7 -UNO Minda Ltd.,UNOMINDA,532539,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"3,630.2","3,219.8",401.6,11.09%,125.4,27.2,257.9,73.3,225,3.9,742.4,13 -Motilal Oswal Financial Services Ltd.,MOTILALOFS,532892,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,"1,650.7",724.1,904.5,55.18%,17.3,241.1,657.6,124.2,531.2,35.9,"1,449.3",97.8 -MphasiS Ltd.,MPHASIS,526299,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"3,325.5","2,680.9",595.6,18.18%,89,34,521.7,129.7,391.9,20.8,"1,605.6",85.1 -Muthoot Finance Ltd.,MUTHOOTFIN,533398,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"3,631.9",723.4,"2,801.6",77.69%,22.2,"1,335","1,470.2",374.9,"1,059.6",26.4,"3,982.9",99.2 -Natco Pharma Ltd.,NATCOPHARM,524816,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,060.8",573.4,458,44.41%,43.6,4.2,439.6,70.6,369,20.6,"1,127.4",63 -NBCC (India) Ltd.,NBCC,534309,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"2,129.1","1,957.7",95.5,4.65%,1.3,0,104.6,22.9,79.6,0.4,332.2,1.8 -NCC Ltd.,NCC,500294,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"4,746.4","4,415.9",303.7,6.44%,53.2,153.5,123.8,38.8,77.3,1.2,599.4,9.5 -NHPC Ltd.,NHPC,533098,UTILITIES,ELECTRIC UTILITIES,"3,113.8","1,173.9","1,757.4",59.95%,294.9,104.8,"1,618.3",-75,"1,545.8",1.5,"3,897.8",3.9 -Coforge Ltd.,COFORGE,532541,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,285.1","1,935.3",340.9,14.98%,77.2,31.9,240.7,52.8,187.9,29.6,696.2,113.2 -NLC India Ltd.,NLCINDIA,513683,UTILITIES,ELECTRIC UTILITIES,"3,234","2,143",834.6,28.03%,455.1,213.9,"1,700.6",614.7,"1,084.7",7.8,"1,912.3",13.8 -NTPC Ltd.,NTPC,532555,UTILITIES,ELECTRIC UTILITIES,"45,384.6","32,303.2","12,680.2",28.19%,"4,037.7","2,920.5","6,342.9","2,019.7","4,614.6",4.8,"19,125.2",19.7 -Narayana Hrudayalaya Ltd.,NH,539551,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,323.6",997.1,308.1,23.61%,55.3,22.9,248.4,21.7,226.6,11.2,737.5,36.1 -National Aluminium Company Ltd.,NATIONALUM,532234,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"3,112","2,646.9",396.5,13.03%,186.2,4,275,68.7,187.3,1,"1,272.4",6.9 -Navin Fluorine International Ltd.,NAVINFLUOR,532504,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,494.9,373.4,98.3,20.84%,24.2,20,77.2,16.6,60.6,12.2,365,73.7 -Oberoi Realty Ltd.,OBEROIRLTY,533273,REALTY,REALTY,"1,243.8",579.2,638.2,52.42%,11.3,56.5,596.8,142.1,456.8,12.6,"1,961.3",53.9 -Oil And Natural Gas Corporation Ltd.,ONGC,500312,OIL & GAS,EXPLORATION & PRODUCTION,"149,388.5","118,618.4","28,255.3",19.24%,"6,698.1","2,603.3","21,564.9","5,633.6","13,734.1",10.9,"43,072.5",34.2 -Oil India Ltd.,OIL,533106,OIL & GAS,EXPLORATION & PRODUCTION,"9,200.1","5,293.3","3,523.2",39.96%,499,278.9,762,67.6,420.7,3.9,"5,874.5",54.2 -Oracle Financial Services Software Ltd.,OFSS,532466,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,509.6",886.4,558.1,38.64%,19,8,596.2,178.8,417.4,48.2,"1,835.1",211.9 -PI Industries Ltd.,PIIND,523642,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"2,163.8","1,565.5",551.4,26.05%,80.3,7.8,510.2,31.7,480.5,31.7,"1,495.8",98.4 -PNB Housing Finance Ltd.,PNBHOUSING,540173,BANKING AND FINANCE,HOUSING FINANCE,"1,779.4",158.8,"1,574.1",88.54%,11.3,"1,057.3",507.1,124.1,383,14.8,"1,278.7",49.3 -PNC Infratech Ltd.,PNCINFRA,539150,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,932.4","1,511.6",399.8,20.92%,40.9,161.3,218.6,70.7,147.9,5.8,614.3,23.9 -PVR INOX Ltd.,PVRINOX,532689,RETAILING,SPECIALTY RETAIL,"2,023.7","1,293.1",706.8,35.34%,308.6,200.3,221.7,55.5,166.3,17,-232.5,-23.7 -Page Industries Ltd.,PAGEIND,532827,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,"1,126.8",891.6,233.5,20.76%,24.6,11.2,199.4,49.1,150.3,134.7,510.7,457.9 -Persistent Systems Ltd.,PERSISTENT,533179,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,449","2,006.5",405.2,16.80%,74.4,12.3,355.8,92.5,263.3,35,981.5,127.6 -Petronet LNG Ltd.,PETRONET,532522,OIL & GAS,OIL MARKETING & DISTRIBUTION,"12,686.2","11,317.9","1,214.7",9.69%,194.8,74.7,"1,098.8",283.9,855.7,5.7,"3,490.3",23.3 -Pfizer Ltd.,PFIZER,500680,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,611.3,392.6,182.6,31.75%,15.4,2.7,200.5,51.6,149,32.6,522.8,114.3 -Phoenix Mills Ltd.,PHOENIXLTD,503100,REALTY,REALTY,906.6,361.2,506,57.82%,65.9,96.5,375.2,71.4,252.6,14.2,923.6,51.7 -Pidilite Industries Ltd.,PIDILITIND,500331,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"3,107.6","2,396.3",679.7,22.10%,75.2,13.1,623,163.1,450.1,8.8,"1,505.5",29.6 -Power Finance Corporation Ltd.,PFC,532810,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"22,403.7",315.4,"22,941.9",102.46%,12.7,"14,313.1","8,628.8","2,000.6","4,833.1",14.7,"17,946.4",54.4 -Power Grid Corporation of India Ltd.,POWERGRID,532898,UTILITIES,ELECTRIC UTILITIES,"11,530.4","1,358.7","9,908.4",87.94%,"3,277","2,341.3","4,393.4",573.7,"3,781.4",4.1,"15,344.4",16.5 -Prestige Estates Projects Ltd.,PRESTIGE,ASM,REALTY,REALTY,"3,256","1,643.9",592.5,26.49%,174.1,263.9,"1,174.1",256.4,850.9,21.2,"1,714",42.8 -Prism Johnson Ltd.,PRSMJOHNSN,500338,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,846","1,745.4",92.4,5.03%,95.2,43.5,210,30.4,182.7,3.6,154.2,3.1 -Procter & Gamble Hygiene & Healthcare Ltd.,PGHH,500459,FMCG,PERSONAL PRODUCTS,"1,154.1",853.5,284.9,25.03%,14.3,1.9,284.5,73.8,210.7,64.9,734.4,226.3 -Punjab National Bank,PNB,532461,BANKING AND FINANCE,BANKS,"29,857","6,798.1","6,239.1",23.23%,0,"16,819.8","2,778.3","1,013.8","1,990.2",1.8,"5,904.8",5.4 -Quess Corp Ltd.,QUESS,539978,SOFTWARE & SERVICES,BPO/KPO,"4,763.5","4,584.8",163.6,3.44%,69.7,28.1,79.3,8.3,71.9,4.8,240.9,16.2 -RBL Bank Ltd.,RBLBANK,540065,BANKING AND FINANCE,BANKS,"3,720.6","1,422.6",765.4,25.45%,0,"1,532.6",125,-206.1,331.1,5.5,"1,173.9",19.5 -Radico Khaitan Ltd.,RADICO,532497,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,925.7,803.8,121.2,13.10%,26.1,12.5,83.3,21.4,64.8,4.8,237,17.7 -Rain Industries Ltd.,RAIN,500339,CHEMICALS & PETROCHEMICALS,PETROCHEMICALS,"4,208.9","3,794.3",366,8.80%,192.5,241.7,-19.5,46.2,-90.2,-2.7,270.4,8 -Rajesh Exports Ltd.,RAJESHEXPO,531500,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"38,079.4","38,015.8",50.1,0.13%,10.7,0,53,7.7,45.3,1.5,"1,142.2",38.7 -Rallis India Ltd.,RALLIS,500355,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,837,699,133,15.99%,26,3,110,28,82,4.2,98.4,5.2 -Rashtriya Chemicals & Fertilizers Ltd.,RCF,524230,FERTILIZERS,FERTILIZERS,"4,222.1","4,049.3",105.9,2.55%,56.1,44,72.8,21.1,51,0.9,523.6,9.5 -Redington Ltd.,REDINGTON,532805,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,"22,296.6","21,738.7",481.4,2.17%,43.7,105.8,408.3,96.7,303.5,3.9,"1,242",15.9 -Relaxo Footwears Ltd.,RELAXO,530517,RETAILING,FOOTWEAR,725.9,623.8,91.5,12.79%,36.9,4.7,60.4,16.2,44.2,1.8,193.9,7.8 -Reliance Industries Ltd.,RELIANCE,500325,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"238,797","193,988","40,968",17.44%,"12,585","5,731","26,493","6,673","17,394",25.7,"68,496",101.2 -REC Ltd.,RECLTD,532955,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"11,701.3",275.1,"12,180.5",104.21%,6.1,"7,349.8","4,837.6","1,047.7","3,789.9",14.4,"12,738.6",48.4 -SJVN Ltd.,SJVN,533206,UTILITIES,ELECTRIC UTILITIES,951.6,172.2,706.2,80.40%,101.9,124.2,567.7,129.2,439.6,1.1,"1,016",2.6 -SKF India Ltd.,SKFINDIA,500472,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,"1,145.5","1,003.7",121.5,10.80%,19.3,0.5,122,31.7,90,18.2,484,97.9 -SRF Ltd.,SRF,503806,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"3,206.5","2,551.2",626.2,19.71%,161.2,79.3,414.8,114,300.8,10.2,"1,733.4",58.5 -Sanofi India Ltd.,SANOFI,500674,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,726.4,506.1,208.5,29.17%,9.9,0.3,210.1,57.9,152.1,66.1,596.3,259.3 -Schaeffler India Ltd.,SCHAEFFLER,505790,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,879.2","1,506.3",342,18.50%,55.6,1.6,315.7,80.7,235,15,922.6,59 -Shree Cements Ltd.,SHREECEM,500387,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"4,932.1","3,914.1",886,18.46%,411.7,67,539.2,92.6,446.6,123.8,"1,826.8",506.3 -Shriram Finance Ltd.,SHRIRAMFIN,511218,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"8,893","1,409.4","6,334.3",71.30%,141.4,"3,798","2,404.2",614.9,"1,786.1",47.6,"6,575.4",175.2 -Siemens Ltd.,SIEMENS,500550,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"5,953.2","5,107.5",700.2,12.06%,78.6,4.9,762.2,190.5,571.3,16.1,"1,960.9",55.1 -Sobha Ltd.,SOBHA,532784,REALTY,REALTY,773.6,665.8,75.4,10.18%,19.3,63.9,24.7,9.7,14.9,1.6,107.4,11.3 -Solar Industries India Ltd.,SOLARINDS,532725,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"1,355.2","1,011.3",336.1,24.95%,33.7,24.9,285.3,75.5,200.1,22.1,808.2,89.3 -Sonata Software Ltd.,SONATSOFTW,532221,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,935.8","1,715.2",197.3,10.32%,33.3,20.7,166.5,42.3,124.2,9,475.7,34.3 -State Bank of India,SBIN,500112,BANKING AND FINANCE,BANKS,"144,256.1","58,597.6","22,703.3",21.14%,0,"62,955.2","21,935.7","5,552.5","17,196.2",18,"69,304.1",77.7 -Steel Authority of India (SAIL) Ltd.,SAIL,500113,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"29,858.2","25,836.7","3,875.4",13.04%,"1,326.6",605.2,"1,674.7",464.2,"1,305.6",3.2,"3,219.5",7.8 -Sun Pharma Advanced Research Company Ltd.,SPARC,532872,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,29.7,112.7,-91.5,-431.87%,3.2,0.3,-86.4,0,-86.4,-2.7,-253.6,-7.8 -Sun Pharmaceutical Industries Ltd.,SUNPHARMA,524715,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"12,486","9,013","3,179.4",26.08%,632.8,49.3,"2,790.9",390.1,"2,375.5",9.9,"8,548.5",35.6 -Sun TV Network Ltd.,SUNTV,532733,MEDIA,BROADCASTING & CABLE TV,"1,160.2",320.6,727.8,69.42%,218.8,1.7,619.1,154.4,464.7,11.8,"1,861.8",47.2 -Sundram Fasteners Ltd.,SUNDRMFAST,500403,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,429.1","1,191.1",230.7,16.23%,54.5,7.4,176.2,43.1,131.9,6.3,502.9,23.9 -Sunteck Realty Ltd.,SUNTECK,512179,REALTY,REALTY,36.2,39.1,-14.1,-56.70%,2.2,15.8,-20.9,-6.4,-13.9,-1,-46.5,-3.3 -Supreme Industries Ltd.,SUPREMEIND,509930,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,"2,321.4","1,952.5",356.2,15.43%,71.9,1.6,295.4,76.3,243.2,19.1,"1,028.2",80.9 -Suzlon Energy Ltd.,SUZLON,ASM,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"1,428.7","1,196.4",225,15.83%,51.2,43.7,102.4,0.1,102.3,0.1,561.4,0.4 -Syngene International Ltd.,SYNGENE,539268,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,931.7,656,254.1,27.92%,104.6,13,150.7,34.2,116.5,2.9,498.3,12.4 -TTK Prestige Ltd.,TTKPRESTIG,517506,CONSUMER DURABLES,HOUSEWARE,747.2,648.6,80.8,11.08%,15.9,3.1,79.5,20.5,59.3,4.3,224.3,16.2 -TV18 Broadcast Ltd.,TV18BRDCST,532800,MEDIA,BROADCASTING & CABLE TV,"1,989","1,992.2",-198.1,-11.04%,50.1,33.8,-87.1,-6.5,-28.9,-0.2,92.2,0.5 -TVS Motor Company Ltd.,TVSMOTOR,532343,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"9,983.8","8,576.9","1,355.9",13.65%,237.1,483.3,686.4,259.8,386.3,8.1,"1,457.6",30.7 -Tata Consultancy Services Ltd.,TCS,532540,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"60,698","43,946","15,746",26.38%,"1,263",159,"15,33","3,95","11,342",31,"44,654",122 -Tata Elxsi Ltd.,TATAELXSI,500408,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,912.8,618.2,263.5,29.89%,25,5.8,263.9,63.8,200,32.1,785.1,126.1 -Tata Consumer Products Ltd.,TATACONSUM,500800,FMCG,PACKAGED FOODS,"3,823.6","3,196.7",537.1,14.38%,93.9,27.6,490.9,131.7,338.2,3.6,"1,275.2",13.7 -Tata Motors Limited (DVR),TATAMTRDVR,570001,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,,,,,,,,,,,, -Tata Motors Ltd.,TATAMOTORS,500570,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"106,759","91,361.3","13,766.9",13.10%,"6,636.4","2,651.7","5,985.9","2,202.8","3,764",9.8,"15,332.3",40 -Tata Power Company Ltd.,TATAPOWER,500400,UTILITIES,ELECTRIC UTILITIES,"16,029.5","12,647","3,091",19.64%,925.9,"1,181.8",979.2,213.3,875.5,2.7,"3,570.8",11.2 -Tata Steel Ltd.,TATASTEEL,500470,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"55,910.2","51,414.1","4,267.8",7.66%,"2,479.8","1,959.4","-6,842.1",-228,"-6,196.2",-5.1,"-6,081.3",-5 -Tech Mahindra Ltd.,TECHM,532755,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"13,128.1","11,941.1",922.8,7.17%,465.7,97.5,623.8,110,493.9,5.6,"3,600.7",40.9 -The Ramco Cements Ltd.,RAMCOCEM,500260,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,352.1","1,935",405.6,17.33%,162.8,116.5,137.8,37,72,3.1,348.9,14.8 -Thermax Ltd.,THERMAX,500411,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,368.3","2,097.8",204.6,8.89%,33,19.8,217.7,58.9,157.7,14,498.8,44.3 -Timken India Ltd.,TIMKEN,522113,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,692.1,546.5,135.5,19.87%,21.1,0.9,123.6,30.6,93,12.4,358.3,47.6 -Titan Company Ltd.,TITAN,500114,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"12,653","11,118","1,411",11.26%,144,140,"1,251",336,915,10.3,"3,302",37.1 -Torrent Pharmaceuticals Ltd.,TORNTPHARM,500420,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,686","1,835",825,31.02%,201,91,559,173,386,11.4,"1,334",39.4 -Torrent Power Ltd.,TORNTPOWER,532779,UTILITIES,ELECTRIC UTILITIES,"7,069.1","5,739.5","1,221.4",17.55%,341.7,247.2,740.7,198.1,525.9,10.9,"2,176.8",45.3 -Trent Ltd.,TRENT,500251,RETAILING,DEPARTMENT STORES,"3,062.5","2,525.8",456.6,15.31%,152.2,95.5,288.9,86.3,234.7,6.6,629.4,17.7 -Trident Ltd.,TRIDENT,521064,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,812","1,557.3",240.3,13.37%,89.4,35,130.4,40.1,90.7,0.2,458.1,0.9 -UPL Ltd.,UPL,512070,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"10,275","8,807","1,325",13.03%,657,871,-185,-96,-189,-2.5,"1,856",24.7 -UltraTech Cement Ltd.,ULTRACEMCO,532538,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"16,179.3","13,461.2","2,550.9",15.93%,797.8,233.9,"1,686.2",409.4,"1,281.5",44.5,"5,694.1",197.2 -Union Bank of India,UNIONBANK,532477,BANKING AND FINANCE,BANKS,"28,952.5","6,189.3","7,265",29.38%,0,"15,498.2","5,492.3","1,944","3,571.8",5.1,"11,918.9",16.1 -United Breweries Ltd.,UBL,532478,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,"1,902.1","1,705.8",184.3,9.75%,50.9,1.4,144,36.9,107.3,4.1,251.3,9.5 -United Spirits Ltd.,MCDOWELL-N,532432,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,"6,776.6","6,269.8",466.7,6.93%,65.3,26.2,446,106.3,339.3,4.8,"1,133",15.6 -V-Guard Industries Ltd.,VGUARD,532953,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,147.9","1,041.3",92.5,8.16%,19.8,9.3,77.5,18.6,59,1.4,215.2,5 -Vardhman Textiles Ltd.,VTL,502986,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,487","2,192.1",205.4,8.57%,103.7,22,169.2,41.7,134.3,4.7,531.9,18.7 -Varun Beverages Ltd.,VBL,540180,FOOD BEVERAGES & TOBACCO,NON-ALCOHOLIC BEVERAGES,"3,889","2,988.4",882.1,22.79%,170.8,62.5,667.3,152.9,501.1,3.9,"1,998.7",15.4 -Vinati Organics Ltd.,VINATIORGA,524200,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,464.4,337.3,110.8,24.73%,13.7,0.3,113,28.9,84.2,8.2,408.2,39.7 -Voltas Ltd.,VOLTAS,500575,CONSUMER DURABLES,CONSUMER ELECTRONICS,"2,363.7","2,222.5",70.3,3.06%,11.7,11.4,118.1,49.3,36.7,1.1,199.5,6 -ZF Commercial Vehicle Control Systems India Ltd.,ZFCVINDIA,533023,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,015.8",846.2,145.5,14.67%,27.1,1.3,141.2,35.5,105.7,55.7,392,206.7 -Welspun Corp Ltd.,WELCORP,ASM,METALS & MINING,IRON & STEEL PRODUCTS,"4,161.4","3,659.9",399.5,9.84%,85.7,75,340.8,79,384.7,14.7,809.2,30.9 -Welspun Living Ltd.,WELSPUNLIV,514162,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,542.4","2,151.1",358,14.27%,98.5,33.8,258.9,58.7,196.7,2,526.1,5.4 -Whirlpool of India Ltd.,WHIRLPOOL,500238,CONSUMER DURABLES,CONSUMER ELECTRONICS,"1,555.5","1,448.4",73.2,4.81%,49.2,5.6,52.3,14.1,36.6,2.9,198.8,15.7 -Wipro Ltd.,WIPRO,507685,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"23,255.7","18,543.2","3,972.7",17.64%,897,303.3,"3,512.2",841.9,"2,646.3",5.1,"11,643.8",22.3 -Zee Entertainment Enterprises Ltd.,ZEEL,505537,MEDIA,BROADCASTING & CABLE TV,"2,509.6","2,105",332.8,13.65%,77.2,23.4,184.2,54.4,123,1.3,-102.2,-1.1 -eClerx Services Ltd.,ECLERX,532927,SOFTWARE & SERVICES,BPO/KPO,735.9,517,204.7,28.37%,30.3,6.1,182.4,46.3,136,28.2,506,105 -Sterlite Technologies Ltd.,STLTECH,532374,TELECOMMUNICATIONS EQUIPMENT,TELECOM CABLES,"1,497","1,281",213,14.26%,85,95,36,12,34,0.9,203,5.1 -HEG Ltd.,HEG,509631,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,642.2,512.3,101.9,16.58%,38.5,8.5,82.9,21.7,96,24.9,439.5,113.9 -SBI Life Insurance Company Ltd.,SBILIFE,540719,BANKING AND FINANCE,LIFE INSURANCE,"28,816.2","28,183.8",609.9,2.12%,0,0,621.5,43.9,380.2,3.8,"1,842.2",18.4 -General Insurance Corporation of India,GICRE,540755,BANKING AND FINANCE,GENERAL INSURANCE,"13,465.9","11,574","1,464.6",11.20%,0,0,"1,855.4",243.7,"1,689",15.2,"6,628",37.8 -Tube Investments of India Ltd.,TIINDIA,540762,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,005.4","1,718.2",251.4,12.76%,34.6,7.7,244.8,63.4,181.4,9.4,717.5,37.1 -Honeywell Automation India Ltd.,HONAUT,517174,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,144.3",965.9,138.3,12.52%,13.8,0.7,163.9,42,121.9,137.8,443.4,503.9 -Indian Energy Exchange Ltd.,IEX,540750,BANKING AND FINANCE,EXCHANGE,133,16.6,92,84.73%,5.1,0.7,110.6,27.9,86.5,1,327.8,3.7 -ICICI Lombard General Insurance Company Ltd.,ICICIGI,540716,BANKING AND FINANCE,GENERAL INSURANCE,"5,271.1","4,612.4",743.5,14.16%,0,0,763.6,186.4,577.3,11.8,"1,757.1",35.8 -Aster DM Healthcare Ltd.,ASTERDM,540975,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"3,325.2","2,939.4",377.3,11.38%,227.2,101.9,2.1,10.2,-30.8,-0.6,284.3,5.7 -Central Depository Services (India) Ltd.,CDSL,CDSL,OTHERS,INVESTMENT COMPANIES,230.1,77.9,129.4,62.40%,6.5,0,145.6,35.8,108.9,10.4,320.2,30.6 -Graphite India Ltd.,GRAPHITE,509488,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,884,823,-30,-3.78%,19,4,992,190,804,41.1,856,43.9 -Grasim Industries Ltd.,GRASIM,500300,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"30,505.3","25,995.9","4,224.8",13.98%,"1,245.2",397.8,"2,866.4",837.7,"1,163.8",17.7,"6,624.9",100.6 -KNR Constructions Ltd.,KNRCON,532942,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"1,043.8",806.9,231.6,22.30%,39.2,20.6,177.1,34.6,147.4,5.2,537.5,19.1 -Aditya Birla Capital Ltd.,ABCAPITAL,540691,DIVERSIFIED,HOLDING COMPANIES,"7,730.4","4,550.1","2,821.9",36.55%,48,"1,827",956.8,284.1,705,2.7,"5,231.9",20.1 -Dixon Technologies (India) Ltd.,DIXON,540699,CONSUMER DURABLES,CONSUMER ELECTRONICS,"4,943.9","4,744.3",198.9,4.02%,36.4,17.1,146.1,35.2,107.3,19,308.7,51.8 -Cholamandalam Financial Holdings Ltd.,CHOLAHLDNG,504973,DIVERSIFIED,HOLDING COMPANIES,"6,372.2","2,495.1","3,404.8",54.05%,52.1,"2,209.4","1,215.8",324.6,420.9,22.4,"1,532.3",81.6 -Cochin Shipyard Ltd.,COCHINSHIP,540678,TRANSPORTATION,MARINE PORT & SERVICES,"1,100.4",820.5,191.2,18.90%,18.9,9.6,251.4,69.9,181.5,13.8,429.9,32.7 -Bharat Dynamics Ltd.,BDL,541143,GENERAL INDUSTRIALS,DEFENCE,694.1,481.8,134,21.77%,17.4,0.8,194.1,47,147.1,8,425.4,23.2 -Lux Industries Ltd.,LUXIND,539542,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,643.6,584.2,55,8.61%,5.9,5.4,48,12.1,37.1,12.3,103.1,32.9 -Zensar Technologies Ltd.,ZENSARTECH,504067,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,277.1","1,009.9",230.9,18.61%,36.6,5.7,224.9,51,173.9,7.7,525.8,23.2 -PCBL Ltd.,PCBL,506590,CHEMICALS & PETROCHEMICALS,CARBON BLACK,"1,489.4","1,248.6",238.1,16.02%,48.2,21,171.6,48.8,122.6,3.2,431.6,11.4 -Zydus Wellness Ltd.,ZYDUSWELL,531335,FMCG,PACKAGED FOODS,444,423.1,16.8,3.82%,5.8,6.5,8.6,2.7,5.9,0.9,281.2,44.2 -Linde India Ltd.,LINDEINDIA,523457,GENERAL INDUSTRIALS,INDUSTRIAL GASES,729.9,537.7,173.6,24.41%,49.7,1.2,141.3,34.6,108.7,12.8,417.9,49 -FDC Ltd.,FDC,531599,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,513.6,409.9,76.4,15.71%,9.9,1.1,92.7,22.9,69.8,4.2,251.2,15.4 -The New India Assurance Company Ltd.,NIACL,540769,BANKING AND FINANCE,GENERAL INSURANCE,"10,571","10,773.4",-246.5,-2.33%,0,0,-242,-46.7,-176.1,-1.1,947,5.7 -Sundaram Finance Ltd.,SUNDARMFIN,590071,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"1,710.6",322.5,"1,332.1",77.98%,43.6,820.3,470.6,142.8,365.4,33.2,"1,506.7",135.6 -TeamLease Services Ltd.,TEAMLEASE,539658,COMMERCIAL SERVICES & SUPPLIES,MISC. COMMERCIAL SERVICES,"2,285.6","2,240.8",31.8,1.40%,12.9,2.5,29.4,1.8,27.3,16.3,106.6,63.5 -Galaxy Surfactants Ltd.,GALAXYSURF,540935,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,985.8,858.2,124.9,12.70%,24.7,5.4,97.5,20.1,77.4,21.8,349.3,98.5 -Bandhan Bank Ltd.,BANDHANBNK,541153,BANKING AND FINANCE,BANKS,"5,032.2","1,400.2","1,583.4",35.25%,0,"2,048.6",947.2,226.1,721.2,4.5,"2,541.1",15.8 -ICICI Securities Ltd.,ISEC,541179,BANKING AND FINANCE,CAPITAL MARKETS,"1,249",433.5,810.2,64.87%,25.8,215.1,569.4,145.7,423.6,13.1,"1,238.1",38.3 -V-Mart Retail Ltd.,VMART,534976,RETAILING,DEPARTMENT STORES,551.4,548.8,0.7,0.12%,53.2,35.9,-86.4,-22.3,-64.1,-32.4,-103.1,-52.1 -Nippon Life India Asset Management Ltd.,NAM-INDIA,540767,BANKING AND FINANCE,ASSET MANAGEMENT COS.,475.4,156.1,241.4,60.73%,7.2,1.7,310.4,66.1,244.4,3.9,883.3,14.1 -Grindwell Norton Ltd.,GRINDWELL,506076,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,690,536,131.4,19.69%,16.9,1.8,135.3,33.1,101.9,9.2,378.3,34.2 -HDFC Life Insurance Company Ltd.,HDFCLIFE,540777,BANKING AND FINANCE,LIFE INSURANCE,"23,276.6","23,659.3",-508.1,-2.20%,0,0,-373.1,-657.5,378.2,1.8,"1,472.8",6.9 -Elgi Equipments Ltd.,ELGIEQUIP,522074,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,817.8,663.4,142.7,17.71%,18.7,6.6,129.2,38.8,91.3,2.9,401.9,12.7 -Hindustan Aeronautics Ltd.,HAL,541154,GENERAL INDUSTRIALS,DEFENCE,"6,105.1","4,108.1","1,527.6",27.11%,349.6,0.3,"1,647",414.8,"1,236.7",18.5,"6,037.3",90.3 -BSE Ltd.,BSE,BSE,BANKING AND FINANCE,EXCHANGE,367,172.8,189.2,52.26%,22.7,8.5,163,63.6,120.5,8.8,706,52.1 -Rites Ltd.,RITES,541556,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,608.8,444.5,137.8,23.67%,14.1,1.4,148.8,40.1,101.2,4.2,488.1,20.3 -Fortis Healthcare Ltd.,FORTIS,532843,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,783.5","1,439.8",330.2,18.65%,84.1,31.8,231.4,48.8,173.7,2.3,547.6,7.3 -Varroc Engineering Ltd.,VARROC,541578,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,893.5","1,692.6",194.3,10.30%,84.9,50.3,65.9,18.2,54.2,3.5,146.5,9.6 -Adani Green Energy Ltd.,ADANIGREEN,ASM,UTILITIES,ELECTRIC UTILITIES,"2,589",521,"1,699",76.53%,474,"1,165",413,119,372,2.2,"1,305",8.2 -VIP Industries Ltd.,VIPIND,507880,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,548.7,493.2,52.9,9.68%,23.8,12.4,19.3,6,13.3,0.9,110.9,7.8 -CreditAccess Grameen Ltd.,CREDITACC,541770,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"1,247.6",248.8,902.3,72.36%,12.3,423.9,466.8,119.7,347,21.8,"1,204.2",75.7 -CESC Ltd.,CESC,500084,UTILITIES,ELECTRIC UTILITIES,"4,414","3,706",646,14.84%,303,305,461,98,348,2.6,"1,447",10.9 -Jamna Auto Industries Ltd.,JAMNAAUTO,520051,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,608.7,528.2,79.1,13.03%,10.9,0.8,68.7,18.6,50.1,2.4,189.3,4.7 -Suprajit Engineering Ltd.,SUPRAJIT,532509,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,727.6,639.1,69.8,9.85%,25.7,13.6,49.2,14.5,34.8,2.5,146.9,10.6 -JK Paper Ltd.,JKPAPER,532162,COMMERCIAL SERVICES & SUPPLIES,PAPER & PAPER PRODUCTS,"1,708.8","1,242.8",407.3,24.68%,83.5,42,340.6,34.9,302.4,17.9,"1,220.6",72.1 -Bank of Maharashtra,MAHABANK,532525,BANKING AND FINANCE,BANKS,"5,735.5","1,179.4","1,920.5",37.90%,0,"2,635.7",935.7,16,919.8,1.3,"3,420.8",4.8 -Aavas Financiers Ltd.,AAVAS,541988,BANKING AND FINANCE,HOUSING FINANCE,497.6,123.5,367.8,74.03%,7.6,203.6,157.4,35.7,121.7,15.4,465.4,58.8 -HDFC Asset Management Company Ltd.,HDFCAMC,541729,BANKING AND FINANCE,ASSET MANAGEMENT COS.,765.4,162,481.1,74.81%,13,2.3,588.1,151.6,436.5,20.4,"1,659.3",77.7 -KEI Industries Ltd.,KEI,517569,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,954.2","1,742.7",203.9,10.47%,15.6,7.5,188.4,48.2,140.2,15.5,528.3,58.5 -Orient Electric Ltd.,ORIENTELEC,541301,CONSUMER DURABLES,CONSUMER ELECTRONICS,570.3,546.2,20.7,3.65%,14.2,5.2,23.4,4.9,18.4,0.9,95.3,4.5 -Deepak Nitrite Ltd.,DEEPAKNTR,506401,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"1,795.1","1,475.8",302.3,17.00%,39.4,2.7,277.2,72.1,205.1,15,797.9,58.5 -Fine Organic Industries Ltd.,FINEORG,541557,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,557.6,409.4,131.1,24.25%,14.4,0.7,133.1,28.9,103.4,33.7,458.8,149.6 -LTIMindtree Ltd.,LTIM,540005,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"9,048.6","7,274.1","1,631.3",18.32%,208.2,47,"1,519.3",357,"1,161.8",39.3,"4,427.5",149.6 -Dalmia Bharat Ltd.,DALBHARAT,542216,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"3,234","2,56",589,18.70%,401,101,172,48,118,6.3,"1,041",54.8 -Godfrey Phillips India Ltd.,GODFRYPHLP,500163,FOOD BEVERAGES & TOBACCO,CIGARETTES-TOBACCO PRODUCTS,"1,412.5","1,151",223.6,16.27%,36.5,6.6,218.5,55.5,202.1,38.9,802.9,154.4 -Vaibhav Global Ltd.,VAIBHAVGBL,532156,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,708.4,641.5,63.5,9.01%,22.6,2.9,41.4,12.4,29.4,1.8,121.3,7.3 -Abbott India Ltd.,ABBOTINDIA,500488,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,549.7","1,113.3",380.9,25.49%,17.8,3.1,415.4,102.5,312.9,147.3,"1,081.4",508.9 -Adani Total Gas Ltd.,ATGL,ASM,UTILITIES,UTILITIES,"1,104.8",815.7,279.9,25.55%,37.6,27.3,224.2,57.2,172.7,1.6,571,5.2 -Nestle India Ltd.,NESTLEIND,500790,FMCG,PACKAGED FOODS,"5,070.1","3,811.9","1,224.9",24.32%,111.2,31.4,"1,222",313.9,908.1,94.2,"2,971.1",308.2 -Bayer Cropscience Ltd.,BAYERCROP,506285,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"1,633.3","1,312.3",304.9,18.85%,11.6,3.7,305.7,82.8,222.9,49.6,844.4,188.1 -Amber Enterprises India Ltd.,AMBER,540902,CONSUMER DURABLES,CONSUMER ELECTRONICS,939.8,867.5,59.6,6.43%,45.2,36.6,-9.5,-3.8,-6.9,-2.1,156.8,46.5 -Rail Vikas Nigam Ltd.,RVNL,542649,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"5,210.3","4,616",298.3,6.07%,6.2,132.7,455.4,85.2,394.3,1.9,"1,478.8",7.1 -Metropolis Healthcare Ltd.,METROPOLIS,542650,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,309.7,233.7,74.8,24.25%,22.2,5.7,48.1,12.5,35.5,6.9,133.4,26 -Polycab India Ltd.,POLYCAB,542652,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"4,253","3,608.8",608.9,14.44%,60.3,26.8,557.2,127.4,425.6,28.4,"1,607.2",107.1 -Multi Commodity Exchange of India Ltd.,MCX,534091,BANKING AND FINANCE,EXCHANGE,184,193.8,-28.7,-17.38%,6.6,0.1,-16.4,1.6,-19.1,-3.7,44.8,8.8 -IIFL Finance Ltd.,IIFL,532636,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,"2,533.7",788.3,"1,600.8",64.66%,43.3,932.1,683.5,158,474.3,12.4,"1,690.7",44.4 -Ratnamani Metals & Tubes Ltd.,RATNAMANI,520111,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"1,141.9",886.3,244.9,21.65%,23.6,10.8,221.1,56.8,163.9,23.4,622.6,88.8 -RHI Magnesita India Ltd.,RHIM,534076,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,989.7,839,147.9,14.98%,44.2,8.5,97.9,26.3,71.3,3.5,-502.2,-24.3 -Birlasoft Ltd.,BSOFT,532400,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,325.4","1,102.7",207.1,15.81%,21.5,5.7,195.5,50.4,145.1,5.2,378.4,13.7 -EIH Ltd.,EIHOTEL,500840,HOTELS RESTAURANTS & TOURISM,HOTELS,552.5,387.6,142.9,26.94%,33.2,5.6,126.1,36.2,93.1,1.5,424.1,6.8 -Affle (India) Ltd.,AFFLE,542752,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,441.2,344.1,87.2,20.22%,18.4,5.5,73.2,6.4,66.8,5,264.3,19.8 -Westlife Foodworld Ltd.,WESTLIFE,505533,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,618,516.5,98.2,15.98%,43.9,27.4,30.2,7.8,22.4,1.4,107.7,6.9 -IndiaMART InterMESH Ltd.,INDIAMART,542726,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,329.3,214.7,80,27.15%,8,2.3,104.3,23.9,69.4,11.4,321.1,53.6 -Infosys Ltd.,INFY,500209,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"39,626","29,554","9,44",24.21%,"1,166",138,"8,768","2,553","6,212",15,"24,871",60.1 -Sterling and Wilson Renewable Energy Ltd.,SWSOLAR,542760,COMMERCIAL SERVICES & SUPPLIES,CONSULTING SERVICES,776.7,758,1.5,0.19%,4.3,64.3,-50,4.6,-54.2,-2.9,-668.4,-35.2 -ABB India Ltd.,ABB,500002,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,846","2,330.7",438.5,15.84%,30.3,0.9,484.2,122.2,362.9,17.1,"1,208.7",57 -Poly Medicure Ltd.,POLYMED,531768,HEALTHCARE EQUIPMENT & SUPPLIES,HEALTHCARE SUPPLIES,351.4,253.1,84.2,24.97%,16,2.2,80.9,18.8,62.2,6.5,233.7,24.4 -GMM Pfaudler Ltd.,GMMPFAUDLR,505255,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,946,795.5,142,15.15%,32.2,21.5,96.8,26.5,71.1,15.8,183.2,40.8 -Gujarat Fluorochemicals Ltd.,FLUOROCHEM,542812,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,960.3,783.7,163.1,17.23%,67.5,34.2,74.8,22.1,52.7,4.8,915.2,83.3 -360 One Wam Ltd.,360ONE,542772,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,617.1,235.6,317.8,57.31%,13.7,139.9,226.8,40.8,186,5.2,696.8,19.5 -Tata Communications Ltd.,TATACOMM,500483,TELECOM SERVICES,OTHER TELECOM SERVICES,"4,897.9","3,857.1","1,015.5",20.84%,605.1,137.4,298.3,77.9,220.7,7.7,"1,322.3",46.4 -Alkyl Amines Chemicals Ltd.,ALKYLAMINE,506767,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,354.5,303.9,48.3,13.71%,12.5,1.7,36.4,9.2,27.2,5.3,171.3,33.5 -CSB Bank Ltd.,CSBBANK,542867,BANKING AND FINANCE,BANKS,835.8,317.5,174.6,25.41%,0,343.6,178,44.8,133.2,7.7,577.7,33.3 -Indian Railway Catering & Tourism Corporation Ltd.,IRCTC,542830,DIVERSIFIED CONSUMER SERVICES,TRAVEL SUPPORT SERVICES,"1,042.4",628.8,366.6,36.83%,14,4.4,395.2,100.5,294.7,3.7,"1,061.2",13.3 -Sumitomo Chemical India Ltd.,SUMICHEM,542920,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,928,715.5,187.9,20.80%,15.8,1.2,195.5,52,143.4,2.9,367.7,7.4 -Century Textiles & Industries Ltd.,CENTURYTEX,500040,COMMERCIAL SERVICES & SUPPLIES,PAPER & PAPER PRODUCTS,"1,114.9","1,069.2",33.8,3.07%,59.2,17,-30.5,-3.3,-30.4,-2.8,117.7,10.5 -SBI Cards and Payment Services Ltd.,SBICARD,543066,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"4,221.4","2,018.8","1,327",32.47%,46.8,604.9,809.4,206.4,603,6.4,"2,302.2",24.3 -Hitachi Energy India Ltd.,POWERINDIA,543187,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"1,228.2","1,162.6",65.3,5.32%,22.5,10.7,32.4,7.6,24.7,5.8,82.5,19.5 -Suven Pharmaceuticals Ltd.,SUVENPHAR,543064,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,250.9,133.1,98,42.40%,11.9,0.5,105.4,25.8,79.6,3.1,431.8,17 -Tata Chemicals Ltd.,TATACHEM,500770,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"4,083","3,179",819,20.49%,234,145,627,120,428,16.8,"2,06",80.8 -Aarti Drugs Ltd.,AARTIDRUGS,524348,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,642.2,565.1,76.4,11.92%,12.6,8.2,56.3,16.7,39.6,4.3,180.2,19.6 -Gujarat Ambuja Exports Ltd.,GAEL,524226,FMCG,EDIBLE OILS,"1,157.7","1,012.2",103.3,9.26%,30.5,5.9,109.1,26.3,82.8,3.6,305.1,13.3 -Polyplex Corporation Ltd.,POLYPLEX,524051,COMMERCIAL SERVICES & SUPPLIES,CONTAINERS & PACKAGING,"1,595.7","1,451.5",120.6,7.67%,75.1,9.9,59.1,10.9,27.9,8.9,71.1,22.6 -Chalet Hotels Ltd.,CHALET,542399,HOTELS RESTAURANTS & TOURISM,HOTELS,318.2,188.6,126,40.04%,35,50.1,44.5,8,36.4,1.8,266.7,13 -Adani Enterprises Ltd.,ADANIENT,512599,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,"23,066","20,087.2","2,430.1",10.79%,757,"1,342.8",791,397.8,227.8,2,"2,444.3",21.4 -YES Bank Ltd.,YESBANK,532648,BANKING AND FINANCE,BANKS,"7,980.6","2,377.1",810,12.06%,0,"4,793.6",304.4,75.7,228.6,0.1,836.6,0.3 -EPL Ltd.,EPL,500135,COMMERCIAL SERVICES & SUPPLIES,CONTAINERS & PACKAGING,"1,011.2",820.6,181,18.07%,83.6,30.6,76.4,25.4,50.5,1.6,251.9,7.9 -Network18 Media & Investments Ltd.,NETWORK18,532798,MEDIA,BROADCASTING & CABLE TV,"2,052.2","2,083.8",-218.3,-11.70%,56.8,66.2,-154.5,-6.5,-61,-0.6,-144.2,-1.4 -CIE Automotive India Ltd.,CIEINDIA,532756,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,299.4","1,934",345.4,15.15%,78.3,31,256.1,69.1,375.4,9.9,298.4,7.9 -Vedanta Ltd.,VEDL,500295,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"39,585","27,466","11,479",29.47%,"2,642","2,523","8,177","9,092","-1,783",-4.8,"5,202",14 -Rossari Biotech Ltd.,ROSSARI,543213,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,484.8,419.9,63.6,13.15%,15.1,5,44.8,11.9,32.9,6,116.8,21.2 -KPIT Technologies Ltd.,KPITTECH,542651,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,208.6",959.2,239.9,20.01%,48.1,13.6,187.7,46.3,140.9,5.2,486.9,18 -Intellect Design Arena Ltd.,INTELLECT,538835,SOFTWARE & SERVICES,IT SOFTWARE PRODUCTS,631.7,497.2,121.9,19.69%,33.7,0.8,96.5,25.7,70.4,5.2,316.6,23.2 -Balaji Amines Ltd.,BALAMINES,530999,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,387.3,326.8,53.8,14.13%,10.8,1.8,48,11.6,34.7,10.7,197.3,60.9 -UTI Asset Management Company Ltd.,UTIAMC,543238,BANKING AND FINANCE,ASSET MANAGEMENT COS.,405.6,172.5,231.5,57.30%,10.4,2.8,219.8,37,182.8,14.4,562.9,44.3 -Mazagon Dock Shipbuilders Ltd.,MAZDOCK,543237,TRANSPORTATION,SHIPPING,"2,079.2","1,651.1",176.6,9.66%,20.2,1.3,406.6,102.8,332.9,16.5,"1,327.6",65.8 -Computer Age Management Services Ltd.,CAMS,543232,BANKING AND FINANCE,CAPITAL MARKETS,284.7,153,122.1,44.39%,17.4,2,112.4,28.6,84.5,17.2,309.2,62.9 -Happiest Minds Technologies Ltd.,HAPPSTMNDS,543227,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,428.8,324,82.6,20.32%,14.6,11.2,79.1,20.7,58.5,3.9,232,15.6 -Triveni Turbine Ltd.,TRITURBINE,533655,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,402.3,313.4,74.3,19.17%,5.1,0.6,83.2,19,64.2,2,233.1,7.3 -Angel One Ltd.,ANGELONE,ASM,BANKING AND FINANCE,CAPITAL MARKETS,"1,049.3",602.6,443.4,42.31%,11.2,26.4,407.2,102.7,304.5,36.3,"1,020.2",121.7 -Tanla Platforms Ltd.,TANLA,532790,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,014.9",811.8,196.8,19.51%,22.6,1.8,178.7,36.2,142.5,10.6,514.7,38.3 -Max Healthcare Institute Ltd.,MAXHEALTH,543220,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,408.6",975.8,387.4,28.42%,57.9,8.5,366.4,89.7,276.7,2.9,990.1,10.2 -Asahi India Glass Ltd.,ASAHIINDIA,515030,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,122.6",934,185.6,16.58%,43,34.4,111.3,30.2,86.9,3.6,343.5,14.1 -Prince Pipes & Fittings Ltd.,PRINCEPIPE,542907,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,660.4,562.3,94.2,14.35%,22.5,0.7,92.8,22.2,70.6,5.2,219.8,19.9 -Route Mobile Ltd.,ROUTE,543228,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,018.3",886.5,128.1,12.63%,21.4,6.5,103.8,15.5,88.8,14.2,365.3,58.3 -KPR Mill Ltd.,KPRMILL,532889,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,533","1,212.9",298,19.72%,46,18.1,256,54.2,201.8,5.9,788.8,23.1 -Infibeam Avenues Ltd.,INFIBEAM,539807,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,792.6,719.7,70.2,8.89%,17.1,0.5,55.2,14.7,41,0.1,142.2,0.5 -Restaurant Brands Asia Ltd.,RBA,543248,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,628.2,568.7,56.2,9.00%,78.6,31.5,-50.7,0,-46,-0.9,-220.3,-4.5 -Larsen & Toubro Ltd.,LT,500510,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"52,157","45,392.1","5,632",11.04%,909.9,864,"4,991.1","1,135.5","3,222.6",22.9,"12,255.3",89.2 -Gland Pharma Ltd.,GLAND,543245,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,426.6","1,049.3",324.1,23.60%,81.3,6,289.9,95.8,194.1,11.8,698.8,42.4 -Macrotech Developers Ltd.,LODHA,543287,REALTY,REALTY,"1,755.1","1,333.5",416.1,23.78%,29.3,123.1,269.2,62.4,201.9,2.1,"1,529.2",15.9 -Poonawalla Fincorp Ltd.,POONAWALLA,524000,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),745.3,178.9,531.7,71.98%,14.7,215.5,"1,124.6",270,860.2,11.2,"1,466.4",19.1 -The Fertilisers and Chemicals Travancore Ltd.,FACT,590024,FERTILIZERS,FERTILIZERS,"1,713.6","1,530.8",132.4,7.96%,5.3,61.2,105.2,0,105.2,1.6,508.4,7.9 -Home First Finance Company India Ltd.,HOMEFIRST,543259,BANKING AND FINANCE,HOUSING FINANCE,278,53.7,211.6,77.43%,2.8,117,96.4,22.1,74.3,8.4,266.2,30.2 -CG Power and Industrial Solutions Ltd.,CGPOWER,500093,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,019","1,692.9",308.6,15.42%,22.9,0.4,329.9,86.2,242.3,1.6,"1,1",7.2 -Laxmi Organic Industries Ltd.,LXCHEM,543277,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,660.5,613.3,38.9,5.97%,27.5,2.1,17.5,6.8,10.7,0.4,100.6,3.8 -Anupam Rasayan India Ltd.,ANURAS,543275,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,395.6,284.7,107.5,27.41%,19.8,20.4,70.7,22,40.7,3.8,178.9,16.6 -Kalyan Jewellers India Ltd.,KALYANKJIL,ASM,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"4,427.7","4,100.9",313.7,7.11%,66.9,81.7,178.1,43.3,135.2,1.3,497.9,4.8 -Jubilant Pharmova Ltd.,JUBLPHARMA,530019,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,690.2","1,438.5",241.8,14.39%,96.6,66.1,89,35.9,62.5,3.9,-44.6,-2.8 -Indigo Paints Ltd.,INDIGOPNTS,543258,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,273.4,228.7,41.8,15.45%,10,0.5,34.3,8.2,26.1,5.5,132.4,27.8 -Indian Railway Finance Corporation Ltd.,IRFC,543257,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"6,767.5",33.5,"6,732.4",99.50%,2.1,"5,181.5","1,549.9",0,"1,549.9",1.2,"6,067.6",4.6 -Mastek Ltd.,MASTEK,523704,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,770.4,642.5,123,16.07%,20.9,12.6,90.3,25,62.8,20.5,269.7,88 -Equitas Small Finance Bank Ltd.,EQUITASBNK,543243,BANKING AND FINANCE,BANKS,"1,540.4",616.8,330.2,24.30%,0,593.4,267,68.9,198.1,1.8,749.5,6.7 -Tata Teleservices (Maharashtra) Ltd.,TTML,532371,TELECOM SERVICES,TELECOM SERVICES,288.6,159.3,127.5,44.45%,36.3,403.2,-310.2,0,-310.2,-1.6,"-1,168.3",-6 -Praj Industries Ltd.,PRAJIND,522205,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,893.3,798.4,84,9.52%,9.1,1,84.8,22.4,62.4,3.4,271.4,14.8 -Nazara Technologies Ltd.,NAZARA,543280,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,309.5,269.4,26.7,8.98%,15.1,2.7,21.2,-1.3,19.8,3,60,9.1 -Jubilant Ingrevia Ltd.,JUBLINGREA,543271,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,028.5",902.3,117.7,11.54%,33.9,12.5,79.8,22.4,57.5,3.6,258.9,16.4 -Sona BLW Precision Forgings Ltd.,SONACOMS,543300,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,796.9,567.5,223.3,28.24%,53.4,6,164.1,40.1,123.8,2.1,462.8,7.9 -Chemplast Sanmar Ltd.,CHEMPLASTS,543336,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,025",941.8,46,4.65%,35.3,38.6,9.2,-16.8,26.1,1.6,35.3,2.2 -Aptus Value Housing Finance India Ltd.,APTUS,543335,BANKING AND FINANCE,HOUSING FINANCE,344.5,50.6,277.5,83.18%,2.6,96.1,189.6,41.5,148,3,551.1,11.1 -Clean Science & Technology Ltd.,CLEAN,543318,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,187.1,106.3,74.8,41.32%,11.1,0.3,69.5,17.3,52.2,4.9,275.5,25.9 -Medplus Health Services Ltd.,MEDPLUS,543427,HEALTHCARE EQUIPMENT & SUPPLIES,HEALTHCARE SUPPLIES,"1,419","1,323.5",85.1,6.04%,55.5,23.5,16.4,1.9,14.6,1.2,58.3,4.9 -Nuvoco Vistas Corporation Ltd.,NUVOCO,543334,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,578.9","2,243",329.9,12.82%,225.6,139.9,-29.6,-31.1,1.5,0,141.8,4 -Star Health and Allied Insurance Company Ltd.,STARHEALTH,543412,BANKING AND FINANCE,GENERAL INSURANCE,"3,463.2","3,295.8",165.7,4.79%,0,0,167.1,41.8,125.3,2.1,725.4,12.4 -Go Fashion (India) Ltd.,GOCOLORS,543401,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,192.8,132.2,56.6,29.98%,25.8,8.9,25.8,5.7,20,3.7,85.4,15.8 -PB Fintech Ltd.,POLICYBZR,543390,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,909.1,900.7,-89.1,-10.98%,22.3,7.2,-21.1,-0.3,-20.2,-0.5,-127.9,-2.8 -FSN E-Commerce Ventures Ltd.,NYKAA,543384,SOFTWARE & SERVICES,INTERNET & CATALOGUE RETAIL,"1,515.6","1,426.4",80.6,5.35%,54.6,21.3,13.3,4,5.8,0,19.8,0.1 -Krishna Institute of Medical Sciences Ltd.,KIMS,543308,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,655.4,475.2,177.3,27.17%,32.6,8.9,138.6,37.3,92,11.5,342.1,42.7 -Zomato Ltd.,ZOMATO,543320,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"3,06","2,895",-47,-1.65%,128,16,21,-15,36,0,-496.8,-0.6 -Brightcom Group Ltd.,BCG,532368,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,690.5","1,172.3",518,30.65%,72.3,0.1,445.8,124.3,321.5,1.6,"1,415.2",7 -Shyam Metalics and Energy Ltd.,SHYAMMETL,543299,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"2,978.9","2,633.6",307.1,10.44%,176.5,35.4,133.4,-348.6,484.1,18.9,"1,049.9",41.2 -G R Infraprojects Ltd.,GRINFRA,543317,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,909.2","1,415.7",467.1,24.81%,61.7,144.6,287.1,69.9,217.2,22.5,"1,240.3",128.3 -RattanIndia Enterprises Ltd.,RTNINDIA,534597,UTILITIES,ELECTRIC UTILITIES,"1,618.1","1,392.8",1.5,0.11%,4.3,28.8,142.2,1.7,140.9,1,147.6,1.1 -Borosil Renewables Ltd.,BORORENEW,502219,CONSUMER DURABLES,HOUSEWARE,406.3,369.2,32.5,8.09%,31,9.6,28.9,-1.1,25.1,1.9,32.1,2.5 -HLE Glascoat Ltd.,HLEGLAS,522215,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,227.8,198,26.5,11.79%,6.1,5.8,16.1,5.3,10,1.6,54.4,8 -Tata Investment Corporation Ltd.,TATAINVEST,501301,DIVERSIFIED,HOLDING COMPANIES,125,10.1,113.8,91.88%,0.2,4.7,110.1,-1.3,124.4,24.6,326.1,64.4 -Sapphire Foods India Ltd.,SAPPHIRE,543397,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,650.1,527.5,115.1,17.91%,76.8,24.5,21.4,6.2,15.3,2.4,208.5,32.7 -Devyani International Ltd.,DEVYANI,543330,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,826,665,154.4,18.84%,86.3,41.7,19,-16.8,33.4,0.3,177.5,1.5 -Vijaya Diagnostic Centre Ltd.,VIJAYA,543350,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,145.6,81.5,57.4,41.31%,13.7,5.9,44.6,11,33.3,3.3,103.4,10.1 -C.E. Info Systems Ltd.,MAPMYINDIA,543425,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,99.3,50.1,41,44.98%,3.7,0.7,44.7,11.1,33,6.1,122.9,22.7 -Latent View Analytics Ltd.,LATENTVIEW,543398,SOFTWARE & SERVICES,DATA PROCESSING SERVICES,172.7,124.9,30.8,19.78%,2.3,0.8,44.7,10.6,34,1.7,153.6,7.5 -Metro Brands Ltd.,METROBRAND,543426,RETAILING,FOOTWEAR,571.9,400.3,155.4,27.96%,57.2,19.7,94.7,27.5,66.7,2.5,340,12.5 -Easy Trip Planners Ltd.,EASEMYTRIP,543272,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,144.6,76.9,64.8,45.71%,1,2,64.7,17.7,47.2,0.3,146,0.8 -Shree Renuka Sugars Ltd.,RENUKA,532670,FOOD BEVERAGES & TOBACCO,SUGAR,"2,564.7","2,491",63.7,2.49%,64.1,216.8,-207.2,-1.6,-204.9,-1,-286,-1.3 -One97 Communications Ltd.,PAYTM,543396,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"2,662.5","2,749.6",-231,-9.17%,180.1,7,-279.9,12.7,-290.5,-5,"-1,207.9",-19 -MTAR Technologies Ltd.,MTARTECH,543270,GENERAL INDUSTRIALS,DEFENCE,167.7,130.7,36.1,21.64%,5.8,5.5,25.7,5.2,20.5,6.7,103.3,33.6 -Capri Global Capital Ltd.,CGCL,531595,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),557.4,229.3,304.8,54.70%,23.1,195.8,86,20.8,65.2,3.2,231.2,11.2 -GMR Airports Infrastructure Ltd.,GMRINFRA,ASM,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"2,185","1,336.8",726.7,35.22%,373,695.8,-252,54.9,-91,-0.1,-370.9,-0.6 -Triveni Engineering & Industries Ltd.,TRIVENI,532356,FOOD BEVERAGES & TOBACCO,SUGAR,"1,629.7","1,554.5",62.9,3.89%,25.8,10.2,39.3,10.1,29.1,1.3,434.3,19.8 -Delhivery Ltd.,DELHIVERY,543529,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"2,043","1,957.3",-15.6,-0.80%,171.2,19.6,-105.2,-2.1,-102.9,-1.4,-546.7,-7.5 -Life Insurance Corporation of India,LICI,543526,BANKING AND FINANCE,LIFE INSURANCE,"202,394.9","193,612.5","8,445",4.18%,0,0,"8,696.5","1,083.9","8,030.3",12.7,"37,204.8",58.8 -Campus Activewear Ltd.,CAMPUS,543523,RETAILING,FOOTWEAR,259.1,234.2,24.5,9.46%,18.1,6.5,0.4,0.1,0.3,0,103.1,3.4 -Motherson Sumi Wiring India Ltd.,MSUMI,543498,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,110.2","1,856.5",248.1,11.79%,36.4,7.4,210,54.1,155.9,0.3,523.6,1.2 -Olectra Greentech Ltd.,OLECTRA,532439,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,310.3,266.6,40.5,13.20%,8.8,9.7,25.2,8,18.6,2.2,78.5,9.6 -Patanjali Foods Ltd.,PATANJALI,500368,FMCG,EDIBLE OILS,"7,845.8","7,426.6",395.3,5.05%,60.1,24,335.1,80.5,254.5,7,875.2,24.2 -Raymond Ltd.,RAYMOND,500330,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,320.7","1,938.8",314.6,13.96%,65.4,89.3,204.2,50.7,159.8,24,"1,514.2",227.5 -Swan Energy Ltd.,SWANENERGY,503310,REALTY,REALTY,"1,230.1",966.3,257,21.01%,27.1,58.3,178.4,12.8,84.6,6.7,308.4,11.7 -Samvardhana Motherson International Ltd.,MOTHERSON,517334,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"23,639.2","21,585","1,888.8",8.05%,867.4,487.9,449.5,229.2,201.6,0.3,"1,910.3",2.8 -Vedant Fashions Ltd.,MANYAVAR,543463,RETAILING,SPECIALTY RETAIL,233.4,125.5,92.8,42.51%,32.5,10.7,64.8,16.1,48.7,2,399.9,16.5 -Adani Wilmar Ltd.,AWL,543458,FMCG,EDIBLE OILS,"12,331.2","12,123.5",143.7,1.17%,95.7,220.2,-161.8,-31.5,-130.7,-1,130.1,1 -Mahindra Lifespace Developers Ltd.,MAHLIFE,532313,REALTY,REALTY,25.7,52.7,-34.9,-196.45%,3.1,0.2,-30.3,-10.8,-18.9,-1.2,10.5,0.7 -Tejas Networks Ltd.,TEJASNET,540595,TELECOM SERVICES,OTHER TELECOM SERVICES,413.9,383,13,3.28%,41.7,7,-17.7,-5.1,-12.6,-0.7,-61.3,-3.5 -Aether Industries Ltd.,AETHER,543534,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,178.3,118.2,46,28.00%,9.7,1.6,48.7,12.1,36.7,2.8,139.1,10.5 -JBM Auto Ltd.,JBMA,ASM,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,238.8","1,091.3",139.7,11.35%,41.2,47.9,58.3,11.3,44.2,3.7,136.8,11.6 -Deepak Fertilisers & Petrochemicals Corporation Ltd.,DEEPAKFERT,500645,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"2,443.2","2,138.1",286.1,11.80%,81.2,107.1,116.8,53.3,60.1,4.8,674.5,53.4 -Sharda Cropchem Ltd.,SHARDACROP,538666,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,604.3,559.6,21.2,3.65%,74,4.6,-33.8,-6.3,-27.6,-3.1,191,21.2 -Shoppers Stop Ltd.,SHOPERSTOP,532638,RETAILING,DEPARTMENT STORES,"1,049.7",878.2,160.9,15.49%,108.2,54.9,3.5,0.8,2.7,0.2,94.2,8.6 -BEML Ltd.,BEML,500048,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,924,855.3,61.5,6.70%,15.8,10.8,42.2,-9.6,51.8,12.4,200.8,48.2 -Lemon Tree Hotels Ltd.,LEMONTREE,541233,HOTELS RESTAURANTS & TOURISM,HOTELS,230.1,125.3,101.9,44.84%,22.6,47.3,34.8,8.6,22.6,0.3,130.1,1.6 -Rainbow Childrens Medicare Ltd.,RAINBOW,543524,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,340.5,215.1,117.6,35.34%,26.8,13.3,85.2,22.1,62.9,6.2,215.4,21.2 -UCO Bank,UCOBANK,532505,BANKING AND FINANCE,BANKS,"5,865.6","1,581.5",981.9,18.81%,0,"3,302.3",639.8,238.1,403.5,0.3,"1,84",1.5 -Piramal Pharma Ltd.,PPLPHARMA,543635,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,960.6","1,645.7",265.6,13.90%,184.5,109.9,20.4,34.5,5,0,-133.6,-1 -KSB Ltd.,KSB,500249,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,572.2,493.4,70.3,12.47%,12.3,2,64.5,17.1,50.1,14.4,209.7,60.3 -Data Patterns (India) Ltd.,DATAPATTNS,543428,GENERAL INDUSTRIALS,DEFENCE,119.2,67.5,40.8,37.63%,3.1,2.3,46.3,12.5,33.8,6,148.3,26.5 -Global Health Ltd.,MEDANTA,543654,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,864.7,631.1,212.9,25.22%,42.9,20.1,170.6,45.4,125.2,4.7,408.9,15.2 -Aarti Industries Ltd.,AARTIIND,524208,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,454","1,221.2",232.8,16.01%,93,58.2,81.6,-9.1,90.7,2.5,446.2,12.3 -BLS International Services Ltd.,BLS,540073,DIVERSIFIED CONSUMER SERVICES,TRAVEL SUPPORT SERVICES,416.4,321,86.7,21.27%,7.3,1,87.2,5.2,78.7,1.9,267.6,6.5 -Archean Chemical Industries Ltd.,ACI,543657,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,301.7,195,95.5,32.86%,17.5,1.9,87.3,21.3,66,5.4,394.4,32.1 -Adani Power Ltd.,ADANIPOWER,ASM,UTILITIES,ELECTRIC UTILITIES,"14,935.7","7,819.2","5,171.4",39.81%,"1,004.5",888.4,"5,223.6","-1,370.6","6,594.2",16.5,"20,604.8",53.4 -Craftsman Automation Ltd.,CRAFTSMAN,543276,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,183.8",941.6,237.5,20.14%,66.8,41.6,133.8,29.6,94.5,44.1,298.3,141.2 -NMDC Ltd.,NMDC,526371,METALS & MINING,MINING,"4,335","2,823.6","1,190.4",29.66%,88.8,18.6,"1,404.1",379,"1,026.2",3.5,"5,862.2",20 -Epigral Ltd.,EPIGRAL,543332,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,479.1,370.2,107.9,22.57%,31.5,21.3,56.1,17.9,38,9.1,223.4,53.8 -Apar Industries Ltd.,APARINDS,532259,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"3,944.7","3,576.2",349.8,8.91%,28.2,103.1,237.3,62.9,173.9,45.4,783.9,204.8 -Bikaji Foods International Ltd.,BIKAJI,543653,FMCG,PACKAGED FOODS,614.7,521,87.7,14.41%,15.6,2.9,75.2,15.4,61.2,2.5,173.6,6.9 -Five-Star Business Finance Ltd.,FIVESTAR,543663,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),522.4,133.2,375,72.28%,5.7,105.9,267,67.6,199.4,6.8,703,24.1 -Ingersoll-Rand (India) Ltd.,INGERRAND,500210,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,282.8,210.7,65.7,23.76%,4.6,0.6,67,17.2,49.7,15.8,218.5,69.2 -KFIN Technologies Ltd.,KFINTECH,543720,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,215.3,115.3,93.7,44.82%,12.6,3.2,84.2,22.3,61.4,3.6,215.1,12.6 -Piramal Enterprises Ltd.,PEL,500302,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"2,205.2","1,320.1","1,117.9",50.97%,38.3,"1,038.9",-11.8,10.7,48.2,2,"3,906.5",173.9 -NMDC Steel Ltd.,NSLNISP,543768,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,290.3,349.6,-72.2,-26.04%,74.5,40.8,-174.7,-43.6,-131.1,-0.5,, -Eris Lifesciences Ltd.,ERIS,540596,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,508.8,324.2,181.1,35.85%,42.1,16.3,126.2,3.9,123.4,9.1,385.6,28.3 -Mankind Pharma Ltd.,MANKIND,543904,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,768.1","2,025.5",682.6,25.21%,96.5,8.6,637.5,129.8,501,12.5,"1,564.8",39.1 -Kaynes Technology India Ltd.,KAYNES,ASM,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,369.8,312.1,48.8,13.52%,6.5,11.8,39.4,7.1,32.3,5.5,143.2,24.6 -Safari Industries (India) Ltd.,SAFARI,523025,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,372.9,306.6,63.5,17.15%,12.2,2.2,51.9,12.1,39.8,16.7,162.3,68.2 -Saregama India Ltd.,SAREGAMA,532163,MEDIA,MOVIES & ENTERTAINMENT,185.6,111.5,60.9,35.32%,8.2,0.2,65.6,17.6,48.1,2.5,193.4,10 -Syrma SGS Technology Ltd.,SYRMA,543573,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,720.6,662.7,49,6.88%,11.6,8,37,6.4,28.3,1.6,132.4,7.5 -Jindal Saw Ltd.,JINDALSAW,ASM,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"5,488.9","4,662",804.2,14.71%,142.5,188.7,495.6,139.6,375.7,11.8,"1,135.8",35.5 -Godawari Power & Ispat Ltd.,GPIL,532734,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"1,314.2",929.6,361.4,28.00%,34.8,10.2,339.6,86.1,256.9,20.6,785.5,63 -Gillette India Ltd.,GILLETTE,507815,FMCG,PERSONAL PRODUCTS,676.2,530.8,136.7,20.48%,20.1,0.1,125.2,32.5,92.7,28.4,361.6,111 -Symphony Ltd.,SYMPHONY,517385,CONSUMER DURABLES,CONSUMER ELECTRONICS,286,234,41,14.91%,7,2,43,8,35,5.1,114,16.5 -Glenmark Life Sciences Ltd.,GLS,543322,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,600.7,428.3,167.1,28.06%,13.1,0.4,158.9,40.2,118.7,9.7,505.5,41.3 -Usha Martin Ltd.,USHAMART,517146,METALS & MINING,IRON & STEEL PRODUCTS,806,640.4,144.3,18.39%,18,6.4,141.2,35,109.5,3.6,399.4,13.1 -Ircon International Ltd.,IRCON,541956,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"3,136.3","2,771.2",215.7,7.22%,27.1,36.9,301.2,77.6,250.7,2.7,884.6,9.4 -Ujjivan Small Finance Bank Ltd.,UJJIVANSFB,542904,BANKING AND FINANCE,BANKS,"1,579.8",528.6,483.4,34.75%,0,567.8,436.4,108.7,327.7,1.7,"1,254.5",6.4 -Procter & Gamble Health Ltd.,PGHL,500126,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,311,216.3,88.7,29.08%,6.5,0.2,88,22.5,65.6,39.5,231.4,139.4 -Allcargo Logistics Ltd.,ALLCARGO,532749,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"3,336.3","3,188.8",118,3.57%,106.7,36.7,14.2,1.3,21.8,0.9,361.9,14.7 -Sheela Foam Ltd.,SFL,540203,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,637.6,547,66.2,10.80%,21.9,8.6,60.2,15.6,44,4.5,192.4,17.7 -Alok Industries Ltd.,ALOKINDS,521070,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,369.3","1,323.1",35.9,2.64%,78.6,142.2,-174.6,0,-174.8,-0.3,-948.4,-1.9 -Minda Corporation Ltd.,MINDACORP,538962,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,197.9","1,064.5",131.3,10.98%,41.4,14.9,77,18.7,58.8,2.5,278.2,11.6 -Concord Biotech Ltd.,CONCORDBIO,543960,PHARMACEUTICALS & BIOTECHNOLOGY,BIOTECHNOLOGY,270.5,143.2,119.2,45.43%,13.3,0.8,113.2,28.7,81,7.7,, \ No newline at end of file diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/sampleFileForUpload.txt b/sdk/ai/ai-projects/samples/v1-beta/javascript/data/sampleFileForUpload.txt deleted file mode 100644 index ab553b3304c1..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/sampleFileForUpload.txt +++ /dev/null @@ -1 +0,0 @@ -The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457. diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/weatherOpenApi.json b/sdk/ai/ai-projects/samples/v1-beta/javascript/data/weatherOpenApi.json deleted file mode 100644 index df0192590adb..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/data/weatherOpenApi.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "openapi": "3.1.0", - "info": { - "title": "get weather data", - "description": "Retrieves current weather data for a location based on wttr.in.", - "version": "v1.0.0" - }, - "servers": [ - { - "url": "https://wttr.in" - } - ], - "auth": [], - "paths": { - "/{location}": { - "get": { - "description": "Get weather information for a specific location", - "operationId": "GetCurrentWeather", - "parameters": [ - { - "name": "location", - "in": "path", - "description": "City or location to retrieve the weather for", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "format", - "in": "query", - "description": "Always use j1 value for this parameter", - "required": true, - "schema": { - "type": "string", - "default": "j1" - } - } - ], - "responses": { - "200": { - "description": "Successful response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "Location not found" - } - }, - "deprecated": false - } - } - }, - "components": { - "schemes": {} - } -} \ No newline at end of file diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/package.json b/sdk/ai/ai-projects/samples/v1-beta/javascript/package.json deleted file mode 100644 index 6c0a2d70f61a..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "@azure-samples/ai-projects-js-beta", - "private": true, - "version": "1.0.0", - "description": "Azure AI Projects client library samples for JavaScript (Beta)", - "engines": { - "node": ">=18.0.0" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git", - "directory": "sdk/ai/ai-projects" - }, - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects", - "dependencies": { - "@azure/ai-projects": "next", - "dotenv": "latest", - "@azure/monitor-opentelemetry-exporter": "^1.0.0-beta.31", - "@azure/opentelemetry-instrumentation-azure-sdk": "^1.0.0-beta.7", - "@opentelemetry/api": "^1.9.0", - "@opentelemetry/instrumentation": "0.57.0", - "@opentelemetry/sdk-trace-node": "^1.30.0", - "@azure/core-util": "^1.9.0", - "@azure/identity": "^4.3.0" - } -} diff --git a/sdk/ai/ai-projects/samples/v1-beta/javascript/sample.env b/sdk/ai/ai-projects/samples/v1-beta/javascript/sample.env deleted file mode 100644 index 0d9bbe518d6f..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/javascript/sample.env +++ /dev/null @@ -1,3 +0,0 @@ -AZURE_AI_PROJECTS_CONNECTION_STRING="" - -APPLICATIONINSIGHTS_CONNECTION_STRING="" diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/README.md b/sdk/ai/ai-projects/samples/v1-beta/typescript/README.md deleted file mode 100644 index 4505a6483e23..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/README.md +++ /dev/null @@ -1,136 +0,0 @@ ---- -page_type: sample -languages: - - typescript -products: - - azure -urlFragment: ai-projects-typescript-beta ---- - -# Azure AI Projects client library samples for TypeScript (Beta) - -These sample programs show how to use the TypeScript client libraries for Azure AI Projects in some common scenarios. - -| **File Name** | **Description** | -| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| [agents/codeInterpreterWithStreaming.ts][agents_codeinterpreterwithstreaming] | demonstrates how to use agent operations with code interpreter. | -| [agents/agentCreateWithTracingConsole.ts][agents_agentcreatewithtracingconsole] | Create Agent and instrument using open telemetry. | -| [agents/agentTokenUsage.ts][agents_agenttokenusage] | demonstrates how to track the token usage of an Agent. | -| [agents/agentsAzureAiSearch.ts][agents_agentsazureaisearch] | demonstrates how to use agent operations with the Azure AI Search tool. | -| [agents/agentsAzureFunctions.ts][agents_agentsazurefunctions] | demonstrates how to use azure function agent operations from the Azure Agents service | -| [agents/agentsBasics.ts][agents_agentsbasics] | demonstrates how to use basic agent operations. | -| [agents/agentsBingCustomSearch.ts][agents_agentsbingcustomsearch] | demonstrates how to use agent operations with the Bing Customer Search tool. | -| [agents/agentsBingGrounding.ts][agents_agentsbinggrounding] | demonstrates how to use agent operations with the Grounding with Bing Search tool. | -| [agents/agentsBingGroundingWithStreaming.ts][agents_agentsbinggroundingwithstreaming] | demonstrates how to use agent operations with the Grounding with Bing Search tool using streaming. | -| [agents/agentsFabric.ts][agents_agentsfabric] | demonstrates how to use agent operations with the Microsoft Fabric tool. | -| [agents/agentsImageInputWithBase64.ts][agents_agentsimageinputwithbase64] | This sample demonstrates how to use basic agent operations with image input (base64 encoded) for the Azure Agents service. | -| [agents/agentsImageInputWithFile.ts][agents_agentsimageinputwithfile] | This sample demonstrates how to use basic agent operations using image file input for the Azure Agents service. | -| [agents/agentsImageInputWithUrl.ts][agents_agentsimageinputwithurl] | This sample demonstrates how to use basic agent operations using image url input for the Azure Agents service. | -| [agents/agentsSharepoint.ts][agents_agentssharepoint] | demonstrates how to use agent operations with the Sharepoint tool. | -| [agents/agentsWithFunctionTool.ts][agents_agentswithfunctiontool] | demonstrates how to use basic agent operations using function tool. | -| [agents/agentsWithOpenApi.ts][agents_agentswithopenapi] | demonstrates how to use agent operations with an OpenApi tool. | -| [agents/agentsWithToolset.ts][agents_agentswithtoolset] | demonstrates how to use agent operations with toolset. | -| [agents/batchVectorStoreWithFiles.ts][agents_batchvectorstorewithfiles] | demonstrates how to create the batch vector store with the list of files. | -| [agents/batchVectorStoreWithFilesAndPolling.ts][agents_batchvectorstorewithfilesandpolling] | demonstrates how to create the batch vector store with the list of files using polling operation. | -| [agents/codeInterpreter.ts][agents_codeinterpreter] | demonstrates how to use agent operations with code interpreter. | -| [agents/fileSearch.ts][agents_filesearch] | This sample demonstrates how to use agent operations with file searching. | -| [agents/files.ts][agents_files] | demonstrates how to use basic files agent operations. | -| [agents/filesWithLocalUpload.ts][agents_fileswithlocalupload] | demonstrates how to use basic files agent operations with local file upload. | -| [agents/filesWithPolling.ts][agents_fileswithpolling] | demonstrates how to upload a file and poll for its status. | -| [agents/messages.ts][agents_messages] | demonstrates how to use basic message agent operations. | -| [agents/runSteps.ts][agents_runsteps] | demonstrates how to use basic run agent operations. | -| [agents/streaming.ts][agents_streaming] | demonstrates how to use agent operations in streaming. | -| [agents/threads.ts][agents_threads] | demonstrates how to use basic thread agent operations. | -| [agents/vectorStoreWithFiles.ts][agents_vectorstorewithfiles] | demonstrates how to create the vector store with the list of files. | -| [agents/vectorStoreWithFilesAndPolling.ts][agents_vectorstorewithfilesandpolling] | demonstrates how to create the vector store with the list of files using polling operation. | -| [agents/vectorStores.ts][agents_vectorstores] | demonstrates how to create the vector store. | -| [agents/vectorStoresWithPolling.ts][agents_vectorstoreswithpolling] | demonstrates how to create the vector store using polling operation. | -| [connections/connectionsBasics.ts][connections_connectionsbasics] | Given an AIProjectClient, this sample demonstrates how to enumerate the properties of all connections, get the properties of a default connection, and get the properties of a connection by its name. | - -## Prerequisites - -The sample programs are compatible with [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule). - -Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: - -```bash -npm install -g typescript -``` - -You need [an Azure subscription][freesub] to run these sample programs. - -Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. - -Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. - -## Setup - -To run the samples using the published version of the package: - -1. Install the dependencies using `npm`: - -```bash -npm install -``` - -2. Compile the samples: - -```bash -npm run build -``` - -3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. - -4. Run whichever samples you like (note that some samples may require additional setup, see the table above): - -```bash -node dist/agents\codeInterpreterWithStreaming.js -``` - -Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): - -```bash -npx dev-tool run vendored cross-env AZURE_AI_PROJECTS_CONNECTION_STRING="" MODEL_DEPLOYMENT_NAME="" node dist/agents\codeInterpreterWithStreaming.js -``` - -## Next Steps - -Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. - -[agents_codeinterpreterwithstreaming]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreterWithStreaming.ts -[agents_agentcreatewithtracingconsole]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentCreateWithTracingConsole.ts -[agents_agenttokenusage]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentTokenUsage.ts -[agents_agentsazureaisearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureAiSearch.ts -[agents_agentsazurefunctions]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureFunctions.ts -[agents_agentsbasics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBasics.ts -[agents_agentsbingcustomsearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingCustomSearch.ts -[agents_agentsbinggrounding]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGrounding.ts -[agents_agentsbinggroundingwithstreaming]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGroundingWithStreaming.ts -[agents_agentsfabric]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsFabric.ts -[agents_agentsimageinputwithbase64]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithBase64.ts -[agents_agentsimageinputwithfile]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithFile.ts -[agents_agentsimageinputwithurl]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithUrl.ts -[agents_agentssharepoint]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsSharepoint.ts -[agents_agentswithfunctiontool]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithFunctionTool.ts -[agents_agentswithopenapi]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithOpenApi.ts -[agents_agentswithtoolset]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithToolset.ts -[agents_batchvectorstorewithfiles]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFiles.ts -[agents_batchvectorstorewithfilesandpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFilesAndPolling.ts -[agents_codeinterpreter]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreter.ts -[agents_filesearch]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/fileSearch.ts -[agents_files]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/files.ts -[agents_fileswithlocalupload]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithLocalUpload.ts -[agents_fileswithpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithPolling.ts -[agents_messages]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/messages.ts -[agents_runsteps]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/runSteps.ts -[agents_streaming]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/streaming.ts -[agents_threads]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/threads.ts -[agents_vectorstorewithfiles]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFiles.ts -[agents_vectorstorewithfilesandpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFilesAndPolling.ts -[agents_vectorstores]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStores.ts -[agents_vectorstoreswithpolling]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoresWithPolling.ts -[connections_connectionsbasics]: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/ai/ai-projects/samples/v1-beta/typescript/src/connections/connectionsBasics.ts -[apiref]: https://learn.microsoft.com/javascript/api/@azure/ai-projects -[freesub]: https://azure.microsoft.com/free/ -[package]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects/README.md -[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/image_file.png b/sdk/ai/ai-projects/samples/v1-beta/typescript/data/image_file.png deleted file mode 100644 index 50ae6c65367a..000000000000 Binary files a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/image_file.png and /dev/null differ diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/localFile.txt b/sdk/ai/ai-projects/samples/v1-beta/typescript/data/localFile.txt deleted file mode 100644 index 8ab686eafeb1..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/localFile.txt +++ /dev/null @@ -1 +0,0 @@ -Hello, World! diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/nifty500QuarterlyResults.csv b/sdk/ai/ai-projects/samples/v1-beta/typescript/data/nifty500QuarterlyResults.csv deleted file mode 100644 index e02068e09042..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/nifty500QuarterlyResults.csv +++ /dev/null @@ -1,502 +0,0 @@ -name,NSE_code,BSE_code,sector,industry,revenue,operating_expenses,operating_profit,operating_profit_margin,depreciation,interest,profit_before_tax,tax,net_profit,EPS,profit_TTM,EPS_TTM -3M India Ltd.,3MINDIA,523395,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"1,057",847.4,192.1,18.48%,12.9,0.7,195.9,49.8,146.1,129.7,535.9,475.7 -ACC Ltd.,ACC,500410,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"4,644.8","3,885.4",549.3,12.39%,212.8,28.9,517.7,131.5,387.9,20.7,"1,202.7",64 -AIA Engineering Ltd.,AIAENG,532683,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,"1,357.1",912.7,382.1,29.51%,24.5,7.4,412.5,88.4,323.1,34.3,"1,216.1",128.9 -APL Apollo Tubes Ltd.,APLAPOLLO,533758,METALS & MINING,IRON & STEEL PRODUCTS,"4,65","4,305.4",325,7.02%,41.3,26.6,276.7,73.8,202.9,7.3,767.5,27.7 -Au Small Finance Bank Ltd.,AUBANK,540611,BANKING AND FINANCE,BANKS,"2,956.5","1,026.7",647.7,25.59%,0,"1,282.1",533.4,131.5,401.8,6,"1,606.2",24 -Adani Ports & Special Economic Zone Ltd.,ADANIPORTS,532921,TRANSPORTATION,MARINE PORT & SERVICES,"6,951.9","2,982.4","3,664",55.13%,974.5,520.1,"2,474.9",759,"1,747.8",8.1,"6,337",29.3 -Adani Energy Solutions Ltd.,ADANIENSOL,ASM,UTILITIES,ELECTRIC UTILITIES,"3,766.5","2,169.3","1,504.6",40.95%,432.1,640.8,369.9,84.9,275.9,2.5,"1,315.1",11.8 -Aditya Birla Fashion and Retail Ltd.,ABFRL,535755,RETAILING,DEPARTMENT STORES,"3,272.2","2,903.6",322.9,10.01%,388.8,208.4,-228.6,-28.2,-179.2,-1.9,-491.7,-5.2 -Aegis Logistics Ltd.,AEGISCHEM,500003,OIL & GAS,OIL MARKETING & DISTRIBUTION,"1,279.3","1,026.5",208.3,16.87%,34.1,26.6,192,42,127,3.6,509,14.5 -Ajanta Pharma Ltd.,AJANTPHARM,532331,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,049.8",737.8,290.7,28.26%,33.7,2.3,275.9,80.6,195.3,15.5,660.2,52.3 -Alembic Pharmaceuticals Ltd.,APLLTD,533573,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,605.1","1,386.7",208.2,13.06%,67.6,15.7,135.1,-1.9,136.6,7,531.7,27 -Alkem Laboratories Ltd.,ALKEM,539523,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"3,503.4","2,693.4",746.7,21.71%,73.9,30.3,648,33.1,620.5,51.9,"1,432.9",119.9 -Amara Raja Energy & Mobility Ltd.,ARE&M,500008,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,988.6","2,556.9",402.5,13.60%,115.7,6.2,309.8,83.5,226.3,13.2,779.8,45.7 -Ambuja Cements Ltd.,AMBUJACEM,500425,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"7,9","6,122.1","1,301.8",17.54%,380.9,61.2,"1,335.7",352.5,793,4,"2,777.9",14 -Apollo Hospitals Enterprise Ltd.,APOLLOHOSP,508869,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"4,869.1","4,219.4",627.5,12.95%,163.4,111.3,376.9,130.2,232.9,16.2,697.5,48.5 -Apollo Tyres Ltd.,APOLLOTYRE,500877,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"6,304.9","5,119.8","1,159.8",18.47%,360.3,132.8,679.9,205.8,474.3,7.5,"1,590.7",25 -Ashok Leyland Ltd.,ASHOKLEY,500477,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"11,463","9,558.6","1,870.4",16.37%,226.6,715.1,924.4,358,526,1.8,"2,141.5",7.3 -Asian Paints Ltd.,ASIANPAINT,500820,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"8,643.8","6,762.3","1,716.2",20.24%,208.7,50.9,"1,621.8",418.6,"1,205.4",12.6,"5,062.6",52.8 -Astral Ltd.,ASTRAL,532830,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,"1,376.4","1,142.9",220.1,16.15%,48.7,8,176.8,45.1,131.2,4.9,549.7,20.4 -Atul Ltd.,ATUL,500027,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,215.8","1,038.5",155.2,13.00%,54,1.9,121.5,32.5,90.3,30.6,392.3,132.9 -Aurobindo Pharma Ltd.,AUROPHARMA,524804,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"7,406.4","5,846","1,373.4",19.02%,417.5,68.2,"1,074.7",323.7,757.2,12.8,"2,325.5",39.7 -Avanti Feeds Ltd.,AVANTIFEED,512573,FOOD BEVERAGES & TOBACCO,OTHER FOOD PRODUCTS,"1,312","1,184.5",94,7.35%,14.3,0.2,113,30.5,74.2,5.5,336.4,24.7 -Avenue Supermarts Ltd.,DMART,540376,RETAILING,DEPARTMENT STORES,"12,661.3","11,619.4","1,005",7.96%,174.4,15.6,851.9,228.6,623.6,9.6,"2,332.1",35.8 -Axis Bank Ltd.,AXISBANK,532215,BANKING AND FINANCE,BANKS,"33,122.2","9,207.3","9,166",33.43%,0,"14,749","8,313.8","2,096.1","6,204.1",20.1,"13,121",42.6 -Bajaj Auto Ltd.,BAJAJ-AUTO,532977,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"11,206.8","8,708.1","2,130.1",19.65%,91.8,6.5,"2,400.4",564,"2,02",71.4,"6,841.6",241.8 -Bajaj Finance Ltd.,BAJFINANCE,500034,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"13,381.8","2,851.5","9,449.7",70.63%,158.5,"4,537.1","4,757.6","1,207","3,550.8",58.7,"13,118.5",216.7 -Bajaj Finserv Ltd.,BAJAJFINSV,532978,DIVERSIFIED,HOLDING COMPANIES,"26,022.7","14,992.2","9,949.9",38.24%,208.8,"4,449.1","5,292","1,536.5","1,929",12.1,"7,422.6",46.6 -Bajaj Holdings & Investment Ltd.,BAJAJHLDNG,500490,DIVERSIFIED,HOLDING COMPANIES,240.1,33.5,191.2,85.08%,8.4,0.2,197.9,73.9,"1,491.2",134,"5,545.1",498.3 -Balkrishna Industries Ltd.,BALKRISIND,502355,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"2,360.3","1,720.5",532.7,23.64%,160.4,23.9,455.5,108.1,347.4,18,"1,047.5",54.2 -Balrampur Chini Mills Ltd.,BALRAMCHIN,500038,FOOD BEVERAGES & TOBACCO,SUGAR,"1,649","1,374.6",164.9,10.71%,41.2,17.2,215.9,56.6,166.3,8.2,540.5,26.8 -Bank of Baroda,BANKBARODA,532134,BANKING AND FINANCE,BANKS,"35,766","8,430.4","9,807.9",33.52%,0,"17,527.7","6,022.8","1,679.7","4,458.4",8.5,"18,602.9",35.9 -Bank of India,BANKINDIA,532149,BANKING AND FINANCE,BANKS,"16,779.4","3,704.9","3,818.8",25.35%,0,"9,255.7","2,977.4","1,488.6","1,498.5",3.6,"5,388.7",13.1 -Bata India Ltd.,BATAINDIA,500043,RETAILING,FOOTWEAR,834.6,637.5,181.7,22.18%,81.7,28.4,46.1,12.1,34,2.6,289.7,22.5 -Berger Paints (India) Ltd.,BERGEPAINT,509480,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"2,782.6","2,293.7",473.6,17.12%,82.9,21.1,385,96.7,291.6,2.5,"1,032.6",8.9 -Bharat Electronics Ltd.,BEL,500049,GENERAL INDUSTRIALS,DEFENCE,"4,146.1","2,994.9","1,014.2",25.30%,108.3,1.5,"1,041.5",260.7,789.4,1.1,"3,323",4.5 -Bharat Forge Ltd.,BHARATFORG,500493,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"3,826.7","3,152.8",621.4,16.47%,211.3,124.3,336.1,121.8,227.2,4.9,783.7,16.8 -Bharat Heavy Electricals Ltd.,BHEL,500103,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"5,305.4","5,513",-387.7,-7.56%,59.9,180.4,-447.9,-197.9,-238.1,-0.7,71.3,0.2 -Bharat Petroleum Corporation Ltd.,BPCL,500547,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"103,72","90,103.9","12,940.5",12.56%,"1,605.3",973.2,"10,755.7","2,812.2","8,243.5",38.7,"27,505.3",129.2 -Bharti Airtel Ltd.,BHARTIARTL,532454,TELECOM SERVICES,TELECOM SERVICES,"37,374.2","17,530.1","19,513.7",52.68%,"9,734.3","5,185.8","3,353.7","1,846.5","1,340.7",2.4,"7,547",13.2 -Indus Towers Ltd.,INDUSTOWER,534816,TELECOM SERVICES,OTHER TELECOM SERVICES,"7,229.7","3,498.8","3,633.7",50.95%,"1,525.6",458.6,"1,746.7",452,"1,294.7",4.8,"3,333.5",12.4 -Biocon Ltd.,BIOCON,532523,PHARMACEUTICALS & BIOTECHNOLOGY,BIOTECHNOLOGY,"3,620.2","2,720.7",741.6,21.42%,389.3,247.7,238.5,41.6,125.6,1.1,498.4,4.2 -Birla Corporation Ltd.,BIRLACORPN,500335,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,313.2","1,997",288.9,12.64%,143.5,95.4,77.1,18.8,58.4,7.6,153.1,19.9 -Blue Dart Express Ltd.,BLUEDART,526612,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"1,329.7","1,101.8",222.7,16.82%,110.6,19.5,97.9,24.8,73.1,30.8,292.4,123.2 -Blue Star Ltd.,BLUESTARCO,500067,CONSUMER DURABLES,CONSUMER ELECTRONICS,"1,903.4","1,767.7",122.7,6.49%,23,17.6,95,24.3,70.7,3.6,437.7,21.3 -Bombay Burmah Trading Corporation Ltd.,BBTC,501425,FOOD BEVERAGES & TOBACCO,TEA & COFFEE,"4,643.5","3,664.7",859.2,18.99%,74.7,154.6,697.1,212.6,122,17.5,"-1,499.5",-214.8 -Bosch Ltd.,BOSCHLTD,500530,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"4,284.3","3,638.8",491.3,11.90%,101.3,12.2,"1,317",318.1,999.8,339,"2,126.9",721 -Brigade Enterprises Ltd.,BRIGADE,532929,REALTY,REALTY,"1,407.9","1,041.8",324.8,23.77%,75.7,110,180.3,67.8,133.5,5.8,298.2,12.9 -Britannia Industries Ltd.,BRITANNIA,500825,FMCG,PACKAGED FOODS,"4,485.2","3,560.5",872.4,19.68%,71.7,53.4,799.7,212.1,587.6,24.4,"2,536.2",105.3 -CCL Products India Ltd.,CCL,519600,FOOD BEVERAGES & TOBACCO,TEA & COFFEE,608.3,497.7,109.9,18.09%,22.6,18.4,69.7,8.8,60.9,4.6,279.9,21 -Crisil Ltd.,CRISIL,500092,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,771.8,544.2,191.7,26.05%,26.5,0.8,200.3,48.3,152,20.8,606.3,82.9 -Zydus Lifesciences Ltd.,ZYDUSLIFE,532321,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"4,422.8","3,222.7","1,146.1",26.23%,184.2,8.7,"1,007.2",226.4,800.7,7.9,"2,807.1",27.7 -Can Fin Homes Ltd.,CANFINHOME,511196,BANKING AND FINANCE,HOUSING FINANCE,871,49.7,749.2,86.01%,2.8,548.4,198,39.9,158.1,11.9,658.8,49.5 -Canara Bank,CANBK,532483,BANKING AND FINANCE,BANKS,"33,891.2","8,250.3","7,706.6",28.24%,0,"17,934.3","5,098","1,420.6","3,86",20.9,"13,968.4",77 -Carborundum Universal Ltd.,CARBORUNIV,513375,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"1,166",978.8,167.5,14.61%,45.9,4.9,136.4,43.7,101.9,5.4,461.3,24.3 -Castrol India Ltd.,CASTROLIND,500870,OIL & GAS,OIL MARKETING & DISTRIBUTION,"1,203.2",914.4,268.6,22.70%,22.9,2.4,263.5,69.1,194.4,2,815.5,8.2 -Ceat Ltd.,CEATLTD,500878,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"3,063.8","2,597.2",456.1,14.94%,124.5,71.7,270.4,68.3,208,51.4,521.7,129 -Central Bank of India,CENTRALBK,532885,BANKING AND FINANCE,BANKS,"8,438.5","2,565.4","1,535.4",20.81%,0,"4,337.7",567.2,-41.5,622,0.7,"2,181.4",2.5 -Century Plyboards (India) Ltd.,CENTURYPLY,532548,FOREST MATERIALS,FOREST PRODUCTS,"1,011.4",852.5,144.3,14.47%,23.4,6.1,129.4,32.2,96.9,4.4,380.7,17.1 -Cera Sanitaryware Ltd.,CERA,532443,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,476.2,387.2,76.5,16.49%,8.9,1.4,77.2,19.8,56.9,43.8,232.4,178.7 -Chambal Fertilisers & Chemicals Ltd.,CHAMBLFERT,500085,FERTILIZERS,FERTILIZERS,"5,467.3","4,770.5",615,11.42%,78.4,45.8,572.6,200.2,381,9.2,"1,137.7",27.3 -Cholamandalam Investment & Finance Company Ltd.,CHOLAFIN,511243,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"4,695.2",987.6,"3,235.1",69.99%,38.5,"2,204.2","1,065",288.8,772.9,9.4,"3,022.8",36.7 -Cipla Ltd.,CIPLA,500087,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"6,854.5","4,944.4","1,733.8",25.96%,290,25.8,"1,594.2",438.4,"1,130.9",14,"3,449.1",42.7 -City Union Bank Ltd.,CUB,532210,BANKING AND FINANCE,BANKS,"1,486.1",333.9,386.6,29.65%,0,765.6,330.6,50,280.6,3.8,943.8,12.7 -Coal India Ltd.,COALINDIA,533278,METALS & MINING,COAL,"34,760.3","24,639.4","8,137",24.83%,"1,178.2",182.5,"8,760.2","2,036.5","6,799.8",11,"28,059.6",45.5 -Colgate-Palmolive (India) Ltd.,COLPAL,500830,FMCG,PERSONAL PRODUCTS,"1,492.1",989,482.1,32.77%,44.3,1.1,457.8,117.8,340.1,12.5,"1,173.2",43.1 -Container Corporation of India Ltd.,CONCOR,531344,COMMERCIAL SERVICES & SUPPLIES,WAREHOUSING AND LOGISTICS,"2,299.8","1,648.4",546.5,24.90%,153.1,16.5,481.8,119,367.4,6,"1,186.2",19.5 -Coromandel International Ltd.,COROMANDEL,506395,FERTILIZERS,FERTILIZERS,"7,032.9","5,929.4","1,058.7",15.15%,54,46.2,"1,003.3",245,756.9,25.7,"2,024.2",68.8 -Crompton Greaves Consumer Electricals Ltd.,CROMPTON,539876,CONSUMER DURABLES,HOUSEHOLD APPLIANCES,"1,797.2","1,607.8",174.5,9.79%,32.1,21.5,135.8,34.9,97.2,1.5,432,6.7 -Cummins India Ltd.,CUMMINSIND,500480,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"2,011.3","1,575.4",346.2,18.02%,38.3,6.8,390.9,99.6,329.1,11.9,"1,445.5",52.1 -Cyient Ltd.,CYIENT,532175,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,792","1,452.7",325.8,18.32%,65.8,27,240.3,56.7,178.3,16.3,665.6,60.1 -DCM Shriram Ltd.,DCMSHRIRAM,523367,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"2,73","2,593.9",114.1,4.21%,74,14.7,47.5,15.2,32.2,2.1,617.6,39.4 -DLF Ltd.,DLF,532868,REALTY,REALTY,"1,476.4",885.3,462.4,34.31%,37,90.2,464,112.2,622.8,2.5,"2,239",9 -Dabur India Ltd.,DABUR,500096,FMCG,PERSONAL PRODUCTS,"3,320.2","2,543",660.9,20.63%,98.3,28.1,650.8,144.3,515,2.9,"1,755.7",9.9 -Delta Corp Ltd.,DELTACORP,532848,COMMERCIAL SERVICES & SUPPLIES,MISC. COMMERCIAL SERVICES,282.6,170.5,100.1,36.99%,16.9,2.7,92.4,23,69.4,2.6,273.3,10.2 -Divi's Laboratories Ltd.,DIVISLAB,532488,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,995","1,43",479,25.09%,95,1,469,121,348,13.1,"1,331.8",50.3 -Dr. Lal Pathlabs Ltd.,LALPATHLAB,539524,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,619.4,423.5,177.8,29.57%,35.9,7.8,152.2,41.5,109.3,13.2,301.4,36.1 -Dr. Reddy's Laboratories Ltd.,DRREDDY,500124,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"7,217.6","4,888.8","2,008.3",29.09%,375.5,35.3,"1,912.5",434.5,"1,482.2",89.1,"5,091.2",305.2 -EID Parry (India) Ltd.,EIDPARRY,500125,FOOD BEVERAGES & TOBACCO,OTHER FOOD PRODUCTS,"9,210.3","8,002","1,057.5",11.67%,101.2,74.2,"1,032.8",246.8,452.3,25.5,991,55.8 -Eicher Motors Ltd.,EICHERMOT,505200,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"4,388.3","3,027.4","1,087.2",26.42%,142.5,12.7,"1,205.7",291.1,"1,016.2",37.1,"3,581",130.8 -Emami Ltd.,EMAMILTD,531162,FMCG,PERSONAL PRODUCTS,876,631.2,233.7,27.02%,46.1,2.2,196.4,15.8,178.5,4.1,697.8,16 -Endurance Technologies Ltd.,ENDURANCE,540153,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,560.5","2,226.7",318.3,12.51%,118.4,9.8,205.6,51.1,154.6,11,562.8,40 -Engineers India Ltd.,ENGINERSIN,532178,COMMERCIAL SERVICES & SUPPLIES,CONSULTING SERVICES,833.6,691.3,98.5,12.47%,8.3,0.4,133.6,32.2,127.5,2.3,472.7,8.4 -Escorts Kubota Ltd.,ESCORTS,500495,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"2,154.4","1,798.6",260.7,12.66%,40.8,3.1,311.9,79.7,223.3,20.6,910.5,82.4 -Exide Industries Ltd.,EXIDEIND,500086,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"4,408.9","3,872.4",499.1,11.42%,141.5,29.7,365.3,95.2,269.4,3.2,872.7,10.3 -Federal Bank Ltd.,FEDERALBNK,500469,BANKING AND FINANCE,BANKS,"6,548.2","1,603.8","1,400.3",24.18%,0,"3,544.1","1,342.7",342.6,994.1,4.3,"3,671.4",15.6 -Finolex Cables Ltd.,FINCABLES,500144,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,229.3","1,041.3",146.1,12.30%,10.8,0.4,176.7,52.3,154.2,10.1,643.9,42.1 -Finolex Industries Ltd.,FINPIPE,500940,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,944.5,780.2,103,11.66%,27.4,12.5,124.5,35.4,98,1.6,459.3,7.4 -Firstsource Solutions Ltd.,FSL,532809,SOFTWARE & SERVICES,BPO/KPO,"1,556.9","1,311.2",228.8,14.86%,65.4,26.1,154.3,27.8,126.5,1.9,551.7,7.9 -GAIL (India) Ltd.,GAIL,532155,UTILITIES,UTILITIES,"33,191","29,405.5","3,580.2",10.85%,837.3,199.6,"2,748.7",696.3,"2,444.1",3.7,"5,283.8",8 -GlaxoSmithKline Pharmaceuticals Ltd.,GLAXO,500660,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,985.2,667.5,289.5,30.25%,18.1,0.4,299.2,81.7,217.5,12.8,647.8,38.2 -Glenmark Pharmaceuticals Ltd.,GLENMARK,532296,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"3,209.1","2,745.1",462.3,14.41%,141.5,121.5,-124.4,55.9,-81.9,-2.9,-196.3,-7 -Godrej Consumer Products Ltd.,GODREJCP,532424,FMCG,PERSONAL PRODUCTS,"3,667.9","2,897.8",704.2,19.55%,60.9,77.3,619.4,186.6,432.8,4.2,"1,750.1",17.1 -Godrej Industries Ltd.,GODREJIND,500164,DIVERSIFIED,DIVERSIFIED,"4,256.9","3,672.1",265.5,6.74%,89.3,333.1,162.4,75.9,87.3,2.6,880,26.1 -Godrej Properties Ltd.,GODREJPROP,533150,REALTY,REALTY,605.1,404.7,-61.7,-17.98%,7.4,48,145.1,38.8,66.8,2.4,662.6,23.8 -Granules India Ltd.,GRANULES,532482,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,191",976.5,213,17.90%,52.5,26,136,33.9,102.1,4.2,393.9,16.3 -Great Eastern Shipping Company Ltd.,GESHIP,500620,TRANSPORTATION,SHIPPING,"1,461.5",585.6,643.4,52.35%,186.7,77.1,611.9,17.3,594.7,41.6,"2,520.1",176.5 -Gujarat Alkalies & Chemicals Ltd.,GUJALKALI,530001,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"1,042.3",926.1,45.2,4.65%,95.2,10.8,10.2,-0.1,-18.4,-2.5,82.7,11.3 -Gujarat Gas Ltd.,GUJGASLTD,539336,UTILITIES,UTILITIES,"4,019.3","3,494.5",496.6,12.44%,117.9,7.8,399.1,102.9,296.2,4.3,"1,254.3",18.2 -Gujarat Narmada Valley Fertilizers & Chemicals Ltd.,GNFC,500670,FERTILIZERS,FERTILIZERS,"2,232","1,911",169,8.12%,78,1,242,64,182,11.7,932,60.1 -Gujarat Pipavav Port Ltd.,GPPL,533248,TRANSPORTATION,MARINE PORT & SERVICES,270.4,102,150.6,59.64%,28.8,2.2,141.1,53.4,92.3,1.9,341.8,7.1 -Gujarat State Fertilizer & Chemicals Ltd.,GSFC,500690,FERTILIZERS,FERTILIZERS,"3,313.2","2,881.4",237.3,7.61%,45.7,1.6,387,78.1,308.9,7.8,"1,056.2",26.5 -Gujarat State Petronet Ltd.,GSPL,532702,UTILITIES,UTILITIES,"4,455.9","3,497.2",913.7,20.72%,165,14.5,779.2,198.7,454.6,8.1,"1,522",27 -HCL Technologies Ltd.,HCLTECH,532281,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"27,037","20,743","5,929",22.23%,"1,01",156,"5,128","1,295","3,832",14.2,"15,445",56.9 -HDFC Bank Ltd.,HDFCBANK,500180,BANKING AND FINANCE,BANKS,"107,566.6","42,037.6","24,279.1",32.36%,0,"41,249.9","20,967.4","3,655","16,811.4",22.2,"54,474.6",71.8 -Havells India Ltd.,HAVELLS,517354,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"3,952.8","3,527",373.4,9.57%,81.2,9.3,335.3,86.2,249.1,4,"1,177.7",18.8 -Hero MotoCorp Ltd.,HEROMOTOCO,500182,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"9,741.2","8,173.5","1,359.5",14.26%,187.1,25,"1,355.6",353.1,"1,006.3",50.3,"3,247.6",162.5 -HFCL Ltd.,HFCL,500183,TELECOMMUNICATIONS EQUIPMENT,TELECOM CABLES,"1,128.7",978.9,132.6,11.93%,21.4,34.8,93.5,24,69.4,0.5,305.5,2.1 -Hindalco Industries Ltd.,HINDALCO,500440,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"54,632","48,557","5,612",10.36%,"1,843","1,034","3,231","1,035","2,196",9.9,"8,423",37.9 -Hindustan Copper Ltd.,HINDCOPPER,513599,METALS & MINING,COPPER,392.6,260.2,121.2,31.77%,45.6,4.1,82.6,21.9,60.7,0.6,320.5,3.3 -Hindustan Petroleum Corporation Ltd.,HINDPETRO,500104,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"96,093.4","87,512","8,24",8.61%,"1,247.3",590,"6,744.1","1,616","5,827",41.1,"16,645",117.3 -Hindustan Unilever Ltd.,HINDUNILVR,500696,FMCG,PERSONAL PRODUCTS,"15,806","11,826","3,797",24.30%,297,88,"3,59",931,"2,656",11.3,"10,284",43.8 -Hindustan Zinc Ltd.,HINDZINC,500188,METALS & MINING,ZINC,"7,014","3,652","3,139",46.22%,825,232,"2,305",576,"1,729",4.1,"8,432",20 -Housing and Urban Development Corporation Ltd.,HUDCO,540530,BANKING AND FINANCE,HOUSING FINANCE,"1,880.8",82.7,"1,809.6",97.04%,2.4,"1,216.8",606.4,154.7,451.6,2.3,"1,790.7",8.9 -ITC Ltd.,ITC,500875,FOOD BEVERAGES & TOBACCO,CIGARETTES-TOBACCO PRODUCTS,"18,439.3","11,320.2","6,454.2",36.31%,453,9.9,"6,656.2","1,700.3","4,898.1",3.9,"20,185.1",16.2 -ICICI Bank Ltd.,ICICIBANK,532174,BANKING AND FINANCE,BANKS,"57,292.3","23,911","15,473.2",39.74%,0,"17,908","14,824.2","3,808.8","11,805.6",15.6,"41,086.8",58.7 -ICICI Prudential Life Insurance Company Ltd.,ICICIPRULI,540133,BANKING AND FINANCE,LIFE INSURANCE,"17,958.1","17,612.3",-229.6,-1.32%,0,0,340.2,32.5,243.9,1.7,906.9,6.3 -IDBI Bank Ltd.,IDBI,500116,BANKING AND FINANCE,BANKS,"7,063.7","1,922.3","2,175.3",36.02%,0,"2,966.1","2,396.9","1,003.7","1,385.4",1.3,"4,776.3",4.4 -IDFC First Bank Ltd.,IDFCFIRSTB,539437,BANKING AND FINANCE,BANKS,"8,765.8","3,849","1,511.2",20.54%,0,"3,405.6",982.8,236,746.9,1.1,"2,911.1",4.3 -IDFC Ltd.,IDFC,532659,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),36.7,6,30.6,83.56%,0,0,30.6,6.6,223.5,1.4,"4,147.1",25.9 -IRB Infrastructure Developers Ltd.,IRB,532947,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,874.5",950.4,794.6,45.54%,232.7,434.6,256.9,85.8,95.7,0.2,501,0.8 -ITI Ltd.,ITI,523610,TELECOMMUNICATIONS EQUIPMENT,TELECOM EQUIPMENT,256.1,299.3,-52.8,-21.42%,13.3,69.3,-125.8,0,-126,-1.3,-388.4,-4 -Vodafone Idea Ltd.,IDEA,532822,TELECOM SERVICES,TELECOM SERVICES,"10,750.8","6,433.5","4,282.8",39.97%,"5,667.3","6,569","-7,919",817.7,"-8,737.9",-1.8,"-30,986.8",-6.4 -India Cements Ltd.,INDIACEM,530005,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,272.4","1,26",4.4,0.35%,55,60.4,-103,-17.4,-80.1,-2.6,-261.1,-8.4 -Indiabulls Housing Finance Ltd.,IBULHSGFIN,535789,BANKING AND FINANCE,HOUSING FINANCE,"2,242.3",190.6,"1,779.2",79.88%,22.9,"1,349.8",421.6,123.6,298,6.5,"1,146",24.3 -Indian Bank,INDIANB,532814,BANKING AND FINANCE,BANKS,"15,929.4","3,599.1","4,327.7",31.44%,0,"8,002.6","2,776.7",768.6,"2,068.5",16.6,"6,893.3",55.3 -Indian Hotels Company Ltd.,INDHOTEL,500850,HOTELS RESTAURANTS & TOURISM,HOTELS,"1,480.9","1,078.4",354.8,24.75%,111.2,59,232.2,72.3,166.9,1.2,"1,100.3",7.7 -Indian Oil Corporation Ltd.,IOC,530965,OIL & GAS,OIL MARKETING & DISTRIBUTION,"179,752.1","156,013.1","23,328.4",13.01%,"3,609.6","2,135","18,090.2","4,699.7","13,114.3",9.5,"38,614.3",27.3 -Indian Overseas Bank,IOB,532388,BANKING AND FINANCE,BANKS,"6,941.5","1,785.1","1,679.8",28.84%,0,"3,476.6",635.5,8.3,627.2,0.3,"2,341.9",1.2 -Indraprastha Gas Ltd.,IGL,532514,UTILITIES,UTILITIES,"3,520.2","2,801.6",656.9,18.99%,102.2,2.5,613.9,151.4,552.7,7.9,"1,806.2",25.8 -IndusInd Bank Ltd.,INDUSINDBK,532187,BANKING AND FINANCE,BANKS,"13,529.7","3,449.9","3,908.7",34.75%,0,"6,171.1","2,934.9",732.9,"2,202.2",28.4,"8,333.7",107.2 -Info Edge (India) Ltd.,NAUKRI,532777,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,792,421.2,204.7,32.70%,25.9,8.2,382.8,68.7,205.1,15.9,-25.6,-2 -InterGlobe Aviation Ltd.,INDIGO,539448,TRANSPORTATION,AIRLINES,"15,502.9","12,743.6","2,200.3",14.72%,"1,549","1,021.3",189.1,0.2,188.9,4.9,"5,621.3",145.7 -Ipca Laboratories Ltd.,IPCALAB,524494,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,072.5","1,712.7",321.3,15.80%,90.3,44.1,225.4,87.9,145.1,5.7,492.2,19.4 -J B Chemicals & Pharmaceuticals Ltd.,JBCHEPHARM,506943,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,889.4,638.2,243.5,27.62%,32.2,10.4,208.7,58.1,150.6,9.7,486.6,31.4 -JK Cement Ltd.,JKCEMENT,532644,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,782.1","2,285.8",467,16.96%,137.1,115,244.2,65.7,178.1,23.1,444,57.5 -JK Lakshmi Cement Ltd.,JKLAKSHMI,500380,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,588.5","1,357.3",217.3,13.80%,56.6,33.6,141,45.1,92.7,7.9,357.6,30.4 -JM Financial Ltd.,JMFINANCIL,523405,DIVERSIFIED,HOLDING COMPANIES,"1,214",407.9,662.6,55.34%,13.2,388.1,277.9,72.4,194.9,2,608.1,6.4 -JSW Energy Ltd.,JSWENERGY,533148,UTILITIES,ELECTRIC UTILITIES,"3,387.4","1,379","1,880.4",57.69%,408.7,513.7,"1,085.9",235.1,850.2,5.2,"1,591.7",9.7 -JSW Steel Ltd.,JSWSTEEL,500228,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"44,821","36,698","7,886",17.69%,"2,019","2,084","4,609","1,812","2,76",11.4,"9,252",38.1 -Jindal Stainless Ltd.,JSL,532508,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"9,829","8,566.5","1,230.6",12.56%,221.9,155.6,985.7,229.1,774.3,9.4,"2,600.2",31.6 -Jindal Steel & Power Ltd.,JINDALSTEL,532286,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"12,282","9,964.5","2,285.7",18.66%,603.7,329.4,"1,384.5",-5.8,"1,387.8",13.8,"4,056",40.4 -Jubilant Foodworks Ltd.,JUBLFOOD,533155,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,"1,375.7","1,091.4",277.2,20.25%,141.9,56.8,85.5,23.3,97.2,1.5,235,3.6 -Just Dial Ltd.,JUSTDIAL,535648,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,318.5,211.8,48.8,18.71%,12.2,2.4,92.1,20.3,71.8,8.4,314.1,36.9 -Jyothy Labs Ltd.,JYOTHYLAB,532926,FMCG,PERSONAL PRODUCTS,745.6,597,135.4,18.48%,12.3,1.2,135.1,31.1,104.2,2.8,326.9,8.9 -KRBL Ltd.,KRBL,530813,FMCG,PACKAGED FOODS,"1,246.5","1,018.9",194.5,16.03%,19.9,0.8,206.8,53.6,153.3,6.5,671.4,29.3 -Kajaria Ceramics Ltd.,KAJARIACER,500233,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"1,129.9",941.9,179.7,16.02%,36.1,4.3,147.7,36.6,108,6.8,397.8,25 -Kalpataru Projects International Ltd.,KPIL,522287,UTILITIES,ELECTRIC UTILITIES,"4,53","4,148",370,8.19%,113,137,132,42,89,5.5,478,29.9 -Kansai Nerolac Paints Ltd.,KANSAINER,500165,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,"1,978.6","1,683.3",273.2,13.97%,47.4,7.6,240.3,64.8,177.2,2.2,"1,118.8",13.8 -Karur Vysya Bank Ltd.,KARURVYSYA,590003,BANKING AND FINANCE,BANKS,"2,336",616.4,637.9,31.94%,0,"1,081.7",511.5,133.1,378.4,4.7,"1,364.2",17 -KEC International Ltd.,KEC,532714,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"4,514.9","4,224.7",274.3,6.10%,46.5,177.8,65.8,9.9,55.8,2.2,187.9,7.3 -Kotak Mahindra Bank Ltd.,KOTAKBANK,500247,BANKING AND FINANCE,BANKS,"21,559.5","9,681","6,343",46.24%,0,"5,535.5","5,888.3","1,465.5","4,461",22.4,"17,172.7",86.4 -L&T Finance Holdings Ltd.,L&TFH,533519,DIVERSIFIED,HOLDING COMPANIES,"3,482.1",935.3,"1,882.4",58.57%,28.3,"1,324.9",797.4,203.2,595.1,2.4,"2,080.8",8.4 -L&T Technology Services Ltd.,LTTS,540115,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,427.7","1,910.9",475.6,19.93%,68.1,12.6,436.1,120.2,315.4,29.8,"1,239.7",117.5 -LIC Housing Finance Ltd.,LICHSGFIN,500253,BANKING AND FINANCE,HOUSING FINANCE,"6,765.9",250.6,"6,095.7",90.10%,13.2,"4,599.9","1,483",291.2,"1,193.5",21.7,"4,164.5",75.7 -Lakshmi Machine Works Ltd.,LAXMIMACH,500252,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,"1,355.5","1,184.5",136,10.30%,23.6,0,147.4,32.3,115.1,107.8,416,389.5 -Laurus Labs Ltd.,LAURUSLABS,540222,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,226.2","1,036.6",187.9,15.34%,93.4,42.4,53.9,14.6,37,0.7,367.8,6.8 -Lupin Ltd.,LUPIN,500257,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"5,079","4,120.8",917.8,18.21%,247.8,80.6,629.7,134.3,489.5,10.8,"1,331.2",29.2 -MMTC Ltd.,MMTC,513377,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,-167.2,-180.1,-30.4,14.42%,0.8,1.1,12.1,1.5,52,0.3,174.1,1.2 -MRF Ltd.,MRF,500290,AUTOMOBILES & AUTO COMPONENTS,AUTO TYRES & RUBBER PRODUCTS,"6,287.8","5,060.2","1,156.9",18.61%,351.5,85.5,790.6,203.9,586.7,1383.3,"1,690.9",3988 -Mahanagar Gas Ltd.,MGL,539957,UTILITIES,UTILITIES,"1,772.7","1,250.1",478.9,27.70%,65.8,2.5,454.3,115.8,338.5,34.3,"1,147.8",116.2 -Mahindra & Mahindra Financial Services Ltd.,M&MFIN,532720,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"3,863.5","1,077.5","2,109.3",55.03%,67.1,"1,703.4",369.1,96,281.1,2.3,"1,982.5",16 -Mahindra & Mahindra Ltd.,M&M,500520,AUTOMOBILES & AUTO COMPONENTS,CARS & UTILITY VEHICLES,"35,027.2","28,705.9","5,729.6",16.64%,"1,138.6","1,835.2","3,347.5","1,083.7","2,347.8",21.1,"11,169.4",100.2 -Mahindra Holidays & Resorts India Ltd.,MHRIL,533088,HOTELS RESTAURANTS & TOURISM,HOTELS,672.2,519.3,136,20.76%,83.8,33.3,35.8,14,21.3,1.1,66,3.3 -Manappuram Finance Ltd.,MANAPPURAM,531213,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"2,174",555.6,"1,481.3",68.68%,62.5,689.4,746.7,186.1,558.4,6.6,"1,859.8",22 -Mangalore Refinery And Petrochemicals Ltd.,MRPL,500109,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"22,904.7","20,705.6","2,138.2",9.36%,296,311.2,"1,592",546.2,"1,051.7",6,"3,784.9",21.6 -Marico Ltd.,MARICO,531642,FMCG,PERSONAL PRODUCTS,"2,514","1,979",497,20.07%,39,20,476,116,353,2.7,"1,41",10.9 -Maruti Suzuki India Ltd.,MARUTI,532500,AUTOMOBILES & AUTO COMPONENTS,CARS & UTILITY VEHICLES,"37,902.1","32,282.5","4,790.3",12.92%,794.4,35.1,"4,790.1","1,083.8","3,764.3",124.6,"11,351.8",375.9 -Max Financial Services Ltd.,MFSL,500271,BANKING AND FINANCE,LIFE INSURANCE,"10,189.1","10,024.6",143.9,1.42%,0.8,9.4,158.2,-12.1,147.9,4.3,506.4,14.7 -UNO Minda Ltd.,UNOMINDA,532539,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"3,630.2","3,219.8",401.6,11.09%,125.4,27.2,257.9,73.3,225,3.9,742.4,13 -Motilal Oswal Financial Services Ltd.,MOTILALOFS,532892,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,"1,650.7",724.1,904.5,55.18%,17.3,241.1,657.6,124.2,531.2,35.9,"1,449.3",97.8 -MphasiS Ltd.,MPHASIS,526299,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"3,325.5","2,680.9",595.6,18.18%,89,34,521.7,129.7,391.9,20.8,"1,605.6",85.1 -Muthoot Finance Ltd.,MUTHOOTFIN,533398,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"3,631.9",723.4,"2,801.6",77.69%,22.2,"1,335","1,470.2",374.9,"1,059.6",26.4,"3,982.9",99.2 -Natco Pharma Ltd.,NATCOPHARM,524816,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,060.8",573.4,458,44.41%,43.6,4.2,439.6,70.6,369,20.6,"1,127.4",63 -NBCC (India) Ltd.,NBCC,534309,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"2,129.1","1,957.7",95.5,4.65%,1.3,0,104.6,22.9,79.6,0.4,332.2,1.8 -NCC Ltd.,NCC,500294,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"4,746.4","4,415.9",303.7,6.44%,53.2,153.5,123.8,38.8,77.3,1.2,599.4,9.5 -NHPC Ltd.,NHPC,533098,UTILITIES,ELECTRIC UTILITIES,"3,113.8","1,173.9","1,757.4",59.95%,294.9,104.8,"1,618.3",-75,"1,545.8",1.5,"3,897.8",3.9 -Coforge Ltd.,COFORGE,532541,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,285.1","1,935.3",340.9,14.98%,77.2,31.9,240.7,52.8,187.9,29.6,696.2,113.2 -NLC India Ltd.,NLCINDIA,513683,UTILITIES,ELECTRIC UTILITIES,"3,234","2,143",834.6,28.03%,455.1,213.9,"1,700.6",614.7,"1,084.7",7.8,"1,912.3",13.8 -NTPC Ltd.,NTPC,532555,UTILITIES,ELECTRIC UTILITIES,"45,384.6","32,303.2","12,680.2",28.19%,"4,037.7","2,920.5","6,342.9","2,019.7","4,614.6",4.8,"19,125.2",19.7 -Narayana Hrudayalaya Ltd.,NH,539551,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,323.6",997.1,308.1,23.61%,55.3,22.9,248.4,21.7,226.6,11.2,737.5,36.1 -National Aluminium Company Ltd.,NATIONALUM,532234,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"3,112","2,646.9",396.5,13.03%,186.2,4,275,68.7,187.3,1,"1,272.4",6.9 -Navin Fluorine International Ltd.,NAVINFLUOR,532504,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,494.9,373.4,98.3,20.84%,24.2,20,77.2,16.6,60.6,12.2,365,73.7 -Oberoi Realty Ltd.,OBEROIRLTY,533273,REALTY,REALTY,"1,243.8",579.2,638.2,52.42%,11.3,56.5,596.8,142.1,456.8,12.6,"1,961.3",53.9 -Oil And Natural Gas Corporation Ltd.,ONGC,500312,OIL & GAS,EXPLORATION & PRODUCTION,"149,388.5","118,618.4","28,255.3",19.24%,"6,698.1","2,603.3","21,564.9","5,633.6","13,734.1",10.9,"43,072.5",34.2 -Oil India Ltd.,OIL,533106,OIL & GAS,EXPLORATION & PRODUCTION,"9,200.1","5,293.3","3,523.2",39.96%,499,278.9,762,67.6,420.7,3.9,"5,874.5",54.2 -Oracle Financial Services Software Ltd.,OFSS,532466,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,509.6",886.4,558.1,38.64%,19,8,596.2,178.8,417.4,48.2,"1,835.1",211.9 -PI Industries Ltd.,PIIND,523642,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"2,163.8","1,565.5",551.4,26.05%,80.3,7.8,510.2,31.7,480.5,31.7,"1,495.8",98.4 -PNB Housing Finance Ltd.,PNBHOUSING,540173,BANKING AND FINANCE,HOUSING FINANCE,"1,779.4",158.8,"1,574.1",88.54%,11.3,"1,057.3",507.1,124.1,383,14.8,"1,278.7",49.3 -PNC Infratech Ltd.,PNCINFRA,539150,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,932.4","1,511.6",399.8,20.92%,40.9,161.3,218.6,70.7,147.9,5.8,614.3,23.9 -PVR INOX Ltd.,PVRINOX,532689,RETAILING,SPECIALTY RETAIL,"2,023.7","1,293.1",706.8,35.34%,308.6,200.3,221.7,55.5,166.3,17,-232.5,-23.7 -Page Industries Ltd.,PAGEIND,532827,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,"1,126.8",891.6,233.5,20.76%,24.6,11.2,199.4,49.1,150.3,134.7,510.7,457.9 -Persistent Systems Ltd.,PERSISTENT,533179,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"2,449","2,006.5",405.2,16.80%,74.4,12.3,355.8,92.5,263.3,35,981.5,127.6 -Petronet LNG Ltd.,PETRONET,532522,OIL & GAS,OIL MARKETING & DISTRIBUTION,"12,686.2","11,317.9","1,214.7",9.69%,194.8,74.7,"1,098.8",283.9,855.7,5.7,"3,490.3",23.3 -Pfizer Ltd.,PFIZER,500680,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,611.3,392.6,182.6,31.75%,15.4,2.7,200.5,51.6,149,32.6,522.8,114.3 -Phoenix Mills Ltd.,PHOENIXLTD,503100,REALTY,REALTY,906.6,361.2,506,57.82%,65.9,96.5,375.2,71.4,252.6,14.2,923.6,51.7 -Pidilite Industries Ltd.,PIDILITIND,500331,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"3,107.6","2,396.3",679.7,22.10%,75.2,13.1,623,163.1,450.1,8.8,"1,505.5",29.6 -Power Finance Corporation Ltd.,PFC,532810,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"22,403.7",315.4,"22,941.9",102.46%,12.7,"14,313.1","8,628.8","2,000.6","4,833.1",14.7,"17,946.4",54.4 -Power Grid Corporation of India Ltd.,POWERGRID,532898,UTILITIES,ELECTRIC UTILITIES,"11,530.4","1,358.7","9,908.4",87.94%,"3,277","2,341.3","4,393.4",573.7,"3,781.4",4.1,"15,344.4",16.5 -Prestige Estates Projects Ltd.,PRESTIGE,ASM,REALTY,REALTY,"3,256","1,643.9",592.5,26.49%,174.1,263.9,"1,174.1",256.4,850.9,21.2,"1,714",42.8 -Prism Johnson Ltd.,PRSMJOHNSN,500338,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"1,846","1,745.4",92.4,5.03%,95.2,43.5,210,30.4,182.7,3.6,154.2,3.1 -Procter & Gamble Hygiene & Healthcare Ltd.,PGHH,500459,FMCG,PERSONAL PRODUCTS,"1,154.1",853.5,284.9,25.03%,14.3,1.9,284.5,73.8,210.7,64.9,734.4,226.3 -Punjab National Bank,PNB,532461,BANKING AND FINANCE,BANKS,"29,857","6,798.1","6,239.1",23.23%,0,"16,819.8","2,778.3","1,013.8","1,990.2",1.8,"5,904.8",5.4 -Quess Corp Ltd.,QUESS,539978,SOFTWARE & SERVICES,BPO/KPO,"4,763.5","4,584.8",163.6,3.44%,69.7,28.1,79.3,8.3,71.9,4.8,240.9,16.2 -RBL Bank Ltd.,RBLBANK,540065,BANKING AND FINANCE,BANKS,"3,720.6","1,422.6",765.4,25.45%,0,"1,532.6",125,-206.1,331.1,5.5,"1,173.9",19.5 -Radico Khaitan Ltd.,RADICO,532497,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,925.7,803.8,121.2,13.10%,26.1,12.5,83.3,21.4,64.8,4.8,237,17.7 -Rain Industries Ltd.,RAIN,500339,CHEMICALS & PETROCHEMICALS,PETROCHEMICALS,"4,208.9","3,794.3",366,8.80%,192.5,241.7,-19.5,46.2,-90.2,-2.7,270.4,8 -Rajesh Exports Ltd.,RAJESHEXPO,531500,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"38,079.4","38,015.8",50.1,0.13%,10.7,0,53,7.7,45.3,1.5,"1,142.2",38.7 -Rallis India Ltd.,RALLIS,500355,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,837,699,133,15.99%,26,3,110,28,82,4.2,98.4,5.2 -Rashtriya Chemicals & Fertilizers Ltd.,RCF,524230,FERTILIZERS,FERTILIZERS,"4,222.1","4,049.3",105.9,2.55%,56.1,44,72.8,21.1,51,0.9,523.6,9.5 -Redington Ltd.,REDINGTON,532805,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,"22,296.6","21,738.7",481.4,2.17%,43.7,105.8,408.3,96.7,303.5,3.9,"1,242",15.9 -Relaxo Footwears Ltd.,RELAXO,530517,RETAILING,FOOTWEAR,725.9,623.8,91.5,12.79%,36.9,4.7,60.4,16.2,44.2,1.8,193.9,7.8 -Reliance Industries Ltd.,RELIANCE,500325,OIL & GAS,REFINERIES/PETRO-PRODUCTS,"238,797","193,988","40,968",17.44%,"12,585","5,731","26,493","6,673","17,394",25.7,"68,496",101.2 -REC Ltd.,RECLTD,532955,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"11,701.3",275.1,"12,180.5",104.21%,6.1,"7,349.8","4,837.6","1,047.7","3,789.9",14.4,"12,738.6",48.4 -SJVN Ltd.,SJVN,533206,UTILITIES,ELECTRIC UTILITIES,951.6,172.2,706.2,80.40%,101.9,124.2,567.7,129.2,439.6,1.1,"1,016",2.6 -SKF India Ltd.,SKFINDIA,500472,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,"1,145.5","1,003.7",121.5,10.80%,19.3,0.5,122,31.7,90,18.2,484,97.9 -SRF Ltd.,SRF,503806,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"3,206.5","2,551.2",626.2,19.71%,161.2,79.3,414.8,114,300.8,10.2,"1,733.4",58.5 -Sanofi India Ltd.,SANOFI,500674,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,726.4,506.1,208.5,29.17%,9.9,0.3,210.1,57.9,152.1,66.1,596.3,259.3 -Schaeffler India Ltd.,SCHAEFFLER,505790,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,879.2","1,506.3",342,18.50%,55.6,1.6,315.7,80.7,235,15,922.6,59 -Shree Cements Ltd.,SHREECEM,500387,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"4,932.1","3,914.1",886,18.46%,411.7,67,539.2,92.6,446.6,123.8,"1,826.8",506.3 -Shriram Finance Ltd.,SHRIRAMFIN,511218,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"8,893","1,409.4","6,334.3",71.30%,141.4,"3,798","2,404.2",614.9,"1,786.1",47.6,"6,575.4",175.2 -Siemens Ltd.,SIEMENS,500550,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"5,953.2","5,107.5",700.2,12.06%,78.6,4.9,762.2,190.5,571.3,16.1,"1,960.9",55.1 -Sobha Ltd.,SOBHA,532784,REALTY,REALTY,773.6,665.8,75.4,10.18%,19.3,63.9,24.7,9.7,14.9,1.6,107.4,11.3 -Solar Industries India Ltd.,SOLARINDS,532725,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"1,355.2","1,011.3",336.1,24.95%,33.7,24.9,285.3,75.5,200.1,22.1,808.2,89.3 -Sonata Software Ltd.,SONATSOFTW,532221,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,935.8","1,715.2",197.3,10.32%,33.3,20.7,166.5,42.3,124.2,9,475.7,34.3 -State Bank of India,SBIN,500112,BANKING AND FINANCE,BANKS,"144,256.1","58,597.6","22,703.3",21.14%,0,"62,955.2","21,935.7","5,552.5","17,196.2",18,"69,304.1",77.7 -Steel Authority of India (SAIL) Ltd.,SAIL,500113,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"29,858.2","25,836.7","3,875.4",13.04%,"1,326.6",605.2,"1,674.7",464.2,"1,305.6",3.2,"3,219.5",7.8 -Sun Pharma Advanced Research Company Ltd.,SPARC,532872,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,29.7,112.7,-91.5,-431.87%,3.2,0.3,-86.4,0,-86.4,-2.7,-253.6,-7.8 -Sun Pharmaceutical Industries Ltd.,SUNPHARMA,524715,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"12,486","9,013","3,179.4",26.08%,632.8,49.3,"2,790.9",390.1,"2,375.5",9.9,"8,548.5",35.6 -Sun TV Network Ltd.,SUNTV,532733,MEDIA,BROADCASTING & CABLE TV,"1,160.2",320.6,727.8,69.42%,218.8,1.7,619.1,154.4,464.7,11.8,"1,861.8",47.2 -Sundram Fasteners Ltd.,SUNDRMFAST,500403,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,429.1","1,191.1",230.7,16.23%,54.5,7.4,176.2,43.1,131.9,6.3,502.9,23.9 -Sunteck Realty Ltd.,SUNTECK,512179,REALTY,REALTY,36.2,39.1,-14.1,-56.70%,2.2,15.8,-20.9,-6.4,-13.9,-1,-46.5,-3.3 -Supreme Industries Ltd.,SUPREMEIND,509930,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,"2,321.4","1,952.5",356.2,15.43%,71.9,1.6,295.4,76.3,243.2,19.1,"1,028.2",80.9 -Suzlon Energy Ltd.,SUZLON,ASM,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"1,428.7","1,196.4",225,15.83%,51.2,43.7,102.4,0.1,102.3,0.1,561.4,0.4 -Syngene International Ltd.,SYNGENE,539268,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,931.7,656,254.1,27.92%,104.6,13,150.7,34.2,116.5,2.9,498.3,12.4 -TTK Prestige Ltd.,TTKPRESTIG,517506,CONSUMER DURABLES,HOUSEWARE,747.2,648.6,80.8,11.08%,15.9,3.1,79.5,20.5,59.3,4.3,224.3,16.2 -TV18 Broadcast Ltd.,TV18BRDCST,532800,MEDIA,BROADCASTING & CABLE TV,"1,989","1,992.2",-198.1,-11.04%,50.1,33.8,-87.1,-6.5,-28.9,-0.2,92.2,0.5 -TVS Motor Company Ltd.,TVSMOTOR,532343,AUTOMOBILES & AUTO COMPONENTS,2/3 WHEELERS,"9,983.8","8,576.9","1,355.9",13.65%,237.1,483.3,686.4,259.8,386.3,8.1,"1,457.6",30.7 -Tata Consultancy Services Ltd.,TCS,532540,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"60,698","43,946","15,746",26.38%,"1,263",159,"15,33","3,95","11,342",31,"44,654",122 -Tata Elxsi Ltd.,TATAELXSI,500408,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,912.8,618.2,263.5,29.89%,25,5.8,263.9,63.8,200,32.1,785.1,126.1 -Tata Consumer Products Ltd.,TATACONSUM,500800,FMCG,PACKAGED FOODS,"3,823.6","3,196.7",537.1,14.38%,93.9,27.6,490.9,131.7,338.2,3.6,"1,275.2",13.7 -Tata Motors Limited (DVR),TATAMTRDVR,570001,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,,,,,,,,,,,, -Tata Motors Ltd.,TATAMOTORS,500570,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,"106,759","91,361.3","13,766.9",13.10%,"6,636.4","2,651.7","5,985.9","2,202.8","3,764",9.8,"15,332.3",40 -Tata Power Company Ltd.,TATAPOWER,500400,UTILITIES,ELECTRIC UTILITIES,"16,029.5","12,647","3,091",19.64%,925.9,"1,181.8",979.2,213.3,875.5,2.7,"3,570.8",11.2 -Tata Steel Ltd.,TATASTEEL,500470,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"55,910.2","51,414.1","4,267.8",7.66%,"2,479.8","1,959.4","-6,842.1",-228,"-6,196.2",-5.1,"-6,081.3",-5 -Tech Mahindra Ltd.,TECHM,532755,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"13,128.1","11,941.1",922.8,7.17%,465.7,97.5,623.8,110,493.9,5.6,"3,600.7",40.9 -The Ramco Cements Ltd.,RAMCOCEM,500260,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,352.1","1,935",405.6,17.33%,162.8,116.5,137.8,37,72,3.1,348.9,14.8 -Thermax Ltd.,THERMAX,500411,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,368.3","2,097.8",204.6,8.89%,33,19.8,217.7,58.9,157.7,14,498.8,44.3 -Timken India Ltd.,TIMKEN,522113,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,692.1,546.5,135.5,19.87%,21.1,0.9,123.6,30.6,93,12.4,358.3,47.6 -Titan Company Ltd.,TITAN,500114,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"12,653","11,118","1,411",11.26%,144,140,"1,251",336,915,10.3,"3,302",37.1 -Torrent Pharmaceuticals Ltd.,TORNTPHARM,500420,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,686","1,835",825,31.02%,201,91,559,173,386,11.4,"1,334",39.4 -Torrent Power Ltd.,TORNTPOWER,532779,UTILITIES,ELECTRIC UTILITIES,"7,069.1","5,739.5","1,221.4",17.55%,341.7,247.2,740.7,198.1,525.9,10.9,"2,176.8",45.3 -Trent Ltd.,TRENT,500251,RETAILING,DEPARTMENT STORES,"3,062.5","2,525.8",456.6,15.31%,152.2,95.5,288.9,86.3,234.7,6.6,629.4,17.7 -Trident Ltd.,TRIDENT,521064,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,812","1,557.3",240.3,13.37%,89.4,35,130.4,40.1,90.7,0.2,458.1,0.9 -UPL Ltd.,UPL,512070,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"10,275","8,807","1,325",13.03%,657,871,-185,-96,-189,-2.5,"1,856",24.7 -UltraTech Cement Ltd.,ULTRACEMCO,532538,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"16,179.3","13,461.2","2,550.9",15.93%,797.8,233.9,"1,686.2",409.4,"1,281.5",44.5,"5,694.1",197.2 -Union Bank of India,UNIONBANK,532477,BANKING AND FINANCE,BANKS,"28,952.5","6,189.3","7,265",29.38%,0,"15,498.2","5,492.3","1,944","3,571.8",5.1,"11,918.9",16.1 -United Breweries Ltd.,UBL,532478,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,"1,902.1","1,705.8",184.3,9.75%,50.9,1.4,144,36.9,107.3,4.1,251.3,9.5 -United Spirits Ltd.,MCDOWELL-N,532432,FOOD BEVERAGES & TOBACCO,BREWERIES & DISTILLERIES,"6,776.6","6,269.8",466.7,6.93%,65.3,26.2,446,106.3,339.3,4.8,"1,133",15.6 -V-Guard Industries Ltd.,VGUARD,532953,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,147.9","1,041.3",92.5,8.16%,19.8,9.3,77.5,18.6,59,1.4,215.2,5 -Vardhman Textiles Ltd.,VTL,502986,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,487","2,192.1",205.4,8.57%,103.7,22,169.2,41.7,134.3,4.7,531.9,18.7 -Varun Beverages Ltd.,VBL,540180,FOOD BEVERAGES & TOBACCO,NON-ALCOHOLIC BEVERAGES,"3,889","2,988.4",882.1,22.79%,170.8,62.5,667.3,152.9,501.1,3.9,"1,998.7",15.4 -Vinati Organics Ltd.,VINATIORGA,524200,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,464.4,337.3,110.8,24.73%,13.7,0.3,113,28.9,84.2,8.2,408.2,39.7 -Voltas Ltd.,VOLTAS,500575,CONSUMER DURABLES,CONSUMER ELECTRONICS,"2,363.7","2,222.5",70.3,3.06%,11.7,11.4,118.1,49.3,36.7,1.1,199.5,6 -ZF Commercial Vehicle Control Systems India Ltd.,ZFCVINDIA,533023,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,015.8",846.2,145.5,14.67%,27.1,1.3,141.2,35.5,105.7,55.7,392,206.7 -Welspun Corp Ltd.,WELCORP,ASM,METALS & MINING,IRON & STEEL PRODUCTS,"4,161.4","3,659.9",399.5,9.84%,85.7,75,340.8,79,384.7,14.7,809.2,30.9 -Welspun Living Ltd.,WELSPUNLIV,514162,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,542.4","2,151.1",358,14.27%,98.5,33.8,258.9,58.7,196.7,2,526.1,5.4 -Whirlpool of India Ltd.,WHIRLPOOL,500238,CONSUMER DURABLES,CONSUMER ELECTRONICS,"1,555.5","1,448.4",73.2,4.81%,49.2,5.6,52.3,14.1,36.6,2.9,198.8,15.7 -Wipro Ltd.,WIPRO,507685,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"23,255.7","18,543.2","3,972.7",17.64%,897,303.3,"3,512.2",841.9,"2,646.3",5.1,"11,643.8",22.3 -Zee Entertainment Enterprises Ltd.,ZEEL,505537,MEDIA,BROADCASTING & CABLE TV,"2,509.6","2,105",332.8,13.65%,77.2,23.4,184.2,54.4,123,1.3,-102.2,-1.1 -eClerx Services Ltd.,ECLERX,532927,SOFTWARE & SERVICES,BPO/KPO,735.9,517,204.7,28.37%,30.3,6.1,182.4,46.3,136,28.2,506,105 -Sterlite Technologies Ltd.,STLTECH,532374,TELECOMMUNICATIONS EQUIPMENT,TELECOM CABLES,"1,497","1,281",213,14.26%,85,95,36,12,34,0.9,203,5.1 -HEG Ltd.,HEG,509631,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,642.2,512.3,101.9,16.58%,38.5,8.5,82.9,21.7,96,24.9,439.5,113.9 -SBI Life Insurance Company Ltd.,SBILIFE,540719,BANKING AND FINANCE,LIFE INSURANCE,"28,816.2","28,183.8",609.9,2.12%,0,0,621.5,43.9,380.2,3.8,"1,842.2",18.4 -General Insurance Corporation of India,GICRE,540755,BANKING AND FINANCE,GENERAL INSURANCE,"13,465.9","11,574","1,464.6",11.20%,0,0,"1,855.4",243.7,"1,689",15.2,"6,628",37.8 -Tube Investments of India Ltd.,TIINDIA,540762,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,005.4","1,718.2",251.4,12.76%,34.6,7.7,244.8,63.4,181.4,9.4,717.5,37.1 -Honeywell Automation India Ltd.,HONAUT,517174,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,144.3",965.9,138.3,12.52%,13.8,0.7,163.9,42,121.9,137.8,443.4,503.9 -Indian Energy Exchange Ltd.,IEX,540750,BANKING AND FINANCE,EXCHANGE,133,16.6,92,84.73%,5.1,0.7,110.6,27.9,86.5,1,327.8,3.7 -ICICI Lombard General Insurance Company Ltd.,ICICIGI,540716,BANKING AND FINANCE,GENERAL INSURANCE,"5,271.1","4,612.4",743.5,14.16%,0,0,763.6,186.4,577.3,11.8,"1,757.1",35.8 -Aster DM Healthcare Ltd.,ASTERDM,540975,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"3,325.2","2,939.4",377.3,11.38%,227.2,101.9,2.1,10.2,-30.8,-0.6,284.3,5.7 -Central Depository Services (India) Ltd.,CDSL,CDSL,OTHERS,INVESTMENT COMPANIES,230.1,77.9,129.4,62.40%,6.5,0,145.6,35.8,108.9,10.4,320.2,30.6 -Graphite India Ltd.,GRAPHITE,509488,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,884,823,-30,-3.78%,19,4,992,190,804,41.1,856,43.9 -Grasim Industries Ltd.,GRASIM,500300,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"30,505.3","25,995.9","4,224.8",13.98%,"1,245.2",397.8,"2,866.4",837.7,"1,163.8",17.7,"6,624.9",100.6 -KNR Constructions Ltd.,KNRCON,532942,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"1,043.8",806.9,231.6,22.30%,39.2,20.6,177.1,34.6,147.4,5.2,537.5,19.1 -Aditya Birla Capital Ltd.,ABCAPITAL,540691,DIVERSIFIED,HOLDING COMPANIES,"7,730.4","4,550.1","2,821.9",36.55%,48,"1,827",956.8,284.1,705,2.7,"5,231.9",20.1 -Dixon Technologies (India) Ltd.,DIXON,540699,CONSUMER DURABLES,CONSUMER ELECTRONICS,"4,943.9","4,744.3",198.9,4.02%,36.4,17.1,146.1,35.2,107.3,19,308.7,51.8 -Cholamandalam Financial Holdings Ltd.,CHOLAHLDNG,504973,DIVERSIFIED,HOLDING COMPANIES,"6,372.2","2,495.1","3,404.8",54.05%,52.1,"2,209.4","1,215.8",324.6,420.9,22.4,"1,532.3",81.6 -Cochin Shipyard Ltd.,COCHINSHIP,540678,TRANSPORTATION,MARINE PORT & SERVICES,"1,100.4",820.5,191.2,18.90%,18.9,9.6,251.4,69.9,181.5,13.8,429.9,32.7 -Bharat Dynamics Ltd.,BDL,541143,GENERAL INDUSTRIALS,DEFENCE,694.1,481.8,134,21.77%,17.4,0.8,194.1,47,147.1,8,425.4,23.2 -Lux Industries Ltd.,LUXIND,539542,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,643.6,584.2,55,8.61%,5.9,5.4,48,12.1,37.1,12.3,103.1,32.9 -Zensar Technologies Ltd.,ZENSARTECH,504067,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,277.1","1,009.9",230.9,18.61%,36.6,5.7,224.9,51,173.9,7.7,525.8,23.2 -PCBL Ltd.,PCBL,506590,CHEMICALS & PETROCHEMICALS,CARBON BLACK,"1,489.4","1,248.6",238.1,16.02%,48.2,21,171.6,48.8,122.6,3.2,431.6,11.4 -Zydus Wellness Ltd.,ZYDUSWELL,531335,FMCG,PACKAGED FOODS,444,423.1,16.8,3.82%,5.8,6.5,8.6,2.7,5.9,0.9,281.2,44.2 -Linde India Ltd.,LINDEINDIA,523457,GENERAL INDUSTRIALS,INDUSTRIAL GASES,729.9,537.7,173.6,24.41%,49.7,1.2,141.3,34.6,108.7,12.8,417.9,49 -FDC Ltd.,FDC,531599,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,513.6,409.9,76.4,15.71%,9.9,1.1,92.7,22.9,69.8,4.2,251.2,15.4 -The New India Assurance Company Ltd.,NIACL,540769,BANKING AND FINANCE,GENERAL INSURANCE,"10,571","10,773.4",-246.5,-2.33%,0,0,-242,-46.7,-176.1,-1.1,947,5.7 -Sundaram Finance Ltd.,SUNDARMFIN,590071,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"1,710.6",322.5,"1,332.1",77.98%,43.6,820.3,470.6,142.8,365.4,33.2,"1,506.7",135.6 -TeamLease Services Ltd.,TEAMLEASE,539658,COMMERCIAL SERVICES & SUPPLIES,MISC. COMMERCIAL SERVICES,"2,285.6","2,240.8",31.8,1.40%,12.9,2.5,29.4,1.8,27.3,16.3,106.6,63.5 -Galaxy Surfactants Ltd.,GALAXYSURF,540935,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,985.8,858.2,124.9,12.70%,24.7,5.4,97.5,20.1,77.4,21.8,349.3,98.5 -Bandhan Bank Ltd.,BANDHANBNK,541153,BANKING AND FINANCE,BANKS,"5,032.2","1,400.2","1,583.4",35.25%,0,"2,048.6",947.2,226.1,721.2,4.5,"2,541.1",15.8 -ICICI Securities Ltd.,ISEC,541179,BANKING AND FINANCE,CAPITAL MARKETS,"1,249",433.5,810.2,64.87%,25.8,215.1,569.4,145.7,423.6,13.1,"1,238.1",38.3 -V-Mart Retail Ltd.,VMART,534976,RETAILING,DEPARTMENT STORES,551.4,548.8,0.7,0.12%,53.2,35.9,-86.4,-22.3,-64.1,-32.4,-103.1,-52.1 -Nippon Life India Asset Management Ltd.,NAM-INDIA,540767,BANKING AND FINANCE,ASSET MANAGEMENT COS.,475.4,156.1,241.4,60.73%,7.2,1.7,310.4,66.1,244.4,3.9,883.3,14.1 -Grindwell Norton Ltd.,GRINDWELL,506076,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,690,536,131.4,19.69%,16.9,1.8,135.3,33.1,101.9,9.2,378.3,34.2 -HDFC Life Insurance Company Ltd.,HDFCLIFE,540777,BANKING AND FINANCE,LIFE INSURANCE,"23,276.6","23,659.3",-508.1,-2.20%,0,0,-373.1,-657.5,378.2,1.8,"1,472.8",6.9 -Elgi Equipments Ltd.,ELGIEQUIP,522074,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,817.8,663.4,142.7,17.71%,18.7,6.6,129.2,38.8,91.3,2.9,401.9,12.7 -Hindustan Aeronautics Ltd.,HAL,541154,GENERAL INDUSTRIALS,DEFENCE,"6,105.1","4,108.1","1,527.6",27.11%,349.6,0.3,"1,647",414.8,"1,236.7",18.5,"6,037.3",90.3 -BSE Ltd.,BSE,BSE,BANKING AND FINANCE,EXCHANGE,367,172.8,189.2,52.26%,22.7,8.5,163,63.6,120.5,8.8,706,52.1 -Rites Ltd.,RITES,541556,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,608.8,444.5,137.8,23.67%,14.1,1.4,148.8,40.1,101.2,4.2,488.1,20.3 -Fortis Healthcare Ltd.,FORTIS,532843,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,783.5","1,439.8",330.2,18.65%,84.1,31.8,231.4,48.8,173.7,2.3,547.6,7.3 -Varroc Engineering Ltd.,VARROC,541578,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,893.5","1,692.6",194.3,10.30%,84.9,50.3,65.9,18.2,54.2,3.5,146.5,9.6 -Adani Green Energy Ltd.,ADANIGREEN,ASM,UTILITIES,ELECTRIC UTILITIES,"2,589",521,"1,699",76.53%,474,"1,165",413,119,372,2.2,"1,305",8.2 -VIP Industries Ltd.,VIPIND,507880,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,548.7,493.2,52.9,9.68%,23.8,12.4,19.3,6,13.3,0.9,110.9,7.8 -CreditAccess Grameen Ltd.,CREDITACC,541770,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"1,247.6",248.8,902.3,72.36%,12.3,423.9,466.8,119.7,347,21.8,"1,204.2",75.7 -CESC Ltd.,CESC,500084,UTILITIES,ELECTRIC UTILITIES,"4,414","3,706",646,14.84%,303,305,461,98,348,2.6,"1,447",10.9 -Jamna Auto Industries Ltd.,JAMNAAUTO,520051,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,608.7,528.2,79.1,13.03%,10.9,0.8,68.7,18.6,50.1,2.4,189.3,4.7 -Suprajit Engineering Ltd.,SUPRAJIT,532509,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,727.6,639.1,69.8,9.85%,25.7,13.6,49.2,14.5,34.8,2.5,146.9,10.6 -JK Paper Ltd.,JKPAPER,532162,COMMERCIAL SERVICES & SUPPLIES,PAPER & PAPER PRODUCTS,"1,708.8","1,242.8",407.3,24.68%,83.5,42,340.6,34.9,302.4,17.9,"1,220.6",72.1 -Bank of Maharashtra,MAHABANK,532525,BANKING AND FINANCE,BANKS,"5,735.5","1,179.4","1,920.5",37.90%,0,"2,635.7",935.7,16,919.8,1.3,"3,420.8",4.8 -Aavas Financiers Ltd.,AAVAS,541988,BANKING AND FINANCE,HOUSING FINANCE,497.6,123.5,367.8,74.03%,7.6,203.6,157.4,35.7,121.7,15.4,465.4,58.8 -HDFC Asset Management Company Ltd.,HDFCAMC,541729,BANKING AND FINANCE,ASSET MANAGEMENT COS.,765.4,162,481.1,74.81%,13,2.3,588.1,151.6,436.5,20.4,"1,659.3",77.7 -KEI Industries Ltd.,KEI,517569,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"1,954.2","1,742.7",203.9,10.47%,15.6,7.5,188.4,48.2,140.2,15.5,528.3,58.5 -Orient Electric Ltd.,ORIENTELEC,541301,CONSUMER DURABLES,CONSUMER ELECTRONICS,570.3,546.2,20.7,3.65%,14.2,5.2,23.4,4.9,18.4,0.9,95.3,4.5 -Deepak Nitrite Ltd.,DEEPAKNTR,506401,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"1,795.1","1,475.8",302.3,17.00%,39.4,2.7,277.2,72.1,205.1,15,797.9,58.5 -Fine Organic Industries Ltd.,FINEORG,541557,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,557.6,409.4,131.1,24.25%,14.4,0.7,133.1,28.9,103.4,33.7,458.8,149.6 -LTIMindtree Ltd.,LTIM,540005,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"9,048.6","7,274.1","1,631.3",18.32%,208.2,47,"1,519.3",357,"1,161.8",39.3,"4,427.5",149.6 -Dalmia Bharat Ltd.,DALBHARAT,542216,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"3,234","2,56",589,18.70%,401,101,172,48,118,6.3,"1,041",54.8 -Godfrey Phillips India Ltd.,GODFRYPHLP,500163,FOOD BEVERAGES & TOBACCO,CIGARETTES-TOBACCO PRODUCTS,"1,412.5","1,151",223.6,16.27%,36.5,6.6,218.5,55.5,202.1,38.9,802.9,154.4 -Vaibhav Global Ltd.,VAIBHAVGBL,532156,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,708.4,641.5,63.5,9.01%,22.6,2.9,41.4,12.4,29.4,1.8,121.3,7.3 -Abbott India Ltd.,ABBOTINDIA,500488,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,549.7","1,113.3",380.9,25.49%,17.8,3.1,415.4,102.5,312.9,147.3,"1,081.4",508.9 -Adani Total Gas Ltd.,ATGL,ASM,UTILITIES,UTILITIES,"1,104.8",815.7,279.9,25.55%,37.6,27.3,224.2,57.2,172.7,1.6,571,5.2 -Nestle India Ltd.,NESTLEIND,500790,FMCG,PACKAGED FOODS,"5,070.1","3,811.9","1,224.9",24.32%,111.2,31.4,"1,222",313.9,908.1,94.2,"2,971.1",308.2 -Bayer Cropscience Ltd.,BAYERCROP,506285,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,"1,633.3","1,312.3",304.9,18.85%,11.6,3.7,305.7,82.8,222.9,49.6,844.4,188.1 -Amber Enterprises India Ltd.,AMBER,540902,CONSUMER DURABLES,CONSUMER ELECTRONICS,939.8,867.5,59.6,6.43%,45.2,36.6,-9.5,-3.8,-6.9,-2.1,156.8,46.5 -Rail Vikas Nigam Ltd.,RVNL,542649,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"5,210.3","4,616",298.3,6.07%,6.2,132.7,455.4,85.2,394.3,1.9,"1,478.8",7.1 -Metropolis Healthcare Ltd.,METROPOLIS,542650,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,309.7,233.7,74.8,24.25%,22.2,5.7,48.1,12.5,35.5,6.9,133.4,26 -Polycab India Ltd.,POLYCAB,542652,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"4,253","3,608.8",608.9,14.44%,60.3,26.8,557.2,127.4,425.6,28.4,"1,607.2",107.1 -Multi Commodity Exchange of India Ltd.,MCX,534091,BANKING AND FINANCE,EXCHANGE,184,193.8,-28.7,-17.38%,6.6,0.1,-16.4,1.6,-19.1,-3.7,44.8,8.8 -IIFL Finance Ltd.,IIFL,532636,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,"2,533.7",788.3,"1,600.8",64.66%,43.3,932.1,683.5,158,474.3,12.4,"1,690.7",44.4 -Ratnamani Metals & Tubes Ltd.,RATNAMANI,520111,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"1,141.9",886.3,244.9,21.65%,23.6,10.8,221.1,56.8,163.9,23.4,622.6,88.8 -RHI Magnesita India Ltd.,RHIM,534076,GENERAL INDUSTRIALS,OTHER INDUSTRIAL GOODS,989.7,839,147.9,14.98%,44.2,8.5,97.9,26.3,71.3,3.5,-502.2,-24.3 -Birlasoft Ltd.,BSOFT,532400,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,325.4","1,102.7",207.1,15.81%,21.5,5.7,195.5,50.4,145.1,5.2,378.4,13.7 -EIH Ltd.,EIHOTEL,500840,HOTELS RESTAURANTS & TOURISM,HOTELS,552.5,387.6,142.9,26.94%,33.2,5.6,126.1,36.2,93.1,1.5,424.1,6.8 -Affle (India) Ltd.,AFFLE,542752,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,441.2,344.1,87.2,20.22%,18.4,5.5,73.2,6.4,66.8,5,264.3,19.8 -Westlife Foodworld Ltd.,WESTLIFE,505533,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,618,516.5,98.2,15.98%,43.9,27.4,30.2,7.8,22.4,1.4,107.7,6.9 -IndiaMART InterMESH Ltd.,INDIAMART,542726,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,329.3,214.7,80,27.15%,8,2.3,104.3,23.9,69.4,11.4,321.1,53.6 -Infosys Ltd.,INFY,500209,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"39,626","29,554","9,44",24.21%,"1,166",138,"8,768","2,553","6,212",15,"24,871",60.1 -Sterling and Wilson Renewable Energy Ltd.,SWSOLAR,542760,COMMERCIAL SERVICES & SUPPLIES,CONSULTING SERVICES,776.7,758,1.5,0.19%,4.3,64.3,-50,4.6,-54.2,-2.9,-668.4,-35.2 -ABB India Ltd.,ABB,500002,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,846","2,330.7",438.5,15.84%,30.3,0.9,484.2,122.2,362.9,17.1,"1,208.7",57 -Poly Medicure Ltd.,POLYMED,531768,HEALTHCARE EQUIPMENT & SUPPLIES,HEALTHCARE SUPPLIES,351.4,253.1,84.2,24.97%,16,2.2,80.9,18.8,62.2,6.5,233.7,24.4 -GMM Pfaudler Ltd.,GMMPFAUDLR,505255,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,946,795.5,142,15.15%,32.2,21.5,96.8,26.5,71.1,15.8,183.2,40.8 -Gujarat Fluorochemicals Ltd.,FLUOROCHEM,542812,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,960.3,783.7,163.1,17.23%,67.5,34.2,74.8,22.1,52.7,4.8,915.2,83.3 -360 One Wam Ltd.,360ONE,542772,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,617.1,235.6,317.8,57.31%,13.7,139.9,226.8,40.8,186,5.2,696.8,19.5 -Tata Communications Ltd.,TATACOMM,500483,TELECOM SERVICES,OTHER TELECOM SERVICES,"4,897.9","3,857.1","1,015.5",20.84%,605.1,137.4,298.3,77.9,220.7,7.7,"1,322.3",46.4 -Alkyl Amines Chemicals Ltd.,ALKYLAMINE,506767,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,354.5,303.9,48.3,13.71%,12.5,1.7,36.4,9.2,27.2,5.3,171.3,33.5 -CSB Bank Ltd.,CSBBANK,542867,BANKING AND FINANCE,BANKS,835.8,317.5,174.6,25.41%,0,343.6,178,44.8,133.2,7.7,577.7,33.3 -Indian Railway Catering & Tourism Corporation Ltd.,IRCTC,542830,DIVERSIFIED CONSUMER SERVICES,TRAVEL SUPPORT SERVICES,"1,042.4",628.8,366.6,36.83%,14,4.4,395.2,100.5,294.7,3.7,"1,061.2",13.3 -Sumitomo Chemical India Ltd.,SUMICHEM,542920,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,928,715.5,187.9,20.80%,15.8,1.2,195.5,52,143.4,2.9,367.7,7.4 -Century Textiles & Industries Ltd.,CENTURYTEX,500040,COMMERCIAL SERVICES & SUPPLIES,PAPER & PAPER PRODUCTS,"1,114.9","1,069.2",33.8,3.07%,59.2,17,-30.5,-3.3,-30.4,-2.8,117.7,10.5 -SBI Cards and Payment Services Ltd.,SBICARD,543066,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"4,221.4","2,018.8","1,327",32.47%,46.8,604.9,809.4,206.4,603,6.4,"2,302.2",24.3 -Hitachi Energy India Ltd.,POWERINDIA,543187,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"1,228.2","1,162.6",65.3,5.32%,22.5,10.7,32.4,7.6,24.7,5.8,82.5,19.5 -Suven Pharmaceuticals Ltd.,SUVENPHAR,543064,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,250.9,133.1,98,42.40%,11.9,0.5,105.4,25.8,79.6,3.1,431.8,17 -Tata Chemicals Ltd.,TATACHEM,500770,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"4,083","3,179",819,20.49%,234,145,627,120,428,16.8,"2,06",80.8 -Aarti Drugs Ltd.,AARTIDRUGS,524348,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,642.2,565.1,76.4,11.92%,12.6,8.2,56.3,16.7,39.6,4.3,180.2,19.6 -Gujarat Ambuja Exports Ltd.,GAEL,524226,FMCG,EDIBLE OILS,"1,157.7","1,012.2",103.3,9.26%,30.5,5.9,109.1,26.3,82.8,3.6,305.1,13.3 -Polyplex Corporation Ltd.,POLYPLEX,524051,COMMERCIAL SERVICES & SUPPLIES,CONTAINERS & PACKAGING,"1,595.7","1,451.5",120.6,7.67%,75.1,9.9,59.1,10.9,27.9,8.9,71.1,22.6 -Chalet Hotels Ltd.,CHALET,542399,HOTELS RESTAURANTS & TOURISM,HOTELS,318.2,188.6,126,40.04%,35,50.1,44.5,8,36.4,1.8,266.7,13 -Adani Enterprises Ltd.,ADANIENT,512599,COMMERCIAL SERVICES & SUPPLIES,COMMODITY TRADING & DISTRIBUTION,"23,066","20,087.2","2,430.1",10.79%,757,"1,342.8",791,397.8,227.8,2,"2,444.3",21.4 -YES Bank Ltd.,YESBANK,532648,BANKING AND FINANCE,BANKS,"7,980.6","2,377.1",810,12.06%,0,"4,793.6",304.4,75.7,228.6,0.1,836.6,0.3 -EPL Ltd.,EPL,500135,COMMERCIAL SERVICES & SUPPLIES,CONTAINERS & PACKAGING,"1,011.2",820.6,181,18.07%,83.6,30.6,76.4,25.4,50.5,1.6,251.9,7.9 -Network18 Media & Investments Ltd.,NETWORK18,532798,MEDIA,BROADCASTING & CABLE TV,"2,052.2","2,083.8",-218.3,-11.70%,56.8,66.2,-154.5,-6.5,-61,-0.6,-144.2,-1.4 -CIE Automotive India Ltd.,CIEINDIA,532756,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,299.4","1,934",345.4,15.15%,78.3,31,256.1,69.1,375.4,9.9,298.4,7.9 -Vedanta Ltd.,VEDL,500295,METALS & MINING,ALUMINIUM AND ALUMINIUM PRODUCTS,"39,585","27,466","11,479",29.47%,"2,642","2,523","8,177","9,092","-1,783",-4.8,"5,202",14 -Rossari Biotech Ltd.,ROSSARI,543213,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,484.8,419.9,63.6,13.15%,15.1,5,44.8,11.9,32.9,6,116.8,21.2 -KPIT Technologies Ltd.,KPITTECH,542651,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,"1,208.6",959.2,239.9,20.01%,48.1,13.6,187.7,46.3,140.9,5.2,486.9,18 -Intellect Design Arena Ltd.,INTELLECT,538835,SOFTWARE & SERVICES,IT SOFTWARE PRODUCTS,631.7,497.2,121.9,19.69%,33.7,0.8,96.5,25.7,70.4,5.2,316.6,23.2 -Balaji Amines Ltd.,BALAMINES,530999,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,387.3,326.8,53.8,14.13%,10.8,1.8,48,11.6,34.7,10.7,197.3,60.9 -UTI Asset Management Company Ltd.,UTIAMC,543238,BANKING AND FINANCE,ASSET MANAGEMENT COS.,405.6,172.5,231.5,57.30%,10.4,2.8,219.8,37,182.8,14.4,562.9,44.3 -Mazagon Dock Shipbuilders Ltd.,MAZDOCK,543237,TRANSPORTATION,SHIPPING,"2,079.2","1,651.1",176.6,9.66%,20.2,1.3,406.6,102.8,332.9,16.5,"1,327.6",65.8 -Computer Age Management Services Ltd.,CAMS,543232,BANKING AND FINANCE,CAPITAL MARKETS,284.7,153,122.1,44.39%,17.4,2,112.4,28.6,84.5,17.2,309.2,62.9 -Happiest Minds Technologies Ltd.,HAPPSTMNDS,543227,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,428.8,324,82.6,20.32%,14.6,11.2,79.1,20.7,58.5,3.9,232,15.6 -Triveni Turbine Ltd.,TRITURBINE,533655,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,402.3,313.4,74.3,19.17%,5.1,0.6,83.2,19,64.2,2,233.1,7.3 -Angel One Ltd.,ANGELONE,ASM,BANKING AND FINANCE,CAPITAL MARKETS,"1,049.3",602.6,443.4,42.31%,11.2,26.4,407.2,102.7,304.5,36.3,"1,020.2",121.7 -Tanla Platforms Ltd.,TANLA,532790,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,014.9",811.8,196.8,19.51%,22.6,1.8,178.7,36.2,142.5,10.6,514.7,38.3 -Max Healthcare Institute Ltd.,MAXHEALTH,543220,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,"1,408.6",975.8,387.4,28.42%,57.9,8.5,366.4,89.7,276.7,2.9,990.1,10.2 -Asahi India Glass Ltd.,ASAHIINDIA,515030,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,122.6",934,185.6,16.58%,43,34.4,111.3,30.2,86.9,3.6,343.5,14.1 -Prince Pipes & Fittings Ltd.,PRINCEPIPE,542907,GENERAL INDUSTRIALS,PLASTIC PRODUCTS,660.4,562.3,94.2,14.35%,22.5,0.7,92.8,22.2,70.6,5.2,219.8,19.9 -Route Mobile Ltd.,ROUTE,543228,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,018.3",886.5,128.1,12.63%,21.4,6.5,103.8,15.5,88.8,14.2,365.3,58.3 -KPR Mill Ltd.,KPRMILL,532889,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,533","1,212.9",298,19.72%,46,18.1,256,54.2,201.8,5.9,788.8,23.1 -Infibeam Avenues Ltd.,INFIBEAM,539807,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,792.6,719.7,70.2,8.89%,17.1,0.5,55.2,14.7,41,0.1,142.2,0.5 -Restaurant Brands Asia Ltd.,RBA,543248,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,628.2,568.7,56.2,9.00%,78.6,31.5,-50.7,0,-46,-0.9,-220.3,-4.5 -Larsen & Toubro Ltd.,LT,500510,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"52,157","45,392.1","5,632",11.04%,909.9,864,"4,991.1","1,135.5","3,222.6",22.9,"12,255.3",89.2 -Gland Pharma Ltd.,GLAND,543245,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,426.6","1,049.3",324.1,23.60%,81.3,6,289.9,95.8,194.1,11.8,698.8,42.4 -Macrotech Developers Ltd.,LODHA,543287,REALTY,REALTY,"1,755.1","1,333.5",416.1,23.78%,29.3,123.1,269.2,62.4,201.9,2.1,"1,529.2",15.9 -Poonawalla Fincorp Ltd.,POONAWALLA,524000,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),745.3,178.9,531.7,71.98%,14.7,215.5,"1,124.6",270,860.2,11.2,"1,466.4",19.1 -The Fertilisers and Chemicals Travancore Ltd.,FACT,590024,FERTILIZERS,FERTILIZERS,"1,713.6","1,530.8",132.4,7.96%,5.3,61.2,105.2,0,105.2,1.6,508.4,7.9 -Home First Finance Company India Ltd.,HOMEFIRST,543259,BANKING AND FINANCE,HOUSING FINANCE,278,53.7,211.6,77.43%,2.8,117,96.4,22.1,74.3,8.4,266.2,30.2 -CG Power and Industrial Solutions Ltd.,CGPOWER,500093,GENERAL INDUSTRIALS,HEAVY ELECTRICAL EQUIPMENT,"2,019","1,692.9",308.6,15.42%,22.9,0.4,329.9,86.2,242.3,1.6,"1,1",7.2 -Laxmi Organic Industries Ltd.,LXCHEM,543277,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,660.5,613.3,38.9,5.97%,27.5,2.1,17.5,6.8,10.7,0.4,100.6,3.8 -Anupam Rasayan India Ltd.,ANURAS,543275,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,395.6,284.7,107.5,27.41%,19.8,20.4,70.7,22,40.7,3.8,178.9,16.6 -Kalyan Jewellers India Ltd.,KALYANKJIL,ASM,TEXTILES APPARELS & ACCESSORIES,GEMS & JEWELLERY,"4,427.7","4,100.9",313.7,7.11%,66.9,81.7,178.1,43.3,135.2,1.3,497.9,4.8 -Jubilant Pharmova Ltd.,JUBLPHARMA,530019,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,690.2","1,438.5",241.8,14.39%,96.6,66.1,89,35.9,62.5,3.9,-44.6,-2.8 -Indigo Paints Ltd.,INDIGOPNTS,543258,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,273.4,228.7,41.8,15.45%,10,0.5,34.3,8.2,26.1,5.5,132.4,27.8 -Indian Railway Finance Corporation Ltd.,IRFC,543257,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"6,767.5",33.5,"6,732.4",99.50%,2.1,"5,181.5","1,549.9",0,"1,549.9",1.2,"6,067.6",4.6 -Mastek Ltd.,MASTEK,523704,SOFTWARE & SERVICES,IT CONSULTING & SOFTWARE,770.4,642.5,123,16.07%,20.9,12.6,90.3,25,62.8,20.5,269.7,88 -Equitas Small Finance Bank Ltd.,EQUITASBNK,543243,BANKING AND FINANCE,BANKS,"1,540.4",616.8,330.2,24.30%,0,593.4,267,68.9,198.1,1.8,749.5,6.7 -Tata Teleservices (Maharashtra) Ltd.,TTML,532371,TELECOM SERVICES,TELECOM SERVICES,288.6,159.3,127.5,44.45%,36.3,403.2,-310.2,0,-310.2,-1.6,"-1,168.3",-6 -Praj Industries Ltd.,PRAJIND,522205,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,893.3,798.4,84,9.52%,9.1,1,84.8,22.4,62.4,3.4,271.4,14.8 -Nazara Technologies Ltd.,NAZARA,543280,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,309.5,269.4,26.7,8.98%,15.1,2.7,21.2,-1.3,19.8,3,60,9.1 -Jubilant Ingrevia Ltd.,JUBLINGREA,543271,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,028.5",902.3,117.7,11.54%,33.9,12.5,79.8,22.4,57.5,3.6,258.9,16.4 -Sona BLW Precision Forgings Ltd.,SONACOMS,543300,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,796.9,567.5,223.3,28.24%,53.4,6,164.1,40.1,123.8,2.1,462.8,7.9 -Chemplast Sanmar Ltd.,CHEMPLASTS,543336,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,025",941.8,46,4.65%,35.3,38.6,9.2,-16.8,26.1,1.6,35.3,2.2 -Aptus Value Housing Finance India Ltd.,APTUS,543335,BANKING AND FINANCE,HOUSING FINANCE,344.5,50.6,277.5,83.18%,2.6,96.1,189.6,41.5,148,3,551.1,11.1 -Clean Science & Technology Ltd.,CLEAN,543318,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,187.1,106.3,74.8,41.32%,11.1,0.3,69.5,17.3,52.2,4.9,275.5,25.9 -Medplus Health Services Ltd.,MEDPLUS,543427,HEALTHCARE EQUIPMENT & SUPPLIES,HEALTHCARE SUPPLIES,"1,419","1,323.5",85.1,6.04%,55.5,23.5,16.4,1.9,14.6,1.2,58.3,4.9 -Nuvoco Vistas Corporation Ltd.,NUVOCO,543334,CEMENT AND CONSTRUCTION,CEMENT & CEMENT PRODUCTS,"2,578.9","2,243",329.9,12.82%,225.6,139.9,-29.6,-31.1,1.5,0,141.8,4 -Star Health and Allied Insurance Company Ltd.,STARHEALTH,543412,BANKING AND FINANCE,GENERAL INSURANCE,"3,463.2","3,295.8",165.7,4.79%,0,0,167.1,41.8,125.3,2.1,725.4,12.4 -Go Fashion (India) Ltd.,GOCOLORS,543401,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,192.8,132.2,56.6,29.98%,25.8,8.9,25.8,5.7,20,3.7,85.4,15.8 -PB Fintech Ltd.,POLICYBZR,543390,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,909.1,900.7,-89.1,-10.98%,22.3,7.2,-21.1,-0.3,-20.2,-0.5,-127.9,-2.8 -FSN E-Commerce Ventures Ltd.,NYKAA,543384,SOFTWARE & SERVICES,INTERNET & CATALOGUE RETAIL,"1,515.6","1,426.4",80.6,5.35%,54.6,21.3,13.3,4,5.8,0,19.8,0.1 -Krishna Institute of Medical Sciences Ltd.,KIMS,543308,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,655.4,475.2,177.3,27.17%,32.6,8.9,138.6,37.3,92,11.5,342.1,42.7 -Zomato Ltd.,ZOMATO,543320,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"3,06","2,895",-47,-1.65%,128,16,21,-15,36,0,-496.8,-0.6 -Brightcom Group Ltd.,BCG,532368,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"1,690.5","1,172.3",518,30.65%,72.3,0.1,445.8,124.3,321.5,1.6,"1,415.2",7 -Shyam Metalics and Energy Ltd.,SHYAMMETL,543299,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"2,978.9","2,633.6",307.1,10.44%,176.5,35.4,133.4,-348.6,484.1,18.9,"1,049.9",41.2 -G R Infraprojects Ltd.,GRINFRA,543317,CEMENT AND CONSTRUCTION,ROADS & HIGHWAYS,"1,909.2","1,415.7",467.1,24.81%,61.7,144.6,287.1,69.9,217.2,22.5,"1,240.3",128.3 -RattanIndia Enterprises Ltd.,RTNINDIA,534597,UTILITIES,ELECTRIC UTILITIES,"1,618.1","1,392.8",1.5,0.11%,4.3,28.8,142.2,1.7,140.9,1,147.6,1.1 -Borosil Renewables Ltd.,BORORENEW,502219,CONSUMER DURABLES,HOUSEWARE,406.3,369.2,32.5,8.09%,31,9.6,28.9,-1.1,25.1,1.9,32.1,2.5 -HLE Glascoat Ltd.,HLEGLAS,522215,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,227.8,198,26.5,11.79%,6.1,5.8,16.1,5.3,10,1.6,54.4,8 -Tata Investment Corporation Ltd.,TATAINVEST,501301,DIVERSIFIED,HOLDING COMPANIES,125,10.1,113.8,91.88%,0.2,4.7,110.1,-1.3,124.4,24.6,326.1,64.4 -Sapphire Foods India Ltd.,SAPPHIRE,543397,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,650.1,527.5,115.1,17.91%,76.8,24.5,21.4,6.2,15.3,2.4,208.5,32.7 -Devyani International Ltd.,DEVYANI,543330,HOTELS RESTAURANTS & TOURISM,RESTAURANTS,826,665,154.4,18.84%,86.3,41.7,19,-16.8,33.4,0.3,177.5,1.5 -Vijaya Diagnostic Centre Ltd.,VIJAYA,543350,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE SERVICES,145.6,81.5,57.4,41.31%,13.7,5.9,44.6,11,33.3,3.3,103.4,10.1 -C.E. Info Systems Ltd.,MAPMYINDIA,543425,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,99.3,50.1,41,44.98%,3.7,0.7,44.7,11.1,33,6.1,122.9,22.7 -Latent View Analytics Ltd.,LATENTVIEW,543398,SOFTWARE & SERVICES,DATA PROCESSING SERVICES,172.7,124.9,30.8,19.78%,2.3,0.8,44.7,10.6,34,1.7,153.6,7.5 -Metro Brands Ltd.,METROBRAND,543426,RETAILING,FOOTWEAR,571.9,400.3,155.4,27.96%,57.2,19.7,94.7,27.5,66.7,2.5,340,12.5 -Easy Trip Planners Ltd.,EASEMYTRIP,543272,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,144.6,76.9,64.8,45.71%,1,2,64.7,17.7,47.2,0.3,146,0.8 -Shree Renuka Sugars Ltd.,RENUKA,532670,FOOD BEVERAGES & TOBACCO,SUGAR,"2,564.7","2,491",63.7,2.49%,64.1,216.8,-207.2,-1.6,-204.9,-1,-286,-1.3 -One97 Communications Ltd.,PAYTM,543396,SOFTWARE & SERVICES,INTERNET SOFTWARE & SERVICES,"2,662.5","2,749.6",-231,-9.17%,180.1,7,-279.9,12.7,-290.5,-5,"-1,207.9",-19 -MTAR Technologies Ltd.,MTARTECH,543270,GENERAL INDUSTRIALS,DEFENCE,167.7,130.7,36.1,21.64%,5.8,5.5,25.7,5.2,20.5,6.7,103.3,33.6 -Capri Global Capital Ltd.,CGCL,531595,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),557.4,229.3,304.8,54.70%,23.1,195.8,86,20.8,65.2,3.2,231.2,11.2 -GMR Airports Infrastructure Ltd.,GMRINFRA,ASM,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"2,185","1,336.8",726.7,35.22%,373,695.8,-252,54.9,-91,-0.1,-370.9,-0.6 -Triveni Engineering & Industries Ltd.,TRIVENI,532356,FOOD BEVERAGES & TOBACCO,SUGAR,"1,629.7","1,554.5",62.9,3.89%,25.8,10.2,39.3,10.1,29.1,1.3,434.3,19.8 -Delhivery Ltd.,DELHIVERY,543529,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"2,043","1,957.3",-15.6,-0.80%,171.2,19.6,-105.2,-2.1,-102.9,-1.4,-546.7,-7.5 -Life Insurance Corporation of India,LICI,543526,BANKING AND FINANCE,LIFE INSURANCE,"202,394.9","193,612.5","8,445",4.18%,0,0,"8,696.5","1,083.9","8,030.3",12.7,"37,204.8",58.8 -Campus Activewear Ltd.,CAMPUS,543523,RETAILING,FOOTWEAR,259.1,234.2,24.5,9.46%,18.1,6.5,0.4,0.1,0.3,0,103.1,3.4 -Motherson Sumi Wiring India Ltd.,MSUMI,543498,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"2,110.2","1,856.5",248.1,11.79%,36.4,7.4,210,54.1,155.9,0.3,523.6,1.2 -Olectra Greentech Ltd.,OLECTRA,532439,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,310.3,266.6,40.5,13.20%,8.8,9.7,25.2,8,18.6,2.2,78.5,9.6 -Patanjali Foods Ltd.,PATANJALI,500368,FMCG,EDIBLE OILS,"7,845.8","7,426.6",395.3,5.05%,60.1,24,335.1,80.5,254.5,7,875.2,24.2 -Raymond Ltd.,RAYMOND,500330,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"2,320.7","1,938.8",314.6,13.96%,65.4,89.3,204.2,50.7,159.8,24,"1,514.2",227.5 -Swan Energy Ltd.,SWANENERGY,503310,REALTY,REALTY,"1,230.1",966.3,257,21.01%,27.1,58.3,178.4,12.8,84.6,6.7,308.4,11.7 -Samvardhana Motherson International Ltd.,MOTHERSON,517334,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"23,639.2","21,585","1,888.8",8.05%,867.4,487.9,449.5,229.2,201.6,0.3,"1,910.3",2.8 -Vedant Fashions Ltd.,MANYAVAR,543463,RETAILING,SPECIALTY RETAIL,233.4,125.5,92.8,42.51%,32.5,10.7,64.8,16.1,48.7,2,399.9,16.5 -Adani Wilmar Ltd.,AWL,543458,FMCG,EDIBLE OILS,"12,331.2","12,123.5",143.7,1.17%,95.7,220.2,-161.8,-31.5,-130.7,-1,130.1,1 -Mahindra Lifespace Developers Ltd.,MAHLIFE,532313,REALTY,REALTY,25.7,52.7,-34.9,-196.45%,3.1,0.2,-30.3,-10.8,-18.9,-1.2,10.5,0.7 -Tejas Networks Ltd.,TEJASNET,540595,TELECOM SERVICES,OTHER TELECOM SERVICES,413.9,383,13,3.28%,41.7,7,-17.7,-5.1,-12.6,-0.7,-61.3,-3.5 -Aether Industries Ltd.,AETHER,543534,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,178.3,118.2,46,28.00%,9.7,1.6,48.7,12.1,36.7,2.8,139.1,10.5 -JBM Auto Ltd.,JBMA,ASM,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,238.8","1,091.3",139.7,11.35%,41.2,47.9,58.3,11.3,44.2,3.7,136.8,11.6 -Deepak Fertilisers & Petrochemicals Corporation Ltd.,DEEPAKFERT,500645,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,"2,443.2","2,138.1",286.1,11.80%,81.2,107.1,116.8,53.3,60.1,4.8,674.5,53.4 -Sharda Cropchem Ltd.,SHARDACROP,538666,CHEMICALS & PETROCHEMICALS,AGROCHEMICALS,604.3,559.6,21.2,3.65%,74,4.6,-33.8,-6.3,-27.6,-3.1,191,21.2 -Shoppers Stop Ltd.,SHOPERSTOP,532638,RETAILING,DEPARTMENT STORES,"1,049.7",878.2,160.9,15.49%,108.2,54.9,3.5,0.8,2.7,0.2,94.2,8.6 -BEML Ltd.,BEML,500048,AUTOMOBILES & AUTO COMPONENTS,COMMERCIAL VEHICLES,924,855.3,61.5,6.70%,15.8,10.8,42.2,-9.6,51.8,12.4,200.8,48.2 -Lemon Tree Hotels Ltd.,LEMONTREE,541233,HOTELS RESTAURANTS & TOURISM,HOTELS,230.1,125.3,101.9,44.84%,22.6,47.3,34.8,8.6,22.6,0.3,130.1,1.6 -Rainbow Childrens Medicare Ltd.,RAINBOW,543524,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,340.5,215.1,117.6,35.34%,26.8,13.3,85.2,22.1,62.9,6.2,215.4,21.2 -UCO Bank,UCOBANK,532505,BANKING AND FINANCE,BANKS,"5,865.6","1,581.5",981.9,18.81%,0,"3,302.3",639.8,238.1,403.5,0.3,"1,84",1.5 -Piramal Pharma Ltd.,PPLPHARMA,543635,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"1,960.6","1,645.7",265.6,13.90%,184.5,109.9,20.4,34.5,5,0,-133.6,-1 -KSB Ltd.,KSB,500249,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,572.2,493.4,70.3,12.47%,12.3,2,64.5,17.1,50.1,14.4,209.7,60.3 -Data Patterns (India) Ltd.,DATAPATTNS,543428,GENERAL INDUSTRIALS,DEFENCE,119.2,67.5,40.8,37.63%,3.1,2.3,46.3,12.5,33.8,6,148.3,26.5 -Global Health Ltd.,MEDANTA,543654,DIVERSIFIED CONSUMER SERVICES,HEALTHCARE FACILITIES,864.7,631.1,212.9,25.22%,42.9,20.1,170.6,45.4,125.2,4.7,408.9,15.2 -Aarti Industries Ltd.,AARTIIND,524208,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,"1,454","1,221.2",232.8,16.01%,93,58.2,81.6,-9.1,90.7,2.5,446.2,12.3 -BLS International Services Ltd.,BLS,540073,DIVERSIFIED CONSUMER SERVICES,TRAVEL SUPPORT SERVICES,416.4,321,86.7,21.27%,7.3,1,87.2,5.2,78.7,1.9,267.6,6.5 -Archean Chemical Industries Ltd.,ACI,543657,CHEMICALS & PETROCHEMICALS,COMMODITY CHEMICALS,301.7,195,95.5,32.86%,17.5,1.9,87.3,21.3,66,5.4,394.4,32.1 -Adani Power Ltd.,ADANIPOWER,ASM,UTILITIES,ELECTRIC UTILITIES,"14,935.7","7,819.2","5,171.4",39.81%,"1,004.5",888.4,"5,223.6","-1,370.6","6,594.2",16.5,"20,604.8",53.4 -Craftsman Automation Ltd.,CRAFTSMAN,543276,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,183.8",941.6,237.5,20.14%,66.8,41.6,133.8,29.6,94.5,44.1,298.3,141.2 -NMDC Ltd.,NMDC,526371,METALS & MINING,MINING,"4,335","2,823.6","1,190.4",29.66%,88.8,18.6,"1,404.1",379,"1,026.2",3.5,"5,862.2",20 -Epigral Ltd.,EPIGRAL,543332,CHEMICALS & PETROCHEMICALS,SPECIALTY CHEMICALS,479.1,370.2,107.9,22.57%,31.5,21.3,56.1,17.9,38,9.1,223.4,53.8 -Apar Industries Ltd.,APARINDS,532259,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,"3,944.7","3,576.2",349.8,8.91%,28.2,103.1,237.3,62.9,173.9,45.4,783.9,204.8 -Bikaji Foods International Ltd.,BIKAJI,543653,FMCG,PACKAGED FOODS,614.7,521,87.7,14.41%,15.6,2.9,75.2,15.4,61.2,2.5,173.6,6.9 -Five-Star Business Finance Ltd.,FIVESTAR,543663,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),522.4,133.2,375,72.28%,5.7,105.9,267,67.6,199.4,6.8,703,24.1 -Ingersoll-Rand (India) Ltd.,INGERRAND,500210,GENERAL INDUSTRIALS,INDUSTRIAL MACHINERY,282.8,210.7,65.7,23.76%,4.6,0.6,67,17.2,49.7,15.8,218.5,69.2 -KFIN Technologies Ltd.,KFINTECH,543720,BANKING AND FINANCE,OTHER FINANCIAL SERVICES,215.3,115.3,93.7,44.82%,12.6,3.2,84.2,22.3,61.4,3.6,215.1,12.6 -Piramal Enterprises Ltd.,PEL,500302,BANKING AND FINANCE,FINANCE (INCLUDING NBFCS),"2,205.2","1,320.1","1,117.9",50.97%,38.3,"1,038.9",-11.8,10.7,48.2,2,"3,906.5",173.9 -NMDC Steel Ltd.,NSLNISP,543768,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,290.3,349.6,-72.2,-26.04%,74.5,40.8,-174.7,-43.6,-131.1,-0.5,, -Eris Lifesciences Ltd.,ERIS,540596,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,508.8,324.2,181.1,35.85%,42.1,16.3,126.2,3.9,123.4,9.1,385.6,28.3 -Mankind Pharma Ltd.,MANKIND,543904,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,"2,768.1","2,025.5",682.6,25.21%,96.5,8.6,637.5,129.8,501,12.5,"1,564.8",39.1 -Kaynes Technology India Ltd.,KAYNES,ASM,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,369.8,312.1,48.8,13.52%,6.5,11.8,39.4,7.1,32.3,5.5,143.2,24.6 -Safari Industries (India) Ltd.,SAFARI,523025,TEXTILES APPARELS & ACCESSORIES,OTHER APPARELS & ACCESSORIES,372.9,306.6,63.5,17.15%,12.2,2.2,51.9,12.1,39.8,16.7,162.3,68.2 -Saregama India Ltd.,SAREGAMA,532163,MEDIA,MOVIES & ENTERTAINMENT,185.6,111.5,60.9,35.32%,8.2,0.2,65.6,17.6,48.1,2.5,193.4,10 -Syrma SGS Technology Ltd.,SYRMA,543573,CONSUMER DURABLES,OTHER ELECTRICAL EQUIPMENT/PRODUCTS,720.6,662.7,49,6.88%,11.6,8,37,6.4,28.3,1.6,132.4,7.5 -Jindal Saw Ltd.,JINDALSAW,ASM,GENERAL INDUSTRIALS,OTHER INDUSTRIAL PRODUCTS,"5,488.9","4,662",804.2,14.71%,142.5,188.7,495.6,139.6,375.7,11.8,"1,135.8",35.5 -Godawari Power & Ispat Ltd.,GPIL,532734,METALS & MINING,IRON & STEEL/INTERM.PRODUCTS,"1,314.2",929.6,361.4,28.00%,34.8,10.2,339.6,86.1,256.9,20.6,785.5,63 -Gillette India Ltd.,GILLETTE,507815,FMCG,PERSONAL PRODUCTS,676.2,530.8,136.7,20.48%,20.1,0.1,125.2,32.5,92.7,28.4,361.6,111 -Symphony Ltd.,SYMPHONY,517385,CONSUMER DURABLES,CONSUMER ELECTRONICS,286,234,41,14.91%,7,2,43,8,35,5.1,114,16.5 -Glenmark Life Sciences Ltd.,GLS,543322,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,600.7,428.3,167.1,28.06%,13.1,0.4,158.9,40.2,118.7,9.7,505.5,41.3 -Usha Martin Ltd.,USHAMART,517146,METALS & MINING,IRON & STEEL PRODUCTS,806,640.4,144.3,18.39%,18,6.4,141.2,35,109.5,3.6,399.4,13.1 -Ircon International Ltd.,IRCON,541956,CEMENT AND CONSTRUCTION,CONSTRUCTION & ENGINEERING,"3,136.3","2,771.2",215.7,7.22%,27.1,36.9,301.2,77.6,250.7,2.7,884.6,9.4 -Ujjivan Small Finance Bank Ltd.,UJJIVANSFB,542904,BANKING AND FINANCE,BANKS,"1,579.8",528.6,483.4,34.75%,0,567.8,436.4,108.7,327.7,1.7,"1,254.5",6.4 -Procter & Gamble Health Ltd.,PGHL,500126,PHARMACEUTICALS & BIOTECHNOLOGY,PHARMACEUTICALS,311,216.3,88.7,29.08%,6.5,0.2,88,22.5,65.6,39.5,231.4,139.4 -Allcargo Logistics Ltd.,ALLCARGO,532749,TRANSPORTATION,TRANSPORTATION - LOGISTICS,"3,336.3","3,188.8",118,3.57%,106.7,36.7,14.2,1.3,21.8,0.9,361.9,14.7 -Sheela Foam Ltd.,SFL,540203,DIVERSIFIED CONSUMER SERVICES,FURNITURE-FURNISHING-PAINTS,637.6,547,66.2,10.80%,21.9,8.6,60.2,15.6,44,4.5,192.4,17.7 -Alok Industries Ltd.,ALOKINDS,521070,TEXTILES APPARELS & ACCESSORIES,TEXTILES,"1,369.3","1,323.1",35.9,2.64%,78.6,142.2,-174.6,0,-174.8,-0.3,-948.4,-1.9 -Minda Corporation Ltd.,MINDACORP,538962,AUTOMOBILES & AUTO COMPONENTS,AUTO PARTS & EQUIPMENT,"1,197.9","1,064.5",131.3,10.98%,41.4,14.9,77,18.7,58.8,2.5,278.2,11.6 -Concord Biotech Ltd.,CONCORDBIO,543960,PHARMACEUTICALS & BIOTECHNOLOGY,BIOTECHNOLOGY,270.5,143.2,119.2,45.43%,13.3,0.8,113.2,28.7,81,7.7,, \ No newline at end of file diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/sampleFileForUpload.txt b/sdk/ai/ai-projects/samples/v1-beta/typescript/data/sampleFileForUpload.txt deleted file mode 100644 index ab553b3304c1..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/sampleFileForUpload.txt +++ /dev/null @@ -1 +0,0 @@ -The word 'apple' uses the code 442345, while the word 'banana' uses the code 673457. diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/weatherOpenApi.json b/sdk/ai/ai-projects/samples/v1-beta/typescript/data/weatherOpenApi.json deleted file mode 100644 index df0192590adb..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/data/weatherOpenApi.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "openapi": "3.1.0", - "info": { - "title": "get weather data", - "description": "Retrieves current weather data for a location based on wttr.in.", - "version": "v1.0.0" - }, - "servers": [ - { - "url": "https://wttr.in" - } - ], - "auth": [], - "paths": { - "/{location}": { - "get": { - "description": "Get weather information for a specific location", - "operationId": "GetCurrentWeather", - "parameters": [ - { - "name": "location", - "in": "path", - "description": "City or location to retrieve the weather for", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "format", - "in": "query", - "description": "Always use j1 value for this parameter", - "required": true, - "schema": { - "type": "string", - "default": "j1" - } - } - ], - "responses": { - "200": { - "description": "Successful response", - "content": { - "text/plain": { - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "Location not found" - } - }, - "deprecated": false - } - } - }, - "components": { - "schemes": {} - } -} \ No newline at end of file diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/package.json b/sdk/ai/ai-projects/samples/v1-beta/typescript/package.json deleted file mode 100644 index be38fb64963a..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/package.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "name": "@azure-samples/ai-projects-ts-beta", - "private": true, - "version": "1.0.0", - "description": "Azure AI Projects client library samples for TypeScript (Beta)", - "engines": { - "node": ">=18.0.0" - }, - "scripts": { - "build": "tsc", - "prebuild": "rimraf dist/" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/Azure/azure-sdk-for-js.git", - "directory": "sdk/ai/ai-projects" - }, - "keywords": [ - "node", - "azure", - "cloud", - "typescript", - "browser", - "isomorphic" - ], - "author": "Microsoft Corporation", - "license": "MIT", - "bugs": { - "url": "https://github.com/Azure/azure-sdk-for-js/issues" - }, - "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/ai/ai-projects", - "dependencies": { - "@azure/ai-projects": "next", - "dotenv": "latest", - "@azure/monitor-opentelemetry-exporter": "^1.0.0-beta.31", - "@azure/opentelemetry-instrumentation-azure-sdk": "^1.0.0-beta.7", - "@opentelemetry/api": "^1.9.0", - "@opentelemetry/instrumentation": "0.57.0", - "@opentelemetry/sdk-trace-node": "^1.30.0", - "@azure/core-util": "^1.9.0", - "@azure/identity": "^4.3.0" - }, - "devDependencies": { - "@types/node": "^18.0.0", - "typescript": "~5.8.2", - "rimraf": "latest" - } -} diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/sample.env b/sdk/ai/ai-projects/samples/v1-beta/typescript/sample.env deleted file mode 100644 index 0d9bbe518d6f..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/sample.env +++ /dev/null @@ -1,3 +0,0 @@ -AZURE_AI_PROJECTS_CONNECTION_STRING="" - -APPLICATIONINSIGHTS_CONNECTION_STRING="" diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentCreateWithTracingConsole.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentCreateWithTracingConsole.ts deleted file mode 100644 index f76ac5c171a5..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentCreateWithTracingConsole.ts +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * Demonstrates How to instrument and get tracing using open telemetry. - * - * @summary Create Agent and instrument using open telemetry. - */ - -import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter"; -import { createAzureSdkInstrumentation } from "@azure/opentelemetry-instrumentation-azure-sdk"; -import { context, trace } from "@opentelemetry/api"; -import { registerInstrumentations } from "@opentelemetry/instrumentation"; -import { - ConsoleSpanExporter, - NodeTracerProvider, - SimpleSpanProcessor, -} from "@opentelemetry/sdk-trace-node"; - -import "dotenv/config"; - -const provider = new NodeTracerProvider(); -provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); -provider.register(); - -registerInstrumentations({ - instrumentations: [createAzureSdkInstrumentation()], -}); - -import { AIProjectsClient } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -let appInsightsConnectionString = process.env["APPLICATIONINSIGHTS_CONNECTION_STRING"]; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const tracer = trace.getTracer("Agents Sample", "1.0.0"); - - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - if (!appInsightsConnectionString) { - appInsightsConnectionString = await client.telemetry.getConnectionString(); - } - - if (appInsightsConnectionString) { - const exporter = new AzureMonitorTraceExporter({ - connectionString: appInsightsConnectionString, - }); - provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); - } - - await tracer.startActiveSpan("main", async (span) => { - client.telemetry.updateSettings({ enableContentRecording: true }); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - tracingOptions: { tracingContext: context.active() }, - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - const thread = await client.agents.createThread(); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - console.log(`Created message, message ID ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created Run, Run ID: ${run.id}`); - - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - } - - await client.agents.deleteAgent(agent.id); - - console.log(`Deleted agent`); - - await client.agents.listMessages(thread.id); - - span.end(); - }); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentTokenUsage.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentTokenUsage.ts deleted file mode 100644 index 4714802d5278..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentTokenUsage.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to track the token usage of an Agent in the Azure Agents service. - * - * @summary demonstrates how to track the token usage of an Agent. - */ -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create an Agent - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - }); - - // Create a thread - const thread = await client.agents.createThread(); - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - // the usage should be null at this point - console.log(`usage for run ${run.id}:`, JSON.stringify(run.usage, null, 2)); - // Wait for run to complete - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Run status: ${run.status}`); - } - - // token usage should be like this: - // { - // "completionTokens": 16, - // "promptTokens": 56, - // "totalTokens": 72 - // } - console.log(`usage for run ${run.id}:`, JSON.stringify(run.usage, null, 2)); - - // Delete the Agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted Agent, Agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureAiSearch.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureAiSearch.ts deleted file mode 100644 index 00cfdd7c4e79..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureAiSearch.ts +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Azure AI Search tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Azure AI Search tool. - */ - -import type { - MessageContentOutput, - MessageTextContentOutput, - RunStepToolCallDetailsOutput, - RunStepAzureAISearchToolCallOutput, -} from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const connectionName = process.env["AZURE_AI_SEARCH_CONNECTION_NAME"] || ""; - const connection = await client.connections.getConnection(connectionName); - - // Initialize Azure AI Search tool - const azureAISearchTool = ToolUtility.createAzureAISearchTool(connection.id, "ai-search-sample", { - queryType: "simple", - topK: 3, - filter: "", - }); - - // Create agent with the Azure AI search tool - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [azureAISearchTool.definition], - toolResources: azureAISearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What is the temperature rating of the cozynights sleeping bag?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed:`, JSON.stringify(run, null, 2)); - } - console.log(`Run finished with status: ${run.status}`); - - // Fetch run steps to get the details of agent run - const { data: runSteps } = await client.agents.listRunSteps(thread.id, run.id); - - for (const step of runSteps) { - console.log(`Step ID: ${step.id}, Status: ${step.status}`); - const stepDetails = step.stepDetails; - if (isOutputOfType(stepDetails, "tool_calls")) { - const toolCalls = stepDetails.toolCalls; - for (const toolCall of toolCalls) { - console.log(`Tool Call ID: ${toolCall.id}, Tool type: ${toolCall.type}`); - if (isOutputOfType(toolCall, "azure_ai_search")) { - { - const azureAISearch = toolCall.azureAISearch; - if (azureAISearch) { - console.log(`Azure AI Search Tool Call input: ${azureAISearch.input}`); - console.log(`Azure AI Search Tool Call output: ${azureAISearch.output}`); - } - } - } - } - } - } - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureFunctions.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureFunctions.ts deleted file mode 100644 index 55098a7ca598..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsAzureFunctions.ts +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use azure function agent operations from the Azure Agents service - * - * @summary demonstrates how to use azure function agent operations from the Azure Agents service - */ - -import { AIProjectsClient, ToolUtility } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const storageServiceEndpoint = - process.env["STORAGE_SERVICE_ENDPOINT"] || ""; - - // create azure function tool - const azureFunctionTool = ToolUtility.createAzureFunctionTool( - "azure-function-tool", - "azure function tool", - { - type: "object", - properties: { - query: { type: "string", description: "The question to ask." }, - outputqueueuri: { type: "string", description: "The full output queue uri." }, - }, - }, - { - queueServiceEndpoint: storageServiceEndpoint, - queueName: "input-queue", - }, - { - queueServiceEndpoint: storageServiceEndpoint, - queueName: "output-queue", - }, - { - function: { - name: "azure-function-tool", - description: "Azure function", - parameters: { - type: "object", - properties: { - query: { type: "string", description: "The question to ask." }, - outputqueueuri: { type: "string", description: "The full output queue uri." }, - }, - }, - }, - inputBinding: { - type: "storage_queue", - storageQueue: { - queueName: "input-queue", - queueServiceEndpoint: storageServiceEndpoint, - }, - }, - outputBinding: { - type: "storage_queue", - storageQueue: { - queueName: "output-queue", - queueServiceEndpoint: storageServiceEndpoint, - }, - }, - }, - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "azure-function-agent", - instructions: `You are a helpful support agent. Use the provided function any time the prompt contains the string 'What would foo say?'. When you invoke the function, ALWAYS specify the output queue uri parameter as '${storageServiceEndpoint}/azure-function-tool-output'. Always responds with "Foo says" and then the response from the tool.`, - tools: [azureFunctionTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What is the most prevalent element in the universe? What would foo say?", - }); - console.log(`Created message, message ID: ${message.id}`); - - const run = await client.agents.createRun(thread.id, agent.id); - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - - // Get messages from the thread - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages: ${messages}`); - - // Get the last message from the sender - const messagesArray: any[] = [messages]; - const lastMsg = messagesArray.find((msg) => msg.role === "agent"); - if (lastMsg) { - console.log(`Last Message: ${lastMsg.content}`); - } - - // Delete the agent once done - const result = await client.agents.deleteAgent(agent.id); - if (result.deleted) { - console.log(`Deleted agent ${result.id}`); - } else { - console.log(`Failed to delete agent ${result.id}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBasics.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBasics.ts deleted file mode 100644 index 40d39e40e9b9..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBasics.ts +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic agent operations. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID : ${thread.id}`); - - // List all threads for the agent - const threads = await client.agents.listThreads(); - console.log(`Threads for agent ${agent.id}:`); - for await (const t of (await threads).data) { - console.log(`Thread ID: ${t.id}`); - console.log(`Created at: ${t.createdAt}`); - console.log(`Metadata: ${t.metadata}`); - console.log(`---- `); - } - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - console.log(`Created message, message ID : ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run status: ${run.status}`); - - await client.agents.deleteAgent(agent.id); - - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingCustomSearch.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingCustomSearch.ts deleted file mode 100644 index cce96c74f446..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingCustomSearch.ts +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Customer Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Bing Customer Search tool. - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, ToolUtility, isOutputOfType } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const bingCustomSearchInstanceName = - process.env["BING_CUSTOM_SEARCH_INSTANCE_NAME"] || ""; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingCustomSearchConnection = await client.connections.getConnection( - process.env["BING_CUSTOM_SEARCH"] || "", - ); - console.log(`Bing custom search connection ID:`, bingCustomSearchConnection.id); - - // Initialize agent bing custom search tool with the connection id - const bingCustomSearchTool = ToolUtility.createBingCustomSearchTool([ - { - connectionId: bingCustomSearchConnection.id, - // please do not use bingCustomSearchConnection.name here - instanceName: bingCustomSearchInstanceName, - }, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: - "You are a customer support chatbot. Use the tools provided and your knowledge base to best respond to customer queries", - tools: [bingCustomSearchTool.definition], - requestOptions: { - headers: { - "x-ms-enable-preview": true, - }, - }, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${JSON.stringify(run, null, 2)}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGrounding.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGrounding.ts deleted file mode 100644 index bbf819ed68b6..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGrounding.ts +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Grounding with Bing Search tool. - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { - AIProjectsClient, - ToolUtility, - connectionToolType, - isOutputOfType, -} from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingConnection = await client.connections.getConnection( - process.env["BING_CONNECTION_NAME"] || "", - ); - const connectionId = bingConnection.id; - - // Initialize agent bing tool with the connection id - const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [ - connectionId, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGroundingWithStreaming.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGroundingWithStreaming.ts deleted file mode 100644 index 2829a3dde0a3..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsBingGroundingWithStreaming.ts +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Grounding with Bing Search tool - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Grounding with Bing Search tool using streaming. - */ - -import type { - MessageContentOutput, - MessageDeltaChunk, - MessageDeltaTextContent, - MessageTextContentOutput, - ThreadRunOutput, -} from "@azure/ai-projects"; -import { - AIProjectsClient, - DoneEvent, - ErrorEvent, - MessageStreamEvent, - RunStreamEvent, - ToolUtility, - connectionToolType, - isOutputOfType, -} from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Foundry project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const bingConnection = await client.connections.getConnection( - process.env["BING_CONNECTION_NAME"] || "", - ); - const connectionId = bingConnection.id; - - const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [ - connectionId, - ]); - - // Create agent with the bing tool and process assistant run - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "How does wikipedia explain Euler's Identity?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run with streaming in thread with tools - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - // Delete the assistant when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsFabric.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsFabric.ts deleted file mode 100644 index 24d8bf8782ca..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsFabric.ts +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Microsoft Fabric tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Microsoft Fabric tool. - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, ToolUtility, isOutputOfType } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - // Create an Azure AI Client from a connection string, copied from your AI Studio project. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const fabricConnection = await client.connections.getConnection( - process.env["FABRIC_CONNECTION_NAME"] || "", - ); - - const connectionId = fabricConnection.id; - - // Initialize agent Microsoft Fabric tool with the connection id - const fabricTool = ToolUtility.createFabricTool(connectionId); - - // Create agent with the Microsoft Fabric tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [fabricTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What are the top 3 weather events with the highest property damage?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the agent when done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithBase64.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithBase64.ts deleted file mode 100644 index 0350ecd0c33d..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithBase64.ts +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations with image input (base64 encoded) for the Azure Agents service. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const filePath = "./data/image_file.png"; - -/** - * Convert an image file to a Base64-encoded data URL. - * @param imagePath - The path to the image file - * @param mimeType - The MIME type of the image (e.g., 'image/png', 'image/jpeg') - * @returns A data URL with the Base64-encoded image - */ -function imageToBase64DataUrl(imagePath: string, mimeType: string): string { - try { - // Read the image file as binary - const imageBuffer = fs.readFileSync(imagePath); - // Convert to base64 - const base64Data = imageBuffer.toString("base64"); - // Format as a data URL - return `data:${mimeType};base64,${base64Data}`; - } catch (error) { - console.error(`Error reading image file at ${imagePath}:`, error); - throw error; - } -} - -export async function main(): Promise { - console.log("== AI Projects Agent with Base64 Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message with text and image content using base64 - console.log("Converting image to base64..."); - const imageDataUrl = imageToBase64DataUrl(filePath, "image/png"); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageDataUrl, - detail: "high", - }, - }, - ]; - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithFile.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithFile.ts deleted file mode 100644 index b93d07b6037b..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithFile.ts +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations using image file input for the - * Azure Agents service. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const imagePath = "./data/image_file.png"; - -export async function main(): Promise { - console.log("== AI Projects Agent with Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Upload an image file - console.log("Uploading image file..."); - const fileStream = fs.createReadStream(imagePath); - const imageFile = await client.agents.uploadFile(fileStream, "assistants", { - fileName: "image_file.png", - }); - console.log(`Uploaded file, file ID: ${imageFile.id}`); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_file", - image_file: { - file_id: imageFile.id, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithUrl.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithUrl.ts deleted file mode 100644 index 2232aea66ada..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsImageInputWithUrl.ts +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * @summary This sample demonstrates how to use basic agent operations using image url input for the - * Azure Agents service. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -// Load environment variables -const connectionString = process.env.AZURE_AI_PROJECTS_CONNECTION_STRING || ""; -const modelDeployment = process.env.MODEL_DEPLOYMENT_NAME || ""; -const imageUrl = - "https://github.com/Azure/azure-sdk-for-js/blob/0aa88ceb18d865726d423f73b8393134e783aea6/sdk/ai/ai-projects/data/image_file.png?raw=true"; - -export async function main(): Promise { - console.log("== AI Projects Agent with Image Input Sample =="); - - // Create the client - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - - // Create an agent - console.log(`Creating agent with model ${modelDeployment}...`); - const agent = await client.agents.createAgent(modelDeployment, { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - console.log("Creating thread..."); - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageUrl, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and poll a run - console.log("Creating run..."); - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - console.log(`Run status: ${run.status}, waiting...`); - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - console.log(`Run complete with status: ${run.status}`); - - // Delete the agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // List messages - const messages = await client.agents.listMessages(thread.id, { - order: "asc", - }); - - for (const dataPoint of messages.data) { - const textContent = dataPoint.content.find((item) => item.type === "text"); - if (textContent && "text" in textContent) { - console.log(`${dataPoint.role}: ${textContent.text.value}`); - } - } - - console.log("Messages: ", messages); -} - -main().catch((error) => { - console.error("An error occurred:", error); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsSharepoint.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsSharepoint.ts deleted file mode 100644 index 35a8bb679b5d..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsSharepoint.ts +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with the Sharepoint tool from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with the Sharepoint tool. - */ - -import type { MessageContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { - AIProjectsClient, - ToolUtility, - connectionToolType, - isOutputOfType, -} from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as dotenv from "dotenv"; -dotenv.config(); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - // Create an an Azure AI Project client from a connection string, copied from your AI Foundry project web page. - // At the moment, it should be in the format ";;;" - // Customer needs to login to Azure subscription via Azure CLI and set the environment variables - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const sharepointConnection = await client.connections.getConnection( - process.env["SHAREPOINT_CONNECTION_NAME"] || "", - ); - const connectionId = sharepointConnection.id; - - // Initialize agent Sharepoint tool with the connection id - const sharepointTool = ToolUtility.createConnectionTool(connectionToolType.SharepointGrounding, [ - connectionId, - ]); - - // Create agent with the Sharepoint tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [sharepointTool.definition], - }); - console.log(connectionId); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread for communication - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message to thread - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me about my health insurance options", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and process agent run in thread with tools - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the assistant when done - client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - - // Fetch and log all messages - const messages = await client.agents.listMessages(thread.id); - console.log(`Messages:`); - const agentMessage: MessageContentOutput = messages.data[0].content[0]; - if (isOutputOfType(agentMessage, "text")) { - const textContent = agentMessage as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithFunctionTool.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithFunctionTool.ts deleted file mode 100644 index 120976e8f384..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithFunctionTool.ts +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/* eslint-disable @typescript-eslint/no-unsafe-function-type - */ - -/** - * This sample demonstrates how to use basic agent operations with function tool from the Azure Agents service. - * - * @summary demonstrates how to use basic agent operations using function tool. - * - */ - -import type { - FunctionToolDefinition, - FunctionToolDefinitionOutput, - MessageContentOutput, - MessageImageFileContentOutput, - MessageTextContentOutput, - RequiredToolCallOutput, - SubmitToolOutputsActionOutput, - ToolOutput, -} from "@azure/ai-projects"; -import { AIProjectsClient, ToolUtility, isOutputOfType } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const agents = client.agents; - class FunctionToolExecutor { - private functionTools: { func: Function; definition: FunctionToolDefinition }[]; - - constructor() { - this.functionTools = [ - { - func: this.getUserFavoriteCity, - ...ToolUtility.createFunctionTool({ - name: "getUserFavoriteCity", - description: "Gets the user's favorite city.", - parameters: {}, - }), - }, - { - func: this.getCityNickname, - ...ToolUtility.createFunctionTool({ - name: "getCityNickname", - description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - }, - }, - }), - }, - { - func: this.getWeather, - ...ToolUtility.createFunctionTool({ - name: "getWeather", - description: "Gets the weather for a location.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - unit: { type: "string", enum: ["c", "f"] }, - }, - }, - }), - }, - ]; - } - - private getUserFavoriteCity(): {} { - return { location: "Seattle, WA" }; - } - - private getCityNickname(_location: string): {} { - return { nickname: "The Emerald City" }; - } - - private getWeather(_location: string, unit: string): {} { - return { weather: unit === "f" ? "72f" : "22c" }; - } - - public invokeTool( - toolCall: RequiredToolCallOutput & FunctionToolDefinitionOutput, - ): ToolOutput | undefined { - console.log(`Function tool call - ${toolCall.function.name}`); - const args = []; - if (toolCall.function.parameters) { - try { - const params = JSON.parse(toolCall.function.parameters); - for (const key in params) { - if (Object.prototype.hasOwnProperty.call(params, key)) { - args.push(params[key]); - } - } - } catch (error) { - console.error(`Failed to parse parameters: ${toolCall.function.parameters}`, error); - return undefined; - } - } - const result = this.functionTools - .find((tool) => tool.definition.function.name === toolCall.function.name) - ?.func(...args); - return result - ? { - toolCallId: toolCall.id, - output: JSON.stringify(result), - } - : undefined; - } - - public getFunctionDefinitions(): FunctionToolDefinition[] { - return this.functionTools.map((tool) => { - return tool.definition; - }); - } - } - - const functionToolExecutor = new FunctionToolExecutor(); - const functionTools = functionToolExecutor.getFunctionDefinitions(); - const agent = await agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: - "You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.", - tools: functionTools, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "What's the weather like in my favorite city?", - }); - console.log(`Created message, message ID ${message.id}`); - - // Create run - let run = await agents.createRun(thread.id, agent.id); - console.log(`Created Run, Run ID: ${run.id}`); - - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - if (run.status === "requires_action" && run.requiredAction) { - console.log(`Run requires action - ${run.requiredAction}`); - if ( - isOutputOfType(run.requiredAction, "submit_tool_outputs") - ) { - const submitToolOutputsActionOutput = run.requiredAction as SubmitToolOutputsActionOutput; - const toolCalls = submitToolOutputsActionOutput.submitToolOutputs.toolCalls; - const toolResponses = []; - for (const toolCall of toolCalls) { - if (isOutputOfType(toolCall, "function")) { - const toolResponse = functionToolExecutor.invokeTool(toolCall); - if (toolResponse) { - toolResponses.push(toolResponse); - } - } - } - if (toolResponses.length > 0) { - run = await agents.submitToolOutputsToRun(thread.id, run.id, toolResponses); - console.log(`Submitted tool response - ${run.status}`); - } - } - } - } - - console.log(`Run status - ${run.status}, run ID: ${run.id}`); - const messages = await agents.listMessages(thread.id); - await messages.data.forEach((threadMessage) => { - console.log( - `Thread Message Created at - ${threadMessage.createdAt} - Role - ${threadMessage.role}`, - ); - threadMessage.content.forEach((content: MessageContentOutput) => { - if (isOutputOfType(content, "text")) { - const textContent = content as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } else if (isOutputOfType(content, "image_file")) { - const imageContent = content as MessageImageFileContentOutput; - console.log(`Image Message Content - ${imageContent.imageFile.fileId}`); - } - }); - }); - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithOpenApi.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithOpenApi.ts deleted file mode 100644 index 157546c7e37d..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithOpenApi.ts +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with an OpenApi tool. - * - * @summary demonstrates how to use agent operations with an OpenApi tool. - */ - -import type { MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Read in OpenApi spec - const filePath = "./data/weatherOpenApi.json"; - const openApiSpec = JSON.parse(fs.readFileSync(filePath, "utf-8")); - - // Define OpenApi function - const openApiFunction = { - name: "getWeather", - spec: openApiSpec, - description: "Retrieve weather information for a location", - auth: { - type: "anonymous", - }, - default_params: ["format"], // optional - }; - - // Create OpenApi tool - const openApiTool = ToolUtility.createOpenApiTool(openApiFunction); - - // Create agent with OpenApi tool - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "myAgent", - instructions: "You are a helpful agent", - tools: [openApiTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What's the weather in Seattle?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - // Check if you got "Rate limit is exceeded.", then you want to get more quota - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Get most recent message from the assistant - const messages = await client.agents.listMessages(thread.id); - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithToolset.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithToolset.ts deleted file mode 100644 index f33a931e1d3e..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/agentsWithToolset.ts +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with toolset and iteration in streaming - * from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with toolset. - */ - -import { AIProjectsClient, ToolSet } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file for code interpreter tool - const filePath1 = "./data/nifty500QuarterlyResults.csv"; - const fileStream1 = fs.createReadStream(filePath1); - const codeInterpreterFile = await client.agents.uploadFile(fileStream1, "assistants", { - fileName: "myLocalFile", - }); - - console.log(`Uploaded local file, file ID : ${codeInterpreterFile.id}`); - - // Upload file for file search tool - const filePath2 = "./data/sampleFileForUpload.txt"; - const fileStream2 = fs.createReadStream(filePath2); - const fileSearchFile = await client.agents.uploadFile(fileStream2, "assistants", { - fileName: "sampleFileForUpload.txt", - }); - console.log(`Uploaded file, file ID: ${fileSearchFile.id}`); - - // Create vector store for file search tool - const vectorStore = await client.agents - .createVectorStoreAndPoll({ - fileIds: [fileSearchFile.id], - }) - .pollUntilDone(); - - // Create tool set - const toolSet = new ToolSet(); - await toolSet.addFileSearchTool([vectorStore.id]); - await toolSet.addCodeInterpreterTool([codeInterpreterFile.id]); - - // Create agent with tool set - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: toolSet.toolDefinitions, - toolResources: toolSet.toolResources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create threads, messages, and runs to interact with agent as desired - - // Delete agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFiles.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFiles.ts deleted file mode 100644 index 0fa6fe0790c2..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFiles.ts +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the batch vector store with the list of files. - * - * @summary demonstrates how to create the batch vector store with the list of files. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload first file - const file1Content = "Hello, Vector Store!"; - const readable1 = new Readable(); - await readable1.push(file1Content); - await readable1.push(null); // end the stream - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "vectorFile1.txt", - }); - console.log(`Uploaded file1, file ID: ${file1.id}`); - - // Create and upload second file - const file2Content = "This is another file for the Vector Store!"; - const readable2 = new Readable(); - await readable2.push(file2Content); - await readable2.push(null); // end the stream - const file2 = await client.agents.uploadFile(readable2, "assistants", { - fileName: "vectorFile2.txt", - }); - console.log(`Uploaded file2, file ID: ${file2.id}`); - - // Create vector store file batch - const vectorStoreFileBatch = await client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - console.log( - `Created vector store file batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Retrieve vector store file batch - const _vectorStoreFileBatch = await client.agents.getVectorStoreFileBatch( - vectorStore.id, - vectorStoreFileBatch.id, - ); - console.log( - `Retrieved vector store file batch, vector store file batch ID: ${_vectorStoreFileBatch.id}`, - ); - - // List vector store files in the batch - const vectorStoreFiles = await client.agents.listVectorStoreFileBatchFiles( - vectorStore.id, - vectorStoreFileBatch.id, - ); - console.log( - `List of vector store files in the batch: ${vectorStoreFiles.data.map((f) => f.id).join(", ")}`, - ); - - // Delete files - await client.agents.deleteFile(file1.id); - console.log(`Deleted file1, file ID: ${file1.id}`); - await client.agents.deleteFile(file2.id); - console.log(`Deleted file2, file ID: ${file2.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFilesAndPolling.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFilesAndPolling.ts deleted file mode 100644 index ec86eb30458b..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/batchVectorStoreWithFilesAndPolling.ts +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the batch vector store with the list of files using polling operation. - * - * @summary demonstrates how to create the batch vector store with the list of files using polling operation. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload first file - const file1Content = "Hello, Vector Store!"; - const readable1 = new Readable(); - await readable1.push(file1Content); - await readable1.push(null); // end the stream - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "vectorFile1.txt", - }); - console.log(`Uploaded file1, file ID: ${file1.id}`); - - // Create and upload second file - const file2Content = "This is another file for the Vector Store!"; - const readable2 = new Readable(); - await readable2.push(file2Content); - await readable2.push(null); // end the stream - const file2 = await client.agents.uploadFile(readable2, "assistants", { - fileName: "vectorFile2.txt", - }); - console.log(`Uploaded file2, file ID: ${file2.id}`); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create vector store file batch, which will automatically poll until the operation is complete - const vectorStoreFileBatch1 = await client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - onResponse: onResponse, - }); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch1.status}, vector store file batch ID: ${vectorStoreFileBatch1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStoreFileBatchPoller = client.agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - onResponse: onResponse, - }); - const vectorStoreFileBatch2 = await vectorStoreFileBatchPoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch2.status}, vector store file batch ID: ${vectorStoreFileBatch2.id}`, - ); - - // Delete files - await client.agents.deleteFile(file1.id); - await client.agents.deleteFile(file2.id); - console.log(`Deleted files, file IDs: ${file1.id} & ${file2.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreter.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreter.ts deleted file mode 100644 index 1950c5feaf0a..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreter.ts +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with code interpreter from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with code interpreter. - */ - -import type { MessageImageFileContentOutput, MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; -import * as fs from "fs"; -import path from "node:path"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file and wait for it to be processed - const filePath = "./data/nifty500QuarterlyResults.csv"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "localFile", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Create code interpreter tool - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); - - // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create a bar chart in the TRANSPORTATION sector for the operating profit from the uploaded CSV file and provide the file to me?", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - let run = await client.agents.createRun(thread.id, agent.id); - while (run.status === "queued" || run.status === "in_progress") { - await delay(1000); - run = await client.agents.getRun(thread.id, run.id); - } - if (run.status === "failed") { - // Check if you got "Rate limit is exceeded.", then you want to get more quota - console.log(`Run failed: ${run.lastError}`); - } - console.log(`Run finished with status: ${run.status}`); - - // Delete the original file from the agent to free up space (note: this does not delete your version of the file) - await client.agents.deleteFile(localFile.id); - console.log(`Deleted file, file ID: ${localFile.id}`); - - // Print the messages from the agent - const messages = await client.agents.listMessages(thread.id); - console.log("Messages:", messages); - - // Get most recent message from the assistant - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - - // Save the newly created file - console.log(`Saving new files...`); - const imageFile = (messages.data[0].content[0] as MessageImageFileContentOutput).imageFile; - console.log(`Image file ID : ${imageFile.fileId}`); - const imageFileName = path.resolve( - "./data/" + (await client.agents.getFile(imageFile.fileId)).filename + "ImageFile.png", - ); - - const fileContent = await ( - await client.agents.getFileContent(imageFile.fileId).asNodeStream() - ).body; - if (fileContent) { - const chunks: Buffer[] = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); - } else { - console.error("Failed to retrieve file content: fileContent is undefined"); - } - console.log(`Saved image file to: ${imageFileName}`); - - // Iterate through messages and print details for each annotation - console.log(`Message Details:`); - await messages.data.forEach((m) => { - console.log(`File Paths:`); - console.log(`Type: ${m.content[0].type}`); - if (isOutputOfType(m.content[0], "text")) { - const textContent = m.content[0] as MessageTextContentOutput; - console.log(`Text: ${textContent.text.value}`); - } - console.log(`File ID: ${m.id}`); - console.log(`Start Index: ${messages.firstId}`); - console.log(`End Index: ${messages.lastId}`); - }); - - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreterWithStreaming.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreterWithStreaming.ts deleted file mode 100644 index 64e0a44b7cbc..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/codeInterpreterWithStreaming.ts +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with code interpreter from the Azure Agents service. - * - * @summary demonstrates how to use agent operations with code interpreter. - */ - -import type { - MessageDeltaChunk, - MessageDeltaTextContent, - MessageImageFileContentOutput, - MessageTextContentOutput, - ThreadRunOutput, -} from "@azure/ai-projects"; -import { - AIProjectsClient, - DoneEvent, - ErrorEvent, - isOutputOfType, - MessageStreamEvent, - RunStreamEvent, - ToolUtility, -} from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as fs from "fs"; -import path from "node:path"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file and wait for it to be processed - const filePath = "./data/nifty500QuarterlyResults.csv"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "myLocalFile", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Create code interpreter tool - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); - - // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create a thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create a message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create a bar chart in the TRANSPORTATION sector for the operating profit from the uploaded CSV file and provide the file to me?", - }); - - console.log(`Created message, message ID: ${message.id}`); - - // Create and execute a run - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - // Delete the original file from the agent to free up space (note: this does not delete your version of the file) - await client.agents.deleteFile(localFile.id); - console.log(`Deleted file, file ID : ${localFile.id}`); - - // Print the messages from the agent - const messages = await client.agents.listMessages(thread.id); - console.log("Messages:", messages); - - // Get most recent message from the assistant - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - - // Save the newly created file - console.log(`Saving new files...`); - const imageFileOutput = messages.data[0].content[0] as MessageImageFileContentOutput; - const imageFile = imageFileOutput.imageFile.fileId; - const imageFileName = path.resolve( - "./data/" + (await client.agents.getFile(imageFile)).filename + "ImageFile.png", - ); - console.log(`Image file name : ${imageFileName}`); - - const fileContent = await (await client.agents.getFileContent(imageFile).asNodeStream()).body; - if (fileContent) { - const chunks: Buffer[] = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); - } else { - console.error("Failed to retrieve file content: fileContent is undefined"); - } - console.log(`Saved image file to: ${imageFileName}`); - - // Iterate through messages and print details for each annotation - console.log(`Message Details:`); - await messages.data.forEach((m) => { - console.log(`File Paths:`); - console.log(`Type: ${m.content[0].type}`); - if (isOutputOfType(m.content[0], "text")) { - const textContent = m.content[0] as MessageTextContentOutput; - console.log(`Text: ${textContent.text.value}`); - } - console.log(`File ID: ${m.id}`); - console.log(`Start Index: ${messages.firstId}`); - console.log(`End Index: ${messages.lastId}`); - }); - - // Delete the agent once done - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/fileSearch.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/fileSearch.ts deleted file mode 100644 index 3b6c8acf8000..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/fileSearch.ts +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations with file searching from the Azure Agents service. - * - * @summary This sample demonstrates how to use agent operations with file searching. - */ - -import type { - MessageContentOutput, - MessageImageFileContentOutput, - MessageTextContentOutput, -} from "@azure/ai-projects"; -import { AIProjectsClient, isOutputOfType, ToolUtility } from "@azure/ai-projects"; -import { delay } from "@azure/core-util"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as fs from "fs"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload file - const filePath = "./data/sampleFileForUpload.txt"; - const localFileStream = fs.createReadStream(filePath); - const file = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "sampleFileForUpload.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store - const vectorStore = await client.agents.createVectorStore({ - fileIds: [file.id], - name: "myVectorStore", - }); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Initialize file search tool - const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]); - - // Create agent with files - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "SDK Test Agent - Retrieval", - instructions: "You are helpful agent that can help fetch data from files you know about.", - tools: [fileSearchTool.definition], - toolResources: fileSearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "Can you give me the documented codes for 'banana' and 'orange'?", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - while (["queued", "in_progress"].includes(run.status)) { - await delay(500); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - } - - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - const messages = await client.agents.listMessages(thread.id); - await messages.data.forEach((threadMessage) => { - console.log( - `Thread Message Created at - ${threadMessage.createdAt} - Role - ${threadMessage.role}`, - ); - threadMessage.content.forEach((content: MessageContentOutput) => { - if (isOutputOfType(content, "text")) { - const textContent = content as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } else if (isOutputOfType(content, "image_file")) { - const imageContent = content as MessageImageFileContentOutput; - console.log(`Image Message Content - ${imageContent.imageFile.fileId}`); - } - }); - }); - - // Delete agent - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/files.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/files.ts deleted file mode 100644 index e130f2eb5590..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/files.ts +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic files agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic files agent operations. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import { Readable } from "node:stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create and upload file - const fileContent = "Hello, World!"; - // Create a readable stream from the string content - const readable = Readable.from(Buffer.from(fileContent)); - const file = await client.agents.uploadFile(readable, "assistants", { fileName: "myFile.txt" }); - console.log(`Uploaded file, file ID : ${file.id}`); - - // List uploaded files - const files = await client.agents.listFiles(); - - console.log(`List of files : ${files.data[0].filename}`); - - // Retrieve file - const _file = await client.agents.getFile(file.id); - - console.log(`Retrieved file, file ID : ${_file.id}`); - - // Delete file - await client.agents.deleteFile(file.id); - - console.log(`Deleted file, file ID : ${file.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithLocalUpload.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithLocalUpload.ts deleted file mode 100644 index 6dd2af519ee4..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithLocalUpload.ts +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic files agent operations with local file upload from the Azure Agents service. - * - * @summary demonstrates how to use basic files agent operations with local file upload. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as fs from "fs"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Upload local file - const filePath = "./data/localFile.txt"; - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "myLocalFile.txt", - }); - - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - // Retrieve local file - const retrievedLocalFile = await client.agents.getFile(localFile.id); - - console.log(`Retrieved local file, file ID : ${retrievedLocalFile.id}`); - - // Delete local file - await client.agents.deleteFile(localFile.id); - - console.log(`Deleted local file, file ID : ${localFile.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithPolling.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithPolling.ts deleted file mode 100644 index e9c0149e1825..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/filesWithPolling.ts +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to upload a file and poll for its status. - * - * @summary demonstrates how to upload a file and poll for its status. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create file content - const fileContent1 = "Hello, World!"; - const readable1 = new Readable(); - readable1.push(fileContent1); - readable1.push(null); // end the stream - - const fileContent2 = "How are you?"; - const readable2 = new Readable(); - readable2.push(fileContent2); - readable2.push(null); // end the stream - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Upload file, which will automatically poll until the operation is complete - const file1 = await client.agents.uploadFile(readable1, "assistants", { - fileName: "myPollingFile.txt", - onResponse: onResponse, - }); - console.log(`Uploaded file with status ${file1.status}, file ID : ${file1.id}`); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const filePoller = client.agents.uploadFile(readable2, "assistants", { - fileName: "myPollingFile.txt", - onResponse: onResponse, - }); - const file2 = await filePoller.pollUntilDone({ abortSignal: abortController.signal }); - console.log(`Uploaded file with status ${file2.status}, file ID: ${file2.id}`); - - // Delete file - await client.agents.deleteFile(file1.id); - await client.agents.deleteFile(file2.id); - console.log(`Deleted files, file IDs: ${file1.id} & ${file2.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/messages.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/messages.ts deleted file mode 100644 index 61036b338071..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/messages.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic message agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic message agent operations. - */ - -import type { MessageTextContentOutput } from "@azure/ai-projects"; -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are helpful agent", - }); - const thread = await client.agents.createThread(); - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - const messages = await client.agents.listMessages(thread.id); - console.log( - `Message ${message.id} contents: ${(messages.data[0].content[0] as MessageTextContentOutput).text.value}`, - ); - - const updatedMessage = await client.agents.updateMessage(thread.id, message.id, { - metadata: { introduction: "true" }, - }); - console.log(`Updated message metadata - introduction: ${updatedMessage.metadata?.introduction}`); - - await client.agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID : ${thread.id}`); - - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID : ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/runSteps.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/runSteps.ts deleted file mode 100644 index 04a97ccb908b..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/runSteps.ts +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic run agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic run agent operations. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create agent - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-agent", - instructions: "You are a helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await client.agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - - // Wait for run to complete - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - console.log(`Run status: ${run.status}`); - } - - // List run steps - const runSteps = await client.agents.listRunSteps(thread.id, run.id); - console.log(`Listed run steps, run ID: ${run.id}`); - - // Get specific run step - const stepId = runSteps.data[0].id; - const step = await client.agents.getRunStep(thread.id, run.id, stepId); - console.log(`Retrieved run step, step ID: ${step.id}`); - - // Clean up - await client.agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - await client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/streaming.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/streaming.ts deleted file mode 100644 index 1a3e536c5b0b..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/streaming.ts +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use agent operations in streaming from the Azure Agents service. - * - * @summary demonstrates how to use agent operations in streaming. - */ - -import type { - MessageDeltaChunk, - MessageDeltaTextContent, - ThreadRunOutput, -} from "@azure/ai-projects"; -import { - AIProjectsClient, - DoneEvent, - ErrorEvent, - MessageStreamEvent, - RunStreamEvent, -} from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; -const modelDeploymentName = process.env["MODEL_DEPLOYMENT_NAME"] || "gpt-4o"; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const agent = await client.agents.createAgent(modelDeploymentName, { - name: "my-assistant", - instructions: "You are helpful agent", - }); - - console.log(`Created agent, agent ID : ${agent.id}`); - - const thread = await client.agents.createThread(); - - console.log(`Created thread, thread ID : ${agent.id}`); - - await client.agents.createMessage(thread.id, { role: "user", content: "Hello, tell me a joke" }); - - console.log(`Created message, thread ID : ${agent.id}`); - - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - - await client.agents.deleteAgent(agent.id); - console.log(`Delete agent, agent ID : ${agent.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/threads.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/threads.ts deleted file mode 100644 index fbb3d705e710..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/threads.ts +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to use basic thread agent operations from the Azure Agents service. - * - * @summary demonstrates how to use basic thread agent operations. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - const thread = await client.agents.createThread(); - - console.log(`Created thread, thread ID : ${thread.id}`); - - const _thread = await client.agents.getThread(thread.id); - - console.log(`Retrieved thread, thread ID : ${_thread.id}`); - - await client.agents.deleteThread(thread.id); - - console.log(`Deleted thread, thread ID : ${_thread.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFiles.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFiles.ts deleted file mode 100644 index e58d747f1fef..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFiles.ts +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store with the list of files. - * - * @summary demonstrates how to create the vector store with the list of files. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload file - const fileContent = "Hello, Vector Store!"; - const readable = new Readable(); - await readable.push(fileContent); - await readable.push(null); // end the stream - const file = await client.agents.uploadFile(readable, "assistants", { - fileName: "vectorFile.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file - const vectorStoreFile = await client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - }); - console.log(`Created vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Retrieve vector store file - const _vectorStoreFile = await client.agents.getVectorStoreFile( - vectorStore.id, - vectorStoreFile.id, - ); - console.log(`Retrieved vector store file, vector store file ID: ${_vectorStoreFile.id}`); - - // List vector store files - const vectorStoreFiles = await client.agents.listVectorStoreFiles(vectorStore.id); - console.log(`List of vector store files: ${vectorStoreFiles.data.map((f) => f.id).join(", ")}`); - - // Delete vector store file - await client.agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Delete file - await client.agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFilesAndPolling.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFilesAndPolling.ts deleted file mode 100644 index fb020085be82..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoreWithFilesAndPolling.ts +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store with the list of files using polling operation. - * - * @summary demonstrates how to create the vector store with the list of files using polling operation. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import { Readable } from "stream"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create vector store - const vectorStore = await client.agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Create and upload file - const fileContent = "Hello, Vector Store!"; - const readable = new Readable(); - await readable.push(fileContent); - await readable.push(null); // end the stream - const file = await client.agents.uploadFile(readable, "assistants", { - fileName: "vectorFile.txt", - }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create vector store file, which will automatically poll until the operation is complete - const vectorStoreFile1 = await client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - console.log( - `Created vector store file with status ${vectorStoreFile1.status}, vector store file ID: ${vectorStoreFile1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStoreFilePoller = client.agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - const vectorStoreFile2 = await vectorStoreFilePoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store file with status ${vectorStoreFile2.status}, vector store file ID: ${vectorStoreFile2.id}`, - ); - - // Delete file - await client.agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - - // Delete vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStores.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStores.ts deleted file mode 100644 index 7c22df4d46e5..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStores.ts +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store. - * - * @summary demonstrates how to create the vector store. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // Create a vector store - const vectorStore = await client.agents.createVectorStore({ name: "myVectorStore" }); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // List vector stores - const vectorStores = await client.agents.listVectorStores(); - console.log("List of vector stores:", vectorStores); - - // Modify the vector store - const updatedVectorStore = await client.agents.modifyVectorStore(vectorStore.id, { - name: "updatedVectorStore", - }); - console.log(`Updated vector store, vector store ID: ${updatedVectorStore.id}`); - - // Get a specific vector store - const retrievedVectorStore = await client.agents.getVectorStore(vectorStore.id); - console.log(`Retrieved vector store, vector store ID: ${retrievedVectorStore.id}`); - - // Delete the vector store - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoresWithPolling.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoresWithPolling.ts deleted file mode 100644 index c88e2239f02b..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/agents/vectorStoresWithPolling.ts +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to create the vector store using polling operation. - * - * @summary demonstrates how to create the vector store using polling operation. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import "dotenv/config"; - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // (Optional) Define an onResponse callback to monitor the progress of polling - function onResponse(response: any): void { - console.log(`Received response with status: ${response.parsedBody?.status}`); - } - - // Create a vector, which will automatically poll until the operation is complete - const vectorStore1 = await client.agents.createVectorStore({ - name: "myVectorStore", - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - console.log( - `Created vector store with status ${vectorStore1.status}, vector store ID: ${vectorStore1.id}`, - ); - - // Alternatively, polling can be done using .poll() and .pollUntilDone() methods. - // This approach allows for more control over the polling process. - // (Optional) AbortController can be used to stop polling if needed. - const abortController = new AbortController(); - const vectorStorePoller = client.agents.createVectorStore({ - name: "myVectorStore", - pollingOptions: { - sleepIntervalInMs: 2000, - }, - onResponse: onResponse, - }); - const vectorStore2 = await vectorStorePoller.pollUntilDone({ - abortSignal: abortController.signal, - }); - console.log( - `Created vector store with status ${vectorStore2.status}, vector store ID: ${vectorStore2.id}`, - ); - - // Delete the vector store - await client.agents.deleteVectorStore(vectorStore1.id); - await client.agents.deleteVectorStore(vectorStore2.id); - console.log(`Deleted vector stores, vector store IDs: ${vectorStore1.id} & ${vectorStore2.id}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/connections/connectionsBasics.ts b/sdk/ai/ai-projects/samples/v1-beta/typescript/src/connections/connectionsBasics.ts deleted file mode 100644 index 3837c3a7f1c1..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/src/connections/connectionsBasics.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * This sample demonstrates how to how to use basic connections operations. - * - * @summary Given an AIProjectClient, this sample demonstrates how to enumerate the properties of all connections, - * get the properties of a default connection, and get the properties of a connection by its name. - */ - -import { AIProjectsClient } from "@azure/ai-projects"; -import { DefaultAzureCredential } from "@azure/identity"; - -import * as dotenv from "dotenv"; -dotenv.config(); - -const connectionString = - process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - -export async function main(): Promise { - const client = AIProjectsClient.fromConnectionString( - connectionString || "", - new DefaultAzureCredential(), - ); - - // List the details of all the connections - const connections = await client.connections.listConnections(); - console.log(`Retrieved ${connections.length} connections`); - - // Get the details of a connection, without credentials - const connectionName = connections[0].name; - const connection = await client.connections.getConnection(connectionName); - console.log(`Retrieved connection, connection name: ${connection.name}`); - - // Get the details of a connection, including credentials (if available) - const connectionWithSecrets = await client.connections.getConnectionWithSecrets(connectionName); - console.log(`Retrieved connection with secrets, connection name: ${connectionWithSecrets.name}`); -} - -main().catch((err) => { - console.error("The sample encountered an error:", err); -}); diff --git a/sdk/ai/ai-projects/samples/v1-beta/typescript/tsconfig.json b/sdk/ai/ai-projects/samples/v1-beta/typescript/tsconfig.json deleted file mode 100644 index 400db87cf648..000000000000 --- a/sdk/ai/ai-projects/samples/v1-beta/typescript/tsconfig.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "compilerOptions": { - "target": "ES2023", - "module": "commonjs", - "lib": [], - "importHelpers": true, - "strict": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "moduleResolution": "node10", - "esModuleInterop": true, - "outDir": "./dist", - "resolveJsonModule": true - }, - "include": [ - "./src" - ] -} diff --git a/sdk/ai/ai-projects/src/agents/assistants.ts b/sdk/ai/ai-projects/src/agents/assistants.ts deleted file mode 100644 index fae08b629d40..000000000000 --- a/sdk/ai/ai-projects/src/agents/assistants.ts +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { - AgentDeletionStatusOutput, - AgentOutput, - OpenAIPageableListOfAgentOutput, -} from "../customization/outputModels.js"; -import { - validateLimit, - validateMetadata, - validateOrder, - validateVectorStoreDataType, -} from "./inputValidations.js"; -import { TracingUtility } from "../tracing.js"; -import { traceEndCreateOrUpdateAgent, traceStartCreateOrUpdateAgent } from "./assistantsTrace.js"; -import { traceEndAgentGeneric, traceStartAgentGeneric } from "./traceUtility.js"; -import type { - CreateAgentOptionalParams, - DeleteAgentOptionalParams, - GetAgentOptionalParams, - ListAgentsOptionalParams, - UpdateAgentOptionalParams, -} from "./customModels.js"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import * as ConvertFromWire from "../customization/convertOutputModelsFromWire.js"; -import * as ConverterToWire from "../customization/convertModelsToWrite.js"; -import { convertToListQueryParameters } from "../customization/convertParametersToWire.js"; -import { createOpenAIError } from "./openAIError.js"; - -const expectedStatuses = ["200"]; - -enum Tools { - CodeInterpreter = "code_interpreter", - FileSearch = "file_search", - Function = "function", - BingGrounding = "bing_grounding", - BingCustomSearch = "bing_custom_search", - MicrosoftFabric = "fabric_dataagent", - SharepointGrounding = "sharepoint_grounding", - AzureAISearch = "azure_ai_search", - OpenApi = "openapi", - AzureFunction = "azure_function", -} - -/** Creates a new agent. */ -export async function createAgent( - context: Client, - model: string, - options: CreateAgentOptionalParams = {}, -): Promise { - const createOptions: GeneratedParameters.CreateAgentParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...ConverterToWire.convertCreateAgentOptions({ ...options, model }), - }, - }; - - validateCreateAgentParameters(createOptions); - const response = await TracingUtility.withSpan( - "CreateAgent", - createOptions, - async (updatedOptions) => { - const result = await context.path("/assistants").post(updatedOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - traceStartCreateOrUpdateAgent, - traceEndCreateOrUpdateAgent, - ); - return ConvertFromWire.convertAgentOutput(response); -} - -/** Gets a list of agents that were previously created. */ -export async function listAgents( - context: Client, - options: ListAgentsOptionalParams = {}, -): Promise { - const listAgentsOptions: GeneratedParameters.ListAgentsParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: convertToListQueryParameters(options), - }; - - validateListAgentsParameters(listAgentsOptions); - const response = await TracingUtility.withSpan( - "ListAgents", - listAgentsOptions || {}, - async (updateOptions) => { - const result = await context.path("/assistants").get(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - ); - - return ConvertFromWire.convertOpenAIPageableListOfAgentOutput(response); -} - -/** Retrieves an existing agent. */ -export async function getAgent( - context: Client, - assistantId: string, - options: GetAgentOptionalParams = {}, -): Promise { - const getAgentOptions: GeneratedParameters.GetAgentParameters = { - ...operationOptionsToRequestParameters(options), - }; - - validateAssistantId(assistantId); - const response = await TracingUtility.withSpan( - "GetAgent", - getAgentOptions, - async (updateOptions) => { - const result = await context - .path("/assistants/{assistantId}", assistantId) - .get(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { agentId: assistantId }, - }), - ); - - return ConvertFromWire.convertAgentOutput(response); -} - -/** Modifies an existing agent. */ -export async function updateAgent( - context: Client, - assistantId: string, - options: UpdateAgentOptionalParams = {}, -): Promise { - const updateAgentOptions: GeneratedParameters.UpdateAgentParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...ConverterToWire.convertUpdateAgentOptions(options), - }, - }; - - validateUpdateAgentParameters(assistantId, updateAgentOptions); - const response = await TracingUtility.withSpan( - "UpdateAgent", - updateAgentOptions, - async (updateOptions) => { - const result = await context - .path("/assistants/{assistantId}", assistantId) - .post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => traceStartCreateOrUpdateAgent(span, updatedOptions, assistantId), - traceEndCreateOrUpdateAgent, - ); - return ConvertFromWire.convertAgentOutput(response); -} - -/** Deletes an agent. */ -export async function deleteAgent( - context: Client, - assistantId: string, - options: DeleteAgentOptionalParams = {}, -): Promise { - const deleteAgentOptions: GeneratedParameters.DeleteAgentParameters = { - ...operationOptionsToRequestParameters(options), - }; - - validateAssistantId(assistantId); - const response = await TracingUtility.withSpan( - "DeleteAgent", - deleteAgentOptions, - async (updateOptions) => { - const result = await context - .path("/assistants/{assistantId}", assistantId) - .delete(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - traceStartAgentGeneric, - traceEndAgentGeneric, - ); - return ConvertFromWire.convertAgentDeletionStatusOutput(response); -} - -function validateCreateAgentParameters( - options: GeneratedParameters.CreateAgentParameters | GeneratedParameters.UpdateAgentParameters, -): void { - if (options.body.tools) { - if (options.body.tools.some((value) => !Object.values(Tools).includes(value.type as Tools))) { - throw new Error( - "Tool type must be one of 'code_interpreter', 'file_search', 'function', 'bing_grounding', 'fabric_dataagent', 'sharepoint_grounding', 'azure_ai_search', 'azure_function'", - ); - } - } - if (options.body.tool_resources) { - if (options.body.tool_resources.code_interpreter) { - if ( - options.body.tool_resources.code_interpreter.file_ids && - options.body.tool_resources.code_interpreter.data_sources - ) { - throw new Error("Only file_ids or data_sources can be provided, not both"); - } - if ( - options.body.tool_resources.code_interpreter.file_ids && - options.body.tool_resources.code_interpreter.file_ids.length > 20 - ) { - throw new Error("A maximum of 20 file IDs are allowed"); - } - if (options.body.tool_resources.code_interpreter.data_sources) { - validateVectorStoreDataType(options.body.tool_resources.code_interpreter.data_sources); - } - } - if (options.body.tool_resources.file_search) { - if ( - options.body.tool_resources.file_search.vector_store_ids && - options.body.tool_resources.file_search.vector_store_ids.length > 1 - ) { - throw new Error("Only one vector store ID is allowed"); - } - if (options.body.tool_resources.file_search.vector_stores) { - if (options.body.tool_resources.file_search.vector_stores.length > 1) { - throw new Error("Only one vector store is allowed"); - } - validateVectorStoreDataType( - options.body.tool_resources.file_search.vector_stores[0]?.configuration.data_sources, - ); - } - } - if (options.body.tool_resources.azure_ai_search) { - if ( - options.body.tool_resources.azure_ai_search.indexes && - options.body.tool_resources.azure_ai_search.indexes.length > 1 - ) { - throw new Error("Only one index is allowed"); - } - } - } - if (options.body.temperature && (options.body.temperature < 0 || options.body.temperature > 2)) { - throw new Error("Temperature must be between 0 and 2"); - } - if (options.body.metadata) { - validateMetadata(options.body.metadata); - } -} - -function validateListAgentsParameters(options?: GeneratedParameters.ListAgentsParameters): void { - if (options?.queryParameters?.limit) { - validateLimit(options.queryParameters.limit); - } - if (options?.queryParameters?.order) { - validateOrder(options.queryParameters.order); - } -} - -function validateAssistantId(assistantId: string): void { - if (!assistantId) { - throw new Error("Assistant ID is required"); - } -} - -function validateUpdateAgentParameters( - assistantId: string, - options?: GeneratedParameters.UpdateAgentParameters, -): void { - validateAssistantId(assistantId); - if (options) { - validateCreateAgentParameters(options); - } -} diff --git a/sdk/ai/ai-projects/src/agents/assistantsTrace.ts b/sdk/ai/ai-projects/src/agents/assistantsTrace.ts deleted file mode 100644 index 39f62537b200..000000000000 --- a/sdk/ai/ai-projects/src/agents/assistantsTrace.ts +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { AgentOutput } from "../generated/src/outputModels.js"; -import type { TracingAttributeOptions, Span } from "../tracing.js"; -import { TracingUtility, TracingOperationName } from "../tracing.js"; -import type { CreateAgentParameters, UpdateAgentParameters } from "../generated/src/parameters.js"; -import { - addInstructionsEvent, - formatAgentApiResponse, - UpdateWithAgentAttributes, -} from "./traceUtility.js"; - -/** - * Traces the start of creating or updating an agent. - * @param span - The span to trace. - * @param options - The options for creating an agent. - */ -export function traceStartCreateOrUpdateAgent( - span: Span, - options: CreateAgentParameters | UpdateAgentParameters, - agentId?: string, -): void { - const attributes: TracingAttributeOptions = { - operationName: TracingOperationName.CREATE_AGENT, - name: options.body.name ?? undefined, - model: options.body.model, - description: options.body.description ?? undefined, - instructions: options.body.instructions ?? undefined, - topP: options.body.top_p ?? undefined, - temperature: options.body.temperature ?? undefined, - responseFormat: formatAgentApiResponse(options.body.response_format), - }; - if (agentId) { - attributes.operationName = TracingOperationName.CREATE_UPDATE_AGENT; - attributes.agentId = agentId; - } - TracingUtility.setSpanAttributes( - span, - TracingOperationName.CREATE_AGENT, - UpdateWithAgentAttributes(attributes), - ); - addInstructionsEvent(span, options.body); -} - -/** - * Traces the end of creating an agent. - * @param span - The span to trace. - * @param _options - The options for creating an agent. - * @param result - The result of creating an agent. - */ -export async function traceEndCreateOrUpdateAgent( - span: Span, - _options: CreateAgentParameters | UpdateAgentParameters, - result: Promise, -): Promise { - const resolvedResult = await result; - const attributes: TracingAttributeOptions = { - agentId: resolvedResult.id, - }; - TracingUtility.updateSpanAttributes(span, attributes); -} diff --git a/sdk/ai/ai-projects/src/agents/customModels.ts b/sdk/ai/ai-projects/src/agents/customModels.ts deleted file mode 100644 index a0b5b02977ad..000000000000 --- a/sdk/ai/ai-projects/src/agents/customModels.ts +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { OperationOptions, RequestParameters } from "@azure-rest/core-client"; -import type { ThreadRunOutput } from "../customization/outputModels.js"; -import type { AgentEventMessageStream } from "./streamingModels.js"; -import type { - AgentThreadCreationOptions, - CreateAgentOptions, - CreateAndRunThreadOptions, - CreateRunOptions, - UpdateAgentOptions, - UpdateAgentThreadOptions, - VectorStoreFileStatusFilter, - VectorStoreOptions, - VectorStoreUpdateOptions, -} from "../customization/models.js"; -import type { - ListMessagesQueryParamProperties, - ListFilesQueryParamProperties, - ListThreadsQueryParamProperties, -} from "../customization/parameters.js"; -import type { - CreateVectorStoreFileBatchOptions, - CreateVectorStoreFileOptions, -} from "./vectorStoresModels.js"; - -/** - * Optional request parameters support passing headers, abort signal, etc. - */ -export type OptionalRequestParameters = Pick< - RequestParameters, - "headers" | "timeout" | "abortSignal" | "tracingOptions" ->; - -/** - * Request options for list requests. - */ -export interface ListQueryParameters { - /** - * A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. - */ - limit?: number; - - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - */ - order?: "asc" | "desc"; - - /** - * A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. - */ - after?: string; - - /** - * 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. - */ - before?: string; -} - -/** - * Options for configuring polling behavior. - */ -export interface PollingOptions { - /** - * The interval, in milliseconds, to wait between polling attempts. If not specified, a default interval of 1000ms will be used. - */ - sleepIntervalInMs?: number; -} - -/** - * Optional parameters configuring polling behavior. - */ -export interface PollingOptionsParams { - /** Options for configuring polling behavior. */ - pollingOptions?: PollingOptions; -} - -/** - * Agent run response with support to stream. - */ -export type AgentRunResponse = PromiseLike & { - /** - * Function to start streaming the agent event messages. - * @returns A promise that resolves to an AgentEventMessageStream. - */ - stream: () => Promise; -}; - -/** - * Optional parameters for creating and running a thread, excluding the assistantId. - */ -export type CreateRunOptionalParams = Omit & - OperationOptions; - -/** - * Optional parameters for creating and running a thread, excluding the assistantId. - */ -export type CreateAndRunThreadOptionalParams = Omit & - OperationOptions; - -/** - * Optional parameters for listing run queries. - */ -export interface ListRunQueryOptionalParams extends ListQueryParameters, OperationOptions {} - -/** - * Optional parameters for getting a run. - */ -export interface GetRunOptionalParams extends OperationOptions {} - -/** - * Optional parameters for canceling a run. - */ -export interface CancelRunOptionalParams extends OperationOptions {} - -/** - * Optional parameters for submitting tool outputs to a run. - */ -export interface SubmitToolOutputsToRunOptionalParams extends OperationOptions { - /** - * Whether to stream the tool outputs. - */ - stream?: boolean; -} - -/** - * Optional parameters for updating a run. - */ -export interface UpdateRunOptionalParams extends OperationOptions { - /** Metadata to update in the run. */ - metadata?: Record | null; -} - -/** - * Optional parameters for creating an agent thread. - */ -export interface CreateAgentThreadOptionalParams - extends AgentThreadCreationOptions, - OperationOptions {} - -/** - * Optional parameters for getting an agent thread. - */ -export interface GetAgentThreadOptionalParams extends OperationOptions {} - -/** - * Optional parameters for updating an agent thread. - */ -export interface UpdateAgentThreadOptionalParams - extends UpdateAgentThreadOptions, - OperationOptions {} - -/** - * Optional parameters for deleting an agent thread. - */ -export interface DeleteAgentThreadOptionalParams extends OperationOptions {} - -/** - * Optional parameters for deleting an agent thread. - */ -export interface ListAgentThreadOptionalParams - extends ListThreadsQueryParamProperties, - OperationOptions {} -/** - * Optional parameters for getting an run step. - */ -export interface GetRunStepOptionalParams extends OperationOptions {} - -/** - * Optional parameters for listing run steps. - */ -export interface ListRunStepsOptionalParams extends ListQueryParameters, OperationOptions {} - -/** - * Optional parameters for creating a message. - */ -export interface CreateMessageOptionalParams extends OperationOptions {} - -/** - * Optional parameters for updating a message. - */ -export interface UpdateMessageOptionalParams extends OperationOptions { - /** Metadata to update in the message. */ - metadata?: Record | null; -} - -/** - * Optional parameters for listing messages. - */ -export interface ListMessagesOptionalParams - extends ListMessagesQueryParamProperties, - OperationOptions {} - -/** - * Optional parameters creating vector store. - */ -export interface CreateVectorStoreOptionalParams - extends VectorStoreOptions, - OperationOptions, - PollingOptionsParams {} - -/** - * Optional parameters for listing vector stores. - */ -export interface ListVectorStoresOptionalParams extends ListQueryParameters, OperationOptions {} - -/** - * Optional parameters for updating a vector store. - */ -export interface UpdateVectorStoreOptionalParams - extends VectorStoreUpdateOptions, - OperationOptions {} - -/** - * Optional parameters for deleting a vector store. - */ -export interface DeleteVectorStoreOptionalParams extends OperationOptions {} - -/** - * Optional parameters for getting a vector store. - */ -export interface GetVectorStoreOptionalParams extends OperationOptions {} - -/** - * Optional parameters for listing vector store files. - */ -export interface ListVectorStoreFilesOptionalParams extends ListQueryParameters, OperationOptions {} - -/** - * Optional parameters for creating a vector store file. - */ -export interface CreateVectorStoreFileOptionalParams - extends CreateVectorStoreFileOptions, - OperationOptions, - PollingOptionsParams {} - -/** - * Optional parameters for getting a vector store file. - */ -export interface GetVectorStoreFileOptionalParams extends OperationOptions {} - -/** - * Optional parameters for deleting a vector store file. - */ -export interface DeleteVectorStoreFileOptionalParams extends OperationOptions {} - -/** - * Optional parameters for listing vector store file batches. - */ -export interface ListVectorStoreFileBatchFilesOptionalParams - extends ListQueryParameters, - OperationOptions { - /** Filter by file status. */ - filter?: VectorStoreFileStatusFilter; -} - -/** - * Optional parameters for getting a vector store file batch. - */ -export interface GetVectorStoreFileBatchOptionalParams extends OperationOptions {} - -/** - * Optional parameters for canceling a vector store file batch. - */ -export interface CancelVectorStoreFileBatchOptionalParams extends OperationOptions {} - -/** - * Optional parameters for creating a vector store file batch. - */ -export interface CreateVectorStoreFileBatchOptionalParams - extends CreateVectorStoreFileBatchOptions, - OperationOptions, - PollingOptionsParams {} - -/** - * Optional parameters for creating agent. - */ -export interface CreateAgentOptionalParams - extends Omit, - OperationOptions {} - -/** - * Optional parameters for updating agent. - */ -export interface UpdateAgentOptionalParams extends UpdateAgentOptions, OperationOptions {} - -/** - * Optional parameters for deleting agent. - */ -export interface DeleteAgentOptionalParams extends OperationOptions {} - -/** - * Optional parameters for getting agent. - */ -export interface GetAgentOptionalParams extends OperationOptions {} - -/** - * Optional parameters for listing agents. - */ -export interface ListAgentsOptionalParams extends ListQueryParameters, OperationOptions {} - -/** - * Optional parameters for listing files. - */ -export interface ListFilesOptionalParams extends ListFilesQueryParamProperties, OperationOptions {} - -/** - * Optional parameters for deleting a file. - */ -export interface DeleteFileOptionalParams extends OperationOptions {} - -/** - * Optional parameters for getting a file. - */ -export interface GetFileOptionalParams extends OperationOptions {} - -/** - * Optional parameters for getting file content. - */ -export interface GetFileContentOptionalParams extends OperationOptions {} - -/** - * Optional parameters for uploading a file. - */ -export interface UploadFileOptionalParams extends OperationOptions, PollingOptionsParams { - /** The name of the file. */ - fileName?: string; -} diff --git a/sdk/ai/ai-projects/src/agents/files.ts b/sdk/ai/ai-projects/src/agents/files.ts deleted file mode 100644 index 5505cee62869..000000000000 --- a/sdk/ai/ai-projects/src/agents/files.ts +++ /dev/null @@ -1,197 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client, StreamableMethod } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { - FileDeletionStatusOutput, - FileListResponseOutput, - OpenAIFileOutput, -} from "../customization/outputModels.js"; -import type { FilePurpose as CustomizedFilePurpose } from "../customization/models.js"; -import type { - DeleteFileOptionalParams, - GetFileContentOptionalParams, - GetFileOptionalParams, - ListFilesOptionalParams, - UploadFileOptionalParams, -} from "./customModels.js"; -import { createPoller } from "./poller.js"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import * as ConvertFromWire from "../customization/convertOutputModelsFromWire.js"; -import * as ConvertParameters from "../customization/convertParametersToWire.js"; -import { randomUUID } from "@azure/core-util"; -import { createOpenAIError } from "./openAIError.js"; -import type { OperationState, OperationStatus, PollerLike } from "@azure/core-lro"; -const expectedStatuses = ["200"]; - -enum FilePurpose { - FineTune = "fine-tune", - FineTuneResults = "fine-tune-results", - Assistants = "assistants", - AssistantsOutput = "assistants_output", - Batch = "batch", - BatchOutput = "batch_output", - Vision = "vision", -} - -/** Gets a list of previously uploaded files. */ -export async function listFiles( - context: Client, - options: ListFilesOptionalParams = {}, -): Promise { - const listOptions: GeneratedParameters.ListFilesParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: ConvertParameters.convertListFilesQueryParamProperties(options), - }; - validateListFilesParameters(listOptions); - const result = await context.path("/files").get(options); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertFileListResponseOutput(result.body); -} - -/** Uploads a file for use by other operations. */ -export function uploadFile( - context: Client, - content: ReadableStream | NodeJS.ReadableStream, - purpose: CustomizedFilePurpose, - options: UploadFileOptionalParams = {}, -): PollerLike, OpenAIFileOutput> { - return createPoller({ - initOperation: async () => { - return uploadFileInternal(context, content, purpose, options); - }, - pollOperation: async (currentResult: OpenAIFileOutput) => { - return getFile(context, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - getOperationError: (result: OpenAIFileOutput) => { - return result.status === "failed" && result.statusDetails - ? new Error(`Operation failed: ${result.statusDetails}`) - : undefined; - }, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -export function uploadFileAndPoll( - context: Client, - content: ReadableStream | NodeJS.ReadableStream, - purpose: CustomizedFilePurpose, - options: UploadFileOptionalParams = {}, -): PollerLike, OpenAIFileOutput> { - return createPoller({ - initOperation: async () => { - return uploadFileInternal(context, content, purpose, options); - }, - pollOperation: async (currentResult: OpenAIFileOutput) => { - return getFile(context, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - getOperationError: (result: OpenAIFileOutput) => { - return result.status === "failed" && result.statusDetails - ? new Error(`Operation failed: ${result.statusDetails}`) - : undefined; - }, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -/** Delete a previously uploaded file. */ -export async function deleteFile( - context: Client, - fileId: string, - options: DeleteFileOptionalParams = {}, -): Promise { - const deleteOptions: GeneratedParameters.ListFilesParameters = { - ...operationOptionsToRequestParameters(options), - }; - validateFileId(fileId); - const result = await context.path("/files/{fileId}", fileId).delete(deleteOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; -} - -/** Returns information about a specific file. Does not retrieve file content. */ -export async function getFile( - context: Client, - fileId: string, - options: GetFileOptionalParams = {}, -): Promise { - validateFileId(fileId); - const getFileOptions: GeneratedParameters.ListFilesParameters = { - ...operationOptionsToRequestParameters(options), - }; - const result = await context.path("/files/{fileId}", fileId).get(getFileOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertOpenAIFileOutput(result.body); -} - -/** Returns file content. */ -export function getFileContent( - context: Client, - fileId: string, - options: GetFileContentOptionalParams = {}, -): StreamableMethod { - validateFileId(fileId); - const getFileContentOptions: GeneratedParameters.ListFilesParameters = { - ...operationOptionsToRequestParameters(options), - }; - return context.path("/files/{fileId}/content", fileId).get(getFileContentOptions); -} - -export async function uploadFileInternal( - context: Client, - content: ReadableStream | NodeJS.ReadableStream, - purpose: CustomizedFilePurpose, - options: UploadFileOptionalParams = {}, -): Promise { - const uploadFileOptions: GeneratedParameters.UploadFileParameters = { - ...operationOptionsToRequestParameters(options), - body: [ - { name: "file" as const, body: content, filename: options.fileName ?? randomUUID() }, - { name: "purpose" as const, body: purpose }, - ], - contentType: "multipart/form-data", - }; - const result = await context.path("/files").post(uploadFileOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertOpenAIFileOutput(result.body); -} - -function getLroOperationStatus(result: OpenAIFileOutput): OperationStatus { - switch (result.status) { - case "running": - case "pending": - return "running"; - case "uploaded": - case "processed": - return "succeeded"; - default: - return "failed"; - } -} - -function validateListFilesParameters(options?: GeneratedParameters.ListFilesParameters): void { - if (options?.queryParameters?.purpose) { - if (!Object.values(FilePurpose).includes(options?.queryParameters?.purpose as FilePurpose)) { - throw new Error( - "Purpose must be one of 'fine-tune', 'fine-tune-results', 'assistants', 'assistants_output', 'batch', 'batch_output', 'vision'", - ); - } - } -} - -function validateFileId(fileId: string): void { - if (!fileId) { - throw new Error("File ID is required"); - } -} diff --git a/sdk/ai/ai-projects/src/agents/index.ts b/sdk/ai/ai-projects/src/agents/index.ts deleted file mode 100644 index 780c4f064c16..000000000000 --- a/sdk/ai/ai-projects/src/agents/index.ts +++ /dev/null @@ -1,494 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { type Client, type StreamableMethod } from "@azure-rest/core-client"; -import type { - FileDeletionStatusOutput, - FileListResponseOutput, - OpenAIFileOutput, -} from "../customization/outputModels.js"; -import type { - OpenAIPageableListOfThreadRunOutput, - ThreadRunOutput, - AgentThreadOutput, - RunStepOutput, - OpenAIPageableListOfRunStepOutput, - ThreadMessageOutput, - ThreadDeletionStatusOutput, - OpenAIPageableListOfThreadMessageOutput, - OpenAIPageableListOfVectorStoreOutput, - VectorStoreOutput, - VectorStoreFileOutput, - VectorStoreDeletionStatusOutput, - VectorStoreFileDeletionStatusOutput, - VectorStoreFileBatchOutput, - OpenAIPageableListOfVectorStoreFileOutput, - AgentDeletionStatusOutput, - AgentOutput, - OpenAIPageableListOfAgentOutput, - OpenAIPageableListOfAgentThreadOutput, -} from "../customization/outputModels.js"; -import { createAgent, deleteAgent, getAgent, listAgents, updateAgent } from "./assistants.js"; -import { - deleteFile, - getFile, - getFileContent, - listFiles, - uploadFile, - uploadFileAndPoll, -} from "./files.js"; -import { createThread, deleteThread, getThread, listThreads, updateThread } from "./threads.js"; -import { - cancelRun, - createRun, - createThreadAndRun, - getRun, - listRuns, - submitToolOutputsToRun, - updateRun, -} from "./runs.js"; -import { createMessage, listMessages, updateMessage } from "./messages.js"; -import type { FilePurpose } from "../customization/models.js"; -import { - createVectorStore, - createVectorStoreAndPoll, - deleteVectorStore, - getVectorStore, - listVectorStores, - modifyVectorStore, -} from "./vectorStores.js"; -import { getRunStep, listRunSteps } from "./runSteps.js"; -import { - createVectorStoreFile, - createVectorStoreFileAndPoll, - deleteVectorStoreFile, - getVectorStoreFile, - listVectorStoreFiles, -} from "./vectorStoresFiles.js"; -import { - cancelVectorStoreFileBatch, - createVectorStoreFileBatch, - createVectorStoreFileBatchAndPoll, - getVectorStoreFileBatch, - listVectorStoreFileBatchFiles, -} from "./vectorStoresFileBatches.js"; -import type { - AgentRunResponse, - CreateRunOptionalParams, - GetRunOptionalParams, - CancelRunOptionalParams, - SubmitToolOutputsToRunOptionalParams, - UpdateRunOptionalParams, - ListRunQueryOptionalParams, - CreateAndRunThreadOptionalParams, - CreateAgentThreadOptionalParams, - GetAgentThreadOptionalParams, - UpdateAgentThreadOptionalParams, - DeleteAgentThreadOptionalParams, - GetRunStepOptionalParams, - ListRunStepsOptionalParams, - CreateMessageOptionalParams, - ListMessagesOptionalParams, - UpdateMessageOptionalParams, - GetVectorStoreOptionalParams, - ListVectorStoresOptionalParams, - UpdateVectorStoreOptionalParams, - DeleteVectorStoreOptionalParams, - CreateVectorStoreOptionalParams, - CreateVectorStoreFileOptionalParams, - ListVectorStoreFilesOptionalParams, - GetVectorStoreFileOptionalParams, - DeleteVectorStoreFileOptionalParams, - CreateVectorStoreFileBatchOptionalParams, - GetVectorStoreFileBatchOptionalParams, - ListVectorStoreFileBatchFilesOptionalParams, - CreateAgentOptionalParams, - ListAgentsOptionalParams, - GetAgentOptionalParams, - UpdateAgentOptionalParams, - DeleteFileOptionalParams, - GetFileOptionalParams, - GetFileContentOptionalParams, - ListFilesOptionalParams, - UploadFileOptionalParams, - CancelVectorStoreFileBatchOptionalParams, - DeleteAgentOptionalParams, - ListAgentThreadOptionalParams, -} from "./customModels.js"; -import type { ThreadMessageOptions, ToolOutput } from "../customization/models.js"; -import type { PollerLike, OperationState } from "@azure/core-lro"; - -/** - * Agents Interface Contains operations for creating, listing, updating, and deleting agents, threads, runs, messages, and files. - */ -export interface AgentsOperations { - /** Creates a new agent. */ - createAgent: (model: string, options?: CreateAgentOptionalParams) => Promise; - - /** Gets a list of agents that were previously created. */ - listAgents: (options?: ListAgentsOptionalParams) => Promise; - /** Retrieves an existing agent. */ - getAgent: (assistantId: string, options?: GetAgentOptionalParams) => Promise; - /** Modifies an existing agent. */ - updateAgent: (assistantId: string, options: UpdateAgentOptionalParams) => Promise; - /** Deletes an agent. */ - deleteAgent: ( - assistantId: string, - options?: DeleteAgentOptionalParams, - ) => Promise; - - /** Creates a new thread. Threads contain messages and can be run by agents. */ - createThread: (options?: CreateAgentThreadOptionalParams) => Promise; - /** Gets information about an existing thread. */ - getThread: ( - threadId: string, - options?: GetAgentThreadOptionalParams, - ) => Promise; - /** Modifies an existing thread. */ - updateThread: ( - threadId: string, - options?: UpdateAgentThreadOptionalParams, - ) => Promise; - /** Deletes an existing thread. */ - deleteThread: ( - threadId: string, - options?: DeleteAgentThreadOptionalParams, - ) => Promise; - /** Gets a list of threads that were previously created. */ - listThreads: ( - options?: ListAgentThreadOptionalParams, - ) => Promise; - - /** Creates and starts a new run of the specified thread using the specified agent. */ - createRun: ( - threadId: string, - assistantId: string, - options?: CreateRunOptionalParams, - ) => AgentRunResponse; - - /** Gets a list of runs for a specified thread. */ - listRuns: ( - threadId: string, - options?: ListRunQueryOptionalParams, - ) => Promise; - /** Gets an existing run from an existing thread. */ - getRun: ( - threadId: string, - runId: string, - options?: GetRunOptionalParams, - ) => Promise; - /** Modifies an existing thread run. */ - updateRun: ( - threadId: string, - runId: string, - options?: UpdateRunOptionalParams, - ) => Promise; - /** Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. */ - submitToolOutputsToRun: ( - threadId: string, - runId: string, - toolOutputs: Array, - options?: SubmitToolOutputsToRunOptionalParams, - ) => AgentRunResponse; - - /** Cancels a run of an in progress thread. */ - cancelRun: ( - threadId: string, - runId: string, - options?: CancelRunOptionalParams, - ) => Promise; - /** Creates a new thread and immediately starts a run of that thread. */ - createThreadAndRun: ( - assistantId: string, - options?: CreateAndRunThreadOptionalParams, - ) => AgentRunResponse; - - /** Creates a new message on a specified thread. */ - createMessage: ( - threadId: string, - messageOptions: ThreadMessageOptions, - options?: CreateMessageOptionalParams, - ) => Promise; - /** Gets a list of messages that exist on a thread. */ - listMessages: ( - threadId: string, - options?: ListMessagesOptionalParams, - ) => Promise; - /** Modifies an existing message on an existing thread. */ - updateMessage: ( - threadId: string, - messageId: string, - options?: UpdateMessageOptionalParams, - ) => Promise; - - /** Gets a list of previously uploaded files. */ - listFiles: (options?: ListFilesOptionalParams) => Promise; - /** Uploads a file for use by other operations. */ - uploadFile: ( - data: ReadableStream | NodeJS.ReadableStream, - purpose: FilePurpose, - options?: UploadFileOptionalParams, - ) => PollerLike, OpenAIFileOutput>; - - /** Uploads a file for use by other operations. */ - uploadFileAndPoll: ( - data: ReadableStream | NodeJS.ReadableStream, - purpose: FilePurpose, - options?: UploadFileOptionalParams, - ) => PollerLike, OpenAIFileOutput>; - /** Delete a previously uploaded file. */ - deleteFile: ( - fileId: string, - options?: DeleteFileOptionalParams, - ) => Promise; - /** Returns information about a specific file. Does not retrieve file content. */ - getFile: (fileId: string, options?: GetFileOptionalParams) => Promise; - /** Returns the content of a specific file. */ - getFileContent: ( - fileId: string, - options?: GetFileContentOptionalParams, - ) => StreamableMethod; - - /** Returns a list of vector stores. */ - listVectorStores: ( - options?: ListVectorStoresOptionalParams, - ) => Promise; - /** Creates a vector store. */ - createVectorStore: ( - options?: CreateVectorStoreOptionalParams, - ) => PollerLike, VectorStoreOutput>; - /** Returns the vector store object object matching the specific ID. */ - getVectorStore: ( - vectorStoreId: string, - options?: GetVectorStoreOptionalParams, - ) => Promise; - /** The ID of the vector store to modify. */ - modifyVectorStore: ( - vectorStoreId: string, - options?: UpdateVectorStoreOptionalParams, - ) => Promise; - /** Deletes the vector store object matching the specified ID. */ - deleteVectorStore: ( - vectorStoreId: string, - options?: DeleteVectorStoreOptionalParams, - ) => Promise; - - /** Create vector store and poll. */ - createVectorStoreAndPoll: ( - options?: CreateVectorStoreOptionalParams, - ) => PollerLike, VectorStoreOutput>; - - /** Create a vector store file by attching a file to a vector store. */ - createVectorStoreFile: ( - vectorStoreId: string, - options?: CreateVectorStoreFileOptionalParams, - ) => PollerLike, VectorStoreFileOutput>; - /** Retrieves a vector store file. */ - getVectorStoreFile: ( - vectorStoreId: string, - fileId: string, - options?: GetVectorStoreFileOptionalParams, - ) => Promise; - /** Returns a list of vector store files. */ - listVectorStoreFiles: ( - vectorStoreId: string, - options?: ListVectorStoreFilesOptionalParams, - ) => Promise; - /** - * Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. - * To delete the file, use the delete file endpoint. - */ - deleteVectorStoreFile: ( - vectorStoreId: string, - fileId: string, - options?: DeleteVectorStoreFileOptionalParams, - ) => Promise; - /** Create a vector store file by attaching a file to a vector store and poll. */ - createVectorStoreFileAndPoll: ( - vectorStoreId: string, - options?: CreateVectorStoreFileOptionalParams, - ) => PollerLike, VectorStoreFileOutput>; - - /** Create a vector store file batch. */ - createVectorStoreFileBatch: ( - vectorStoreId: string, - options?: CreateVectorStoreFileBatchOptionalParams, - ) => PollerLike, VectorStoreFileBatchOutput>; - /** Retrieve a vector store file batch. */ - getVectorStoreFileBatch: ( - vectorStoreId: string, - batchId: string, - options?: GetVectorStoreFileBatchOptionalParams, - ) => Promise; - /** Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. */ - cancelVectorStoreFileBatch: ( - vectorStoreId: string, - batchId: string, - options?: CancelVectorStoreFileBatchOptionalParams, - ) => Promise; - /** Returns a list of vector store files in a batch. */ - listVectorStoreFileBatchFiles: ( - vectorStoreId: string, - batchId: string, - options?: ListVectorStoreFileBatchFilesOptionalParams, - ) => Promise; - /** Create a vector store file batch and poll. */ - createVectorStoreFileBatchAndPoll: ( - vectorStoreId: string, - options?: CreateVectorStoreFileBatchOptionalParams, - ) => PollerLike, VectorStoreFileBatchOutput>; - - /** Gets a single run step from a thread run. */ - getRunStep: ( - threadId: string, - runId: string, - stepId: string, - options?: GetRunStepOptionalParams, - ) => Promise; - /** Gets a list of run steps from a thread run. */ - listRunSteps: ( - threadId: string, - runId: string, - options?: ListRunQueryOptionalParams, - ) => Promise; -} - -function getAgents(context: Client): AgentsOperations { - return { - createAgent: (model: string, options?: CreateAgentOptionalParams) => - createAgent(context, model, options), - listAgents: (options?: ListAgentsOptionalParams) => listAgents(context, options), - getAgent: (assistantId: string, options?: GetAgentOptionalParams) => - getAgent(context, assistantId, options), - updateAgent: (assistantId: string, options: UpdateAgentOptionalParams) => - updateAgent(context, assistantId, options), - deleteAgent: (assistantId: string, options?: DeleteAgentOptionalParams) => - deleteAgent(context, assistantId, options), - - createThread: (options?: CreateAgentThreadOptionalParams) => createThread(context, options), - getThread: (threadId: string, options?: GetAgentThreadOptionalParams) => - getThread(context, threadId, options), - updateThread: (threadId: string, options?: UpdateAgentThreadOptionalParams) => - updateThread(context, threadId, options), - deleteThread: (threadId: string, options?: DeleteAgentThreadOptionalParams) => - deleteThread(context, threadId, options), - listThreads: (options?: ListAgentThreadOptionalParams) => listThreads(context, options), - - createRun: (threadId: string, assistantId: string, options?: CreateRunOptionalParams) => - createRun(context, threadId, assistantId, options ?? {}), - listRuns: (threadId: string, options?: ListRunQueryOptionalParams) => - listRuns(context, threadId, options ?? {}), - getRun: (threadId: string, runId: string, options?: GetRunOptionalParams) => - getRun(context, threadId, runId, options), - updateRun: (threadId: string, runId: string, options?: UpdateRunOptionalParams) => - updateRun(context, threadId, runId, options), - submitToolOutputsToRun: ( - threadId: string, - runId: string, - toolOutputs: Array, - options?: SubmitToolOutputsToRunOptionalParams, - ) => submitToolOutputsToRun(context, threadId, runId, toolOutputs, options), - cancelRun: (threadId: string, runId: string, options?: CancelRunOptionalParams) => - cancelRun(context, threadId, runId, options), - createThreadAndRun: (assistantId: string, options?: CreateAndRunThreadOptionalParams) => - createThreadAndRun(context, assistantId, options ?? {}), - - createMessage: ( - threadId: string, - messageOptions: ThreadMessageOptions, - options?: CreateMessageOptionalParams, - ) => createMessage(context, threadId, messageOptions, options), - listMessages: (threadId: string, options?: ListMessagesOptionalParams) => - listMessages(context, threadId, options), - updateMessage: (threadId: string, messageId: string, options?: UpdateMessageOptionalParams) => - updateMessage(context, threadId, messageId, options), - - listFiles: (options?: ListFilesOptionalParams) => listFiles(context, options), - uploadFile: ( - content: ReadableStream | NodeJS.ReadableStream, - purpose: FilePurpose, - options?: UploadFileOptionalParams, - ) => uploadFile(context, content, purpose, options), - uploadFileAndPoll: ( - content: ReadableStream | NodeJS.ReadableStream, - purpose: FilePurpose, - options?: UploadFileOptionalParams, - ) => uploadFileAndPoll(context, content, purpose, options), - deleteFile: (fileId: string, options?: DeleteFileOptionalParams) => - deleteFile(context, fileId, options), - getFile: (fileId: string, options?: GetFileOptionalParams) => getFile(context, fileId, options), - getFileContent: (fileId: string, options?: GetFileContentOptionalParams) => - getFileContent(context, fileId, options), - - listVectorStores: (options?: ListVectorStoresOptionalParams) => - listVectorStores(context, options), - createVectorStore: (options?: CreateVectorStoreOptionalParams) => - createVectorStore(context, options), - getVectorStore: (vectorStoreId: string, options?: GetVectorStoreOptionalParams) => - getVectorStore(context, vectorStoreId, options), - modifyVectorStore: (vectorStoreId: string, options?: UpdateVectorStoreOptionalParams) => - modifyVectorStore(context, vectorStoreId, options), - deleteVectorStore: (vectorStoreId: string, options?: DeleteVectorStoreOptionalParams) => - deleteVectorStore(context, vectorStoreId, options), - createVectorStoreAndPoll: (options?: CreateVectorStoreOptionalParams) => - createVectorStoreAndPoll(context, options), - - createVectorStoreFile: (vectorStoreId: string, options?: CreateVectorStoreFileOptionalParams) => - createVectorStoreFile(context, vectorStoreId, options), - getVectorStoreFile: ( - vectorStoreId: string, - fileId: string, - options?: GetVectorStoreFileOptionalParams, - ) => getVectorStoreFile(context, vectorStoreId, fileId, options), - listVectorStoreFiles: (vectorStoreId: string, options?: ListVectorStoreFilesOptionalParams) => - listVectorStoreFiles(context, vectorStoreId, options), - deleteVectorStoreFile: ( - vectorStoreId: string, - fileId: string, - options?: DeleteVectorStoreFileOptionalParams, - ) => deleteVectorStoreFile(context, vectorStoreId, fileId, options), - createVectorStoreFileAndPoll: ( - vectorStoreId: string, - options?: CreateVectorStoreFileOptionalParams, - ) => createVectorStoreFileAndPoll(context, vectorStoreId, options), - - createVectorStoreFileBatch: ( - vectorStoreId: string, - options?: CreateVectorStoreFileBatchOptionalParams, - ) => createVectorStoreFileBatch(context, vectorStoreId, options), - getVectorStoreFileBatch: ( - vectorStoreId: string, - batchId: string, - options?: GetVectorStoreFileBatchOptionalParams, - ) => getVectorStoreFileBatch(context, vectorStoreId, batchId, options), - cancelVectorStoreFileBatch: ( - vectorStoreId: string, - batchId: string, - options?: CancelVectorStoreFileBatchOptionalParams, - ) => cancelVectorStoreFileBatch(context, vectorStoreId, batchId, options), - listVectorStoreFileBatchFiles: ( - vectorStoreId: string, - batchId: string, - options?: ListVectorStoreFileBatchFilesOptionalParams, - ) => listVectorStoreFileBatchFiles(context, vectorStoreId, batchId, options), - createVectorStoreFileBatchAndPoll: ( - vectorStoreId: string, - options?: CreateVectorStoreFileBatchOptionalParams, - ) => createVectorStoreFileBatchAndPoll(context, vectorStoreId, options), - - getRunStep: ( - threadId: string, - runId: string, - stepId: string, - options?: GetRunStepOptionalParams, - ) => getRunStep(context, threadId, runId, stepId, options), - listRunSteps: (threadId: string, runId: string, options?: ListRunStepsOptionalParams) => - listRunSteps(context, threadId, runId, options), - }; -} - -export function getAgentsOperations(context: Client): AgentsOperations { - return { - ...getAgents(context), - }; -} diff --git a/sdk/ai/ai-projects/src/agents/inputOutputs.ts b/sdk/ai/ai-projects/src/agents/inputOutputs.ts deleted file mode 100644 index 642ecce1e9bc..000000000000 --- a/sdk/ai/ai-projects/src/agents/inputOutputs.ts +++ /dev/null @@ -1,307 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -export * from "../customization/streamingModels.js"; -export * from "./streamingModels.js"; -export * from "./vectorStoresModels.js"; -export * from "./utils.js"; -export * from "../customization/streamingModels.js"; -export type { - OpenAIPageableListOfThreadRunOutput, - ThreadRunOutput, - AgentThreadOutput, - RunStepOutput, - OpenAIPageableListOfRunStepOutput, - ThreadMessageOutput, - ThreadDeletionStatusOutput, - OpenAIPageableListOfThreadMessageOutput, - OpenAIPageableListOfVectorStoreOutput, - VectorStoreOutput, - VectorStoreFileOutput, - VectorStoreDeletionStatusOutput, - VectorStoreFileDeletionStatusOutput, - VectorStoreFileBatchOutput, - OpenAIPageableListOfVectorStoreFileOutput, - AgentDeletionStatusOutput, - AgentOutput, - OpenAIPageableListOfAgentOutput, - FileDeletionStatusOutput, - FileListResponseOutput, - OpenAIFileOutput, - RequiredActionOutput, - RequiredToolCallOutput, - ToolDefinitionOutputParent, - AgentsApiResponseFormatOptionOutput, - ToolDefinitionOutput, - ToolResourcesOutput, - AgentsApiResponseFormatModeOutput, - AgentsApiResponseFormatOutput, - FilePurposeOutput, - FileStateOutput, - RequiredActionOutputParent, - SubmitToolOutputsActionOutput, - RequiredToolCallOutputParent, - RequiredFunctionToolCallOutput, - RunStepErrorOutput, - RunStepStatusOutput, - RunStepDetailsOutput, - RunStepTypeOutput, - RunStepCompletionUsageOutput, - MessageAttachmentOutput, - MessageContentOutput, - MessageIncompleteDetailsOutput, - MessageRoleOutput, - MessageStatusOutput, - IncompleteRunDetailsOutput, - RunErrorOutput, - RunStatusOutput, - AgentsApiToolChoiceOptionOutput, - UpdateToolResourcesOptionsOutput, - TruncationObjectOutput, - RunCompletionUsageOutput, - CodeInterpreterToolDefinitionOutput, - FileSearchToolDefinitionOutput, - FunctionToolDefinitionOutput, - BingGroundingToolDefinitionOutput, - BingCustomSearchToolDefinitionOutput, - SearchConfigurationListOutput, - SearchConfigurationOutput, - AzureAISearchToolDefinitionOutput, - AzureAISearchResourceOutput, - CodeInterpreterToolResourceOutput, - FileSearchToolResourceOutput, - VectorStoreFileCountOutput, - VectorStoreFileBatchStatusOutput, - VectorStoreChunkingStrategyResponseOutput, - VectorStoreConfigurationOutput, - AgentsNamedToolChoiceOutput, - IndexResourceOutput, - ToolConnectionListOutput, - VectorStoreDataSourceOutput, - FileSearchToolDefinitionDetailsOutput, - VectorStoreConfigurationsOutput, - FunctionDefinitionOutput, - MessageAttachmentToolDefinitionOutput, - MessageContentOutputParent, - MessageTextContentOutput, - MessageImageFileContentOutput, - RequiredFunctionToolCallDetailsOutput, - RunStepDetailsOutputParent, - RunStepMessageCreationDetailsOutput, - RunStepToolCallDetailsOutput, - RunStepErrorCodeOutput, - SubmitToolOutputsDetailsOutput, - MicrosoftFabricToolDefinitionOutput, - SharepointToolDefinitionOutput, - UpdateCodeInterpreterToolResourceOptionsOutput, - UpdateFileSearchToolResourceOptionsOutput, - VectorStoreChunkingStrategyResponseOutputParent, - VectorStoreAutoChunkingStrategyResponseOutput, - VectorStoreStaticChunkingStrategyResponseOutput, - VectorStoreFileErrorOutput, - VectorStoreFileStatusOutput, - VectorStoreExpirationPolicyOutput, - VectorStoreStatusOutput, - AgentsApiToolChoiceOptionModeOutput, - FunctionNameOutput, - AgentsNamedToolChoiceTypeOutput, - MessageImageFileDetailsOutput, - MessageIncompleteDetailsReasonOutput, - MessageTextDetailsOutput, - RunStepMessageCreationReferenceOutput, - RunStepToolCallOutput, - ToolConnectionOutput, - TruncationStrategyOutput, - VectorStoreChunkingStrategyResponseTypeOutput, - VectorStoreDataSourceAssetTypeOutput, - VectorStoreExpirationPolicyAnchorOutput, - VectorStoreFileErrorCodeOutput, - VectorStoreStaticChunkingStrategyOptionsOutput, - FileSearchRankingOptionsOutput, - MessageTextAnnotationOutput, - RunStepToolCallOutputParent, - RunStepCodeInterpreterToolCallOutput, - RunStepFileSearchToolCallOutput, - RunStepBingGroundingToolCallOutput, - RunStepAzureAISearchToolCallOutput, - RunStepSharepointToolCallOutput, - RunStepMicrosoftFabricToolCallOutput, - RunStepFunctionToolCallOutput, - MessageTextAnnotationOutputParent, - MessageTextFileCitationAnnotationOutput, - MessageTextFilePathAnnotationOutput, - RunStepCodeInterpreterToolCallOutputOutputParent, - RunStepCodeInterpreterToolCallDetailsOutput, - RunStepFunctionToolCallDetailsOutput, - MessageTextFileCitationDetailsOutput, - MessageTextFilePathDetailsOutput, - RunStepCodeInterpreterToolCallOutputOutput, - RunStepCodeInterpreterLogOutputOutput, - RunStepCodeInterpreterImageOutputOutput, - RunStepCodeInterpreterImageReferenceOutput, - ResponseFormatOutput, - ResponseFormatJsonSchemaTypeOutput, - IncompleteDetailsReasonOutput, - RunStepFileSearchToolCallResultsOutput, - ResponseFormatJsonSchemaOutput, - RunStepFileSearchToolCallResultOutput, - FileSearchToolCallContentOutput, - AzureFunctionToolDefinitionOutput, - AzureFunctionDefinitionOutput, - AzureFunctionBindingOutput, - OpenApiToolDefinitionOutput, - OpenApiFunctionDefinitionOutput, - OpenApiAuthDetailsOutput, - OpenApiAuthTypeOutput, - OpenApiAuthDetailsOutputParent, - OpenApiAnonymousAuthDetailsOutput, - OpenApiConnectionAuthDetailsOutput, - OpenApiManagedAuthDetailsOutput, - AzureFunctionStorageQueueOutput, - OpenApiConnectionSecuritySchemeOutput, - OpenApiManagedSecuritySchemeOutput, - OpenAIPageableListOfAgentThreadOutput, -} from "../customization/outputModels.js"; -export { - ListMessagesQueryParamProperties, - ListFilesQueryParamProperties, - ListThreadsQueryParamProperties, -} from "../customization/parameters.js"; -export type { - AgentRunResponse, - CreateRunOptionalParams, - GetRunOptionalParams, - CancelRunOptionalParams, - SubmitToolOutputsToRunOptionalParams, - UpdateRunOptionalParams, - ListRunQueryOptionalParams, - CreateAndRunThreadOptionalParams, - CreateAgentThreadOptionalParams, - GetAgentThreadOptionalParams, - UpdateAgentThreadOptionalParams, - DeleteAgentThreadOptionalParams, - GetRunStepOptionalParams, - ListRunStepsOptionalParams, - CreateMessageOptionalParams, - ListMessagesOptionalParams, - UpdateMessageOptionalParams, - GetVectorStoreOptionalParams, - ListVectorStoresOptionalParams, - UpdateVectorStoreOptionalParams, - DeleteVectorStoreOptionalParams, - CreateVectorStoreOptionalParams, - CreateVectorStoreFileOptionalParams, - ListVectorStoreFilesOptionalParams, - GetVectorStoreFileOptionalParams, - DeleteVectorStoreFileOptionalParams, - CreateVectorStoreFileBatchOptionalParams, - GetVectorStoreFileBatchOptionalParams, - ListVectorStoreFileBatchFilesOptionalParams, - CreateAgentOptionalParams, - ListAgentsOptionalParams, - GetAgentOptionalParams, - UpdateAgentOptionalParams, - DeleteFileOptionalParams, - GetFileOptionalParams, - GetFileContentOptionalParams, - ListFilesOptionalParams, - UploadFileOptionalParams, - ListQueryParameters, - PollingOptions, - PollingOptionsParams, - CancelVectorStoreFileBatchOptionalParams, - DeleteAgentOptionalParams, - ListAgentThreadOptionalParams, -} from "./customModels.js"; - -export { - AzureAISearchToolDefinition, - CodeInterpreterToolDefinition, - FileSearchToolDefinition, - FileSearchToolDefinitionDetails, - FunctionDefinition, - FunctionToolDefinition, - ToolResources, - VectorStoreConfigurations, - VectorStoreDataSource, - ToolDefinition, - ThreadMessageOptions, - ToolOutput, - FilePurpose, - ToolDefinitionParent, - AgentThreadCreationOptions, - CreateAgentOptions, - CreateAndRunThreadOptions, - CreateRunOptions, - UpdateAgentOptions, - UpdateAgentThreadOptions, - VectorStoreFileStatusFilter, - VectorStoreOptions, - VectorStoreUpdateOptions, - AgentsApiResponseFormatMode, - AgentsApiToolChoiceOption, - TruncationObject, - UpdateToolResourcesOptions, - VectorStoreChunkingStrategyRequest, - FileSearchRankingOptions, - AgentsApiToolChoiceOptionMode, - AgentsNamedToolChoice, - AgentsApiResponseFormatOption, - ConnectionType, - ListSortOrder, - MessageAttachment, - BingGroundingToolDefinition, - MicrosoftFabricToolDefinition, - SharepointToolDefinition, - AzureAISearchResource, - CodeInterpreterToolResource, - FileSearchToolResource, - TruncationStrategy, - UpdateCodeInterpreterToolResourceOptions, - UpdateFileSearchToolResourceOptions, - VectorStoreChunkingStrategyRequestParent, - VectorStoreAutoChunkingStrategyRequest, - VectorStoreStaticChunkingStrategyRequest, - VectorStoreConfiguration, - VectorStoreDataSourceAssetType, - AgentsApiResponseFormat, - FunctionName, - AgentsNamedToolChoiceType, - IndexResource, - ToolConnectionList, - MessageAttachmentToolDefinition, - MessageRole, - VectorStoreChunkingStrategyRequestType, - VectorStoreExpirationPolicy, - VectorStoreStaticChunkingStrategyOptions, - ToolConnection, - VectorStoreExpirationPolicyAnchor, - ResponseFormat, - ResponseFormatJsonSchemaType, - OpenApiToolDefinition, - AzureFunctionToolDefinition, - OpenApiFunctionDefinition, - ResponseFormatJsonSchema, - AzureFunctionDefinition, - AzureFunctionBinding, - OpenApiAuthDetails, - AzureFunctionStorageQueue, - OpenApiAuthType, - OpenApiAuthDetailsParent, - OpenApiAnonymousAuthDetails, - OpenApiConnectionAuthDetails, - OpenApiManagedAuthDetails, - OpenApiConnectionSecurityScheme, - OpenApiManagedSecurityScheme, - CreateMessageContent, - MessageContentBlockInput, - MessageContentBlockInputParent, - MessageTextBlockInput, - MessageImageFileBlockInput, - MessageImageUrlBlockInput, - MessageBlockType, - MessageImageFileParam, - MessageImageUrlParam, - ImageDetailLevel, - AzureFunctionToolResource, -} from "../customization/models.js"; diff --git a/sdk/ai/ai-projects/src/agents/inputValidations.ts b/sdk/ai/ai-projects/src/agents/inputValidations.ts deleted file mode 100644 index c2403cf3d104..000000000000 --- a/sdk/ai/ai-projects/src/agents/inputValidations.ts +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - ToolDefinition, - UpdateToolResourcesOptions, - VectorStoreDataSource, -} from "../generated/src/models.js"; - -export function validateVectorStoreDataType(data_sources: VectorStoreDataSource[]): void { - if (!data_sources.some((value) => !["uri_asset", "id_asset"].includes(value.type))) { - throw new Error("Vector store data type must be one of 'uri_asset', 'id_asset'"); - } -} - -export function validateThreadId(threadId: string): void { - if (!threadId) { - throw new Error("Thread ID is required"); - } -} - -export function validateRunId(runId: string): void { - if (!runId) { - throw new Error("Run ID is required"); - } -} - -export function validateLimit(limit: number): void { - if (limit < 1 || limit > 100) { - throw new Error("Limit must be between 1 and 100"); - } -} - -export function validateOrder(order: string): void { - if (!["asc", "desc"].includes(order)) { - throw new Error("Order must be 'asc' or 'desc'"); - } -} - -enum Tools { - CodeInterpreter = "code_interpreter", - FileSearch = "file_search", - Function = "function", - BingGrounding = "bing_grounding", - MicrosoftFabric = "fabric_dataagent", - SharepointGrounding = "sharepoint_grounding", - AzureAISearch = "azure_ai_search", - AzureFunction = "azure_function", -} - -export function validateTools(value: Array): void { - if (value.some((tool) => !Object.values(Tools).includes(tool as unknown as Tools))) { - throw new Error( - "Tool type must be one of 'code_interpreter', 'file_search', 'function', 'bing_grounding', 'fabric_dataagent', 'sharepoint_grounding', 'azure_ai_search', 'azure_function'", - ); - } -} - -export function validateMetadata(metadata: Record): void { - if (Object.keys(metadata).length > 16) { - throw new Error("Only 16 key/value pairs are allowed"); - } - if (Object.keys(metadata).some((value) => value.length > 64)) { - throw new Error("Keys must be less than 64 characters"); - } - if (Object.values(metadata).some((value) => value.length > 512)) { - throw new Error("Values must be less than 512 characters"); - } -} - -export function validateToolResources(toolResource: UpdateToolResourcesOptions): void { - if (toolResource.code_interpreter) { - if ( - toolResource.code_interpreter.file_ids && - toolResource.code_interpreter.file_ids.length > 20 - ) { - throw new Error("A maximum of 20 file IDs are allowed"); - } - } - if (toolResource.file_search) { - if ( - toolResource.file_search.vector_store_ids && - toolResource.file_search.vector_store_ids.length > 1 - ) { - throw new Error("Only one vector store ID is allowed"); - } - } - if (toolResource.azure_ai_search) { - if (toolResource.azure_ai_search.indexes && toolResource.azure_ai_search.indexes.length > 1) { - throw new Error("Only one index is allowed"); - } - } -} - -export function validateVectorStoreId(vectorStoreId: string): void { - if (!vectorStoreId) { - throw new Error("Vector store ID is required"); - } -} - -export function validateFileId(fileId: string): void { - if (!fileId) { - throw new Error("File ID is required"); - } -} - -enum FileBatchStatus { - InProgress = "in_progress", - Completed = "completed", - Failed = "failed", - Cancelled = "cancelled", -} - -export function validateFileStatusFilter(filter: string): void { - if (!Object.values(FileBatchStatus).includes(filter as FileBatchStatus)) { - throw new Error( - "File status filter must be one of 'in_progress', 'completed', 'failed', 'cancelled'", - ); - } -} - -enum Messages { - User = "user", - Assistants = "assistant", -} - -export function validateMessages(value: string): void { - if (!Object.values(Messages).includes(value as Messages)) { - throw new Error("Role must be either 'user' or 'assistant'"); - } -} - -enum TruncationStrategy { - Auto = "auto", - LastMessages = "last_messages", -} - -export function validateTruncationStrategy(value: string): void { - if (!Object.values(TruncationStrategy).includes(value as TruncationStrategy)) { - throw new Error("Role must be either 'auto' or 'last_messages'"); - } -} diff --git a/sdk/ai/ai-projects/src/agents/messages.ts b/sdk/ai/ai-projects/src/agents/messages.ts deleted file mode 100644 index 30ccef39cf3a..000000000000 --- a/sdk/ai/ai-projects/src/agents/messages.ts +++ /dev/null @@ -1,191 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { - OpenAIPageableListOfThreadMessageOutput, - ThreadMessageOutput, -} from "../customization/outputModels.js"; -import type { - CreateMessageParameters, - ListMessagesParameters, -} from "../generated/src/parameters.js"; -import { validateMetadata, validateVectorStoreDataType } from "./inputValidations.js"; -import { TracingUtility } from "../tracing.js"; -import { - traceEndCreateMessage, - traceEndListMessages, - traceStartCreateMessage, - traceStartListMessages, -} from "./messagesTrace.js"; -import { traceStartAgentGeneric } from "./traceUtility.js"; -import type { ThreadMessageOptions } from "../customization/models.js"; -import type { - CreateMessageOptionalParams, - ListMessagesOptionalParams, - UpdateMessageOptionalParams, -} from "./customModels.js"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import * as ConvertFromWire from "../customization/convertOutputModelsFromWire.js"; -import { createOpenAIError } from "./openAIError.js"; - -const expectedStatuses = ["200"]; - -/** Creates a new message on a specified thread. */ -export async function createMessage( - context: Client, - threadId: string, - messageOptions: ThreadMessageOptions, - options: CreateMessageOptionalParams = {}, -): Promise { - const createOptions: GeneratedParameters.CreateMessageParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...messageOptions, - }, - }; - - validateThreadId(threadId); - validateCreateMessageParameters(createOptions); - const response = await TracingUtility.withSpan( - "CreateMessage", - createOptions, - async (updateOptions) => { - const result = await context - .path("/threads/{threadId}/messages", threadId) - .post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => traceStartCreateMessage(span, threadId, updatedOptions), - traceEndCreateMessage, - ); - return ConvertFromWire.convertThreadMessageOutput(response); -} - -/** Gets a list of messages that exist on a thread. */ -export async function listMessages( - context: Client, - threadId: string, - options: ListMessagesOptionalParams = {}, -): Promise { - const listOptions: GeneratedParameters.ListMessagesParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: { - ...(options.runId && { run_id: options.runId }), - ...(options.limit && { limit: options.limit }), - ...(options.order && { order: options.order }), - ...(options.after && { after: options.after }), - ...(options.before && { before: options.before }), - }, - }; - - validateThreadId(threadId); - validateListMessagesParameters(listOptions); - const output = await TracingUtility.withSpan( - "ListMessages", - listOptions, - async (updateOptions) => { - const result = await context - .path("/threads/{threadId}/messages", threadId) - .get(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => traceStartListMessages(span, threadId, updatedOptions), - traceEndListMessages, - ); - - return ConvertFromWire.convertOpenAIPageableListOfThreadMessageOutput(output); -} - -/** Modifies an existing message on an existing thread. */ -export async function updateMessage( - context: Client, - threadId: string, - messageId: string, - options: UpdateMessageOptionalParams = {}, -): Promise { - const updateMessageOptions: GeneratedParameters.UpdateMessageParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...(options.metadata ? { metadata: options.metadata } : {}), - }, - }; - validateThreadId(threadId); - validateMessageId(messageId); - const response = await TracingUtility.withSpan( - "UpdateMessage", - updateMessageOptions, - async (updateOptions) => { - const result = await context - .path("/threads/{threadId}/messages/{messageId}", threadId, messageId) - .post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { threadId: threadId, messageId: messageId }, - }), - ); - - return ConvertFromWire.convertThreadMessageOutput(response); -} - -function validateThreadId(threadId: string): void { - if (!threadId) { - throw new Error("Thread ID is required"); - } -} - -function validateMessageId(messageId: string): void { - if (!messageId) { - throw new Error("Message ID is required"); - } -} - -function validateCreateMessageParameters(options: CreateMessageParameters): void { - if (options.body.role && !["user", "assistant"].includes(options.body.role)) { - throw new Error("Role must be either 'user' or 'assistant'"); - } - if (options.body.metadata) { - validateMetadata(options.body.metadata); - } - if (options.body.attachments) { - if ( - options.body.attachments.some((value) => { - value.tools.some((tool) => !["code_interpreter", "file_search"].includes(tool.type)); - }) - ) { - throw new Error("Tool type must be either 'code_interpreter' or 'file_search'"); - } - if (options.body.attachments) { - options.body.attachments.forEach((value) => { - if (value.data_source) { - validateVectorStoreDataType([value.data_source]); - } - }); - } - } -} - -function validateListMessagesParameters(options?: ListMessagesParameters): void { - if ( - options?.queryParameters?.limit && - (options.queryParameters.limit < 1 || options.queryParameters.limit > 100) - ) { - throw new Error("Limit must be between 1 and 100"); - } - if (options?.queryParameters?.order && !["asc", "desc"].includes(options.queryParameters.order)) { - throw new Error("Order must be either 'asc' or 'desc'"); - } -} diff --git a/sdk/ai/ai-projects/src/agents/messagesTrace.ts b/sdk/ai/ai-projects/src/agents/messagesTrace.ts deleted file mode 100644 index 9614b2e74309..000000000000 --- a/sdk/ai/ai-projects/src/agents/messagesTrace.ts +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - CreateMessageParameters, - ListMessagesParameters, -} from "../generated/src/parameters.js"; -import type { Span } from "../tracing.js"; -import { TracingAttributes, TracingUtility, TracingOperationName } from "../tracing.js"; -import type { - OpenAIPageableListOfThreadMessageOutput, - ThreadMessageOutput as GeneratedThreadMessageOutput, -} from "../generated/src/outputModels.js"; -import { addMessageEvent } from "./traceUtility.js"; -import type { ThreadMessageOutput } from "../customization/outputModels.js"; - -export function traceStartCreateMessage( - span: Span, - threadId: string, - options: CreateMessageParameters, -): void { - TracingUtility.setSpanAttributes(span, TracingOperationName.CREATE_MESSAGE, { - threadId: threadId, - genAiSystem: TracingAttributes.AZ_AI_AGENT_SYSTEM, - }); - addMessageEvent(span, { ...options.body, thread_id: threadId }); -} - -export async function traceEndCreateMessage( - span: Span, - _options: CreateMessageParameters, - result: Promise, -): Promise { - const resolvedResult = await result; - TracingUtility.updateSpanAttributes(span, { messageId: resolvedResult.id }); -} - -export function traceStartListMessages( - span: Span, - threadId: string, - _options: ListMessagesParameters, -): void { - TracingUtility.setSpanAttributes(span, TracingOperationName.LIST_MESSAGES, { - threadId: threadId, - genAiSystem: TracingAttributes.AZ_AI_AGENT_SYSTEM, - }); -} - -export async function traceEndListMessages( - span: Span, - _options: ListMessagesParameters, - result: Promise, -): Promise { - const resolvedResult = await result; - resolvedResult.data?.forEach((message) => { - addMessageEvent(span, message); - }); -} diff --git a/sdk/ai/ai-projects/src/agents/openAIError.ts b/sdk/ai/ai-projects/src/agents/openAIError.ts deleted file mode 100644 index d4d2ea400824..000000000000 --- a/sdk/ai/ai-projects/src/agents/openAIError.ts +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { PathUncheckedResponse } from "@azure-rest/core-client"; -import { createRestError } from "@azure-rest/core-client"; -import type { RestErrorOptions } from "@azure/core-rest-pipeline"; -import { RestError } from "@azure/core-rest-pipeline"; - -interface OpenAIErrorOptions extends RestErrorOptions { - param?: string; - type?: string; -} - -export class OpenAIError extends RestError { - readonly param?: string; - readonly type?: string; - - constructor(message: string, OpenAIErrorOptions: OpenAIErrorOptions = {}) { - super(message, OpenAIErrorOptions); - this.param = OpenAIErrorOptions?.param; - this.type = OpenAIErrorOptions?.type; - } -} - -export function createOpenAIError(response: PathUncheckedResponse): OpenAIError { - const internalError = response.body.error || response.body; - let restError: RestError; - if (typeof internalError === "string") { - restError = createRestError(internalError, response); - } else { - restError = createRestError(response); - } - - return new OpenAIError(restError.message, { - statusCode: restError?.statusCode, - code: restError?.code, - request: restError?.request, - response: restError?.response, - param: internalError?.param, - type: internalError?.type, - }); -} diff --git a/sdk/ai/ai-projects/src/agents/poller.ts b/sdk/ai/ai-projects/src/agents/poller.ts deleted file mode 100644 index c18e4d220d55..000000000000 --- a/sdk/ai/ai-projects/src/agents/poller.ts +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { delay } from "@azure/core-util"; -import type { PollerLike, OperationState, OperationStatus } from "@azure/core-lro"; -import type { AbortSignalLike } from "@azure/abort-controller"; - -const DEFAULT_POLL_INTERVAL_IN_MS = 1000; - -export function createPoller({ - initOperation, - pollOperation, - getOperationStatus, - getOperationError, - intervalInMs, -}: { - initOperation: () => Promise; - pollOperation: (currentResult: T) => Promise; - getOperationStatus: (result: T) => OperationStatus; - getOperationError?: (result: T) => Error | undefined; - intervalInMs?: number; -}): PollerLike, T> { - let state: OperationState; - const statePromise = initOperation().then((result) => { - state = { - result, - status: getOperationStatus(result), - }; - return state; - }); - - let resultPromise: Promise | undefined; - const abortController = new AbortController(); - type Handler = (state: OperationState) => void; - const handlers = new Map(); - const handleProgressEvents = async (): Promise => handlers.forEach((h) => h(state)); - const currentPollIntervalInMs = intervalInMs ?? DEFAULT_POLL_INTERVAL_IN_MS; - - const poller: PollerLike, T> = { - get operationState(): OperationState | undefined { - return state; - }, - get result(): T | undefined { - return state?.result; - }, - get isDone(): boolean { - return ["succeeded", "failed", "canceled"].includes(state?.status ?? ""); - }, - onProgress: (callback: (state: OperationState) => void) => { - const s = Symbol(); - handlers.set(s, callback); - return () => handlers.delete(s); - }, - serialize: async () => { - await statePromise; - return JSON.stringify({ - state, - }); - }, - submitted: async () => { - await statePromise; - }, - pollUntilDone: async (pollOptions?: { abortSignal?: AbortSignalLike }) => { - resultPromise ??= (async () => { - await statePromise; - if (!state) { - throw new Error("Poller is not initialized"); - } - const { abortSignal: inputAbortSignal } = pollOptions || {}; - function abortListener(): void { - abortController.abort(); - } - const abortSignal = abortController.signal; - if (inputAbortSignal?.aborted) { - abortController.abort(); - } else if (!abortSignal.aborted) { - inputAbortSignal?.addEventListener("abort", abortListener, { once: true }); - } - - try { - if (!poller.isDone) { - await poller.poll({ abortSignal }); - while (!poller.isDone) { - await delay(currentPollIntervalInMs, { abortSignal }); - await poller.poll({ abortSignal }); - } - } - } finally { - inputAbortSignal?.removeEventListener("abort", abortListener); - } - switch (state.status) { - case "succeeded": - return poller.result as T; - case "canceled": - throw new Error("Operation cancelled"); - case "failed": - throw state.error ?? new Error("Operation failed"); - case "notStarted": - case "running": - throw new Error("Polling completed without succeeding or failing"); - } - })().finally(() => { - resultPromise = undefined; - }); - return resultPromise; - }, - - async poll(pollOptions?: { abortSignal?: AbortSignalLike }): Promise> { - // Check state before polling - await statePromise; - if (!state || !state.result) { - throw new Error("Poller is not initialized"); - } - switch (state.status) { - case "succeeded": - return state; - case "canceled": - throw new Error("Operation was canceled"); - case "failed": - throw state.error ?? new Error("Operation failed"); - } - - // Poll - if (pollOptions?.abortSignal?.aborted) { - throw new Error("Operation aborted"); - } - const result = await pollOperation(state.result); - state = { - result, - status: getOperationStatus(result), - error: getOperationError ? getOperationError(result) : undefined, - }; - - await handleProgressEvents(); - switch (state.status) { - case "canceled": - throw new Error("Operation was canceled"); - case "failed": - throw state.error ?? new Error("Operation failed"); - } - return state; - }, - - then( - onfulfilled?: ((value: T) => T1 | PromiseLike) | undefined | null, - onrejected?: ((reason: any) => T2 | PromiseLike) | undefined | null, - ): Promise { - return poller.pollUntilDone().then(onfulfilled, onrejected); - }, - catch( - onrejected?: ((reason: any) => T2 | PromiseLike) | undefined | null, - ): Promise { - return poller.pollUntilDone().catch(onrejected); - }, - finally(onfinally?: (() => void) | undefined | null): Promise { - return poller.pollUntilDone().finally(onfinally); - }, - [Symbol.toStringTag]: "Poller", - }; - return poller; -} diff --git a/sdk/ai/ai-projects/src/agents/runSteps.ts b/sdk/ai/ai-projects/src/agents/runSteps.ts deleted file mode 100644 index b6aa0dd1cde6..000000000000 --- a/sdk/ai/ai-projects/src/agents/runSteps.ts +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { - OpenAIPageableListOfRunStepOutput, - RunStepOutput, -} from "../customization/outputModels.js"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import * as ConverterFromWire from "../customization/convertOutputModelsFromWire.js"; -import { - validateLimit, - validateOrder, - validateRunId, - validateThreadId, -} from "./inputValidations.js"; -import type { GetRunStepOptionalParams, ListRunStepsOptionalParams } from "./customModels.js"; -import { convertToListQueryParameters } from "../customization/convertParametersToWire.js"; -import { createOpenAIError } from "./openAIError.js"; - -const expectedStatuses = ["200"]; - -/** Gets a single run step from a thread run. */ -export async function getRunStep( - context: Client, - threadId: string, - runId: string, - stepId: string, - options: GetRunStepOptionalParams = {}, -): Promise { - validateThreadId(threadId); - validateRunId(runId); - validateStepId(stepId); - - const getOptions: GeneratedParameters.GetRunParameters = { - ...operationOptionsToRequestParameters(options), - }; - - const result = await context - .path("/threads/{threadId}/runs/{runId}/steps/{stepId}", threadId, runId, stepId) - .get(getOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConverterFromWire.convertRunStepOutput(result.body); -} - -/** Gets a list of run steps from a thread run. */ -export async function listRunSteps( - context: Client, - threadId: string, - runId: string, - options: ListRunStepsOptionalParams = {}, -): Promise { - const listOptions: GeneratedParameters.ListRunStepsParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: convertToListQueryParameters(options), - }; - - validateListRunsParameters(threadId, runId, listOptions); - const result = await context - .path("/threads/{threadId}/runs/{runId}/steps", threadId, runId) - .get(listOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConverterFromWire.convertOpenAIPageableListOfRunStepOutput(result.body); -} - -function validateStepId(stepId: string): void { - if (!stepId) { - throw new Error("Step ID is required"); - } -} - -function validateListRunsParameters( - thread_id: string, - runId: string, - options?: GeneratedParameters.ListRunStepsParameters, -): void { - validateThreadId(thread_id); - validateRunId(runId); - if ( - options?.queryParameters?.limit && - (options.queryParameters.limit < 1 || options.queryParameters.limit > 100) - ) { - throw new Error("Limit must be between 1 and 100"); - } - if (options?.queryParameters?.limit) { - validateLimit(options.queryParameters.limit); - } - if (options?.queryParameters?.order) { - validateOrder(options.queryParameters.order); - } -} diff --git a/sdk/ai/ai-projects/src/agents/runTrace.ts b/sdk/ai/ai-projects/src/agents/runTrace.ts deleted file mode 100644 index dc6c725b2013..000000000000 --- a/sdk/ai/ai-projects/src/agents/runTrace.ts +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - CreateRunParameters, - CreateThreadAndRunParameters, - SubmitToolOutputsToRunParameters, - UpdateRunParameters, -} from "../generated/src/parameters.js"; -import type { ThreadRunOutput } from "../generated/src/outputModels.js"; -import type { TracingAttributeOptions, Span } from "../tracing.js"; -import { TracingUtility, TracingOperationName } from "../tracing.js"; -import { - addInstructionsEvent, - addMessageEvent, - addToolMessagesEvent, - formatAgentApiResponse, - UpdateWithAgentAttributes, -} from "./traceUtility.js"; - -export function traceStartCreateRun( - span: Span, - options: CreateRunParameters | CreateThreadAndRunParameters, - threadId?: string, - operationName: string = TracingOperationName.CREATE_RUN, -): void { - const attributes: TracingAttributeOptions = { - threadId: threadId, - agentId: options.body.assistant_id, - model: options.body.model ?? undefined, - instructions: options.body.instructions ?? undefined, - temperature: options.body.temperature ?? undefined, - topP: options.body.top_p ?? undefined, - maxCompletionTokens: options.body.max_completion_tokens ?? undefined, - maxPromptTokens: options.body.max_prompt_tokens ?? undefined, - responseFormat: formatAgentApiResponse(options.body.response_format), - }; - if ((options as CreateRunParameters).body.additional_instructions) { - attributes.additional_instructions = - (options as CreateRunParameters).body.additional_instructions ?? undefined; - } - TracingUtility.setSpanAttributes(span, operationName, UpdateWithAgentAttributes(attributes)); - setSpanEvents(span, options); -} - -export function traceStartCreateThreadAndRun( - span: Span, - options: CreateThreadAndRunParameters, -): void { - traceStartCreateRun(span, options, undefined, TracingOperationName.CREATE_THREAD_RUN); -} - -export async function traceEndCreateOrUpdateRun( - span: Span, - _options: CreateRunParameters | UpdateRunParameters, - result: Promise, -): Promise { - const resolvedResult = await result; - updateSpanAttributesForRun(span, resolvedResult); -} - -export function traceStartSubmitToolOutputsToRun( - span: Span, - options: SubmitToolOutputsToRunParameters, - threadId: string, - runId: string, -): void { - const attributes: TracingAttributeOptions = { threadId: threadId, runId: runId }; - TracingUtility.setSpanAttributes( - span, - TracingOperationName.SUBMIT_TOOL_OUTPUTS, - UpdateWithAgentAttributes(attributes), - ); - addToolMessagesEvent(span, options.body.tool_outputs); -} - -export async function traceEndSubmitToolOutputsToRun( - span: Span, - _options: SubmitToolOutputsToRunParameters, - result: Promise, -): Promise { - const resolvedResult = await result; - updateSpanAttributesForRun(span, resolvedResult); -} - -function updateSpanAttributesForRun(span: Span, output: ThreadRunOutput): void { - TracingUtility.updateSpanAttributes(span, { - runId: output.id, - runStatus: output.status, - responseModel: output.model, - }); - const usage = output.usage; - if (usage && "completion_tokens" in usage && usage.completion_tokens) { - TracingUtility.updateSpanAttributes(span, { - usageCompletionTokens: usage.completion_tokens, - usagePromptTokens: usage.prompt_tokens, - }); - } -} - -function setSpanEvents(span: Span, options: CreateRunParameters): void { - addInstructionsEvent(span, { ...options.body, agentId: options.body.assistant_id }); - options.body.additional_messages?.forEach((message) => { - addMessageEvent(span, message); - }); -} diff --git a/sdk/ai/ai-projects/src/agents/runs.ts b/sdk/ai/ai-projects/src/agents/runs.ts deleted file mode 100644 index cb7f966056af..000000000000 --- a/sdk/ai/ai-projects/src/agents/runs.ts +++ /dev/null @@ -1,404 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import type * as CustomOutputModels from "../customization/outputModels.js"; -import type * as CustomModels from "../customization/models.js"; -import { - validateLimit, - validateMessages, - validateMetadata, - validateOrder, - validateRunId, - validateThreadId, - validateTools, - validateTruncationStrategy, -} from "./inputValidations.js"; -import { TracingUtility } from "../tracing.js"; -import { - traceEndCreateOrUpdateRun, - traceEndSubmitToolOutputsToRun, - traceStartCreateRun, - traceStartCreateThreadAndRun, - traceStartSubmitToolOutputsToRun, -} from "./runTrace.js"; -import { traceStartAgentGeneric } from "./traceUtility.js"; -import { - createRunStreaming, - createThreadAndRunStreaming, - submitToolOutputsToRunStreaming, -} from "./streaming.js"; -import type { AgentEventMessageStream } from "./streamingModels.js"; -import type { - AgentRunResponse, - CreateRunOptionalParams, - CancelRunOptionalParams, - CreateAndRunThreadOptionalParams, - GetRunOptionalParams, - ListRunQueryOptionalParams, - SubmitToolOutputsToRunOptionalParams, - UpdateRunOptionalParams, -} from "./customModels.js"; -import * as ConverterToWire from "../customization/convertModelsToWrite.js"; -import * as ConvertFromWire from "../customization/convertOutputModelsFromWire.js"; -import { convertToListQueryParameters } from "../customization/convertParametersToWire.js"; -import { createOpenAIError } from "./openAIError.js"; - -const expectedStatuses = ["200"]; - -/** Creates and starts a new run of the specified thread using the specified agent. */ -export function createRun( - context: Client, - threadId: string, - assistantId: string, - options: CreateRunOptionalParams, -): AgentRunResponse { - const createRunOptions: GeneratedParameters.CreateRunParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...ConverterToWire.convertCreateRunOptions({ ...options, assistantId }), - stream: false, - }, - }; - validateThreadId(threadId); - validateCreateRunParameters(createRunOptions); - - async function executeCreateRun(): Promise { - const output = await TracingUtility.withSpan( - "CreateRun", - createRunOptions, - async (updateOptions) => { - const result = await context.path("/threads/{threadId}/runs", threadId).post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - const error = createOpenAIError(result); - throw error; - } - return result.body; - }, - (span, updatedOptions) => traceStartCreateRun(span, updatedOptions, threadId), - traceEndCreateOrUpdateRun, - ); - return ConvertFromWire.convertThreadRunOutput(output); - } - - return { - then: function (onFulfilled, onRejected) { - return executeCreateRun().then(onFulfilled, onRejected).catch(onRejected); - }, - async stream(): Promise { - return createRunStreaming(context, threadId, createRunOptions); - }, - }; -} - -/** Gets a list of runs for a specified thread. */ -export async function listRuns( - context: Client, - threadId: string, - options: ListRunQueryOptionalParams = {}, -): Promise { - const listRunOptions: GeneratedParameters.ListRunsParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: convertToListQueryParameters(options), - }; - - validateListRunsParameters(threadId, options); - return TracingUtility.withSpan( - "ListRuns", - listRunOptions || {}, - async (updateOptions) => { - const result = await context.path("/threads/{threadId}/runs", threadId).get(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertOpenAIPageableListOfThreadRunOutput(result.body); - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { threadId: threadId }, - }), - ); -} - -/** Gets an existing run from an existing thread. */ -export async function getRun( - context: Client, - threadId: string, - runId: string, - options: GetRunOptionalParams = {}, -): Promise { - validateThreadId(threadId); - validateRunId(runId); - const getRunOptions: GeneratedParameters.GetRunParameters = { - ...operationOptionsToRequestParameters(options), - }; - return TracingUtility.withSpan( - "GetRun", - getRunOptions, - async (updateOptions) => { - const result = await context - .path("/threads/{threadId}/runs/{runId}", threadId, runId) - .get(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertThreadRunOutput(result.body); - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { threadId: threadId, runId: runId }, - }), - ); -} - -/** Modifies an existing thread run. */ -export async function updateRun( - context: Client, - threadId: string, - runId: string, - options: UpdateRunOptionalParams = {}, -): Promise { - const updateRunOptions: GeneratedParameters.UpdateRunParameters = { - ...operationOptionsToRequestParameters(options), - body: { - metadata: options?.metadata, - }, - }; - - validateUpdateRunParameters(threadId, runId, updateRunOptions); - const response = await TracingUtility.withSpan( - "UpdateRun", - updateRunOptions, - async (updateOptions) => { - const result = await context - .path("/threads/{threadId}/runs/{runId}", threadId, runId) - .post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { threadId: threadId, runId: runId }, - }), - traceEndCreateOrUpdateRun, - ); - - return ConvertFromWire.convertThreadRunOutput(response); -} - -/** Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. */ -export function submitToolOutputsToRun( - context: Client, - threadId: string, - runId: string, - toolOutputs: Array, - options: SubmitToolOutputsToRunOptionalParams = {}, -): AgentRunResponse { - validateThreadId(threadId); - validateRunId(runId); - const submitToolOutputsOptions: GeneratedParameters.SubmitToolOutputsToRunParameters = { - ...operationOptionsToRequestParameters(options), - body: { - tool_outputs: toolOutputs?.map(ConverterToWire.convertToolOutput), - stream: false, - }, - }; - - async function executeSubmitToolOutputsToRun(): Promise { - const response = await TracingUtility.withSpan( - "SubmitToolOutputsToRun", - submitToolOutputsOptions, - async (updateOptions) => { - const result = await context - .path("/threads/{threadId}/runs/{runId}/submit_tool_outputs", threadId, runId) - .post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartSubmitToolOutputsToRun(span, updatedOptions, threadId, runId), - traceEndSubmitToolOutputsToRun, - ); - return ConvertFromWire.convertThreadRunOutput(response); - } - - return { - then: function (onFulfilled, onrejected) { - return executeSubmitToolOutputsToRun().then(onFulfilled, onrejected).catch(onrejected); - }, - async stream(): Promise { - return submitToolOutputsToRunStreaming(context, threadId, runId, submitToolOutputsOptions); - }, - }; -} - -/** Cancels a run of an in progress thread. */ -export async function cancelRun( - context: Client, - threadId: string, - runId: string, - options: CancelRunOptionalParams = {}, -): Promise { - validateThreadId(threadId); - validateRunId(runId); - const cancelRunOptions: GeneratedParameters.CancelRunParameters = { - ...operationOptionsToRequestParameters(options), - }; - return TracingUtility.withSpan("CancelRun", cancelRunOptions, async (updateOptions) => { - const result = await context - .path("/threads/{threadId}/runs/{runId}/cancel", threadId, runId) - .post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertThreadRunOutput(result.body); - }); -} - -/** Creates a new thread and immediately starts a run of that thread. */ -export function createThreadAndRun( - context: Client, - assistantId: string, - options: CreateAndRunThreadOptionalParams, -): AgentRunResponse { - const createThreadAndRunOptions: GeneratedParameters.CreateThreadAndRunParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...ConverterToWire.convertCreateAndRunThreadOptions({ ...options, assistantId }), - stream: false, - }, - }; - - validateCreateThreadAndRunParameters(createThreadAndRunOptions); - - async function executeCreateThreadAndRun(): Promise { - const response = await TracingUtility.withSpan( - "CreateThreadAndRun", - createThreadAndRunOptions, - async (updateOptions) => { - const result = await context.path("/threads/runs").post(updateOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - - return result.body; - }, - traceStartCreateThreadAndRun, - traceEndCreateOrUpdateRun, - ); - - return ConvertFromWire.convertThreadRunOutput(response); - } - - return { - then: function (onFulfilled, onrejected) { - return executeCreateThreadAndRun().then(onFulfilled, onrejected).catch(onrejected); - }, - async stream(): Promise { - return createThreadAndRunStreaming(context, createThreadAndRunOptions); - }, - }; -} - -function validateListRunsParameters( - thread_id: string, - options?: GeneratedParameters.ListRunsParameters, -): void { - validateThreadId(thread_id); - if ( - options?.queryParameters?.limit && - (options.queryParameters.limit < 1 || options.queryParameters.limit > 100) - ) { - throw new Error("Limit must be between 1 and 100"); - } - if (options?.queryParameters?.limit) { - validateLimit(options.queryParameters.limit); - } - if (options?.queryParameters?.order) { - validateOrder(options.queryParameters.order); - } -} - -function validateUpdateRunParameters( - thread_id: string, - run_id: string, - options?: GeneratedParameters.UpdateRunParameters, -): void { - validateThreadId(thread_id); - validateRunId(run_id); - if (options?.body.metadata) { - validateMetadata(options.body.metadata); - } -} - -function validateCreateRunParameters( - options: - | GeneratedParameters.CreateRunParameters - | GeneratedParameters.CreateThreadAndRunParameters, -): void { - if ("additional_messages" in options.body && options.body.additional_messages) { - options.body.additional_messages.forEach((message) => validateMessages(message.role)); - } - if (options.body.tools) { - validateTools(options.body.tools); - } - if (options.body.temperature && (options.body.temperature < 0 || options.body.temperature > 2)) { - throw new Error("Temperature must be between 0 and 2"); - } - if (options.body.tool_choice && typeof options.body.tool_choice !== "string") { - validateTools([options.body.tool_choice]); - } - if (options.body.truncation_strategy?.type) { - validateTruncationStrategy(options.body.truncation_strategy.type); - } - if (options.body.metadata) { - validateMetadata(options.body.metadata); - } -} - -function validateCreateThreadAndRunParameters( - options: GeneratedParameters.CreateThreadAndRunParameters, -): void { - validateCreateRunParameters(options); - if (options.body.thread?.messages) { - options.body.thread?.messages.forEach((message) => validateMessages(message.role)); - } - if (options.body.tools) { - validateTools(options.body.tools); - } - if (options.body.tool_resources?.code_interpreter) { - if (options.body.tool_resources.code_interpreter) { - if ( - options.body.tool_resources.code_interpreter.file_ids && - options.body.tool_resources.code_interpreter.file_ids.length > 20 - ) { - throw new Error("A maximum of 20 file IDs are allowed"); - } - } - if (options.body.tool_resources.file_search) { - if ( - options.body.tool_resources.file_search.vector_store_ids && - options.body.tool_resources.file_search.vector_store_ids.length > 1 - ) { - throw new Error("Only one vector store ID is allowed"); - } - } - if (options.body.tool_resources.azure_ai_search) { - if ( - options.body.tool_resources.azure_ai_search.indexes && - options.body.tool_resources.azure_ai_search.indexes.length > 1 - ) { - throw new Error("Only one index is allowed"); - } - } - } -} diff --git a/sdk/ai/ai-projects/src/agents/streaming.ts b/sdk/ai/ai-projects/src/agents/streaming.ts deleted file mode 100644 index 129a2b05b1fc..000000000000 --- a/sdk/ai/ai-projects/src/agents/streaming.ts +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client, StreamableMethod } from "@azure-rest/core-client"; -import type { - CreateRunParameters, - CreateThreadAndRunBodyParam, - SubmitToolOutputsToRunParameters, -} from "../generated/src/index.js"; -import { - MessageStreamEvent, - RunStepStreamEvent, - RunStreamEvent, - ThreadStreamEvent, - type AgentEventMessage, - type AgentEventMessageStream, - type AgentEventStreamDataOutput, -} from "./streamingModels.js"; -import type { EventMessage, EventMessageStream } from "@azure/core-sse"; -import { createSseStream } from "@azure/core-sse"; -import { isNodeLike } from "@azure/core-util"; -import type { IncomingMessage } from "http"; -import { - validateMessages, - validateMetadata, - validateRunId, - validateThreadId, - validateToolResources, - validateTools, - validateTruncationStrategy, -} from "./inputValidations.js"; -import { createOpenAIError } from "./openAIError.js"; -import { - convertAgentThreadOutput, - convertMessageDeltaChunkOutput, - convertRunStepDeltaChunk, - convertRunStepOutput, - convertThreadMessageOutput, - convertThreadRunOutput, -} from "../customization/convertOutputModelsFromWire.js"; -import { logger } from "../logger.js"; - -const expectedStatuses = ["200"]; - -const handlers = [ - { events: Object.values(ThreadStreamEvent) as string[], converter: convertAgentThreadOutput }, - { events: Object.values(RunStreamEvent) as string[], converter: convertThreadRunOutput }, - { events: Object.values(RunStepStreamEvent) as string[], converter: convertRunStepOutput }, - { events: Object.values(MessageStreamEvent) as string[], converter: convertThreadMessageOutput }, -]; - -function createAgentStream(stream: EventMessageStream): AgentEventMessageStream { - const asyncIterator = toAsyncIterable(stream); - const asyncDisposable = stream as AsyncDisposable; - return Object.assign(asyncIterator, asyncDisposable); -} - -async function* toAsyncIterable(stream: EventMessageStream): AsyncIterable { - for await (const event of stream) { - const data = deserializeEventData(event); - yield { data: data, event: event.event }; - } -} - -function deserializeEventData(event: EventMessage): AgentEventStreamDataOutput { - try { - const jsonData = JSON.parse(event.data); - switch (event.event) { - case MessageStreamEvent.ThreadMessageDelta: - return convertMessageDeltaChunkOutput(jsonData); - case RunStepStreamEvent.ThreadRunStepDelta: - return convertRunStepDeltaChunk(jsonData); - default: { - for (const { events, converter } of handlers) { - if (events.includes(event.event)) { - return converter(jsonData); - } - } - - return jsonData; - } - } - } catch (ex) { - logger.error(`Failed to parse event data ${event.event} - error: ${ex}`); - return event.data; - } -} - -async function processStream(streamResponse: StreamableMethod): Promise { - const result = isNodeLike - ? await streamResponse.asNodeStream() - : await streamResponse.asBrowserStream(); - - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - if (!result.body) { - throw new Error("No body in response"); - } - - const stream = isNodeLike - ? createSseStream(result.body as IncomingMessage) - : createSseStream(result.body as ReadableStream); - return createAgentStream(stream); -} - -/** Create a run and stream the events */ -export async function createRunStreaming( - context: Client, - threadId: string, - options: CreateRunParameters, -): Promise { - validateThreadId(threadId); - validateCreateThreadAndRunBodyParam(options); - options.body.stream = true; - - return processStream(context.path("/threads/{threadId}/runs", threadId).post(options)); -} - -/** Create a thread and run and stream the events */ -export async function createThreadAndRunStreaming( - context: Client, - options: CreateThreadAndRunBodyParam, -): Promise { - validateCreateThreadAndRunBodyParam(options); - options.body.stream = true; - return processStream(context.path("/threads/runs").post(options)); -} - -export async function submitToolOutputsToRunStreaming( - context: Client, - threadId: string, - runId: string, - options: SubmitToolOutputsToRunParameters, -): Promise { - validateThreadId(threadId); - validateRunId(runId); - options.body.stream = true; - - return processStream( - context - .path("/threads/{threadId}/runs/{runId}/submit_tool_outputs", threadId, runId) - .post(options), - ); -} - -function validateCreateThreadAndRunBodyParam( - options: CreateRunParameters | CreateThreadAndRunBodyParam, -): void { - if ("additional_messages" in options.body && options.body.additional_messages) { - options.body.additional_messages.forEach((message) => validateMessages(message.role)); - } - if ("thread" in options.body && options.body.thread?.messages) { - options.body.thread?.messages.forEach((message) => validateMessages(message.role)); - } - if (options.body.tools) { - validateTools(options.body.tools); - } - if ("tool_resources" in options.body && options?.body.tool_resources) { - validateToolResources(options.body.tool_resources); - } - if (options.body.temperature && (options.body.temperature < 0 || options.body.temperature > 2)) { - throw new Error("Temperature must be between 0 and 2"); - } - if (options.body.tool_choice && typeof options.body.tool_choice !== "string") { - validateTools([options.body.tool_choice]); - } - if (options.body.truncation_strategy?.type) { - validateTruncationStrategy(options.body.truncation_strategy.type); - } - if (options.body.response_format) { - if (!["json", "text"].includes(options.body.response_format as string)) { - throw new Error("Response format must be either 'json' or 'text'"); - } - } - if (options?.body.metadata) { - validateMetadata(options.body.metadata); - } -} diff --git a/sdk/ai/ai-projects/src/agents/streamingModels.ts b/sdk/ai/ai-projects/src/agents/streamingModels.ts deleted file mode 100644 index 44d93753c5d6..000000000000 --- a/sdk/ai/ai-projects/src/agents/streamingModels.ts +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { MessageDeltaChunk, RunStepDeltaChunk } from "../customization/streamingModels.js"; -import type { - AgentThreadOutput, - RunStepOutput, - ThreadMessageOutput, - ThreadRunOutput, -} from "../customization/outputModels.js"; - -/** -Each event in a server-sent events stream has an `event` and `data` property: -* -* @example -* ``` ts -* event: thread.created -* data: {"id": "thread_123", "object": "thread", ...} -* ``` -* -* We emit events whenever a new object is created, transitions to a new state, or is being -* streamed in parts (deltas). For example, we emit `thread.run.created` when a new run -* is created, `thread.run.completed` when a run completes, and so on. When an Agent chooses -* to create a message during a run, we emit a `thread.message.created event`, a -* `thread.message.in_progress` event, many `thread.message.delta` events, and finally a -* `thread.message.completed` event. -* -* We may add additional events over time, so we recommend handling unknown events gracefully -* in your code. -**/ -export interface AgentEventMessage { - /** The data of the event. The data can be of type AgentThreadOutput, ThreadRunOutput, RunStepOutput, ThreadMessageOutput, MessageDeltaChunk,RunStepDeltaChunk */ - data: AgentEventStreamDataOutput; - /** The type of the event. */ - event: AgentStreamEventType | string; -} - -/** Represents a stream event data in the agent. */ -export type AgentEventStreamDataOutput = - | AgentThreadOutput - | ThreadRunOutput - | RunStepOutput - | ThreadMessageOutput - | MessageDeltaChunk - | RunStepDeltaChunk - | string; - -/** Thread operation related streaming events */ -export enum ThreadStreamEvent { - /** Event sent when a new thread is created. The data of this event is of type AgentThread */ - ThreadCreated = "thread.created", -} - -/** Run operation related streaming events */ -export enum RunStreamEvent { - /** Event sent when a new run is created. The data of this event is of type ThreadRun */ - ThreadRunCreated = "thread.run.created", - - /** Event sent when a run moves to `queued` status. The data of this event is of type ThreadRun */ - ThreadRunQueued = "thread.run.queued", - - /** Event sent when a run moves to `in_progress` status. The data of this event is of type ThreadRun */ - ThreadRunInProgress = "thread.run.in_progress", - - /** Event sent when a run moves to `requires_action` status. The data of this event is of type ThreadRun */ - ThreadRunRequiresAction = "thread.run.requires_action", - - /** Event sent when a run is completed. The data of this event is of type ThreadRun */ - ThreadRunCompleted = "thread.run.completed", - - /** Event sent when a run fails. The data of this event is of type ThreadRun */ - ThreadRunFailed = "thread.run.failed", - - /** Event sent when a run moves to `cancelling` status. The data of this event is of type ThreadRun */ - ThreadRunCancelling = "thread.run.cancelling", - - /** Event sent when a run is cancelled. The data of this event is of type ThreadRun */ - ThreadRunCancelled = "thread.run.cancelled", - - /** Event sent when a run is expired. The data of this event is of type ThreadRun */ - ThreadRunExpired = "thread.run.expired", -} - -/** Run step operation related streaming events */ -export enum RunStepStreamEvent { - /** Event sent when a new thread run step is created. The data of this event is of type RunStep */ - ThreadRunStepCreated = "thread.run.step.created", - - /** Event sent when a run step moves to `in_progress` status. The data of this event is of type RunStep */ - ThreadRunStepInProgress = "thread.run.step.in_progress", - - /** Event sent when a run step is being streamed. The data of this event is of type RunStepDeltaChunk */ - ThreadRunStepDelta = "thread.run.step.delta", - - /** Event sent when a run step is completed. The data of this event is of type RunStep */ - ThreadRunStepCompleted = "thread.run.step.completed", - - /** Event sent when a run step fails. The data of this event is of type RunStep */ - ThreadRunStepFailed = "thread.run.step.failed", - - /** Event sent when a run step is cancelled. The data of this event is of type RunStep */ - ThreadRunStepCancelled = "thread.run.step.cancelled", - - /** Event sent when a run step is expired. The data of this event is of type RunStep */ - ThreadRunStepExpired = "thread.run.step.expired", -} - -/** Message operation related streaming events */ -export enum MessageStreamEvent { - /** Event sent when a new message is created. The data of this event is of type ThreadMessage */ - ThreadMessageCreated = "thread.message.created", - - /** Event sent when a message moves to `in_progress` status. The data of this event is of type ThreadMessage */ - ThreadMessageInProgress = "thread.message.in_progress", - - /** Event sent when a message is being streamed. The data of this event is of type MessageDeltaChunk */ - ThreadMessageDelta = "thread.message.delta", - - /** Event sent when a message is completed. The data of this event is of type ThreadMessage */ - ThreadMessageCompleted = "thread.message.completed", - - /** Event sent before a message is completed. The data of this event is of type ThreadMessage */ - ThreadMessageIncomplete = "thread.message.incomplete", -} - -/** Terminal event indicating a server side error while streaming. */ -export enum ErrorEvent { - /** Event sent when an error occurs, such as an internal server error or a timeout. */ - Error = "error", -} - -/** Terminal event indicating the successful end of a stream. */ -export enum DoneEvent { - /** Event sent when the stream is done. */ - Done = "done", -} - -/** - Represents the type of an agent stream event. - */ -export type AgentStreamEventType = - | ThreadStreamEvent - | RunStreamEvent - | RunStepStreamEvent - | MessageStreamEvent - | ErrorEvent - | DoneEvent; - -/** Represents a stream of agent event message. */ -export interface AgentEventMessageStream - extends AsyncDisposable, - AsyncIterable {} diff --git a/sdk/ai/ai-projects/src/agents/threads.ts b/sdk/ai/ai-projects/src/agents/threads.ts deleted file mode 100644 index 3682a94ef841..000000000000 --- a/sdk/ai/ai-projects/src/agents/threads.ts +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import * as ConverterToWire from "../customization/convertModelsToWrite.js"; -import * as ConverterFromWire from "../customization/convertOutputModelsFromWire.js"; -import type { - AgentThreadOutput, - OpenAIPageableListOfAgentThreadOutput, - ThreadDeletionStatusOutput, -} from "../customization/outputModels.js"; -import { TracingUtility } from "../tracing.js"; -import { traceEndCreateThread, traceStartCreateThread } from "./threadsTrace.js"; -import { - validateMessages, - validateMetadata, - validateThreadId, - validateToolResources, -} from "./inputValidations.js"; -import { traceStartAgentGeneric } from "./traceUtility.js"; -import type { - CreateAgentThreadOptionalParams, - DeleteAgentThreadOptionalParams, - GetAgentThreadOptionalParams, - ListAgentThreadOptionalParams, - UpdateAgentThreadOptionalParams, -} from "./customModels.js"; -import { convertThreadDeletionStatusOutput } from "../customization/convertOutputModelsFromWire.js"; -import { createOpenAIError } from "./openAIError.js"; - -const expectedStatuses = ["200"]; - -/** Creates a new thread. Threads contain messages and can be run by agents. */ -export async function createThread( - context: Client, - options: CreateAgentThreadOptionalParams = {}, -): Promise { - const createThreadOptions: GeneratedParameters.CreateThreadParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...ConverterToWire.convertAgentThreadCreationOptions(options), - }, - }; - - validateCreateThreadParameters(createThreadOptions); - const response = await TracingUtility.withSpan( - "CreateThread", - createThreadOptions, - async (updatedOptions) => { - const result = await context.path("/threads").post(updatedOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - traceStartCreateThread, - traceEndCreateThread, - ); - - return ConverterFromWire.convertAgentThreadOutput(response); -} - -/** Gets information about an existing thread. */ -export async function getThread( - context: Client, - threadId: string, - options: GetAgentThreadOptionalParams = {}, -): Promise { - const getThreadOptions: GeneratedParameters.GetThreadParameters = { - ...operationOptionsToRequestParameters(options), - }; - - validateThreadId(threadId); - const response = await TracingUtility.withSpan( - "GetThread", - getThreadOptions, - async (updatedOptions) => { - const result = await context.path("/threads/{threadId}", threadId).get(updatedOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { threadId: threadId }, - }), - ); - - return ConverterFromWire.convertAgentThreadOutput(response); -} - -/** Modifies an existing thread. */ -export async function updateThread( - context: Client, - threadId: string, - options: UpdateAgentThreadOptionalParams = {}, -): Promise { - const updateThreadOptions: GeneratedParameters.UpdateThreadParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ...ConverterToWire.convertAgentThreadUpdateOptions(options), - }, - }; - - validateUpdateThreadParameters(threadId, updateThreadOptions); - const response = await TracingUtility.withSpan( - "UpdateThread", - updateThreadOptions, - async (updatedOptions) => { - const result = await context.path("/threads/{threadId}", threadId).post(updatedOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { threadId: threadId }, - }), - ); - - return ConverterFromWire.convertAgentThreadOutput(response); -} - -/** Deletes an existing thread. */ -export async function deleteThread( - context: Client, - threadId: string, - options: DeleteAgentThreadOptionalParams = {}, -): Promise { - const deleteThreadOptions: GeneratedParameters.DeleteAgentParameters = { - ...operationOptionsToRequestParameters(options), - }; - - validateThreadId(threadId); - const response = await TracingUtility.withSpan( - "DeleteThread", - deleteThreadOptions, - async (updatedOptions) => { - const result = await context.path("/threads/{threadId}", threadId).delete(updatedOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: { threadId: threadId }, - }), - ); - - return convertThreadDeletionStatusOutput(response); -} - -/** Gets a list of threads that were previously created. */ -export async function listThreads( - context: Client, - options: ListAgentThreadOptionalParams = {}, -): Promise { - const listThreadsOptions: GeneratedParameters.ListThreadsParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: { - ...(options.limit && { limit: options.limit }), - ...(options.order && { order: options.order }), - ...(options.after && { after: options.after }), - ...(options.before && { before: options.before }), - }, - }; - - validateListThreadsParameters(listThreadsOptions); - const output = await TracingUtility.withSpan( - "ListThreads", - listThreadsOptions, - async (updatedOptions) => { - const result = await context.path("/threads").get(updatedOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return result.body; - }, - (span, updatedOptions) => - traceStartAgentGeneric(span, { - ...updatedOptions, - tracingAttributeOptions: {}, - }), - ); - - return ConverterFromWire.convertOpenAIPageableListOfAgentThreadOutput(output); -} - -function validateCreateThreadParameters( - options?: GeneratedParameters.CreateThreadParameters, -): void { - if (options?.body.messages) { - options.body.messages.forEach((message) => validateMessages(message.role)); - } - if (options?.body.tool_resources) { - validateToolResources(options.body.tool_resources); - } - if (options?.body.metadata) { - validateMetadata(options.body.metadata); - } -} - -function validateUpdateThreadParameters( - threadId: string, - options?: GeneratedParameters.UpdateThreadParameters, -): void { - validateThreadId(threadId); - if (options?.body.tool_resources) { - validateToolResources(options.body.tool_resources); - } - if (options?.body.metadata) { - validateMetadata(options.body.metadata); - } -} - -function validateListThreadsParameters(options?: GeneratedParameters.ListThreadsParameters): void { - if ( - options?.queryParameters?.limit && - (options.queryParameters.limit < 1 || options.queryParameters.limit > 100) - ) { - throw new Error("Limit must be between 1 and 100"); - } - if (options?.queryParameters?.order && !["asc", "desc"].includes(options.queryParameters.order)) { - throw new Error("Order must be either 'asc' or 'desc'"); - } -} diff --git a/sdk/ai/ai-projects/src/agents/threadsTrace.ts b/sdk/ai/ai-projects/src/agents/threadsTrace.ts deleted file mode 100644 index 4f852a3277cd..000000000000 --- a/sdk/ai/ai-projects/src/agents/threadsTrace.ts +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { AgentThreadOutput } from "../generated/src/outputModels.js"; -import type { Span } from "../tracing.js"; -import { TracingUtility, TracingOperationName } from "../tracing.js"; -import type { CreateThreadParameters } from "../generated/src/parameters.js"; -import { addMessageEvent, UpdateWithAgentAttributes } from "./traceUtility.js"; - -export function traceStartCreateThread(span: Span, options: CreateThreadParameters): void { - TracingUtility.setSpanAttributes( - span, - TracingOperationName.CREATE_THREAD, - UpdateWithAgentAttributes({}), - ); - setSpanEvents(span, options); -} - -export async function traceEndCreateThread( - span: Span, - _options: CreateThreadParameters, - result: Promise, -): Promise { - const resolvedResult = await result; - TracingUtility.updateSpanAttributes(span, { threadId: resolvedResult.id }); -} - -function setSpanEvents(span: Span, options: CreateThreadParameters): void { - options.body.messages?.forEach((message) => { - addMessageEvent(span, message); - }); -} diff --git a/sdk/ai/ai-projects/src/agents/traceUtility.ts b/sdk/ai/ai-projects/src/agents/traceUtility.ts deleted file mode 100644 index c1e31f778c5c..000000000000 --- a/sdk/ai/ai-projects/src/agents/traceUtility.ts +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - AgentsApiResponseFormat, - AgentsApiResponseFormatOption, - ThreadMessageOptions, - ToolOutput, -} from "../generated/src/models.js"; -import type { - MessageContentOutput, - RunStepCompletionUsageOutput, - ThreadMessageOutput, -} from "../generated/src/outputModels.js"; -import type { OptionsWithTracing, Span, TracingAttributeOptions } from "../tracing.js"; -import { TracingAttributes, TracingUtility } from "../tracing.js"; -import { getTelemetryOptions } from "../telemetry/telemetry.js"; - -export function traceStartAgentGeneric( - span: Span, - options: Options, -): void { - const attributeOptions = options.tracingAttributeOptions || {}; - TracingUtility.setSpanAttributes( - span, - options.tracingAttributeOptions?.operationName || "Agent_Operation", - UpdateWithAgentAttributes(attributeOptions), - ); -} -export function traceEndAgentGeneric( - span: Span, - _options: Options, -): void { - const attributeOptions = {}; - TracingUtility.updateSpanAttributes(span, UpdateWithAgentAttributes(attributeOptions)); -} - -export function UpdateWithAgentAttributes( - attributeOptions: Omit, -): Omit { - attributeOptions.genAiSystem = TracingAttributes.AZ_AI_AGENT_SYSTEM; - return attributeOptions; -} - -/** - * Adds a message event to the span. - * @param span - The span to add the event to. - * @param messageAttributes - The attributes of the message event. - */ -export function addMessageEvent( - span: Span, - messageAttributes: ThreadMessageOptions | ThreadMessageOutput, - usage?: RunStepCompletionUsageOutput, -): void { - const eventBody: Record = {}; - const telemetryOptions = getTelemetryOptions(); - if (telemetryOptions.enableContentRecording) { - eventBody.content = getMessageContent(messageAttributes.content); - } - eventBody.role = messageAttributes.role; - if (messageAttributes.attachments) { - eventBody.attachments = messageAttributes.attachments.map((attachment) => { - return { - id: attachment.file_id, - tools: attachment.tools.map((tool) => tool.type), - }; - }); - } - const threadId = (messageAttributes as ThreadMessageOutput).thread_id; - const agentId = (messageAttributes as ThreadMessageOutput).assistant_id ?? undefined; - const threadRunId = (messageAttributes as ThreadMessageOutput).run_id; - const messageStatus = (messageAttributes as ThreadMessageOutput).status; - const messageId = (messageAttributes as ThreadMessageOutput).id; - const incompleteDetails = (messageAttributes as ThreadMessageOutput).incomplete_details; - if (incompleteDetails) { - eventBody.incomplete_details = incompleteDetails; - } - const usagePromptTokens = usage?.prompt_tokens; - const usageCompletionTokens = usage?.completion_tokens; - const attributes = { - eventContent: JSON.stringify(eventBody), - threadId, - agentId, - threadRunId, - messageStatus, - messageId, - usagePromptTokens, - usageCompletionTokens, - genAiSystem: TracingAttributes.AZ_AI_AGENT_SYSTEM, - }; - - TracingUtility.addSpanEvent(span, `gen_ai.${messageAttributes.role}.message`, attributes); -} - -/** - * Adds an instruction event to the span. - * @param span - The span to add the event to. - * @param instructionAttributes - The attributes of the instruction event. - */ -export function addInstructionsEvent( - span: Span, - instructionAttributes: { - instructions?: string | null; - additional_instructions?: string | null; - threadId?: string; - agentId?: string; - }, -): void { - const eventBody: Record = {}; - if (instructionAttributes.instructions || instructionAttributes.additional_instructions) { - eventBody.content = - instructionAttributes.instructions && instructionAttributes.additional_instructions - ? `${instructionAttributes.instructions} ${instructionAttributes.additional_instructions}` - : instructionAttributes.instructions || instructionAttributes.additional_instructions; - } - const attributes = { - eventContent: JSON.stringify(eventBody), - threadId: instructionAttributes.threadId, - agentId: instructionAttributes.agentId, - genAiSystem: TracingAttributes.AZ_AI_AGENT_SYSTEM, - }; - TracingUtility.addSpanEvent(span, "gen_ai.system.message", attributes); -} - -/** - * Formats the agent API response. - * @param responseFormat - The response format option. - * @returns The formatted response as a string, or null/undefined. - */ -export function formatAgentApiResponse( - responseFormat: AgentsApiResponseFormatOption | null | undefined, -): string | undefined { - if ( - typeof responseFormat === "string" || - responseFormat === undefined || - responseFormat === null - ) { - return responseFormat ?? undefined; - } - if ((responseFormat as AgentsApiResponseFormat).type) { - return (responseFormat as AgentsApiResponseFormat).type ?? undefined; - } - return undefined; -} - -/** - * Adds a tool messages event to the span - * @param span - The span to add the event to. - * @param tool_outputs - List of tool oupts - */ -export function addToolMessagesEvent(span: Span, tool_outputs: Array): void { - tool_outputs.forEach((tool_output) => { - const eventBody = { content: tool_output.output, id: tool_output.tool_call_id }; - TracingUtility.addSpanEvent(span, "gen_ai.tool.message", { - eventContent: JSON.stringify(eventBody), - genAiSystem: TracingAttributes.AZ_AI_AGENT_SYSTEM, - }); - }); -} - -function getMessageContent(messageContent: string | MessageContentOutput[]): string | {} { - type MessageContentExtended = MessageContentOutput & { [key: string]: any }; - if (!Array.isArray(messageContent)) { - return messageContent; - } - const contentBody: { [key: string]: any } = {}; - messageContent.forEach((content) => { - const typedContent = content.type; - const { value, annotations } = (content as MessageContentExtended)[typedContent]; - contentBody[typedContent] = { value, annotations }; - }); - return contentBody; -} diff --git a/sdk/ai/ai-projects/src/agents/utils.ts b/sdk/ai/ai-projects/src/agents/utils.ts deleted file mode 100644 index 68f99db34703..000000000000 --- a/sdk/ai/ai-projects/src/agents/utils.ts +++ /dev/null @@ -1,409 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - AzureAISearchToolDefinition, - AzureFunctionToolDefinition, - CodeInterpreterToolDefinition, - FileSearchToolDefinition, - FileSearchToolDefinitionDetails, - FunctionDefinition, - FunctionToolDefinition, - SearchConfigurationOutput, - OpenApiToolDefinition, - RequiredActionOutput, - RequiredToolCallOutput, - ToolDefinition, - ToolDefinitionOutputParent, - ToolResources, - VectorStoreConfigurations, - VectorStoreDataSource, - AzureFunctionStorageQueue, - AzureFunctionDefinition, - OpenApiFunctionDefinition, -} from "./inputOutputs.js"; -import type { CreateAzureAISearchToolOptions } from "../customization/models.js"; - -/** - * Determines if the given output is of the specified type. - * - * @typeParam T - The type to check against, which extends one of the possible output parent types. - * @param output - The action to check, which can be of type `RequiredActionOutput`, `RequiredToolCallOutput`, or `ToolDefinitionOutputParent`. - * @param type - The type to check the action against. - * @returns A boolean indicating whether the action is of the specified type. - */ -export function isOutputOfType( - output: RequiredActionOutput | RequiredToolCallOutput | ToolDefinitionOutputParent, - type: string, -): output is T { - return output.type === type; -} - -/** Types of connection tools used to configure an agent */ -export enum connectionToolType { - /** Bing grounding search tool */ - BingGrounding = "bing_grounding", - /** Microsoft Fabric tool */ - MicrosoftFabric = "fabric_dataagent", - /** Sharepoint tool */ - SharepointGrounding = "sharepoint_grounding", - /** Azure Function tool */ - AzureFunction = "azure_function", - /** Bing custom search tool */ - BingCustomSearch = "bing_custom_search", -} - -const toolMap = { - bing_grounding: "bingGrounding", - fabric_dataagent: "fabric_dataagent", - sharepoint_grounding: "sharepointGrounding", - azure_function: "azureFunction", - bing_custom_search: "bingCustomSearch", -}; - -/** - * Utility class for creating various tools. - */ -export class ToolUtility { - /** - * Creates a connection tool - * - * @param toolType - The type of the connection tool. - * @param connectionIds - A list of the IDs of the connections to use. - * @returns An object containing the definition for the connection tool - */ - static createConnectionTool( - toolType: connectionToolType, - connectionIds: string[], - ): { definition: ToolDefinition } { - return { - definition: { - type: toolType, - [toolMap[toolType]]: { - connections: connectionIds.map((connectionId) => ({ connectionId: connectionId })), - }, - }, - }; - } - - /** - * Creates a bing custom search tool - * - * @param searchConfigurations - The ID of bing search connection and instanceName. - * - * @returns An object containing the definition and resources for the bing custom search tool - */ - - static createBingCustomSearchTool(searchConfigurations: SearchConfigurationOutput[]): { - definition: ToolDefinition; - } { - return { - definition: { - type: "bing_custom_search", - bingCustomSearch: { - searchConfigurations: searchConfigurations.map((searchConfiguration) => ({ - connectionId: searchConfiguration.connectionId, - instanceName: searchConfiguration.instanceName, - })), - }, - }, - }; - } - - /** - * Creates a file search tool - * - * @param vectorStoreIds - The ID of the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. - * @param vectorStores - The list of vector store configuration objects from Azure. This list is limited to one element. The only element of this list contains the list of azure asset IDs used by the search tool. - * @param definitionDetails - The input definition information for a file search tool as used to configure an agent. - * - * @returns An object containing the definition and resources for the file search tool - */ - static createFileSearchTool( - vectorStoreIds?: string[], - vectorStores?: Array, - definitionDetails?: FileSearchToolDefinitionDetails, - ): { definition: FileSearchToolDefinition; resources: ToolResources } { - return { - definition: { type: "file_search", fileSearch: definitionDetails }, - resources: { fileSearch: { vectorStoreIds: vectorStoreIds, vectorStores: vectorStores } }, - }; - } - - /** - * Creates a code interpreter tool - * - * @param fileIds - A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * @param dataSources - The data sources to be used. This option is mutually exclusive with fileIds. - * - * @returns An object containing the definition and resources for the code interpreter tool. - */ - static createCodeInterpreterTool( - fileIds?: string[], - dataSources?: Array, - ): { definition: CodeInterpreterToolDefinition; resources: ToolResources } { - if (fileIds && dataSources) { - throw new Error("Cannot specify both fileIds and dataSources"); - } - - return { - definition: { type: "code_interpreter" }, - resources: { codeInterpreter: { fileIds: fileIds, dataSources: dataSources } }, - }; - } - - /** - * Creates an Azure Function tool - * @param name - The name of the Azure Function. - * @param description - The description of the Azure Function. - * @param parameters - The parameters of the Azure Function. - * @param inputQueue - The input queue configuration. - * @param outputQueue - The output queue configuration. - * @returns An object containing the definition and resources for the Azure Function tool. - */ - static createAzureFunctionTool( - name: string, - description: string, - parameters: unknown, - inputQueue: AzureFunctionStorageQueue, - outputQueue: AzureFunctionStorageQueue, - definitionDetails: AzureFunctionDefinition, - ): { definition: AzureFunctionToolDefinition; resources: ToolResources } { - return { - definition: { type: "azure_function", azureFunction: definitionDetails }, - resources: { - azureFunction: { - name: name, - description: description, - parameters: parameters, - inputQueue: inputQueue, - outputQueue: outputQueue, - }, - }, - }; - } - /** - * Creates an Azure AI search tool - * - * @param indexConnectionId - The connection ID of the Azure AI search index. - * @param indexName - The name of the Azure AI search index. - * - * @returns An object containing the definition and resources for the Azure AI search tool. - */ - static createAzureAISearchTool( - indexConnectionId: string, - indexName: string, - options?: CreateAzureAISearchToolOptions, - ): { definition: AzureAISearchToolDefinition; resources: ToolResources } { - return { - definition: { type: "azure_ai_search" }, - resources: { - azureAISearch: { - indexes: [ - { - indexConnectionId: indexConnectionId, - indexName: indexName, - queryType: options?.queryType, - topK: options?.topK, - filter: options?.filter, - }, - ], - }, - }, - }; - } - - /** - * Creates a Microsoft Fabric tool - * - * @param connectionIds - A list of the IDs of the Fabric connections to use. - * @returns An object containing the definition for the Microsoft Fabric tool - */ - static createFabricTool(connectionId: string): { definition: ToolDefinition } { - return { - definition: { - type: "fabric_dataagent", - fabricDataAgent: { - connections: [{ connectionId: connectionId }], - }, - }, - }; - } - - /** - * Creates a function tool - * - * @param functionDefinition - The function definition to use. - * - * @returns An object containing the definition for the function tool. - */ - static createFunctionTool(functionDefinition: FunctionDefinition): { - definition: FunctionToolDefinition; - } { - return { - definition: { - type: "function", - function: functionDefinition, - }, - }; - } - - /** - * Creates an OpenApi tool - * - * @param openApiFunctionDefinition - The OpenApi function definition to use. - * - * @returns An object containing the definition for the OpenApi tool. - */ - static createOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): { - definition: OpenApiToolDefinition; - } { - return { - definition: { - type: "openapi", - openapi: openApiFunctionDefinition, - }, - }; - } -} -/** - * Represents a set of tools with their definitions and resources. - */ -export class ToolSet { - /** A list of tool definitions that have been added to the tool set. */ - toolDefinitions: ToolDefinition[] = []; - - /** A collection of resources associated with the tools in the tool set. */ - toolResources: ToolResources = {}; - - /** - * Adds a connection tool to the tool set. - * - * @param toolType - The type of the connection tool. - * @param connectionIds - A list of the IDs of the connections to use. - * - * @returns An object containing the definition for the connection tool - */ - addConnectionTool( - toolType: connectionToolType, - connectionIds: string[], - ): { definition: ToolDefinition } { - const tool = ToolUtility.createConnectionTool(toolType, connectionIds); - this.toolDefinitions.push(tool.definition); - return tool; - } - - /** - * Adds a file search tool to the tool set. - * - * @param vectorStoreIds - The ID of the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. - * @param vectorStores - The list of vector store configuration objects from Azure. This list is limited to one element. The only element of this list contains the list of azure asset IDs used by the search tool. - * @param definitionDetails - The input definition information for a file search tool as used to configure an agent. - * - * @returns An object containing the definition and resources for the file search tool - */ - addFileSearchTool( - vectorStoreIds?: string[], - vectorStores?: Array, - definitionDetails?: FileSearchToolDefinitionDetails, - ): { definition: FileSearchToolDefinition; resources: ToolResources } { - const tool = ToolUtility.createFileSearchTool(vectorStoreIds, vectorStores, definitionDetails); - this.toolDefinitions.push(tool.definition); - this.toolResources = { ...this.toolResources, ...tool.resources }; - return tool; - } - - /** - * Adds a code interpreter tool to the tool set. - * - * @param fileIds - A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files associated with the tool. - * @param dataSources - The data sources to be used. This option is mutually exclusive with fileIds. - * - * @returns An object containing the definition and resources for the code interpreter tool - */ - addCodeInterpreterTool( - fileIds?: string[], - dataSources?: Array, - ): { definition: CodeInterpreterToolDefinition; resources: ToolResources } { - const tool = ToolUtility.createCodeInterpreterTool(fileIds, dataSources); - this.toolDefinitions.push(tool.definition); - this.toolResources = { ...this.toolResources, ...tool.resources }; - return tool; - } - - /** - * Adds an Azure AI search tool to the tool set. - * - * @param indexConnectionId - The connection ID of the Azure AI search index. - * @param indexName - The name of the Azure AI search index. - * - * @returns An object containing the definition and resources for the Azure AI search tool - */ - addAzureAISearchTool( - indexConnectionId: string, - indexName: string, - ): { definition: AzureAISearchToolDefinition; resources: ToolResources } { - const tool = ToolUtility.createAzureAISearchTool(indexConnectionId, indexName); - this.toolDefinitions.push(tool.definition); - this.toolResources = { ...this.toolResources, ...tool.resources }; - return tool; - } - - /** - * Adds an OpenApi tool to the tool set. - * - * @param openApiFunctionDefinition - The OpenApi function definition to use. - * - * @returns An object containing the definition for the OpenApi tool - */ - addOpenApiTool(openApiFunctionDefinition: OpenApiFunctionDefinition): { - definition: OpenApiToolDefinition; - } { - const tool = ToolUtility.createOpenApiTool(openApiFunctionDefinition); - this.toolDefinitions.push(tool.definition); - return tool; - } - - /** - * Adds an Azure Function tool to the tool set. - * - * @param name - The name of the Azure Function. - * @param description - The description of the Azure Function. - * @param parameters - The parameters of the Azure Function. - * @param inputQueue - The input queue configuration. - * @param outputQueue - The output queue configuration. - * - * @returns An object containing the definition and resources for the Azure Function tool. - */ - addAzureFunctionTool( - name: string, - description: string, - parameters: unknown, - inputQueue: AzureFunctionStorageQueue, - outputQueue: AzureFunctionStorageQueue, - definitionDetails: AzureFunctionDefinition, - ): { definition: AzureFunctionToolDefinition; resources: ToolResources } { - const tool = ToolUtility.createAzureFunctionTool( - name, - description, - parameters, - inputQueue, - outputQueue, - definitionDetails, - ); - this.toolDefinitions.push(tool.definition); - this.toolResources = { ...this.toolResources, ...tool.resources }; - return tool; - } - /** - * Adds a Microsoft Fabric tool to the tool set. - * - * @param connectionId - The ID of the Fabric connection to use. - * @returns An object containing the definition for the Microsoft Fabric tool - */ - addFabricTool(connectionId: string): { definition: ToolDefinition } { - const tool = ToolUtility.createFabricTool(connectionId); - this.toolDefinitions.push(tool.definition); - return tool; - } -} diff --git a/sdk/ai/ai-projects/src/agents/vectorStores.ts b/sdk/ai/ai-projects/src/agents/vectorStores.ts deleted file mode 100644 index f9b7fdb0d10d..000000000000 --- a/sdk/ai/ai-projects/src/agents/vectorStores.ts +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { - ListVectorStoresParameters, - CreateVectorStoreParameters, - ModifyVectorStoreParameters, -} from "../generated/src/parameters.js"; -import type { - OpenAIPageableListOfVectorStoreOutput, - VectorStoreDeletionStatusOutput, - VectorStoreOutput, -} from "../customization/outputModels.js"; -import { createPoller } from "./poller.js"; -import { - type CreateVectorStoreOptionalParams, - type DeleteVectorStoreOptionalParams, - type GetVectorStoreOptionalParams, - type ListVectorStoresOptionalParams, - type UpdateVectorStoreOptionalParams, -} from "./customModels.js"; -import { - validateLimit, - validateMetadata, - validateOrder, - validateVectorStoreId, -} from "./inputValidations.js"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import * as ConvertFromWire from "../customization/convertOutputModelsFromWire.js"; -import * as ConvertToWire from "../customization/convertModelsToWrite.js"; -import { convertToListQueryParameters } from "../customization/convertParametersToWire.js"; -import { createOpenAIError } from "./openAIError.js"; -import type { OperationState, OperationStatus, PollerLike } from "@azure/core-lro"; - -const expectedStatuses = ["200"]; - -/** Returns a list of vector stores. */ -export async function listVectorStores( - context: Client, - options: ListVectorStoresOptionalParams = {}, -): Promise { - const listOptions: GeneratedParameters.ListVectorStoresParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: convertToListQueryParameters(options), - }; - - validateListVectorStoresParameters(listOptions); - const result = await context.path("/vector_stores").get(listOptions); - - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertOpenAIPageableListOfVectorStoreOutput(result.body); -} - -/** Creates a vector store. */ -export function createVectorStore( - context: Client, - options: CreateVectorStoreOptionalParams = {}, -): PollerLike, VectorStoreOutput> { - return createPoller({ - initOperation: async () => { - return createVectorStoreInternal(context, options); - }, - pollOperation: async (currentResult: VectorStoreOutput) => { - return getVectorStore(context, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -/** Returns the vector store object matching the specified ID. */ -export async function getVectorStore( - context: Client, - vectorStoreId: string, - options: GetVectorStoreOptionalParams = {}, -): Promise { - const getOptions: GeneratedParameters.GetVectorStoreParameters = { - ...operationOptionsToRequestParameters(options), - }; - - validateVectorStoreId(vectorStoreId); - const result = await context - .path("/vector_stores/{vectorStoreId}", vectorStoreId) - .get(getOptions); - - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreOutput(result.body); -} - -/** The ID of the vector store to modify. */ -export async function modifyVectorStore( - context: Client, - vectorStoreId: string, - options: UpdateVectorStoreOptionalParams = {}, -): Promise { - const modifyOptions: GeneratedParameters.ModifyVectorStoreParameters = { - ...operationOptionsToRequestParameters(options), - body: ConvertToWire.convertVectorStoreUpdateOptions(options), - }; - - validateVectorStoreId(vectorStoreId); - validateModifyVectorStoreParameters(modifyOptions); - const result = await context - .path("/vector_stores/{vectorStoreId}", vectorStoreId) - .post(modifyOptions); - - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreOutput(result.body); -} - -/** Deletes the vector store object matching the specified ID. */ -export async function deleteVectorStore( - context: Client, - vectorStoreId: string, - options: DeleteVectorStoreOptionalParams = {}, -): Promise { - const deleteOptions: GeneratedParameters.DeleteVectorStoreParameters = { - ...operationOptionsToRequestParameters(options), - }; - - validateVectorStoreId(vectorStoreId); - const result = await context - .path("/vector_stores/{vectorStoreId}", vectorStoreId) - .delete(deleteOptions); - - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreDeletionStatusOutput(result.body); -} - -/** - * Creates a vector store and poll. - */ -export function createVectorStoreAndPoll( - context: Client, - options: CreateVectorStoreOptionalParams = {}, -): PollerLike, VectorStoreOutput> { - return createPoller({ - initOperation: async () => { - return createVectorStoreInternal(context, options); - }, - pollOperation: async (currentResult: VectorStoreOutput) => { - return getVectorStore(context, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -async function createVectorStoreInternal( - context: Client, - options: CreateVectorStoreOptionalParams = {}, -): Promise { - const createOptions: GeneratedParameters.CreateVectorStoreParameters = { - ...operationOptionsToRequestParameters(options), - body: ConvertToWire.convertVectorStoreOptions(options), - }; - - validateCreateVectorStoreParameters(createOptions); - const result = await context.path("/vector_stores").post(createOptions); - - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreOutput(result.body); -} - -function getLroOperationStatus(result: VectorStoreOutput): OperationStatus { - switch (result.status) { - case "in_progress": - return "running"; - case "completed": - return "succeeded"; - case "expired": - return "failed"; - default: - return "failed"; - } -} - -function validateListVectorStoresParameters(options?: ListVectorStoresParameters): void { - if (options?.queryParameters?.limit) { - validateLimit(options.queryParameters.limit); - } - if (options?.queryParameters?.order) { - validateOrder(options.queryParameters.order); - } -} - -function validateCreateVectorStoreParameters(options?: CreateVectorStoreParameters): void { - if ( - options?.body?.chunking_strategy && - (!options.body.file_ids || options.body.file_ids.length === 0) - ) { - throw new Error("Chunking strategy is only applicable if fileIds is non-empty"); - } - if (options?.body?.metadata) { - validateMetadata(options.body.metadata); - } -} - -function validateModifyVectorStoreParameters(options?: ModifyVectorStoreParameters): void { - if (options?.body?.metadata) { - validateMetadata(options.body.metadata); - } -} diff --git a/sdk/ai/ai-projects/src/agents/vectorStoresFileBatches.ts b/sdk/ai/ai-projects/src/agents/vectorStoresFileBatches.ts deleted file mode 100644 index 9120fe4f0e6d..000000000000 --- a/sdk/ai/ai-projects/src/agents/vectorStoresFileBatches.ts +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { - OpenAIPageableListOfVectorStoreFileOutput, - VectorStoreFileBatchOutput, -} from "../customization/outputModels.js"; -import { createPoller } from "./poller.js"; -import type { - CancelVectorStoreFileBatchOptionalParams, - CreateVectorStoreFileBatchOptionalParams, - GetVectorStoreFileBatchOptionalParams, - ListVectorStoreFileBatchFilesOptionalParams, -} from "./customModels.js"; -import { - validateFileStatusFilter, - validateLimit, - validateOrder, - validateVectorStoreId, -} from "./inputValidations.js"; -import type { - CreateVectorStoreFileBatchParameters, - ListVectorStoreFileBatchFilesParameters, -} from "../generated/src/parameters.js"; -import * as ConvertFromWire from "../customization/convertOutputModelsFromWire.js"; -import * as ConvertParamsToWire from "../customization/convertParametersToWire.js"; -import { createOpenAIError } from "./openAIError.js"; -import type { PollerLike, OperationState, OperationStatus } from "@azure/core-lro"; - -const expectedStatuses = ["200"]; - -/** Create a vector store file batch. */ -export function createVectorStoreFileBatch( - context: Client, - vectorStoreId: string, - options: CreateVectorStoreFileBatchOptionalParams = {}, -): PollerLike, VectorStoreFileBatchOutput> { - return createPoller({ - initOperation: async () => { - return createVectorStoreFileBatchInternal(context, vectorStoreId, options); - }, - pollOperation: async (currentResult: VectorStoreFileBatchOutput) => { - return getVectorStoreFileBatch(context, vectorStoreId, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -/** Retrieve a vector store file batch. */ -export async function getVectorStoreFileBatch( - context: Client, - vectorStoreId: string, - batchId: string, - options: GetVectorStoreFileBatchOptionalParams = {}, -): Promise { - validateVectorStoreId(vectorStoreId); - const result = await context - .path("/vector_stores/{vectorStoreId}/file_batches/{batchId}", vectorStoreId, batchId) - .get(options); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreFileBatchOutput(result.body); -} - -/** Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. */ -export async function cancelVectorStoreFileBatch( - context: Client, - vectorStoreId: string, - batchId: string, - options: CancelVectorStoreFileBatchOptionalParams = {}, -): Promise { - validateVectorStoreId(vectorStoreId); - const result = await context - .path("/vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel", vectorStoreId, batchId) - .post(options); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreFileBatchOutput(result.body); -} - -/** Returns a list of vector store files in a batch. */ -export async function listVectorStoreFileBatchFiles( - context: Client, - vectorStoreId: string, - batchId: string, - options: ListVectorStoreFileBatchFilesOptionalParams = {}, -): Promise { - const listOptions: ListVectorStoreFileBatchFilesParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: ConvertParamsToWire.convertListVectorStoreFileBatchFilesQueryParamProperties( - options, - ) as Record, - }; - - validateVectorStoreId(vectorStoreId); - validateBatchId(batchId); - validateListVectorStoreFileBatchFilesParameters(listOptions); - const result = await context - .path("/vector_stores/{vectorStoreId}/file_batches/{batchId}/files", vectorStoreId, batchId) - .get(listOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertOpenAIPageableListOfVectorStoreFileOutput(result.body); -} - -/** Create a vector store file batch and poll. */ -export function createVectorStoreFileBatchAndPoll( - context: Client, - vectorStoreId: string, - options: CreateVectorStoreFileBatchOptionalParams = {}, -): PollerLike, VectorStoreFileBatchOutput> { - return createPoller({ - initOperation: async () => { - return createVectorStoreFileBatchInternal(context, vectorStoreId, options); - }, - pollOperation: async (currentResult: VectorStoreFileBatchOutput) => { - return getVectorStoreFileBatch(context, vectorStoreId, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -export async function createVectorStoreFileBatchInternal( - context: Client, - vectorStoreId: string, - options: CreateVectorStoreFileBatchOptionalParams = {}, -): Promise { - const createOptions: CreateVectorStoreFileBatchParameters = { - ...operationOptionsToRequestParameters(options), - ...ConvertParamsToWire.convertCreateVectorStoreFileBatchParam({ body: options }), - }; - - validateVectorStoreId(vectorStoreId); - validateCreateVectorStoreFileBatchParameters(createOptions); - const result = await context - .path("/vector_stores/{vectorStoreId}/file_batches", vectorStoreId) - .post(createOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreFileBatchOutput(result.body); -} - -function getLroOperationStatus(result: VectorStoreFileBatchOutput): OperationStatus { - switch (result.status) { - case "in_progress": - return "running"; - case "completed": - return "succeeded"; - case "cancelled": - return "canceled"; - default: - return "failed"; - } -} - -function validateBatchId(batchId: string): void { - if (!batchId) { - throw new Error("Batch ID is required"); - } -} - -function validateCreateVectorStoreFileBatchParameters( - options?: CreateVectorStoreFileBatchParameters, -): void { - if ( - options?.body?.chunking_strategy && - (!options.body.file_ids || options.body.file_ids.length === 0) - ) { - throw new Error("Chunking strategy is only applicable if fileIds are included"); - } -} - -function validateListVectorStoreFileBatchFilesParameters( - options?: ListVectorStoreFileBatchFilesParameters, -): void { - if (options?.queryParameters?.filter) { - validateFileStatusFilter(options.queryParameters.filter); - } - if (options?.queryParameters?.limit) { - validateLimit(options.queryParameters.limit); - } - if (options?.queryParameters?.order) { - validateOrder(options.queryParameters.order); - } -} diff --git a/sdk/ai/ai-projects/src/agents/vectorStoresFiles.ts b/sdk/ai/ai-projects/src/agents/vectorStoresFiles.ts deleted file mode 100644 index 9535772b1e35..000000000000 --- a/sdk/ai/ai-projects/src/agents/vectorStoresFiles.ts +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { - ListVectorStoreFilesParameters, - CreateVectorStoreFileParameters, -} from "../generated/src/parameters.js"; -import type { - OpenAIPageableListOfVectorStoreFileOutput, - VectorStoreFileDeletionStatusOutput, - VectorStoreFileOutput, -} from "../customization/outputModels.js"; -import { createPoller } from "./poller.js"; -import type { - CreateVectorStoreFileOptionalParams, - DeleteVectorStoreFileOptionalParams, - GetVectorStoreFileOptionalParams, - ListVectorStoreFilesOptionalParams, -} from "./customModels.js"; -import { - validateFileId, - validateFileStatusFilter, - validateLimit, - validateOrder, - validateVectorStoreId, -} from "./inputValidations.js"; -import { convertToListQueryParameters } from "../customization/convertParametersToWire.js"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import * as ConvertFromWire from "../customization/convertOutputModelsFromWire.js"; -import * as ConvertParamsToWire from "../customization/convertParametersToWire.js"; -import { createOpenAIError } from "./openAIError.js"; -import type { OperationState, OperationStatus, PollerLike } from "@azure/core-lro"; - -const expectedStatuses = ["200"]; - -/** Returns a list of vector store files. */ -export async function listVectorStoreFiles( - context: Client, - vectorStoreId: string, - options: ListVectorStoreFilesOptionalParams = {}, -): Promise { - validateVectorStoreId(vectorStoreId); - - const listOptions: GeneratedParameters.ListVectorStoreFilesParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: convertToListQueryParameters(options), - }; - - validateListVectorStoreFilesParameters(listOptions); - const result = await context - .path("/vector_stores/{vectorStoreId}/files", vectorStoreId) - .get(listOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertOpenAIPageableListOfVectorStoreFileOutput(result.body); -} - -/** Create a vector store file by attaching a file to a vector store. */ -export function createVectorStoreFile( - context: Client, - vectorStoreId: string, - options: CreateVectorStoreFileOptionalParams = {}, -): PollerLike, VectorStoreFileOutput> { - return createPoller({ - initOperation: async () => { - return createVectorStoreFileInternal(context, vectorStoreId, options); - }, - pollOperation: async (currentResult: VectorStoreFileOutput) => { - return getVectorStoreFile(context, vectorStoreId, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - getOperationError: (result: VectorStoreFileOutput) => { - return result.status === "failed" && result.lastError - ? new Error( - `Operation failed with code ${result.lastError.code}: ${result.lastError.message}`, - ) - : undefined; - }, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -/** Retrieves a vector store file. */ -export async function getVectorStoreFile( - context: Client, - vectorStoreId: string, - fileId: string, - options: GetVectorStoreFileOptionalParams = {}, -): Promise { - const getOptions: GeneratedParameters.GetVectorStoreFileParameters = { - ...operationOptionsToRequestParameters(options), - }; - - validateVectorStoreId(vectorStoreId); - validateFileId(fileId); - const result = await context - .path("/vector_stores/{vectorStoreId}/files/{fileId}", vectorStoreId, fileId) - .get(getOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreFileOutput(result.body); -} - -/** - * Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. - * To delete the file, use the delete file endpoint. - */ -export async function deleteVectorStoreFile( - context: Client, - vectorStoreId: string, - fileId: string, - options: DeleteVectorStoreFileOptionalParams = {}, -): Promise { - validateVectorStoreId(vectorStoreId); - validateFileId(fileId); - const deleteOptions: GeneratedParameters.GetVectorStoreFileParameters = { - ...operationOptionsToRequestParameters(options), - }; - const result = await context - .path("/vector_stores/{vectorStoreId}/files/{fileId}", vectorStoreId, fileId) - .delete(deleteOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreFileDeletionStatusOutput(result.body); -} - -/** Create a vector store file by attaching a file to a vector store and poll. */ -export function createVectorStoreFileAndPoll( - context: Client, - vectorStoreId: string, - options: CreateVectorStoreFileOptionalParams = {}, -): PollerLike, VectorStoreFileOutput> { - return createPoller({ - initOperation: async () => { - return createVectorStoreFileInternal(context, vectorStoreId, options); - }, - pollOperation: async (currentResult: VectorStoreFileOutput) => { - return getVectorStoreFile(context, vectorStoreId, currentResult.id, options); - }, - getOperationStatus: getLroOperationStatus, - getOperationError: (result: VectorStoreFileOutput) => { - return result.status === "failed" && result.lastError - ? new Error( - `Operation failed with code ${result.lastError.code}: ${result.lastError.message}`, - ) - : undefined; - }, - intervalInMs: options.pollingOptions?.sleepIntervalInMs, - }); -} - -async function createVectorStoreFileInternal( - context: Client, - vectorStoreId: string, - options: CreateVectorStoreFileOptionalParams = {}, -): Promise { - const createOptions: CreateVectorStoreFileParameters = { - ...operationOptionsToRequestParameters(options), - ...ConvertParamsToWire.convertCreateVectorStoreFileParam({ body: options }), - }; - - validateVectorStoreId(vectorStoreId); - validateCreateVectorStoreFileParameters(createOptions); - const result = await context - .path("/vector_stores/{vectorStoreId}/files", vectorStoreId) - .post(createOptions); - if (!expectedStatuses.includes(result.status)) { - throw createOpenAIError(result); - } - return ConvertFromWire.convertVectorStoreFileOutput(result.body); -} - -function getLroOperationStatus(result: VectorStoreFileOutput): OperationStatus { - switch (result.status) { - case "in_progress": - return "running"; - case "completed": - return "succeeded"; - case "cancelled": - return "canceled"; - default: - return "failed"; - } -} - -function validateListVectorStoreFilesParameters(options?: ListVectorStoreFilesParameters): void { - if (options?.queryParameters?.filter) { - validateFileStatusFilter(options.queryParameters.filter); - } - if (options?.queryParameters?.limit) { - validateLimit(options.queryParameters.limit); - } - if (options?.queryParameters?.order) { - validateOrder(options.queryParameters.order); - } -} - -function validateCreateVectorStoreFileParameters(options?: CreateVectorStoreFileParameters): void { - if (options?.body?.chunking_strategy && !options.body.file_id) { - throw new Error("Chunking strategy is only applicable if fileId is included"); - } -} diff --git a/sdk/ai/ai-projects/src/agents/vectorStoresModels.ts b/sdk/ai/ai-projects/src/agents/vectorStoresModels.ts deleted file mode 100644 index 03b58c251467..000000000000 --- a/sdk/ai/ai-projects/src/agents/vectorStoresModels.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - VectorStoreChunkingStrategyRequest, - VectorStoreDataSource, - VectorStoreFileStatusFilter, -} from "../customization/models.js"; - -/** Request object for creating a vector store file. */ -export interface CreateVectorStoreFileOptions { - /** A File ID that the vector store should use. Useful for tools like `file_search` that can access files. */ - fileId?: string; - - /** The data sources to be used. This option is mutually exclusive with fileId. */ - dataSources?: Array; - - /** The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. */ - chunkingStrategy?: VectorStoreChunkingStrategyRequest; -} - -/** Request object for creating a vector store file batch. */ -export interface CreateVectorStoreFileBatchOptions { - /** A list of File IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ - fileIds?: string[]; - - /** The data sources to be used. This option is mutually exclusive with fileId. */ - dataSources?: VectorStoreDataSource[]; - - /** The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. */ - chunkingStrategy?: VectorStoreChunkingStrategyRequest; -} - -/** Filter by file status. */ -export interface FileStatusFilter { - /** - * Possible values: "in_progress", "completed", "failed", "cancelled" - */ - filter?: VectorStoreFileStatusFilter; -} diff --git a/sdk/ai/ai-projects/src/aiProjectClient.ts b/sdk/ai/ai-projects/src/aiProjectClient.ts new file mode 100644 index 000000000000..b5cd23e64983 --- /dev/null +++ b/sdk/ai/ai-projects/src/aiProjectClient.ts @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + createAIProject, + AIProjectContext, + AIProjectClientOptionalParams, +} from "./api/index.js"; +import { + RedTeamsOperations, + _getRedTeamsOperations, +} from "./classic/redTeams/index.js"; +import { + DeploymentsOperations, + _getDeploymentsOperations, +} from "./classic/deployments/index.js"; +import { + IndexesOperations, + _getIndexesOperations, +} from "./classic/indexes/index.js"; +import { + DatasetsOperations, + _getDatasetsOperations, +} from "./classic/datasets/index.js"; +import { + EvaluationsOperations, + _getEvaluationsOperations, +} from "./classic/evaluations/index.js"; +import { + ConnectionsOperations, + _getConnectionsOperations, +} from "./classic/connections/index.js"; +import { Pipeline } from "@azure/core-rest-pipeline"; +import { TokenCredential } from "@azure/core-auth"; + +export { AIProjectClientOptionalParams } from "./api/aiProjectContext.js"; + +export class AIProjectClient { + private _client: AIProjectContext; + /** The pipeline used by this client to make requests */ + public readonly pipeline: Pipeline; + + constructor( + endpointParam: string, + credential: TokenCredential, + options: AIProjectClientOptionalParams = {}, + ) { + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-client` + : `azsdk-js-client`; + this._client = createAIProject(endpointParam, credential, { + ...options, + userAgentOptions: { userAgentPrefix }, + }); + this.pipeline = this._client.pipeline; + this.redTeams = _getRedTeamsOperations(this._client); + this.deployments = _getDeploymentsOperations(this._client); + this.indexes = _getIndexesOperations(this._client); + this.datasets = _getDatasetsOperations(this._client); + this.evaluations = _getEvaluationsOperations(this._client); + this.connections = _getConnectionsOperations(this._client); + } + + /** The operation groups for redTeams */ + public readonly redTeams: RedTeamsOperations; + /** The operation groups for deployments */ + public readonly deployments: DeploymentsOperations; + /** The operation groups for indexes */ + public readonly indexes: IndexesOperations; + /** The operation groups for datasets */ + public readonly datasets: DatasetsOperations; + /** The operation groups for evaluations */ + public readonly evaluations: EvaluationsOperations; + /** The operation groups for connections */ + public readonly connections: ConnectionsOperations; +} diff --git a/sdk/ai/ai-projects/src/aiProjectsClient.ts b/sdk/ai/ai-projects/src/aiProjectsClient.ts deleted file mode 100644 index ad6af9c98c00..000000000000 --- a/sdk/ai/ai-projects/src/aiProjectsClient.ts +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -import type { Client } from "@azure-rest/core-client"; -import type { TokenCredential } from "@azure/core-auth"; -import type { AgentsOperations } from "./agents/index.js"; -import { getAgentsOperations } from "./agents/index.js"; -import type { ConnectionsOperations } from "./connections/index.js"; -import { getConnectionsOperations } from "./connections/index.js"; -import type { ProjectsClientOptions } from "./generated/src/projectsClient.js"; -import createClient from "./generated/src/projectsClient.js"; -import type { TelemetryOperations } from "./telemetry/index.js"; -import { getTelemetryOperations } from "./telemetry/index.js"; - -/** - * The options for the AIProjectsClient - */ -export interface AIProjectsClientOptions extends ProjectsClientOptions {} - -/** - * The Azure AI Projects client - */ -export class AIProjectsClient { - private _client: Client; - private _connectionClient: Client; - private _telemetryClient: Client; - - /* - * @param endpointParam - The Azure AI Foundry project endpoint, in the form `https://.api.azureml.ms` or `https://..api.azureml.ms`, where is the Azure region where the project is deployed (e.g. westus) and is the GUID of the Enterprise private link. - * @param subscriptionId - The Azure subscription ID. - * @param resourceGroupName - The name of the Azure Resource Group. - * @param projectName - The Azure AI Foundry project name. - * @param options - the parameter for all optional parameters - */ - constructor( - endpointParam: string, - subscriptionId: string, - resourceGroupName: string, - projectName: string, - credential: TokenCredential, - options: AIProjectsClientOptions = {}, - ) { - const connectionEndPoint = `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/${projectName}`; - this._client = createClient( - endpointParam, - subscriptionId, - resourceGroupName, - projectName, - credential, - options, - ); - - this._connectionClient = createClient( - endpointParam, - subscriptionId, - resourceGroupName, - projectName, - credential, - { ...options, endpoint: connectionEndPoint }, - ); - - this._telemetryClient = createClient( - endpointParam, - subscriptionId, - resourceGroupName, - projectName, - credential, - { ...options, apiVersion: "2020-02-02", endpoint: "https://management.azure.com" }, - ); - - this.agents = getAgentsOperations(this._client); - this.connections = getConnectionsOperations(this._connectionClient); - this.telemetry = getTelemetryOperations(this._telemetryClient, this.connections); - } - - /** - * Creates a new instance of AzureAIProjectsClient - * @param connectionString - Connection string with the endpoint, subscriptionId, resourceGroupName, and projectName - * @param credential - The credential to use - * @param options - The parameter for all optional parameters - */ - static fromConnectionString( - connectionString: string, - credential: TokenCredential, - // eslint-disable-next-line @azure/azure-sdk/ts-naming-options - options: AIProjectsClientOptions = {}, - ): AIProjectsClient { - const { endpointParam, subscriptionId, resourceGroupName, projectName } = - AIProjectsClient.praseConnectionString(connectionString); - return new AIProjectsClient( - endpointParam, - subscriptionId, - resourceGroupName, - projectName, - credential, - options, - ); - } - - private static praseConnectionString(connectionString: string): { - endpointParam: string; - subscriptionId: string; - resourceGroupName: string; - projectName: string; - } { - const parts = connectionString.split(";"); - return { - endpointParam: `https://${parts[0]}`, - subscriptionId: parts[1], - resourceGroupName: parts[2], - projectName: parts[3], - }; - } - - /** The operation groups for Agents */ - public readonly agents: AgentsOperations; - - /** The operation groups for connections */ - public readonly connections: ConnectionsOperations; - - /** The operation groups for telemetry */ - public readonly telemetry: TelemetryOperations; -} diff --git a/sdk/ai/ai-projects/src/api/aiProjectContext.ts b/sdk/ai/ai-projects/src/api/aiProjectContext.ts new file mode 100644 index 000000000000..d57730860a23 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/aiProjectContext.ts @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { logger } from "../logger.js"; +import { KnownVersions } from "../models/models.js"; +import { Client, ClientOptions, getClient } from "@azure-rest/core-client"; +import { TokenCredential } from "@azure/core-auth"; + +export interface AIProjectContext extends Client { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion: string; +} + +/** Optional parameters for the client. */ +export interface AIProjectClientOptionalParams extends ClientOptions { + /** The API version to use for this operation. */ + /** Known values of {@link KnownVersions} that the service accepts. */ + apiVersion?: string; +} + +export function createAIProject( + endpointParam: string, + credential: TokenCredential, + options: AIProjectClientOptionalParams = {}, +): AIProjectContext { + const endpointUrl = + options.endpoint ?? options.baseUrl ?? String(endpointParam); + const prefixFromOptions = options?.userAgentOptions?.userAgentPrefix; + const userAgentInfo = `azsdk-js-ai-projects/1.0.0-beta.1`; + const userAgentPrefix = prefixFromOptions + ? `${prefixFromOptions} azsdk-js-api ${userAgentInfo}` + : `azsdk-js-api ${userAgentInfo}`; + const { apiVersion: _, ...updatedOptions } = { + ...options, + userAgentOptions: { userAgentPrefix }, + loggingOptions: { logger: options.loggingOptions?.logger ?? logger.info }, + credentials: { + scopes: options.credentials?.scopes ?? ["https://ai.azure.com/.default"], + }, + }; + const clientContext = getClient(endpointUrl, credential, updatedOptions); + clientContext.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + const apiVersion = options.apiVersion ?? "2025-05-15-preview"; + clientContext.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version")) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + return { ...clientContext, apiVersion } as AIProjectContext; +} diff --git a/sdk/ai/ai-projects/src/api/connections/index.ts b/sdk/ai/ai-projects/src/api/connections/index.ts new file mode 100644 index 000000000000..24767b66c8b5 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/connections/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { list, getWithCredentials, get } from "./operations.js"; +export { + ConnectionsListOptionalParams, + ConnectionsGetWithCredentialsOptionalParams, + ConnectionsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/ai/ai-projects/src/api/connections/operations.ts b/sdk/ai/ai-projects/src/api/connections/operations.ts new file mode 100644 index 000000000000..ad0932088f21 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/connections/operations.ts @@ -0,0 +1,183 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext as Client } from "../index.js"; +import { + Connection, + connectionDeserializer, + _PagedConnection, + _pagedConnectionDeserializer, +} from "../../models/models.js"; +import { + ConnectionsListOptionalParams, + ConnectionsGetWithCredentialsOptionalParams, + ConnectionsGetOptionalParams, +} from "./options.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _listSend( + context: Client, + options: ConnectionsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/connections{?api%2Dversion,connectionType,defaultConnection,top,skip,maxpagesize}", + { + "api%2Dversion": context.apiVersion, + connectionType: options?.connectionType, + defaultConnection: options?.defaultConnection, + top: options?.top, + skip: options?.skip, + maxpagesize: options?.maxpagesize, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedConnection> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedConnectionDeserializer(result.body); +} + +/** List all connections in the project, without populating connection credentials */ +export function list( + context: Client, + options: ConnectionsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getWithCredentialsSend( + context: Client, + name: string, + options: ConnectionsGetWithCredentialsOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/connections/{name}/getConnectionWithCredentials{?api%2Dversion}", + { + name: name, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .post({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getWithCredentialsDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return connectionDeserializer(result.body); +} + +/** Get a connection by name, with its connection credentials */ +export async function getWithCredentials( + context: Client, + name: string, + options: ConnectionsGetWithCredentialsOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getWithCredentialsSend(context, name, options); + return _getWithCredentialsDeserialize(result); +} + +export function _getSend( + context: Client, + name: string, + options: ConnectionsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/connections/{name}{?api%2Dversion}", + { + name: name, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return connectionDeserializer(result.body); +} + +/** Get a connection by name, without populating connection credentials */ +export async function get( + context: Client, + name: string, + options: ConnectionsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, name, options); + return _getDeserialize(result); +} diff --git a/sdk/ai/ai-projects/src/api/connections/options.ts b/sdk/ai/ai-projects/src/api/connections/options.ts new file mode 100644 index 000000000000..ac2032abe05c --- /dev/null +++ b/sdk/ai/ai-projects/src/api/connections/options.ts @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { ConnectionType } from "../../models/models.js"; +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface ConnectionsListOptionalParams extends OperationOptions { + /** List connections of this specific type */ + connectionType?: ConnectionType; + /** List connections that are default connections */ + defaultConnection?: boolean; + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} + +/** Optional parameters. */ +export interface ConnectionsGetWithCredentialsOptionalParams + extends OperationOptions { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} + +/** Optional parameters. */ +export interface ConnectionsGetOptionalParams extends OperationOptions { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} diff --git a/sdk/ai/ai-projects/src/api/datasets/index.ts b/sdk/ai/ai-projects/src/api/datasets/index.ts new file mode 100644 index 000000000000..00bb048fcc53 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/datasets/index.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + getCredentials, + pendingUpload, + createOrUpdate, + $delete, + get, + list, + listVersions, +} from "./operations.js"; +export { + DatasetsGetCredentialsOptionalParams, + DatasetsPendingUploadOptionalParams, + DatasetsCreateOrUpdateOptionalParams, + DatasetsDeleteOptionalParams, + DatasetsGetOptionalParams, + DatasetsListOptionalParams, + DatasetsListVersionsOptionalParams, +} from "./options.js"; diff --git a/sdk/ai/ai-projects/src/api/datasets/operations.ts b/sdk/ai/ai-projects/src/api/datasets/operations.ts new file mode 100644 index 000000000000..888e7447650b --- /dev/null +++ b/sdk/ai/ai-projects/src/api/datasets/operations.ts @@ -0,0 +1,426 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext as Client } from "../index.js"; +import { + _PagedDatasetVersion, + _pagedDatasetVersionDeserializer, + datasetVersionUnionSerializer, + datasetVersionUnionDeserializer, + DatasetVersionUnion, + PendingUploadRequest, + pendingUploadRequestSerializer, + PendingUploadResponse, + pendingUploadResponseDeserializer, + _getCredentialsRequestSerializer, + AssetCredentialResponse, + assetCredentialResponseDeserializer, +} from "../../models/models.js"; +import { + DatasetsGetCredentialsOptionalParams, + DatasetsPendingUploadOptionalParams, + DatasetsCreateOrUpdateOptionalParams, + DatasetsDeleteOptionalParams, + DatasetsGetOptionalParams, + DatasetsListOptionalParams, + DatasetsListVersionsOptionalParams, +} from "./options.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _getCredentialsSend( + context: Client, + name: string, + body: Record, + version: string, + options: DatasetsGetCredentialsOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/datasets/{name}/versions/{version}/credentials{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: _getCredentialsRequestSerializer(body), + }); +} + +export async function _getCredentialsDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return assetCredentialResponseDeserializer(result.body); +} + +/** Get the SAS credential to access the storage account associated with a Dataset version. */ +export async function getCredentials( + context: Client, + name: string, + body: Record, + version: string, + options: DatasetsGetCredentialsOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getCredentialsSend( + context, + name, + body, + version, + options, + ); + return _getCredentialsDeserialize(result); +} + +export function _pendingUploadSend( + context: Client, + name: string, + body: PendingUploadRequest, + version: string, + options: DatasetsPendingUploadOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/datasets/{name}/versions/{version}/startPendingUpload{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: pendingUploadRequestSerializer(body), + }); +} + +export async function _pendingUploadDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return pendingUploadResponseDeserializer(result.body); +} + +/** Start a new or get an existing pending upload of a dataset for a specific version. */ +export async function pendingUpload( + context: Client, + name: string, + body: PendingUploadRequest, + version: string, + options: DatasetsPendingUploadOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _pendingUploadSend( + context, + name, + body, + version, + options, + ); + return _pendingUploadDeserialize(result); +} + +export function _createOrUpdateSend( + context: Client, + name: string, + body: DatasetVersionUnion, + version: string, + options: DatasetsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/datasets/{name}/versions/{version}{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: datasetVersionUnionSerializer(body), + }); +} + +export async function _createOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["201", "200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return datasetVersionUnionDeserializer(result.body); +} + +/** Create a new or update an existing DatasetVersion with the given version id */ +export async function createOrUpdate( + context: Client, + name: string, + body: DatasetVersionUnion, + version: string, + options: DatasetsCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createOrUpdateSend( + context, + name, + body, + version, + options, + ); + return _createOrUpdateDeserialize(result); +} + +export function _$deleteSend( + context: Client, + name: string, + version: string, + options: DatasetsDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/datasets/{name}/versions/{version}{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _$deleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["204"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return; +} + +/** Delete the specific version of the DatasetVersion */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export async function $delete( + context: Client, + name: string, + version: string, + options: DatasetsDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _$deleteSend(context, name, version, options); + return _$deleteDeserialize(result); +} + +export function _getSend( + context: Client, + name: string, + version: string, + options: DatasetsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/datasets/{name}/versions/{version}{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return datasetVersionUnionDeserializer(result.body); +} + +/** Get the specific version of the DatasetVersion */ +export async function get( + context: Client, + name: string, + version: string, + options: DatasetsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, name, version, options); + return _getDeserialize(result); +} + +export function _listSend( + context: Client, + options: DatasetsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/datasets{?api%2Dversion,continuationToken}", + { + "api%2Dversion": context.apiVersion, + continuationToken: options?.continuationToken, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedDatasetVersion> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedDatasetVersionDeserializer(result.body); +} + +/** List the latest version of each DatasetVersion */ +export function list( + context: Client, + options: DatasetsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _listVersionsSend( + context: Client, + name: string, + options: DatasetsListVersionsOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/datasets/{name}/versions{?api%2Dversion,continuationToken}", + { + name: name, + "api%2Dversion": context.apiVersion, + continuationToken: options?.continuationToken, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listVersionsDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedDatasetVersion> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedDatasetVersionDeserializer(result.body); +} + +/** List all versions of the given DatasetVersion */ +export function listVersions( + context: Client, + name: string, + options: DatasetsListVersionsOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listVersionsSend(context, name, options), + _listVersionsDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/ai/ai-projects/src/api/datasets/options.ts b/sdk/ai/ai-projects/src/api/datasets/options.ts new file mode 100644 index 000000000000..4a3397e88367 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/datasets/options.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface DatasetsGetCredentialsOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface DatasetsPendingUploadOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface DatasetsCreateOrUpdateOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface DatasetsDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface DatasetsGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface DatasetsListOptionalParams extends OperationOptions { + /** Continuation token for pagination. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface DatasetsListVersionsOptionalParams extends OperationOptions { + /** Continuation token for pagination. */ + continuationToken?: string; +} diff --git a/sdk/ai/ai-projects/src/api/deployments/index.ts b/sdk/ai/ai-projects/src/api/deployments/index.ts new file mode 100644 index 000000000000..85bb6b900bd5 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/deployments/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { list, get } from "./operations.js"; +export { + DeploymentsListOptionalParams, + DeploymentsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/ai/ai-projects/src/api/deployments/operations.ts b/sdk/ai/ai-projects/src/api/deployments/operations.ts new file mode 100644 index 000000000000..35dd590b0ada --- /dev/null +++ b/sdk/ai/ai-projects/src/api/deployments/operations.ts @@ -0,0 +1,133 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext as Client } from "../index.js"; +import { + deploymentUnionDeserializer, + DeploymentUnion, + _PagedDeployment, + _pagedDeploymentDeserializer, +} from "../../models/models.js"; +import { + DeploymentsListOptionalParams, + DeploymentsGetOptionalParams, +} from "./options.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _listSend( + context: Client, + options: DeploymentsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/deployments{?api%2Dversion,modelPublisher,modelName,deploymentType,top,skip,maxpagesize}", + { + "api%2Dversion": context.apiVersion, + modelPublisher: options?.modelPublisher, + modelName: options?.modelName, + deploymentType: options?.deploymentType, + top: options?.top, + skip: options?.skip, + maxpagesize: options?.maxpagesize, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedDeployment> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedDeploymentDeserializer(result.body); +} + +/** List all deployed models in the project */ +export function list( + context: Client, + options: DeploymentsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getSend( + context: Client, + name: string, + options: DeploymentsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/deployments/{name}{?api%2Dversion}", + { + name: name, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return deploymentUnionDeserializer(result.body); +} + +/** Get a deployed model. */ +export async function get( + context: Client, + name: string, + options: DeploymentsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, name, options); + return _getDeserialize(result); +} diff --git a/sdk/ai/ai-projects/src/api/deployments/options.ts b/sdk/ai/ai-projects/src/api/deployments/options.ts new file mode 100644 index 000000000000..f84dce675fa6 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/deployments/options.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DeploymentType } from "../../models/models.js"; +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface DeploymentsListOptionalParams extends OperationOptions { + /** Model publisher to filter models by */ + modelPublisher?: string; + /** Model name (the publisher specific name) to filter models by */ + modelName?: string; + /** Type of deployment to filter list by */ + deploymentType?: DeploymentType; + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} + +/** Optional parameters. */ +export interface DeploymentsGetOptionalParams extends OperationOptions { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} diff --git a/sdk/ai/ai-projects/src/api/evaluations/index.ts b/sdk/ai/ai-projects/src/api/evaluations/index.ts new file mode 100644 index 000000000000..7f2b836b5d94 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/evaluations/index.ts @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { createAgentEvaluation, create, list, get } from "./operations.js"; +export { + EvaluationsCreateAgentEvaluationOptionalParams, + EvaluationsCreateOptionalParams, + EvaluationsListOptionalParams, + EvaluationsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/ai/ai-projects/src/api/evaluations/operations.ts b/sdk/ai/ai-projects/src/api/evaluations/operations.ts new file mode 100644 index 000000000000..8ed619b7409f --- /dev/null +++ b/sdk/ai/ai-projects/src/api/evaluations/operations.ts @@ -0,0 +1,237 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext as Client } from "../index.js"; +import { + Evaluation, + evaluationSerializer, + evaluationDeserializer, + _PagedEvaluation, + _pagedEvaluationDeserializer, + AgentEvaluationRequest, + agentEvaluationRequestSerializer, + AgentEvaluation, + agentEvaluationDeserializer, +} from "../../models/models.js"; +import { + EvaluationsCreateAgentEvaluationOptionalParams, + EvaluationsCreateOptionalParams, + EvaluationsListOptionalParams, + EvaluationsGetOptionalParams, +} from "./options.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _createAgentEvaluationSend( + context: Client, + evaluation: AgentEvaluationRequest, + options: EvaluationsCreateAgentEvaluationOptionalParams = { + requestOptions: {}, + }, +): StreamableMethod { + const path = expandUrlTemplate( + "/evaluations/runs:runAgent{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: agentEvaluationRequestSerializer(evaluation), + }); +} + +export async function _createAgentEvaluationDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["201"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return agentEvaluationDeserializer(result.body); +} + +/** Creates an agent evaluation run. */ +export async function createAgentEvaluation( + context: Client, + evaluation: AgentEvaluationRequest, + options: EvaluationsCreateAgentEvaluationOptionalParams = { + requestOptions: {}, + }, +): Promise { + const result = await _createAgentEvaluationSend(context, evaluation, options); + return _createAgentEvaluationDeserialize(result); +} + +export function _createSend( + context: Client, + evaluation: Evaluation, + options: EvaluationsCreateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/evaluations/runs:run{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: evaluationSerializer(evaluation), + }); +} + +export async function _createDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["201"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return evaluationDeserializer(result.body); +} + +/** Creates an evaluation run. */ +export async function create( + context: Client, + evaluation: Evaluation, + options: EvaluationsCreateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createSend(context, evaluation, options); + return _createDeserialize(result); +} + +export function _listSend( + context: Client, + options: EvaluationsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/evaluations/runs{?api%2Dversion,top,skip,maxpagesize}", + { + "api%2Dversion": context.apiVersion, + top: options?.top, + skip: options?.skip, + maxpagesize: options?.maxpagesize, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedEvaluation> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedEvaluationDeserializer(result.body); +} + +/** List evaluation runs */ +export function list( + context: Client, + options: EvaluationsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getSend( + context: Client, + name: string, + options: EvaluationsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/evaluations/runs/{name}{?api%2Dversion}", + { + name: name, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return evaluationDeserializer(result.body); +} + +/** Get an evaluation run by name. */ +export async function get( + context: Client, + name: string, + options: EvaluationsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, name, options); + return _getDeserialize(result); +} diff --git a/sdk/ai/ai-projects/src/api/evaluations/options.ts b/sdk/ai/ai-projects/src/api/evaluations/options.ts new file mode 100644 index 000000000000..bccfcbdffd30 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/evaluations/options.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface EvaluationsCreateAgentEvaluationOptionalParams + extends OperationOptions {} + +/** Optional parameters. */ +export interface EvaluationsCreateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface EvaluationsListOptionalParams extends OperationOptions { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} + +/** Optional parameters. */ +export interface EvaluationsGetOptionalParams extends OperationOptions { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} diff --git a/sdk/ai/ai-projects/src/api/index.ts b/sdk/ai/ai-projects/src/api/index.ts new file mode 100644 index 000000000000..c0caa294bb95 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/index.ts @@ -0,0 +1,8 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + createAIProject, + AIProjectContext, + AIProjectClientOptionalParams, +} from "./aiProjectContext.js"; diff --git a/sdk/ai/ai-projects/src/api/indexes/index.ts b/sdk/ai/ai-projects/src/api/indexes/index.ts new file mode 100644 index 000000000000..a8f6b7c81983 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/indexes/index.ts @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + createOrUpdate, + $delete, + get, + list, + listVersions, +} from "./operations.js"; +export { + IndexesCreateOrUpdateOptionalParams, + IndexesDeleteOptionalParams, + IndexesGetOptionalParams, + IndexesListOptionalParams, + IndexesListVersionsOptionalParams, +} from "./options.js"; diff --git a/sdk/ai/ai-projects/src/api/indexes/operations.ts b/sdk/ai/ai-projects/src/api/indexes/operations.ts new file mode 100644 index 000000000000..9c3080dd90ae --- /dev/null +++ b/sdk/ai/ai-projects/src/api/indexes/operations.ts @@ -0,0 +1,297 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext as Client } from "../index.js"; +import { + _PagedIndex, + _pagedIndexDeserializer, + indexUnionSerializer, + indexUnionDeserializer, + IndexUnion, +} from "../../models/models.js"; +import { + IndexesCreateOrUpdateOptionalParams, + IndexesDeleteOptionalParams, + IndexesGetOptionalParams, + IndexesListOptionalParams, + IndexesListVersionsOptionalParams, +} from "./options.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _createOrUpdateSend( + context: Client, + name: string, + body: IndexUnion, + version: string, + options: IndexesCreateOrUpdateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/indexes/{name}/versions/{version}{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .patch({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: indexUnionSerializer(body), + }); +} + +export async function _createOrUpdateDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["201", "200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return indexUnionDeserializer(result.body); +} + +/** Create a new or update an existing Index with the given version id */ +export async function createOrUpdate( + context: Client, + name: string, + body: IndexUnion, + version: string, + options: IndexesCreateOrUpdateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createOrUpdateSend( + context, + name, + body, + version, + options, + ); + return _createOrUpdateDeserialize(result); +} + +export function _$deleteSend( + context: Client, + name: string, + version: string, + options: IndexesDeleteOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/indexes/{name}/versions/{version}{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .delete({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _$deleteDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["204"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return; +} + +/** Delete the specific version of the Index */ +/** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ +export async function $delete( + context: Client, + name: string, + version: string, + options: IndexesDeleteOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _$deleteSend(context, name, version, options); + return _$deleteDeserialize(result); +} + +export function _getSend( + context: Client, + name: string, + version: string, + options: IndexesGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/indexes/{name}/versions/{version}{?api%2Dversion}", + { + name: name, + version: version, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return indexUnionDeserializer(result.body); +} + +/** Get the specific version of the Index */ +export async function get( + context: Client, + name: string, + version: string, + options: IndexesGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, name, version, options); + return _getDeserialize(result); +} + +export function _listSend( + context: Client, + options: IndexesListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/indexes{?api%2Dversion,continuationToken}", + { + "api%2Dversion": context.apiVersion, + continuationToken: options?.continuationToken, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedIndex> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedIndexDeserializer(result.body); +} + +/** List the latest version of each Index */ +export function list( + context: Client, + options: IndexesListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _listVersionsSend( + context: Client, + name: string, + options: IndexesListVersionsOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/indexes/{name}/versions{?api%2Dversion,continuationToken}", + { + name: name, + "api%2Dversion": context.apiVersion, + continuationToken: options?.continuationToken, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listVersionsDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedIndex> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedIndexDeserializer(result.body); +} + +/** List all versions of the given Index */ +export function listVersions( + context: Client, + name: string, + options: IndexesListVersionsOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listVersionsSend(context, name, options), + _listVersionsDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} diff --git a/sdk/ai/ai-projects/src/api/indexes/options.ts b/sdk/ai/ai-projects/src/api/indexes/options.ts new file mode 100644 index 000000000000..40c333d91246 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/indexes/options.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface IndexesCreateOrUpdateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface IndexesDeleteOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface IndexesGetOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface IndexesListOptionalParams extends OperationOptions { + /** Continuation token for pagination. */ + continuationToken?: string; +} + +/** Optional parameters. */ +export interface IndexesListVersionsOptionalParams extends OperationOptions { + /** Continuation token for pagination. */ + continuationToken?: string; +} diff --git a/sdk/ai/ai-projects/src/api/redTeams/index.ts b/sdk/ai/ai-projects/src/api/redTeams/index.ts new file mode 100644 index 000000000000..e4ff0792c953 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/redTeams/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { create, list, get } from "./operations.js"; +export { + RedTeamsCreateOptionalParams, + RedTeamsListOptionalParams, + RedTeamsGetOptionalParams, +} from "./options.js"; diff --git a/sdk/ai/ai-projects/src/api/redTeams/operations.ts b/sdk/ai/ai-projects/src/api/redTeams/operations.ts new file mode 100644 index 000000000000..06047c585964 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/redTeams/operations.ts @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext as Client } from "../index.js"; +import { + RedTeam, + redTeamSerializer, + redTeamDeserializer, + _PagedRedTeam, + _pagedRedTeamDeserializer, +} from "../../models/models.js"; +import { + RedTeamsCreateOptionalParams, + RedTeamsListOptionalParams, + RedTeamsGetOptionalParams, +} from "./options.js"; +import { + PagedAsyncIterableIterator, + buildPagedAsyncIterator, +} from "../../static-helpers/pagingHelpers.js"; +import { expandUrlTemplate } from "../../static-helpers/urlTemplate.js"; +import { + StreamableMethod, + PathUncheckedResponse, + createRestError, + operationOptionsToRequestParameters, +} from "@azure-rest/core-client"; + +export function _createSend( + context: Client, + redTeam: RedTeam, + options: RedTeamsCreateOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/redTeams/runs:run{?api%2Dversion}", + { + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .post({ + ...operationOptionsToRequestParameters(options), + contentType: "application/json", + headers: { + accept: "application/json", + ...options.requestOptions?.headers, + }, + body: redTeamSerializer(redTeam), + }); +} + +export async function _createDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["201"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return redTeamDeserializer(result.body); +} + +/** Creates a redteam run. */ +export async function create( + context: Client, + redTeam: RedTeam, + options: RedTeamsCreateOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _createSend(context, redTeam, options); + return _createDeserialize(result); +} + +export function _listSend( + context: Client, + options: RedTeamsListOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/redTeams/runs{?api%2Dversion,top,skip,maxpagesize}", + { + "api%2Dversion": context.apiVersion, + top: options?.top, + skip: options?.skip, + maxpagesize: options?.maxpagesize, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _listDeserialize( + result: PathUncheckedResponse, +): Promise<_PagedRedTeam> { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return _pagedRedTeamDeserializer(result.body); +} + +/** List a redteam by name. */ +export function list( + context: Client, + options: RedTeamsListOptionalParams = { requestOptions: {} }, +): PagedAsyncIterableIterator { + return buildPagedAsyncIterator( + context, + () => _listSend(context, options), + _listDeserialize, + ["200"], + { itemName: "value", nextLinkName: "nextLink" }, + ); +} + +export function _getSend( + context: Client, + name: string, + options: RedTeamsGetOptionalParams = { requestOptions: {} }, +): StreamableMethod { + const path = expandUrlTemplate( + "/redTeams/runs/{name}{?api%2Dversion}", + { + name: name, + "api%2Dversion": context.apiVersion, + }, + { + allowReserved: options?.requestOptions?.skipUrlEncoding, + }, + ); + return context + .path(path) + .get({ + ...operationOptionsToRequestParameters(options), + headers: { + ...(options?.clientRequestId !== undefined + ? { "x-ms-client-request-id": options?.clientRequestId } + : {}), + accept: "application/json", + ...options.requestOptions?.headers, + }, + }); +} + +export async function _getDeserialize( + result: PathUncheckedResponse, +): Promise { + const expectedStatuses = ["200"]; + if (!expectedStatuses.includes(result.status)) { + throw createRestError(result); + } + + return redTeamDeserializer(result.body); +} + +/** Get a redteam by name. */ +export async function get( + context: Client, + name: string, + options: RedTeamsGetOptionalParams = { requestOptions: {} }, +): Promise { + const result = await _getSend(context, name, options); + return _getDeserialize(result); +} diff --git a/sdk/ai/ai-projects/src/api/redTeams/options.ts b/sdk/ai/ai-projects/src/api/redTeams/options.ts new file mode 100644 index 000000000000..13d9d862b667 --- /dev/null +++ b/sdk/ai/ai-projects/src/api/redTeams/options.ts @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { OperationOptions } from "@azure-rest/core-client"; + +/** Optional parameters. */ +export interface RedTeamsCreateOptionalParams extends OperationOptions {} + +/** Optional parameters. */ +export interface RedTeamsListOptionalParams extends OperationOptions { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} + +/** Optional parameters. */ +export interface RedTeamsGetOptionalParams extends OperationOptions { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + clientRequestId?: string; +} diff --git a/sdk/ai/ai-projects/src/classic/connections/index.ts b/sdk/ai/ai-projects/src/classic/connections/index.ts new file mode 100644 index 000000000000..1b0de541af21 --- /dev/null +++ b/sdk/ai/ai-projects/src/classic/connections/index.ts @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext } from "../../api/aiProjectContext.js"; +import { Connection } from "../../models/models.js"; +import { + ConnectionsListOptionalParams, + ConnectionsGetWithCredentialsOptionalParams, + ConnectionsGetOptionalParams, +} from "../../api/connections/options.js"; +import { + list, + getWithCredentials, + get, +} from "../../api/connections/operations.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Connections operations. */ +export interface ConnectionsOperations { + /** List all connections in the project, without populating connection credentials */ + list: ( + options?: ConnectionsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a connection by name, with its connection credentials */ + getWithCredentials: ( + name: string, + options?: ConnectionsGetWithCredentialsOptionalParams, + ) => Promise; + /** Get a connection by name, without populating connection credentials */ + get: ( + name: string, + options?: ConnectionsGetOptionalParams, + ) => Promise; +} + +function _getConnections(context: AIProjectContext) { + return { + list: (options?: ConnectionsListOptionalParams) => list(context, options), + getWithCredentials: ( + name: string, + options?: ConnectionsGetWithCredentialsOptionalParams, + ) => getWithCredentials(context, name, options), + get: (name: string, options?: ConnectionsGetOptionalParams) => + get(context, name, options), + }; +} + +export function _getConnectionsOperations( + context: AIProjectContext, +): ConnectionsOperations { + return { + ..._getConnections(context), + }; +} diff --git a/sdk/ai/ai-projects/src/classic/datasets/index.ts b/sdk/ai/ai-projects/src/classic/datasets/index.ts new file mode 100644 index 000000000000..d774c16b441e --- /dev/null +++ b/sdk/ai/ai-projects/src/classic/datasets/index.ts @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext } from "../../api/aiProjectContext.js"; +import { + DatasetVersionUnion, + PendingUploadRequest, + PendingUploadResponse, + AssetCredentialResponse, +} from "../../models/models.js"; +import { + DatasetsGetCredentialsOptionalParams, + DatasetsPendingUploadOptionalParams, + DatasetsCreateOrUpdateOptionalParams, + DatasetsDeleteOptionalParams, + DatasetsGetOptionalParams, + DatasetsListOptionalParams, + DatasetsListVersionsOptionalParams, +} from "../../api/datasets/options.js"; +import { + getCredentials, + pendingUpload, + createOrUpdate, + $delete, + get, + list, + listVersions, +} from "../../api/datasets/operations.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Datasets operations. */ +export interface DatasetsOperations { + /** Get the SAS credential to access the storage account associated with a Dataset version. */ + getCredentials: ( + name: string, + body: Record, + version: string, + options?: DatasetsGetCredentialsOptionalParams, + ) => Promise; + /** Start a new or get an existing pending upload of a dataset for a specific version. */ + pendingUpload: ( + name: string, + body: PendingUploadRequest, + version: string, + options?: DatasetsPendingUploadOptionalParams, + ) => Promise; + /** Create a new or update an existing DatasetVersion with the given version id */ + createOrUpdate: ( + name: string, + body: DatasetVersionUnion, + version: string, + options?: DatasetsCreateOrUpdateOptionalParams, + ) => Promise; + /** Delete the specific version of the DatasetVersion */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + name: string, + version: string, + options?: DatasetsDeleteOptionalParams, + ) => Promise; + /** Get the specific version of the DatasetVersion */ + get: ( + name: string, + version: string, + options?: DatasetsGetOptionalParams, + ) => Promise; + /** List the latest version of each DatasetVersion */ + list: ( + options?: DatasetsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** List all versions of the given DatasetVersion */ + listVersions: ( + name: string, + options?: DatasetsListVersionsOptionalParams, + ) => PagedAsyncIterableIterator; +} + +function _getDatasets(context: AIProjectContext) { + return { + getCredentials: ( + name: string, + body: Record, + version: string, + options?: DatasetsGetCredentialsOptionalParams, + ) => getCredentials(context, name, body, version, options), + pendingUpload: ( + name: string, + body: PendingUploadRequest, + version: string, + options?: DatasetsPendingUploadOptionalParams, + ) => pendingUpload(context, name, body, version, options), + createOrUpdate: ( + name: string, + body: DatasetVersionUnion, + version: string, + options?: DatasetsCreateOrUpdateOptionalParams, + ) => createOrUpdate(context, name, body, version, options), + delete: ( + name: string, + version: string, + options?: DatasetsDeleteOptionalParams, + ) => $delete(context, name, version, options), + get: (name: string, version: string, options?: DatasetsGetOptionalParams) => + get(context, name, version, options), + list: (options?: DatasetsListOptionalParams) => list(context, options), + listVersions: ( + name: string, + options?: DatasetsListVersionsOptionalParams, + ) => listVersions(context, name, options), + }; +} + +export function _getDatasetsOperations( + context: AIProjectContext, +): DatasetsOperations { + return { + ..._getDatasets(context), + }; +} diff --git a/sdk/ai/ai-projects/src/classic/deployments/index.ts b/sdk/ai/ai-projects/src/classic/deployments/index.ts new file mode 100644 index 000000000000..195c0102c206 --- /dev/null +++ b/sdk/ai/ai-projects/src/classic/deployments/index.ts @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext } from "../../api/aiProjectContext.js"; +import { DeploymentUnion } from "../../models/models.js"; +import { + DeploymentsListOptionalParams, + DeploymentsGetOptionalParams, +} from "../../api/deployments/options.js"; +import { list, get } from "../../api/deployments/operations.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Deployments operations. */ +export interface DeploymentsOperations { + /** List all deployed models in the project */ + list: ( + options?: DeploymentsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a deployed model. */ + get: ( + name: string, + options?: DeploymentsGetOptionalParams, + ) => Promise; +} + +function _getDeployments(context: AIProjectContext) { + return { + list: (options?: DeploymentsListOptionalParams) => list(context, options), + get: (name: string, options?: DeploymentsGetOptionalParams) => + get(context, name, options), + }; +} + +export function _getDeploymentsOperations( + context: AIProjectContext, +): DeploymentsOperations { + return { + ..._getDeployments(context), + }; +} diff --git a/sdk/ai/ai-projects/src/classic/evaluations/index.ts b/sdk/ai/ai-projects/src/classic/evaluations/index.ts new file mode 100644 index 000000000000..30c7d8c1de90 --- /dev/null +++ b/sdk/ai/ai-projects/src/classic/evaluations/index.ts @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext } from "../../api/aiProjectContext.js"; +import { + Evaluation, + AgentEvaluationRequest, + AgentEvaluation, +} from "../../models/models.js"; +import { + EvaluationsCreateAgentEvaluationOptionalParams, + EvaluationsCreateOptionalParams, + EvaluationsListOptionalParams, + EvaluationsGetOptionalParams, +} from "../../api/evaluations/options.js"; +import { + createAgentEvaluation, + create, + list, + get, +} from "../../api/evaluations/operations.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Evaluations operations. */ +export interface EvaluationsOperations { + /** Creates an agent evaluation run. */ + createAgentEvaluation: ( + evaluation: AgentEvaluationRequest, + options?: EvaluationsCreateAgentEvaluationOptionalParams, + ) => Promise; + /** Creates an evaluation run. */ + create: ( + evaluation: Evaluation, + options?: EvaluationsCreateOptionalParams, + ) => Promise; + /** List evaluation runs */ + list: ( + options?: EvaluationsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get an evaluation run by name. */ + get: ( + name: string, + options?: EvaluationsGetOptionalParams, + ) => Promise; +} + +function _getEvaluations(context: AIProjectContext) { + return { + createAgentEvaluation: ( + evaluation: AgentEvaluationRequest, + options?: EvaluationsCreateAgentEvaluationOptionalParams, + ) => createAgentEvaluation(context, evaluation, options), + create: ( + evaluation: Evaluation, + options?: EvaluationsCreateOptionalParams, + ) => create(context, evaluation, options), + list: (options?: EvaluationsListOptionalParams) => list(context, options), + get: (name: string, options?: EvaluationsGetOptionalParams) => + get(context, name, options), + }; +} + +export function _getEvaluationsOperations( + context: AIProjectContext, +): EvaluationsOperations { + return { + ..._getEvaluations(context), + }; +} diff --git a/sdk/ai/ai-projects/src/classic/index.ts b/sdk/ai/ai-projects/src/classic/index.ts new file mode 100644 index 000000000000..8bf1d51be454 --- /dev/null +++ b/sdk/ai/ai-projects/src/classic/index.ts @@ -0,0 +1,9 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { ConnectionsOperations } from "./connections/index.js"; +export { DatasetsOperations } from "./datasets/index.js"; +export { DeploymentsOperations } from "./deployments/index.js"; +export { EvaluationsOperations } from "./evaluations/index.js"; +export { IndexesOperations } from "./indexes/index.js"; +export { RedTeamsOperations } from "./redTeams/index.js"; diff --git a/sdk/ai/ai-projects/src/classic/indexes/index.ts b/sdk/ai/ai-projects/src/classic/indexes/index.ts new file mode 100644 index 000000000000..0d47d3cf3578 --- /dev/null +++ b/sdk/ai/ai-projects/src/classic/indexes/index.ts @@ -0,0 +1,86 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext } from "../../api/aiProjectContext.js"; +import { IndexUnion } from "../../models/models.js"; +import { + IndexesCreateOrUpdateOptionalParams, + IndexesDeleteOptionalParams, + IndexesGetOptionalParams, + IndexesListOptionalParams, + IndexesListVersionsOptionalParams, +} from "../../api/indexes/options.js"; +import { + createOrUpdate, + $delete, + get, + list, + listVersions, +} from "../../api/indexes/operations.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a Indexes operations. */ +export interface IndexesOperations { + /** Create a new or update an existing Index with the given version id */ + createOrUpdate: ( + name: string, + body: IndexUnion, + version: string, + options?: IndexesCreateOrUpdateOptionalParams, + ) => Promise; + /** Delete the specific version of the Index */ + /** + * @fixme delete is a reserved word that cannot be used as an operation name. + * Please add @clientName("clientName") or @clientName("", "javascript") + * to the operation to override the generated name. + */ + delete: ( + name: string, + version: string, + options?: IndexesDeleteOptionalParams, + ) => Promise; + /** Get the specific version of the Index */ + get: ( + name: string, + version: string, + options?: IndexesGetOptionalParams, + ) => Promise; + /** List the latest version of each Index */ + list: ( + options?: IndexesListOptionalParams, + ) => PagedAsyncIterableIterator; + /** List all versions of the given Index */ + listVersions: ( + name: string, + options?: IndexesListVersionsOptionalParams, + ) => PagedAsyncIterableIterator; +} + +function _getIndexes(context: AIProjectContext) { + return { + createOrUpdate: ( + name: string, + body: IndexUnion, + version: string, + options?: IndexesCreateOrUpdateOptionalParams, + ) => createOrUpdate(context, name, body, version, options), + delete: ( + name: string, + version: string, + options?: IndexesDeleteOptionalParams, + ) => $delete(context, name, version, options), + get: (name: string, version: string, options?: IndexesGetOptionalParams) => + get(context, name, version, options), + list: (options?: IndexesListOptionalParams) => list(context, options), + listVersions: (name: string, options?: IndexesListVersionsOptionalParams) => + listVersions(context, name, options), + }; +} + +export function _getIndexesOperations( + context: AIProjectContext, +): IndexesOperations { + return { + ..._getIndexes(context), + }; +} diff --git a/sdk/ai/ai-projects/src/classic/redTeams/index.ts b/sdk/ai/ai-projects/src/classic/redTeams/index.ts new file mode 100644 index 000000000000..fd87d844b39e --- /dev/null +++ b/sdk/ai/ai-projects/src/classic/redTeams/index.ts @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { AIProjectContext } from "../../api/aiProjectContext.js"; +import { RedTeam } from "../../models/models.js"; +import { + RedTeamsCreateOptionalParams, + RedTeamsListOptionalParams, + RedTeamsGetOptionalParams, +} from "../../api/redTeams/options.js"; +import { create, list, get } from "../../api/redTeams/operations.js"; +import { PagedAsyncIterableIterator } from "../../static-helpers/pagingHelpers.js"; + +/** Interface representing a RedTeams operations. */ +export interface RedTeamsOperations { + /** Creates a redteam run. */ + create: ( + redTeam: RedTeam, + options?: RedTeamsCreateOptionalParams, + ) => Promise; + /** List a redteam by name. */ + list: ( + options?: RedTeamsListOptionalParams, + ) => PagedAsyncIterableIterator; + /** Get a redteam by name. */ + get: (name: string, options?: RedTeamsGetOptionalParams) => Promise; +} + +function _getRedTeams(context: AIProjectContext) { + return { + create: (redTeam: RedTeam, options?: RedTeamsCreateOptionalParams) => + create(context, redTeam, options), + list: (options?: RedTeamsListOptionalParams) => list(context, options), + get: (name: string, options?: RedTeamsGetOptionalParams) => + get(context, name, options), + }; +} + +export function _getRedTeamsOperations( + context: AIProjectContext, +): RedTeamsOperations { + return { + ..._getRedTeams(context), + }; +} diff --git a/sdk/ai/ai-projects/src/connections/connections.ts b/sdk/ai/ai-projects/src/connections/connections.ts deleted file mode 100644 index 53ea38da39ca..000000000000 --- a/sdk/ai/ai-projects/src/connections/connections.ts +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import { createRestError, operationOptionsToRequestParameters } from "@azure-rest/core-client"; -import type { GetConnectionResponseOutput } from "./inputOutput.js"; -import type { - GetWorkspaceParameters, - GetConnectionParameters, - GetConnectionWithSecretsParameters, - ListConnectionsParameters, -} from "../customization/parameters.js"; -import type { - GetConnectionOptionalParams, - GetConnectionWithSecretsOptionalParams, - GetWorkspaceOptionalParams, - ListConnectionsOptionalParams, -} from "./customModels.js"; -import type { GetWorkspaceResponseOutput } from "../customization/outputModels.js"; - -const expectedStatuses = ["200"]; - -/** Gets the properties of the specified machine learning workspace. */ -export async function getWorkspace( - context: Client, - options: GetWorkspaceOptionalParams = {}, -): Promise { - const getOptions: GetWorkspaceParameters = { - ...operationOptionsToRequestParameters(options), - }; - const result = await context.path("/").get(getOptions); - if (!expectedStatuses.includes(result.status)) { - throw createRestError(result); - } - return result.body; -} - -/** List the details of all the connections (not including their credentials) */ -export async function listConnections( - context: Client, - options: ListConnectionsOptionalParams = {}, -): Promise> { - const listOptions: ListConnectionsParameters = { - ...operationOptionsToRequestParameters(options), - queryParameters: { - ...(options.includeAll && { includeAll: options.includeAll }), - ...(options.category && { category: options.category }), - ...(options.target && { target: options.target }), - }, - }; - const result = await context.path("/connections").get(listOptions); - if (!expectedStatuses.includes(result.status)) { - throw createRestError(result); - } - return result.body.value; -} - -/** Get the details of a single connection, without credentials. */ -export async function getConnection( - context: Client, - connectionName: string, - options: GetConnectionOptionalParams = {}, -): Promise { - const getOptions: GetConnectionParameters = { - ...operationOptionsToRequestParameters(options), - }; - const result = await context - .path("/connections/{connectionName}", connectionName) - .get(getOptions); - if (!expectedStatuses.includes(result.status)) { - throw createRestError(result); - } - return result.body; -} - -/** Get the details of a single connection, including credentials (if available). */ -export async function getConnectionWithSecrets( - context: Client, - connectionName: string, - options: GetConnectionWithSecretsOptionalParams = {}, -): Promise { - const getOptions: GetConnectionWithSecretsParameters = { - ...operationOptionsToRequestParameters(options), - body: { - ignored: "", - }, - }; - const result = await context - .path("/connections/{connectionName}/listsecrets", connectionName) - .post(getOptions); - if (!expectedStatuses.includes(result.status)) { - throw createRestError(result); - } - return result.body; -} diff --git a/sdk/ai/ai-projects/src/connections/customModels.ts b/sdk/ai/ai-projects/src/connections/customModels.ts deleted file mode 100644 index 0c29ea92d723..000000000000 --- a/sdk/ai/ai-projects/src/connections/customModels.ts +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { OperationOptions } from "@azure-rest/core-client"; -import type { ListConnectionsQueryParamProperties } from "../customization/parameters.js"; -import type { GetConnectionResponseOutput } from "../customization/outputModels.js"; - -/** Get workspace optional parameters. */ -export interface GetWorkspaceOptionalParams extends OperationOptions {} - -/** List connections optional parameters. */ -export interface ListConnectionsOptionalParams - extends ListConnectionsQueryParamProperties, - OperationOptions {} - -/** Get connection optional parameters. */ -export interface GetConnectionOptionalParams extends OperationOptions {} - -/** Get connection with secrets optional parameters. */ -export interface GetConnectionWithSecretsOptionalParams extends OperationOptions {} - -/** - * Connections Interface for managing connections. - */ -export interface ConnectionsOperations { - /** List the details of all the connections (not including their credentials) */ - listConnections: ( - options?: ListConnectionsOptionalParams, - ) => Promise>; - /** Get the details of a single connection, without credentials */ - getConnection: ( - connectionName: string, - options?: GetConnectionOptionalParams, - ) => Promise; - /** Get the details of a single connections, including credentials (if available). */ - getConnectionWithSecrets: ( - connectionName: string, - options?: GetConnectionWithSecretsOptionalParams, - ) => Promise; -} diff --git a/sdk/ai/ai-projects/src/connections/index.ts b/sdk/ai/ai-projects/src/connections/index.ts deleted file mode 100644 index e25191c06250..000000000000 --- a/sdk/ai/ai-projects/src/connections/index.ts +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; - -import { - getConnection, - getConnectionWithSecrets, - getWorkspace, - listConnections, -} from "./connections.js"; -import type { - ConnectionsOperations, - GetConnectionOptionalParams, - GetConnectionWithSecretsOptionalParams, - GetWorkspaceOptionalParams, - ListConnectionsOptionalParams, -} from "./customModels.js"; -import type { ConnectionsInternalOperations } from "./internalModels.js"; - -export * from "./inputOutput.js"; - -function getConnections(context: Client): ConnectionsInternalOperations { - return { - getWorkspace: (options?: GetWorkspaceOptionalParams) => getWorkspace(context, options), - listConnections: (options?: ListConnectionsOptionalParams) => listConnections(context, options), - getConnection: (connectionName: string, options?: GetConnectionOptionalParams) => - getConnection(context, connectionName, options), - getConnectionWithSecrets: ( - connectionName: string, - options?: GetConnectionWithSecretsOptionalParams, - ) => getConnectionWithSecrets(context, connectionName, options), - }; -} - -/** - * Get the connections operations - * @returns The connections operations - **/ -export function getConnectionsOperations(context: Client): ConnectionsOperations { - return { - ...getConnections(context), - }; -} diff --git a/sdk/ai/ai-projects/src/connections/inputOutput.ts b/sdk/ai/ai-projects/src/connections/inputOutput.ts deleted file mode 100644 index 23a4ba36c76d..000000000000 --- a/sdk/ai/ai-projects/src/connections/inputOutput.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -export { ListConnectionsQueryParamProperties } from "../customization/parameters.js"; -export { - GetConnectionResponseOutput, - InternalConnectionPropertiesOutput, - InternalConnectionPropertiesOutputParent, - InternalConnectionPropertiesApiKeyAuthOutput, - InternalConnectionPropertiesAADAuthOutput, - InternalConnectionPropertiesSASAuthOutput, - CredentialsApiKeyAuthOutput, - AuthenticationTypeOutput, - ConnectionTypeOutput, - CredentialsSASAuthOutput, -} from "../customization/outputModels.js"; - -export * from "./customModels.js"; diff --git a/sdk/ai/ai-projects/src/connections/internalModels.ts b/sdk/ai/ai-projects/src/connections/internalModels.ts deleted file mode 100644 index a3764c0fa3e6..000000000000 --- a/sdk/ai/ai-projects/src/connections/internalModels.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { GetWorkspaceResponseOutput } from "../customization/outputModels.js"; -import type { ConnectionsOperations, GetWorkspaceOptionalParams } from "./customModels.js"; - -export interface ConnectionsInternalOperations extends ConnectionsOperations { - /** Gets the properties of the specified machine learning workspace. */ - getWorkspace: (options?: GetWorkspaceOptionalParams) => Promise; -} diff --git a/sdk/ai/ai-projects/src/constants.ts b/sdk/ai/ai-projects/src/constants.ts deleted file mode 100644 index 0db57a4b677f..000000000000 --- a/sdk/ai/ai-projects/src/constants.ts +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** - * Current version of the `@azure/ai-projects` package. - */ -export const SDK_VERSION = `1.0.0-beta.5`; - -/** - * The package name of the `@azure/ai-projects` package. - */ -export const PACKAGE_NAME = "@azure/ai-projects"; diff --git a/sdk/ai/ai-projects/src/customization/convertModelsToWrite.ts b/sdk/ai/ai-projects/src/customization/convertModelsToWrite.ts deleted file mode 100644 index 2fb62fd98ac3..000000000000 --- a/sdk/ai/ai-projects/src/customization/convertModelsToWrite.ts +++ /dev/null @@ -1,567 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type * as PublicModels from "./models.js"; -import type * as GeneratedModels from "../generated/src/models.js"; - -// Conversion functions -export function convertCreateAgentOptions( - source: PublicModels.CreateAgentOptions, -): GeneratedModels.CreateAgentOptions { - return { - model: source.model, - ...(source.name && { name: source.name }), - ...(source.description && { description: source.description }), - ...(source.instructions && { instructions: source.instructions }), - ...(source.tools && { tools: source.tools.map(convertToolDefinition) }), - ...(source.toolResources && { tool_resources: convertToolResources(source.toolResources) }), - ...(source.temperature !== undefined && { temperature: source.temperature }), - ...(source.topP !== undefined && { top_p: source.topP }), - ...(source.responseFormat && { response_format: source.responseFormat }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -function convertToolResources(source: PublicModels.ToolResources): GeneratedModels.ToolResources { - return { - ...(source.codeInterpreter && { - code_interpreter: convertCodeInterpreterToolResource(source.codeInterpreter), - }), - ...(source.fileSearch && { file_search: convertFileSearchToolResource(source.fileSearch) }), - ...(source.azureAISearch && { - azure_ai_search: convertAzureAISearchResource(source.azureAISearch), - }), - ...(source.azureFunction && { - name: source.azureFunction.name, - }), - }; -} - -function convertMessageAttachmentToolDefinition( - source: PublicModels.MessageAttachmentToolDefinition, -): GeneratedModels.MessageAttachmentToolDefinition { - switch (source.type) { - case "code_interpreter": - return convertCodeInterpreterToolDefinition( - source as PublicModels.CodeInterpreterToolDefinition, - ); - case "file_search": - return convertFileSearchToolDefinition(source as PublicModels.FileSearchToolDefinition); - default: - throw new Error(`Unknown tool type: ${source}`); - } -} - -function convertToolDefinition( - source: PublicModels.ToolDefinition, -): GeneratedModels.ToolDefinition { - switch (source.type) { - case "code_interpreter": - return convertCodeInterpreterToolDefinition( - source as PublicModels.CodeInterpreterToolDefinition, - ); - case "file_search": - return convertFileSearchToolDefinition(source as PublicModels.FileSearchToolDefinition); - case "function": - return convertFunctionToolDefinition(source as PublicModels.FunctionToolDefinition); - case "bing_grounding": - return convertBingGroundingToolDefinition(source as PublicModels.BingGroundingToolDefinition); - case "bing_custom_search": - return convertBingCustomSearchToolDefinition( - source as PublicModels.BingCustomSearchToolDefinition, - ); - case "fabric_dataagent": - return convertMicrosoftFabricToolDefinition( - source as PublicModels.MicrosoftFabricToolDefinition, - ); - case "sharepoint_grounding": - return convertSharepointToolDefinition(source as PublicModels.SharepointToolDefinition); - case "azure_ai_search": - return convertAzureAISearchToolDefinition(source as PublicModels.AzureAISearchToolDefinition); - case "openapi": - return convertOpenApiToolDefinition(source as PublicModels.OpenApiToolDefinition); - case "azure_function": - return convertAzureFunctionToolDefinition(source as PublicModels.AzureFunctionToolDefinition); - default: - throw new Error(`Unknown tool type: ${source.type}`); - } -} - -function convertCodeInterpreterToolDefinition( - source: PublicModels.CodeInterpreterToolDefinition, -): GeneratedModels.CodeInterpreterToolDefinition { - return { - type: source.type, - }; -} - -function convertFileSearchToolDefinition( - source: PublicModels.FileSearchToolDefinition, -): GeneratedModels.FileSearchToolDefinition { - return { - type: source.type, - ...(source.fileSearch && { - file_search: convertFileSearchToolDefinitionDetails(source.fileSearch), - }), - }; -} - -function convertFunctionToolDefinition( - source: PublicModels.FunctionToolDefinition, -): GeneratedModels.FunctionToolDefinition { - return { - type: source.type, - function: convertFunctionDefinition(source.function), - }; -} - -function convertBingGroundingToolDefinition( - source: PublicModels.BingGroundingToolDefinition, -): GeneratedModels.BingGroundingToolDefinition { - return { - type: source.type, - bing_grounding: convertToolConnectionList(source.bingGrounding), - }; -} - -function convertBingCustomSearchToolDefinition( - source: PublicModels.BingCustomSearchToolDefinition, -): GeneratedModels.BingCustomSearchToolDefinition { - return { - type: source.type, - bing_custom_search: source?.bingCustomSearch?.searchConfigurations - ? { - search_configurations: source.bingCustomSearch.searchConfigurations.map( - convertToolSearchConfiguration, - ), - } - : { search_configurations: [] }, - }; -} - -function convertMicrosoftFabricToolDefinition( - source: PublicModels.MicrosoftFabricToolDefinition, -): GeneratedModels.MicrosoftFabricToolDefinition { - return { - type: source.type, - fabric_dataagent: convertToolConnectionList(source.fabricDataAgent), - }; -} - -function convertSharepointToolDefinition( - source: PublicModels.SharepointToolDefinition, -): GeneratedModels.SharepointToolDefinition { - return { - type: source.type, - sharepoint_grounding: convertToolConnectionList(source.sharepointGrounding), - }; -} - -function convertAzureAISearchToolDefinition( - source: PublicModels.AzureAISearchToolDefinition, -): GeneratedModels.AzureAISearchToolDefinition { - return { - type: source.type, - }; -} - -function convertOpenApiToolDefinition( - source: PublicModels.OpenApiToolDefinition, -): GeneratedModels.OpenApiToolDefinition { - return { - type: source.type, - openapi: source.openapi, - }; -} - -function convertFileSearchToolDefinitionDetails( - source: PublicModels.FileSearchToolDefinitionDetails, -): GeneratedModels.FileSearchToolDefinitionDetails { - return { - ...(source.maxNumResults && { max_num_results: source.maxNumResults }), - ...(source.rankingOptions && { - ranking_options: convertFileSearchRankingOptions(source.rankingOptions), - }), - }; -} - -function convertFileSearchRankingOptions( - source: PublicModels.FileSearchRankingOptions, -): GeneratedModels.FileSearchRankingOptions { - return { - ranker: source.ranker, - score_threshold: source.scoreThreshold, - }; -} - -function convertCodeInterpreterToolResource( - source: PublicModels.CodeInterpreterToolResource, -): GeneratedModels.CodeInterpreterToolResource { - return { - file_ids: source.fileIds, - ...(source.dataSources && { - data_sources: source.dataSources.map(convertVectorStoreDataSource), - }), - }; -} - -export function convertVectorStoreDataSource( - source: PublicModels.VectorStoreDataSource, -): GeneratedModels.VectorStoreDataSource { - return { - uri: source.uri, - type: source.type, - }; -} - -function convertFileSearchToolResource( - source: PublicModels.FileSearchToolResource, -): GeneratedModels.FileSearchToolResource { - return { - ...(source.vectorStoreIds && { vector_store_ids: source.vectorStoreIds }), - ...(source.vectorStores && { - vector_stores: source.vectorStores.map(convertVectorStoreConfigurations), - }), - }; -} - -function convertAzureFunctionToolDefinition( - source: PublicModels.AzureFunctionToolDefinition, -): GeneratedModels.AzureFunctionToolDefinition { - return { - type: source.type, - azure_function: convertAzureFunctionDefinition(source.azureFunction), - }; -} - -function convertAzureFunctionDefinition( - source: PublicModels.AzureFunctionDefinition, -): GeneratedModels.AzureFunctionDefinition { - return { - function: source.function, - input_binding: { - type: source.inputBinding.type, - storage_queue: { - queue_service_endpoint: source.inputBinding.storageQueue.queueServiceEndpoint, - queue_name: source.inputBinding.storageQueue.queueName, - }, - }, - output_binding: { - type: source.outputBinding.type, - storage_queue: { - queue_service_endpoint: source.outputBinding.storageQueue.queueServiceEndpoint, - queue_name: source.outputBinding.storageQueue.queueName, - }, - }, - }; -} - -function convertVectorStoreConfigurations( - source: PublicModels.VectorStoreConfigurations, -): GeneratedModels.VectorStoreConfigurations { - return { - name: source.name, - configuration: convertVectorStoreConfiguration(source.configuration), - }; -} - -function convertVectorStoreConfiguration( - source: PublicModels.VectorStoreConfiguration, -): GeneratedModels.VectorStoreConfiguration { - return { - data_sources: source.dataSources.map(convertVectorStoreDataSource), - }; -} - -function convertAzureAISearchResource( - source: PublicModels.AzureAISearchResource, -): GeneratedModels.AzureAISearchResource { - return { - ...(source.indexes && { indexes: source.indexes.map(convertIndexResource) }), - }; -} - -function convertIndexResource( - source: PublicModels.IndexResource, -): GeneratedModels.AISearchIndexResource { - return { - index_connection_id: source.indexConnectionId, - index_name: source.indexName, - query_type: source.queryType, - top_k: source.topK, - filter: source.filter, - }; -} - -export function convertUpdateAgentOptions( - source: PublicModels.UpdateAgentOptions, -): GeneratedModels.UpdateAgentOptions { - return { - ...(source.model && { model: source.model }), - ...(source.name && { name: source.name }), - ...(source.description && { description: source.description }), - ...(source.instructions && { instructions: source.instructions }), - ...(source.tools && { tools: source.tools.map(convertToolDefinition) }), - ...(source.toolResources && { tool_resources: convertToolResources(source.toolResources) }), - ...(source.temperature !== undefined && { temperature: source.temperature }), - ...(source.topP !== undefined && { top_p: source.topP }), - ...(source.responseFormat && { response_format: source.responseFormat }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -export function convertAgentThreadCreationOptions( - source: PublicModels.AgentThreadCreationOptions, -): GeneratedModels.AgentThreadCreationOptions { - return { - ...(source.messages && { messages: source.messages.map(convertThreadMessageOptions) }), - ...(source.toolResources && { tool_resources: convertToolResources(source.toolResources) }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -export function convertAgentThreadUpdateOptions( - source: PublicModels.UpdateAgentThreadOptions, -): GeneratedModels.UpdateAgentThreadOptions { - return { - ...(source.toolResources && { tool_resources: convertToolResources(source.toolResources) }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -function convertThreadMessageOptions( - source: PublicModels.ThreadMessageOptions, -): GeneratedModels.ThreadMessageOptions { - return { - role: source.role, - content: source.content, - ...(source.attachments && { attachments: source.attachments.map(convertMessageAttachment) }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -function convertMessageAttachment( - source: PublicModels.MessageAttachment, -): GeneratedModels.MessageAttachment { - return { - file_id: source.fileId, - ...(source.dataSource && { - data_source: convertVectorStoreDataSource(source.dataSource), - }), - ...(source.tools && { tools: source.tools.map(convertMessageAttachmentToolDefinition) }), - }; -} - -export function convertCreateRunOptions( - source: PublicModels.CreateRunOptions, -): GeneratedModels.CreateRunOptions { - return { - assistant_id: source.assistantId, - ...(source.model && { model: source.model }), - ...(source.instructions && { instructions: source.instructions }), - ...(source.additionalInstructions && { - additional_instructions: source.additionalInstructions, - }), - ...(source.additionalMessages && { - additional_messages: source.additionalMessages.map(convertThreadMessageOptions), - }), - ...(source.tools && { tools: source.tools.map(convertToolDefinition) }), - ...(source.stream !== undefined && { stream: source.stream }), - ...(source.temperature !== undefined && { temperature: source.temperature }), - ...(source.topP !== undefined && { top_p: source.topP }), - ...(source.maxPromptTokens !== undefined && { max_prompt_tokens: source.maxPromptTokens }), - ...(source.maxCompletionTokens !== undefined && { - max_completion_tokens: source.maxCompletionTokens, - }), - ...(source.truncationStrategy && { - truncation_strategy: convertTruncationObject(source.truncationStrategy), - }), - ...(source.toolChoice && { tool_choice: source.toolChoice }), - ...(source.responseFormat && { response_format: source.responseFormat }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -function convertTruncationObject( - source: PublicModels.TruncationObject, -): GeneratedModels.TruncationObject { - return { - type: source.type, - ...(source.lastMessages !== undefined && { last_messages: source.lastMessages }), - }; -} - -function convertUpdateToolResourcesOptions( - source: PublicModels.UpdateToolResourcesOptions, -): GeneratedModels.UpdateToolResourcesOptions { - return { - ...(source.codeInterpreter && { - code_interpreter: convertUpdateCodeInterpreterToolResourceOptions(source.codeInterpreter), - }), - ...(source.fileSearch && { - file_search: convertUpdateFileSearchToolResourceOptions(source.fileSearch), - }), - ...(source.azureAISearch && { - azure_ai_search: convertAzureAISearchResource(source.azureAISearch), - }), - }; -} - -function convertUpdateCodeInterpreterToolResourceOptions( - source: PublicModels.UpdateCodeInterpreterToolResourceOptions, -): GeneratedModels.UpdateCodeInterpreterToolResourceOptions { - return { - ...(source.fileIds && { file_ids: source.fileIds }), - }; -} - -function convertUpdateFileSearchToolResourceOptions( - source: PublicModels.UpdateFileSearchToolResourceOptions, -): GeneratedModels.UpdateFileSearchToolResourceOptions { - return { - ...(source.vectorStoreIds && { vector_store_ids: source.vectorStoreIds }), - }; -} - -export function convertToolOutput(source: PublicModels.ToolOutput): GeneratedModels.ToolOutput { - return { - ...(source.toolCallId !== undefined && { tool_call_id: source.toolCallId }), - ...(source.output !== undefined && { output: source.output }), - }; -} - -export function convertCreateAndRunThreadOptions( - source: PublicModels.CreateAndRunThreadOptions, -): GeneratedModels.CreateAndRunThreadOptions { - return { - assistant_id: source.assistantId, - ...(source.thread && { thread: convertAgentThreadCreationOptions(source.thread) }), - ...(source.model && { model: source.model }), - ...(source.instructions && { instructions: source.instructions }), - ...(source.tools && { tools: source.tools.map(convertToolDefinition) }), - ...(source.toolResources && { - tool_resources: convertUpdateToolResourcesOptions(source.toolResources), - }), - ...(source.stream !== undefined && { stream: source.stream }), - ...(source.temperature !== undefined && { temperature: source.temperature }), - ...(source.topP !== undefined && { top_p: source.topP }), - ...(source.maxPromptTokens !== undefined && { max_prompt_tokens: source.maxPromptTokens }), - ...(source.maxCompletionTokens !== undefined && { - max_completion_tokens: source.maxCompletionTokens, - }), - ...(source.truncationStrategy && { - truncation_strategy: convertTruncationObject(source.truncationStrategy), - }), - ...(source.toolChoice && { tool_choice: source.toolChoice }), - ...(source.responseFormat && { response_format: source.responseFormat }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -function convertVectorStoreExpirationPolicy( - source: PublicModels.VectorStoreExpirationPolicy, -): GeneratedModels.VectorStoreExpirationPolicy { - return { - anchor: source.anchor, - days: source.days, - }; -} - -export function convertVectorStoreOptions( - source: PublicModels.VectorStoreOptions, -): GeneratedModels.VectorStoreOptions { - return { - ...(source.fileIds && { file_ids: source.fileIds }), - ...(source.name && { name: source.name }), - ...(source.configuration && { - configuration: convertVectorStoreConfiguration(source.configuration), - }), - ...(source.expiresAfter && { - expires_after: convertVectorStoreExpirationPolicy(source.expiresAfter), - }), - ...(source.chunkingStrategy && { - chunking_strategy: convertVectorStoreChunkingStrategyRequest(source.chunkingStrategy), - }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -export function convertVectorStoreChunkingStrategyRequest( - source: PublicModels.VectorStoreChunkingStrategyRequest, -): GeneratedModels.VectorStoreChunkingStrategyRequest { - switch (source.type) { - case "auto": - return source as GeneratedModels.VectorStoreAutoChunkingStrategyRequest; - case "static": - return convertVectorStoreStaticChunkingStrategyRequest( - source as PublicModels.VectorStoreStaticChunkingStrategyRequest, - ); - default: - throw new Error(`Unknown chunking strategy type: ${source.type}`); - } -} - -function convertVectorStoreStaticChunkingStrategyRequest( - source: PublicModels.VectorStoreStaticChunkingStrategyRequest, -): GeneratedModels.VectorStoreStaticChunkingStrategyRequest { - return { - ...source, - static: convertVectorStoreStaticChunkingStrategyOptions(source.static), - }; -} - -function convertVectorStoreStaticChunkingStrategyOptions( - source: PublicModels.VectorStoreStaticChunkingStrategyOptions, -): GeneratedModels.VectorStoreStaticChunkingStrategyOptions { - return { - max_chunk_size_tokens: source.maxChunkSizeTokens, - chunk_overlap_tokens: source.chunkOverlapTokens, - }; -} - -export function convertVectorStoreUpdateOptions( - source: PublicModels.VectorStoreUpdateOptions, -): GeneratedModels.VectorStoreUpdateOptions { - return { - ...(source.name && { name: source.name }), - ...(source.expiresAfter && { - expires_after: convertVectorStoreExpirationPolicy(source.expiresAfter), - }), - ...(source.metadata && { metadata: source.metadata }), - }; -} - -function convertFunctionDefinition( - source: PublicModels.FunctionDefinition, -): GeneratedModels.FunctionDefinition { - return { - name: source.name, - ...(source.description && { description: source.description }), - parameters: source.parameters, - }; -} - -function convertToolConnectionList( - source: PublicModels.ToolConnectionList, -): GeneratedModels.ToolConnectionList { - return { - ...(source.connections && { connections: source.connections.map(convertToolConnection) }), - }; -} - -function convertToolConnection( - source: PublicModels.ToolConnection, -): GeneratedModels.ToolConnection { - return { - connection_id: source.connectionId, - }; -} - -function convertToolSearchConfiguration( - source: PublicModels.SearchConfiguration, -): GeneratedModels.SearchConfiguration { - return { - connection_id: source.connectionId, - instance_name: source.instanceName, - }; -} diff --git a/sdk/ai/ai-projects/src/customization/convertOutputModelsFromWire.ts b/sdk/ai/ai-projects/src/customization/convertOutputModelsFromWire.ts deleted file mode 100644 index c5696cfca7d6..000000000000 --- a/sdk/ai/ai-projects/src/customization/convertOutputModelsFromWire.ts +++ /dev/null @@ -1,1460 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type * as GeneratedModels from "../generated/src/outputModels.js"; -import type * as PublicModels from "./outputModels.js"; -import type * as WireStreamingModels from "./streamingWireModels.js"; -import type * as PublicStreamingModels from "./streamingModels.js"; -import { logger } from "../logger.js"; - -// Conversion functions - -function convertAzureFunctionToolDefinitionOutput( - input: GeneratedModels.AzureFunctionToolDefinitionOutput, -): PublicModels.AzureFunctionToolDefinitionOutput { - return { - type: "azure_function", - azureFunction: { - ...input.azure_function, - inputBinding: { - ...input.azure_function.input_binding, - storageQueue: { - queueServiceEndpoint: - input.azure_function.input_binding.storage_queue.queue_service_endpoint, - queueName: input.azure_function.input_binding.storage_queue.queue_name, - }, - }, - outputBinding: { - ...input.azure_function.output_binding, - storageQueue: { - queueServiceEndpoint: - input.azure_function.output_binding.storage_queue.queue_service_endpoint, - queueName: input.azure_function.output_binding.storage_queue.queue_name, - }, - }, - }, - }; -} - -function convertCodeInterpreterToolDefinitionOutput( - input: GeneratedModels.CodeInterpreterToolDefinitionOutput, -): PublicModels.CodeInterpreterToolDefinitionOutput { - return { ...input }; -} - -function convertFileSearchToolDefinitionOutput( - input: GeneratedModels.FileSearchToolDefinitionOutput, -): PublicModels.FileSearchToolDefinitionOutput { - return { - type: "file_search", - fileSearch: input.file_search - ? convertFileSearchToolDefinitionDetailsOutput(input.file_search) - : undefined, - }; -} - -function convertFileSearchToolDefinitionDetailsOutput( - input: GeneratedModels.FileSearchToolDefinitionDetailsOutput, -): PublicModels.FileSearchToolDefinitionDetailsOutput { - return { - maxNumResults: input.max_num_results, - rankingOptions: input.ranking_options - ? convertFileSearchRankingOptionsOutput(input.ranking_options) - : undefined, - }; -} - -function convertFileSearchRankingOptionsOutput( - input: GeneratedModels.FileSearchRankingOptionsOutput, -): PublicModels.FileSearchRankingOptionsOutput { - return { - ranker: input.ranker, - scoreThreshold: input.score_threshold, - }; -} - -function convertFunctionToolDefinitionOutput( - input: GeneratedModels.FunctionToolDefinitionOutput, -): PublicModels.FunctionToolDefinitionOutput { - return { - type: "function", - function: input.function && convertFunctionDefinitionOutput(input.function), - }; -} - -function convertFunctionDefinitionOutput( - input: GeneratedModels.FunctionDefinitionOutput, -): PublicModels.FunctionDefinitionOutput { - return { ...input }; -} - -function convertBingGroundingToolDefinitionOutput( - input: GeneratedModels.BingGroundingToolDefinitionOutput, -): PublicModels.BingGroundingToolDefinitionOutput { - return { - type: "bing_grounding", - bingGrounding: input.bing_grounding && convertToolConnectionListOutput(input.bing_grounding), - }; -} - -function convertBingCustomSearchToolDefinitionOutput( - input: GeneratedModels.BingCustomSearchToolDefinitionOutput, -): PublicModels.BingCustomSearchToolDefinitionOutput { - return { - type: "bing_custom_search", - bingCustomSearch: input.bing_custom_search - ? convertToolSearchConfigurationListOutput(input.bing_custom_search) - : undefined, - }; -} - -function convertToolSearchConfigurationListOutput( - input: GeneratedModels.SearchConfigurationListOutput, -): PublicModels.SearchConfigurationListOutput { - return { - searchConfigurations: input.search_configurations?.map((item) => ({ - connectionId: item.connection_id, - instanceName: item.instance_name, - })), - }; -} - -function convertToolConnectionListOutput( - input: GeneratedModels.ToolConnectionListOutput, -): PublicModels.ToolConnectionListOutput { - return { - connections: input.connections?.map(convertToolConnectionOutput), - }; -} - -function convertToolConnectionOutput( - input: GeneratedModels.ToolConnectionOutput, -): PublicModels.ToolConnectionOutput { - return { connectionId: input.connection_id }; -} - -function convertMicrosoftFabricToolDefinitionOutput( - input: GeneratedModels.MicrosoftFabricToolDefinitionOutput, -): PublicModels.MicrosoftFabricToolDefinitionOutput { - return { - type: "fabric_dataagent", - fabricDataAgent: - input.fabric_dataagent && convertToolConnectionListOutput(input.fabric_dataagent), - }; -} - -function convertSharepointToolDefinitionOutput( - input: GeneratedModels.SharepointToolDefinitionOutput, -): PublicModels.SharepointToolDefinitionOutput { - return { - type: "sharepoint_grounding", - sharepointGrounding: - input.sharepoint_grounding && convertToolConnectionListOutput(input.sharepoint_grounding), - }; -} - -function convertAzureAISearchToolDefinitionOutput( - input: GeneratedModels.AzureAISearchToolDefinitionOutput, -): PublicModels.AzureAISearchToolDefinitionOutput { - return { ...input }; -} - -function convertToolResourcesOutput( - input: GeneratedModels.ToolResourcesOutput, -): PublicModels.ToolResourcesOutput { - return { - codeInterpreter: input.code_interpreter - ? convertCodeInterpreterToolResourceOutput(input.code_interpreter) - : undefined, - fileSearch: input.file_search - ? convertFileSearchToolResourceOutput(input.file_search) - : undefined, - azureAISearch: input.azure_ai_search - ? convertAzureAISearchResourceOutput(input.azure_ai_search) - : undefined, - }; -} - -function convertCodeInterpreterToolResourceOutput( - input: GeneratedModels.CodeInterpreterToolResourceOutput, -): PublicModels.CodeInterpreterToolResourceOutput { - return { - fileIds: input.file_ids, - dataSources: input.data_sources?.map(convertVectorStoreDataSourceOutput), - }; -} - -function convertVectorStoreDataSourceOutput( - input: GeneratedModels.VectorStoreDataSourceOutput, -): PublicModels.VectorStoreDataSourceOutput { - return { ...input }; -} - -function convertFileSearchToolResourceOutput( - input: GeneratedModels.FileSearchToolResourceOutput, -): PublicModels.FileSearchToolResourceOutput { - return { - vectorStoreIds: input.vector_store_ids, - vectorStores: input.vector_stores?.map(convertVectorStoreConfigurationsOutput), - }; -} - -function convertVectorStoreConfigurationsOutput( - input: GeneratedModels.VectorStoreConfigurationsOutput, -): PublicModels.VectorStoreConfigurationsOutput { - return { - name: input.name, - configuration: - input.configuration && convertVectorStoreConfigurationOutput(input.configuration), - }; -} - -function convertVectorStoreConfigurationOutput( - input: GeneratedModels.VectorStoreConfigurationOutput, -): PublicModels.VectorStoreConfigurationOutput { - return { - ...input, - dataSources: input.data_sources?.map(convertVectorStoreDataSourceOutput), - }; -} - -function convertAzureAISearchResourceOutput( - input: GeneratedModels.AzureAISearchResourceOutput, -): PublicModels.AzureAISearchResourceOutput { - return { - indexes: input.indexes?.map(convertIndexResourceOutput), - }; -} - -function convertIndexResourceOutput( - input: GeneratedModels.AISearchIndexResourceOutput, -): PublicModels.IndexResourceOutput { - return { indexConnectionId: input.index_connection_id, indexName: input.index_name }; -} - -export function convertAgentOutput(input: GeneratedModels.AgentOutput): PublicModels.AgentOutput { - return { - id: input.id, - object: input.object, - createdAt: new Date(input.created_at), - name: input.name, - description: input.description, - model: input.model, - instructions: input.instructions, - tools: input.tools?.map(convertToolDefinitionOutput), - toolResources: input.tool_resources ? convertToolResourcesOutput(input.tool_resources) : null, - temperature: input.temperature, - topP: input.top_p, - responseFormat: input.response_format - ? convertAgentsApiResponseFormatOptionOutput(input.response_format) - : null, - metadata: input.metadata, - }; -} -function convertToolDefinitionOutput( - tool: GeneratedModels.ToolDefinitionOutput, -): PublicModels.ToolDefinitionOutput { - switch (tool.type) { - case "code_interpreter": - return convertCodeInterpreterToolDefinitionOutput( - tool as GeneratedModels.CodeInterpreterToolDefinitionOutput, - ); - case "file_search": - return convertFileSearchToolDefinitionOutput( - tool as GeneratedModels.FileSearchToolDefinitionOutput, - ); - case "function": - return convertFunctionToolDefinitionOutput( - tool as GeneratedModels.FunctionToolDefinitionOutput, - ); - case "bing_grounding": - return convertBingGroundingToolDefinitionOutput( - tool as GeneratedModels.BingGroundingToolDefinitionOutput, - ); - case "bing_custom_search": - return convertBingCustomSearchToolDefinitionOutput( - tool as GeneratedModels.BingCustomSearchToolDefinitionOutput, - ); - case "fabric_dataagent": - return convertMicrosoftFabricToolDefinitionOutput( - tool as GeneratedModels.MicrosoftFabricToolDefinitionOutput, - ); - case "sharepoint_grounding": - return convertSharepointToolDefinitionOutput( - tool as GeneratedModels.SharepointToolDefinitionOutput, - ); - case "azure_ai_search": - return convertAzureAISearchToolDefinitionOutput( - tool as GeneratedModels.AzureAISearchToolDefinitionOutput, - ); - case "azure_function": - return convertAzureFunctionToolDefinitionOutput( - tool as GeneratedModels.AzureFunctionToolDefinitionOutput, - ); - default: - return tool; - } -} - -function convertAgentsApiResponseFormatOptionOutput( - input: GeneratedModels.AgentsApiResponseFormatOptionOutput, -): PublicModels.AgentsApiResponseFormatOptionOutput { - const formatOutput = input as GeneratedModels.AgentsApiResponseFormatOutput; - if (formatOutput && formatOutput.type) { - switch (formatOutput.type) { - case "json_schema": - return { - type: formatOutput.type, - jsonSchema: (formatOutput as GeneratedModels.ResponseFormatJsonSchemaTypeOutput) - .json_schema, - }; - default: - return input as PublicModels.AgentsApiResponseFormatOptionOutput; - } - } - return input as PublicModels.AgentsApiResponseFormatOptionOutput; -} - -export function convertOpenAIPageableListOfAgentOutput( - input: GeneratedModels.OpenAIPageableListOfAgentOutput, -): PublicModels.OpenAIPageableListOfAgentOutput { - return { - object: input.object, - firstId: input.first_id, - lastId: input.last_id, - hasMore: input.has_more, - data: input.data.map(convertAgentOutput), - }; -} - -export function convertAgentDeletionStatusOutput( - input: GeneratedModels.AgentDeletionStatusOutput, -): PublicModels.AgentDeletionStatusOutput { - return { ...input }; -} - -function convertMessageAttachmentOutput( - input: GeneratedModels.MessageAttachmentOutput, -): PublicModels.MessageAttachmentOutput { - return { - fileId: input.file_id, - dataSource: input.data_source && convertVectorStoreDataSourceOutput(input.data_source), - tools: input.tools?.map(convertMessageAttachmentToolDefinitionOutput), - }; -} - -function convertMessageAttachmentToolDefinitionOutput( - input: GeneratedModels.MessageAttachmentToolDefinitionOutput, -): PublicModels.MessageAttachmentToolDefinitionOutput { - switch (input.type) { - case "code_interpreter": - return convertCodeInterpreterToolDefinitionOutput( - input as GeneratedModels.CodeInterpreterToolDefinitionOutput, - ); - case "file_search": - return convertFileSearchToolDefinitionOutput( - input as GeneratedModels.FileSearchToolDefinitionOutput, - ); - default: - throw new Error(`Unknown tool type: ${input}`); - } -} - -export function convertAgentThreadOutput( - input: GeneratedModels.AgentThreadOutput, -): PublicModels.AgentThreadOutput { - return { - id: input.id, - object: input.object, - createdAt: new Date(input.created_at), - toolResources: input.tool_resources ? convertToolResourcesOutput(input.tool_resources) : null, - metadata: input.metadata, - }; -} - -export function convertThreadDeletionStatusOutput( - input: GeneratedModels.ThreadDeletionStatusOutput, -): PublicModels.ThreadDeletionStatusOutput { - return { ...input }; -} - -export function convertThreadMessageOutput( - input: GeneratedModels.ThreadMessageOutput, -): PublicModels.ThreadMessageOutput { - return { - id: input.id, - object: input.object, - createdAt: new Date(input.created_at), - threadId: input.thread_id, - status: input.status, - incompleteDetails: input.incomplete_details - ? convertMessageIncompleteDetailsOutput(input.incomplete_details) - : null, - completedAt: input.completed_at ? new Date(input.completed_at) : null, - incompleteAt: input.incomplete_at ? new Date(input.incomplete_at) : null, - role: input.role, - content: input.content?.map(convertMessageContentOutput), - assistantId: input.assistant_id, - runId: input.run_id, - attachments: !input.attachments - ? input.attachments - : input.attachments?.map(convertMessageAttachmentOutput), - metadata: input.metadata, - }; -} - -function convertMessageIncompleteDetailsOutput( - input: GeneratedModels.MessageIncompleteDetailsOutput, -): PublicModels.MessageIncompleteDetailsOutput { - return { ...input }; -} - -function convertMessageContentOutput( - input: GeneratedModels.MessageContentOutput, -): PublicModels.MessageContentOutput { - switch (input.type) { - case "text": - return convertMessageTextContentOutput(input as GeneratedModels.MessageTextContentOutput); - case "image_file": - return convertMessageImageFileContentOutput( - input as GeneratedModels.MessageImageFileContentOutput, - ); - default: - return { ...input }; - } -} - -function convertMessageTextContentOutput( - input: GeneratedModels.MessageTextContentOutput, -): PublicModels.MessageTextContentOutput { - return { - type: input.type, - text: input.text && convertMessageTextDetailsOutput(input.text), - }; -} - -function convertMessageTextDetailsOutput( - input: GeneratedModels.MessageTextDetailsOutput, -): PublicModels.MessageTextDetailsOutput { - return { - value: input.value, - annotations: input.annotations?.map(convertMessageTextAnnotationOutput), - }; -} - -function convertMessageTextAnnotationOutput( - input: GeneratedModels.MessageTextAnnotationOutputParent, -): PublicModels.MessageTextAnnotationOutput { - switch (input.type) { - case "file_citation": - return convertMessageTextFileCitationAnnotationOutput( - input as GeneratedModels.MessageTextFileCitationAnnotationOutput, - ); - case "file_path": - return convertMessageTextFilePathAnnotationOutput( - input as GeneratedModels.MessageTextFilePathAnnotationOutput, - ); - default: - return { ...input }; - } -} - -function convertMessageTextFileCitationAnnotationOutput( - input: GeneratedModels.MessageTextFileCitationAnnotationOutput, -): PublicModels.MessageTextFileCitationAnnotationOutput { - return { - type: input.type, - text: input.text, - fileCitation: - input.file_citation && convertMessageTextFileCitationDetailsOutput(input.file_citation), - }; -} - -function convertMessageTextFileCitationDetailsOutput( - input: GeneratedModels.MessageTextFileCitationDetailsOutput, -): PublicModels.MessageTextFileCitationDetailsOutput { - return { - fileId: input.file_id, - quote: input.quote, - }; -} - -function convertMessageTextFilePathAnnotationOutput( - input: GeneratedModels.MessageTextFilePathAnnotationOutput, -): PublicModels.MessageTextFilePathAnnotationOutput { - return { - type: input.type, - filePath: input.file_path && convertMessageTextFilePathDetailsOutput(input.file_path), - startIndex: input.start_index, - endIndex: input.end_index, - text: input.text, - }; -} - -function convertMessageTextFilePathDetailsOutput( - input: GeneratedModels.MessageTextFilePathDetailsOutput, -): PublicModels.MessageTextFilePathDetailsOutput { - return { fileId: input.file_id }; -} - -function convertMessageImageFileContentOutput( - input: GeneratedModels.MessageImageFileContentOutput, -): PublicModels.MessageImageFileContentOutput { - return { - type: input.type, - imageFile: input.image_file && convertMessageImageFileDetailsOutput(input.image_file), - }; -} - -function convertMessageImageFileDetailsOutput( - input: GeneratedModels.MessageImageFileDetailsOutput, -): PublicModels.MessageImageFileDetailsOutput { - return { fileId: input.file_id }; -} - -export function convertThreadRunOutput( - input: GeneratedModels.ThreadRunOutput, -): PublicModels.ThreadRunOutput { - return { - id: input.id, - object: input.object, - threadId: input.thread_id, - assistantId: input.assistant_id, - status: input.status, - ...(input.required_action && { - requiredAction: convertRequiredActionOutput(input.required_action), - }), - lastError: input.last_error, - model: input.model, - instructions: input.instructions, - tools: input.tools?.map(convertToolDefinitionOutput) ?? [], - createdAt: new Date(input.created_at), - expiresAt: input.expires_at ? new Date(input.expires_at) : null, - startedAt: input.started_at ? new Date(input.started_at) : null, - completedAt: input.completed_at ? new Date(input.completed_at) : null, - cancelledAt: input.cancelled_at ? new Date(input.cancelled_at) : null, - failedAt: input.failed_at ? new Date(input.failed_at) : null, - incompleteDetails: input.incomplete_details, - usage: input.usage ? convertRunStepCompletionUsageOutput(input.usage) : null, - ...(input.temperature && { temperature: input.temperature }), - ...(input.top_p && { topP: input.top_p }), - maxPromptTokens: input.max_prompt_tokens, - maxCompletionTokens: input.max_completion_tokens, - truncationStrategy: input.truncation_strategy - ? convertTruncationObjectOutput(input.truncation_strategy) - : null, - toolChoice: input.tool_choice, - responseFormat: input.response_format, - metadata: input.metadata, - ...(input.tool_resources && { - toolResources: convertToolResourcesOutput(input.tool_resources), - }), - parallelToolCalls: input.parallel_tool_calls, - }; -} - -function convertRunCompletionUsageOutput( - input: GeneratedModels.RunCompletionUsageOutput, -): PublicModels.RunCompletionUsageOutput { - return { - completionTokens: input.completion_tokens, - promptTokens: input.prompt_tokens, - totalTokens: input.total_tokens, - }; -} - -function convertRequiredActionOutput( - input: GeneratedModels.RequiredActionOutput, -): PublicModels.RequiredActionOutput { - switch (input.type) { - case "submit_tool_outputs": - return convertSubmitToolOutputsActionOutput( - input as GeneratedModels.SubmitToolOutputsActionOutput, - ); - default: - return { ...input }; - } -} - -function convertSubmitToolOutputsActionOutput( - input: GeneratedModels.SubmitToolOutputsActionOutput, -): PublicModels.SubmitToolOutputsActionOutput { - return { - type: input.type, - submitToolOutputs: - input.submit_tool_outputs && convertSubmitToolOutputsDetailsOutput(input.submit_tool_outputs), - }; -} - -function convertSubmitToolOutputsDetailsOutput( - input: GeneratedModels.SubmitToolOutputsDetailsOutput, -): PublicModels.SubmitToolOutputsDetailsOutput { - return { - toolCalls: input.tool_calls?.map(convertRequiredToolCallOutput), - }; -} - -function convertRequiredToolCallOutput( - input: GeneratedModels.RequiredToolCallOutput, -): PublicModels.RequiredToolCallOutput { - switch (input.type) { - case "function": - return convertRequiredFunctionToolCallOutput( - input as GeneratedModels.RequiredFunctionToolCallOutput, - ); - default: - return { ...input }; - } -} - -function convertRequiredFunctionToolCallOutput( - input: GeneratedModels.RequiredFunctionToolCallOutput, -): PublicModels.RequiredFunctionToolCallOutput { - return { - id: input.id, - type: input.type, - function: input.function && convertRequiredFunctionToolCallDetailsOutput(input.function), - }; -} - -function convertRequiredFunctionToolCallDetailsOutput( - input: GeneratedModels.RequiredFunctionToolCallDetailsOutput, -): PublicModels.RequiredFunctionToolCallDetailsOutput { - return { - name: input.name, - arguments: input.arguments, - }; -} - -function convertTruncationObjectOutput( - input: GeneratedModels.TruncationObjectOutput, -): PublicModels.TruncationObjectOutput { - return { - type: input.type, - lastMessages: input.last_messages, - }; -} - -export function convertOpenAIPageableListOfThreadRunOutput( - input: GeneratedModels.OpenAIPageableListOfThreadRunOutput, -): PublicModels.OpenAIPageableListOfThreadRunOutput { - return { - object: input.object, - firstId: input.first_id, - lastId: input.last_id, - hasMore: input.has_more, - data: input.data?.map(convertThreadRunOutput), - }; -} -export function convertRunStepOutput( - input: GeneratedModels.RunStepOutput, -): PublicModels.RunStepOutput { - return { - id: input.id, - object: input.object, - type: input.type, - assistantId: input.assistant_id, - threadId: input.thread_id, - runId: input.run_id, - status: input.status, - stepDetails: input.step_details && convertRunStepDetailsOutput(input.step_details), - lastError: input.last_error ? convertRunStepErrorOutput(input.last_error) : null, - createdAt: new Date(input.created_at), - expiredAt: input.expired_at ? new Date(input.expired_at) : null, - completedAt: input.completed_at ? new Date(input.completed_at) : null, - failedAt: input.failed_at ? new Date(input.failed_at) : null, - cancelledAt: input.cancelled_at ? new Date(input.cancelled_at) : null, - ...(input.usage && { usage: convertRunCompletionUsageOutput(input.usage) }), - metadata: input.metadata, - }; -} - -function convertRunStepDetailsOutput( - input: GeneratedModels.RunStepDetailsOutput, -): PublicModels.RunStepDetailsOutput { - switch (input.type) { - case "message_creation": - return convertRunStepMessageCreationDetailsOutput( - input as GeneratedModels.RunStepMessageCreationDetailsOutput, - ); - case "tool_calls": - return convertRunStepToolCallDetailsOutput( - input as GeneratedModels.RunStepToolCallDetailsOutput, - ); - default: { - throw new Error(`Unknown run step type: ${input.type}`); - } - } -} - -function convertRunStepMessageCreationDetailsOutput( - input: GeneratedModels.RunStepMessageCreationDetailsOutput, -): PublicModels.RunStepMessageCreationDetailsOutput { - return { - type: input.type, - messageCreation: convertRunStepMessageCreationReferenceOutput(input.message_creation), - }; -} - -function convertRunStepMessageCreationReferenceOutput( - input: GeneratedModels.RunStepMessageCreationReferenceOutput, -): PublicModels.RunStepMessageCreationReferenceOutput { - return { - messageId: input.message_id, - }; -} - -function convertRunStepToolCallDetailsOutput( - input: GeneratedModels.RunStepToolCallDetailsOutput, -): PublicModels.RunStepToolCallDetailsOutput { - return { - type: input.type, - toolCalls: input.tool_calls && input.tool_calls.map(convertRunStepToolCallOutput), - }; -} - -function convertRunStepToolCallOutput( - input: GeneratedModels.RunStepToolCallOutput, -): PublicModels.RunStepToolCallOutput { - switch (input.type) { - case "code_interpreter": - return convertRunStepCodeInterpreterToolCallOutput( - input as GeneratedModels.RunStepCodeInterpreterToolCallOutput, - ); - case "file_search": - return convertRunStepFileSearchToolCallOutput( - input as GeneratedModels.RunStepFileSearchToolCallOutput, - ); - case "bing_grounding": - return convertRunStepBingGroundingToolCallOutput( - input as GeneratedModels.RunStepBingGroundingToolCallOutput, - ); - case "azure_ai_search": - return convertRunStepAzureAISearchToolCallOutput( - input as GeneratedModels.RunStepAzureAISearchToolCallOutput, - ); - case "sharepoint_grounding": - return convertRunStepSharepointToolCallOutput( - input as GeneratedModels.RunStepSharepointToolCallOutput, - ); - case "fabric_dataagent": - return convertRunStepMicrosoftFabricToolCallOutput( - input as GeneratedModels.RunStepMicrosoftFabricToolCallOutput, - ); - case "function": - return convertRunStepFunctionToolCallOutput( - input as GeneratedModels.RunStepFunctionToolCallOutput, - ); - default: { - throw new Error(`Unknown run step tool call type: ${input.type}`); - } - } -} - -function convertRunStepCodeInterpreterToolCallOutput( - input: GeneratedModels.RunStepCodeInterpreterToolCallOutput, -): PublicModels.RunStepCodeInterpreterToolCallOutput { - return { - type: input.type, - id: input.id, - codeInterpreter: - input.code_interpreter && - convertRunStepCodeInterpreterToolCallDetailsOutput(input.code_interpreter), - }; -} - -function convertRunStepFileSearchToolCallOutput( - input: GeneratedModels.RunStepFileSearchToolCallOutput, -): PublicModels.RunStepFileSearchToolCallOutput { - return { - type: input.type, - id: input.id, - fileSearch: - input.file_search && convertRunStepFileSearchToolCallResultsOutput(input.file_search), - }; -} - -function convertRunStepFileSearchToolCallResultsOutput( - input: GeneratedModels.RunStepFileSearchToolCallResultsOutput, -): PublicModels.RunStepFileSearchToolCallResultsOutput { - return { - rankingOptions: - input.ranking_options && convertFileSearchRankingOptionsOutput(input.ranking_options), - results: input.results?.map(convertRunStepFileSearchToolCallResultOutput), - }; -} - -function convertRunStepFileSearchToolCallResultOutput( - input: GeneratedModels.RunStepFileSearchToolCallResultOutput, -): PublicModels.RunStepFileSearchToolCallResultOutput { - return { - fileId: input.file_id, - fileName: input.file_name, - score: input.score, - content: input.content, - }; -} - -function convertRunStepBingGroundingToolCallOutput( - input: GeneratedModels.RunStepBingGroundingToolCallOutput, -): PublicModels.RunStepBingGroundingToolCallOutput { - return { - type: input.type, - id: input.id, - bingGrounding: input.bing_grounding, - }; -} - -function convertRunStepAzureAISearchToolCallOutput( - input: GeneratedModels.RunStepAzureAISearchToolCallOutput, -): PublicModels.RunStepAzureAISearchToolCallOutput { - return { - type: input.type, - id: input.id, - azureAISearch: input.azure_ai_search, - }; -} - -function convertRunStepSharepointToolCallOutput( - input: GeneratedModels.RunStepSharepointToolCallOutput, -): PublicModels.RunStepSharepointToolCallOutput { - return { - type: input.type, - id: input.id, - sharepointGrounding: input.sharepoint_grounding, - }; -} - -function convertRunStepMicrosoftFabricToolCallOutput( - input: GeneratedModels.RunStepMicrosoftFabricToolCallOutput, -): PublicModels.RunStepMicrosoftFabricToolCallOutput { - return { - type: input.type, - id: input.id, - fabricDataAgent: input.fabric_dataagent, - }; -} - -function convertRunStepFunctionToolCallOutput( - input: GeneratedModels.RunStepFunctionToolCallOutput, -): PublicModels.RunStepFunctionToolCallOutput { - return { - type: input.type, - id: input.id, - function: convertRunStepFunctionToolCallDetailsOutput(input.function), - }; -} - -function convertRunStepFunctionToolCallDetailsOutput( - input: GeneratedModels.RunStepFunctionToolCallDetailsOutput, -): PublicModels.RunStepFunctionToolCallDetailsOutput { - return { - name: input.name, - arguments: input.arguments, - output: input.output, - }; -} - -function convertRunStepCodeInterpreterToolCallDetailsOutput( - input: GeneratedModels.RunStepCodeInterpreterToolCallDetailsOutput, -): PublicModels.RunStepCodeInterpreterToolCallDetailsOutput { - return { - input: input.input, - outputs: input.outputs && input.outputs.map(convertRunStepCodeInterpreterToolCallOutputOutput), - }; -} - -function convertRunStepCodeInterpreterToolCallOutputOutput( - input: GeneratedModels.RunStepCodeInterpreterToolCallOutputOutput, -): PublicModels.RunStepCodeInterpreterToolCallOutputOutput { - switch (input.type) { - case "logs": - return convertRunStepCodeInterpreterLogOutputOutput( - input as GeneratedModels.RunStepCodeInterpreterLogOutputOutput, - ); - case "image": - return convertRunStepCodeInterpreterImageOutputOutput( - input as GeneratedModels.RunStepCodeInterpreterImageOutputOutput, - ); - default: - return input; - } -} - -function convertRunStepCodeInterpreterLogOutputOutput( - input: GeneratedModels.RunStepCodeInterpreterLogOutputOutput, -): PublicModels.RunStepCodeInterpreterLogOutputOutput { - return { - type: input.type, - logs: input.logs, - }; -} - -function convertRunStepCodeInterpreterImageOutputOutput( - input: GeneratedModels.RunStepCodeInterpreterImageOutputOutput, -): PublicModels.RunStepCodeInterpreterImageOutputOutput { - return { - type: input.type, - image: convertRunStepCodeInterpreterImageReferenceOutput(input.image), - }; -} - -function convertRunStepCodeInterpreterImageReferenceOutput( - input: GeneratedModels.RunStepCodeInterpreterImageReferenceOutput, -): PublicModels.RunStepCodeInterpreterImageReferenceOutput { - return { - fileId: input.file_id, - }; -} - -function convertRunStepErrorOutput( - input: GeneratedModels.RunStepErrorOutput, -): PublicModels.RunStepErrorOutput { - return { - code: input.code, - message: input.message, - }; -} - -function convertRunStepCompletionUsageOutput( - input: GeneratedModels.RunStepCompletionUsageOutput, -): PublicModels.RunStepCompletionUsageOutput { - return { - completionTokens: input.completion_tokens, - promptTokens: input.prompt_tokens, - totalTokens: input.total_tokens, - }; -} - -export function convertOpenAIPageableListOfRunStepOutput( - input: GeneratedModels.OpenAIPageableListOfRunStepOutput, -): PublicModels.OpenAIPageableListOfRunStepOutput { - return { - object: input.object, - firstId: input.first_id, - lastId: input.last_id, - hasMore: input.has_more, - data: input.data?.map(convertRunStepOutput), - }; -} - -export function convertOpenAIPageableListOfThreadMessageOutput( - input: GeneratedModels.OpenAIPageableListOfThreadMessageOutput, -): PublicModels.OpenAIPageableListOfThreadMessageOutput { - return { - object: input.object, - firstId: input.first_id, - lastId: input.last_id, - hasMore: input.has_more, - data: input.data?.map(convertThreadMessageOutput), - }; -} - -export function convertOpenAIPageableListOfAgentThreadOutput( - input: GeneratedModels.OpenAIPageableListOfAgentThreadOutput, -): PublicModels.OpenAIPageableListOfAgentThreadOutput { - return { - object: input.object, - firstId: input.first_id, - lastId: input.last_id, - hasMore: input.has_more, - data: input.data?.map(convertAgentThreadOutput), - }; -} - -export function convertOpenAIPageableListOfVectorStoreOutput( - input: GeneratedModels.OpenAIPageableListOfVectorStoreOutput, -): PublicModels.OpenAIPageableListOfVectorStoreOutput { - return { - object: input.object, - firstId: input.first_id, - lastId: input.last_id, - hasMore: input.has_more, - data: input.data.map(convertVectorStoreOutput), - }; -} - -export function convertVectorStoreOutput( - input: GeneratedModels.VectorStoreOutput, -): PublicModels.VectorStoreOutput { - return { - id: input.id, - object: input.object, - createdAt: new Date(input.created_at), - name: input.name, - usageBytes: input.usage_bytes, - fileCounts: convertVectorStoreFileCountOutput(input.file_counts), - status: input.status, - expiresAfter: input.expires_after - ? convertVectorStoreExpirationPolicyOutput(input.expires_after) - : undefined, - expiresAt: input.expires_at ? new Date(input.expires_at) : null, - lastActiveAt: input.last_active_at ? new Date(input.last_active_at) : null, - metadata: input.metadata, - }; -} - -function convertVectorStoreFileCountOutput( - input: GeneratedModels.VectorStoreFileCountOutput, -): PublicModels.VectorStoreFileCountOutput { - return { - inProgress: input.in_progress, - completed: input.completed, - failed: input.failed, - cancelled: input.cancelled, - total: input.total, - }; -} - -function convertVectorStoreExpirationPolicyOutput( - input: GeneratedModels.VectorStoreExpirationPolicyOutput, -): PublicModels.VectorStoreExpirationPolicyOutput { - return { - anchor: input.anchor, - days: input.days, - }; -} - -export function convertVectorStoreDeletionStatusOutput( - input: GeneratedModels.VectorStoreDeletionStatusOutput, -): PublicModels.VectorStoreDeletionStatusOutput { - return { - id: input.id, - deleted: input.deleted, - object: input.object, - }; -} - -export function convertVectorStoreFileBatchOutput( - input: GeneratedModels.VectorStoreFileBatchOutput, -): PublicModels.VectorStoreFileBatchOutput { - return { - id: input.id, - object: input.object, - createdAt: new Date(input.created_at), - vectorStoreId: input.vector_store_id, - status: input.status, - fileCounts: convertVectorStoreFileCountOutput(input.file_counts), - }; -} - -export function convertOpenAIPageableListOfVectorStoreFileOutput( - input: GeneratedModels.OpenAIPageableListOfVectorStoreFileOutput, -): PublicModels.OpenAIPageableListOfVectorStoreFileOutput { - return { - object: input.object, - firstId: input.first_id, - lastId: input.last_id, - hasMore: input.has_more, - data: input.data.map(convertVectorStoreFileOutput), - }; -} - -export function convertVectorStoreFileOutput( - input: GeneratedModels.VectorStoreFileOutput, -): PublicModels.VectorStoreFileOutput { - return { - id: input.id, - object: input.object, - usageBytes: input.usage_bytes, - createdAt: new Date(input.created_at), - vectorStoreId: input.vector_store_id, - status: input.status, - lastError: input.last_error, - chunkingStrategy: - input.chunking_strategy && - convertVectorStoreChunkingStrategyResponseOutput(input.chunking_strategy), - }; -} - -function convertVectorStoreChunkingStrategyResponseOutput( - input: GeneratedModels.VectorStoreChunkingStrategyResponseOutput, -): PublicModels.VectorStoreChunkingStrategyResponseOutput { - switch (input.type) { - case "auto": - return input as PublicModels.VectorStoreAutoChunkingStrategyResponseOutput; - case "static": - return convertVectorStoreStaticChunkingStrategyResponseOutput( - input as GeneratedModels.VectorStoreStaticChunkingStrategyResponseOutput, - ); - default: - throw new Error(`Unknown chunking strategy type: ${input.type}`); - } -} -function convertVectorStoreStaticChunkingStrategyResponseOutput( - input: GeneratedModels.VectorStoreStaticChunkingStrategyResponseOutput, -): PublicModels.VectorStoreStaticChunkingStrategyResponseOutput { - return { - type: input.type, - static: input.static && convertVectorStoreStaticChunkingStrategyOptionsOutput(input.static), - }; -} - -function convertVectorStoreStaticChunkingStrategyOptionsOutput( - input: GeneratedModels.VectorStoreStaticChunkingStrategyOptionsOutput, -): PublicModels.VectorStoreStaticChunkingStrategyOptionsOutput { - return { - maxChunkSizeTokens: input.max_chunk_size_tokens, - chunkOverlapTokens: input.chunk_overlap_tokens, - }; -} - -export function convertVectorStoreFileDeletionStatusOutput( - input: GeneratedModels.VectorStoreFileDeletionStatusOutput, -): PublicModels.VectorStoreFileDeletionStatusOutput { - return { - id: input.id, - deleted: input.deleted, - object: input.object, - }; -} - -export function convertOpenAIFileOutput( - input: GeneratedModels.OpenAIFileOutput, -): PublicModels.OpenAIFileOutput { - return { - id: input.id, - object: input.object, - bytes: input.bytes, - filename: input.filename, - createdAt: new Date(input.created_at), - purpose: input.purpose, - status: input.status, - statusDetails: input.status_details, - }; -} - -export function convertFileListResponseOutput( - input: GeneratedModels.FileListResponseOutput, -): PublicModels.FileListResponseOutput { - return { - object: input.object, - data: input.data.map(convertOpenAIFileOutput), - }; -} - -function convertMessageDelta( - input: WireStreamingModels.MessageDelta, -): PublicStreamingModels.MessageDelta { - return { - role: input.role, - content: input.content?.map(convertStreamingMessageDeltaContent), - }; -} - -export function convertMessageDeltaChunkOutput( - input: WireStreamingModels.MessageDeltaChunk, -): PublicStreamingModels.MessageDeltaChunk { - return { - id: input.id, - object: input.object, - delta: input.delta && convertMessageDelta(input.delta), - }; -} -function convertStreamingMessageDeltaContent( - input: WireStreamingModels.MessageDeltaContent, -): PublicStreamingModels.MessageDeltaContent { - switch (input.type) { - case "text": - return convertStreamingMessageTextContent( - input as WireStreamingModels.MessageDeltaTextContent, - ); - case "image": - return convertStreamingMessageImageContent( - input as WireStreamingModels.MessageDeltaImageFileContent, - ); - default: - logger.error(`Unknown message content type: ${input.type}`); - return { - index: input.index, - type: input.type, - }; - } -} - -function convertStreamingMessageTextContent( - input: WireStreamingModels.MessageDeltaTextContent, -): PublicStreamingModels.MessageDeltaTextContent { - return { - index: input.index, - type: input.type, - text: input.text && convertStreamingMessageTextDetails(input.text), - }; -} - -function convertStreamingMessageTextDetails( - input: WireStreamingModels.MessageDeltaTextContentObject, -): PublicStreamingModels.MessageDeltaTextContentObject { - return { - value: input.value, - annotations: input.annotations?.map(convertStreamingMessageTextAnnotation), - }; -} - -function convertStreamingMessageTextAnnotation( - input: WireStreamingModels.MessageDeltaTextAnnotation, -): PublicStreamingModels.MessageDeltaTextAnnotation { - switch (input.type) { - case "file_citation": - return convertStreamingMessageTextFileCitationAnnotation( - input as WireStreamingModels.MessageDeltaTextFileCitationAnnotation, - ); - case "file_path": - return convertStreamingMessageTextFilePathAnnotation( - input as WireStreamingModels.MessageDeltaTextFilePathAnnotation, - ); - default: - return input; - } -} - -function convertStreamingMessageTextFileCitationAnnotation( - input: WireStreamingModels.MessageDeltaTextFileCitationAnnotation, -): PublicStreamingModels.MessageDeltaTextFileCitationAnnotation { - return { - index: input.index, - type: input.type, - text: input.text, - fileCitation: - input.file_citation && convertStreamingMessageTextFileCitationDetails(input.file_citation), - startIndex: input.start_index, - endIndex: input.end_index, - }; -} - -function convertStreamingMessageTextFileCitationDetails( - input: WireStreamingModels.MessageDeltaTextFileCitationAnnotationObject, -): PublicStreamingModels.MessageDeltaTextFileCitationAnnotationObject { - return { - fileId: input.file_id, - quote: input.quote, - }; -} - -function convertStreamingMessageTextFilePathAnnotation( - input: WireStreamingModels.MessageDeltaTextFilePathAnnotation, -): PublicStreamingModels.MessageDeltaTextFilePathAnnotation { - return { - index: input.index, - type: input.type, - text: input.text, - filePath: input.file_path && convertStreamingMessageTextFilePathDetails(input.file_path), - startIndex: input.start_index, - endIndex: input.end_index, - }; -} - -function convertStreamingMessageTextFilePathDetails( - input: WireStreamingModels.MessageDeltaTextFilePathAnnotationObject, -): PublicStreamingModels.MessageDeltaTextFilePathAnnotationObject { - return { - fileId: input.file_id, - }; -} - -function convertStreamingMessageImageContent( - input: WireStreamingModels.MessageDeltaImageFileContent, -): PublicStreamingModels.MessageDeltaImageFileContent { - return { - index: input.index, - type: input.type, - imageFile: input.image_file && convertStreamingMessageImageFileDetails(input.image_file), - }; -} - -function convertStreamingMessageImageFileDetails( - input: WireStreamingModels.MessageDeltaImageFileContentObject, -): PublicStreamingModels.MessageDeltaImageFileContentObject { - return { - fileId: input.file_id, - }; -} - -export function convertRunStepDeltaChunk( - input: WireStreamingModels.RunStepDeltaChunk, -): PublicStreamingModels.RunStepDeltaChunk { - return { - id: input.id, - object: input.object, - delta: input.delta && convertRunStepDelta(input.delta), - }; -} -function convertRunStepDelta( - input: WireStreamingModels.RunStepDelta, -): PublicStreamingModels.RunStepDelta { - return { - stepDetails: input.step_details && convertRunStepDetailsDelta(input.step_details), - }; -} - -function convertRunStepDetailsDelta( - input: WireStreamingModels.RunStepDeltaDetail, -): PublicStreamingModels.RunStepDeltaDetail { - switch (input.type) { - case "message_creation": - return convertRunStepMessageCreationDetailsDelta( - input as WireStreamingModels.RunStepDeltaMessageCreation, - ); - case "tool_calls": - return convertRunStepToolCallDetailsDelta( - input as WireStreamingModels.RunStepDeltaToolCallObject, - ); - default: - logger.error(`Unknown run step type: ${input.type}`); - return { type: input.type }; - } -} - -function convertRunStepMessageCreationDetailsDelta( - input: WireStreamingModels.RunStepDeltaMessageCreation, -): PublicStreamingModels.RunStepDeltaMessageCreation { - return { - type: input.type, - messageCreation: - input.message_creation && convertRunStepDeltaMessageCreationObject(input.message_creation), - }; -} - -function convertRunStepDeltaMessageCreationObject( - input: WireStreamingModels.RunStepDeltaMessageCreationObject, -): PublicStreamingModels.RunStepDeltaMessageCreationObject { - return { - messageId: input.message_id, - }; -} - -function convertRunStepToolCallDetailsDelta( - input: WireStreamingModels.RunStepDeltaToolCallObject, -): PublicStreamingModels.RunStepDeltaToolCallObject { - return { - type: input.type, - toolCalls: input.tool_calls && input.tool_calls.map(convertRunStepToolCallDelta), - }; -} - -function convertRunStepToolCallDelta( - input: WireStreamingModels.RunStepDeltaToolCall, -): PublicStreamingModels.RunStepDeltaToolCall { - switch (input.type) { - case "code_interpreter": - return convertRunStepCodeInterpreterToolCallDelta( - input as WireStreamingModels.RunStepDeltaCodeInterpreterToolCall, - ); - case "file_search": - return convertRunStepFileSearchToolCallDelta( - input as WireStreamingModels.RunStepDeltaFileSearchToolCall, - ); - case "function": - return convertRunStepFunctionToolCallDelta( - input as WireStreamingModels.RunStepDeltaFunctionToolCall, - ); - default: - logger.error(`Unknown run step tool call type: ${input.type}`); - return { - index: input.index, - id: input.id, - type: input.type, - }; - } -} - -function convertRunStepCodeInterpreterToolCallDelta( - input: WireStreamingModels.RunStepDeltaCodeInterpreterToolCall, -): PublicStreamingModels.RunStepDeltaCodeInterpreterToolCall { - return { - index: input.index, - type: input.type, - id: input.id, - codeInterpreter: - input.code_interpreter && - convertRunStepCodeInterpreterToolCallDetailsDelta(input.code_interpreter), - }; -} - -function convertRunStepCodeInterpreterToolCallDetailsDelta( - input: WireStreamingModels.RunStepDeltaCodeInterpreterDetailItemObject, -): PublicStreamingModels.RunStepDeltaCodeInterpreterDetailItemObject { - return { - input: input.input, - outputs: input.outputs && input.outputs.map(convertRunStepCodeInterpreterToolCallOutputDelta), - }; -} - -function convertRunStepCodeInterpreterToolCallOutputDelta( - input: WireStreamingModels.RunStepDeltaCodeInterpreterOutput, -): PublicStreamingModels.RunStepDeltaCodeInterpreterOutput { - switch (input.type) { - case "logs": - return convertRunStepCodeInterpreterLogOutputDelta( - input as WireStreamingModels.RunStepDeltaCodeInterpreterLogOutput, - ); - case "image": - return convertRunStepCodeInterpreterImageOutputDelta( - input as WireStreamingModels.RunStepDeltaCodeInterpreterImageOutput, - ); - default: - return input; - } -} - -function convertRunStepCodeInterpreterLogOutputDelta( - input: WireStreamingModels.RunStepDeltaCodeInterpreterLogOutput, -): PublicStreamingModels.RunStepDeltaCodeInterpreterLogOutput { - return { - index: input.index, - type: input.type, - logs: input.logs, - }; -} - -function convertRunStepCodeInterpreterImageOutputDelta( - input: WireStreamingModels.RunStepDeltaCodeInterpreterImageOutput, -): PublicStreamingModels.RunStepDeltaCodeInterpreterImageOutput { - return { - index: input.index, - type: input.type, - image: input.image && convertRunStepCodeInterpreterImageReferenceDelta(input.image), - }; -} - -function convertRunStepCodeInterpreterImageReferenceDelta( - input: WireStreamingModels.RunStepDeltaCodeInterpreterImageOutputObject, -): PublicStreamingModels.RunStepDeltaCodeInterpreterImageOutputObject { - return { - fileId: input.file_id, - }; -} - -function convertRunStepFunctionToolCallDelta( - input: WireStreamingModels.RunStepDeltaFunctionToolCall, -): PublicStreamingModels.RunStepDeltaFunctionToolCall { - return { - index: input.index, - type: input.type, - id: input.id, - function: input.function && convertRunStepFunctionToolCallDetailsDelta(input.function), - }; -} - -function convertRunStepFunctionToolCallDetailsDelta( - input: WireStreamingModels.RunStepDeltaFunction, -): PublicStreamingModels.RunStepDeltaFunction { - return { - name: input.name, - arguments: input.arguments, - output: input.output, - }; -} - -function convertRunStepFileSearchToolCallDelta( - input: WireStreamingModels.RunStepDeltaFileSearchToolCall, -): PublicStreamingModels.RunStepDeltaFileSearchToolCall { - return { - index: input.index, - type: input.type, - id: input.id, - fileSearch: convertRunStepFileSearchToolCallResultsOutput( - input.file_search as GeneratedModels.RunStepFileSearchToolCallResultsOutput, - ), - }; -} diff --git a/sdk/ai/ai-projects/src/customization/convertParametersToWire.ts b/sdk/ai/ai-projects/src/customization/convertParametersToWire.ts deleted file mode 100644 index 8acc8289e329..000000000000 --- a/sdk/ai/ai-projects/src/customization/convertParametersToWire.ts +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type * as PublicParameters from "./parameters.js"; -import type * as GeneratedParameters from "../generated/src/parameters.js"; -import { - convertVectorStoreChunkingStrategyRequest, - convertVectorStoreDataSource, -} from "./convertModelsToWrite.js"; - -/** - * Request options for list requests. - */ -interface ListQueryParameters { - limit?: number; - order?: string; - after?: string; - before?: string; -} - -export function convertCreateVectorStoreFileBatchParam( - input: PublicParameters.CreateVectorStoreFileBatchBodyParam, -): GeneratedParameters.CreateVectorStoreFileBatchBodyParam { - return { - body: input.body && { - ...(input.body.fileIds && { file_ids: input.body.fileIds }), - ...(input.body.dataSources && { - data_sources: input.body.dataSources.map(convertVectorStoreDataSource), - }), - ...(input.body.chunkingStrategy && { - chunking_strategy: convertVectorStoreChunkingStrategyRequest(input.body.chunkingStrategy), - }), - }, - }; -} - -export function convertCreateVectorStoreFileParam( - input: PublicParameters.CreateVectorStoreFileBodyParam, -): GeneratedParameters.CreateVectorStoreFileBodyParam { - return { - body: input.body && { - ...(input.body.fileId && { file_id: input.body.fileId }), - ...(input.body.dataSources && { - data_sources: input.body.dataSources.map(convertVectorStoreDataSource), - }), - ...(input.body.chunkingStrategy && { - chunking_strategy: convertVectorStoreChunkingStrategyRequest(input.body.chunkingStrategy), - }), - }, - }; -} - -export function convertToListQueryParameters( - options: T, -): ListQueryParameters & Record { - return { - ...(options.limit && { limit: options.limit }), - ...(options.order && { order: options.order }), - ...(options.after && { after: options.after }), - ...(options.before && { before: options.before }), - }; -} - -export function convertListVectorStoreFileBatchFilesQueryParamProperties( - options: PublicParameters.ListVectorStoreFileBatchFilesQueryParamProperties, -): GeneratedParameters.ListVectorStoreFileBatchFilesQueryParamProperties { - return { - ...convertToListQueryParameters(options), - ...(options.filter && { filter: options.filter }), - }; -} - -export function convertListFilesQueryParamProperties( - options: PublicParameters.ListFilesQueryParamProperties, -): GeneratedParameters.ListFilesQueryParamProperties & Record { - return { - ...(options.purpose && { purpose: options.purpose }), - }; -} diff --git a/sdk/ai/ai-projects/src/customization/models.ts b/sdk/ai/ai-projects/src/customization/models.ts deleted file mode 100644 index ae2d42e7ed32..000000000000 --- a/sdk/ai/ai-projects/src/customization/models.ts +++ /dev/null @@ -1,1069 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** The request details to use when creating a new agent. */ -export interface CreateAgentOptions { - /** The ID of the model to use. */ - model: string; - /** The name of the new agent. */ - name?: string | null; - /** The description of the new agent. */ - description?: string | null; - /** The system instructions for the new agent to use. */ - instructions?: string | null; - /** The collection of tools to enable for the new agent. */ - tools?: Array; - /** - * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` - * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - */ - toolResources?: ToolResources | null; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - topP?: number | null; - /** The response format of the tool calls used by this agent. */ - responseFormat?: AgentsApiResponseFormatOption | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** An abstract representation of an input tool definition that an agent can use. */ -export interface ToolDefinitionParent { - type: string; -} - -/** The input definition information for a code interpreter tool as used to configure an agent. */ -export interface CodeInterpreterToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'code_interpreter'. */ - type: "code_interpreter"; -} - -/** The input definition information for a file search tool as used to configure an agent. */ -export interface FileSearchToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'file_search'. */ - type: "file_search"; - /** Options overrides for the file search tool. */ - fileSearch?: FileSearchToolDefinitionDetails; -} - -/** Options overrides for the file search tool. */ -export interface FileSearchToolDefinitionDetails { - /** - * The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. - * - * Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. - */ - maxNumResults?: number; - /** Ranking options for file search. */ - rankingOptions?: FileSearchRankingOptions; -} - -/** Ranking options for file search. */ -export interface FileSearchRankingOptions { - /** File search ranker. */ - ranker: string; - /** Ranker search threshold. */ - scoreThreshold: number; -} - -/** The input definition information for a function tool as used to configure an agent. */ -export interface FunctionToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'function'. */ - type: "function"; - /** The definition of the concrete function that the function tool should call. */ - function: FunctionDefinition; -} - -/** The input definition information for a function. */ -export interface FunctionDefinition { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The parameters the functions accepts, described as a JSON Schema object. */ - parameters: unknown; -} - -/** The input definition information for a bing grounding search tool as used to configure an agent. */ -export interface BingGroundingToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'bing_grounding'. */ - type: "bing_grounding"; - /** The list of connections used by the bing grounding tool. */ - bingGrounding: ToolConnectionList; -} - -/** - * The input definition information for a bing custom search tool as used to configure an agent. - */ -export interface BingCustomSearchToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'bing_custom_search'. */ - type: "bing_custom_search"; - /** The list of connections used by the bing custom search tool. */ - bingCustomSearch?: SearchConfigurationList; -} - -/** The array of search configurations used by the bing custom search tool. */ -export interface SearchConfigurationList { - /** The list of connections used by the bing custom search tool. */ - searchConfigurations: Array; -} - -/** The input definition information for a search configuration. */ -export interface SearchConfiguration { - /** A connection in a ToolConnectionList attached to this tool. */ - connectionId: string; - /** Name of the custom configuration instance given to config. */ - instanceName: string; -} - -/** A set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or `sharepoint_grounding` tools. */ -export interface ToolConnectionList { - /** - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - connections?: Array; -} - -/** A connection resource. */ -export interface ToolConnection { - /** A connection in a ToolConnectionList attached to this tool. */ - connectionId: string; -} - -/** The input definition information for a Microsoft Fabric tool as used to configure an agent. */ -export interface MicrosoftFabricToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'fabric_dataagent'. */ - type: "fabric_dataagent"; - /** The list of connections used by the Microsoft Fabric tool. */ - fabricDataAgent: ToolConnectionList; -} - -/** The input definition information for a sharepoint tool as used to configure an agent. */ -export interface SharepointToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'sharepoint_grounding'. */ - type: "sharepoint_grounding"; - /** The list of connections used by the SharePoint tool. */ - sharepointGrounding: ToolConnectionList; -} - -/** The input definition information for an Azure AI search tool as used to configure an agent. */ -export interface AzureAISearchToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'azure_ai_search'. */ - type: "azure_ai_search"; -} - -/** The input definition information for an OpenAPI tool as used to configure an agent. */ -export interface OpenApiToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'openapi'. */ - type: "openapi"; - /** The openapi function definition. */ - openapi: OpenApiFunctionDefinition; -} - -/** The input definition information for an openapi function. */ -export interface OpenApiFunctionDefinition { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The openapi function shape, described as a JSON Schema object. */ - spec: unknown; - /** Open API authentication details */ - auth: OpenApiAuthDetails; - /** List of OpenAPI spec parameters that will use user-provided defaults */ - defaultParams?: string[]; - /** List of functions returned in response */ - functions?: Array; -} - -/** authentication details for OpenApiFunctionDefinition */ -export interface OpenApiAuthDetailsParent { - type: OpenApiAuthType; -} - -/** Security details for OpenApi anonymous authentication */ -export interface OpenApiAnonymousAuthDetails extends OpenApiAuthDetailsParent { - /** The object type, which is always 'anonymous'. */ - type: "anonymous"; -} - -/** Security details for OpenApi connection authentication */ -export interface OpenApiConnectionAuthDetails extends OpenApiAuthDetailsParent { - /** The object type, which is always 'connection'. */ - type: "connection"; - /** Connection auth security details */ - securityScheme: OpenApiConnectionSecurityScheme; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiConnectionSecurityScheme { - /** Connection id for Connection auth type */ - connectionId: string; -} - -/** Security details for OpenApi managed_identity authentication */ -export interface OpenApiManagedAuthDetails extends OpenApiAuthDetailsParent { - /** The object type, which is always 'managed_identity'. */ - type: "managed_identity"; - /** Connection auth security details */ - securityScheme: OpenApiManagedSecurityScheme; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiManagedSecurityScheme { - /** Authentication scope for managed_identity auth type */ - audience: string; -} - -/** A list of search configurations currently used by the `bing_custom_search` tool. */ -export interface SearchConfigurationList { - /** - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - searchConfigurations: Array; -} - -/** A custom search configuration. */ -export interface SearchConfiguration { - /** A connection in a ToolConnectionList attached to this tool. */ - connectionId: string; - /** Name of the custom configuration instance given to config. */ - instanceName: string; -} - -/** The input definition information for a azure function tool as used to configure an agent. */ -export interface AzureFunctionToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'azure_function'. */ - type: "azure_function"; - /** The definition of the concrete function that the function tool should call. */ - azureFunction: AzureFunctionDefinition; -} - -/** The definition of Azure function. */ -export interface AzureFunctionDefinition { - /** The definition of azure function and its parameters. */ - function: FunctionDefinition; - /** Input storage queue. The queue storage trigger runs a function as messages are added to it. */ - inputBinding: AzureFunctionBinding; - /** Output storage queue. The function writes output to this queue when the input items are processed. */ - outputBinding: AzureFunctionBinding; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionBinding { - /** The type of binding, which is always 'storage_queue'. */ - type: "storage_queue"; - /** Storage queue. */ - storageQueue: AzureFunctionStorageQueue; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionStorageQueue { - /** URI to the Azure Storage Queue service allowing you to manipulate a queue. */ - queueServiceEndpoint: string; - /** The name of an Azure function storage queue. */ - queueName: string; -} - -/** - * A set of resources that are used by the agent's tools. The resources are specific to the type of - * tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` - * tool requires a list of vector store IDs. - */ -export interface ToolResources { - /** Resources to be used by the `code_interpreter` tool consisting of file IDs. */ - codeInterpreter?: CodeInterpreterToolResource; - /** Resources to be used by the `file_search` tool consisting of vector store IDs. */ - fileSearch?: FileSearchToolResource; - /** Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azureAISearch?: AzureAISearchResource; - /** Resources to be used by the `azure_function` tool consisting of connection IDs. */ - azureFunction?: AzureFunctionToolResource; -} - -/** A set of resources that are used by the `code_interpreter` tool. */ -export interface CodeInterpreterToolResource { - /** - * A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - fileIds?: string[]; - /** The data sources to be used. This option is mutually exclusive with the `fileIds` property. */ - dataSources?: Array; -} - -/** - * The structure, containing Azure asset URI path and the asset type of the file used as a data source - * for the enterprise file search. - */ -export interface VectorStoreDataSource { - /** Asset URI. */ - uri: string; - /** - * The asset type - * - * Possible values: "uri_asset", "id_asset" - */ - type: VectorStoreDataSourceAssetType; -} - -/** A set of resources that are used by the `file_search` tool. */ -export interface FileSearchToolResource { - /** - * The ID of the vector store attached to this agent. There can be a maximum of 1 vector - * store attached to the agent. - */ - vectorStoreIds?: string[]; - /** - * The list of vector store configuration objects from Azure. - * This list is limited to one element. - * The only element of this list contains the list of azure asset IDs used by the search tool. - */ - vectorStores?: Array; -} - -export interface AzureFunctionToolResource { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description: string; - /** The parameters the functions accepts, described as a JSON Schema object. */ - parameters: unknown; - inputQueue: AzureFunctionStorageQueue; - outputQueue: AzureFunctionStorageQueue; -} - -/** The structure, containing the list of vector storage configurations i.e. the list of azure asset IDs. */ -export interface VectorStoreConfigurations { - /** Name */ - name: string; - /** Configurations */ - configuration: VectorStoreConfiguration; -} - -/** - * Vector storage configuration is the list of data sources, used when multiple - * files can be used for the enterprise file search. - */ -export interface VectorStoreConfiguration { - /** Data sources */ - dataSources: Array; -} - -/** A set of index resources used by the `azure_ai_search` tool. */ -export interface AzureAISearchResource { - /** - * The indices attached to this agent. There can be a maximum of 1 index - * resource attached to the agent. - */ - indexes?: Array; -} - -/** the optional parameters for the Azure AI Search tool */ -export interface CreateAzureAISearchToolOptions { - /** the query type of azure ai search. */ - queryType?: AzureAISearchQueryType; - /** the topK number of documents to retrieve from azure ai search. */ - topK?: number; - /** the filter used for azure ai search. */ - filter?: string; -} - -/** A Index resource. */ -export interface IndexResource { - /** An index connection id in an IndexResource attached to this agent. */ - indexConnectionId: string; - /** The name of an index in an IndexResource attached to this agent. */ - indexName: string; - /** - * Type of query in an AIIndexResource attached to this agent. - * - * Possible values: "simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid" - */ - queryType?: AzureAISearchQueryType; - /** Number of documents to retrieve from search and present to the model. */ - topK?: number; - /** Odata filter string for search resource. */ - filter?: string; -} - -/** - * An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. - * If `text` the model can return text or any value needed. - */ -export interface AgentsApiResponseFormat { - /** - * Must be one of `text` or `json_object`. - * - * Possible values: "text", "json_object" - */ - type?: ResponseFormat; -} - -/** The type of response format being defined: `json_schema` */ -export interface ResponseFormatJsonSchemaType { - /** Type */ - type: "json_schema"; - /** The JSON schema, describing response format. */ - jsonSchema: ResponseFormatJsonSchema; -} - -/** A description of what the response format is for, used by the model to determine how to respond in the format. */ -export interface ResponseFormatJsonSchema { - /** A description of what the response format is for, used by the model to determine how to respond in the format. */ - description?: string; - /** The name of a schema. */ - name: string; - /** The JSON schema object, describing the response format. */ - schema: unknown; -} - -/** The request details to use when modifying an existing agent. */ -export interface UpdateAgentOptions { - /** The ID of the model to use. */ - model?: string; - /** The modified name for the agent to use. */ - name?: string | null; - /** The modified description for the agent to use. */ - description?: string | null; - /** The modified system instructions for the new agent to use. */ - instructions?: string | null; - /** The modified collection of tools to enable for the agent. */ - tools?: Array; - /** - * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, - * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - */ - toolResources?: ToolResources; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - topP?: number | null; - /** The response format of the tool calls used by this agent. */ - responseFormat?: AgentsApiResponseFormatOption | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** The details used to create a new agent thread. */ -export interface AgentThreadCreationOptions { - /** The initial messages to associate with the new thread. */ - messages?: Array; - /** - * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - * a list of vector store IDs. - */ - toolResources?: ToolResources | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** A single message within an agent thread, as provided during that thread's creation for its initial state. */ -export interface ThreadMessageOptions { - /** - * The role of the entity that is creating the message. Allowed values include: - * - `user`: Indicates the message is sent by an actual user and should be used in most - * cases to represent user-generated messages. - * - `assistant`: Indicates the message is generated by the agent. Use this value to insert - * messages from the agent into the - * conversation. - * - * Possible values: "user", "assistant" - */ - role: MessageRole; - /** - * The textual content of the initial message. Currently, robust input including images and annotated text may only be provided via - * a separate call to the create message API. - */ - content: CreateMessageContent; - /** A list of files attached to the message, and the tools they should be added to. */ - attachments?: Array | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** Defines a single content block when creating a message. The 'type' field determines whether it is text, an image file, or an external image URL, etc. */ -export interface MessageContentBlockInputParent { - type: MessageBlockType; -} - -/** Creation-time text block. */ -export interface MessageTextBlockInput extends MessageContentBlockInputParent { - /** Always 'text'. */ - type: "text"; - /** The text content. */ - text: string; -} - -/** Creation-time image-file block. */ -export interface MessageImageFileBlockInput extends MessageContentBlockInputParent { - /** Always 'image_file'. */ - type: "image_file"; - /** References an uploaded image by file ID. */ - imageFile: MessageImageFileParam; -} - -/** Parameter for an image file (by ID) at creation time. */ -export interface MessageImageFileParam { - /** File ID for the uploaded image. */ - fileId: string; - /** - * Specifies the requested detail level for the image. - * - * Possible values: "auto", "low", "high" - */ - detail?: ImageDetailLevel; -} - -/** Creation-time image-URL block. */ -export interface MessageImageUrlBlockInput extends MessageContentBlockInputParent { - /** Always 'image_url'. */ - type: "image_url"; - /** References an external image by URL. */ - imageUrl: MessageImageUrlParam; -} - -/** Parameter for an external image URL at creation time. */ -export interface MessageImageUrlParam { - /** The externally accessible image URL. */ - url: string; - /** - * Specifies the requested detail level for the image. Default is 'auto'. - * - * Possible values: "auto", "low", "high" - */ - detail?: ImageDetailLevel; -} - -/** This describes to which tools a file has been attached. */ -export interface MessageAttachment { - /** The ID of the file to attach to the message. */ - fileId?: string; - /** Azure asset ID. */ - dataSource?: VectorStoreDataSource; - /** The tools to add to this file. */ - tools: MessageAttachmentToolDefinition[]; -} - -/** The details used to update an existing agent thread */ -export interface UpdateAgentThreadOptions { - /** - * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - * a list of vector store IDs - */ - toolResources?: ToolResources | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** The details used when creating a new run of an agent thread. */ -export interface CreateRunOptions { - /** The ID of the agent that should run the thread. */ - assistantId: string; - /** The overridden model name that the agent should use to run the thread. */ - model?: string | null; - /** The overridden system instructions that the agent should use to run the thread. */ - instructions?: string | null; - /** - * Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior - * on a per-run basis without overriding other instructions. - */ - additionalInstructions?: string | null; - /** Adds additional messages to the thread before creating the run. */ - additionalMessages?: Array | null; - /** The overridden list of enabled tools that the agent should use to run the thread. */ - tools?: Array | null; - /** - * If `true`, returns a stream of events that happen during the Run as server-sent events, - * terminating when the Run enters a terminal state with a `data: [DONE]` message. - */ - stream?: boolean; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model - * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - * comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - topP?: number | null; - /** - * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - * the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - maxPromptTokens?: number | null; - /** - * The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort - * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of - * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - maxCompletionTokens?: number | null; - /** The strategy to use for dropping messages as the context windows moves forward. */ - truncationStrategy?: TruncationObject | null; - /** Controls whether or not and which tool is called by the model. */ - toolChoice?: AgentsApiToolChoiceOption | null; - /** Specifies the format that the model must output. */ - responseFormat?: AgentsApiResponseFormatOption | null; - /** If `true` functions will run in parallel during tool use. */ - parallelToolCalls?: boolean; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** - * Controls for how a thread will be truncated prior to the run. Use this to control the initial - * context window of the run. - */ -export interface TruncationObject { - /** - * The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will - * be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread - * will be dropped to fit the context length of the model, `max_prompt_tokens`. - * - * Possible values: "auto", "last_messages" - */ - type: TruncationStrategy; - /** The number of most recent messages from the thread when constructing the context for the run. */ - lastMessages?: number | null; -} - -/** Specifies a tool the model should use. Use to force the model to call a specific tool. */ -export interface AgentsNamedToolChoice { - /** - * the type of tool. If type is `function`, the function name must be set. - * - * Possible values: "function", "code_interpreter", "file_search", "bing_grounding", "fabric_dataagent", "sharepoint_grounding", "azure_ai_search" - */ - type: AgentsNamedToolChoiceType; - /** The name of the function to call */ - function?: FunctionName; -} - -/** The function name that will be used, if using the `function` tool */ -export interface FunctionName { - /** The name of the function to call */ - name: string; -} - -/** - * Request object. A set of resources that are used by the agent's tools. The resources are specific to the type of tool. - * For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of - * vector store IDs. - */ -export interface UpdateToolResourcesOptions { - /** - * Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - codeInterpreter?: UpdateCodeInterpreterToolResourceOptions; - /** Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. */ - fileSearch?: UpdateFileSearchToolResourceOptions; - /** Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azureAISearch?: AzureAISearchResource; - /** Overrides the resources to be used by the `azure_function` tool consisting of connection IDs. */ - azureFunction?: AzureFunctionToolResource; -} - -/** Request object to update `code_interpreted` tool resources. */ -export interface UpdateCodeInterpreterToolResourceOptions { - /** A list of file IDs to override the current list of the agent. */ - fileIds?: string[]; -} - -/** Request object to update `file_search` tool resources. */ -export interface UpdateFileSearchToolResourceOptions { - /** A list of vector store IDs to override the current list of the agent. */ - vectorStoreIds?: string[]; -} - -/** The data provided during a tool outputs submission to resolve pending tool calls and allow the model to continue. */ -export interface ToolOutput { - /** The ID of the tool call being resolved, as provided in the tool calls of a required action from a run. */ - toolCallId?: string; - /** The output from the tool to be submitted. */ - output?: string; -} - -/** The details used when creating and immediately running a new agent thread. */ -export interface CreateAndRunThreadOptions { - /** The ID of the agent for which the thread should be created. */ - assistantId: string; - /** The details used to create the new thread. If no thread is provided, an empty one will be created. */ - thread?: AgentThreadCreationOptions; - /** The overridden model that the agent should use to run the thread. */ - model?: string | null; - /** The overridden system instructions the agent should use to run the thread. */ - instructions?: string | null; - /** The overridden list of enabled tools the agent should use to run the thread. */ - tools?: Array | null; - /** Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis */ - toolResources?: UpdateToolResourcesOptions | null; - /** - * If `true`, returns a stream of events that happen during the Run as server-sent events, - * terminating when the Run enters a terminal state with a `data: [DONE]` message. - */ - stream?: boolean; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model - * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - * comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - topP?: number | null; - /** - * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - * the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - maxPromptTokens?: number | null; - /** - * The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only - * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens - * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - maxCompletionTokens?: number | null; - /** The strategy to use for dropping messages as the context windows moves forward. */ - truncationStrategy?: TruncationObject | null; - /** Controls whether or not and which tool is called by the model. */ - toolChoice?: AgentsApiToolChoiceOption | null; - /** Specifies the format that the model must output. */ - responseFormat?: AgentsApiResponseFormatOption | null; - /** If `true` functions will run in parallel during tool use. */ - parallelToolCalls?: boolean; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** The expiration policy for a vector store. */ -export interface VectorStoreExpirationPolicy { - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - * - * Possible values: "last_active_at" - */ - anchor: VectorStoreExpirationPolicyAnchor; - /** The anchor timestamp after which the expiration policy applies. */ - days: number; -} - -/** Request object for creating a vector store. */ -export interface VectorStoreOptions { - /** A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ - fileIds?: string[]; - /** The name of the vector store. */ - name?: string; - /** The vector store configuration, used when vector store is created from Azure asset URIs. */ - configuration?: VectorStoreConfiguration; - /** Details on when this vector store expires */ - expiresAfter?: VectorStoreExpirationPolicy; - /** The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. */ - chunkingStrategy?: VectorStoreChunkingStrategyRequest; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** An abstract representation of a vector store chunking strategy configuration. */ -export interface VectorStoreChunkingStrategyRequestParent { - type: VectorStoreChunkingStrategyRequestType; -} - -/** The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400. */ -export interface VectorStoreAutoChunkingStrategyRequest - extends VectorStoreChunkingStrategyRequestParent { - /** The object type, which is always 'auto'. */ - type: "auto"; -} - -/** A statically configured chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyRequest - extends VectorStoreChunkingStrategyRequestParent { - /** The object type, which is always 'static'. */ - type: "static"; - /** The options for the static chunking strategy. */ - static: VectorStoreStaticChunkingStrategyOptions; -} - -/** Options to configure a vector store static chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyOptions { - /** The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. */ - maxChunkSizeTokens: number; - /** - * The number of tokens that overlap between chunks. The default value is 400. - * Note that the overlap must not exceed half of max_chunk_size_tokens. - */ - chunkOverlapTokens: number; -} - -/** Request object for updating a vector store. */ -export interface VectorStoreUpdateOptions { - /** The name of the vector store. */ - name?: string | null; - /** Details on when this vector store expires */ - expiresAfter?: VectorStoreExpirationPolicy | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** Evaluation Definition */ -export interface Evaluation { - /** Data for evaluation. */ - data: InputData; - /** Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. */ - displayName?: string; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; -} - -/** Abstract data class for input data configuration. */ -export interface InputDataParent { - type: string; -} - -/** Data Source for Application Insights. */ -export interface ApplicationInsightsConfiguration extends InputDataParent { - /** LogAnalytic Workspace resourceID associated with ApplicationInsights */ - resourceId: string; - /** Query to fetch the data. */ - query: string; - /** Service name. */ - serviceName: string; - /** Connection String to connect to ApplicationInsights. */ - connectionString?: string; -} - -/** Dataset as source for evaluation. */ -export interface Dataset extends InputDataParent { - /** Evaluation input data */ - id: string; -} - -/** Target for the evaluation process. */ -export interface EvaluationTarget { - /** System message related to the evaluation target. */ - systemMessage: string; - /** Model configuration for the evaluation. */ - modelConfig: TargetModelConfig; - /** A dictionary of parameters for the model. */ - modelParams?: Record; -} - -/** Abstract class for model configuration. */ -export interface TargetModelConfigParent { - type: string; -} - -/** Azure OpenAI model configuration. The API version would be selected by the service for querying the model. */ -export interface AoaiModelConfig extends TargetModelConfigParent { - /** Endpoint targetURI for AOAI model. */ - azureEndpoint: string; - /** API Key for AOAI model. */ - apiKey: string; - /** Deployment name for AOAI model. */ - azureDeployment: string; -} - -/** MaaS model configuration. The API version would be selected by the service for querying the model. */ -export interface MaasModelConfig extends TargetModelConfigParent { - /** Endpoint targetURI for MAAS model. */ - azureEndpoint: string; - /** API Key for MAAS model. */ - apiKey: string; -} - -/** Metadata pertaining to creation and last modification of the resource. */ -export interface SystemData {} - -/** Evaluator Configuration */ -export interface EvaluatorConfiguration { - /** Identifier of the evaluator. */ - id: string; - /** Initialization parameters of the evaluator. */ - initParams?: Record; - /** Data parameters of the evaluator. */ - dataMapping?: Record; -} - -/** Evaluation Schedule Definition */ -export interface EvaluationSchedule { - /** Data for evaluation. */ - data: ApplicationInsightsConfiguration; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; - /** Trigger for the evaluation. */ - trigger: Trigger; -} - -/** Abstract data class for input data configuration. */ -export interface TriggerParent { - type: string; -} - -/** Recurrence Trigger Definition */ -export interface RecurrenceTrigger extends TriggerParent { - /** - * The frequency to trigger schedule. - * - * Possible values: "Month", "Week", "Day", "Hour", "Minute" - */ - frequency: Frequency; - /** Specifies schedule interval in conjunction with frequency */ - interval: number; - /** The recurrence schedule. */ - schedule?: RecurrenceSchedule; -} - -/** RecurrenceSchedule Definition */ -export interface RecurrenceSchedule { - /** List of hours for the schedule. */ - hours: number[]; - /** List of minutes for the schedule. */ - minutes: number[]; - /** List of days for the schedule. */ - weekDays?: WeekDays[]; - /** List of month days for the schedule */ - monthDays?: number[]; -} - -/** Cron Trigger Definition */ -export interface CronTrigger extends TriggerParent { - /** Cron expression for the trigger. */ - expression: string; -} - -/** An abstract representation of an input tool definition that an agent can use. */ -export type ToolDefinition = - | ToolDefinitionParent - | CodeInterpreterToolDefinition - | FileSearchToolDefinition - | FunctionToolDefinition - | BingGroundingToolDefinition - | MicrosoftFabricToolDefinition - | SharepointToolDefinition - | AzureAISearchToolDefinition - | OpenApiToolDefinition - | BingCustomSearchToolDefinition - | AzureFunctionToolDefinition; -/** authentication details for OpenApiFunctionDefinition */ -export type OpenApiAuthDetails = - | OpenApiAuthDetailsParent - | OpenApiAnonymousAuthDetails - | OpenApiConnectionAuthDetails - | OpenApiManagedAuthDetails; -/** Defines a single content block when creating a message. The 'type' field determines whether it is text, an image file, or an external image URL, etc. */ -export type MessageContentBlockInput = - | MessageContentBlockInputParent - | MessageTextBlockInput - | MessageImageFileBlockInput - | MessageImageUrlBlockInput; -/** An abstract representation of a vector store chunking strategy configuration. */ -export type VectorStoreChunkingStrategyRequest = - | VectorStoreChunkingStrategyRequestParent - | VectorStoreAutoChunkingStrategyRequest - | VectorStoreStaticChunkingStrategyRequest; -/** Abstract data class for input data configuration. */ -export type InputData = InputDataParent | ApplicationInsightsConfiguration | Dataset; -/** Abstract class for model configuration. */ -export type TargetModelConfig = TargetModelConfigParent | AoaiModelConfig | MaasModelConfig; -/** Abstract data class for input data configuration. */ -export type Trigger = TriggerParent | RecurrenceTrigger | CronTrigger; -/** Alias for OpenApiAuthType */ -export type OpenApiAuthType = string; -/** Alias for VectorStoreDataSourceAssetType */ -export type VectorStoreDataSourceAssetType = string; -/** Alias for AzureAISearchQueryType */ -export type AzureAISearchQueryType = string; -/** Alias for AgentsApiResponseFormatMode */ -export type AgentsApiResponseFormatMode = string; -/** Alias for ResponseFormat */ -export type ResponseFormat = string; -/** Alias for AgentsApiResponseFormatOption */ -export type AgentsApiResponseFormatOption = - | string - | AgentsApiResponseFormatMode - | AgentsApiResponseFormat - | ResponseFormatJsonSchemaType; -/** Alias for ListSortOrder */ -export type ListSortOrder = string; -/** Alias for MessageRole */ -export type MessageRole = string; -/** Alias for MessageBlockType */ -export type MessageBlockType = string; -/** Alias for ImageDetailLevel */ -export type ImageDetailLevel = string; -/** Alias for CreateMessageContent */ -export type CreateMessageContent = string | Array; -/** Alias for MessageAttachmentToolDefinition */ -export type MessageAttachmentToolDefinition = - | CodeInterpreterToolDefinition - | FileSearchToolDefinition; -/** Alias for RunAdditionalFieldList */ -export type RunAdditionalFieldList = string; -/** Alias for TruncationStrategy */ -export type TruncationStrategy = string; -/** Alias for AgentsApiToolChoiceOptionMode */ -export type AgentsApiToolChoiceOptionMode = string; -/** Alias for AgentsNamedToolChoiceType */ -export type AgentsNamedToolChoiceType = string; -/** Alias for AgentsApiToolChoiceOption */ -export type AgentsApiToolChoiceOption = - | string - | AgentsApiToolChoiceOptionMode - | AgentsNamedToolChoice; -/** Alias for FilePurpose */ -export type FilePurpose = string; -/** Alias for VectorStoreExpirationPolicyAnchor */ -export type VectorStoreExpirationPolicyAnchor = string; -/** Alias for VectorStoreChunkingStrategyRequestType */ -export type VectorStoreChunkingStrategyRequestType = string; -/** Alias for VectorStoreFileStatusFilter */ -export type VectorStoreFileStatusFilter = string; -/** Alias for ConnectionType */ -export type ConnectionType = string; -/** Alias for Frequency */ -export type Frequency = string; -/** Alias for WeekDays */ -export type WeekDays = string; diff --git a/sdk/ai/ai-projects/src/customization/outputModels.ts b/sdk/ai/ai-projects/src/customization/outputModels.ts deleted file mode 100644 index ee336e424b2f..000000000000 --- a/sdk/ai/ai-projects/src/customization/outputModels.ts +++ /dev/null @@ -1,1712 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** An abstract representation of an input tool definition that an agent can use. */ -export interface ToolDefinitionOutputParent { - type: string; -} - -/** The input definition information for a code interpreter tool as used to configure an agent. */ -export interface CodeInterpreterToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'code_interpreter'. */ - type: "code_interpreter"; -} - -/** The input definition information for a file search tool as used to configure an agent. */ -export interface FileSearchToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'file_search'. */ - type: "file_search"; - /** Options overrides for the file search tool. */ - fileSearch?: FileSearchToolDefinitionDetailsOutput; -} - -/** Options overrides for the file search tool. */ -export interface FileSearchToolDefinitionDetailsOutput { - /** - * The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. - * - * Note that the file search tool may output fewer than `maxNumResults` results. See the file search tool documentation for more information. - */ - maxNumResults?: number; - /** Ranking options for file search. */ - rankingOptions?: FileSearchRankingOptionsOutput; -} - -/** Ranking options for file search. */ -export interface FileSearchRankingOptionsOutput { - /** File search ranker. */ - ranker: string; - /** Ranker search threshold. */ - scoreThreshold: number; -} - -/** The input definition information for a function tool as used to configure an agent. */ -export interface FunctionToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'function'. */ - type: "function"; - /** The definition of the concrete function that the function tool should call. */ - function: FunctionDefinitionOutput; -} - -/** The input definition information for a function. */ -export interface FunctionDefinitionOutput { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The parameters the functions accepts, described as a JSON Schema object. */ - parameters: any; -} - -/** The input definition information for a bing grounding search tool as used to configure an agent. */ -export interface BingGroundingToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'bing_grounding'. */ - type: "bing_grounding"; - /** The list of connections used by the bing grounding tool. */ - bingGrounding: ToolConnectionListOutput; -} - -/** The input definition information for a bing custom search tool as used to configure an agent. */ -export interface BingCustomSearchToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'bing_custom_search'. */ - type: "bing_custom_search"; - /** The list of connections used by the bing custom search tool. */ - bingCustomSearch?: SearchConfigurationListOutput; -} - -/** A set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or `sharepoint_grounding` tools. */ -export interface ToolConnectionListOutput { - /** - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - connections?: Array; -} - -/** An array of connection resources currently used by the `bing_custom_search` tool. */ -export interface SearchConfigurationListOutput { - /** The connections attached to this tool. */ - searchConfigurations?: Array; -} - -/** The connection information for a search configuration. This is used by the `bing_custom_search` tool. */ -export interface SearchConfigurationOutput { - /** The connection ID of the search configuration. */ - connectionId: string; - /** The name of the search configuration. */ - instanceName: string; -} - -/** A connection resource. */ -export interface ToolConnectionOutput { - /** A connection in a ToolConnectionList attached to this tool. */ - connectionId: string; -} - -/** The input definition information for a Microsoft Fabric tool as used to configure an agent. */ -export interface MicrosoftFabricToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'fabric_dataagent'. */ - type: "fabric_dataagent"; - /** The list of connections used by the Microsoft Fabric tool. */ - fabricDataAgent: ToolConnectionListOutput; -} - -/** The input definition information for a sharepoint tool as used to configure an agent. */ -export interface SharepointToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'sharepoint_grounding'. */ - type: "sharepoint_grounding"; - /** The list of connections used by the SharePoint tool. */ - sharepointGrounding: ToolConnectionListOutput; -} - -/** The input definition information for an Azure AI search tool as used to configure an agent. */ -export interface AzureAISearchToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'azure_ai_search'. */ - type: "azure_ai_search"; -} - -/** The input definition information for an OpenAPI tool as used to configure an agent. */ -export interface OpenApiToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'openapi'. */ - type: "openapi"; - /** The openapi function definition. */ - openapi: OpenApiFunctionDefinitionOutput; -} - -/** The input definition information for an openapi function. */ -export interface OpenApiFunctionDefinitionOutput { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The openapi function shape, described as a JSON Schema object. */ - spec: any; - /** Open API authentication details */ - auth: OpenApiAuthDetailsOutput; -} - -/** authentication details for OpenApiFunctionDefinition */ -export interface OpenApiAuthDetailsOutputParent { - type: OpenApiAuthTypeOutput; -} - -/** Security details for OpenApi anonymous authentication */ -export interface OpenApiAnonymousAuthDetailsOutput extends OpenApiAuthDetailsOutputParent { - /** The object type, which is always 'anonymous'. */ - type: "anonymous"; -} - -/** Security details for OpenApi connection authentication */ -export interface OpenApiConnectionAuthDetailsOutput extends OpenApiAuthDetailsOutputParent { - /** The object type, which is always 'connection'. */ - type: "connection"; - /** Connection auth security details */ - securityScheme: OpenApiConnectionSecuritySchemeOutput; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiConnectionSecuritySchemeOutput { - /** Connection id for Connection auth type */ - connectionId: string; -} - -/** Security details for OpenApi managed_identity authentication */ -export interface OpenApiManagedAuthDetailsOutput extends OpenApiAuthDetailsOutputParent { - /** The object type, which is always 'managed_identity'. */ - type: "managed_identity"; - /** Connection auth security details */ - securityScheme: OpenApiManagedSecuritySchemeOutput; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiManagedSecuritySchemeOutput { - /** Authentication scope for managed_identity auth type */ - audience: string; -} - -/** The input definition information for a azure function tool as used to configure an agent. */ -export interface AzureFunctionToolDefinitionOutput extends ToolDefinitionOutputParent { - /** The object type, which is always 'azure_function'. */ - type: "azure_function"; - /** The definition of the concrete function that the function tool should call. */ - azureFunction: AzureFunctionDefinitionOutput; -} - -/** The definition of Azure function. */ -export interface AzureFunctionDefinitionOutput { - /** The definition of azure function and its parameters. */ - function: FunctionDefinitionOutput; - /** Input storage queue. The queue storage trigger runs a function as messages are added to it. */ - inputBinding: AzureFunctionBindingOutput; - /** Output storage queue. The function writes output to this queue when the input items are processed. */ - outputBinding: AzureFunctionBindingOutput; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionBindingOutput { - /** The type of binding, which is always 'storage_queue'. */ - type: "storage_queue"; - /** Storage queue. */ - storageQueue: AzureFunctionStorageQueueOutput; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionStorageQueueOutput { - /** URI to the Azure Storage Queue service allowing you to manipulate a queue. */ - queueServiceEndpoint: string; - /** The name of an Azure function storage queue. */ - queueName: string; -} - -/** - * A set of resources that are used by the agent's tools. The resources are specific to the type of - * tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` - * tool requires a list of vector store IDs. - */ -export interface ToolResourcesOutput { - /** Resources to be used by the `code_interpreter` tool consisting of file IDs. */ - codeInterpreter?: CodeInterpreterToolResourceOutput; - /** Resources to be used by the `file_search` tool consisting of vector store IDs. */ - fileSearch?: FileSearchToolResourceOutput; - /** Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azureAISearch?: AzureAISearchResourceOutput; -} - -/** A set of resources that are used by the `code_interpreter` tool. */ -export interface CodeInterpreterToolResourceOutput { - /** - * A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - fileIds?: string[]; - /** The data sources to be used. This option is mutually exclusive with the `fileIds` property. */ - dataSources?: Array; -} - -/** - * The structure, containing Azure asset URI path and the asset type of the file used as a data source - * for the enterprise file search. - */ -export interface VectorStoreDataSourceOutput { - /** Asset URI. */ - uri: string; - /** - * The asset type - * - * Possible values: "uri_asset", "id_asset" - */ - type: VectorStoreDataSourceAssetTypeOutput; -} - -/** A set of resources that are used by the `file_search` tool. */ -export interface FileSearchToolResourceOutput { - /** - * The ID of the vector store attached to this agent. There can be a maximum of 1 vector - * store attached to the agent. - */ - vectorStoreIds?: string[]; - /** - * The list of vector store configuration objects from Azure. - * This list is limited to one element. - * The only element of this list contains the list of azure asset IDs used by the search tool. - */ - vectorStores?: Array; -} - -/** The structure, containing the list of vector storage configurations i.e. the list of azure asset IDs. */ -export interface VectorStoreConfigurationsOutput { - /** Name */ - name: string; - /** Configurations */ - configuration: VectorStoreConfigurationOutput; -} - -/** - * Vector storage configuration is the list of data sources, used when multiple - * files can be used for the enterprise file search. - */ -export interface VectorStoreConfigurationOutput { - /** Data sources */ - dataSources: Array; -} - -/** A set of index resources used by the `azure_ai_search` tool. */ -export interface AzureAISearchResourceOutput { - /** - * The indices attached to this agent. There can be a maximum of 1 index - * resource attached to the agent. - */ - indexes?: Array; -} - -/** A Index resource. */ -export interface IndexResourceOutput { - /** An index connection id in an IndexResource attached to this agent. */ - indexConnectionId: string; - /** The name of an index in an IndexResource attached to this agent. */ - indexName: string; -} - -/** - * An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. - * If `text` the model can return text or any value needed. - */ -export interface AgentsApiResponseFormatOutput { - /** - * Must be one of `text` or `json_object`. - * - * Possible values: "text", "json_object" - */ - type?: ResponseFormatOutput; -} - -/** The type of response format being defined: `json_schema` */ -export interface ResponseFormatJsonSchemaTypeOutput { - /** Type */ - type: "json_schema"; - /** The JSON schema, describing response format. */ - jsonSchema: ResponseFormatJsonSchemaOutput; -} - -/** A description of what the response format is for, used by the model to determine how to respond in the format. */ -export interface ResponseFormatJsonSchemaOutput { - /** A description of what the response format is for, used by the model to determine how to respond in the format. */ - description?: string; - /** The name of a schema. */ - name: string; - /** The JSON schema object, describing the response format. */ - schema: any; -} - -/** Represents an agent that can call the model and use tools. */ -export interface AgentOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always assistant. */ - object: "assistant"; - /** The Unix timestamp, in seconds, representing when this object was created. */ - createdAt: Date; - /** The name of the agent. */ - name: string | null; - /** The description of the agent. */ - description: string | null; - /** The ID of the model to use. */ - model: string; - /** The system instructions for the agent to use. */ - instructions: string | null; - /** The collection of tools enabled for the agent. */ - tools: Array; - /** - * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` - * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - */ - toolResources: ToolResourcesOutput | null; - /** - * 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. - */ - temperature: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - topP: number | null; - /** The response format of the tool calls used by this agent. */ - responseFormat?: AgentsApiResponseFormatOptionOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfAgentOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - firstId: string; - /** The last ID represented in this list. */ - lastId: string; - /** A value indicating whether there are additional values available not captured in this list. */ - hasMore: boolean; -} - -/** The status of an agent deletion operation. */ -export interface AgentDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'assistant.deleted'. */ - object: "assistant.deleted"; -} - -/** This describes to which tools a file has been attached. */ -export interface MessageAttachmentOutput { - /** The ID of the file to attach to the message. */ - fileId?: string; - /** Azure asset ID. */ - dataSource?: VectorStoreDataSourceOutput; - /** The tools to add to this file. */ - tools: MessageAttachmentToolDefinitionOutput[]; -} - -/** Information about a single thread associated with an agent. */ -export interface AgentThreadOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread'. */ - object: "thread"; - /** The Unix timestamp, in seconds, representing when this object was created. */ - createdAt: Date; - /** - * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type - * of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list - * of vector store IDs. - */ - toolResources: ToolResourcesOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** The status of a thread deletion operation. */ -export interface ThreadDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'thread.deleted'. */ - object: "thread.deleted"; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfAgentThreadOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - firstId: string; - /** The last ID represented in this list. */ - lastId: string; - /** A value indicating whether there are additional values available not captured in this list. */ - hasMore: boolean; -} - -/** A single, existing message within an agent thread. */ -export interface ThreadMessageOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread.message'. */ - object: "thread.message"; - /** The Unix timestamp, in seconds, representing when this object was created. */ - createdAt: Date; - /** The ID of the thread that this message belongs to. */ - threadId: string; - /** - * The status of the message. - * - * Possible values: "in_progress", "incomplete", "completed" - */ - status: MessageStatusOutput; - /** On an incomplete message, details about why the message is incomplete. */ - incompleteDetails: MessageIncompleteDetailsOutput | null; - /** The Unix timestamp (in seconds) for when the message was completed. */ - completedAt: Date | null; - /** The Unix timestamp (in seconds) for when the message was marked as incomplete. */ - incompleteAt: Date | null; - /** - * The role associated with the agent thread message. - * - * Possible values: "user", "assistant" - */ - role: MessageRoleOutput; - /** The list of content items associated with the agent thread message. */ - content: Array; - /** If applicable, the ID of the agent that authored this message. */ - assistantId: string | null; - /** If applicable, the ID of the run associated with the authoring of this message. */ - runId: string | null; - /** A list of files attached to the message, and the tools they were added to. */ - attachments: Array | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** Information providing additional detail about a message entering an incomplete status. */ -export interface MessageIncompleteDetailsOutput { - /** - * The provided reason describing why the message was marked as incomplete. - * - * Possible values: "content_filter", "max_tokens", "run_cancelled", "run_failed", "run_expired" - */ - reason: MessageIncompleteDetailsReasonOutput; -} - -/** An abstract representation of a single item of thread message content. */ -export interface MessageContentOutputParent { - type: string; -} - -/** A representation of a textual item of thread message content. */ -export interface MessageTextContentOutput extends MessageContentOutputParent { - /** The object type, which is always 'text'. */ - type: "text"; - /** The text and associated annotations for this thread message content item. */ - text: MessageTextDetailsOutput; -} - -/** The text and associated annotations for a single item of agent thread message content. */ -export interface MessageTextDetailsOutput { - /** The text data. */ - value: string; - /** A list of annotations associated with this text. */ - annotations: Array; -} - -/** An abstract representation of an annotation to text thread message content. */ -export interface MessageTextAnnotationOutputParent { - /** The textual content associated with this text annotation item. */ - text: string; - type: string; -} - -/** A citation within the message that points to a specific quote from a specific File associated with the agent or the message. Generated when the agent uses the 'file_search' tool to search files. */ -export interface MessageTextFileCitationAnnotationOutput extends MessageTextAnnotationOutputParent { - /** The object type, which is always 'file_citation'. */ - type: "file_citation"; - /** - * A citation within the message that points to a specific quote from a specific file. - * Generated when the agent uses the "file_search" tool to search files. - */ - fileCitation: MessageTextFileCitationDetailsOutput; - /** The first text index associated with this text annotation. */ - startIndex?: number; - /** The last text index associated with this text annotation. */ - endIndex?: number; -} - -/** A representation of a file-based text citation, as used in a file-based annotation of text thread message content. */ -export interface MessageTextFileCitationDetailsOutput { - /** The ID of the file associated with this citation. */ - fileId: string; - /** The specific quote cited in the associated file. */ - quote: string; -} - -/** A citation within the message that points to a file located at a specific path. */ -export interface MessageTextFilePathAnnotationOutput extends MessageTextAnnotationOutputParent { - /** The object type, which is always 'file_path'. */ - type: "file_path"; - /** A URL for the file that's generated when the agent used the code_interpreter tool to generate a file. */ - filePath: MessageTextFilePathDetailsOutput; - /** The first text index associated with this text annotation. */ - startIndex?: number; - /** The last text index associated with this text annotation. */ - endIndex?: number; -} - -/** An encapsulation of an image file ID, as used by message image content. */ -export interface MessageTextFilePathDetailsOutput { - /** The ID of the specific file that the citation is from. */ - fileId: string; -} - -/** A representation of image file content in a thread message. */ -export interface MessageImageFileContentOutput extends MessageContentOutputParent { - /** The object type, which is always 'image_file'. */ - type: "image_file"; - /** The image file for this thread message content item. */ - imageFile: MessageImageFileDetailsOutput; -} - -/** An image reference, as represented in thread message content. */ -export interface MessageImageFileDetailsOutput { - /** The ID for the file associated with this image. */ - fileId: string; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfThreadMessageOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - firstId: string; - /** The last ID represented in this list. */ - lastId: string; - /** A value indicating whether there are additional values available not captured in this list. */ - hasMore: boolean; -} - -/** - * Controls for how a thread will be truncated prior to the run. Use this to control the initial - * context window of the run. - */ -export interface TruncationObjectOutput { - /** - * The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will - * be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread - * will be dropped to fit the context length of the model, `max_prompt_tokens`. - * - * Possible values: "auto", "last_messages" - */ - type: TruncationStrategyOutput; - /** The number of most recent messages from the thread when constructing the context for the run. */ - lastMessages?: number | null; -} - -/** Specifies a tool the model should use. Use to force the model to call a specific tool. */ -export interface AgentsNamedToolChoiceOutput { - /** - * the type of tool. If type is `function`, the function name must be set. - * - * Possible values: "function", "code_interpreter", "file_search", "bing_grounding", "fabric_dataagent", "sharepoint_grounding", "azure_ai_search" - */ - type: AgentsNamedToolChoiceTypeOutput; - /** The name of the function to call */ - function?: FunctionNameOutput; -} - -/** The function name that will be used, if using the `function` tool */ -export interface FunctionNameOutput { - /** The name of the function to call */ - name: string; -} - -/** Data representing a single evaluation run of an agent thread. */ -export interface ThreadRunOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread.run'. */ - object: "thread.run"; - /** The ID of the thread associated with this run. */ - threadId: string; - /** The ID of the agent associated with the thread this run was performed against. */ - assistantId: string; - /** - * The status of the agent thread run. - * - * Possible values: "queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", "expired" - */ - status: RunStatusOutput; - /** The details of the action required for the agent thread run to continue. */ - requiredAction?: RequiredActionOutput | null; - /** The last error, if any, encountered by this agent thread run. */ - lastError: RunErrorOutput | null; - /** The ID of the model to use. */ - model: string; - /** The overridden system instructions used for this agent thread run. */ - instructions: string; - /** The overridden enabled tools used for this agent thread run. */ - tools: Array; - /** The Unix timestamp, in seconds, representing when this object was created. */ - createdAt: Date; - /** The Unix timestamp, in seconds, representing when this item expires. */ - expiresAt: Date | null; - /** The Unix timestamp, in seconds, representing when this item was started. */ - startedAt: Date | null; - /** The Unix timestamp, in seconds, representing when this completed. */ - completedAt: Date | null; - /** The Unix timestamp, in seconds, representing when this was cancelled. */ - cancelledAt: Date | null; - /** The Unix timestamp, in seconds, representing when this failed. */ - failedAt: Date | null; - /** Details on why the run is incomplete. Will be `null` if the run is not incomplete. */ - incompleteDetails: IncompleteRunDetailsOutput | null; - /** Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). */ - usage: RunCompletionUsageOutput | null; - /** The sampling temperature used for this run. If not set, defaults to 1. */ - temperature?: number | null; - /** The nucleus sampling value used for this run. If not set, defaults to 1. */ - topP?: number | null; - /** The maximum number of prompt tokens specified to have been used over the course of the run. */ - maxPromptTokens: number | null; - /** The maximum number of completion tokens specified to have been used over the course of the run. */ - maxCompletionTokens: number | null; - /** The strategy to use for dropping messages as the context windows moves forward. */ - truncationStrategy: TruncationObjectOutput | null; - /** Controls whether or not and which tool is called by the model. */ - toolChoice: AgentsApiToolChoiceOptionOutput | null; - /** The response format of the tool calls used in this run. */ - responseFormat: AgentsApiResponseFormatOptionOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; - /** Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis */ - toolResources?: UpdateToolResourcesOptionsOutput | null; - /** Determines if tools can be executed in parallel within the run. */ - parallelToolCalls: boolean; -} - -/** An abstract representation of a required action for an agent thread run to continue. */ -export interface RequiredActionOutputParent { - type: string; -} - -/** The details for required tool calls that must be submitted for an agent thread run to continue. */ -export interface SubmitToolOutputsActionOutput extends RequiredActionOutputParent { - /** The object type, which is always 'submit_tool_outputs'. */ - type: "submit_tool_outputs"; - /** The details describing tools that should be called to submit tool outputs. */ - submitToolOutputs: SubmitToolOutputsDetailsOutput; -} - -/** The details describing tools that should be called to submit tool outputs. */ -export interface SubmitToolOutputsDetailsOutput { - /** The list of tool calls that must be resolved for the agent thread run to continue. */ - toolCalls: Array; -} - -/** An abstract representation of a tool invocation needed by the model to continue a run. */ -export interface RequiredToolCallOutputParent { - /** The ID of the tool call. This ID must be referenced when submitting tool outputs. */ - id: string; - type: string; -} - -/** A representation of a requested call to a function tool, needed by the model to continue evaluation of a run. */ -export interface RequiredFunctionToolCallOutput extends RequiredToolCallOutputParent { - /** The object type of the required tool call. Always 'function' for function tools. */ - type: "function"; - /** Detailed information about the function to be executed by the tool that includes name and arguments. */ - function: RequiredFunctionToolCallDetailsOutput; -} - -/** The detailed information for a function invocation, as provided by a required action invoking a function tool, that includes the name of and arguments to the function. */ -export interface RequiredFunctionToolCallDetailsOutput { - /** The name of the function. */ - name: string; - /** The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. */ - arguments: string; -} - -/** The details of an error as encountered by an agent thread run. */ -export interface RunErrorOutput { - /** The status for the error. */ - code: string; - /** The human-readable text associated with the error. */ - message: string; -} - -/** Details on why the run is incomplete. Will be `null` if the run is not incomplete. */ -export interface IncompleteRunDetailsOutput { - /** - * The reason why the run is incomplete. This indicates which specific token limit was reached during the run. - * - * Possible values: "max_completion_tokens", "max_prompt_tokens" - */ - reason: IncompleteDetailsReasonOutput; -} - -/** Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). */ -export interface RunCompletionUsageOutput { - /** Number of completion tokens used over the course of the run. */ - completionTokens: number; - /** Number of prompt tokens used over the course of the run. */ - promptTokens: number; - /** Total number of tokens used (prompt + completion). */ - totalTokens: number; -} - -/** - * Request object. A set of resources that are used by the agent's tools. The resources are specific to the type of tool. - * For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of - * vector store IDs. - */ -export interface UpdateToolResourcesOptionsOutput { - /** - * Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - codeInterpreter?: UpdateCodeInterpreterToolResourceOptionsOutput; - /** Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. */ - fileSearch?: UpdateFileSearchToolResourceOptionsOutput; - /** Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azureAISearch?: AzureAISearchResourceOutput; -} - -/** Request object to update `code_interpreted` tool resources. */ -export interface UpdateCodeInterpreterToolResourceOptionsOutput { - /** A list of file IDs to override the current list of the agent. */ - fileIds?: string[]; -} - -/** Request object to update `file_search` tool resources. */ -export interface UpdateFileSearchToolResourceOptionsOutput { - /** A list of vector store IDs to override the current list of the agent. */ - vectorStoreIds?: string[]; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfThreadRunOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - firstId: string; - /** The last ID represented in this list. */ - lastId: string; - /** A value indicating whether there are additional values available not captured in this list. */ - hasMore: boolean; -} - -/** Detailed information about a single step of an agent thread run. */ -export interface RunStepOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread.run.step'. */ - object: "thread.run.step"; - /** - * The type of run step, which can be either message_creation or tool_calls. - * - * Possible values: "message_creation", "tool_calls" - */ - type: RunStepTypeOutput; - /** The ID of the agent associated with the run step. */ - assistantId: string; - /** The ID of the thread that was run. */ - threadId: string; - /** The ID of the run that this run step is a part of. */ - runId: string; - /** - * The status of this run step. - * - * Possible values: "in_progress", "cancelled", "failed", "completed", "expired" - */ - status: RunStepStatusOutput; - /** The details for this run step. */ - stepDetails: RunStepDetailsOutput; - /** If applicable, information about the last error encountered by this run step. */ - lastError: RunStepErrorOutput | null; - /** The Unix timestamp, in seconds, representing when this object was created. */ - createdAt: Date; - /** The Unix timestamp, in seconds, representing when this item expired. */ - expiredAt: Date | null; - /** The Unix timestamp, in seconds, representing when this completed. */ - completedAt: Date | null; - /** The Unix timestamp, in seconds, representing when this was cancelled. */ - cancelledAt: Date | null; - /** The Unix timestamp, in seconds, representing when this failed. */ - failedAt: Date | null; - /** Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. */ - usage?: RunStepCompletionUsageOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** An abstract representation of the details for a run step. */ -export interface RunStepDetailsOutputParent { - type: RunStepTypeOutput; -} - -/** The detailed information associated with a message creation run step. */ -export interface RunStepMessageCreationDetailsOutput extends RunStepDetailsOutputParent { - /** The object type, which is always 'message_creation'. */ - type: "message_creation"; - /** Information about the message creation associated with this run step. */ - messageCreation: RunStepMessageCreationReferenceOutput; -} - -/** The details of a message created as a part of a run step. */ -export interface RunStepMessageCreationReferenceOutput { - /** The ID of the message created by this run step. */ - messageId: string; -} - -/** The detailed information associated with a run step calling tools. */ -export interface RunStepToolCallDetailsOutput extends RunStepDetailsOutputParent { - /** The object type, which is always 'tool_calls'. */ - type: "tool_calls"; - /** A list of tool call details for this run step. */ - toolCalls: Array; -} - -/** An abstract representation of a detailed tool call as recorded within a run step for an existing run. */ -export interface RunStepToolCallOutputParent { - /** The ID of the tool call. This ID must be referenced when you submit tool outputs. */ - id: string; - type: string; -} - -/** - * A record of a call to a code interpreter tool, issued by the model in evaluation of a defined tool, that - * represents inputs and outputs consumed and emitted by the code interpreter. - */ -export interface RunStepCodeInterpreterToolCallOutput extends RunStepToolCallOutputParent { - /** The object type, which is always 'code_interpreter'. */ - type: "code_interpreter"; - /** The details of the tool call to the code interpreter tool. */ - codeInterpreter: RunStepCodeInterpreterToolCallDetailsOutput; -} - -/** The detailed information about a code interpreter invocation by the model. */ -export interface RunStepCodeInterpreterToolCallDetailsOutput { - /** The input provided by the model to the code interpreter tool. */ - input: string; - /** The outputs produced by the code interpreter tool back to the model in response to the tool call. */ - outputs: Array; -} - -/** An abstract representation of an emitted output from a code interpreter tool. */ -export interface RunStepCodeInterpreterToolCallOutputOutputParent { - type: string; -} - -/** A representation of a log output emitted by a code interpreter tool in response to a tool call by the model. */ -export interface RunStepCodeInterpreterLogOutputOutput - extends RunStepCodeInterpreterToolCallOutputOutputParent { - /** The object type, which is always 'logs'. */ - type: "logs"; - /** The serialized log output emitted by the code interpreter. */ - logs: string; -} - -/** A representation of an image output emitted by a code interpreter tool in response to a tool call by the model. */ -export interface RunStepCodeInterpreterImageOutputOutput - extends RunStepCodeInterpreterToolCallOutputOutputParent { - /** The object type, which is always 'image'. */ - type: "image"; - /** Referential information for the image associated with this output. */ - image: RunStepCodeInterpreterImageReferenceOutput; -} - -/** An image reference emitted by a code interpreter tool in response to a tool call by the model. */ -export interface RunStepCodeInterpreterImageReferenceOutput { - /** The ID of the file associated with this image. */ - fileId: string; -} - -/** - * A record of a call to a file search tool, issued by the model in evaluation of a defined tool, that represents - * executed file search. - */ -export interface RunStepFileSearchToolCallOutput extends RunStepToolCallOutputParent { - /** The object type, which is always 'file_search'. */ - type: "file_search"; - /** The ID of the tool call. This ID must be referenced when you submit tool outputs. */ - id: string; - /** For now, this is always going to be an empty object. */ - fileSearch: RunStepFileSearchToolCallResultsOutput; -} - -/** The results of the file search. */ -export interface RunStepFileSearchToolCallResultsOutput { - /** Ranking options for file search. */ - rankingOptions?: FileSearchRankingOptionsOutput; - /** The array of a file search results */ - results: Array; -} - -/** File search tool call result. */ -export interface RunStepFileSearchToolCallResultOutput { - /** The ID of the file that result was found in. */ - fileId: string; - /** The name of the file that result was found in. */ - fileName: string; - /** The score of the result. All values must be a floating point number between 0 and 1. */ - score: number; - /** The content of the result that was found. The content is only included if requested via the include query parameter. */ - content?: Array; -} - -/** The file search result content object. */ -export interface FileSearchToolCallContentOutput { - /** The type of the content. */ - type: "text"; - /** The text content of the file. */ - text: string; -} - -/** - * A record of a call to a bing grounding tool, issued by the model in evaluation of a defined tool, that represents - * executed search with bing grounding. - */ -export interface RunStepBingGroundingToolCallOutput extends RunStepToolCallOutputParent { - /** The object type, which is always 'bing_grounding'. */ - type: "bing_grounding"; - /** Reserved for future use. */ - bingGrounding: Record; -} - -/** - * A record of a call to an Azure AI Search tool, issued by the model in evaluation of a defined tool, that represents - * executed Azure AI search. - */ -export interface RunStepAzureAISearchToolCallOutput extends RunStepToolCallOutputParent { - /** The object type, which is always 'azure_ai_search'. */ - type: "azure_ai_search"; - /** Reserved for future use. */ - azureAISearch: Record; -} - -/** - * A record of a call to a SharePoint tool, issued by the model in evaluation of a defined tool, that represents - * executed SharePoint actions. - */ -export interface RunStepSharepointToolCallOutput extends RunStepToolCallOutputParent { - /** The object type, which is always 'sharepoint_grounding'. */ - type: "sharepoint_grounding"; - /** Reserved for future use. */ - sharepointGrounding: Record; -} - -/** - * A record of a call to a Microsoft Fabric tool, issued by the model in evaluation of a defined tool, that represents - * executed Microsoft Fabric operations. - */ -export interface RunStepMicrosoftFabricToolCallOutput extends RunStepToolCallOutputParent { - /** The object type, which is always 'fabric_dataagent'. */ - type: "fabric_dataagent"; - /** Reserved for future use. */ - fabricDataAgent: Record; -} - -/** - * A record of a call to a function tool, issued by the model in evaluation of a defined tool, that represents the inputs - * and output consumed and emitted by the specified function. - */ -export interface RunStepFunctionToolCallOutput extends RunStepToolCallOutputParent { - /** The object type, which is always 'function'. */ - type: "function"; - /** The detailed information about the function called by the model. */ - function: RunStepFunctionToolCallDetailsOutput; -} - -/** The detailed information about the function called by the model. */ -export interface RunStepFunctionToolCallDetailsOutput { - /** The name of the function. */ - name: string; - /** The arguments that the model requires are provided to the named function. */ - arguments: string; - /** The output of the function, only populated for function calls that have already have had their outputs submitted. */ - output: string | null; -} - -/** The error information associated with a failed run step. */ -export interface RunStepErrorOutput { - /** - * The error code for this error. - * - * Possible values: "server_error", "rate_limit_exceeded" - */ - code: RunStepErrorCodeOutput; - /** The human-readable text associated with this error. */ - message: string; -} - -/** Usage statistics related to the run step. */ -export interface RunStepCompletionUsageOutput { - /** Number of completion tokens used over the course of the run step. */ - completionTokens: number; - /** Number of prompt tokens used over the course of the run step. */ - promptTokens: number; - /** Total number of tokens used (prompt + completion). */ - totalTokens: number; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfRunStepOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - firstId: string; - /** The last ID represented in this list. */ - lastId: string; - /** A value indicating whether there are additional values available not captured in this list. */ - hasMore: boolean; -} - -/** The response data from a file list operation. */ -export interface FileListResponseOutput { - /** The object type, which is always 'list'. */ - object: "list"; - /** The files returned for the request. */ - data: Array; -} - -/** Represents an agent that can call the model and use tools. */ -export interface OpenAIFileOutput { - /** The object type, which is always 'file'. */ - object: "file"; - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The size of the file, in bytes. */ - bytes: number; - /** The name of the file. */ - filename: string; - /** The Unix timestamp, in seconds, representing when this object was created. */ - createdAt: Date; - /** - * The intended purpose of a file. - * - * Possible values: "fine-tune", "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision" - */ - purpose: FilePurposeOutput; - /** - * The state of the file. This field is available in Azure OpenAI only. - * - * Possible values: "uploaded", "pending", "running", "processed", "error", "deleting", "deleted" - */ - status?: FileStateOutput; - /** The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. */ - statusDetails?: string; -} - -/** A status response from a file deletion operation. */ -export interface FileDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'file'. */ - object: "file"; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfVectorStoreOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - firstId: string; - /** The last ID represented in this list. */ - lastId: string; - /** A value indicating whether there are additional values available not captured in this list. */ - hasMore: boolean; -} - -/** A vector store is a collection of processed files can be used by the `file_search` tool. */ -export interface VectorStoreOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always `vector_store` */ - object: "vector_store"; - /** The Unix timestamp (in seconds) for when the vector store was created. */ - createdAt: Date; - /** The name of the vector store. */ - name: string; - /** The total number of bytes used by the files in the vector store. */ - usageBytes: number; - /** Files count grouped by status processed or being processed by this vector store. */ - fileCounts: VectorStoreFileCountOutput; - /** - * The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. - * - * Possible values: "expired", "in_progress", "completed" - */ - status: VectorStoreStatusOutput; - /** Details on when this vector store expires */ - expiresAfter?: VectorStoreExpirationPolicyOutput; - /** The Unix timestamp (in seconds) for when the vector store will expire. */ - expiresAt?: Date | null; - /** The Unix timestamp (in seconds) for when the vector store was last active. */ - lastActiveAt: Date | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** Counts of files processed or being processed by this vector store grouped by status. */ -export interface VectorStoreFileCountOutput { - /** The number of files that are currently being processed. */ - inProgress: number; - /** The number of files that have been successfully processed. */ - completed: number; - /** The number of files that have failed to process. */ - failed: number; - /** The number of files that were cancelled. */ - cancelled: number; - /** The total number of files. */ - total: number; -} - -/** The expiration policy for a vector store. */ -export interface VectorStoreExpirationPolicyOutput { - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - * - * Possible values: "last_active_at" - */ - anchor: VectorStoreExpirationPolicyAnchorOutput; - /** The anchor timestamp after which the expiration policy applies. */ - days: number; -} - -/** Options to configure a vector store static chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyOptionsOutput { - /** The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. */ - maxChunkSizeTokens: number; - /** - * The number of tokens that overlap between chunks. The default value is 400. - * Note that the overlap must not exceed half of max_chunk_size_tokens. - */ - chunkOverlapTokens: number; -} - -/** Response object for deleting a vector store. */ -export interface VectorStoreDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'vector_store.deleted'. */ - object: "vector_store.deleted"; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfVectorStoreFileOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - firstId: string; - /** The last ID represented in this list. */ - lastId: string; - /** A value indicating whether there are additional values available not captured in this list. */ - hasMore: boolean; -} - -/** Description of a file attached to a vector store. */ -export interface VectorStoreFileOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always `vector_store.file`. */ - object: "vector_store.file"; - /** - * The total vector store usage in bytes. Note that this may be different from the original file - * size. - */ - usageBytes: number; - /** The Unix timestamp (in seconds) for when the vector store file was created. */ - createdAt: Date; - /** The ID of the vector store that the file is attached to. */ - vectorStoreId: string; - /** - * The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. - * - * Possible values: "in_progress", "completed", "failed", "cancelled" - */ - status: VectorStoreFileStatusOutput; - /** The last error associated with this vector store file. Will be `null` if there are no errors. */ - lastError: VectorStoreFileErrorOutput | null; - /** The strategy used to chunk the file. */ - chunkingStrategy: VectorStoreChunkingStrategyResponseOutput; -} - -/** Details on the error that may have occurred while processing a file for this vector store */ -export interface VectorStoreFileErrorOutput { - /** - * One of `server_error` or `rate_limit_exceeded`. - * - * Possible values: "server_error", "invalid_file", "unsupported_file" - */ - code: VectorStoreFileErrorCodeOutput; - /** A human-readable description of the error. */ - message: string; -} - -/** An abstract representation of a vector store chunking strategy configuration. */ -export interface VectorStoreChunkingStrategyResponseOutputParent { - type: VectorStoreChunkingStrategyResponseTypeOutput; -} - -/** This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the chunking_strategy concept was introduced in the API. */ -export interface VectorStoreAutoChunkingStrategyResponseOutput - extends VectorStoreChunkingStrategyResponseOutputParent { - /** The object type, which is always 'other'. */ - type: "other"; -} - -/** A statically configured chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyResponseOutput - extends VectorStoreChunkingStrategyResponseOutputParent { - /** The object type, which is always 'static'. */ - type: "static"; - /** The options for the static chunking strategy. */ - static: VectorStoreStaticChunkingStrategyOptionsOutput; -} - -/** Response object for deleting a vector store file relationship. */ -export interface VectorStoreFileDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'vector_store.deleted'. */ - object: "vector_store.file.deleted"; -} - -/** A batch of files attached to a vector store. */ -export interface VectorStoreFileBatchOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always `vector_store.file_batch`. */ - object: "vector_store.files_batch"; - /** The Unix timestamp (in seconds) for when the vector store files batch was created. */ - createdAt: Date; - /** The ID of the vector store that the file is attached to. */ - vectorStoreId: string; - /** - * The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. - * - * Possible values: "in_progress", "completed", "cancelled", "failed" - */ - status: VectorStoreFileBatchStatusOutput; - /** Files count grouped by status processed or being processed by this vector store. */ - fileCounts: VectorStoreFileCountOutput; -} - -/** Response from the Workspace - Get operation */ -export interface GetWorkspaceResponseOutput { - /** A unique identifier for the resource */ - id: string; - /** The name of the resource */ - name: string; - /** The properties of the resource */ - properties: WorkspacePropertiesOutput; -} - -/** workspace properties */ -export interface WorkspacePropertiesOutput { - /** Authentication type of the connection target */ - applicationInsights: string; -} - -/** Response from the list operation */ -export interface ListConnectionsResponseOutput { - /** A list of connection list secrets */ - value: Array; -} - -/** Response from the listSecrets operation */ -export interface GetConnectionResponseOutput { - /** A unique identifier for the connection */ - id: string; - /** The name of the resource */ - name: string; - /** The properties of the resource */ - properties: InternalConnectionPropertiesOutput; -} - -/** Connection properties */ -export interface InternalConnectionPropertiesOutputParent { - /** Category of the connection */ - category: ConnectionTypeOutput; - /** The connection URL to be used for this service */ - target: string; - authType: AuthenticationTypeOutput; -} - -/** Connection properties for connections with API key authentication */ -export interface InternalConnectionPropertiesApiKeyAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "ApiKey"; - /** Credentials will only be present for authType=ApiKey */ - credentials: CredentialsApiKeyAuthOutput; -} - -/** The credentials needed for API key authentication */ -export interface CredentialsApiKeyAuthOutput { - /** The API key */ - key: string; -} - -/** Connection properties for connections with AAD authentication (aka `Entra ID passthrough`) */ -export interface InternalConnectionPropertiesAADAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "AAD"; -} - -/** Connection properties for connections with SAS authentication */ -export interface InternalConnectionPropertiesSASAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "SAS"; - /** Credentials will only be present for authType=ApiKey */ - credentials: CredentialsSASAuthOutput; -} - -/** The credentials needed for Shared Access Signatures (SAS) authentication */ -export interface CredentialsSASAuthOutput { - /** The Shared Access Signatures (SAS) token */ - SAS: string; -} - -/** Response from getting properties of the Application Insights resource */ -export interface GetAppInsightsResponseOutput { - /** A unique identifier for the resource */ - id: string; - /** The name of the resource */ - name: string; - /** The properties of the resource */ - properties: AppInsightsPropertiesOutput; -} - -/** The properties of the Application Insights resource */ -export interface AppInsightsPropertiesOutput { - /** Authentication type of the connection target */ - ConnectionString: string; -} - -/** Evaluation Definition */ -export interface EvaluationOutput { - /** Identifier of the evaluation. */ - readonly id: string; - /** Data for evaluation. */ - data: InputDataOutput; - /** Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. */ - displayName?: string; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Metadata containing createdBy and modifiedBy information. */ - readonly systemData?: SystemDataOutput; - /** Status of the evaluation. It is set by service and is read-only. */ - readonly status?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; -} - -/** Abstract data class for input data configuration. */ -export interface InputDataOutputParent { - type: string; -} - -/** Data Source for Application Insights. */ -export interface ApplicationInsightsConfigurationOutput extends InputDataOutputParent { - readonly type: "app_insights"; - /** LogAnalytic Workspace resourceID associated with ApplicationInsights */ - resourceId: string; - /** Query to fetch the data. */ - query: string; - /** Service name. */ - serviceName: string; - /** Connection String to connect to ApplicationInsights. */ - connectionString?: string; -} - -/** Dataset as source for evaluation. */ -export interface DatasetOutput extends InputDataOutputParent { - readonly type: "dataset"; - /** Evaluation input data */ - id: string; -} - -/** Metadata pertaining to creation and last modification of the resource. */ -export interface SystemDataOutput { - /** The timestamp the resource was created at. */ - readonly createdAt?: string; - /** The identity that created the resource. */ - readonly createdBy?: string; - /** The identity type that created the resource. */ - readonly createdByType?: string; - /** The timestamp of resource last modification (UTC) */ - readonly lastModifiedAt?: string; -} - -/** Evaluator Configuration */ -export interface EvaluatorConfigurationOutput { - /** Identifier of the evaluator. */ - id: string; - /** Initialization parameters of the evaluator. */ - initParams?: Record; - /** Data parameters of the evaluator. */ - dataMapping?: Record; -} - -/** Paged collection of Evaluation items */ -export interface PagedEvaluationOutput { - /** The Evaluation items on this page */ - value: Array; - /** The link to the next page of items */ - nextLink?: string; -} - -/** Evaluation Schedule Definition */ -export interface EvaluationScheduleOutput { - /** Name of the schedule, which also serves as the unique identifier for the evaluation */ - readonly name: string; - /** Data for evaluation. */ - data: ApplicationInsightsConfigurationOutput; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Metadata containing createdBy and modifiedBy information. */ - readonly systemData?: SystemDataOutput; - /** Provisioning State of the evaluation. It is set by service and is read-only. */ - readonly provisioningState?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Enabled status of the evaluation. It is set by service and is read-only. */ - readonly isEnabled?: string; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; - /** Trigger for the evaluation. */ - trigger: TriggerOutput; -} - -/** Abstract data class for input data configuration. */ -export interface TriggerOutputParent { - type: string; -} - -/** Recurrence Trigger Definition */ -export interface RecurrenceTriggerOutput extends TriggerOutputParent { - readonly type: "Recurrence"; - /** - * The frequency to trigger schedule. - * - * Possible values: "Month", "Week", "Day", "Hour", "Minute" - */ - frequency: FrequencyOutput; - /** Specifies schedule interval in conjunction with frequency */ - interval: number; - /** The recurrence schedule. */ - schedule?: RecurrenceScheduleOutput; -} - -/** RecurrenceSchedule Definition */ -export interface RecurrenceScheduleOutput { - /** List of hours for the schedule. */ - hours: number[]; - /** List of minutes for the schedule. */ - minutes: number[]; - /** List of days for the schedule. */ - weekDays?: WeekDaysOutput[]; - /** List of month days for the schedule */ - monthDays?: number[]; -} - -/** Cron Trigger Definition */ -export interface CronTriggerOutput extends TriggerOutputParent { - readonly type: "Cron"; - /** Cron expression for the trigger. */ - expression: string; -} - -/** Paged collection of EvaluationSchedule items */ -export interface PagedEvaluationScheduleOutput { - /** The EvaluationSchedule items on this page */ - value: Array; - /** The link to the next page of items */ - nextLink?: string; -} - -/** An abstract representation of an input tool definition that an agent can use. */ -export type ToolDefinitionOutput = - | ToolDefinitionOutputParent - | CodeInterpreterToolDefinitionOutput - | FileSearchToolDefinitionOutput - | FunctionToolDefinitionOutput - | BingGroundingToolDefinitionOutput - | MicrosoftFabricToolDefinitionOutput - | SharepointToolDefinitionOutput - | AzureAISearchToolDefinitionOutput - | OpenApiToolDefinitionOutput - | BingCustomSearchToolDefinitionOutput - | AzureFunctionToolDefinitionOutput; -/** authentication details for OpenApiFunctionDefinition */ -export type OpenApiAuthDetailsOutput = - | OpenApiAuthDetailsOutputParent - | OpenApiAnonymousAuthDetailsOutput - | OpenApiConnectionAuthDetailsOutput - | OpenApiManagedAuthDetailsOutput; -/** An abstract representation of a single item of thread message content. */ -export type MessageContentOutput = - | MessageContentOutputParent - | MessageTextContentOutput - | MessageImageFileContentOutput; -/** An abstract representation of an annotation to text thread message content. */ -export type MessageTextAnnotationOutput = - | MessageTextAnnotationOutputParent - | MessageTextFileCitationAnnotationOutput - | MessageTextFilePathAnnotationOutput; -/** An abstract representation of a required action for an agent thread run to continue. */ -export type RequiredActionOutput = RequiredActionOutputParent | SubmitToolOutputsActionOutput; -/** An abstract representation of a tool invocation needed by the model to continue a run. */ -export type RequiredToolCallOutput = RequiredToolCallOutputParent | RequiredFunctionToolCallOutput; -/** An abstract representation of the details for a run step. */ -export type RunStepDetailsOutput = - | RunStepDetailsOutputParent - | RunStepMessageCreationDetailsOutput - | RunStepToolCallDetailsOutput; -/** An abstract representation of a detailed tool call as recorded within a run step for an existing run. */ -export type RunStepToolCallOutput = - | RunStepToolCallOutputParent - | RunStepCodeInterpreterToolCallOutput - | RunStepFileSearchToolCallOutput - | RunStepBingGroundingToolCallOutput - | RunStepAzureAISearchToolCallOutput - | RunStepSharepointToolCallOutput - | RunStepMicrosoftFabricToolCallOutput - | RunStepFunctionToolCallOutput; -/** An abstract representation of an emitted output from a code interpreter tool. */ -export type RunStepCodeInterpreterToolCallOutputOutput = - | RunStepCodeInterpreterToolCallOutputOutputParent - | RunStepCodeInterpreterLogOutputOutput - | RunStepCodeInterpreterImageOutputOutput; -/** An abstract representation of a vector store chunking strategy configuration. */ -export type VectorStoreChunkingStrategyResponseOutput = - | VectorStoreChunkingStrategyResponseOutputParent - | VectorStoreAutoChunkingStrategyResponseOutput - | VectorStoreStaticChunkingStrategyResponseOutput; -/** Connection properties */ -export type InternalConnectionPropertiesOutput = - | InternalConnectionPropertiesOutputParent - | InternalConnectionPropertiesApiKeyAuthOutput - | InternalConnectionPropertiesAADAuthOutput - | InternalConnectionPropertiesSASAuthOutput; -/** Abstract data class for input data configuration. */ -export type InputDataOutput = - | InputDataOutputParent - | ApplicationInsightsConfigurationOutput - | DatasetOutput; -/** Abstract data class for input data configuration. */ -export type TriggerOutput = TriggerOutputParent | RecurrenceTriggerOutput | CronTriggerOutput; -/** Alias for OpenApiAuthTypeOutput */ -export type OpenApiAuthTypeOutput = string; -/** Alias for VectorStoreDataSourceAssetTypeOutput */ -export type VectorStoreDataSourceAssetTypeOutput = string; -/** Alias for AgentsApiResponseFormatModeOutput */ -export type AgentsApiResponseFormatModeOutput = string; -/** Alias for ResponseFormatOutput */ -export type ResponseFormatOutput = string; -/** Alias for AgentsApiResponseFormatOptionOutput */ -export type AgentsApiResponseFormatOptionOutput = - | string - | AgentsApiResponseFormatModeOutput - | AgentsApiResponseFormatOutput - | ResponseFormatJsonSchemaTypeOutput; -/** Alias for MessageRoleOutput */ -export type MessageRoleOutput = string; -/** Alias for MessageAttachmentToolDefinitionOutput */ -export type MessageAttachmentToolDefinitionOutput = - | CodeInterpreterToolDefinitionOutput - | FileSearchToolDefinitionOutput; -/** Alias for MessageStatusOutput */ -export type MessageStatusOutput = string; -/** Alias for MessageIncompleteDetailsReasonOutput */ -export type MessageIncompleteDetailsReasonOutput = string; -/** Alias for TruncationStrategyOutput */ -export type TruncationStrategyOutput = string; -/** Alias for AgentsApiToolChoiceOptionModeOutput */ -export type AgentsApiToolChoiceOptionModeOutput = string; -/** Alias for AgentsNamedToolChoiceTypeOutput */ -export type AgentsNamedToolChoiceTypeOutput = string; -/** Alias for AgentsApiToolChoiceOptionOutput */ -export type AgentsApiToolChoiceOptionOutput = - | string - | AgentsApiToolChoiceOptionModeOutput - | AgentsNamedToolChoiceOutput; -/** Alias for RunStatusOutput */ -export type RunStatusOutput = string; -/** Alias for IncompleteDetailsReasonOutput */ -export type IncompleteDetailsReasonOutput = string; -/** Alias for RunStepTypeOutput */ -export type RunStepTypeOutput = string; -/** Alias for RunStepStatusOutput */ -export type RunStepStatusOutput = string; -/** Alias for RunStepErrorCodeOutput */ -export type RunStepErrorCodeOutput = string; -/** Alias for FilePurposeOutput */ -export type FilePurposeOutput = string; -/** Alias for FileStateOutput */ -export type FileStateOutput = string; -/** Alias for VectorStoreStatusOutput */ -export type VectorStoreStatusOutput = string; -/** Alias for VectorStoreExpirationPolicyAnchorOutput */ -export type VectorStoreExpirationPolicyAnchorOutput = string; -/** Alias for VectorStoreFileStatusOutput */ -export type VectorStoreFileStatusOutput = string; -/** Alias for VectorStoreFileErrorCodeOutput */ -export type VectorStoreFileErrorCodeOutput = string; -/** Alias for VectorStoreChunkingStrategyResponseTypeOutput */ -export type VectorStoreChunkingStrategyResponseTypeOutput = string; -/** Alias for VectorStoreFileBatchStatusOutput */ -export type VectorStoreFileBatchStatusOutput = string; -/** The Type (or category) of the connection */ -export type ConnectionTypeOutput = - | "AzureOpenAI" - | "Serverless" - | "AzureBlob" - | "AIServices" - | "CognitiveSearch"; -/** Authentication type used by Azure AI service to connect to another service */ -export type AuthenticationTypeOutput = "ApiKey" | "AAD" | "SAS"; -/** Alias for FrequencyOutput */ -export type FrequencyOutput = string; -/** Alias for WeekDaysOutput */ -export type WeekDaysOutput = string; diff --git a/sdk/ai/ai-projects/src/customization/parameters.ts b/sdk/ai/ai-projects/src/customization/parameters.ts deleted file mode 100644 index 5ed2c2311f54..000000000000 --- a/sdk/ai/ai-projects/src/customization/parameters.ts +++ /dev/null @@ -1,512 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline"; -import type { RequestParameters } from "@azure-rest/core-client"; -import type { - CreateAgentOptions, - ListSortOrder, - UpdateAgentOptions, - AgentThreadCreationOptions, - UpdateAgentThreadOptions, - ThreadMessageOptions, - CreateRunOptions, - ToolOutput, - CreateAndRunThreadOptions, - FilePurpose, - VectorStoreOptions, - VectorStoreUpdateOptions, - VectorStoreFileStatusFilter, - VectorStoreDataSource, - VectorStoreChunkingStrategyRequest, - ConnectionType, - Evaluation, - EvaluationSchedule, -} from "./models.js"; - -export interface CreateAgentBodyParam { - body: CreateAgentOptions; -} - -export type CreateAgentParameters = CreateAgentBodyParam & RequestParameters; - -export interface ListAgentsQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListAgentsQueryParam { - queryParameters?: ListAgentsQueryParamProperties; -} - -export type ListAgentsParameters = ListAgentsQueryParam & RequestParameters; -export type GetAgentParameters = RequestParameters; - -export interface UpdateAgentBodyParam { - body: UpdateAgentOptions; -} - -export type UpdateAgentParameters = UpdateAgentBodyParam & RequestParameters; -export type DeleteAgentParameters = RequestParameters; - -export interface CreateThreadBodyParam { - body: AgentThreadCreationOptions; -} - -export type CreateThreadParameters = CreateThreadBodyParam & RequestParameters; -export type GetThreadParameters = RequestParameters; - -export interface UpdateThreadBodyParam { - body: UpdateAgentThreadOptions; -} - -export type UpdateThreadParameters = UpdateThreadBodyParam & RequestParameters; -export type DeleteThreadParameters = RequestParameters; - -export interface ListThreadsQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListThreadsQueryParam { - queryParameters?: ListThreadsQueryParamProperties; -} - -export type ListThreadsParameters = ListThreadsQueryParam & RequestParameters; - -export interface CreateMessageBodyParam { - body: ThreadMessageOptions; -} - -export type CreateMessageParameters = CreateMessageBodyParam & RequestParameters; - -export interface ListMessagesQueryParamProperties { - /** Filter messages by the run ID that generated them. */ - runId?: string; - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListMessagesQueryParam { - queryParameters?: ListMessagesQueryParamProperties; -} - -export type ListMessagesParameters = ListMessagesQueryParam & RequestParameters; -export type GetMessageParameters = RequestParameters; - -export interface UpdateMessageBodyParam { - body: { metadata?: Record | null }; -} - -export type UpdateMessageParameters = UpdateMessageBodyParam & RequestParameters; - -export interface CreateRunBodyParam { - body: CreateRunOptions; -} - -export type CreateRunParameters = CreateRunBodyParam & RequestParameters; - -export interface ListRunsQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListRunsQueryParam { - queryParameters?: ListRunsQueryParamProperties; -} - -export type ListRunsParameters = ListRunsQueryParam & RequestParameters; -export type GetRunParameters = RequestParameters; - -export interface UpdateRunBodyParam { - body: { metadata?: Record | null }; -} - -export type UpdateRunParameters = UpdateRunBodyParam & RequestParameters; - -export interface SubmitToolOutputsToRunBodyParam { - body: { toolOutputs: Array; stream?: boolean | null }; -} - -export type SubmitToolOutputsToRunParameters = SubmitToolOutputsToRunBodyParam & RequestParameters; -export type CancelRunParameters = RequestParameters; - -export interface CreateThreadAndRunBodyParam { - body: CreateAndRunThreadOptions; -} - -export type CreateThreadAndRunParameters = CreateThreadAndRunBodyParam & RequestParameters; -export type GetRunStepParameters = RequestParameters; - -export interface ListRunStepsQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListRunStepsQueryParam { - queryParameters?: ListRunStepsQueryParamProperties; -} - -export type ListRunStepsParameters = ListRunStepsQueryParam & RequestParameters; - -export interface ListFilesQueryParamProperties { - /** - * The purpose of the file. - * - * Possible values: "fine-tune", "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision" - */ - purpose?: FilePurpose; -} - -export interface ListFilesQueryParam { - queryParameters?: ListFilesQueryParamProperties; -} - -export type ListFilesParameters = ListFilesQueryParam & RequestParameters; - -export interface UploadFileBodyParam { - body: - | FormData - | Array< - | { - name: "file"; - body: string | Uint8Array | ReadableStream | NodeJS.ReadableStream | File; - filename?: string; - contentType?: string; - } - | { - name: "purpose"; - body: FilePurpose; - filename?: string; - contentType?: string; - } - | { name: "filename"; body: string } - >; -} - -export interface UploadFileMediaTypesParam { - /** The name of the file to upload. */ - contentType: "multipart/form-data"; -} - -export type UploadFileParameters = UploadFileMediaTypesParam & - UploadFileBodyParam & - RequestParameters; -export type DeleteFileParameters = RequestParameters; -export type GetFileParameters = RequestParameters; -export type GetFileContentParameters = RequestParameters; - -export interface ListVectorStoresQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListVectorStoresQueryParam { - queryParameters?: ListVectorStoresQueryParamProperties; -} - -export type ListVectorStoresParameters = ListVectorStoresQueryParam & RequestParameters; - -export interface CreateVectorStoreBodyParam { - body: VectorStoreOptions; -} - -export type CreateVectorStoreParameters = CreateVectorStoreBodyParam & RequestParameters; -export type GetVectorStoreParameters = RequestParameters; - -export interface ModifyVectorStoreBodyParam { - body: VectorStoreUpdateOptions; -} - -export type ModifyVectorStoreParameters = ModifyVectorStoreBodyParam & RequestParameters; -export type DeleteVectorStoreParameters = RequestParameters; - -export interface ListVectorStoreFilesQueryParamProperties { - /** - * Filter by file status. - * - * Possible values: "in_progress", "completed", "failed", "cancelled" - */ - filter?: VectorStoreFileStatusFilter; - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListVectorStoreFilesQueryParam { - queryParameters?: ListVectorStoreFilesQueryParamProperties; -} - -export type ListVectorStoreFilesParameters = ListVectorStoreFilesQueryParam & RequestParameters; - -export interface CreateVectorStoreFileBodyParam { - body: { - fileId?: string; - dataSources?: Array; - chunkingStrategy?: VectorStoreChunkingStrategyRequest; - }; -} - -export type CreateVectorStoreFileParameters = CreateVectorStoreFileBodyParam & RequestParameters; -export type GetVectorStoreFileParameters = RequestParameters; -export type DeleteVectorStoreFileParameters = RequestParameters; - -export interface CreateVectorStoreFileBatchBodyParam { - body: { - fileIds?: string[]; - dataSources?: Array; - chunkingStrategy?: VectorStoreChunkingStrategyRequest; - }; -} - -export type CreateVectorStoreFileBatchParameters = CreateVectorStoreFileBatchBodyParam & - RequestParameters; -export type GetVectorStoreFileBatchParameters = RequestParameters; -export type CancelVectorStoreFileBatchParameters = RequestParameters; - -export interface ListVectorStoreFileBatchFilesQueryParamProperties { - /** - * Filter by file status. - * - * Possible values: "in_progress", "completed", "failed", "cancelled" - */ - filter?: VectorStoreFileStatusFilter; - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListVectorStoreFileBatchFilesQueryParam { - queryParameters?: ListVectorStoreFileBatchFilesQueryParamProperties; -} - -export type ListVectorStoreFileBatchFilesParameters = ListVectorStoreFileBatchFilesQueryParam & - RequestParameters; -export type GetWorkspaceParameters = RequestParameters; - -export interface ListConnectionsQueryParamProperties { - /** Category of the workspace connection. */ - category?: ConnectionType; - /** Indicates whether to list datastores. Service default: do not list datastores. */ - includeAll?: boolean; - /** Target of the workspace connection. */ - target?: string; -} - -export interface ListConnectionsQueryParam { - queryParameters?: ListConnectionsQueryParamProperties; -} - -export type ListConnectionsParameters = ListConnectionsQueryParam & RequestParameters; -export type GetConnectionParameters = RequestParameters; - -export interface GetConnectionWithSecretsBodyParam { - body: { ignored: string }; -} - -export type GetConnectionWithSecretsParameters = GetConnectionWithSecretsBodyParam & - RequestParameters; -export type GetAppInsightsParameters = RequestParameters; - -export interface GetHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface GetHeaderParam { - headers?: RawHttpHeadersInput & GetHeaders; -} - -export type GetParameters = GetHeaderParam & RequestParameters; - -export interface CreateBodyParam { - /** Evaluation to run. */ - body: Evaluation; -} - -export type CreateParameters = CreateBodyParam & RequestParameters; - -export interface ListHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface ListQueryParamProperties { - /** The number of result items to return. */ - top?: number; - /** The number of result items to skip. */ - skip?: number; - /** The maximum number of result items per page. */ - maxpagesize?: number; -} - -export interface ListQueryParam { - queryParameters?: ListQueryParamProperties; -} - -export interface ListHeaderParam { - headers?: RawHttpHeadersInput & ListHeaders; -} - -export type ListParameters = ListQueryParam & ListHeaderParam & RequestParameters; - -export interface UpdateHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The resource instance. */ -export type EvaluationResourceMergeAndPatch = Partial; - -export interface UpdateBodyParam { - /** The resource instance. */ - body: EvaluationResourceMergeAndPatch; -} - -export interface UpdateHeaderParam { - headers?: RawHttpHeadersInput & UpdateHeaders; -} - -export interface UpdateMediaTypesParam { - /** This request has a JSON Merge Patch body. */ - contentType: "application/merge-patch+json"; -} - -export type UpdateParameters = UpdateHeaderParam & - UpdateMediaTypesParam & - UpdateBodyParam & - RequestParameters; - -export interface GetScheduleHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface GetScheduleHeaderParam { - headers?: RawHttpHeadersInput & GetScheduleHeaders; -} - -export type GetScheduleParameters = GetScheduleHeaderParam & RequestParameters; - -export interface CreateOrReplaceScheduleHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface CreateOrReplaceScheduleBodyParam { - /** The resource instance. */ - body: EvaluationSchedule; -} - -export interface CreateOrReplaceScheduleHeaderParam { - headers?: RawHttpHeadersInput & CreateOrReplaceScheduleHeaders; -} - -export type CreateOrReplaceScheduleParameters = CreateOrReplaceScheduleHeaderParam & - CreateOrReplaceScheduleBodyParam & - RequestParameters; - -export interface ListScheduleHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface ListScheduleQueryParamProperties { - /** The number of result items to return. */ - top?: number; - /** The number of result items to skip. */ - skip?: number; - /** The maximum number of result items per page. */ - maxpagesize?: number; -} - -export interface ListScheduleQueryParam { - queryParameters?: ListScheduleQueryParamProperties; -} - -export interface ListScheduleHeaderParam { - headers?: RawHttpHeadersInput & ListScheduleHeaders; -} - -export type ListScheduleParameters = ListScheduleQueryParam & - ListScheduleHeaderParam & - RequestParameters; -export type DisableScheduleParameters = RequestParameters; diff --git a/sdk/ai/ai-projects/src/customization/streamingModels.ts b/sdk/ai/ai-projects/src/customization/streamingModels.ts deleted file mode 100644 index 93c38c5e4d8e..000000000000 --- a/sdk/ai/ai-projects/src/customization/streamingModels.ts +++ /dev/null @@ -1,308 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { MessageRole } from "./models.js"; -import type { RunStepFileSearchToolCallResultsOutput } from "./outputModels.js"; - -/** Represents a message delta i.e. any changed fields on a message during streaming. */ -export interface MessageDeltaChunk { - /** The identifier of the message, which can be referenced in API endpoints. */ - id: string; - - /** The object type, which is always `thread.message.delta`. */ - object: "thread.message.delta"; - - /** The delta containing the fields that have changed on the Message. */ - delta: MessageDelta; -} - -/** Represents the typed 'delta' payload within a streaming message delta chunk. */ -export interface MessageDelta { - /** The entity that produced the message. */ - role: MessageRole; - - /** The content of the message as an array of text and/or images. */ - content: Array; -} - -/** Represents the content of a message delta. */ -export type MessageDeltaContent = - | MessageDeltaContentParent - | MessageDeltaTextContent - | MessageDeltaImageFileContent; - -/** The abstract base representation of a partial streamed message content payload. */ -export interface MessageDeltaContentParent { - /** The index of the content part of the message. */ - index: number; - - /** The type of content for this content part. */ - type: string; -} -/** Represents a streamed image file content part within a streaming message delta chunk. */ -export interface MessageDeltaImageFileContent extends MessageDeltaContentParent { - /** The type of content for this content part, which is always "image_file." */ - type: "image_file"; - - /** The image_file data. */ - imageFile?: MessageDeltaImageFileContentObject; -} - -/** Represents the 'image_file' payload within streaming image file content. */ -export interface MessageDeltaImageFileContentObject { - /** The file ID of the image in the message content. */ - fileId?: string; -} - -/** Represents a streamed text content part within a streaming message delta chunk. */ -export interface MessageDeltaTextContent extends MessageDeltaContentParent { - /** The type of content for this content part, which is always "text." */ - type: "text"; - - /** The text content details. */ - text?: MessageDeltaTextContentObject; -} - -/** Represents the data of a streamed text content part within a streaming message delta chunk. */ -export interface MessageDeltaTextContentObject { - /** The data that makes up the text. */ - value?: string; - - /** Annotations for the text. */ - annotations?: Array; -} - -/** Represents a text annotation within a streamed text content part. */ -export type MessageDeltaTextAnnotation = - | MessageDeltaTextAnnotationParent - | MessageDeltaTextFileCitationAnnotation - | MessageDeltaTextFilePathAnnotation; - -/** The abstract base representation of a streamed text content part's text annotation. */ -export interface MessageDeltaTextAnnotationParent { - /** The index of the annotation within a text content part. */ - index: number; - - /** The type of the text content annotation. */ - type: string; -} - -/** Represents a streamed file citation applied to a streaming text content part. */ -export interface MessageDeltaTextFileCitationAnnotation extends MessageDeltaTextAnnotationParent { - /** The type of the text content annotation, which is always "file_citation." */ - type: "file_citation"; - - /** The file citation information. */ - fileCitation?: MessageDeltaTextFileCitationAnnotationObject; - - /** The text in the message content that needs to be replaced */ - text?: string; - - /** The start index of this annotation in the content text. */ - startIndex?: number; - - /** The end index of this annotation in the content text. */ - endIndex?: number; -} - -/** Represents the data of a streamed file citation as applied to a streaming text content part. */ -export interface MessageDeltaTextFileCitationAnnotationObject { - /** The ID of the specific file the citation is from. */ - fileId?: string; - - /** The specific quote in the cited file. */ - quote?: string; -} - -/** Represents a streamed file path annotation applied to a streaming text content part. */ -export interface MessageDeltaTextFilePathAnnotation extends MessageDeltaTextAnnotationParent { - /** The type of the text content annotation, which is always "file_path." */ - type: "file_path"; - - /** The file path information. */ - filePath?: MessageDeltaTextFilePathAnnotationObject; - - /** The start index of this annotation in the content text. */ - startIndex?: number; - - /** The end index of this annotation in the content text. */ - endIndex?: number; - - /** The text in the message content that needs to be replaced */ - text?: string; -} - -/** Represents the data of a streamed file path annotation as applied to a streaming text content part. */ -export interface MessageDeltaTextFilePathAnnotationObject { - /** The file ID for the annotation. */ - fileId?: string; -} - -/** A representation of the URL used for the text citation. */ -export interface MessageDeltaTextUrlCitationDetails { - /** The URL where the citation is from. */ - url?: string; - - /** The title of the URL. */ - title?: string; -} - -/** Represents a run step delta i.e. any changed fields on a run step during streaming. */ -export interface RunStepDeltaChunk { - /** The identifier of the run step, which can be referenced in API endpoints. */ - id: string; - - /** The object type, which is always `thread.run.step.delta`. */ - object: "thread.run.step.delta"; - - /** The delta containing the fields that have changed on the run step. */ - delta: RunStepDelta; -} - -/** Represents the delta payload in a streaming run step delta chunk. */ -export interface RunStepDelta { - /** The details of the run step. */ - stepDetails?: RunStepDeltaDetail; -} - -/** Represents a single run step detail item in a streaming run step's delta payload. */ -export interface RunStepDeltaDetail { - /** The object type for the run step detail object. */ - type: string; -} - -/** Represents a message creation within a streaming run step delta. */ -export interface RunStepDeltaMessageCreation extends RunStepDeltaDetail { - /** The object type, which is always "message_creation." */ - type: "message_creation"; - - /** The message creation data. */ - messageCreation?: RunStepDeltaMessageCreationObject; -} - -/** Represents the data within a streaming run step message creation response object. */ -export interface RunStepDeltaMessageCreationObject { - /** The ID of the newly-created message. */ - messageId?: string; -} - -/** Represents an invocation of tool calls as part of a streaming run step. */ -export interface RunStepDeltaToolCallObject extends RunStepDeltaDetail { - /** The object type, which is always "tool_calls." */ - type: "tool_calls"; - - /** The collection of tool calls for the tool call detail item. */ - toolCalls?: Array; -} - -/** Represents a single tool call within a streaming run step's delta tool call details. */ -export type RunStepDeltaToolCall = - | RunStepDeltaToolCallParent - | RunStepDeltaFunctionToolCall - | RunStepDeltaFileSearchToolCall - | RunStepDeltaCodeInterpreterToolCall; - -/** The abstract base representation of a single tool call within a streaming run step's delta tool call details. */ -export interface RunStepDeltaToolCallParent { - /** The index of the tool call detail in the run step's tool_calls array. */ - index: number; - - /** The ID of the tool call, used when submitting outputs to the run. */ - id: string; - - /** The type of the tool call detail item in a streaming run step's details. */ - type: string; -} - -/** Represents a function tool call within a streaming run step's tool call details. */ -export interface RunStepDeltaFunctionToolCall extends RunStepDeltaToolCallParent { - /** The object type, which is always "function." */ - type: "function"; - - /** The function data for the tool call. */ - function?: RunStepDeltaFunction; -} - -/** Represents a file search tool call within a streaming run step's tool call details. */ -export interface RunStepDeltaFileSearchToolCall extends RunStepDeltaToolCallParent { - /** The object type, which is always "file_search." */ - type: "file_search"; - - /** Reserved for future use. */ - fileSearch?: RunStepFileSearchToolCallResultsOutput; -} - -/** Represents a Code Interpreter tool call within a streaming run step's tool call details. */ -export interface RunStepDeltaCodeInterpreterToolCall extends RunStepDeltaToolCallParent { - /** The object type, which is always "code_interpreter." */ - type: "code_interpreter"; - - /** The Code Interpreter data for the tool call. */ - codeInterpreter?: RunStepDeltaCodeInterpreterDetailItemObject; -} - -/** Represents the function data in a streaming run step delta's function tool call. */ -export interface RunStepDeltaFunction { - /** The name of the function. */ - name?: string; - - /** The arguments passed to the function as input. */ - arguments?: string; - - /** The output of the function, null if outputs have not yet been submitted. */ - output?: string | null; -} - -/** Represents the Code Interpreter data in a streaming run step's tool call output. */ -export type RunStepDeltaCodeInterpreterOutput = - | RunStepDeltaCodeInterpreterOutputParent - | RunStepDeltaCodeInterpreterLogOutput - | RunStepDeltaCodeInterpreterImageOutput; - -/** Represents the Code Interpreter tool call data in a streaming run step's tool calls. */ -export interface RunStepDeltaCodeInterpreterDetailItemObject { - /** The input into the Code Interpreter tool call. */ - input?: string; - - /** - * The outputs from the Code Interpreter tool call. Code Interpreter can output one or more - * items, including text (`logs`) or images (`image`). Each of these are represented by a - * different object type. - */ - outputs?: Array; -} - -/** The abstract base representation of a streaming run step tool call's Code Interpreter tool output. */ -export interface RunStepDeltaCodeInterpreterOutputParent { - /** The index of the output in the streaming run step tool call's Code Interpreter outputs array. */ - index: number; - - /** The type of the streaming run step tool call's Code Interpreter output. */ - type: string; -} - -/** Represents a log output as produced by the Code Interpreter tool and as represented in a streaming run step's delta tool calls collection. */ -export interface RunStepDeltaCodeInterpreterLogOutput - extends RunStepDeltaCodeInterpreterOutputParent { - /** The type of the object, which is always "logs." */ - type: "logs"; - - /** The text output from the Code Interpreter tool call. */ - logs?: string; -} - -/** Represents an image output as produced the Code interpreter tool and as represented in a streaming run step's delta tool calls collection. */ -export interface RunStepDeltaCodeInterpreterImageOutput - extends RunStepDeltaCodeInterpreterOutputParent { - /** The object type, which is always "image." */ - type: "image"; - - /** The image data for the Code Interpreter tool call output. */ - image?: RunStepDeltaCodeInterpreterImageOutputObject; -} - -/** Represents the data for a streaming run step's Code Interpreter tool call image output. */ -export interface RunStepDeltaCodeInterpreterImageOutputObject { - /** The file ID for the image. */ - fileId?: string; -} diff --git a/sdk/ai/ai-projects/src/customization/streamingWireModels.ts b/sdk/ai/ai-projects/src/customization/streamingWireModels.ts deleted file mode 100644 index 3d6f10fe860f..000000000000 --- a/sdk/ai/ai-projects/src/customization/streamingWireModels.ts +++ /dev/null @@ -1,304 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { MessageRole } from "../generated/src/models.js"; -import type { RunStepFileSearchToolCallResultsOutput } from "../generated/src/outputModels.js"; - -/** Represents a message delta i.e. any changed fields on a message during streaming. */ -export interface MessageDeltaChunk { - /** The identifier of the message, which can be referenced in API endpoints. */ - id: string; - - /** The object type, which is always `thread.message.delta`. */ - object: "thread.message.delta"; - - /** The delta containing the fields that have changed on the Message. */ - delta: MessageDelta; -} - -/** Represents the typed 'delta' payload within a streaming message delta chunk. */ -export interface MessageDelta { - /** The entity that produced the message. */ - role: MessageRole; - - /** The content of the message as an array of text and/or images. */ - content: Array; -} - -export type MessageDeltaContent = - | MessageDeltaContentParent - | MessageDeltaTextContent - | MessageDeltaImageFileContent; - -/** The abstract base representation of a partial streamed message content payload. */ -export interface MessageDeltaContentParent { - /** The index of the content part of the message. */ - index: number; - - /** The type of content for this content part. */ - type: string; -} -/** Represents a streamed image file content part within a streaming message delta chunk. */ -export interface MessageDeltaImageFileContent extends MessageDeltaContentParent { - /** The type of content for this content part, which is always "image_file." */ - type: "image_file"; - - /** The image_file data. */ - image_file?: MessageDeltaImageFileContentObject; -} - -/** Represents the 'image_file' payload within streaming image file content. */ -export interface MessageDeltaImageFileContentObject { - /** The file ID of the image in the message content. */ - file_id?: string; -} - -/** Represents a streamed text content part within a streaming message delta chunk. */ -export interface MessageDeltaTextContent extends MessageDeltaContentParent { - /** The type of content for this content part, which is always "text." */ - type: "text"; - - /** The text content details. */ - text?: MessageDeltaTextContentObject; -} - -/** Represents the data of a streamed text content part within a streaming message delta chunk. */ -export interface MessageDeltaTextContentObject { - /** The data that makes up the text. */ - value?: string; - - /** Annotations for the text. */ - annotations?: Array; -} - -export type MessageDeltaTextAnnotation = - | MessageDeltaTextAnnotationParent - | MessageDeltaTextFileCitationAnnotation - | MessageDeltaTextFilePathAnnotation; - -/** The abstract base representation of a streamed text content part's text annotation. */ -export interface MessageDeltaTextAnnotationParent { - /** The index of the annotation within a text content part. */ - index: number; - - /** The type of the text content annotation. */ - type: string; -} - -/** Represents a streamed file citation applied to a streaming text content part. */ -export interface MessageDeltaTextFileCitationAnnotation extends MessageDeltaTextAnnotationParent { - /** The type of the text content annotation, which is always "file_citation." */ - type: "file_citation"; - - /** The file citation information. */ - file_citation?: MessageDeltaTextFileCitationAnnotationObject; - - /** The text in the message content that needs to be replaced */ - text?: string; - - /** The start index of this annotation in the content text. */ - start_index?: number; - - /** The end index of this annotation in the content text. */ - end_index?: number; -} - -/** Represents the data of a streamed file citation as applied to a streaming text content part. */ -export interface MessageDeltaTextFileCitationAnnotationObject { - /** The ID of the specific file the citation is from. */ - file_id?: string; - - /** The specific quote in the cited file. */ - quote?: string; -} - -/** Represents a streamed file path annotation applied to a streaming text content part. */ -export interface MessageDeltaTextFilePathAnnotation extends MessageDeltaTextAnnotationParent { - /** The type of the text content annotation, which is always "file_path." */ - type: "file_path"; - - /** The file path information. */ - file_path?: MessageDeltaTextFilePathAnnotationObject; - - /** The start index of this annotation in the content text. */ - start_index?: number; - - /** The end index of this annotation in the content text. */ - end_index?: number; - - /** The text in the message content that needs to be replaced */ - text?: string; -} - -/** Represents the data of a streamed file path annotation as applied to a streaming text content part. */ -export interface MessageDeltaTextFilePathAnnotationObject { - /** The file ID for the annotation. */ - file_id?: string; -} - -/** A representation of the URL used for the text citation. */ -export interface MessageDeltaTextUrlCitationDetails { - /** The URL where the citation is from. */ - url?: string; - - /** The title of the URL. */ - title?: string; -} - -/** Represents a run step delta i.e. any changed fields on a run step during streaming. */ -export interface RunStepDeltaChunk { - /** The identifier of the run step, which can be referenced in API endpoints. */ - id: string; - - /** The object type, which is always `thread.run.step.delta`. */ - object: "thread.run.step.delta"; - - /** The delta containing the fields that have changed on the run step. */ - delta: RunStepDelta; -} - -/** Represents the delta payload in a streaming run step delta chunk. */ -export interface RunStepDelta { - /** The details of the run step. */ - step_details?: RunStepDeltaDetail; -} - -/** Represents a single run step detail item in a streaming run step's delta payload. */ -export interface RunStepDeltaDetail { - /** The object type for the run step detail object. */ - type: string; -} - -/** Represents a message creation within a streaming run step delta. */ -export interface RunStepDeltaMessageCreation extends RunStepDeltaDetail { - /** The object type, which is always "message_creation." */ - type: "message_creation"; - - /** The message creation data. */ - message_creation?: RunStepDeltaMessageCreationObject; -} - -/** Represents the data within a streaming run step message creation response object. */ -export interface RunStepDeltaMessageCreationObject { - /** The ID of the newly-created message. */ - message_id?: string; -} - -/** Represents an invocation of tool calls as part of a streaming run step. */ -export interface RunStepDeltaToolCallObject extends RunStepDeltaDetail { - /** The object type, which is always "tool_calls." */ - type: "tool_calls"; - - /** The collection of tool calls for the tool call detail item. */ - tool_calls?: Array; -} - -export type RunStepDeltaToolCall = - | RunStepDeltaToolCallParent - | RunStepDeltaFunctionToolCall - | RunStepDeltaFileSearchToolCall - | RunStepDeltaCodeInterpreterToolCall; - -/** The abstract base representation of a single tool call within a streaming run step's delta tool call details. */ -export interface RunStepDeltaToolCallParent { - /** The index of the tool call detail in the run step's tool_calls array. */ - index: number; - - /** The ID of the tool call, used when submitting outputs to the run. */ - id: string; - - /** The type of the tool call detail item in a streaming run step's details. */ - type: string; -} - -/** Represents a function tool call within a streaming run step's tool call details. */ -export interface RunStepDeltaFunctionToolCall extends RunStepDeltaToolCallParent { - /** The object type, which is always "function." */ - type: "function"; - - /** The function data for the tool call. */ - function?: RunStepDeltaFunction; -} - -/** Represents a file search tool call within a streaming run step's tool call details. */ -export interface RunStepDeltaFileSearchToolCall extends RunStepDeltaToolCallParent { - /** The object type, which is always "file_search." */ - type: "file_search"; - - /** Reserved for future use. */ - file_search?: RunStepFileSearchToolCallResultsOutput; -} - -/** Represents a Code Interpreter tool call within a streaming run step's tool call details. */ -export interface RunStepDeltaCodeInterpreterToolCall extends RunStepDeltaToolCallParent { - /** The object type, which is always "code_interpreter." */ - type: "code_interpreter"; - - /** The Code Interpreter data for the tool call. */ - code_interpreter?: RunStepDeltaCodeInterpreterDetailItemObject; -} - -/** Represents the function data in a streaming run step delta's function tool call. */ -export interface RunStepDeltaFunction { - /** The name of the function. */ - name?: string; - - /** The arguments passed to the function as input. */ - arguments?: string; - - /** The output of the function, null if outputs have not yet been submitted. */ - output?: string | null; -} - -export type RunStepDeltaCodeInterpreterOutput = - | RunStepDeltaCodeInterpreterOutputParent - | RunStepDeltaCodeInterpreterLogOutput - | RunStepDeltaCodeInterpreterImageOutput; - -/** Represents the Code Interpreter tool call data in a streaming run step's tool calls. */ -export interface RunStepDeltaCodeInterpreterDetailItemObject { - /** The input into the Code Interpreter tool call. */ - input?: string; - - /** - * The outputs from the Code Interpreter tool call. Code Interpreter can output one or more - * items, including text (`logs`) or images (`image`). Each of these are represented by a - * different object type. - */ - outputs?: Array; -} - -/** The abstract base representation of a streaming run step tool call's Code Interpreter tool output. */ -export interface RunStepDeltaCodeInterpreterOutputParent { - /** The index of the output in the streaming run step tool call's Code Interpreter outputs array. */ - index: number; - - /** The type of the streaming run step tool call's Code Interpreter output. */ - type: string; -} - -/** Represents a log output as produced by the Code Interpreter tool and as represented in a streaming run step's delta tool calls collection. */ -export interface RunStepDeltaCodeInterpreterLogOutput - extends RunStepDeltaCodeInterpreterOutputParent { - /** The type of the object, which is always "logs." */ - type: "logs"; - - /** The text output from the Code Interpreter tool call. */ - logs?: string; -} - -/** Represents an image output as produced the Code interpreter tool and as represented in a streaming run step's delta tool calls collection. */ -export interface RunStepDeltaCodeInterpreterImageOutput - extends RunStepDeltaCodeInterpreterOutputParent { - /** The object type, which is always "image." */ - type: "image"; - - /** The image data for the Code Interpreter tool call output. */ - image?: RunStepDeltaCodeInterpreterImageOutputObject; -} - -/** Represents the data for a streaming run step's Code Interpreter tool call image output. */ -export interface RunStepDeltaCodeInterpreterImageOutputObject { - /** The file ID for the image. */ - file_id?: string; -} diff --git a/sdk/ai/ai-projects/src/generated/src/clientDefinitions.ts b/sdk/ai/ai-projects/src/generated/src/clientDefinitions.ts deleted file mode 100644 index aa5320c8a032..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/clientDefinitions.ts +++ /dev/null @@ -1,679 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - CreateAgentParameters, - ListAgentsParameters, - GetAgentParameters, - UpdateAgentParameters, - DeleteAgentParameters, - CreateThreadParameters, - ListThreadsParameters, - GetThreadParameters, - UpdateThreadParameters, - DeleteThreadParameters, - CreateMessageParameters, - ListMessagesParameters, - GetMessageParameters, - UpdateMessageParameters, - CreateRunParameters, - ListRunsParameters, - GetRunParameters, - UpdateRunParameters, - SubmitToolOutputsToRunParameters, - CancelRunParameters, - CreateThreadAndRunParameters, - GetRunStepParameters, - ListRunStepsParameters, - ListFilesParameters, - UploadFileParameters, - DeleteFileParameters, - GetFileParameters, - GetFileContentParameters, - ListVectorStoresParameters, - CreateVectorStoreParameters, - GetVectorStoreParameters, - ModifyVectorStoreParameters, - DeleteVectorStoreParameters, - ListVectorStoreFilesParameters, - CreateVectorStoreFileParameters, - GetVectorStoreFileParameters, - DeleteVectorStoreFileParameters, - CreateVectorStoreFileBatchParameters, - GetVectorStoreFileBatchParameters, - CancelVectorStoreFileBatchParameters, - ListVectorStoreFileBatchFilesParameters, - GetWorkspaceParameters, - ListConnectionsParameters, - GetConnectionParameters, - GetConnectionWithSecretsParameters, - GetAppInsightsParameters, - GetParameters, - UpdateParameters, - CreateParameters, - ListParameters, - GetScheduleParameters, - CreateOrReplaceScheduleParameters, - ListScheduleParameters, - DisableScheduleParameters, -} from "./parameters.js"; -import type { - CreateAgent200Response, - CreateAgentDefaultResponse, - ListAgents200Response, - ListAgentsDefaultResponse, - GetAgent200Response, - GetAgentDefaultResponse, - UpdateAgent200Response, - UpdateAgentDefaultResponse, - DeleteAgent200Response, - DeleteAgentDefaultResponse, - CreateThread200Response, - CreateThreadDefaultResponse, - ListThreads200Response, - ListThreadsDefaultResponse, - GetThread200Response, - GetThreadDefaultResponse, - UpdateThread200Response, - UpdateThreadDefaultResponse, - DeleteThread200Response, - DeleteThreadDefaultResponse, - CreateMessage200Response, - CreateMessageDefaultResponse, - ListMessages200Response, - ListMessagesDefaultResponse, - GetMessage200Response, - GetMessageDefaultResponse, - UpdateMessage200Response, - UpdateMessageDefaultResponse, - CreateRun200Response, - CreateRunDefaultResponse, - ListRuns200Response, - ListRunsDefaultResponse, - GetRun200Response, - GetRunDefaultResponse, - UpdateRun200Response, - UpdateRunDefaultResponse, - SubmitToolOutputsToRun200Response, - SubmitToolOutputsToRunDefaultResponse, - CancelRun200Response, - CancelRunDefaultResponse, - CreateThreadAndRun200Response, - CreateThreadAndRunDefaultResponse, - GetRunStep200Response, - GetRunStepDefaultResponse, - ListRunSteps200Response, - ListRunStepsDefaultResponse, - ListFiles200Response, - ListFilesDefaultResponse, - UploadFile200Response, - UploadFileDefaultResponse, - DeleteFile200Response, - DeleteFileDefaultResponse, - GetFile200Response, - GetFileDefaultResponse, - GetFileContent200Response, - GetFileContentDefaultResponse, - ListVectorStores200Response, - ListVectorStoresDefaultResponse, - CreateVectorStore200Response, - CreateVectorStoreDefaultResponse, - GetVectorStore200Response, - GetVectorStoreDefaultResponse, - ModifyVectorStore200Response, - ModifyVectorStoreDefaultResponse, - DeleteVectorStore200Response, - DeleteVectorStoreDefaultResponse, - ListVectorStoreFiles200Response, - ListVectorStoreFilesDefaultResponse, - CreateVectorStoreFile200Response, - CreateVectorStoreFileDefaultResponse, - GetVectorStoreFile200Response, - GetVectorStoreFileDefaultResponse, - DeleteVectorStoreFile200Response, - DeleteVectorStoreFileDefaultResponse, - CreateVectorStoreFileBatch200Response, - CreateVectorStoreFileBatchDefaultResponse, - GetVectorStoreFileBatch200Response, - GetVectorStoreFileBatchDefaultResponse, - CancelVectorStoreFileBatch200Response, - CancelVectorStoreFileBatchDefaultResponse, - ListVectorStoreFileBatchFiles200Response, - ListVectorStoreFileBatchFilesDefaultResponse, - GetWorkspace200Response, - GetWorkspaceDefaultResponse, - ListConnections200Response, - ListConnectionsDefaultResponse, - GetConnection200Response, - GetConnectionDefaultResponse, - GetConnectionWithSecrets200Response, - GetConnectionWithSecretsDefaultResponse, - GetAppInsights200Response, - GetAppInsightsDefaultResponse, - Get200Response, - GetDefaultResponse, - Update200Response, - UpdateDefaultResponse, - Create201Response, - List200Response, - ListDefaultResponse, - GetSchedule200Response, - GetScheduleDefaultResponse, - CreateOrReplaceSchedule200Response, - CreateOrReplaceSchedule201Response, - CreateOrReplaceScheduleDefaultResponse, - ListSchedule200Response, - ListScheduleDefaultResponse, - DisableSchedule204Response, - DisableScheduleDefaultResponse, -} from "./responses.js"; -import type { Client, StreamableMethod } from "@azure-rest/core-client"; - -export interface CreateAgent { - /** Creates a new agent. */ - post( - options: CreateAgentParameters, - ): StreamableMethod; - /** Gets a list of agents that were previously created. */ - get( - options?: ListAgentsParameters, - ): StreamableMethod; -} - -export interface GetAgent { - /** Retrieves an existing agent. */ - get( - options?: GetAgentParameters, - ): StreamableMethod; - /** Modifies an existing agent. */ - post( - options: UpdateAgentParameters, - ): StreamableMethod; - /** Deletes an agent. */ - delete( - options?: DeleteAgentParameters, - ): StreamableMethod; -} - -export interface CreateThread { - /** Creates a new thread. Threads contain messages and can be run by agents. */ - post( - options: CreateThreadParameters, - ): StreamableMethod; - /** Gets a list of threads that were previously created. */ - get( - options?: ListThreadsParameters, - ): StreamableMethod; -} - -export interface GetThread { - /** Gets information about an existing thread. */ - get( - options?: GetThreadParameters, - ): StreamableMethod; - /** Modifies an existing thread. */ - post( - options: UpdateThreadParameters, - ): StreamableMethod; - /** Deletes an existing thread. */ - delete( - options?: DeleteThreadParameters, - ): StreamableMethod; -} - -export interface CreateMessage { - /** Creates a new message on a specified thread. */ - post( - options: CreateMessageParameters, - ): StreamableMethod; - /** Gets a list of messages that exist on a thread. */ - get( - options?: ListMessagesParameters, - ): StreamableMethod; -} - -export interface GetMessage { - /** Gets an existing message from an existing thread. */ - get( - options?: GetMessageParameters, - ): StreamableMethod; - /** Modifies an existing message on an existing thread. */ - post( - options: UpdateMessageParameters, - ): StreamableMethod; -} - -export interface CreateRun { - /** Creates a new run for an agent thread. */ - post( - options: CreateRunParameters, - ): StreamableMethod; - /** Gets a list of runs for a specified thread. */ - get( - options?: ListRunsParameters, - ): StreamableMethod; -} - -export interface GetRun { - /** Gets an existing run from an existing thread. */ - get( - options?: GetRunParameters, - ): StreamableMethod; - /** Modifies an existing thread run. */ - post( - options: UpdateRunParameters, - ): StreamableMethod; -} - -export interface SubmitToolOutputsToRun { - /** Submits outputs from tools as requested by tool calls in a run. Runs that need submitted tool outputs will have a status of 'requires_action' with a required_action.type of 'submit_tool_outputs'. */ - post( - options: SubmitToolOutputsToRunParameters, - ): StreamableMethod< - SubmitToolOutputsToRun200Response | SubmitToolOutputsToRunDefaultResponse - >; -} - -export interface CancelRun { - /** Cancels a run of an in progress thread. */ - post( - options?: CancelRunParameters, - ): StreamableMethod; -} - -export interface CreateThreadAndRun { - /** Creates a new agent thread and immediately starts a run using that new thread. */ - post( - options: CreateThreadAndRunParameters, - ): StreamableMethod< - CreateThreadAndRun200Response | CreateThreadAndRunDefaultResponse - >; -} - -export interface GetRunStep { - /** Gets a single run step from a thread run. */ - get( - options?: GetRunStepParameters, - ): StreamableMethod; -} - -export interface ListRunSteps { - /** Gets a list of run steps from a thread run. */ - get( - options?: ListRunStepsParameters, - ): StreamableMethod; -} - -export interface ListFiles { - /** Gets a list of previously uploaded files. */ - get( - options?: ListFilesParameters, - ): StreamableMethod; - /** Uploads a file for use by other operations. */ - post( - options: UploadFileParameters, - ): StreamableMethod; -} - -export interface DeleteFile { - /** Delete a previously uploaded file. */ - delete( - options?: DeleteFileParameters, - ): StreamableMethod; - /** Returns information about a specific file. Does not retrieve file content. */ - get( - options?: GetFileParameters, - ): StreamableMethod; -} - -export interface GetFileContent { - /** Retrieves the raw content of a specific file. */ - get( - options?: GetFileContentParameters, - ): StreamableMethod< - GetFileContent200Response | GetFileContentDefaultResponse - >; -} - -export interface ListVectorStores { - /** Returns a list of vector stores. */ - get( - options?: ListVectorStoresParameters, - ): StreamableMethod< - ListVectorStores200Response | ListVectorStoresDefaultResponse - >; - /** Creates a vector store. */ - post( - options: CreateVectorStoreParameters, - ): StreamableMethod< - CreateVectorStore200Response | CreateVectorStoreDefaultResponse - >; -} - -export interface GetVectorStore { - /** Returns the vector store object matching the specified ID. */ - get( - options?: GetVectorStoreParameters, - ): StreamableMethod< - GetVectorStore200Response | GetVectorStoreDefaultResponse - >; - /** The ID of the vector store to modify. */ - post( - options: ModifyVectorStoreParameters, - ): StreamableMethod< - ModifyVectorStore200Response | ModifyVectorStoreDefaultResponse - >; - /** Deletes the vector store object matching the specified ID. */ - delete( - options?: DeleteVectorStoreParameters, - ): StreamableMethod< - DeleteVectorStore200Response | DeleteVectorStoreDefaultResponse - >; -} - -export interface ListVectorStoreFiles { - /** Returns a list of vector store files. */ - get( - options?: ListVectorStoreFilesParameters, - ): StreamableMethod< - ListVectorStoreFiles200Response | ListVectorStoreFilesDefaultResponse - >; - /** Create a vector store file by attaching a file to a vector store. */ - post( - options: CreateVectorStoreFileParameters, - ): StreamableMethod< - CreateVectorStoreFile200Response | CreateVectorStoreFileDefaultResponse - >; -} - -export interface GetVectorStoreFile { - /** Retrieves a vector store file. */ - get( - options?: GetVectorStoreFileParameters, - ): StreamableMethod< - GetVectorStoreFile200Response | GetVectorStoreFileDefaultResponse - >; - /** - * Delete a vector store file. This will remove the file from the vector store but the file itself will not be deleted. - * To delete the file, use the delete file endpoint. - */ - delete( - options?: DeleteVectorStoreFileParameters, - ): StreamableMethod< - DeleteVectorStoreFile200Response | DeleteVectorStoreFileDefaultResponse - >; -} - -export interface CreateVectorStoreFileBatch { - /** Create a vector store file batch. */ - post( - options: CreateVectorStoreFileBatchParameters, - ): StreamableMethod< - | CreateVectorStoreFileBatch200Response - | CreateVectorStoreFileBatchDefaultResponse - >; -} - -export interface GetVectorStoreFileBatch { - /** Retrieve a vector store file batch. */ - get( - options?: GetVectorStoreFileBatchParameters, - ): StreamableMethod< - GetVectorStoreFileBatch200Response | GetVectorStoreFileBatchDefaultResponse - >; -} - -export interface CancelVectorStoreFileBatch { - /** Cancel a vector store file batch. This attempts to cancel the processing of files in this batch as soon as possible. */ - post( - options?: CancelVectorStoreFileBatchParameters, - ): StreamableMethod< - | CancelVectorStoreFileBatch200Response - | CancelVectorStoreFileBatchDefaultResponse - >; -} - -export interface ListVectorStoreFileBatchFiles { - /** Returns a list of vector store files in a batch. */ - get( - options?: ListVectorStoreFileBatchFilesParameters, - ): StreamableMethod< - | ListVectorStoreFileBatchFiles200Response - | ListVectorStoreFileBatchFilesDefaultResponse - >; -} - -export interface GetWorkspace { - /** Gets the properties of the specified machine learning workspace. */ - get( - options?: GetWorkspaceParameters, - ): StreamableMethod; -} - -export interface ListConnections { - /** List the details of all the connections (not including their credentials) */ - get( - options?: ListConnectionsParameters, - ): StreamableMethod< - ListConnections200Response | ListConnectionsDefaultResponse - >; -} - -export interface GetConnection { - /** Get the details of a single connection, without credentials. */ - get( - options?: GetConnectionParameters, - ): StreamableMethod; -} - -export interface GetConnectionWithSecrets { - /** Get the details of a single connection, including credentials (if available). */ - post( - options: GetConnectionWithSecretsParameters, - ): StreamableMethod< - | GetConnectionWithSecrets200Response - | GetConnectionWithSecretsDefaultResponse - >; -} - -export interface GetAppInsights { - /** Gets the properties of the specified Application Insights resource */ - get( - options?: GetAppInsightsParameters, - ): StreamableMethod< - GetAppInsights200Response | GetAppInsightsDefaultResponse - >; -} - -export interface Get { - /** Resource read operation template. */ - get( - options?: GetParameters, - ): StreamableMethod; - /** Resource update operation template. */ - patch( - options: UpdateParameters, - ): StreamableMethod; -} - -export interface Create { - /** Run the evaluation. */ - post(options: CreateParameters): StreamableMethod; -} - -export interface List { - /** Resource list operation template. */ - get( - options?: ListParameters, - ): StreamableMethod; -} - -export interface GetSchedule { - /** Resource read operation template. */ - get( - options?: GetScheduleParameters, - ): StreamableMethod; - /** Create or replace operation template. */ - put( - options: CreateOrReplaceScheduleParameters, - ): StreamableMethod< - | CreateOrReplaceSchedule200Response - | CreateOrReplaceSchedule201Response - | CreateOrReplaceScheduleDefaultResponse - >; -} - -export interface ListSchedule { - /** Resource list operation template. */ - get( - options?: ListScheduleParameters, - ): StreamableMethod; -} - -export interface DisableSchedule { - /** Disable the evaluation schedule. */ - patch( - options?: DisableScheduleParameters, - ): StreamableMethod< - DisableSchedule204Response | DisableScheduleDefaultResponse - >; -} - -export interface Routes { - /** Resource for '/assistants' has methods for the following verbs: post, get */ - (path: "/assistants"): CreateAgent; - /** Resource for '/assistants/\{assistantId\}' has methods for the following verbs: get, post, delete */ - (path: "/assistants/{assistantId}", assistantId: string): GetAgent; - /** Resource for '/threads' has methods for the following verbs: post, get */ - (path: "/threads"): CreateThread; - /** Resource for '/threads/\{threadId\}' has methods for the following verbs: get, post, delete */ - (path: "/threads/{threadId}", threadId: string): GetThread; - /** Resource for '/threads/\{threadId\}/messages' has methods for the following verbs: post, get */ - (path: "/threads/{threadId}/messages", threadId: string): CreateMessage; - /** Resource for '/threads/\{threadId\}/messages/\{messageId\}' has methods for the following verbs: get, post */ - ( - path: "/threads/{threadId}/messages/{messageId}", - threadId: string, - messageId: string, - ): GetMessage; - /** Resource for '/threads/\{threadId\}/runs' has methods for the following verbs: post, get */ - (path: "/threads/{threadId}/runs", threadId: string): CreateRun; - /** Resource for '/threads/\{threadId\}/runs/\{runId\}' has methods for the following verbs: get, post */ - ( - path: "/threads/{threadId}/runs/{runId}", - threadId: string, - runId: string, - ): GetRun; - /** Resource for '/threads/\{threadId\}/runs/\{runId\}/submit_tool_outputs' has methods for the following verbs: post */ - ( - path: "/threads/{threadId}/runs/{runId}/submit_tool_outputs", - threadId: string, - runId: string, - ): SubmitToolOutputsToRun; - /** Resource for '/threads/\{threadId\}/runs/\{runId\}/cancel' has methods for the following verbs: post */ - ( - path: "/threads/{threadId}/runs/{runId}/cancel", - threadId: string, - runId: string, - ): CancelRun; - /** Resource for '/threads/runs' has methods for the following verbs: post */ - (path: "/threads/runs"): CreateThreadAndRun; - /** Resource for '/threads/\{threadId\}/runs/\{runId\}/steps/\{stepId\}' has methods for the following verbs: get */ - ( - path: "/threads/{threadId}/runs/{runId}/steps/{stepId}", - threadId: string, - runId: string, - stepId: string, - ): GetRunStep; - /** Resource for '/threads/\{threadId\}/runs/\{runId\}/steps' has methods for the following verbs: get */ - ( - path: "/threads/{threadId}/runs/{runId}/steps", - threadId: string, - runId: string, - ): ListRunSteps; - /** Resource for '/files' has methods for the following verbs: get, post */ - (path: "/files"): ListFiles; - /** Resource for '/files/\{fileId\}' has methods for the following verbs: delete, get */ - (path: "/files/{fileId}", fileId: string): DeleteFile; - /** Resource for '/files/\{fileId\}/content' has methods for the following verbs: get */ - (path: "/files/{fileId}/content", fileId: string): GetFileContent; - /** Resource for '/vector_stores' has methods for the following verbs: get, post */ - (path: "/vector_stores"): ListVectorStores; - /** Resource for '/vector_stores/\{vectorStoreId\}' has methods for the following verbs: get, post, delete */ - ( - path: "/vector_stores/{vectorStoreId}", - vectorStoreId: string, - ): GetVectorStore; - /** Resource for '/vector_stores/\{vectorStoreId\}/files' has methods for the following verbs: get, post */ - ( - path: "/vector_stores/{vectorStoreId}/files", - vectorStoreId: string, - ): ListVectorStoreFiles; - /** Resource for '/vector_stores/\{vectorStoreId\}/files/\{fileId\}' has methods for the following verbs: get, delete */ - ( - path: "/vector_stores/{vectorStoreId}/files/{fileId}", - vectorStoreId: string, - fileId: string, - ): GetVectorStoreFile; - /** Resource for '/vector_stores/\{vectorStoreId\}/file_batches' has methods for the following verbs: post */ - ( - path: "/vector_stores/{vectorStoreId}/file_batches", - vectorStoreId: string, - ): CreateVectorStoreFileBatch; - /** Resource for '/vector_stores/\{vectorStoreId\}/file_batches/\{batchId\}' has methods for the following verbs: get */ - ( - path: "/vector_stores/{vectorStoreId}/file_batches/{batchId}", - vectorStoreId: string, - batchId: string, - ): GetVectorStoreFileBatch; - /** Resource for '/vector_stores/\{vectorStoreId\}/file_batches/\{batchId\}/cancel' has methods for the following verbs: post */ - ( - path: "/vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel", - vectorStoreId: string, - batchId: string, - ): CancelVectorStoreFileBatch; - /** Resource for '/vector_stores/\{vectorStoreId\}/file_batches/\{batchId\}/files' has methods for the following verbs: get */ - ( - path: "/vector_stores/{vectorStoreId}/file_batches/{batchId}/files", - vectorStoreId: string, - batchId: string, - ): ListVectorStoreFileBatchFiles; - /** Resource for '/' has methods for the following verbs: get */ - (path: "/"): GetWorkspace; - /** Resource for '/connections' has methods for the following verbs: get */ - (path: "/connections"): ListConnections; - /** Resource for '/connections/\{connectionName\}' has methods for the following verbs: get */ - ( - path: "/connections/{connectionName}", - connectionName: string, - ): GetConnection; - /** Resource for '/connections/\{connectionName\}/listsecrets' has methods for the following verbs: post */ - ( - path: "/connections/{connectionName}/listsecrets", - connectionName: string, - ): GetConnectionWithSecrets; - /** Resource for '/\{appInsightsResourceUrl\}' has methods for the following verbs: get */ - ( - path: "/{appInsightsResourceUrl}", - appInsightsResourceUrl: string, - ): GetAppInsights; - /** Resource for '/evaluations/runs/\{id\}' has methods for the following verbs: get, patch */ - (path: "/evaluations/runs/{id}", id: string): Get; - /** Resource for '/evaluations/runs:run' has methods for the following verbs: post */ - (path: "/evaluations/runs:run"): Create; - /** Resource for '/evaluations/runs' has methods for the following verbs: get */ - (path: "/evaluations/runs"): List; - /** Resource for '/evaluations/schedules/\{name\}' has methods for the following verbs: get, put */ - (path: "/evaluations/schedules/{name}", name: string): GetSchedule; - /** Resource for '/evaluations/schedules' has methods for the following verbs: get */ - (path: "/evaluations/schedules"): ListSchedule; - /** Resource for '/evaluations/schedules/\{name\}/disable' has methods for the following verbs: patch */ - ( - path: "/evaluations/schedules/{name}/disable", - name: string, - ): DisableSchedule; -} - -export type ProjectsClient = Client & { - path: Routes; -}; diff --git a/sdk/ai/ai-projects/src/generated/src/index.ts b/sdk/ai/ai-projects/src/generated/src/index.ts deleted file mode 100644 index 0afd734a7856..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import ProjectsClient from "./projectsClient.js"; - -export * from "./projectsClient.js"; -export * from "./parameters.js"; -export * from "./responses.js"; -export * from "./clientDefinitions.js"; -export * from "./isUnexpected.js"; -export * from "./models.js"; -export * from "./outputModels.js"; -export * from "./paginateHelper.js"; - -export default ProjectsClient; diff --git a/sdk/ai/ai-projects/src/generated/src/isUnexpected.ts b/sdk/ai/ai-projects/src/generated/src/isUnexpected.ts deleted file mode 100644 index 8bdb587791d8..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/isUnexpected.ts +++ /dev/null @@ -1,595 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - CreateAgent200Response, - CreateAgentDefaultResponse, - ListAgents200Response, - ListAgentsDefaultResponse, - GetAgent200Response, - GetAgentDefaultResponse, - UpdateAgent200Response, - UpdateAgentDefaultResponse, - DeleteAgent200Response, - DeleteAgentDefaultResponse, - CreateThread200Response, - CreateThreadDefaultResponse, - ListThreads200Response, - ListThreadsDefaultResponse, - GetThread200Response, - GetThreadDefaultResponse, - UpdateThread200Response, - UpdateThreadDefaultResponse, - DeleteThread200Response, - DeleteThreadDefaultResponse, - CreateMessage200Response, - CreateMessageDefaultResponse, - ListMessages200Response, - ListMessagesDefaultResponse, - GetMessage200Response, - GetMessageDefaultResponse, - UpdateMessage200Response, - UpdateMessageDefaultResponse, - CreateRun200Response, - CreateRunDefaultResponse, - ListRuns200Response, - ListRunsDefaultResponse, - GetRun200Response, - GetRunDefaultResponse, - UpdateRun200Response, - UpdateRunDefaultResponse, - SubmitToolOutputsToRun200Response, - SubmitToolOutputsToRunDefaultResponse, - CancelRun200Response, - CancelRunDefaultResponse, - CreateThreadAndRun200Response, - CreateThreadAndRunDefaultResponse, - GetRunStep200Response, - GetRunStepDefaultResponse, - ListRunSteps200Response, - ListRunStepsDefaultResponse, - ListFiles200Response, - ListFilesDefaultResponse, - UploadFile200Response, - UploadFileDefaultResponse, - DeleteFile200Response, - DeleteFileDefaultResponse, - GetFile200Response, - GetFileDefaultResponse, - GetFileContent200Response, - GetFileContentDefaultResponse, - ListVectorStores200Response, - ListVectorStoresDefaultResponse, - CreateVectorStore200Response, - CreateVectorStoreDefaultResponse, - GetVectorStore200Response, - GetVectorStoreDefaultResponse, - ModifyVectorStore200Response, - ModifyVectorStoreDefaultResponse, - DeleteVectorStore200Response, - DeleteVectorStoreDefaultResponse, - ListVectorStoreFiles200Response, - ListVectorStoreFilesDefaultResponse, - CreateVectorStoreFile200Response, - CreateVectorStoreFileDefaultResponse, - GetVectorStoreFile200Response, - GetVectorStoreFileDefaultResponse, - DeleteVectorStoreFile200Response, - DeleteVectorStoreFileDefaultResponse, - CreateVectorStoreFileBatch200Response, - CreateVectorStoreFileBatchDefaultResponse, - GetVectorStoreFileBatch200Response, - GetVectorStoreFileBatchDefaultResponse, - CancelVectorStoreFileBatch200Response, - CancelVectorStoreFileBatchDefaultResponse, - ListVectorStoreFileBatchFiles200Response, - ListVectorStoreFileBatchFilesDefaultResponse, - GetWorkspace200Response, - GetWorkspaceDefaultResponse, - ListConnections200Response, - ListConnectionsDefaultResponse, - GetConnection200Response, - GetConnectionDefaultResponse, - GetConnectionWithSecrets200Response, - GetConnectionWithSecretsDefaultResponse, - GetAppInsights200Response, - GetAppInsightsDefaultResponse, - Get200Response, - GetDefaultResponse, - Update200Response, - UpdateDefaultResponse, - List200Response, - ListDefaultResponse, - GetSchedule200Response, - GetScheduleDefaultResponse, - CreateOrReplaceSchedule200Response, - CreateOrReplaceSchedule201Response, - CreateOrReplaceScheduleDefaultResponse, - ListSchedule200Response, - ListScheduleDefaultResponse, - DisableSchedule204Response, - DisableScheduleDefaultResponse, -} from "./responses.js"; - -const responseMap: Record = { - "POST /assistants": ["200"], - "GET /assistants": ["200"], - "GET /assistants/{assistantId}": ["200"], - "POST /assistants/{assistantId}": ["200"], - "DELETE /assistants/{assistantId}": ["200"], - "POST /threads": ["200"], - "GET /threads": ["200"], - "GET /threads/{threadId}": ["200"], - "POST /threads/{threadId}": ["200"], - "DELETE /threads/{threadId}": ["200"], - "POST /threads/{threadId}/messages": ["200"], - "GET /threads/{threadId}/messages": ["200"], - "GET /threads/{threadId}/messages/{messageId}": ["200"], - "POST /threads/{threadId}/messages/{messageId}": ["200"], - "POST /threads/{threadId}/runs": ["200"], - "GET /threads/{threadId}/runs": ["200"], - "GET /threads/{threadId}/runs/{runId}": ["200"], - "POST /threads/{threadId}/runs/{runId}": ["200"], - "POST /threads/{threadId}/runs/{runId}/submit_tool_outputs": ["200"], - "POST /threads/{threadId}/runs/{runId}/cancel": ["200"], - "POST /threads/runs": ["200"], - "GET /threads/{threadId}/runs/{runId}/steps/{stepId}": ["200"], - "GET /threads/{threadId}/runs/{runId}/steps": ["200"], - "GET /files": ["200"], - "POST /files": ["200"], - "DELETE /files/{fileId}": ["200"], - "GET /files/{fileId}": ["200"], - "GET /files/{fileId}/content": ["200"], - "GET /vector_stores": ["200"], - "POST /vector_stores": ["200"], - "GET /vector_stores/{vectorStoreId}": ["200"], - "POST /vector_stores/{vectorStoreId}": ["200"], - "DELETE /vector_stores/{vectorStoreId}": ["200"], - "GET /vector_stores/{vectorStoreId}/files": ["200"], - "POST /vector_stores/{vectorStoreId}/files": ["200"], - "GET /vector_stores/{vectorStoreId}/files/{fileId}": ["200"], - "DELETE /vector_stores/{vectorStoreId}/files/{fileId}": ["200"], - "POST /vector_stores/{vectorStoreId}/file_batches": ["200"], - "GET /vector_stores/{vectorStoreId}/file_batches/{batchId}": ["200"], - "POST /vector_stores/{vectorStoreId}/file_batches/{batchId}/cancel": ["200"], - "GET /vector_stores/{vectorStoreId}/file_batches/{batchId}/files": ["200"], - "GET /": ["200"], - "GET /connections": ["200"], - "GET /connections/{connectionName}": ["200"], - "POST /connections/{connectionName}/listsecrets": ["200"], - "GET /{appInsightsResourceUrl}": ["200"], - "GET /evaluations/runs/{id}": ["200"], - "PATCH /evaluations/runs/{id}": ["200"], - "POST /evaluations/runs:run": ["201"], - "GET /evaluations/runs": ["200"], - "GET /evaluations/schedules/{name}": ["200"], - "PUT /evaluations/schedules/{name}": ["200", "201"], - "GET /evaluations/schedules": ["200"], - "PATCH /evaluations/schedules/{name}/disable": ["204"], -}; - -export function isUnexpected( - response: CreateAgent200Response | CreateAgentDefaultResponse, -): response is CreateAgentDefaultResponse; -export function isUnexpected( - response: ListAgents200Response | ListAgentsDefaultResponse, -): response is ListAgentsDefaultResponse; -export function isUnexpected( - response: GetAgent200Response | GetAgentDefaultResponse, -): response is GetAgentDefaultResponse; -export function isUnexpected( - response: UpdateAgent200Response | UpdateAgentDefaultResponse, -): response is UpdateAgentDefaultResponse; -export function isUnexpected( - response: DeleteAgent200Response | DeleteAgentDefaultResponse, -): response is DeleteAgentDefaultResponse; -export function isUnexpected( - response: CreateThread200Response | CreateThreadDefaultResponse, -): response is CreateThreadDefaultResponse; -export function isUnexpected( - response: ListThreads200Response | ListThreadsDefaultResponse, -): response is ListThreadsDefaultResponse; -export function isUnexpected( - response: GetThread200Response | GetThreadDefaultResponse, -): response is GetThreadDefaultResponse; -export function isUnexpected( - response: UpdateThread200Response | UpdateThreadDefaultResponse, -): response is UpdateThreadDefaultResponse; -export function isUnexpected( - response: DeleteThread200Response | DeleteThreadDefaultResponse, -): response is DeleteThreadDefaultResponse; -export function isUnexpected( - response: CreateMessage200Response | CreateMessageDefaultResponse, -): response is CreateMessageDefaultResponse; -export function isUnexpected( - response: ListMessages200Response | ListMessagesDefaultResponse, -): response is ListMessagesDefaultResponse; -export function isUnexpected( - response: GetMessage200Response | GetMessageDefaultResponse, -): response is GetMessageDefaultResponse; -export function isUnexpected( - response: UpdateMessage200Response | UpdateMessageDefaultResponse, -): response is UpdateMessageDefaultResponse; -export function isUnexpected( - response: CreateRun200Response | CreateRunDefaultResponse, -): response is CreateRunDefaultResponse; -export function isUnexpected( - response: ListRuns200Response | ListRunsDefaultResponse, -): response is ListRunsDefaultResponse; -export function isUnexpected( - response: GetRun200Response | GetRunDefaultResponse, -): response is GetRunDefaultResponse; -export function isUnexpected( - response: UpdateRun200Response | UpdateRunDefaultResponse, -): response is UpdateRunDefaultResponse; -export function isUnexpected( - response: - | SubmitToolOutputsToRun200Response - | SubmitToolOutputsToRunDefaultResponse, -): response is SubmitToolOutputsToRunDefaultResponse; -export function isUnexpected( - response: CancelRun200Response | CancelRunDefaultResponse, -): response is CancelRunDefaultResponse; -export function isUnexpected( - response: CreateThreadAndRun200Response | CreateThreadAndRunDefaultResponse, -): response is CreateThreadAndRunDefaultResponse; -export function isUnexpected( - response: GetRunStep200Response | GetRunStepDefaultResponse, -): response is GetRunStepDefaultResponse; -export function isUnexpected( - response: ListRunSteps200Response | ListRunStepsDefaultResponse, -): response is ListRunStepsDefaultResponse; -export function isUnexpected( - response: ListFiles200Response | ListFilesDefaultResponse, -): response is ListFilesDefaultResponse; -export function isUnexpected( - response: UploadFile200Response | UploadFileDefaultResponse, -): response is UploadFileDefaultResponse; -export function isUnexpected( - response: DeleteFile200Response | DeleteFileDefaultResponse, -): response is DeleteFileDefaultResponse; -export function isUnexpected( - response: GetFile200Response | GetFileDefaultResponse, -): response is GetFileDefaultResponse; -export function isUnexpected( - response: GetFileContent200Response | GetFileContentDefaultResponse, -): response is GetFileContentDefaultResponse; -export function isUnexpected( - response: ListVectorStores200Response | ListVectorStoresDefaultResponse, -): response is ListVectorStoresDefaultResponse; -export function isUnexpected( - response: CreateVectorStore200Response | CreateVectorStoreDefaultResponse, -): response is CreateVectorStoreDefaultResponse; -export function isUnexpected( - response: GetVectorStore200Response | GetVectorStoreDefaultResponse, -): response is GetVectorStoreDefaultResponse; -export function isUnexpected( - response: ModifyVectorStore200Response | ModifyVectorStoreDefaultResponse, -): response is ModifyVectorStoreDefaultResponse; -export function isUnexpected( - response: DeleteVectorStore200Response | DeleteVectorStoreDefaultResponse, -): response is DeleteVectorStoreDefaultResponse; -export function isUnexpected( - response: - | ListVectorStoreFiles200Response - | ListVectorStoreFilesDefaultResponse, -): response is ListVectorStoreFilesDefaultResponse; -export function isUnexpected( - response: - | CreateVectorStoreFile200Response - | CreateVectorStoreFileDefaultResponse, -): response is CreateVectorStoreFileDefaultResponse; -export function isUnexpected( - response: GetVectorStoreFile200Response | GetVectorStoreFileDefaultResponse, -): response is GetVectorStoreFileDefaultResponse; -export function isUnexpected( - response: - | DeleteVectorStoreFile200Response - | DeleteVectorStoreFileDefaultResponse, -): response is DeleteVectorStoreFileDefaultResponse; -export function isUnexpected( - response: - | CreateVectorStoreFileBatch200Response - | CreateVectorStoreFileBatchDefaultResponse, -): response is CreateVectorStoreFileBatchDefaultResponse; -export function isUnexpected( - response: - | GetVectorStoreFileBatch200Response - | GetVectorStoreFileBatchDefaultResponse, -): response is GetVectorStoreFileBatchDefaultResponse; -export function isUnexpected( - response: - | CancelVectorStoreFileBatch200Response - | CancelVectorStoreFileBatchDefaultResponse, -): response is CancelVectorStoreFileBatchDefaultResponse; -export function isUnexpected( - response: - | ListVectorStoreFileBatchFiles200Response - | ListVectorStoreFileBatchFilesDefaultResponse, -): response is ListVectorStoreFileBatchFilesDefaultResponse; -export function isUnexpected( - response: GetWorkspace200Response | GetWorkspaceDefaultResponse, -): response is GetWorkspaceDefaultResponse; -export function isUnexpected( - response: ListConnections200Response | ListConnectionsDefaultResponse, -): response is ListConnectionsDefaultResponse; -export function isUnexpected( - response: GetConnection200Response | GetConnectionDefaultResponse, -): response is GetConnectionDefaultResponse; -export function isUnexpected( - response: - | GetConnectionWithSecrets200Response - | GetConnectionWithSecretsDefaultResponse, -): response is GetConnectionWithSecretsDefaultResponse; -export function isUnexpected( - response: GetAppInsights200Response | GetAppInsightsDefaultResponse, -): response is GetAppInsightsDefaultResponse; -export function isUnexpected( - response: Get200Response | GetDefaultResponse, -): response is GetDefaultResponse; -export function isUnexpected( - response: Update200Response | UpdateDefaultResponse, -): response is UpdateDefaultResponse; -export function isUnexpected( - response: List200Response | ListDefaultResponse, -): response is ListDefaultResponse; -export function isUnexpected( - response: GetSchedule200Response | GetScheduleDefaultResponse, -): response is GetScheduleDefaultResponse; -export function isUnexpected( - response: - | CreateOrReplaceSchedule200Response - | CreateOrReplaceSchedule201Response - | CreateOrReplaceScheduleDefaultResponse, -): response is CreateOrReplaceScheduleDefaultResponse; -export function isUnexpected( - response: ListSchedule200Response | ListScheduleDefaultResponse, -): response is ListScheduleDefaultResponse; -export function isUnexpected( - response: DisableSchedule204Response | DisableScheduleDefaultResponse, -): response is DisableScheduleDefaultResponse; -export function isUnexpected( - response: - | CreateAgent200Response - | CreateAgentDefaultResponse - | ListAgents200Response - | ListAgentsDefaultResponse - | GetAgent200Response - | GetAgentDefaultResponse - | UpdateAgent200Response - | UpdateAgentDefaultResponse - | DeleteAgent200Response - | DeleteAgentDefaultResponse - | CreateThread200Response - | CreateThreadDefaultResponse - | ListThreads200Response - | ListThreadsDefaultResponse - | GetThread200Response - | GetThreadDefaultResponse - | UpdateThread200Response - | UpdateThreadDefaultResponse - | DeleteThread200Response - | DeleteThreadDefaultResponse - | CreateMessage200Response - | CreateMessageDefaultResponse - | ListMessages200Response - | ListMessagesDefaultResponse - | GetMessage200Response - | GetMessageDefaultResponse - | UpdateMessage200Response - | UpdateMessageDefaultResponse - | CreateRun200Response - | CreateRunDefaultResponse - | ListRuns200Response - | ListRunsDefaultResponse - | GetRun200Response - | GetRunDefaultResponse - | UpdateRun200Response - | UpdateRunDefaultResponse - | SubmitToolOutputsToRun200Response - | SubmitToolOutputsToRunDefaultResponse - | CancelRun200Response - | CancelRunDefaultResponse - | CreateThreadAndRun200Response - | CreateThreadAndRunDefaultResponse - | GetRunStep200Response - | GetRunStepDefaultResponse - | ListRunSteps200Response - | ListRunStepsDefaultResponse - | ListFiles200Response - | ListFilesDefaultResponse - | UploadFile200Response - | UploadFileDefaultResponse - | DeleteFile200Response - | DeleteFileDefaultResponse - | GetFile200Response - | GetFileDefaultResponse - | GetFileContent200Response - | GetFileContentDefaultResponse - | ListVectorStores200Response - | ListVectorStoresDefaultResponse - | CreateVectorStore200Response - | CreateVectorStoreDefaultResponse - | GetVectorStore200Response - | GetVectorStoreDefaultResponse - | ModifyVectorStore200Response - | ModifyVectorStoreDefaultResponse - | DeleteVectorStore200Response - | DeleteVectorStoreDefaultResponse - | ListVectorStoreFiles200Response - | ListVectorStoreFilesDefaultResponse - | CreateVectorStoreFile200Response - | CreateVectorStoreFileDefaultResponse - | GetVectorStoreFile200Response - | GetVectorStoreFileDefaultResponse - | DeleteVectorStoreFile200Response - | DeleteVectorStoreFileDefaultResponse - | CreateVectorStoreFileBatch200Response - | CreateVectorStoreFileBatchDefaultResponse - | GetVectorStoreFileBatch200Response - | GetVectorStoreFileBatchDefaultResponse - | CancelVectorStoreFileBatch200Response - | CancelVectorStoreFileBatchDefaultResponse - | ListVectorStoreFileBatchFiles200Response - | ListVectorStoreFileBatchFilesDefaultResponse - | GetWorkspace200Response - | GetWorkspaceDefaultResponse - | ListConnections200Response - | ListConnectionsDefaultResponse - | GetConnection200Response - | GetConnectionDefaultResponse - | GetConnectionWithSecrets200Response - | GetConnectionWithSecretsDefaultResponse - | GetAppInsights200Response - | GetAppInsightsDefaultResponse - | Get200Response - | GetDefaultResponse - | Update200Response - | UpdateDefaultResponse - | List200Response - | ListDefaultResponse - | GetSchedule200Response - | GetScheduleDefaultResponse - | CreateOrReplaceSchedule200Response - | CreateOrReplaceSchedule201Response - | CreateOrReplaceScheduleDefaultResponse - | ListSchedule200Response - | ListScheduleDefaultResponse - | DisableSchedule204Response - | DisableScheduleDefaultResponse, -): response is - | CreateAgentDefaultResponse - | ListAgentsDefaultResponse - | GetAgentDefaultResponse - | UpdateAgentDefaultResponse - | DeleteAgentDefaultResponse - | CreateThreadDefaultResponse - | ListThreadsDefaultResponse - | GetThreadDefaultResponse - | UpdateThreadDefaultResponse - | DeleteThreadDefaultResponse - | CreateMessageDefaultResponse - | ListMessagesDefaultResponse - | GetMessageDefaultResponse - | UpdateMessageDefaultResponse - | CreateRunDefaultResponse - | ListRunsDefaultResponse - | GetRunDefaultResponse - | UpdateRunDefaultResponse - | SubmitToolOutputsToRunDefaultResponse - | CancelRunDefaultResponse - | CreateThreadAndRunDefaultResponse - | GetRunStepDefaultResponse - | ListRunStepsDefaultResponse - | ListFilesDefaultResponse - | UploadFileDefaultResponse - | DeleteFileDefaultResponse - | GetFileDefaultResponse - | GetFileContentDefaultResponse - | ListVectorStoresDefaultResponse - | CreateVectorStoreDefaultResponse - | GetVectorStoreDefaultResponse - | ModifyVectorStoreDefaultResponse - | DeleteVectorStoreDefaultResponse - | ListVectorStoreFilesDefaultResponse - | CreateVectorStoreFileDefaultResponse - | GetVectorStoreFileDefaultResponse - | DeleteVectorStoreFileDefaultResponse - | CreateVectorStoreFileBatchDefaultResponse - | GetVectorStoreFileBatchDefaultResponse - | CancelVectorStoreFileBatchDefaultResponse - | ListVectorStoreFileBatchFilesDefaultResponse - | GetWorkspaceDefaultResponse - | ListConnectionsDefaultResponse - | GetConnectionDefaultResponse - | GetConnectionWithSecretsDefaultResponse - | GetAppInsightsDefaultResponse - | GetDefaultResponse - | UpdateDefaultResponse - | ListDefaultResponse - | GetScheduleDefaultResponse - | CreateOrReplaceScheduleDefaultResponse - | ListScheduleDefaultResponse - | DisableScheduleDefaultResponse { - const lroOriginal = response.headers["x-ms-original-url"]; - const url = new URL(lroOriginal ?? response.request.url); - const method = response.request.method; - let pathDetails = responseMap[`${method} ${url.pathname}`]; - if (!pathDetails) { - pathDetails = getParametrizedPathSuccess(method, url.pathname); - } - return !pathDetails.includes(response.status); -} - -function getParametrizedPathSuccess(method: string, path: string): string[] { - const pathParts = path.split("/"); - - // Traverse list to match the longest candidate - // matchedLen: the length of candidate path - // matchedValue: the matched status code array - let matchedLen = -1, - matchedValue: string[] = []; - - // Iterate the responseMap to find a match - for (const [key, value] of Object.entries(responseMap)) { - // Extracting the path from the map key which is in format - // GET /path/foo - if (!key.startsWith(method)) { - continue; - } - const candidatePath = getPathFromMapKey(key); - // Get each part of the url path - const candidateParts = candidatePath.split("/"); - - // track if we have found a match to return the values found. - let found = true; - for ( - let i = candidateParts.length - 1, j = pathParts.length - 1; - i >= 1 && j >= 1; - i--, j-- - ) { - if ( - candidateParts[i]?.startsWith("{") && - candidateParts[i]?.indexOf("}") !== -1 - ) { - const start = candidateParts[i]!.indexOf("}") + 1, - end = candidateParts[i]?.length; - // If the current part of the candidate is a "template" part - // Try to use the suffix of pattern to match the path - // {guid} ==> $ - // {guid}:export ==> :export$ - const isMatched = new RegExp( - `${candidateParts[i]?.slice(start, end)}`, - ).test(pathParts[j] || ""); - - if (!isMatched) { - found = false; - break; - } - continue; - } - - // If the candidate part is not a template and - // the parts don't match mark the candidate as not found - // to move on with the next candidate path. - if (candidateParts[i] !== pathParts[j]) { - found = false; - break; - } - } - - // We finished evaluating the current candidate parts - // Update the matched value if and only if we found the longer pattern - if (found && candidatePath.length > matchedLen) { - matchedLen = candidatePath.length; - matchedValue = value; - } - } - - return matchedValue; -} - -function getPathFromMapKey(mapKey: string): string { - const pathStart = mapKey.indexOf("/"); - return mapKey.slice(pathStart); -} diff --git a/sdk/ai/ai-projects/src/generated/src/logger.ts b/sdk/ai/ai-projects/src/generated/src/logger.ts deleted file mode 100644 index ac271f422ccc..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/logger.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { createClientLogger } from "@azure/logger"; -export const logger = createClientLogger("ai-projects"); diff --git a/sdk/ai/ai-projects/src/generated/src/models.ts b/sdk/ai/ai-projects/src/generated/src/models.ts deleted file mode 100644 index 37eb0a18eb1c..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/models.ts +++ /dev/null @@ -1,1064 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** The request details to use when creating a new agent. */ -export interface CreateAgentOptions { - /** The ID of the model to use. */ - model: string; - /** The name of the new agent. */ - name?: string | null; - /** The description of the new agent. */ - description?: string | null; - /** The system instructions for the new agent to use. */ - instructions?: string | null; - /** The collection of tools to enable for the new agent. */ - tools?: Array; - /** - * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` - * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - */ - tool_resources?: ToolResources | null; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - top_p?: number | null; - /** The response format of the tool calls used by this agent. */ - response_format?: AgentsApiResponseFormatOption | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** An abstract representation of an input tool definition that an agent can use. */ -export interface ToolDefinitionParent { - type: string; -} - -/** The input definition information for a code interpreter tool as used to configure an agent. */ -export interface CodeInterpreterToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'code_interpreter'. */ - type: "code_interpreter"; -} - -/** The input definition information for a file search tool as used to configure an agent. */ -export interface FileSearchToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'file_search'. */ - type: "file_search"; - /** Options overrides for the file search tool. */ - file_search?: FileSearchToolDefinitionDetails; -} - -/** Options overrides for the file search tool. */ -export interface FileSearchToolDefinitionDetails { - /** - * The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. - * - * Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. - */ - max_num_results?: number; - /** Ranking options for file search. */ - ranking_options?: FileSearchRankingOptions; -} - -/** Ranking options for file search. */ -export interface FileSearchRankingOptions { - /** File search ranker. */ - ranker: string; - /** Ranker search threshold. */ - score_threshold: number; -} - -/** The input definition information for a function tool as used to configure an agent. */ -export interface FunctionToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'function'. */ - type: "function"; - /** The definition of the concrete function that the function tool should call. */ - function: FunctionDefinition; -} - -/** The input definition information for a function. */ -export interface FunctionDefinition { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The parameters the functions accepts, described as a JSON Schema object. */ - parameters: unknown; -} - -/** The input definition information for a bing grounding search tool as used to configure an agent. */ -export interface BingGroundingToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'bing_grounding'. */ - type: "bing_grounding"; - /** The list of connections used by the bing grounding tool. */ - bing_grounding: ToolConnectionList; -} - -/** A set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or `sharepoint_grounding` tools. */ -export interface ToolConnectionList { - /** - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - connections?: Array; -} - -/** A connection resource. */ -export interface ToolConnection { - /** A connection in a ToolConnectionList attached to this tool. */ - connection_id: string; -} - -/** The input definition information for a Microsoft Fabric tool as used to configure an agent. */ -export interface MicrosoftFabricToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'fabric_dataagent'. */ - type: "fabric_dataagent"; - /** The list of connections used by the Microsoft Fabric tool. */ - fabric_dataagent: ToolConnectionList; -} - -/** The input definition information for a sharepoint tool as used to configure an agent. */ -export interface SharepointToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'sharepoint_grounding'. */ - type: "sharepoint_grounding"; - /** The list of connections used by the SharePoint tool. */ - sharepoint_grounding: ToolConnectionList; -} - -/** The input definition information for an Azure AI search tool as used to configure an agent. */ -export interface AzureAISearchToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'azure_ai_search'. */ - type: "azure_ai_search"; -} - -/** The input definition information for an OpenAPI tool as used to configure an agent. */ -export interface OpenApiToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'openapi'. */ - type: "openapi"; - /** The openapi function definition. */ - openapi: OpenApiFunctionDefinition; -} - -/** The input definition information for an openapi function. */ -export interface OpenApiFunctionDefinition { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The openapi function shape, described as a JSON Schema object. */ - spec: unknown; - /** Open API authentication details */ - auth: OpenApiAuthDetails; - /** List of OpenAPI spec parameters that will use user-provided defaults */ - default_params?: string[]; -} - -/** authentication details for OpenApiFunctionDefinition */ -export interface OpenApiAuthDetailsParent { - type: OpenApiAuthType; -} - -/** Security details for OpenApi anonymous authentication */ -export interface OpenApiAnonymousAuthDetails extends OpenApiAuthDetailsParent { - /** The object type, which is always 'anonymous'. */ - type: "anonymous"; -} - -/** Security details for OpenApi connection authentication */ -export interface OpenApiConnectionAuthDetails extends OpenApiAuthDetailsParent { - /** The object type, which is always 'connection'. */ - type: "connection"; - /** Connection auth security details */ - security_scheme: OpenApiConnectionSecurityScheme; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiConnectionSecurityScheme { - /** Connection id for Connection auth type */ - connection_id: string; -} - -/** Security details for OpenApi managed_identity authentication */ -export interface OpenApiManagedAuthDetails extends OpenApiAuthDetailsParent { - /** The object type, which is always 'managed_identity'. */ - type: "managed_identity"; - /** Connection auth security details */ - security_scheme: OpenApiManagedSecurityScheme; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiManagedSecurityScheme { - /** Authentication scope for managed_identity auth type */ - audience: string; -} - -/** The input definition information for a Bing custom search tool as used to configure an agent. */ -export interface BingCustomSearchToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'bing_custom_search'. */ - type: "bing_custom_search"; - /** The list of search configurations used by the bing custom search tool. */ - bing_custom_search: SearchConfigurationList; -} - -/** A list of search configurations currently used by the `bing_custom_search` tool. */ -export interface SearchConfigurationList { - /** - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - search_configurations: Array; -} - -/** A custom search configuration. */ -export interface SearchConfiguration { - /** A connection in a ToolConnectionList attached to this tool. */ - connection_id: string; - /** Name of the custom configuration instance given to config. */ - instance_name: string; -} - -/** The input definition information for a connected agent tool which defines a domain specific sub-agent */ -export interface ConnectedAgentToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'connected_agent'. */ - type: "connected_agent"; - /** The sub-agent to connect */ - connected_agent: ConnectedAgentDetails; -} - -/** Information for connecting one agent to another as a tool */ -export interface ConnectedAgentDetails { - /** The identifier of the child agent. */ - id: string; - /** The name of the agent to be called. */ - name: string; - /** A description of what the agent does, used by the model to choose when and how to call the agent. */ - description: string; -} - -/** The input definition information for a azure function tool as used to configure an agent. */ -export interface AzureFunctionToolDefinition extends ToolDefinitionParent { - /** The object type, which is always 'azure_function'. */ - type: "azure_function"; - /** The definition of the concrete function that the function tool should call. */ - azure_function: AzureFunctionDefinition; -} - -/** The definition of Azure function. */ -export interface AzureFunctionDefinition { - /** The definition of azure function and its parameters. */ - function: FunctionDefinition; - /** Input storage queue. The queue storage trigger runs a function as messages are added to it. */ - input_binding: AzureFunctionBinding; - /** Output storage queue. The function writes output to this queue when the input items are processed. */ - output_binding: AzureFunctionBinding; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionBinding { - /** The type of binding, which is always 'storage_queue'. */ - type: "storage_queue"; - /** Storage queue. */ - storage_queue: AzureFunctionStorageQueue; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionStorageQueue { - /** URI to the Azure Storage Queue service allowing you to manipulate a queue. */ - queue_service_endpoint: string; - /** The name of an Azure function storage queue. */ - queue_name: string; -} - -/** - * A set of resources that are used by the agent's tools. The resources are specific to the type of - * tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` - * tool requires a list of vector store IDs. - */ -export interface ToolResources { - /** Resources to be used by the `code_interpreter` tool consisting of file IDs. */ - code_interpreter?: CodeInterpreterToolResource; - /** Resources to be used by the `file_search` tool consisting of vector store IDs. */ - file_search?: FileSearchToolResource; - /** Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azure_ai_search?: AzureAISearchResource; -} - -/** A set of resources that are used by the `code_interpreter` tool. */ -export interface CodeInterpreterToolResource { - /** - * A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - file_ids?: string[]; - /** The data sources to be used. This option is mutually exclusive with the `fileIds` property. */ - data_sources?: Array; -} - -/** - * The structure, containing Azure asset URI path and the asset type of the file used as a data source - * for the enterprise file search. - */ -export interface VectorStoreDataSource { - /** Asset URI. */ - uri: string; - /** - * The asset type - * - * Possible values: "uri_asset", "id_asset" - */ - type: VectorStoreDataSourceAssetType; -} - -/** A set of resources that are used by the `file_search` tool. */ -export interface FileSearchToolResource { - /** - * The ID of the vector store attached to this agent. There can be a maximum of 1 vector - * store attached to the agent. - */ - vector_store_ids?: string[]; - /** - * The list of vector store configuration objects from Azure. - * This list is limited to one element. - * The only element of this list contains the list of azure asset IDs used by the search tool. - */ - vector_stores?: Array; -} - -/** The structure, containing the list of vector storage configurations i.e. the list of azure asset IDs. */ -export interface VectorStoreConfigurations { - /** Name */ - name: string; - /** Configurations */ - configuration: VectorStoreConfiguration; -} - -/** - * Vector storage configuration is the list of data sources, used when multiple - * files can be used for the enterprise file search. - */ -export interface VectorStoreConfiguration { - /** Data sources */ - data_sources: Array; -} - -/** A set of index resources used by the `azure_ai_search` tool. */ -export interface AzureAISearchResource { - /** - * The indices attached to this agent. There can be a maximum of 1 index - * resource attached to the agent. - */ - indexes?: Array; -} - -/** A AI Search Index resource. */ -export interface AISearchIndexResource { - /** An index connection id in an IndexResource attached to this agent. */ - index_connection_id: string; - /** The name of an index in an IndexResource attached to this agent. */ - index_name: string; - /** - * Type of query in an AIIndexResource attached to this agent. - * - * Possible values: "simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid" - */ - query_type?: AzureAISearchQueryType; - /** Number of documents to retrieve from search and present to the model. */ - top_k?: number; - /** Odata filter string for search resource. */ - filter?: string; -} - -/** - * An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. - * If `text` the model can return text or any value needed. - */ -export interface AgentsApiResponseFormat { - /** - * Must be one of `text` or `json_object`. - * - * Possible values: "text", "json_object" - */ - type?: ResponseFormat; -} - -/** The type of response format being defined: `json_schema` */ -export interface ResponseFormatJsonSchemaType { - /** Type */ - type: "json_schema"; - /** The JSON schema, describing response format. */ - json_schema: ResponseFormatJsonSchema; -} - -/** A description of what the response format is for, used by the model to determine how to respond in the format. */ -export interface ResponseFormatJsonSchema { - /** A description of what the response format is for, used by the model to determine how to respond in the format. */ - description?: string; - /** The name of a schema. */ - name: string; - /** The JSON schema object, describing the response format. */ - schema: unknown; -} - -/** The request details to use when modifying an existing agent. */ -export interface UpdateAgentOptions { - /** The ID of the model to use. */ - model?: string; - /** The modified name for the agent to use. */ - name?: string | null; - /** The modified description for the agent to use. */ - description?: string | null; - /** The modified system instructions for the new agent to use. */ - instructions?: string | null; - /** The modified collection of tools to enable for the agent. */ - tools?: Array; - /** - * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, - * the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - */ - tool_resources?: ToolResources; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - top_p?: number | null; - /** The response format of the tool calls used by this agent. */ - response_format?: AgentsApiResponseFormatOption | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** The details used to create a new agent thread. */ -export interface AgentThreadCreationOptions { - /** The initial messages to associate with the new thread. */ - messages?: Array; - /** - * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - * a list of vector store IDs. - */ - tool_resources?: ToolResources | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** - * A single message within an agent thread, - * as provided during that thread's creation for its initial state. - */ -export interface ThreadMessageOptions { - /** - * The role of the entity that is creating the message. Allowed values include: - * `user`, which indicates the message is sent by an actual user (and should be - * used in most cases to represent user-generated messages), and `assistant`, - * which indicates the message is generated by the agent (use this value to insert - * messages from the agent into the conversation). - * - * Possible values: "user", "assistant" - */ - role: MessageRole; - /** - * The content of the initial message. This may be a basic string (if you only - * need text) or an array of typed content blocks (for example, text, image_file, - * image_url, and so on). - */ - content: MessageInputContent; - /** A list of files attached to the message, and the tools they should be added to. */ - attachments?: Array | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** Defines a single content block when creating a message. The 'type' field determines whether it is text, an image file, or an external image URL, etc. */ -export interface MessageInputContentBlockParent { - type: MessageBlockType; -} - -/** A text block in a new message, containing plain text content. */ -export interface MessageInputTextBlock extends MessageInputContentBlockParent { - /** Must be 'text' for a text block. */ - type: "text"; - /** The plain text content for this block. */ - text: string; -} - -/** An image-file block in a new message, referencing an internally uploaded image by file ID. */ -export interface MessageInputImageFileBlock - extends MessageInputContentBlockParent { - /** Must be 'image_file' for an internally uploaded image block. */ - type: "image_file"; - /** Information about the referenced image file, including file ID and optional detail level. */ - image_file: MessageImageFileParam; -} - -/** Defines how an internally uploaded image file is referenced when creating an image-file block. */ -export interface MessageImageFileParam { - /** The ID of the previously uploaded image file. */ - file_id: string; - /** - * Optional detail level for the image (auto, low, or high). - * - * Possible values: "auto", "low", "high" - */ - detail?: ImageDetailLevel; -} - -/** An image-URL block in a new message, referencing an external image by URL. */ -export interface MessageInputImageUrlBlock - extends MessageInputContentBlockParent { - /** Must be 'image_url' for an externally hosted image block. */ - type: "image_url"; - /** Information about the external image URL, including the URL and optional detail level. */ - image_url: MessageImageUrlParam; -} - -/** Defines how an external image URL is referenced when creating an image-URL block. */ -export interface MessageImageUrlParam { - /** The publicly accessible URL of the external image. */ - url: string; - /** - * Optional detail level for the image (auto, low, or high). Defaults to 'auto' if not specified. - * - * Possible values: "auto", "low", "high" - */ - detail?: ImageDetailLevel; -} - -/** This describes to which tools a file has been attached. */ -export interface MessageAttachment { - /** The ID of the file to attach to the message. */ - file_id?: string; - /** Azure asset ID. */ - data_source?: VectorStoreDataSource; - /** The tools to add to this file. */ - tools: Array; -} - -/** The details used to update an existing agent thread */ -export interface UpdateAgentThreadOptions { - /** - * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the - * type of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires - * a list of vector store IDs - */ - tool_resources?: ToolResources | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** The details used when creating a new run of an agent thread. */ -export interface CreateRunOptions { - /** The ID of the agent that should run the thread. */ - assistant_id: string; - /** The overridden model name that the agent should use to run the thread. */ - model?: string | null; - /** The overridden system instructions that the agent should use to run the thread. */ - instructions?: string | null; - /** - * Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior - * on a per-run basis without overriding other instructions. - */ - additional_instructions?: string | null; - /** Adds additional messages to the thread before creating the run. */ - additional_messages?: Array | null; - /** The overridden list of enabled tools that the agent should use to run the thread. */ - tools?: Array | null; - /** - * If `true`, returns a stream of events that happen during the Run as server-sent events, - * terminating when the Run enters a terminal state with a `data: [DONE]` message. - */ - stream?: boolean; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model - * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - * comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - top_p?: number | null; - /** - * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - * the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - max_prompt_tokens?: number | null; - /** - * The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort - * to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of - * completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - max_completion_tokens?: number | null; - /** The strategy to use for dropping messages as the context windows moves forward. */ - truncation_strategy?: TruncationObject | null; - /** Controls whether or not and which tool is called by the model. */ - tool_choice?: AgentsApiToolChoiceOption | null; - /** Specifies the format that the model must output. */ - response_format?: AgentsApiResponseFormatOption | null; - /** If `true` functions will run in parallel during tool use. */ - parallel_tool_calls?: boolean; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** - * Controls for how a thread will be truncated prior to the run. Use this to control the initial - * context window of the run. - */ -export interface TruncationObject { - /** - * The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will - * be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread - * will be dropped to fit the context length of the model, `max_prompt_tokens`. - * - * Possible values: "auto", "last_messages" - */ - type: TruncationStrategy; - /** The number of most recent messages from the thread when constructing the context for the run. */ - last_messages?: number | null; -} - -/** Specifies a tool the model should use. Use to force the model to call a specific tool. */ -export interface AgentsNamedToolChoice { - /** - * the type of tool. If type is `function`, the function name must be set. - * - * Possible values: "function", "code_interpreter", "file_search", "bing_grounding", "fabric_dataagent", "sharepoint_grounding", "azure_ai_search", "bing_custom_search", "connected_agent" - */ - type: AgentsNamedToolChoiceType; - /** The name of the function to call */ - function?: FunctionName; -} - -/** The function name that will be used, if using the `function` tool */ -export interface FunctionName { - /** The name of the function to call */ - name: string; -} - -/** - * Request object. A set of resources that are used by the agent's tools. The resources are specific to the type of tool. - * For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of - * vector store IDs. - */ -export interface UpdateToolResourcesOptions { - /** - * Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - code_interpreter?: UpdateCodeInterpreterToolResourceOptions; - /** Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. */ - file_search?: UpdateFileSearchToolResourceOptions; - /** Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azure_ai_search?: AzureAISearchResource; -} - -/** Request object to update `code_interpreted` tool resources. */ -export interface UpdateCodeInterpreterToolResourceOptions { - /** A list of file IDs to override the current list of the agent. */ - file_ids?: string[]; -} - -/** Request object to update `file_search` tool resources. */ -export interface UpdateFileSearchToolResourceOptions { - /** A list of vector store IDs to override the current list of the agent. */ - vector_store_ids?: string[]; -} - -/** The data provided during a tool outputs submission to resolve pending tool calls and allow the model to continue. */ -export interface ToolOutput { - /** The ID of the tool call being resolved, as provided in the tool calls of a required action from a run. */ - tool_call_id?: string; - /** The output from the tool to be submitted. */ - output?: string; -} - -/** The details used when creating and immediately running a new agent thread. */ -export interface CreateAndRunThreadOptions { - /** The ID of the agent for which the thread should be created. */ - assistant_id: string; - /** The details used to create the new thread. If no thread is provided, an empty one will be created. */ - thread?: AgentThreadCreationOptions; - /** The overridden model that the agent should use to run the thread. */ - model?: string | null; - /** The overridden system instructions the agent should use to run the thread. */ - instructions?: string | null; - /** The overridden list of enabled tools the agent should use to run the thread. */ - tools?: Array | null; - /** Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis */ - tool_resources?: UpdateToolResourcesOptions | null; - /** - * If `true`, returns a stream of events that happen during the Run as server-sent events, - * terminating when the Run enters a terminal state with a `data: [DONE]` message. - */ - stream?: boolean; - /** - * 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. - */ - temperature?: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model - * considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens - * comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - top_p?: number | null; - /** - * The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only - * the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified, - * the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - max_prompt_tokens?: number | null; - /** - * The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort to use only - * the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of completion tokens - * specified, the run will end with status `incomplete`. See `incomplete_details` for more info. - */ - max_completion_tokens?: number | null; - /** The strategy to use for dropping messages as the context windows moves forward. */ - truncation_strategy?: TruncationObject | null; - /** Controls whether or not and which tool is called by the model. */ - tool_choice?: AgentsApiToolChoiceOption | null; - /** Specifies the format that the model must output. */ - response_format?: AgentsApiResponseFormatOption | null; - /** If `true` functions will run in parallel during tool use. */ - parallel_tool_calls?: boolean; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -export interface HttpPartFile {} - -export interface HttpPartFilePurpose {} - -export interface HttpPartString {} - -/** The expiration policy for a vector store. */ -export interface VectorStoreExpirationPolicy { - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - * - * Possible values: "last_active_at" - */ - anchor: VectorStoreExpirationPolicyAnchor; - /** The anchor timestamp after which the expiration policy applies. */ - days: number; -} - -/** Request object for creating a vector store. */ -export interface VectorStoreOptions { - /** A list of file IDs that the vector store should use. Useful for tools like `file_search` that can access files. */ - file_ids?: string[]; - /** The name of the vector store. */ - name?: string; - /** The vector store configuration, used when vector store is created from Azure asset URIs. */ - configuration?: VectorStoreConfiguration; - /** Details on when this vector store expires */ - expires_after?: VectorStoreExpirationPolicy; - /** The chunking strategy used to chunk the file(s). If not set, will use the auto strategy. Only applicable if file_ids is non-empty. */ - chunking_strategy?: VectorStoreChunkingStrategyRequest; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** An abstract representation of a vector store chunking strategy configuration. */ -export interface VectorStoreChunkingStrategyRequestParent { - type: VectorStoreChunkingStrategyRequestType; -} - -/** The default strategy. This strategy currently uses a max_chunk_size_tokens of 800 and chunk_overlap_tokens of 400. */ -export interface VectorStoreAutoChunkingStrategyRequest - extends VectorStoreChunkingStrategyRequestParent { - /** The object type, which is always 'auto'. */ - type: "auto"; -} - -/** A statically configured chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyRequest - extends VectorStoreChunkingStrategyRequestParent { - /** The object type, which is always 'static'. */ - type: "static"; - /** The options for the static chunking strategy. */ - static: VectorStoreStaticChunkingStrategyOptions; -} - -/** Options to configure a vector store static chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyOptions { - /** The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. */ - max_chunk_size_tokens: number; - /** - * The number of tokens that overlap between chunks. The default value is 400. - * Note that the overlap must not exceed half of max_chunk_size_tokens. - */ - chunk_overlap_tokens: number; -} - -/** Request object for updating a vector store. */ -export interface VectorStoreUpdateOptions { - /** The name of the vector store. */ - name?: string | null; - /** Details on when this vector store expires */ - expires_after?: VectorStoreExpirationPolicy | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata?: Record | null; -} - -/** Evaluation Definition */ -export interface Evaluation { - /** Data for evaluation. */ - data: InputData; - /** Evaluation target specifying the model config and parameters */ - target?: EvaluationTarget; - /** Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. */ - displayName?: string; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; -} - -/** Abstract data class for input data configuration. */ -export interface InputDataParent { - type: string; -} - -/** Data Source for Application Insights. */ -export interface ApplicationInsightsConfiguration extends InputDataParent { - /** LogAnalytic Workspace resourceID associated with ApplicationInsights */ - resourceId: string; - /** Query to fetch the data. */ - query: string; - /** Service name. */ - serviceName?: string; - /** Connection String to connect to ApplicationInsights. */ - connectionString?: string; -} - -/** Dataset as source for evaluation. */ -export interface Dataset extends InputDataParent { - /** Evaluation input data */ - id: string; -} - -/** Target for the evaluation process. */ -export interface EvaluationTarget { - /** System message related to the evaluation target. */ - systemMessage: string; - /** Model configuration for the evaluation. */ - modelConfig: TargetModelConfig; - /** A dictionary of parameters for the model. */ - modelParams?: Record; -} - -/** Abstract class for model configuration. */ -export interface TargetModelConfigParent { - type: string; -} - -/** Azure OpenAI model configuration. The API version would be selected by the service for querying the model. */ -export interface AoaiModelConfig extends TargetModelConfigParent { - /** Endpoint targetURI for AOAI model. */ - azureEndpoint: string; - /** API Key for AOAI model. */ - apiKey: string; - /** Deployment name for AOAI model. */ - azureDeployment: string; -} - -/** MaaS model configuration. The API version would be selected by the service for querying the model. */ -export interface MaasModelConfig extends TargetModelConfigParent { - /** Endpoint targetURI for MAAS model. */ - azureEndpoint: string; - /** API Key for MAAS model. */ - apiKey: string; -} - -/** Metadata pertaining to creation and last modification of the resource. */ -export interface SystemData {} - -/** Evaluator Configuration */ -export interface EvaluatorConfiguration { - /** Identifier of the evaluator. */ - id: string; - /** Initialization parameters of the evaluator. */ - initParams?: Record; - /** Data parameters of the evaluator. */ - dataMapping?: Record; -} - -/** Evaluation Schedule Definition */ -export interface EvaluationSchedule { - /** Data for evaluation. */ - data: ApplicationInsightsConfiguration; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; - /** Trigger for the evaluation. */ - trigger: Trigger; -} - -/** Abstract data class for input data configuration. */ -export interface TriggerParent { - type: string; -} - -/** Recurrence Trigger Definition */ -export interface RecurrenceTrigger extends TriggerParent { - /** - * The frequency to trigger schedule. - * - * Possible values: "Month", "Week", "Day", "Hour", "Minute" - */ - frequency: Frequency; - /** Specifies schedule interval in conjunction with frequency */ - interval: number; - /** The recurrence schedule. */ - schedule?: RecurrenceSchedule; -} - -/** RecurrenceSchedule Definition */ -export interface RecurrenceSchedule { - /** List of hours for the schedule. */ - hours: number[]; - /** List of minutes for the schedule. */ - minutes: number[]; - /** List of days for the schedule. */ - weekDays?: WeekDays[]; - /** List of month days for the schedule */ - monthDays?: number[]; -} - -/** Cron Trigger Definition */ -export interface CronTrigger extends TriggerParent { - /** Cron expression for the trigger. */ - expression: string; -} - -/** An abstract representation of an input tool definition that an agent can use. */ -export type ToolDefinition = - | ToolDefinitionParent - | CodeInterpreterToolDefinition - | FileSearchToolDefinition - | FunctionToolDefinition - | BingGroundingToolDefinition - | MicrosoftFabricToolDefinition - | SharepointToolDefinition - | AzureAISearchToolDefinition - | OpenApiToolDefinition - | BingCustomSearchToolDefinition - | ConnectedAgentToolDefinition - | AzureFunctionToolDefinition; -/** authentication details for OpenApiFunctionDefinition */ -export type OpenApiAuthDetails = - | OpenApiAuthDetailsParent - | OpenApiAnonymousAuthDetails - | OpenApiConnectionAuthDetails - | OpenApiManagedAuthDetails; -/** Defines a single content block when creating a message. The 'type' field determines whether it is text, an image file, or an external image URL, etc. */ -export type MessageInputContentBlock = - | MessageInputContentBlockParent - | MessageInputTextBlock - | MessageInputImageFileBlock - | MessageInputImageUrlBlock; -/** An abstract representation of a vector store chunking strategy configuration. */ -export type VectorStoreChunkingStrategyRequest = - | VectorStoreChunkingStrategyRequestParent - | VectorStoreAutoChunkingStrategyRequest - | VectorStoreStaticChunkingStrategyRequest; -/** Abstract data class for input data configuration. */ -export type InputData = - | InputDataParent - | ApplicationInsightsConfiguration - | Dataset; -/** Abstract class for model configuration. */ -export type TargetModelConfig = - | TargetModelConfigParent - | AoaiModelConfig - | MaasModelConfig; -/** Abstract data class for input data configuration. */ -export type Trigger = TriggerParent | RecurrenceTrigger | CronTrigger; -/** Alias for OpenApiAuthType */ -export type OpenApiAuthType = string; -/** Alias for VectorStoreDataSourceAssetType */ -export type VectorStoreDataSourceAssetType = string; -/** Alias for AzureAISearchQueryType */ -export type AzureAISearchQueryType = string; -/** Alias for AgentsApiResponseFormatMode */ -export type AgentsApiResponseFormatMode = string; -/** Alias for ResponseFormat */ -export type ResponseFormat = string; -/** Alias for AgentsApiResponseFormatOption */ -export type AgentsApiResponseFormatOption = - | string - | AgentsApiResponseFormatMode - | AgentsApiResponseFormat - | ResponseFormatJsonSchemaType; -/** Alias for ListSortOrder */ -export type ListSortOrder = string; -/** Alias for MessageRole */ -export type MessageRole = string; -/** Alias for MessageBlockType */ -export type MessageBlockType = string; -/** Alias for ImageDetailLevel */ -export type ImageDetailLevel = string; -/** Alias for MessageInputContent */ -export type MessageInputContent = string | Array; -/** Alias for MessageAttachmentToolDefinition */ -export type MessageAttachmentToolDefinition = - | CodeInterpreterToolDefinition - | FileSearchToolDefinition; -/** Alias for RunAdditionalFieldList */ -export type RunAdditionalFieldList = string; -/** Alias for TruncationStrategy */ -export type TruncationStrategy = string; -/** Alias for AgentsApiToolChoiceOptionMode */ -export type AgentsApiToolChoiceOptionMode = string; -/** Alias for AgentsNamedToolChoiceType */ -export type AgentsNamedToolChoiceType = string; -/** Alias for AgentsApiToolChoiceOption */ -export type AgentsApiToolChoiceOption = - | string - | AgentsApiToolChoiceOptionMode - | AgentsNamedToolChoice; -/** Alias for FilePurpose */ -export type FilePurpose = string; -/** Alias for VectorStoreExpirationPolicyAnchor */ -export type VectorStoreExpirationPolicyAnchor = string; -/** Alias for VectorStoreChunkingStrategyRequestType */ -export type VectorStoreChunkingStrategyRequestType = string; -/** Alias for VectorStoreFileStatusFilter */ -export type VectorStoreFileStatusFilter = string; -/** Alias for ConnectionType */ -export type ConnectionType = string; -/** Alias for Frequency */ -export type Frequency = string; -/** Alias for WeekDays */ -export type WeekDays = string; diff --git a/sdk/ai/ai-projects/src/generated/src/outputModels.ts b/sdk/ai/ai-projects/src/generated/src/outputModels.ts deleted file mode 100644 index ee09f4611903..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/outputModels.ts +++ /dev/null @@ -1,1894 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -/** An abstract representation of an input tool definition that an agent can use. */ -export interface ToolDefinitionOutputParent { - type: string; -} - -/** The input definition information for a code interpreter tool as used to configure an agent. */ -export interface CodeInterpreterToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'code_interpreter'. */ - type: "code_interpreter"; -} - -/** The input definition information for a file search tool as used to configure an agent. */ -export interface FileSearchToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'file_search'. */ - type: "file_search"; - /** Options overrides for the file search tool. */ - file_search?: FileSearchToolDefinitionDetailsOutput; -} - -/** Options overrides for the file search tool. */ -export interface FileSearchToolDefinitionDetailsOutput { - /** - * The maximum number of results the file search tool should output. The default is 20 for gpt-4* models and 5 for gpt-3.5-turbo. This number should be between 1 and 50 inclusive. - * - * Note that the file search tool may output fewer than `max_num_results` results. See the file search tool documentation for more information. - */ - max_num_results?: number; - /** Ranking options for file search. */ - ranking_options?: FileSearchRankingOptionsOutput; -} - -/** Ranking options for file search. */ -export interface FileSearchRankingOptionsOutput { - /** File search ranker. */ - ranker: string; - /** Ranker search threshold. */ - score_threshold: number; -} - -/** The input definition information for a function tool as used to configure an agent. */ -export interface FunctionToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'function'. */ - type: "function"; - /** The definition of the concrete function that the function tool should call. */ - function: FunctionDefinitionOutput; -} - -/** The input definition information for a function. */ -export interface FunctionDefinitionOutput { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The parameters the functions accepts, described as a JSON Schema object. */ - parameters: any; -} - -/** The input definition information for a bing grounding search tool as used to configure an agent. */ -export interface BingGroundingToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'bing_grounding'. */ - type: "bing_grounding"; - /** The list of connections used by the bing grounding tool. */ - bing_grounding: ToolConnectionListOutput; -} - -/** A set of connection resources currently used by either the `bing_grounding`, `fabric_dataagent`, or `sharepoint_grounding` tools. */ -export interface ToolConnectionListOutput { - /** - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - connections?: Array; -} - -/** A connection resource. */ -export interface ToolConnectionOutput { - /** A connection in a ToolConnectionList attached to this tool. */ - connection_id: string; -} - -/** The input definition information for a Microsoft Fabric tool as used to configure an agent. */ -export interface MicrosoftFabricToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'fabric_dataagent'. */ - type: "fabric_dataagent"; - /** The list of connections used by the Microsoft Fabric tool. */ - fabric_dataagent: ToolConnectionListOutput; -} - -/** The input definition information for a sharepoint tool as used to configure an agent. */ -export interface SharepointToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'sharepoint_grounding'. */ - type: "sharepoint_grounding"; - /** The list of connections used by the SharePoint tool. */ - sharepoint_grounding: ToolConnectionListOutput; -} - -/** The input definition information for an Azure AI search tool as used to configure an agent. */ -export interface AzureAISearchToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'azure_ai_search'. */ - type: "azure_ai_search"; -} - -/** The input definition information for an OpenAPI tool as used to configure an agent. */ -export interface OpenApiToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'openapi'. */ - type: "openapi"; - /** The openapi function definition. */ - openapi: OpenApiFunctionDefinitionOutput; -} - -/** The input definition information for an openapi function. */ -export interface OpenApiFunctionDefinitionOutput { - /** The name of the function to be called. */ - name: string; - /** A description of what the function does, used by the model to choose when and how to call the function. */ - description?: string; - /** The openapi function shape, described as a JSON Schema object. */ - spec: any; - /** Open API authentication details */ - auth: OpenApiAuthDetailsOutput; - /** List of OpenAPI spec parameters that will use user-provided defaults */ - default_params?: string[]; -} - -/** authentication details for OpenApiFunctionDefinition */ -export interface OpenApiAuthDetailsOutputParent { - type: OpenApiAuthTypeOutput; -} - -/** Security details for OpenApi anonymous authentication */ -export interface OpenApiAnonymousAuthDetailsOutput - extends OpenApiAuthDetailsOutputParent { - /** The object type, which is always 'anonymous'. */ - type: "anonymous"; -} - -/** Security details for OpenApi connection authentication */ -export interface OpenApiConnectionAuthDetailsOutput - extends OpenApiAuthDetailsOutputParent { - /** The object type, which is always 'connection'. */ - type: "connection"; - /** Connection auth security details */ - security_scheme: OpenApiConnectionSecuritySchemeOutput; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiConnectionSecuritySchemeOutput { - /** Connection id for Connection auth type */ - connection_id: string; -} - -/** Security details for OpenApi managed_identity authentication */ -export interface OpenApiManagedAuthDetailsOutput - extends OpenApiAuthDetailsOutputParent { - /** The object type, which is always 'managed_identity'. */ - type: "managed_identity"; - /** Connection auth security details */ - security_scheme: OpenApiManagedSecuritySchemeOutput; -} - -/** Security scheme for OpenApi managed_identity authentication */ -export interface OpenApiManagedSecuritySchemeOutput { - /** Authentication scope for managed_identity auth type */ - audience: string; -} - -/** The input definition information for a Bing custom search tool as used to configure an agent. */ -export interface BingCustomSearchToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'bing_custom_search'. */ - type: "bing_custom_search"; - /** The list of search configurations used by the bing custom search tool. */ - bing_custom_search: SearchConfigurationListOutput; -} - -/** A list of search configurations currently used by the `bing_custom_search` tool. */ -export interface SearchConfigurationListOutput { - /** - * The connections attached to this tool. There can be a maximum of 1 connection - * resource attached to the tool. - */ - search_configurations: Array; -} - -/** A custom search configuration. */ -export interface SearchConfigurationOutput { - /** A connection in a ToolConnectionList attached to this tool. */ - connection_id: string; - /** Name of the custom configuration instance given to config. */ - instance_name: string; -} - -/** The input definition information for a connected agent tool which defines a domain specific sub-agent */ -export interface ConnectedAgentToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'connected_agent'. */ - type: "connected_agent"; - /** The sub-agent to connect */ - connected_agent: ConnectedAgentDetailsOutput; -} - -/** Information for connecting one agent to another as a tool */ -export interface ConnectedAgentDetailsOutput { - /** The identifier of the child agent. */ - id: string; - /** The name of the agent to be called. */ - name: string; - /** A description of what the agent does, used by the model to choose when and how to call the agent. */ - description: string; -} - -/** The input definition information for a azure function tool as used to configure an agent. */ -export interface AzureFunctionToolDefinitionOutput - extends ToolDefinitionOutputParent { - /** The object type, which is always 'azure_function'. */ - type: "azure_function"; - /** The definition of the concrete function that the function tool should call. */ - azure_function: AzureFunctionDefinitionOutput; -} - -/** The definition of Azure function. */ -export interface AzureFunctionDefinitionOutput { - /** The definition of azure function and its parameters. */ - function: FunctionDefinitionOutput; - /** Input storage queue. The queue storage trigger runs a function as messages are added to it. */ - input_binding: AzureFunctionBindingOutput; - /** Output storage queue. The function writes output to this queue when the input items are processed. */ - output_binding: AzureFunctionBindingOutput; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionBindingOutput { - /** The type of binding, which is always 'storage_queue'. */ - type: "storage_queue"; - /** Storage queue. */ - storage_queue: AzureFunctionStorageQueueOutput; -} - -/** The structure for keeping storage queue name and URI. */ -export interface AzureFunctionStorageQueueOutput { - /** URI to the Azure Storage Queue service allowing you to manipulate a queue. */ - queue_service_endpoint: string; - /** The name of an Azure function storage queue. */ - queue_name: string; -} - -/** - * A set of resources that are used by the agent's tools. The resources are specific to the type of - * tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` - * tool requires a list of vector store IDs. - */ -export interface ToolResourcesOutput { - /** Resources to be used by the `code_interpreter` tool consisting of file IDs. */ - code_interpreter?: CodeInterpreterToolResourceOutput; - /** Resources to be used by the `file_search` tool consisting of vector store IDs. */ - file_search?: FileSearchToolResourceOutput; - /** Resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azure_ai_search?: AzureAISearchResourceOutput; -} - -/** A set of resources that are used by the `code_interpreter` tool. */ -export interface CodeInterpreterToolResourceOutput { - /** - * A list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - file_ids?: string[]; - /** The data sources to be used. This option is mutually exclusive with the `fileIds` property. */ - data_sources?: Array; -} - -/** - * The structure, containing Azure asset URI path and the asset type of the file used as a data source - * for the enterprise file search. - */ -export interface VectorStoreDataSourceOutput { - /** Asset URI. */ - uri: string; - /** - * The asset type - * - * Possible values: "uri_asset", "id_asset" - */ - type: VectorStoreDataSourceAssetTypeOutput; -} - -/** A set of resources that are used by the `file_search` tool. */ -export interface FileSearchToolResourceOutput { - /** - * The ID of the vector store attached to this agent. There can be a maximum of 1 vector - * store attached to the agent. - */ - vector_store_ids?: string[]; - /** - * The list of vector store configuration objects from Azure. - * This list is limited to one element. - * The only element of this list contains the list of azure asset IDs used by the search tool. - */ - vector_stores?: Array; -} - -/** The structure, containing the list of vector storage configurations i.e. the list of azure asset IDs. */ -export interface VectorStoreConfigurationsOutput { - /** Name */ - name: string; - /** Configurations */ - configuration: VectorStoreConfigurationOutput; -} - -/** - * Vector storage configuration is the list of data sources, used when multiple - * files can be used for the enterprise file search. - */ -export interface VectorStoreConfigurationOutput { - /** Data sources */ - data_sources: Array; -} - -/** A set of index resources used by the `azure_ai_search` tool. */ -export interface AzureAISearchResourceOutput { - /** - * The indices attached to this agent. There can be a maximum of 1 index - * resource attached to the agent. - */ - indexes?: Array; -} - -/** A AI Search Index resource. */ -export interface AISearchIndexResourceOutput { - /** An index connection id in an IndexResource attached to this agent. */ - index_connection_id: string; - /** The name of an index in an IndexResource attached to this agent. */ - index_name: string; - /** - * Type of query in an AIIndexResource attached to this agent. - * - * Possible values: "simple", "semantic", "vector", "vector_simple_hybrid", "vector_semantic_hybrid" - */ - query_type?: AzureAISearchQueryTypeOutput; - /** Number of documents to retrieve from search and present to the model. */ - top_k?: number; - /** Odata filter string for search resource. */ - filter?: string; -} - -/** - * An object describing the expected output of the model. If `json_object` only `function` type `tools` are allowed to be passed to the Run. - * If `text` the model can return text or any value needed. - */ -export interface AgentsApiResponseFormatOutput { - /** - * Must be one of `text` or `json_object`. - * - * Possible values: "text", "json_object" - */ - type?: ResponseFormatOutput; -} - -/** The type of response format being defined: `json_schema` */ -export interface ResponseFormatJsonSchemaTypeOutput { - /** Type */ - type: "json_schema"; - /** The JSON schema, describing response format. */ - json_schema: ResponseFormatJsonSchemaOutput; -} - -/** A description of what the response format is for, used by the model to determine how to respond in the format. */ -export interface ResponseFormatJsonSchemaOutput { - /** A description of what the response format is for, used by the model to determine how to respond in the format. */ - description?: string; - /** The name of a schema. */ - name: string; - /** The JSON schema object, describing the response format. */ - schema: any; -} - -/** Represents an agent that can call the model and use tools. */ -export interface AgentOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always assistant. */ - object: "assistant"; - /** The Unix timestamp, in seconds, representing when this object was created. */ - created_at: number; - /** The name of the agent. */ - name: string | null; - /** The description of the agent. */ - description: string | null; - /** The ID of the model to use. */ - model: string; - /** The system instructions for the agent to use. */ - instructions: string | null; - /** The collection of tools enabled for the agent. */ - tools: Array; - /** - * A set of resources that are used by the agent's tools. The resources are specific to the type of tool. For example, the `code_interpreter` - * tool requires a list of file IDs, while the `file_search` tool requires a list of vector store IDs. - */ - tool_resources: ToolResourcesOutput | null; - /** - * 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. - */ - temperature: number | null; - /** - * An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are considered. - * - * We generally recommend altering this or temperature but not both. - */ - top_p: number | null; - /** The response format of the tool calls used by this agent. */ - response_format?: AgentsApiResponseFormatOptionOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfAgentOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - first_id: string; - /** The last ID represented in this list. */ - last_id: string; - /** A value indicating whether there are additional values available not captured in this list. */ - has_more: boolean; -} - -/** The status of an agent deletion operation. */ -export interface AgentDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'assistant.deleted'. */ - object: "assistant.deleted"; -} - -/** This describes to which tools a file has been attached. */ -export interface MessageAttachmentOutput { - /** The ID of the file to attach to the message. */ - file_id?: string; - /** Azure asset ID. */ - data_source?: VectorStoreDataSourceOutput; - /** The tools to add to this file. */ - tools: Array; -} - -/** Information about a single thread associated with an agent. */ -export interface AgentThreadOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread'. */ - object: "thread"; - /** The Unix timestamp, in seconds, representing when this object was created. */ - created_at: number; - /** - * A set of resources that are made available to the agent's tools in this thread. The resources are specific to the type - * of tool. For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list - * of vector store IDs. - */ - tool_resources: ToolResourcesOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** The status of a thread deletion operation. */ -export interface ThreadDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'thread.deleted'. */ - object: "thread.deleted"; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfAgentThreadOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - first_id: string; - /** The last ID represented in this list. */ - last_id: string; - /** A value indicating whether there are additional values available not captured in this list. */ - has_more: boolean; -} - -/** A single, existing message within an agent thread. */ -export interface ThreadMessageOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread.message'. */ - object: "thread.message"; - /** The Unix timestamp, in seconds, representing when this object was created. */ - created_at: number; - /** The ID of the thread that this message belongs to. */ - thread_id: string; - /** - * The status of the message. - * - * Possible values: "in_progress", "incomplete", "completed" - */ - status: MessageStatusOutput; - /** On an incomplete message, details about why the message is incomplete. */ - incomplete_details: MessageIncompleteDetailsOutput | null; - /** The Unix timestamp (in seconds) for when the message was completed. */ - completed_at: number | null; - /** The Unix timestamp (in seconds) for when the message was marked as incomplete. */ - incomplete_at: number | null; - /** - * The role associated with the agent thread message. - * - * Possible values: "user", "assistant" - */ - role: MessageRoleOutput; - /** The list of content items associated with the agent thread message. */ - content: Array; - /** If applicable, the ID of the agent that authored this message. */ - assistant_id: string | null; - /** If applicable, the ID of the run associated with the authoring of this message. */ - run_id: string | null; - /** A list of files attached to the message, and the tools they were added to. */ - attachments: Array | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** Information providing additional detail about a message entering an incomplete status. */ -export interface MessageIncompleteDetailsOutput { - /** - * The provided reason describing why the message was marked as incomplete. - * - * Possible values: "content_filter", "max_tokens", "run_cancelled", "run_failed", "run_expired" - */ - reason: MessageIncompleteDetailsReasonOutput; -} - -/** An abstract representation of a single item of thread message content. */ -export interface MessageContentOutputParent { - type: string; -} - -/** A representation of a textual item of thread message content. */ -export interface MessageTextContentOutput extends MessageContentOutputParent { - /** The object type, which is always 'text'. */ - type: "text"; - /** The text and associated annotations for this thread message content item. */ - text: MessageTextDetailsOutput; -} - -/** The text and associated annotations for a single item of agent thread message content. */ -export interface MessageTextDetailsOutput { - /** The text data. */ - value: string; - /** A list of annotations associated with this text. */ - annotations: Array; -} - -/** An abstract representation of an annotation to text thread message content. */ -export interface MessageTextAnnotationOutputParent { - /** The textual content associated with this text annotation item. */ - text: string; - type: string; -} - -/** A citation within the message that points to a specific URL associated with the message. Generated when the agent uses tools such as 'bing_grounding' to search the Internet. */ -export interface MessageTextUrlCitationAnnotationOutput - extends MessageTextAnnotationOutputParent { - /** The object type, which is always 'url_citation'. */ - type: "url_citation"; - /** The details of the URL citation. */ - url_citation: MessageTextUrlCitationDetailsOutput; - /** The first text index associated with this text annotation. */ - start_index?: number; - /** The last text index associated with this text annotation. */ - end_index?: number; -} - -/** A representation of a URL citation, as used in text thread message content. */ -export interface MessageTextUrlCitationDetailsOutput { - /** The URL associated with this citation. */ - url: string; - /** The title of the URL. */ - title?: string; -} - -/** A citation within the message that points to a specific quote from a specific File associated with the agent or the message. Generated when the agent uses the 'file_search' tool to search files. */ -export interface MessageTextFileCitationAnnotationOutput - extends MessageTextAnnotationOutputParent { - /** The object type, which is always 'file_citation'. */ - type: "file_citation"; - /** - * A citation within the message that points to a specific quote from a specific file. - * Generated when the agent uses the "file_search" tool to search files. - */ - file_citation: MessageTextFileCitationDetailsOutput; - /** The first text index associated with this text annotation. */ - start_index?: number; - /** The last text index associated with this text annotation. */ - end_index?: number; -} - -/** A representation of a file-based text citation, as used in a file-based annotation of text thread message content. */ -export interface MessageTextFileCitationDetailsOutput { - /** The ID of the file associated with this citation. */ - file_id: string; - /** The specific quote cited in the associated file. */ - quote: string; -} - -/** A citation within the message that points to a file located at a specific path. */ -export interface MessageTextFilePathAnnotationOutput - extends MessageTextAnnotationOutputParent { - /** The object type, which is always 'file_path'. */ - type: "file_path"; - /** A URL for the file that's generated when the agent used the code_interpreter tool to generate a file. */ - file_path: MessageTextFilePathDetailsOutput; - /** The first text index associated with this text annotation. */ - start_index?: number; - /** The last text index associated with this text annotation. */ - end_index?: number; -} - -/** An encapsulation of an image file ID, as used by message image content. */ -export interface MessageTextFilePathDetailsOutput { - /** The ID of the specific file that the citation is from. */ - file_id: string; -} - -/** A representation of image file content in a thread message. */ -export interface MessageImageFileContentOutput - extends MessageContentOutputParent { - /** The object type, which is always 'image_file'. */ - type: "image_file"; - /** The image file for this thread message content item. */ - image_file: MessageImageFileDetailsOutput; -} - -/** An image reference, as represented in thread message content. */ -export interface MessageImageFileDetailsOutput { - /** The ID for the file associated with this image. */ - file_id: string; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfThreadMessageOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - first_id: string; - /** The last ID represented in this list. */ - last_id: string; - /** A value indicating whether there are additional values available not captured in this list. */ - has_more: boolean; -} - -/** - * Controls for how a thread will be truncated prior to the run. Use this to control the initial - * context window of the run. - */ -export interface TruncationObjectOutput { - /** - * The truncation strategy to use for the thread. The default is `auto`. If set to `last_messages`, the thread will - * be truncated to the `lastMessages` count most recent messages in the thread. When set to `auto`, messages in the middle of the thread - * will be dropped to fit the context length of the model, `max_prompt_tokens`. - * - * Possible values: "auto", "last_messages" - */ - type: TruncationStrategyOutput; - /** The number of most recent messages from the thread when constructing the context for the run. */ - last_messages?: number | null; -} - -/** Specifies a tool the model should use. Use to force the model to call a specific tool. */ -export interface AgentsNamedToolChoiceOutput { - /** - * the type of tool. If type is `function`, the function name must be set. - * - * Possible values: "function", "code_interpreter", "file_search", "bing_grounding", "fabric_dataagent", "sharepoint_grounding", "azure_ai_search", "bing_custom_search", "connected_agent" - */ - type: AgentsNamedToolChoiceTypeOutput; - /** The name of the function to call */ - function?: FunctionNameOutput; -} - -/** The function name that will be used, if using the `function` tool */ -export interface FunctionNameOutput { - /** The name of the function to call */ - name: string; -} - -/** Data representing a single evaluation run of an agent thread. */ -export interface ThreadRunOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread.run'. */ - object: "thread.run"; - /** The ID of the thread associated with this run. */ - thread_id: string; - /** The ID of the agent associated with the thread this run was performed against. */ - assistant_id: string; - /** - * The status of the agent thread run. - * - * Possible values: "queued", "in_progress", "requires_action", "cancelling", "cancelled", "failed", "completed", "expired" - */ - status: RunStatusOutput; - /** The details of the action required for the agent thread run to continue. */ - required_action?: RequiredActionOutput | null; - /** The last error, if any, encountered by this agent thread run. */ - last_error: RunErrorOutput | null; - /** The ID of the model to use. */ - model: string; - /** The overridden system instructions used for this agent thread run. */ - instructions: string; - /** The overridden enabled tools used for this agent thread run. */ - tools: Array; - /** The Unix timestamp, in seconds, representing when this object was created. */ - created_at: number; - /** The Unix timestamp, in seconds, representing when this item expires. */ - expires_at: number | null; - /** The Unix timestamp, in seconds, representing when this item was started. */ - started_at: number | null; - /** The Unix timestamp, in seconds, representing when this completed. */ - completed_at: number | null; - /** The Unix timestamp, in seconds, representing when this was cancelled. */ - cancelled_at: number | null; - /** The Unix timestamp, in seconds, representing when this failed. */ - failed_at: number | null; - /** Details on why the run is incomplete. Will be `null` if the run is not incomplete. */ - incomplete_details: IncompleteRunDetailsOutput | null; - /** Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). */ - usage: RunCompletionUsageOutput | null; - /** The sampling temperature used for this run. If not set, defaults to 1. */ - temperature?: number | null; - /** The nucleus sampling value used for this run. If not set, defaults to 1. */ - top_p?: number | null; - /** The maximum number of prompt tokens specified to have been used over the course of the run. */ - max_prompt_tokens: number | null; - /** The maximum number of completion tokens specified to have been used over the course of the run. */ - max_completion_tokens: number | null; - /** The strategy to use for dropping messages as the context windows moves forward. */ - truncation_strategy: TruncationObjectOutput | null; - /** Controls whether or not and which tool is called by the model. */ - tool_choice: AgentsApiToolChoiceOptionOutput | null; - /** The response format of the tool calls used in this run. */ - response_format: AgentsApiResponseFormatOptionOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; - /** Override the tools the agent can use for this run. This is useful for modifying the behavior on a per-run basis */ - tool_resources?: UpdateToolResourcesOptionsOutput | null; - /** Determines if tools can be executed in parallel within the run. */ - parallel_tool_calls: boolean; -} - -/** An abstract representation of a required action for an agent thread run to continue. */ -export interface RequiredActionOutputParent { - type: string; -} - -/** The details for required tool calls that must be submitted for an agent thread run to continue. */ -export interface SubmitToolOutputsActionOutput - extends RequiredActionOutputParent { - /** The object type, which is always 'submit_tool_outputs'. */ - type: "submit_tool_outputs"; - /** The details describing tools that should be called to submit tool outputs. */ - submit_tool_outputs: SubmitToolOutputsDetailsOutput; -} - -/** The details describing tools that should be called to submit tool outputs. */ -export interface SubmitToolOutputsDetailsOutput { - /** The list of tool calls that must be resolved for the agent thread run to continue. */ - tool_calls: Array; -} - -/** An abstract representation of a tool invocation needed by the model to continue a run. */ -export interface RequiredToolCallOutputParent { - /** The ID of the tool call. This ID must be referenced when submitting tool outputs. */ - id: string; - type: string; -} - -/** A representation of a requested call to a function tool, needed by the model to continue evaluation of a run. */ -export interface RequiredFunctionToolCallOutput - extends RequiredToolCallOutputParent { - /** The object type of the required tool call. Always 'function' for function tools. */ - type: "function"; - /** Detailed information about the function to be executed by the tool that includes name and arguments. */ - function: RequiredFunctionToolCallDetailsOutput; -} - -/** The detailed information for a function invocation, as provided by a required action invoking a function tool, that includes the name of and arguments to the function. */ -export interface RequiredFunctionToolCallDetailsOutput { - /** The name of the function. */ - name: string; - /** The arguments to use when invoking the named function, as provided by the model. Arguments are presented as a JSON document that should be validated and parsed for evaluation. */ - arguments: string; -} - -/** The details of an error as encountered by an agent thread run. */ -export interface RunErrorOutput { - /** The status for the error. */ - code: string; - /** The human-readable text associated with the error. */ - message: string; -} - -/** Details on why the run is incomplete. Will be `null` if the run is not incomplete. */ -export interface IncompleteRunDetailsOutput { - /** - * The reason why the run is incomplete. This indicates which specific token limit was reached during the run. - * - * Possible values: "max_completion_tokens", "max_prompt_tokens" - */ - reason: IncompleteDetailsReasonOutput; -} - -/** Usage statistics related to the run. This value will be `null` if the run is not in a terminal state (i.e. `in_progress`, `queued`, etc.). */ -export interface RunCompletionUsageOutput { - /** Number of completion tokens used over the course of the run. */ - completion_tokens: number; - /** Number of prompt tokens used over the course of the run. */ - prompt_tokens: number; - /** Total number of tokens used (prompt + completion). */ - total_tokens: number; -} - -/** - * Request object. A set of resources that are used by the agent's tools. The resources are specific to the type of tool. - * For example, the `code_interpreter` tool requires a list of file IDs, while the `file_search` tool requires a list of - * vector store IDs. - */ -export interface UpdateToolResourcesOptionsOutput { - /** - * Overrides the list of file IDs made available to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. - */ - code_interpreter?: UpdateCodeInterpreterToolResourceOptionsOutput; - /** Overrides the vector store attached to this agent. There can be a maximum of 1 vector store attached to the agent. */ - file_search?: UpdateFileSearchToolResourceOptionsOutput; - /** Overrides the resources to be used by the `azure_ai_search` tool consisting of index IDs and names. */ - azure_ai_search?: AzureAISearchResourceOutput; -} - -/** Request object to update `code_interpreted` tool resources. */ -export interface UpdateCodeInterpreterToolResourceOptionsOutput { - /** A list of file IDs to override the current list of the agent. */ - file_ids?: string[]; -} - -/** Request object to update `file_search` tool resources. */ -export interface UpdateFileSearchToolResourceOptionsOutput { - /** A list of vector store IDs to override the current list of the agent. */ - vector_store_ids?: string[]; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfThreadRunOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - first_id: string; - /** The last ID represented in this list. */ - last_id: string; - /** A value indicating whether there are additional values available not captured in this list. */ - has_more: boolean; -} - -/** Detailed information about a single step of an agent thread run. */ -export interface RunStepOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always 'thread.run.step'. */ - object: "thread.run.step"; - /** - * The type of run step, which can be either message_creation or tool_calls. - * - * Possible values: "message_creation", "tool_calls" - */ - type: RunStepTypeOutput; - /** The ID of the agent associated with the run step. */ - assistant_id: string; - /** The ID of the thread that was run. */ - thread_id: string; - /** The ID of the run that this run step is a part of. */ - run_id: string; - /** - * The status of this run step. - * - * Possible values: "in_progress", "cancelled", "failed", "completed", "expired" - */ - status: RunStepStatusOutput; - /** The details for this run step. */ - step_details: RunStepDetailsOutput; - /** If applicable, information about the last error encountered by this run step. */ - last_error: RunStepErrorOutput | null; - /** The Unix timestamp, in seconds, representing when this object was created. */ - created_at: number; - /** The Unix timestamp, in seconds, representing when this item expired. */ - expired_at: number | null; - /** The Unix timestamp, in seconds, representing when this completed. */ - completed_at: number | null; - /** The Unix timestamp, in seconds, representing when this was cancelled. */ - cancelled_at: number | null; - /** The Unix timestamp, in seconds, representing when this failed. */ - failed_at: number | null; - /** Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. */ - usage?: RunStepCompletionUsageOutput | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** An abstract representation of the details for a run step. */ -export interface RunStepDetailsOutputParent { - type: RunStepTypeOutput; -} - -/** The detailed information associated with a message creation run step. */ -export interface RunStepMessageCreationDetailsOutput - extends RunStepDetailsOutputParent { - /** The object type, which is always 'message_creation'. */ - type: "message_creation"; - /** Information about the message creation associated with this run step. */ - message_creation: RunStepMessageCreationReferenceOutput; -} - -/** The details of a message created as a part of a run step. */ -export interface RunStepMessageCreationReferenceOutput { - /** The ID of the message created by this run step. */ - message_id: string; -} - -/** The detailed information associated with a run step calling tools. */ -export interface RunStepToolCallDetailsOutput - extends RunStepDetailsOutputParent { - /** The object type, which is always 'tool_calls'. */ - type: "tool_calls"; - /** A list of tool call details for this run step. */ - tool_calls: Array; -} - -/** An abstract representation of a detailed tool call as recorded within a run step for an existing run. */ -export interface RunStepToolCallOutputParent { - /** The ID of the tool call. This ID must be referenced when you submit tool outputs. */ - id: string; - type: string; -} - -/** - * A record of a call to a code interpreter tool, issued by the model in evaluation of a defined tool, that - * represents inputs and outputs consumed and emitted by the code interpreter. - */ -export interface RunStepCodeInterpreterToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'code_interpreter'. */ - type: "code_interpreter"; - /** The details of the tool call to the code interpreter tool. */ - code_interpreter: RunStepCodeInterpreterToolCallDetailsOutput; -} - -/** The detailed information about a code interpreter invocation by the model. */ -export interface RunStepCodeInterpreterToolCallDetailsOutput { - /** The input provided by the model to the code interpreter tool. */ - input: string; - /** The outputs produced by the code interpreter tool back to the model in response to the tool call. */ - outputs: Array; -} - -/** An abstract representation of an emitted output from a code interpreter tool. */ -export interface RunStepCodeInterpreterToolCallOutputOutputParent { - type: string; -} - -/** A representation of a log output emitted by a code interpreter tool in response to a tool call by the model. */ -export interface RunStepCodeInterpreterLogOutputOutput - extends RunStepCodeInterpreterToolCallOutputOutputParent { - /** The object type, which is always 'logs'. */ - type: "logs"; - /** The serialized log output emitted by the code interpreter. */ - logs: string; -} - -/** A representation of an image output emitted by a code interpreter tool in response to a tool call by the model. */ -export interface RunStepCodeInterpreterImageOutputOutput - extends RunStepCodeInterpreterToolCallOutputOutputParent { - /** The object type, which is always 'image'. */ - type: "image"; - /** Referential information for the image associated with this output. */ - image: RunStepCodeInterpreterImageReferenceOutput; -} - -/** An image reference emitted by a code interpreter tool in response to a tool call by the model. */ -export interface RunStepCodeInterpreterImageReferenceOutput { - /** The ID of the file associated with this image. */ - file_id: string; -} - -/** - * A record of a call to a file search tool, issued by the model in evaluation of a defined tool, that represents - * executed file search. - */ -export interface RunStepFileSearchToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'file_search'. */ - type: "file_search"; - /** The ID of the tool call. This ID must be referenced when you submit tool outputs. */ - id: string; - /** For now, this is always going to be an empty object. */ - file_search: RunStepFileSearchToolCallResultsOutput; -} - -/** The results of the file search. */ -export interface RunStepFileSearchToolCallResultsOutput { - /** Ranking options for file search. */ - ranking_options?: FileSearchRankingOptionsOutput; - /** The array of a file search results */ - results: Array; -} - -/** File search tool call result. */ -export interface RunStepFileSearchToolCallResultOutput { - /** The ID of the file that result was found in. */ - file_id: string; - /** The name of the file that result was found in. */ - file_name: string; - /** The score of the result. All values must be a floating point number between 0 and 1. */ - score: number; - /** The content of the result that was found. The content is only included if requested via the include query parameter. */ - content?: Array; -} - -/** The file search result content object. */ -export interface FileSearchToolCallContentOutput { - /** The type of the content. */ - type: "text"; - /** The text content of the file. */ - text: string; -} - -/** - * A record of a call to a bing grounding tool, issued by the model in evaluation of a defined tool, that represents - * executed search with bing grounding. - */ -export interface RunStepBingGroundingToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'bing_grounding'. */ - type: "bing_grounding"; - /** Reserved for future use. */ - bing_grounding: Record; -} - -/** - * A record of a call to an Azure AI Search tool, issued by the model in evaluation of a defined tool, that represents - * executed Azure AI search. - */ -export interface RunStepAzureAISearchToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'azure_ai_search'. */ - type: "azure_ai_search"; - /** Reserved for future use. */ - azure_ai_search: Record; -} - -/** - * A record of a call to a SharePoint tool, issued by the model in evaluation of a defined tool, that represents - * executed SharePoint actions. - */ -export interface RunStepSharepointToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'sharepoint_grounding'. */ - type: "sharepoint_grounding"; - /** Reserved for future use. */ - sharepoint_grounding: Record; -} - -/** - * A record of a call to a Microsoft Fabric tool, issued by the model in evaluation of a defined tool, that represents - * executed Microsoft Fabric operations. - */ -export interface RunStepMicrosoftFabricToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'fabric_dataagent'. */ - type: "fabric_dataagent"; - /** Reserved for future use. */ - fabric_dataagent: Record; -} - -/** - * A record of a call to a bing custom search tool, issued by the model in evaluation of a defined tool, that represents - * executed search with bing custom search. - */ -export interface RunStepCustomSearchToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'bing_custom_search'. */ - type: "bing_custom_search"; - /** Reserved for future use. */ - bing_custom_search: Record; -} - -/** - * A record of a call to a function tool, issued by the model in evaluation of a defined tool, that represents the inputs - * and output consumed and emitted by the specified function. - */ -export interface RunStepFunctionToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'function'. */ - type: "function"; - /** The detailed information about the function called by the model. */ - function: RunStepFunctionToolCallDetailsOutput; -} - -/** The detailed information about the function called by the model. */ -export interface RunStepFunctionToolCallDetailsOutput { - /** The name of the function. */ - name: string; - /** The arguments that the model requires are provided to the named function. */ - arguments: string; - /** The output of the function, only populated for function calls that have already have had their outputs submitted. */ - output: string | null; -} - -/** - * A record of a call to an OpenAPI tool, issued by the model in evaluation of a defined tool, that represents - * executed OpenAPI operations. - */ -export interface RunStepOpenAPIToolCallOutput - extends RunStepToolCallOutputParent { - /** The object type, which is always 'openapi'. */ - type: "openapi"; - /** Reserved for future use. */ - openapi: Record; -} - -/** The error information associated with a failed run step. */ -export interface RunStepErrorOutput { - /** - * The error code for this error. - * - * Possible values: "server_error", "rate_limit_exceeded" - */ - code: RunStepErrorCodeOutput; - /** The human-readable text associated with this error. */ - message: string; -} - -/** Usage statistics related to the run step. */ -export interface RunStepCompletionUsageOutput { - /** Number of completion tokens used over the course of the run step. */ - completion_tokens: number; - /** Number of prompt tokens used over the course of the run step. */ - prompt_tokens: number; - /** Total number of tokens used (prompt + completion). */ - total_tokens: number; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfRunStepOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - first_id: string; - /** The last ID represented in this list. */ - last_id: string; - /** A value indicating whether there are additional values available not captured in this list. */ - has_more: boolean; -} - -/** The response data from a file list operation. */ -export interface FileListResponseOutput { - /** The object type, which is always 'list'. */ - object: "list"; - /** The files returned for the request. */ - data: Array; -} - -/** Represents an agent that can call the model and use tools. */ -export interface OpenAIFileOutput { - /** The object type, which is always 'file'. */ - object: "file"; - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The size of the file, in bytes. */ - bytes: number; - /** The name of the file. */ - filename: string; - /** The Unix timestamp, in seconds, representing when this object was created. */ - created_at: number; - /** - * The intended purpose of a file. - * - * Possible values: "fine-tune", "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision" - */ - purpose: FilePurposeOutput; - /** - * The state of the file. This field is available in Azure OpenAI only. - * - * Possible values: "uploaded", "pending", "running", "processed", "error", "deleting", "deleted" - */ - status?: FileStateOutput; - /** The error message with details in case processing of this file failed. This field is available in Azure OpenAI only. */ - status_details?: string; -} - -/** A status response from a file deletion operation. */ -export interface FileDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'file'. */ - object: "file"; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfVectorStoreOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - first_id: string; - /** The last ID represented in this list. */ - last_id: string; - /** A value indicating whether there are additional values available not captured in this list. */ - has_more: boolean; -} - -/** A vector store is a collection of processed files can be used by the `file_search` tool. */ -export interface VectorStoreOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always `vector_store` */ - object: "vector_store"; - /** The Unix timestamp (in seconds) for when the vector store was created. */ - created_at: number; - /** The name of the vector store. */ - name: string; - /** The total number of bytes used by the files in the vector store. */ - usage_bytes: number; - /** Files count grouped by status processed or being processed by this vector store. */ - file_counts: VectorStoreFileCountOutput; - /** - * The status of the vector store, which can be either `expired`, `in_progress`, or `completed`. A status of `completed` indicates that the vector store is ready for use. - * - * Possible values: "expired", "in_progress", "completed" - */ - status: VectorStoreStatusOutput; - /** Details on when this vector store expires */ - expires_after?: VectorStoreExpirationPolicyOutput; - /** The Unix timestamp (in seconds) for when the vector store will expire. */ - expires_at?: number | null; - /** The Unix timestamp (in seconds) for when the vector store was last active. */ - last_active_at: number | null; - /** A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length. */ - metadata: Record | null; -} - -/** Counts of files processed or being processed by this vector store grouped by status. */ -export interface VectorStoreFileCountOutput { - /** The number of files that are currently being processed. */ - in_progress: number; - /** The number of files that have been successfully processed. */ - completed: number; - /** The number of files that have failed to process. */ - failed: number; - /** The number of files that were cancelled. */ - cancelled: number; - /** The total number of files. */ - total: number; -} - -/** The expiration policy for a vector store. */ -export interface VectorStoreExpirationPolicyOutput { - /** - * Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. - * - * Possible values: "last_active_at" - */ - anchor: VectorStoreExpirationPolicyAnchorOutput; - /** The anchor timestamp after which the expiration policy applies. */ - days: number; -} - -/** Options to configure a vector store static chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyOptionsOutput { - /** The maximum number of tokens in each chunk. The default value is 800. The minimum value is 100 and the maximum value is 4096. */ - max_chunk_size_tokens: number; - /** - * The number of tokens that overlap between chunks. The default value is 400. - * Note that the overlap must not exceed half of max_chunk_size_tokens. - */ - chunk_overlap_tokens: number; -} - -/** Response object for deleting a vector store. */ -export interface VectorStoreDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'vector_store.deleted'. */ - object: "vector_store.deleted"; -} - -/** The response data for a requested list of items. */ -export interface OpenAIPageableListOfVectorStoreFileOutput { - /** The object type, which is always list. */ - object: "list"; - /** The requested list of items. */ - data: Array; - /** The first ID represented in this list. */ - first_id: string; - /** The last ID represented in this list. */ - last_id: string; - /** A value indicating whether there are additional values available not captured in this list. */ - has_more: boolean; -} - -/** Description of a file attached to a vector store. */ -export interface VectorStoreFileOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always `vector_store.file`. */ - object: "vector_store.file"; - /** - * The total vector store usage in bytes. Note that this may be different from the original file - * size. - */ - usage_bytes: number; - /** The Unix timestamp (in seconds) for when the vector store file was created. */ - created_at: number; - /** The ID of the vector store that the file is attached to. */ - vector_store_id: string; - /** - * The status of the vector store file, which can be either `in_progress`, `completed`, `cancelled`, or `failed`. The status `completed` indicates that the vector store file is ready for use. - * - * Possible values: "in_progress", "completed", "failed", "cancelled" - */ - status: VectorStoreFileStatusOutput; - /** The last error associated with this vector store file. Will be `null` if there are no errors. */ - last_error: VectorStoreFileErrorOutput | null; - /** The strategy used to chunk the file. */ - chunking_strategy: VectorStoreChunkingStrategyResponseOutput; -} - -/** Details on the error that may have occurred while processing a file for this vector store */ -export interface VectorStoreFileErrorOutput { - /** - * One of `server_error` or `rate_limit_exceeded`. - * - * Possible values: "server_error", "invalid_file", "unsupported_file" - */ - code: VectorStoreFileErrorCodeOutput; - /** A human-readable description of the error. */ - message: string; -} - -/** An abstract representation of a vector store chunking strategy configuration. */ -export interface VectorStoreChunkingStrategyResponseOutputParent { - type: VectorStoreChunkingStrategyResponseTypeOutput; -} - -/** This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the chunking_strategy concept was introduced in the API. */ -export interface VectorStoreAutoChunkingStrategyResponseOutput - extends VectorStoreChunkingStrategyResponseOutputParent { - /** The object type, which is always 'other'. */ - type: "other"; -} - -/** A statically configured chunking strategy. */ -export interface VectorStoreStaticChunkingStrategyResponseOutput - extends VectorStoreChunkingStrategyResponseOutputParent { - /** The object type, which is always 'static'. */ - type: "static"; - /** The options for the static chunking strategy. */ - static: VectorStoreStaticChunkingStrategyOptionsOutput; -} - -/** Response object for deleting a vector store file relationship. */ -export interface VectorStoreFileDeletionStatusOutput { - /** The ID of the resource specified for deletion. */ - id: string; - /** A value indicating whether deletion was successful. */ - deleted: boolean; - /** The object type, which is always 'vector_store.deleted'. */ - object: "vector_store.file.deleted"; -} - -/** A batch of files attached to a vector store. */ -export interface VectorStoreFileBatchOutput { - /** The identifier, which can be referenced in API endpoints. */ - id: string; - /** The object type, which is always `vector_store.file_batch`. */ - object: "vector_store.files_batch"; - /** The Unix timestamp (in seconds) for when the vector store files batch was created. */ - created_at: number; - /** The ID of the vector store that the file is attached to. */ - vector_store_id: string; - /** - * The status of the vector store files batch, which can be either `in_progress`, `completed`, `cancelled` or `failed`. - * - * Possible values: "in_progress", "completed", "cancelled", "failed" - */ - status: VectorStoreFileBatchStatusOutput; - /** Files count grouped by status processed or being processed by this vector store. */ - file_counts: VectorStoreFileCountOutput; -} - -/** Response from the Workspace - Get operation */ -export interface GetWorkspaceResponseOutput { - /** A unique identifier for the resource */ - id: string; - /** The name of the resource */ - name: string; - /** The properties of the resource */ - properties: WorkspacePropertiesOutput; -} - -/** workspace properties */ -export interface WorkspacePropertiesOutput { - /** Authentication type of the connection target */ - applicationInsights: string; -} - -/** Response from the list operation */ -export interface ListConnectionsResponseOutput { - /** A list of connection list secrets */ - value: Array; -} - -/** Response from the listSecrets operation */ -export interface GetConnectionResponseOutput { - /** A unique identifier for the connection */ - id: string; - /** The name of the resource */ - name: string; - /** The properties of the resource */ - properties: InternalConnectionPropertiesOutput; -} - -/** Connection properties */ -export interface InternalConnectionPropertiesOutputParent { - /** - * Category of the connection - * - * Possible values: "AzureOpenAI", "Serverless", "AzureBlob", "AIServices", "CognitiveSearch", "ApiKey", "CustomKeys", "CognitiveService" - */ - category: ConnectionTypeOutput; - /** The connection URL to be used for this service */ - target: string; - authType: AuthenticationTypeOutput; -} - -/** Connection properties for connections with API key authentication */ -export interface InternalConnectionPropertiesApiKeyAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "ApiKey"; - /** Credentials will only be present for authType=ApiKey */ - credentials: CredentialsApiKeyAuthOutput; -} - -/** The credentials needed for API key authentication */ -export interface CredentialsApiKeyAuthOutput { - /** The API key */ - key: string; -} - -/** Connection properties for connections with AAD authentication (aka `Entra ID passthrough`) */ -export interface InternalConnectionPropertiesAADAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "AAD"; -} - -/** Connection properties for connections with Custom authentication */ -export interface InternalConnectionPropertiesCustomAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "CustomKeys"; -} - -/** Connection properties for connections with SAS authentication */ -export interface InternalConnectionPropertiesSASAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "SAS"; - /** Credentials will only be present for authType=ApiKey */ - credentials: CredentialsSASAuthOutput; -} - -/** The credentials needed for Shared Access Signatures (SAS) authentication */ -export interface CredentialsSASAuthOutput { - /** The Shared Access Signatures (SAS) token */ - SAS: string; -} - -/** Connection properties for connections with no authentication */ -export interface InternalConnectionPropertiesNoAuthOutput - extends InternalConnectionPropertiesOutputParent { - /** Authentication type of the connection target */ - authType: "None"; -} - -/** Response from getting properties of the Application Insights resource */ -export interface GetAppInsightsResponseOutput { - /** A unique identifier for the resource */ - id: string; - /** The name of the resource */ - name: string; - /** The properties of the resource */ - properties: AppInsightsPropertiesOutput; -} - -/** The properties of the Application Insights resource */ -export interface AppInsightsPropertiesOutput { - /** Authentication type of the connection target */ - ConnectionString: string; -} - -/** Evaluation Definition */ -export interface EvaluationOutput { - /** Identifier of the evaluation. */ - readonly id: string; - /** Data for evaluation. */ - data: InputDataOutput; - /** Evaluation target specifying the model config and parameters */ - target?: EvaluationTargetOutput; - /** Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. */ - displayName?: string; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Metadata containing createdBy and modifiedBy information. */ - readonly systemData?: SystemDataOutput; - /** Status of the evaluation. It is set by service and is read-only. */ - readonly status?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; -} - -/** Abstract data class for input data configuration. */ -export interface InputDataOutputParent { - type: string; -} - -/** Data Source for Application Insights. */ -export interface ApplicationInsightsConfigurationOutput - extends InputDataOutputParent { - readonly type: "app_insights"; - /** LogAnalytic Workspace resourceID associated with ApplicationInsights */ - resourceId: string; - /** Query to fetch the data. */ - query: string; - /** Service name. */ - serviceName?: string; - /** Connection String to connect to ApplicationInsights. */ - connectionString?: string; -} - -/** Dataset as source for evaluation. */ -export interface DatasetOutput extends InputDataOutputParent { - readonly type: "dataset"; - /** Evaluation input data */ - id: string; -} - -/** Target for the evaluation process. */ -export interface EvaluationTargetOutput { - /** System message related to the evaluation target. */ - systemMessage: string; - /** Model configuration for the evaluation. */ - modelConfig: TargetModelConfigOutput; - /** A dictionary of parameters for the model. */ - modelParams?: Record; -} - -/** Abstract class for model configuration. */ -export interface TargetModelConfigOutputParent { - type: string; -} - -/** Azure OpenAI model configuration. The API version would be selected by the service for querying the model. */ -export interface AoaiModelConfigOutput extends TargetModelConfigOutputParent { - readonly type: "AOAI"; - /** Endpoint targetURI for AOAI model. */ - azureEndpoint: string; - /** API Key for AOAI model. */ - apiKey: string; - /** Deployment name for AOAI model. */ - azureDeployment: string; -} - -/** MaaS model configuration. The API version would be selected by the service for querying the model. */ -export interface MaasModelConfigOutput extends TargetModelConfigOutputParent { - readonly type: "MAAS"; - /** Endpoint targetURI for MAAS model. */ - azureEndpoint: string; - /** API Key for MAAS model. */ - apiKey: string; -} - -/** Metadata pertaining to creation and last modification of the resource. */ -export interface SystemDataOutput { - /** The timestamp the resource was created at. */ - readonly createdAt?: string; - /** The identity that created the resource. */ - readonly createdBy?: string; - /** The identity type that created the resource. */ - readonly createdByType?: string; - /** The timestamp of resource last modification (UTC) */ - readonly lastModifiedAt?: string; -} - -/** Evaluator Configuration */ -export interface EvaluatorConfigurationOutput { - /** Identifier of the evaluator. */ - id: string; - /** Initialization parameters of the evaluator. */ - initParams?: Record; - /** Data parameters of the evaluator. */ - dataMapping?: Record; -} - -/** Paged collection of Evaluation items */ -export interface PagedEvaluationOutput { - /** The Evaluation items on this page */ - value: Array; - /** The link to the next page of items */ - nextLink?: string; -} - -/** Evaluation Schedule Definition */ -export interface EvaluationScheduleOutput { - /** Name of the schedule, which also serves as the unique identifier for the evaluation */ - readonly name: string; - /** Data for evaluation. */ - data: ApplicationInsightsConfigurationOutput; - /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ - description?: string; - /** Metadata containing createdBy and modifiedBy information. */ - readonly systemData?: SystemDataOutput; - /** Provisioning State of the evaluation. It is set by service and is read-only. */ - readonly provisioningState?: string; - /** Evaluation's tags. Unlike properties, tags are fully mutable. */ - tags?: Record; - /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ - properties?: Record; - /** Enabled status of the evaluation. It is set by service and is read-only. */ - readonly isEnabled?: string; - /** Evaluators to be used for the evaluation. */ - evaluators: Record; - /** Trigger for the evaluation. */ - trigger: TriggerOutput; -} - -/** Abstract data class for input data configuration. */ -export interface TriggerOutputParent { - type: string; -} - -/** Recurrence Trigger Definition */ -export interface RecurrenceTriggerOutput extends TriggerOutputParent { - readonly type: "Recurrence"; - /** - * The frequency to trigger schedule. - * - * Possible values: "Month", "Week", "Day", "Hour", "Minute" - */ - frequency: FrequencyOutput; - /** Specifies schedule interval in conjunction with frequency */ - interval: number; - /** The recurrence schedule. */ - schedule?: RecurrenceScheduleOutput; -} - -/** RecurrenceSchedule Definition */ -export interface RecurrenceScheduleOutput { - /** List of hours for the schedule. */ - hours: number[]; - /** List of minutes for the schedule. */ - minutes: number[]; - /** List of days for the schedule. */ - weekDays?: WeekDaysOutput[]; - /** List of month days for the schedule */ - monthDays?: number[]; -} - -/** Cron Trigger Definition */ -export interface CronTriggerOutput extends TriggerOutputParent { - readonly type: "Cron"; - /** Cron expression for the trigger. */ - expression: string; -} - -/** Paged collection of EvaluationSchedule items */ -export interface PagedEvaluationScheduleOutput { - /** The EvaluationSchedule items on this page */ - value: Array; - /** The link to the next page of items */ - nextLink?: string; -} - -/** An abstract representation of an input tool definition that an agent can use. */ -export type ToolDefinitionOutput = - | ToolDefinitionOutputParent - | CodeInterpreterToolDefinitionOutput - | FileSearchToolDefinitionOutput - | FunctionToolDefinitionOutput - | BingGroundingToolDefinitionOutput - | MicrosoftFabricToolDefinitionOutput - | SharepointToolDefinitionOutput - | AzureAISearchToolDefinitionOutput - | OpenApiToolDefinitionOutput - | BingCustomSearchToolDefinitionOutput - | ConnectedAgentToolDefinitionOutput - | AzureFunctionToolDefinitionOutput; -/** authentication details for OpenApiFunctionDefinition */ -export type OpenApiAuthDetailsOutput = - | OpenApiAuthDetailsOutputParent - | OpenApiAnonymousAuthDetailsOutput - | OpenApiConnectionAuthDetailsOutput - | OpenApiManagedAuthDetailsOutput; -/** An abstract representation of a single item of thread message content. */ -export type MessageContentOutput = - | MessageContentOutputParent - | MessageTextContentOutput - | MessageImageFileContentOutput; -/** An abstract representation of an annotation to text thread message content. */ -export type MessageTextAnnotationOutput = - | MessageTextAnnotationOutputParent - | MessageTextUrlCitationAnnotationOutput - | MessageTextFileCitationAnnotationOutput - | MessageTextFilePathAnnotationOutput; -/** An abstract representation of a required action for an agent thread run to continue. */ -export type RequiredActionOutput = - | RequiredActionOutputParent - | SubmitToolOutputsActionOutput; -/** An abstract representation of a tool invocation needed by the model to continue a run. */ -export type RequiredToolCallOutput = - | RequiredToolCallOutputParent - | RequiredFunctionToolCallOutput; -/** An abstract representation of the details for a run step. */ -export type RunStepDetailsOutput = - | RunStepDetailsOutputParent - | RunStepMessageCreationDetailsOutput - | RunStepToolCallDetailsOutput; -/** An abstract representation of a detailed tool call as recorded within a run step for an existing run. */ -export type RunStepToolCallOutput = - | RunStepToolCallOutputParent - | RunStepCodeInterpreterToolCallOutput - | RunStepFileSearchToolCallOutput - | RunStepBingGroundingToolCallOutput - | RunStepAzureAISearchToolCallOutput - | RunStepSharepointToolCallOutput - | RunStepMicrosoftFabricToolCallOutput - | RunStepCustomSearchToolCallOutput - | RunStepFunctionToolCallOutput - | RunStepOpenAPIToolCallOutput; -/** An abstract representation of an emitted output from a code interpreter tool. */ -export type RunStepCodeInterpreterToolCallOutputOutput = - | RunStepCodeInterpreterToolCallOutputOutputParent - | RunStepCodeInterpreterLogOutputOutput - | RunStepCodeInterpreterImageOutputOutput; -/** An abstract representation of a vector store chunking strategy configuration. */ -export type VectorStoreChunkingStrategyResponseOutput = - | VectorStoreChunkingStrategyResponseOutputParent - | VectorStoreAutoChunkingStrategyResponseOutput - | VectorStoreStaticChunkingStrategyResponseOutput; -/** Connection properties */ -export type InternalConnectionPropertiesOutput = - | InternalConnectionPropertiesOutputParent - | InternalConnectionPropertiesApiKeyAuthOutput - | InternalConnectionPropertiesAADAuthOutput - | InternalConnectionPropertiesCustomAuthOutput - | InternalConnectionPropertiesSASAuthOutput - | InternalConnectionPropertiesNoAuthOutput; -/** Abstract data class for input data configuration. */ -export type InputDataOutput = - | InputDataOutputParent - | ApplicationInsightsConfigurationOutput - | DatasetOutput; -/** Abstract class for model configuration. */ -export type TargetModelConfigOutput = - | TargetModelConfigOutputParent - | AoaiModelConfigOutput - | MaasModelConfigOutput; -/** Abstract data class for input data configuration. */ -export type TriggerOutput = - | TriggerOutputParent - | RecurrenceTriggerOutput - | CronTriggerOutput; -/** Alias for OpenApiAuthTypeOutput */ -export type OpenApiAuthTypeOutput = string; -/** Alias for VectorStoreDataSourceAssetTypeOutput */ -export type VectorStoreDataSourceAssetTypeOutput = string; -/** Alias for AzureAISearchQueryTypeOutput */ -export type AzureAISearchQueryTypeOutput = string; -/** Alias for AgentsApiResponseFormatModeOutput */ -export type AgentsApiResponseFormatModeOutput = string; -/** Alias for ResponseFormatOutput */ -export type ResponseFormatOutput = string; -/** Alias for AgentsApiResponseFormatOptionOutput */ -export type AgentsApiResponseFormatOptionOutput = - | string - | AgentsApiResponseFormatModeOutput - | AgentsApiResponseFormatOutput - | ResponseFormatJsonSchemaTypeOutput; -/** Alias for MessageRoleOutput */ -export type MessageRoleOutput = string; -/** Alias for MessageAttachmentToolDefinitionOutput */ -export type MessageAttachmentToolDefinitionOutput = - | CodeInterpreterToolDefinitionOutput - | FileSearchToolDefinitionOutput; -/** Alias for MessageStatusOutput */ -export type MessageStatusOutput = string; -/** Alias for MessageIncompleteDetailsReasonOutput */ -export type MessageIncompleteDetailsReasonOutput = string; -/** Alias for TruncationStrategyOutput */ -export type TruncationStrategyOutput = string; -/** Alias for AgentsApiToolChoiceOptionModeOutput */ -export type AgentsApiToolChoiceOptionModeOutput = string; -/** Alias for AgentsNamedToolChoiceTypeOutput */ -export type AgentsNamedToolChoiceTypeOutput = string; -/** Alias for AgentsApiToolChoiceOptionOutput */ -export type AgentsApiToolChoiceOptionOutput = - | string - | AgentsApiToolChoiceOptionModeOutput - | AgentsNamedToolChoiceOutput; -/** Alias for RunStatusOutput */ -export type RunStatusOutput = string; -/** Alias for IncompleteDetailsReasonOutput */ -export type IncompleteDetailsReasonOutput = string; -/** Alias for RunStepTypeOutput */ -export type RunStepTypeOutput = string; -/** Alias for RunStepStatusOutput */ -export type RunStepStatusOutput = string; -/** Alias for RunStepErrorCodeOutput */ -export type RunStepErrorCodeOutput = string; -/** Alias for FilePurposeOutput */ -export type FilePurposeOutput = string; -/** Alias for FileStateOutput */ -export type FileStateOutput = string; -/** Alias for VectorStoreStatusOutput */ -export type VectorStoreStatusOutput = string; -/** Alias for VectorStoreExpirationPolicyAnchorOutput */ -export type VectorStoreExpirationPolicyAnchorOutput = string; -/** Alias for VectorStoreFileStatusOutput */ -export type VectorStoreFileStatusOutput = string; -/** Alias for VectorStoreFileErrorCodeOutput */ -export type VectorStoreFileErrorCodeOutput = string; -/** Alias for VectorStoreChunkingStrategyResponseTypeOutput */ -export type VectorStoreChunkingStrategyResponseTypeOutput = string; -/** Alias for VectorStoreFileBatchStatusOutput */ -export type VectorStoreFileBatchStatusOutput = string; -/** Alias for ConnectionTypeOutput */ -export type ConnectionTypeOutput = string; -/** Authentication type used by Azure AI service to connect to another service */ -export type AuthenticationTypeOutput = - | "ApiKey" - | "AAD" - | "SAS" - | "CustomKeys" - | "None"; -/** Alias for FrequencyOutput */ -export type FrequencyOutput = string; -/** Alias for WeekDaysOutput */ -export type WeekDaysOutput = string; diff --git a/sdk/ai/ai-projects/src/generated/src/paginateHelper.ts b/sdk/ai/ai-projects/src/generated/src/paginateHelper.ts deleted file mode 100644 index 70694e2c93c6..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/paginateHelper.ts +++ /dev/null @@ -1,294 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; -import { createRestError } from "@azure-rest/core-client"; - -/** - * returns an async iterator that iterates over results. It also has a `byPage` - * method that returns pages of items at once. - * - * @param pagedResult - an object that specifies how to get pages. - * @returns a paged async iterator that iterates over results. - */ -function getPagedAsyncIterator< - TElement, - TPage = TElement[], - TPageSettings = PageSettings, - TLink = string, ->( - pagedResult: PagedResult, -): PagedAsyncIterableIterator { - const iter = getItemAsyncIterator( - pagedResult, - ); - return { - next() { - return iter.next(); - }, - [Symbol.asyncIterator]() { - return this; - }, - byPage: - pagedResult?.byPage ?? - (((settings?: PageSettings) => { - const { continuationToken } = settings ?? {}; - return getPageAsyncIterator(pagedResult, { - pageLink: continuationToken as unknown as TLink | undefined, - }); - }) as unknown as ( - settings?: TPageSettings, - ) => AsyncIterableIterator), - }; -} - -async function* getItemAsyncIterator( - pagedResult: PagedResult, -): AsyncIterableIterator { - const pages = getPageAsyncIterator(pagedResult); - const firstVal = await pages.next(); - // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is - if (!Array.isArray(firstVal.value)) { - // can extract elements from this page - const { toElements } = pagedResult; - if (toElements) { - yield* toElements(firstVal.value) as TElement[]; - for await (const page of pages) { - yield* toElements(page) as TElement[]; - } - } else { - yield firstVal.value; - // `pages` is of type `AsyncIterableIterator` but TPage = TElement in this case - yield* pages as unknown as AsyncIterableIterator; - } - } else { - yield* firstVal.value; - for await (const page of pages) { - // pages is of type `AsyncIterableIterator` so `page` is of type `TPage`. In this branch, - // it must be the case that `TPage = TElement[]` - yield* page as unknown as TElement[]; - } - } -} - -async function* getPageAsyncIterator( - pagedResult: PagedResult, - options: { - pageLink?: TLink; - } = {}, -): AsyncIterableIterator { - const { pageLink } = options; - let response = await pagedResult.getPage( - pageLink ?? pagedResult.firstPageLink, - ); - if (!response) { - return; - } - yield response.page; - while (response.nextPageLink) { - response = await pagedResult.getPage(response.nextPageLink); - if (!response) { - return; - } - yield response.page; - } -} - -/** - * An interface that tracks the settings for paged iteration - */ -export interface PageSettings { - /** - * The token that keeps track of where to continue the iterator - */ - continuationToken?: string; -} - -/** - * An interface that allows async iterable iteration both to completion and by page. - */ -export interface PagedAsyncIterableIterator< - TElement, - TPage = TElement[], - TPageSettings = PageSettings, -> { - /** - * The next method, part of the iteration protocol - */ - next(): Promise>; - /** - * The connection to the async iterator, part of the iteration protocol - */ - [Symbol.asyncIterator](): PagedAsyncIterableIterator< - TElement, - TPage, - TPageSettings - >; - /** - * Return an AsyncIterableIterator that works a page at a time - */ - byPage: (settings?: TPageSettings) => AsyncIterableIterator; -} - -/** - * An interface that describes how to communicate with the service. - */ -interface PagedResult { - /** - * Link to the first page of results. - */ - firstPageLink: TLink; - /** - * A method that returns a page of results. - */ - getPage: ( - pageLink: TLink, - ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; - /** - * a function to implement the `byPage` method on the paged async iterator. - */ - byPage?: (settings?: TPageSettings) => AsyncIterableIterator; - - /** - * A function to extract elements from a page. - */ - toElements?: (page: TPage) => unknown[]; -} - -/** - * Helper type to extract the type of an array - */ -export type GetArrayType = T extends Array ? TData : never; - -/** - * The type of a custom function that defines how to get a page and a link to the next one if any. - */ -export type GetPage = (pageLink: string) => Promise<{ - page: TPage; - nextPageLink?: string; -}>; - -/** - * Options for the paging helper - */ -export interface PagingOptions { - /** - * Custom function to extract pagination details for crating the PagedAsyncIterableIterator - */ - customGetPage?: GetPage[]>; -} - -/** - * Helper type to infer the Type of the paged elements from the response type - * This type is generated based on the swagger information for x-ms-pageable - * specifically on the itemName property which indicates the property of the response - * where the page items are found. The default value is `value`. - * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter - */ -export type PaginateReturn = TResult extends { - body: { value?: infer TPage }; -} - ? GetArrayType - : Array; - -/** - * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension - * @param client - Client to use for sending the next page requests - * @param initialResponse - Initial response containing the nextLink and current page of elements - * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results - * @returns - PagedAsyncIterableIterator to iterate the elements - */ -export function paginate( - client: Client, - initialResponse: TResponse, - options: PagingOptions = {}, -): PagedAsyncIterableIterator> { - // Extract element type from initial response - type TElement = PaginateReturn; - let firstRun = true; - const itemName = "value"; - const nextLinkName = "nextLink"; - const { customGetPage } = options; - const pagedResult: PagedResult = { - firstPageLink: "", - getPage: - typeof customGetPage === "function" - ? customGetPage - : async (pageLink: string) => { - const result = firstRun - ? initialResponse - : await client.pathUnchecked(pageLink).get(); - firstRun = false; - checkPagingRequest(result); - const nextLink = getNextLink(result.body, nextLinkName); - const values = getElements(result.body, itemName); - return { - page: values, - nextPageLink: nextLink, - }; - }, - }; - - return getPagedAsyncIterator(pagedResult); -} - -/** - * Gets for the value of nextLink in the body - */ -function getNextLink(body: unknown, nextLinkName?: string): string | undefined { - if (!nextLinkName) { - return undefined; - } - - const nextLink = (body as Record)[nextLinkName]; - - if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { - throw new Error( - `Body Property ${nextLinkName} should be a string or undefined`, - ); - } - - return nextLink; -} - -/** - * Gets the elements of the current request in the body. - */ -function getElements(body: unknown, itemName: string): T[] { - const value = (body as Record)[itemName] as T[]; - - // value has to be an array according to the x-ms-pageable extension. - // The fact that this must be an array is used above to calculate the - // type of elements in the page in PaginateReturn - if (!Array.isArray(value)) { - throw new Error( - `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, - ); - } - - return value ?? []; -} - -/** - * Checks if a request failed - */ -function checkPagingRequest(response: PathUncheckedResponse): void { - const Http2xxStatusCodes = [ - "200", - "201", - "202", - "203", - "204", - "205", - "206", - "207", - "208", - "226", - ]; - if (!Http2xxStatusCodes.includes(response.status)) { - throw createRestError( - `Pagination failed with unexpected statusCode ${response.status}`, - response, - ); - } -} diff --git a/sdk/ai/ai-projects/src/generated/src/parameters.ts b/sdk/ai/ai-projects/src/generated/src/parameters.ts deleted file mode 100644 index f30b410df823..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/parameters.ts +++ /dev/null @@ -1,596 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline"; -import type { RequestParameters } from "@azure-rest/core-client"; -import type { - CreateAgentOptions, - ListSortOrder, - UpdateAgentOptions, - AgentThreadCreationOptions, - UpdateAgentThreadOptions, - ThreadMessageOptions, - RunAdditionalFieldList, - CreateRunOptions, - ToolOutput, - CreateAndRunThreadOptions, - FilePurpose, - HttpPartFile, - HttpPartFilePurpose, - HttpPartString, - VectorStoreOptions, - VectorStoreUpdateOptions, - VectorStoreFileStatusFilter, - VectorStoreDataSource, - VectorStoreChunkingStrategyRequest, - ConnectionType, - Evaluation, - EvaluationSchedule, -} from "./models.js"; - -export interface CreateAgentBodyParam { - body: CreateAgentOptions; -} - -export type CreateAgentParameters = CreateAgentBodyParam & RequestParameters; - -export interface ListAgentsQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListAgentsQueryParam { - queryParameters?: ListAgentsQueryParamProperties; -} - -export type ListAgentsParameters = ListAgentsQueryParam & RequestParameters; -export type GetAgentParameters = RequestParameters; - -export interface UpdateAgentBodyParam { - body: UpdateAgentOptions; -} - -export type UpdateAgentParameters = UpdateAgentBodyParam & RequestParameters; -export type DeleteAgentParameters = RequestParameters; - -export interface CreateThreadBodyParam { - body: AgentThreadCreationOptions; -} - -export type CreateThreadParameters = CreateThreadBodyParam & RequestParameters; -export type GetThreadParameters = RequestParameters; - -export interface UpdateThreadBodyParam { - body: UpdateAgentThreadOptions; -} - -export type UpdateThreadParameters = UpdateThreadBodyParam & RequestParameters; -export type DeleteThreadParameters = RequestParameters; - -export interface ListThreadsQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListThreadsQueryParam { - queryParameters?: ListThreadsQueryParamProperties; -} - -export type ListThreadsParameters = ListThreadsQueryParam & RequestParameters; - -export interface CreateMessageBodyParam { - body: ThreadMessageOptions; -} - -export type CreateMessageParameters = CreateMessageBodyParam & - RequestParameters; - -export interface ListMessagesQueryParamProperties { - /** Filter messages by the run ID that generated them. */ - runId?: string; - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListMessagesQueryParam { - queryParameters?: ListMessagesQueryParamProperties; -} - -export type ListMessagesParameters = ListMessagesQueryParam & RequestParameters; -export type GetMessageParameters = RequestParameters; - -export interface UpdateMessageBodyParam { - body: { metadata?: Record | null }; -} - -export type UpdateMessageParameters = UpdateMessageBodyParam & - RequestParameters; - -export interface CreateRunBodyParam { - body: CreateRunOptions; -} - -/** This is the wrapper object for the parameter `include[]` with explode set to false and style set to form. */ -export interface CreateRunIncludeQueryParam { - /** Value of the parameter */ - value: RunAdditionalFieldList[]; - /** Should we explode the value? */ - explode: false; - /** Style of the value */ - style: "form"; -} - -export interface CreateRunQueryParamProperties { - /** - * A list of additional fields to include in the response. - * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - */ - "include[]"?: RunAdditionalFieldList[] | CreateRunIncludeQueryParam; -} - -export interface CreateRunQueryParam { - queryParameters?: CreateRunQueryParamProperties; -} - -export type CreateRunParameters = CreateRunQueryParam & - CreateRunBodyParam & - RequestParameters; - -export interface ListRunsQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListRunsQueryParam { - queryParameters?: ListRunsQueryParamProperties; -} - -export type ListRunsParameters = ListRunsQueryParam & RequestParameters; -export type GetRunParameters = RequestParameters; - -export interface UpdateRunBodyParam { - body: { metadata?: Record | null }; -} - -export type UpdateRunParameters = UpdateRunBodyParam & RequestParameters; - -export interface SubmitToolOutputsToRunBodyParam { - body: { tool_outputs: Array; stream?: boolean | null }; -} - -export type SubmitToolOutputsToRunParameters = SubmitToolOutputsToRunBodyParam & - RequestParameters; -export type CancelRunParameters = RequestParameters; - -export interface CreateThreadAndRunBodyParam { - body: CreateAndRunThreadOptions; -} - -export type CreateThreadAndRunParameters = CreateThreadAndRunBodyParam & - RequestParameters; - -/** This is the wrapper object for the parameter `include[]` with explode set to false and style set to form. */ -export interface GetRunStepIncludeQueryParam { - /** Value of the parameter */ - value: RunAdditionalFieldList[]; - /** Should we explode the value? */ - explode: false; - /** Style of the value */ - style: "form"; -} - -export interface GetRunStepQueryParamProperties { - /** - * A list of additional fields to include in the response. - * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - */ - "include[]"?: RunAdditionalFieldList[] | GetRunStepIncludeQueryParam; -} - -export interface GetRunStepQueryParam { - queryParameters?: GetRunStepQueryParamProperties; -} - -export type GetRunStepParameters = GetRunStepQueryParam & RequestParameters; - -/** This is the wrapper object for the parameter `include[]` with explode set to false and style set to form. */ -export interface ListRunStepsIncludeQueryParam { - /** Value of the parameter */ - value: RunAdditionalFieldList[]; - /** Should we explode the value? */ - explode: false; - /** Style of the value */ - style: "form"; -} - -export interface ListRunStepsQueryParamProperties { - /** - * A list of additional fields to include in the response. - * Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content` to fetch the file search result content. - */ - "include[]"?: RunAdditionalFieldList[] | ListRunStepsIncludeQueryParam; - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListRunStepsQueryParam { - queryParameters?: ListRunStepsQueryParamProperties; -} - -export type ListRunStepsParameters = ListRunStepsQueryParam & RequestParameters; - -export interface ListFilesQueryParamProperties { - /** - * The purpose of the file. - * - * Possible values: "fine-tune", "fine-tune-results", "assistants", "assistants_output", "batch", "batch_output", "vision" - */ - purpose?: FilePurpose; -} - -export interface ListFilesQueryParam { - queryParameters?: ListFilesQueryParamProperties; -} - -export type ListFilesParameters = ListFilesQueryParam & RequestParameters; - -export interface UploadFileBodyParam { - /** Multipart body */ - body: - | FormData - | Array< - | { - name: "file"; - body: HttpPartFile; - filename?: string; - contentType?: string; - } - | { - name: "purpose"; - body: HttpPartFilePurpose; - filename?: string; - contentType?: string; - } - | { name: "filename"; body: HttpPartString } - >; -} - -export interface UploadFileMediaTypesParam { - /** The name of the file to upload. */ - contentType: "multipart/form-data"; -} - -export type UploadFileParameters = UploadFileMediaTypesParam & - UploadFileBodyParam & - RequestParameters; -export type DeleteFileParameters = RequestParameters; -export type GetFileParameters = RequestParameters; -export type GetFileContentParameters = RequestParameters; - -export interface ListVectorStoresQueryParamProperties { - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListVectorStoresQueryParam { - queryParameters?: ListVectorStoresQueryParamProperties; -} - -export type ListVectorStoresParameters = ListVectorStoresQueryParam & - RequestParameters; - -export interface CreateVectorStoreBodyParam { - body: VectorStoreOptions; -} - -export type CreateVectorStoreParameters = CreateVectorStoreBodyParam & - RequestParameters; -export type GetVectorStoreParameters = RequestParameters; - -export interface ModifyVectorStoreBodyParam { - body: VectorStoreUpdateOptions; -} - -export type ModifyVectorStoreParameters = ModifyVectorStoreBodyParam & - RequestParameters; -export type DeleteVectorStoreParameters = RequestParameters; - -export interface ListVectorStoreFilesQueryParamProperties { - /** - * Filter by file status. - * - * Possible values: "in_progress", "completed", "failed", "cancelled" - */ - filter?: VectorStoreFileStatusFilter; - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListVectorStoreFilesQueryParam { - queryParameters?: ListVectorStoreFilesQueryParamProperties; -} - -export type ListVectorStoreFilesParameters = ListVectorStoreFilesQueryParam & - RequestParameters; - -export interface CreateVectorStoreFileBodyParam { - body: { - file_id?: string; - data_source?: VectorStoreDataSource; - chunking_strategy?: VectorStoreChunkingStrategyRequest; - }; -} - -export type CreateVectorStoreFileParameters = CreateVectorStoreFileBodyParam & - RequestParameters; -export type GetVectorStoreFileParameters = RequestParameters; -export type DeleteVectorStoreFileParameters = RequestParameters; - -export interface CreateVectorStoreFileBatchBodyParam { - body: { - file_ids?: string[]; - data_sources?: Array; - chunking_strategy?: VectorStoreChunkingStrategyRequest; - }; -} - -export type CreateVectorStoreFileBatchParameters = - CreateVectorStoreFileBatchBodyParam & RequestParameters; -export type GetVectorStoreFileBatchParameters = RequestParameters; -export type CancelVectorStoreFileBatchParameters = RequestParameters; - -export interface ListVectorStoreFileBatchFilesQueryParamProperties { - /** - * Filter by file status. - * - * Possible values: "in_progress", "completed", "failed", "cancelled" - */ - filter?: VectorStoreFileStatusFilter; - /** A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20. */ - limit?: number; - /** - * Sort order by the created_at timestamp of the objects. asc for ascending order and desc for descending order. - * - * Possible values: "asc", "desc" - */ - order?: ListSortOrder; - /** A cursor for use in pagination. after 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 after=obj_foo in order to fetch the next page of the list. */ - after?: string; - /** 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. */ - before?: string; -} - -export interface ListVectorStoreFileBatchFilesQueryParam { - queryParameters?: ListVectorStoreFileBatchFilesQueryParamProperties; -} - -export type ListVectorStoreFileBatchFilesParameters = - ListVectorStoreFileBatchFilesQueryParam & RequestParameters; -export type GetWorkspaceParameters = RequestParameters; - -export interface ListConnectionsQueryParamProperties { - /** - * Category of the workspace connection. - * - * Possible values: "AzureOpenAI", "Serverless", "AzureBlob", "AIServices", "CognitiveSearch", "ApiKey", "CustomKeys", "CognitiveService" - */ - category?: ConnectionType; - /** Indicates whether to list datastores. Service default: do not list datastores. */ - includeAll?: boolean; - /** Target of the workspace connection. */ - target?: string; -} - -export interface ListConnectionsQueryParam { - queryParameters?: ListConnectionsQueryParamProperties; -} - -export type ListConnectionsParameters = ListConnectionsQueryParam & - RequestParameters; -export type GetConnectionParameters = RequestParameters; - -export interface GetConnectionWithSecretsBodyParam { - body: { ignored: string }; -} - -export type GetConnectionWithSecretsParameters = - GetConnectionWithSecretsBodyParam & RequestParameters; -export type GetAppInsightsParameters = RequestParameters; - -export interface GetHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface GetHeaderParam { - headers?: RawHttpHeadersInput & GetHeaders; -} - -export type GetParameters = GetHeaderParam & RequestParameters; - -export interface CreateBodyParam { - /** Evaluation to run. */ - body: Evaluation; -} - -export type CreateParameters = CreateBodyParam & RequestParameters; - -export interface ListHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface ListQueryParamProperties { - /** The number of result items to return. */ - top?: number; - /** The number of result items to skip. */ - skip?: number; - /** The maximum number of result items per page. */ - maxpagesize?: number; -} - -export interface ListQueryParam { - queryParameters?: ListQueryParamProperties; -} - -export interface ListHeaderParam { - headers?: RawHttpHeadersInput & ListHeaders; -} - -export type ListParameters = ListQueryParam & - ListHeaderParam & - RequestParameters; - -export interface UpdateHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The resource instance. */ -export type EvaluationResourceMergeAndPatch = Partial; - -export interface UpdateBodyParam { - /** The resource instance. */ - body: EvaluationResourceMergeAndPatch; -} - -export interface UpdateHeaderParam { - headers?: RawHttpHeadersInput & UpdateHeaders; -} - -export interface UpdateMediaTypesParam { - /** This request has a JSON Merge Patch body. */ - contentType: "application/merge-patch+json"; -} - -export type UpdateParameters = UpdateHeaderParam & - UpdateMediaTypesParam & - UpdateBodyParam & - RequestParameters; - -export interface GetScheduleHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface GetScheduleHeaderParam { - headers?: RawHttpHeadersInput & GetScheduleHeaders; -} - -export type GetScheduleParameters = GetScheduleHeaderParam & RequestParameters; - -export interface CreateOrReplaceScheduleHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface CreateOrReplaceScheduleBodyParam { - /** The resource instance. */ - body: EvaluationSchedule; -} - -export interface CreateOrReplaceScheduleHeaderParam { - headers?: RawHttpHeadersInput & CreateOrReplaceScheduleHeaders; -} - -export type CreateOrReplaceScheduleParameters = - CreateOrReplaceScheduleHeaderParam & - CreateOrReplaceScheduleBodyParam & - RequestParameters; - -export interface ListScheduleHeaders { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -export interface ListScheduleQueryParamProperties { - /** The number of result items to return. */ - top?: number; - /** The number of result items to skip. */ - skip?: number; - /** The maximum number of result items per page. */ - maxpagesize?: number; -} - -export interface ListScheduleQueryParam { - queryParameters?: ListScheduleQueryParamProperties; -} - -export interface ListScheduleHeaderParam { - headers?: RawHttpHeadersInput & ListScheduleHeaders; -} - -export type ListScheduleParameters = ListScheduleQueryParam & - ListScheduleHeaderParam & - RequestParameters; -export type DisableScheduleParameters = RequestParameters; diff --git a/sdk/ai/ai-projects/src/generated/src/projectsClient.ts b/sdk/ai/ai-projects/src/generated/src/projectsClient.ts deleted file mode 100644 index 6fea84080bbf..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/projectsClient.ts +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { ClientOptions } from "@azure-rest/core-client"; -import { getClient } from "@azure-rest/core-client"; -import { logger } from "./logger.js"; -import type { TokenCredential } from "@azure/core-auth"; -import type { ProjectsClient } from "./clientDefinitions.js"; - -/** The optional parameters for the client */ -export interface ProjectsClientOptions extends ClientOptions { - /** The api version option of the client */ - apiVersion?: string; -} - -/** - * Initialize a new instance of `ProjectsClient` - * @param endpointParam - The Azure AI Foundry project endpoint, in the form `https://.api.azureml.ms` or `https://..api.azureml.ms`, where is the Azure region where the project is deployed (e.g. westus) and is the GUID of the Enterprise private link. - * @param subscriptionId - The Azure subscription ID. - * @param resourceGroupName - The name of the Azure Resource Group. - * @param projectName - The Azure AI Foundry project name. - * @param credentials - uniquely identify client credential - * @param options - the parameter for all optional parameters - */ -export default function createClient( - endpointParam: string, - subscriptionId: string, - resourceGroupName: string, - projectName: string, - credentials: TokenCredential, - { apiVersion = "2024-07-01-preview", ...options }: ProjectsClientOptions = {}, -): ProjectsClient { - const endpointUrl = - options.endpoint ?? - options.baseUrl ?? - `${endpointParam}/agents/v1.0/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/${projectName}`; - const userAgentInfo = `azsdk-js-ai-projects-rest/1.0.0-beta.1`; - const userAgentPrefix = - options.userAgentOptions && options.userAgentOptions.userAgentPrefix - ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` - : `${userAgentInfo}`; - options = { - ...options, - userAgentOptions: { - userAgentPrefix, - }, - loggingOptions: { - logger: options.loggingOptions?.logger ?? logger.info, - }, - credentials: { - scopes: options.credentials?.scopes ?? [ - "https://management.azure.com/.default", - ], - }, - }; - const client = getClient(endpointUrl, credentials, options) as ProjectsClient; - - client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); - client.pipeline.addPolicy({ - name: "ClientApiVersionPolicy", - sendRequest: (req, next) => { - // Use the apiVersion defined in request url directly - // Append one if there is no apiVersion and we have one at client options - const url = new URL(req.url); - if (!url.searchParams.get("api-version") && apiVersion) { - req.url = `${req.url}${ - Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" - }api-version=${apiVersion}`; - } - - return next(req); - }, - }); - - return client; -} diff --git a/sdk/ai/ai-projects/src/generated/src/responses.ts b/sdk/ai/ai-projects/src/generated/src/responses.ts deleted file mode 100644 index d63dc7749290..000000000000 --- a/sdk/ai/ai-projects/src/generated/src/responses.ts +++ /dev/null @@ -1,995 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { RawHttpHeaders } from "@azure/core-rest-pipeline"; -import type { HttpResponse, ErrorResponse } from "@azure-rest/core-client"; -import type { - AgentOutput, - OpenAIPageableListOfAgentOutput, - AgentDeletionStatusOutput, - AgentThreadOutput, - ThreadDeletionStatusOutput, - OpenAIPageableListOfAgentThreadOutput, - ThreadMessageOutput, - OpenAIPageableListOfThreadMessageOutput, - ThreadRunOutput, - OpenAIPageableListOfThreadRunOutput, - RunStepOutput, - OpenAIPageableListOfRunStepOutput, - FileListResponseOutput, - OpenAIFileOutput, - FileDeletionStatusOutput, - OpenAIPageableListOfVectorStoreOutput, - VectorStoreOutput, - VectorStoreDeletionStatusOutput, - OpenAIPageableListOfVectorStoreFileOutput, - VectorStoreFileOutput, - VectorStoreFileDeletionStatusOutput, - VectorStoreFileBatchOutput, - GetWorkspaceResponseOutput, - ListConnectionsResponseOutput, - GetConnectionResponseOutput, - GetAppInsightsResponseOutput, - EvaluationOutput, - PagedEvaluationOutput, - EvaluationScheduleOutput, - PagedEvaluationScheduleOutput, -} from "./outputModels.js"; - -/** The new agent instance. */ -export interface CreateAgent200Response extends HttpResponse { - status: "200"; - body: AgentOutput; -} - -export interface CreateAgentDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateAgentDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateAgentDefaultHeaders; -} - -/** The requested list of agents. */ -export interface ListAgents200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfAgentOutput; -} - -export interface ListAgentsDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListAgentsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListAgentsDefaultHeaders; -} - -/** The requested agent instance. */ -export interface GetAgent200Response extends HttpResponse { - status: "200"; - body: AgentOutput; -} - -export interface GetAgentDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetAgentDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetAgentDefaultHeaders; -} - -/** The updated agent instance. */ -export interface UpdateAgent200Response extends HttpResponse { - status: "200"; - body: AgentOutput; -} - -export interface UpdateAgentDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface UpdateAgentDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & UpdateAgentDefaultHeaders; -} - -/** Status information about the requested deletion operation. */ -export interface DeleteAgent200Response extends HttpResponse { - status: "200"; - body: AgentDeletionStatusOutput; -} - -export interface DeleteAgentDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface DeleteAgentDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & DeleteAgentDefaultHeaders; -} - -/** Information about the newly created thread. */ -export interface CreateThread200Response extends HttpResponse { - status: "200"; - body: AgentThreadOutput; -} - -export interface CreateThreadDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateThreadDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateThreadDefaultHeaders; -} - -/** Information about the requested thread. */ -export interface GetThread200Response extends HttpResponse { - status: "200"; - body: AgentThreadOutput; -} - -export interface GetThreadDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetThreadDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetThreadDefaultHeaders; -} - -/** Information about the modified thread. */ -export interface UpdateThread200Response extends HttpResponse { - status: "200"; - body: AgentThreadOutput; -} - -export interface UpdateThreadDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface UpdateThreadDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & UpdateThreadDefaultHeaders; -} - -/** Status information about the requested thread deletion operation. */ -export interface DeleteThread200Response extends HttpResponse { - status: "200"; - body: ThreadDeletionStatusOutput; -} - -export interface DeleteThreadDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface DeleteThreadDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & DeleteThreadDefaultHeaders; -} - -/** The requested list of threads. */ -export interface ListThreads200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfAgentThreadOutput; -} - -export interface ListThreadsDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListThreadsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListThreadsDefaultHeaders; -} - -/** A representation of the new message. */ -export interface CreateMessage200Response extends HttpResponse { - status: "200"; - body: ThreadMessageOutput; -} - -export interface CreateMessageDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateMessageDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateMessageDefaultHeaders; -} - -/** The requested list of messages. */ -export interface ListMessages200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfThreadMessageOutput; -} - -export interface ListMessagesDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListMessagesDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListMessagesDefaultHeaders; -} - -/** A representation of the requested message. */ -export interface GetMessage200Response extends HttpResponse { - status: "200"; - body: ThreadMessageOutput; -} - -export interface GetMessageDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetMessageDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetMessageDefaultHeaders; -} - -/** A representation of the modified message. */ -export interface UpdateMessage200Response extends HttpResponse { - status: "200"; - body: ThreadMessageOutput; -} - -export interface UpdateMessageDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface UpdateMessageDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & UpdateMessageDefaultHeaders; -} - -/** Information about the new thread run. */ -export interface CreateRun200Response extends HttpResponse { - status: "200"; - body: ThreadRunOutput; -} - -export interface CreateRunDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateRunDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateRunDefaultHeaders; -} - -/** The requested list of thread runs. */ -export interface ListRuns200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfThreadRunOutput; -} - -export interface ListRunsDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListRunsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListRunsDefaultHeaders; -} - -/** The requested information about the specified thread run. */ -export interface GetRun200Response extends HttpResponse { - status: "200"; - body: ThreadRunOutput; -} - -export interface GetRunDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetRunDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetRunDefaultHeaders; -} - -/** Information about the modified run. */ -export interface UpdateRun200Response extends HttpResponse { - status: "200"; - body: ThreadRunOutput; -} - -export interface UpdateRunDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface UpdateRunDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & UpdateRunDefaultHeaders; -} - -/** Updated information about the run. */ -export interface SubmitToolOutputsToRun200Response extends HttpResponse { - status: "200"; - body: ThreadRunOutput; -} - -export interface SubmitToolOutputsToRunDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface SubmitToolOutputsToRunDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & SubmitToolOutputsToRunDefaultHeaders; -} - -/** Updated information about the cancelled run. */ -export interface CancelRun200Response extends HttpResponse { - status: "200"; - body: ThreadRunOutput; -} - -export interface CancelRunDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CancelRunDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CancelRunDefaultHeaders; -} - -/** Information about the newly created thread. */ -export interface CreateThreadAndRun200Response extends HttpResponse { - status: "200"; - body: ThreadRunOutput; -} - -export interface CreateThreadAndRunDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateThreadAndRunDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateThreadAndRunDefaultHeaders; -} - -/** Information about the requested run step. */ -export interface GetRunStep200Response extends HttpResponse { - status: "200"; - body: RunStepOutput; -} - -export interface GetRunStepDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetRunStepDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetRunStepDefaultHeaders; -} - -/** The requested list of run steps. */ -export interface ListRunSteps200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfRunStepOutput; -} - -export interface ListRunStepsDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListRunStepsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListRunStepsDefaultHeaders; -} - -/** The requested list of files. */ -export interface ListFiles200Response extends HttpResponse { - status: "200"; - body: FileListResponseOutput; -} - -export interface ListFilesDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListFilesDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListFilesDefaultHeaders; -} - -/** A representation of the uploaded file. */ -export interface UploadFile200Response extends HttpResponse { - status: "200"; - body: OpenAIFileOutput; -} - -export interface UploadFileDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface UploadFileDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & UploadFileDefaultHeaders; -} - -/** The request has succeeded. */ -export interface DeleteFile200Response extends HttpResponse { - status: "200"; - body: FileDeletionStatusOutput; -} - -export interface DeleteFileDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface DeleteFileDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & DeleteFileDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetFile200Response extends HttpResponse { - status: "200"; - body: OpenAIFileOutput; -} - -export interface GetFileDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetFileDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetFileDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetFileContent200Response extends HttpResponse { - status: "200"; - /** Value may contain any sequence of octets */ - body: Uint8Array; -} - -export interface GetFileContentDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetFileContentDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetFileContentDefaultHeaders; -} - -/** The request has succeeded. */ -export interface ListVectorStores200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfVectorStoreOutput; -} - -export interface ListVectorStoresDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListVectorStoresDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListVectorStoresDefaultHeaders; -} - -/** The request has succeeded. */ -export interface CreateVectorStore200Response extends HttpResponse { - status: "200"; - body: VectorStoreOutput; -} - -export interface CreateVectorStoreDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateVectorStoreDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateVectorStoreDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetVectorStore200Response extends HttpResponse { - status: "200"; - body: VectorStoreOutput; -} - -export interface GetVectorStoreDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetVectorStoreDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetVectorStoreDefaultHeaders; -} - -/** The request has succeeded. */ -export interface ModifyVectorStore200Response extends HttpResponse { - status: "200"; - body: VectorStoreOutput; -} - -export interface ModifyVectorStoreDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ModifyVectorStoreDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ModifyVectorStoreDefaultHeaders; -} - -/** The request has succeeded. */ -export interface DeleteVectorStore200Response extends HttpResponse { - status: "200"; - body: VectorStoreDeletionStatusOutput; -} - -export interface DeleteVectorStoreDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface DeleteVectorStoreDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & DeleteVectorStoreDefaultHeaders; -} - -/** The request has succeeded. */ -export interface ListVectorStoreFiles200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfVectorStoreFileOutput; -} - -export interface ListVectorStoreFilesDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListVectorStoreFilesDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListVectorStoreFilesDefaultHeaders; -} - -/** The request has succeeded. */ -export interface CreateVectorStoreFile200Response extends HttpResponse { - status: "200"; - body: VectorStoreFileOutput; -} - -export interface CreateVectorStoreFileDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateVectorStoreFileDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateVectorStoreFileDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetVectorStoreFile200Response extends HttpResponse { - status: "200"; - body: VectorStoreFileOutput; -} - -export interface GetVectorStoreFileDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetVectorStoreFileDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetVectorStoreFileDefaultHeaders; -} - -/** The request has succeeded. */ -export interface DeleteVectorStoreFile200Response extends HttpResponse { - status: "200"; - body: VectorStoreFileDeletionStatusOutput; -} - -export interface DeleteVectorStoreFileDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface DeleteVectorStoreFileDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & DeleteVectorStoreFileDefaultHeaders; -} - -/** The request has succeeded. */ -export interface CreateVectorStoreFileBatch200Response extends HttpResponse { - status: "200"; - body: VectorStoreFileBatchOutput; -} - -export interface CreateVectorStoreFileBatchDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateVectorStoreFileBatchDefaultResponse - extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateVectorStoreFileBatchDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetVectorStoreFileBatch200Response extends HttpResponse { - status: "200"; - body: VectorStoreFileBatchOutput; -} - -export interface GetVectorStoreFileBatchDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetVectorStoreFileBatchDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetVectorStoreFileBatchDefaultHeaders; -} - -/** The request has succeeded. */ -export interface CancelVectorStoreFileBatch200Response extends HttpResponse { - status: "200"; - body: VectorStoreFileBatchOutput; -} - -export interface CancelVectorStoreFileBatchDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CancelVectorStoreFileBatchDefaultResponse - extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CancelVectorStoreFileBatchDefaultHeaders; -} - -/** The request has succeeded. */ -export interface ListVectorStoreFileBatchFiles200Response extends HttpResponse { - status: "200"; - body: OpenAIPageableListOfVectorStoreFileOutput; -} - -export interface ListVectorStoreFileBatchFilesDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListVectorStoreFileBatchFilesDefaultResponse - extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListVectorStoreFileBatchFilesDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetWorkspace200Response extends HttpResponse { - status: "200"; - body: GetWorkspaceResponseOutput; -} - -export interface GetWorkspaceDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetWorkspaceDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetWorkspaceDefaultHeaders; -} - -/** The request has succeeded. */ -export interface ListConnections200Response extends HttpResponse { - status: "200"; - body: ListConnectionsResponseOutput; -} - -export interface ListConnectionsDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListConnectionsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListConnectionsDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetConnection200Response extends HttpResponse { - status: "200"; - body: GetConnectionResponseOutput; -} - -export interface GetConnectionDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetConnectionDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetConnectionDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetConnectionWithSecrets200Response extends HttpResponse { - status: "200"; - body: GetConnectionResponseOutput; -} - -export interface GetConnectionWithSecretsDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetConnectionWithSecretsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetConnectionWithSecretsDefaultHeaders; -} - -/** The request has succeeded. */ -export interface GetAppInsights200Response extends HttpResponse { - status: "200"; - body: GetAppInsightsResponseOutput; -} - -export interface GetAppInsightsDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetAppInsightsDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetAppInsightsDefaultHeaders; -} - -export interface Get200Headers { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The request has succeeded. */ -export interface Get200Response extends HttpResponse { - status: "200"; - body: EvaluationOutput; - headers: RawHttpHeaders & Get200Headers; -} - -export interface GetDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetDefaultHeaders; -} - -/** Response model for create evaluation */ -export interface Create201Response extends HttpResponse { - status: "201"; - body: EvaluationOutput; -} - -export interface List200Headers { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The request has succeeded. */ -export interface List200Response extends HttpResponse { - status: "200"; - body: PagedEvaluationOutput; - headers: RawHttpHeaders & List200Headers; -} - -export interface ListDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListDefaultHeaders; -} - -export interface Update200Headers { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The request has succeeded. */ -export interface Update200Response extends HttpResponse { - status: "200"; - body: EvaluationOutput; - headers: RawHttpHeaders & Update200Headers; -} - -export interface UpdateDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface UpdateDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & UpdateDefaultHeaders; -} - -export interface GetSchedule200Headers { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The request has succeeded. */ -export interface GetSchedule200Response extends HttpResponse { - status: "200"; - body: EvaluationScheduleOutput; - headers: RawHttpHeaders & GetSchedule200Headers; -} - -export interface GetScheduleDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface GetScheduleDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & GetScheduleDefaultHeaders; -} - -export interface CreateOrReplaceSchedule200Headers { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The request has succeeded. */ -export interface CreateOrReplaceSchedule200Response extends HttpResponse { - status: "200"; - body: EvaluationScheduleOutput; - headers: RawHttpHeaders & CreateOrReplaceSchedule200Headers; -} - -export interface CreateOrReplaceSchedule201Headers { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The request has succeeded and a new resource has been created as a result. */ -export interface CreateOrReplaceSchedule201Response extends HttpResponse { - status: "201"; - body: EvaluationScheduleOutput; - headers: RawHttpHeaders & CreateOrReplaceSchedule201Headers; -} - -export interface CreateOrReplaceScheduleDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface CreateOrReplaceScheduleDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & CreateOrReplaceScheduleDefaultHeaders; -} - -export interface ListSchedule200Headers { - /** An opaque, globally-unique, client-generated string identifier for the request. */ - "x-ms-client-request-id"?: string; -} - -/** The request has succeeded. */ -export interface ListSchedule200Response extends HttpResponse { - status: "200"; - body: PagedEvaluationScheduleOutput; - headers: RawHttpHeaders & ListSchedule200Headers; -} - -export interface ListScheduleDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface ListScheduleDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & ListScheduleDefaultHeaders; -} - -/** There is no content to send for this request, but the headers may be useful. */ -export interface DisableSchedule204Response extends HttpResponse { - status: "204"; -} - -export interface DisableScheduleDefaultHeaders { - /** String error code indicating what went wrong. */ - "x-ms-error-code"?: string; -} - -export interface DisableScheduleDefaultResponse extends HttpResponse { - status: string; - body: ErrorResponse; - headers: RawHttpHeaders & DisableScheduleDefaultHeaders; -} diff --git a/sdk/ai/ai-projects/src/index.ts b/sdk/ai/ai-projects/src/index.ts index 6dbe4513961d..9feb87a0e269 100644 --- a/sdk/ai/ai-projects/src/index.ts +++ b/sdk/ai/ai-projects/src/index.ts @@ -1,20 +1,108 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. -import { AIProjectsClient, AIProjectsClientOptions } from "./aiProjectsClient.js"; -import { ProjectsClientOptions } from "./generated/src/projectsClient.js"; -export { AgentsOperations } from "./agents/index.js"; -export { ConnectionsOperations } from "./connections/index.js"; -export { TelemetryOperations, TelemetryOptions } from "./telemetry/index.js"; +import { + PageSettings, + ContinuablePage, + PagedAsyncIterableIterator, +} from "./static-helpers/pagingHelpers.js"; -export * from "./agents/inputOutputs.js"; -export * from "./connections/inputOutput.js"; -export { - AzureAISearchQueryType, - CreateAzureAISearchToolOptions, - BingCustomSearchToolDefinition, - SearchConfigurationList, - SearchConfiguration, -} from "./customization/models.js"; - -export { AIProjectsClient, AIProjectsClientOptions, ProjectsClientOptions }; +export { AIProjectClient } from "./aiProjectClient.js"; +export { + Connection, + ConnectionType, + BaseCredentials, + BaseCredentialsUnion, + CredentialType, + ApiKeyCredentials, + EntraIDCredentials, + CustomCredential, + SASCredentials, + NoAuthenticationCredentials, + Evaluation, + InputData, + InputDataUnion, + InputDataset, + EvaluatorConfiguration, + AgentEvaluationRequest, + AgentEvaluationSamplingConfiguration, + AgentEvaluationRedactionConfiguration, + AgentEvaluation, + AgentEvaluationResult, + DatasetVersion, + DatasetVersionUnion, + DatasetType, + FileDatasetVersion, + FolderDatasetVersion, + PendingUploadRequest, + PendingUploadResponse, + BlobReference, + SasCredential, + AssetCredentialResponse, + Index, + IndexUnion, + IndexType, + AzureAISearchIndex, + ManagedAzureAISearchIndex, + CosmosDBIndex, + EmbeddingConfiguration, + Deployment, + DeploymentUnion, + DeploymentType, + ModelDeployment, + Sku, + RedTeam, + AttackStrategy, + RiskCategory, + TargetConfig, + TargetConfigUnion, + AzureOpenAIModelConfiguration, + PendingUploadType, + KnownVersions, +} from "./models/index.js"; +export { AIProjectClientOptionalParams } from "./api/index.js"; +export { + ConnectionsListOptionalParams, + ConnectionsGetWithCredentialsOptionalParams, + ConnectionsGetOptionalParams, +} from "./api/connections/index.js"; +export { + DatasetsGetCredentialsOptionalParams, + DatasetsPendingUploadOptionalParams, + DatasetsCreateOrUpdateOptionalParams, + DatasetsDeleteOptionalParams, + DatasetsGetOptionalParams, + DatasetsListOptionalParams, + DatasetsListVersionsOptionalParams, +} from "./api/datasets/index.js"; +export { + DeploymentsListOptionalParams, + DeploymentsGetOptionalParams, +} from "./api/deployments/index.js"; +export { + EvaluationsCreateAgentEvaluationOptionalParams, + EvaluationsCreateOptionalParams, + EvaluationsListOptionalParams, + EvaluationsGetOptionalParams, +} from "./api/evaluations/index.js"; +export { + IndexesCreateOrUpdateOptionalParams, + IndexesDeleteOptionalParams, + IndexesGetOptionalParams, + IndexesListOptionalParams, + IndexesListVersionsOptionalParams, +} from "./api/indexes/index.js"; +export { + RedTeamsCreateOptionalParams, + RedTeamsListOptionalParams, + RedTeamsGetOptionalParams, +} from "./api/redTeams/index.js"; +export { + ConnectionsOperations, + DatasetsOperations, + DeploymentsOperations, + EvaluationsOperations, + IndexesOperations, + RedTeamsOperations, +} from "./classic/index.js"; +export { PageSettings, ContinuablePage, PagedAsyncIterableIterator }; diff --git a/sdk/ai/ai-projects/src/logger.ts b/sdk/ai/ai-projects/src/logger.ts index 9f092c1689f3..ac271f422ccc 100644 --- a/sdk/ai/ai-projects/src/logger.ts +++ b/sdk/ai/ai-projects/src/logger.ts @@ -2,5 +2,4 @@ // Licensed under the MIT License. import { createClientLogger } from "@azure/logger"; -import { PACKAGE_NAME } from "./constants.js"; -export const logger = createClientLogger(PACKAGE_NAME); +export const logger = createClientLogger("ai-projects"); diff --git a/sdk/ai/ai-projects/src/models/index.ts b/sdk/ai/ai-projects/src/models/index.ts new file mode 100644 index 000000000000..10badbdfd89e --- /dev/null +++ b/sdk/ai/ai-projects/src/models/index.ts @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export { + Connection, + ConnectionType, + BaseCredentials, + BaseCredentialsUnion, + CredentialType, + ApiKeyCredentials, + EntraIDCredentials, + CustomCredential, + SASCredentials, + NoAuthenticationCredentials, + Evaluation, + InputData, + InputDataUnion, + InputDataset, + EvaluatorConfiguration, + AgentEvaluationRequest, + AgentEvaluationSamplingConfiguration, + AgentEvaluationRedactionConfiguration, + AgentEvaluation, + AgentEvaluationResult, + DatasetVersion, + DatasetVersionUnion, + DatasetType, + FileDatasetVersion, + FolderDatasetVersion, + PendingUploadRequest, + PendingUploadResponse, + BlobReference, + SasCredential, + AssetCredentialResponse, + Index, + IndexUnion, + IndexType, + AzureAISearchIndex, + ManagedAzureAISearchIndex, + CosmosDBIndex, + EmbeddingConfiguration, + Deployment, + DeploymentUnion, + DeploymentType, + ModelDeployment, + Sku, + RedTeam, + AttackStrategy, + RiskCategory, + TargetConfig, + TargetConfigUnion, + AzureOpenAIModelConfiguration, + PendingUploadType, + KnownVersions, +} from "./models.js"; diff --git a/sdk/ai/ai-projects/src/models/models.ts b/sdk/ai/ai-projects/src/models/models.ts new file mode 100644 index 000000000000..cb95a16fbb7c --- /dev/null +++ b/sdk/ai/ai-projects/src/models/models.ts @@ -0,0 +1,1340 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Response from the list and get connections operations */ +export interface Connection { + /** The name of the resource */ + readonly name: string; + /** Category of the connection */ + readonly type: ConnectionType; + /** The connection URL to be used for this service */ + readonly target: string; + /** Whether the connection is tagged as the default connection of its type */ + readonly isDefault: boolean; + /** The credentials used by the connection */ + readonly credentials: BaseCredentialsUnion; + /** Metadata of the connection */ + readonly metadata: Record; +} + +export function connectionDeserializer(item: any): Connection { + return { + name: item["name"], + type: item["type"], + target: item["target"], + isDefault: item["isDefault"], + credentials: baseCredentialsUnionDeserializer(item["credentials"]), + metadata: item["metadata"], + }; +} + +/** The Type (or category) of the connection */ +export type ConnectionType = + | "AzureOpenAI" + | "AzureBlob" + | "AzureStorageAccount" + | "CognitiveSearch" + | "CosmosDB" + | "ApiKey" + | "AppConfig" + | "AppInsights" + | "CustomKeys"; + +/** A base class for connection credentials */ +export interface BaseCredentials { + /** The type of credential used by the connection */ + /** The discriminator possible values: ApiKey, AAD, CustomKeys, SAS, None */ + readonly type: CredentialType; +} + +export function baseCredentialsDeserializer(item: any): BaseCredentials { + return { + type: item["type"], + }; +} + +/** Alias for BaseCredentialsUnion */ +export type BaseCredentialsUnion = + | ApiKeyCredentials + | EntraIDCredentials + | CustomCredential + | SASCredentials + | NoAuthenticationCredentials + | BaseCredentials; + +export function baseCredentialsUnionDeserializer( + item: any, +): BaseCredentialsUnion { + switch (item.type) { + case "ApiKey": + return apiKeyCredentialsDeserializer(item as ApiKeyCredentials); + + case "AAD": + return entraIDCredentialsDeserializer(item as EntraIDCredentials); + + case "CustomKeys": + return customCredentialDeserializer(item as CustomCredential); + + case "SAS": + return sasCredentialsDeserializer(item as SASCredentials); + + case "None": + return noAuthenticationCredentialsDeserializer( + item as NoAuthenticationCredentials, + ); + + default: + return baseCredentialsDeserializer(item); + } +} + +/** The credential type used by the connection */ +export type CredentialType = "ApiKey" | "AAD" | "SAS" | "CustomKeys" | "None"; + +/** API Key Credential definition */ +export interface ApiKeyCredentials extends BaseCredentials { + /** The credential type */ + readonly type: "ApiKey"; + /** API Key */ + readonly apiKey?: string; +} + +export function apiKeyCredentialsDeserializer(item: any): ApiKeyCredentials { + return { + type: item["type"], + apiKey: item["key"], + }; +} + +/** Entra ID credential definition */ +export interface EntraIDCredentials extends BaseCredentials { + /** The credential type */ + readonly type: "AAD"; +} + +export function entraIDCredentialsDeserializer(item: any): EntraIDCredentials { + return { + type: item["type"], + }; +} + +/** Custom credential definition */ +export interface CustomCredential extends BaseCredentials { + /** The credential type */ + readonly type: "CustomKeys"; + /** The credential type */ + readonly keys: Record; +} + +export function customCredentialDeserializer(item: any): CustomCredential { + return { + type: item["type"], + keys: item["keys"], + }; +} + +/** Shared Access Signature (SAS) credential definition */ +export interface SASCredentials extends BaseCredentials { + /** The credential type */ + readonly type: "SAS"; + /** SAS token */ + readonly sasToken?: string; +} + +export function sasCredentialsDeserializer(item: any): SASCredentials { + return { + type: item["type"], + sasToken: item["SAS"], + }; +} + +/** Credentials that do not require authentication */ +export interface NoAuthenticationCredentials extends BaseCredentials { + /** The credential type */ + readonly type: "None"; +} + +export function noAuthenticationCredentialsDeserializer( + item: any, +): NoAuthenticationCredentials { + return { + type: item["type"], + }; +} + +/** Paged collection of Connection items */ +export interface _PagedConnection { + /** The Connection items on this page */ + value: Connection[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _pagedConnectionDeserializer(item: any): _PagedConnection { + return { + value: connectionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function connectionArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return connectionDeserializer(item); + }); +} + +/** Evaluation Definition */ +export interface Evaluation { + /** Identifier of the evaluation. */ + readonly name: string; + /** Data for evaluation. */ + data: InputDataUnion; + /** Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. */ + displayName?: string; + /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ + description?: string; + /** Status of the evaluation. It is set by service and is read-only. */ + readonly status?: string; + /** Evaluation's tags. Unlike properties, tags are fully mutable. */ + tags?: Record; + /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ + properties?: Record; + /** Evaluators to be used for the evaluation. */ + evaluators: Record; +} + +export function evaluationSerializer(item: Evaluation): any { + return { + data: inputDataUnionSerializer(item["data"]), + displayName: item["displayName"], + description: item["description"], + tags: item["tags"], + properties: item["properties"], + evaluators: evaluatorConfigurationRecordSerializer(item["evaluators"]), + }; +} + +export function evaluationDeserializer(item: any): Evaluation { + return { + name: item["id"], + data: inputDataUnionDeserializer(item["data"]), + displayName: item["displayName"], + description: item["description"], + status: item["status"], + tags: item["tags"], + properties: item["properties"], + evaluators: evaluatorConfigurationRecordDeserializer(item["evaluators"]), + }; +} + +/** Abstract data class. */ +export interface InputData { + /** Type of the data */ + /** The discriminator possible values: dataset */ + type: string; +} + +export function inputDataSerializer(item: InputData): any { + return { type: item["type"] }; +} + +export function inputDataDeserializer(item: any): InputData { + return { + type: item["type"], + }; +} + +/** Alias for InputDataUnion */ +export type InputDataUnion = InputDataset | InputData; + +export function inputDataUnionSerializer(item: InputDataUnion): any { + switch (item.type) { + case "dataset": + return inputDatasetSerializer(item as InputDataset); + + default: + return inputDataSerializer(item); + } +} + +export function inputDataUnionDeserializer(item: any): InputDataUnion { + switch (item.type) { + case "dataset": + return inputDatasetDeserializer(item as InputDataset); + + default: + return inputDataDeserializer(item); + } +} + +/** Dataset as source for evaluation. */ +export interface InputDataset extends InputData { + type: "dataset"; + /** Evaluation input data */ + id: string; +} + +export function inputDatasetSerializer(item: InputDataset): any { + return { type: item["type"], id: item["id"] }; +} + +export function inputDatasetDeserializer(item: any): InputDataset { + return { + type: item["type"], + id: item["id"], + }; +} + +export function evaluatorConfigurationRecordSerializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] + ? item[key] + : evaluatorConfigurationSerializer(item[key]); + }); + return result; +} + +export function evaluatorConfigurationRecordDeserializer( + item: Record, +): Record { + const result: Record = {}; + Object.keys(item).map((key) => { + result[key] = !item[key] + ? item[key] + : evaluatorConfigurationDeserializer(item[key]); + }); + return result; +} + +/** Evaluator Configuration */ +export interface EvaluatorConfiguration { + /** Identifier of the evaluator. */ + id: string; + /** Initialization parameters of the evaluator. */ + initParams?: Record; + /** Data parameters of the evaluator. */ + dataMapping?: Record; +} + +export function evaluatorConfigurationSerializer( + item: EvaluatorConfiguration, +): any { + return { + id: item["id"], + initParams: item["initParams"], + dataMapping: item["dataMapping"], + }; +} + +export function evaluatorConfigurationDeserializer( + item: any, +): EvaluatorConfiguration { + return { + id: item["id"], + initParams: item["initParams"], + dataMapping: item["dataMapping"], + }; +} + +/** Paged collection of Evaluation items */ +export interface _PagedEvaluation { + /** The Evaluation items on this page */ + value: Evaluation[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _pagedEvaluationDeserializer(item: any): _PagedEvaluation { + return { + value: evaluationArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function evaluationArraySerializer(result: Array): any[] { + return result.map((item) => { + return evaluationSerializer(item); + }); +} + +export function evaluationArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return evaluationDeserializer(item); + }); +} + +/** Evaluation request for agent run. */ +export interface AgentEvaluationRequest { + /** Identifier of the agent run. */ + runId: string; + /** Identifier of the agent thread. This field is mandatory currently, but it will be optional in the future. */ + threadId?: string; + /** Evaluators to be used for the evaluation. */ + evaluators: Record; + /** Sampling configuration for the evaluation. */ + samplingConfiguration?: AgentEvaluationSamplingConfiguration; + /** Redaction configuration for the evaluation. */ + redactionConfiguration?: AgentEvaluationRedactionConfiguration; + /** Pass the AppInsights connection string to the agent evaluation for the evaluation results and the errors logs. */ + appInsightsConnectionString: string; +} + +export function agentEvaluationRequestSerializer( + item: AgentEvaluationRequest, +): any { + return { + runId: item["runId"], + threadId: item["threadId"], + evaluators: evaluatorConfigurationRecordSerializer(item["evaluators"]), + samplingConfiguration: !item["samplingConfiguration"] + ? item["samplingConfiguration"] + : agentEvaluationSamplingConfigurationSerializer( + item["samplingConfiguration"], + ), + redactionConfiguration: !item["redactionConfiguration"] + ? item["redactionConfiguration"] + : agentEvaluationRedactionConfigurationSerializer( + item["redactionConfiguration"], + ), + appInsightsConnectionString: item["appInsightsConnectionString"], + }; +} + +/** Definition for sampling strategy. */ +export interface AgentEvaluationSamplingConfiguration { + /** Name of the sampling strategy. */ + name: string; + /** Percentage of sampling per hour (0-100). */ + samplingPercent: number; + /** Maximum request rate per hour (0 to 1000). */ + maxRequestRate: number; +} + +export function agentEvaluationSamplingConfigurationSerializer( + item: AgentEvaluationSamplingConfiguration, +): any { + return { + name: item["name"], + samplingPercent: item["samplingPercent"], + maxRequestRate: item["maxRequestRate"], + }; +} + +/** The redaction configuration will allow the user to control what is redacted. */ +export interface AgentEvaluationRedactionConfiguration { + /** Redact score properties. If not specified, the default is to redact in production. */ + redactScoreProperties?: boolean; +} + +export function agentEvaluationRedactionConfigurationSerializer( + item: AgentEvaluationRedactionConfiguration, +): any { + return { redactScoreProperties: item["redactScoreProperties"] }; +} + +/** Evaluation response for agent evaluation run. */ +export interface AgentEvaluation { + /** Identifier of the agent evaluation run. */ + id: string; + /** Status of the agent evaluation. Options: Running, Completed, Failed. */ + status: string; + /** The reason of the request failure for the long running process, if applicable. */ + error?: string; + /** The agent evaluation result. */ + result?: AgentEvaluationResult[]; +} + +export function agentEvaluationDeserializer(item: any): AgentEvaluation { + return { + id: item["id"], + status: item["status"], + error: item["error"], + result: !item["result"] + ? item["result"] + : agentEvaluationResultArrayDeserializer(item["result"]), + }; +} + +export function agentEvaluationResultArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return agentEvaluationResultDeserializer(item); + }); +} + +/** Result for the agent evaluation evaluator run. */ +export interface AgentEvaluationResult { + /** Evaluator's name. This is the name of the evaluator that was used to evaluate the agent's completion. */ + evaluator: string; + /** Identifier of the evaluator. */ + evaluatorId: string; + /** Score of the given evaluator. No restriction on range. */ + score: number; + /** Status of the evaluator result. Options: Running, Completed, Failed, NotApplicable. */ + status: string; + /** Reasoning for the evaluation result. */ + reason?: string; + /** Version of the evaluator that was used to evaluate the agent's completion. */ + version?: string; + /** The unique identifier of the thread. */ + threadId?: string; + /** The unique identifier of the run. */ + runId: string; + /** A string explaining why there was an error, if applicable. */ + error?: string; + /** Additional properties relevant to the evaluator. These will differ between evaluators. */ + additionalDetails?: Record; +} + +export function agentEvaluationResultDeserializer( + item: any, +): AgentEvaluationResult { + return { + evaluator: item["evaluator"], + evaluatorId: item["evaluatorId"], + score: item["score"], + status: item["status"], + reason: item["reason"], + version: item["version"], + threadId: item["threadId"], + runId: item["runId"], + error: item["error"], + additionalDetails: item["additionalDetails"], + }; +} + +/** Paged collection of DatasetVersion items */ +export interface _PagedDatasetVersion { + /** The DatasetVersion items on this page */ + value: DatasetVersionUnion[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _pagedDatasetVersionDeserializer( + item: any, +): _PagedDatasetVersion { + return { + value: datasetVersionUnionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function datasetVersionUnionArraySerializer( + result: Array, +): any[] { + return result.map((item) => { + return datasetVersionUnionSerializer(item); + }); +} + +export function datasetVersionUnionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return datasetVersionUnionDeserializer(item); + }); +} + +/** DatasetVersion Definition */ +export interface DatasetVersion { + /** URI of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330 */ + dataUri: string; + /** Dataset type */ + /** The discriminator possible values: uri_file, uri_folder */ + type: DatasetType; + /** Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted */ + readonly isReference?: boolean; + /** Asset ID, a unique identifier for the asset */ + readonly id?: string; + /** The name of the resource */ + readonly name: string; + /** The version of the resource */ + readonly version: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; +} + +export function datasetVersionSerializer(item: DatasetVersion): any { + return { + dataUri: item["dataUri"], + type: item["type"], + description: item["description"], + tags: item["tags"], + }; +} + +export function datasetVersionDeserializer(item: any): DatasetVersion { + return { + dataUri: item["dataUri"], + type: item["type"], + isReference: item["isReference"], + id: item["id"], + name: item["name"], + version: item["version"], + description: item["description"], + tags: item["tags"], + }; +} + +/** Alias for DatasetVersionUnion */ +export type DatasetVersionUnion = + | FileDatasetVersion + | FolderDatasetVersion + | DatasetVersion; + +export function datasetVersionUnionSerializer(item: DatasetVersionUnion): any { + switch (item.type) { + case "uri_file": + return fileDatasetVersionSerializer(item as FileDatasetVersion); + + case "uri_folder": + return folderDatasetVersionSerializer(item as FolderDatasetVersion); + + default: + return datasetVersionSerializer(item); + } +} + +export function datasetVersionUnionDeserializer( + item: any, +): DatasetVersionUnion { + switch (item.type) { + case "uri_file": + return fileDatasetVersionDeserializer(item as FileDatasetVersion); + + case "uri_folder": + return folderDatasetVersionDeserializer(item as FolderDatasetVersion); + + default: + return datasetVersionDeserializer(item); + } +} + +/** Enum to determine the type of data. */ +export type DatasetType = "uri_file" | "uri_folder"; + +/** FileDatasetVersion Definition */ +export interface FileDatasetVersion extends DatasetVersion { + /** Dataset type */ + type: "uri_file"; +} + +export function fileDatasetVersionSerializer(item: FileDatasetVersion): any { + return { + dataUri: item["dataUri"], + type: item["type"], + description: item["description"], + tags: item["tags"], + }; +} + +export function fileDatasetVersionDeserializer(item: any): FileDatasetVersion { + return { + dataUri: item["dataUri"], + type: item["type"], + isReference: item["isReference"], + id: item["id"], + name: item["name"], + version: item["version"], + description: item["description"], + tags: item["tags"], + }; +} + +/** FileDatasetVersion Definition */ +export interface FolderDatasetVersion extends DatasetVersion { + /** Dataset type */ + type: "uri_folder"; +} + +export function folderDatasetVersionSerializer( + item: FolderDatasetVersion, +): any { + return { + dataUri: item["dataUri"], + type: item["type"], + description: item["description"], + tags: item["tags"], + }; +} + +export function folderDatasetVersionDeserializer( + item: any, +): FolderDatasetVersion { + return { + dataUri: item["dataUri"], + type: item["type"], + isReference: item["isReference"], + id: item["id"], + name: item["name"], + version: item["version"], + description: item["description"], + tags: item["tags"], + }; +} + +/** Represents a request for a pending upload. */ +export interface PendingUploadRequest { + /** If PendingUploadId is not provided, a random GUID will be used. */ + pendingUploadId?: string; + /** Name of Azure blob storage connection to use for generating temporary SAS token */ + connectionName?: string; + /** BlobReference is the only supported type. */ + pendingUploadType: "BlobReference"; +} + +export function pendingUploadRequestSerializer( + item: PendingUploadRequest, +): any { + return { + pendingUploadId: item["pendingUploadId"], + connectionName: item["connectionName"], + pendingUploadType: item["pendingUploadType"], + }; +} + +/** Represents the response for a pending upload request */ +export interface PendingUploadResponse { + /** Container-level read, write, list SAS. */ + blobReference: BlobReference; + /** ID for this upload request. */ + pendingUploadId: string; + /** Version of asset to be created if user did not specify version when initially creating upload */ + version?: string; + /** BlobReference is the only supported type */ + pendingUploadType: "BlobReference"; +} + +export function pendingUploadResponseDeserializer( + item: any, +): PendingUploadResponse { + return { + blobReference: blobReferenceDeserializer(item["blobReference"]), + pendingUploadId: item["pendingUploadId"], + version: item["version"], + pendingUploadType: item["pendingUploadType"], + }; +} + +/** Blob reference details. */ +export interface BlobReference { + /** Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path */ + blobUri: string; + /** ARM ID of the storage account to use. */ + storageAccountArmId: string; + /** Credential info to access the storage account. */ + credential: SasCredential; +} + +export function blobReferenceDeserializer(item: any): BlobReference { + return { + blobUri: item["blobUri"], + storageAccountArmId: item["storageAccountArmId"], + credential: sasCredentialDeserializer(item["credential"]), + }; +} + +/** SAS Credential definition */ +export interface SasCredential { + /** SAS uri */ + readonly sasUri: string; + /** Type of credential */ + readonly type: "SAS"; +} + +export function sasCredentialDeserializer(item: any): SasCredential { + return { + sasUri: item["sasUri"], + type: item["type"], + }; +} + +/** model interface _GetCredentialsRequest */ +export interface _GetCredentialsRequest {} + +export function _getCredentialsRequestSerializer( + item: _GetCredentialsRequest, +): any { + return item; +} + +/** Represents a reference to a blob for consumption */ +export interface AssetCredentialResponse { + /** Credential info to access the storage account. */ + blobReference: BlobReference; +} + +export function assetCredentialResponseDeserializer( + item: any, +): AssetCredentialResponse { + return { + blobReference: blobReferenceDeserializer(item["blobReference"]), + }; +} + +/** Paged collection of Index items */ +export interface _PagedIndex { + /** The Index items on this page */ + value: IndexUnion[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _pagedIndexDeserializer(item: any): _PagedIndex { + return { + value: indexUnionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function indexUnionArraySerializer(result: Array): any[] { + return result.map((item) => { + return indexUnionSerializer(item); + }); +} + +export function indexUnionArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return indexUnionDeserializer(item); + }); +} + +/** Index resource Definition */ +export interface Index { + /** Type of index */ + /** The discriminator possible values: AzureSearch, ManagedAzureSearch, CosmosDBNoSqlVectorStore */ + type: IndexType; + /** Asset ID, a unique identifier for the asset */ + readonly id?: string; + /** The name of the resource */ + readonly name: string; + /** The version of the resource */ + readonly version: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; +} + +export function indexSerializer(item: Index): any { + return { + type: item["type"], + description: item["description"], + tags: item["tags"], + }; +} + +export function indexDeserializer(item: any): Index { + return { + type: item["type"], + id: item["id"], + name: item["name"], + version: item["version"], + description: item["description"], + tags: item["tags"], + }; +} + +/** Alias for IndexUnion */ +export type IndexUnion = + | AzureAISearchIndex + | ManagedAzureAISearchIndex + | CosmosDBIndex + | Index; + +export function indexUnionSerializer(item: IndexUnion): any { + switch (item.type) { + case "AzureSearch": + return azureAISearchIndexSerializer(item as AzureAISearchIndex); + + case "ManagedAzureSearch": + return managedAzureAISearchIndexSerializer( + item as ManagedAzureAISearchIndex, + ); + + case "CosmosDBNoSqlVectorStore": + return cosmosDBIndexSerializer(item as CosmosDBIndex); + + default: + return indexSerializer(item); + } +} + +export function indexUnionDeserializer(item: any): IndexUnion { + switch (item.type) { + case "AzureSearch": + return azureAISearchIndexDeserializer(item as AzureAISearchIndex); + + case "ManagedAzureSearch": + return managedAzureAISearchIndexDeserializer( + item as ManagedAzureAISearchIndex, + ); + + case "CosmosDBNoSqlVectorStore": + return cosmosDBIndexDeserializer(item as CosmosDBIndex); + + default: + return indexDeserializer(item); + } +} + +/** Type of IndexType */ +export type IndexType = + | "AzureSearch" + | "CosmosDBNoSqlVectorStore" + | "ManagedAzureSearch"; + +/** Azure AI Search Index Definition */ +export interface AzureAISearchIndex extends Index { + /** Type of index */ + type: "AzureSearch"; + /** Name of connection to Azure AI Search */ + connectionName: string; + /** Name of index in Azure AI Search resource to attach */ + indexName: string; +} + +export function azureAISearchIndexSerializer(item: AzureAISearchIndex): any { + return { + type: item["type"], + description: item["description"], + tags: item["tags"], + connectionName: item["connectionName"], + indexName: item["indexName"], + }; +} + +export function azureAISearchIndexDeserializer(item: any): AzureAISearchIndex { + return { + type: item["type"], + id: item["id"], + name: item["name"], + version: item["version"], + description: item["description"], + tags: item["tags"], + connectionName: item["connectionName"], + indexName: item["indexName"], + }; +} + +/** Managed Azure AI Search Index Definition */ +export interface ManagedAzureAISearchIndex extends Index { + /** Type of index */ + type: "ManagedAzureSearch"; + /** Vector store id of managed index */ + vectorStoreId: string; +} + +export function managedAzureAISearchIndexSerializer( + item: ManagedAzureAISearchIndex, +): any { + return { + type: item["type"], + description: item["description"], + tags: item["tags"], + vectorStoreId: item["vectorStoreId"], + }; +} + +export function managedAzureAISearchIndexDeserializer( + item: any, +): ManagedAzureAISearchIndex { + return { + type: item["type"], + id: item["id"], + name: item["name"], + version: item["version"], + description: item["description"], + tags: item["tags"], + vectorStoreId: item["vectorStoreId"], + }; +} + +/** CosmosDB Vector Store Index Definition */ +export interface CosmosDBIndex extends Index { + /** Type of index */ + type: "CosmosDBNoSqlVectorStore"; + /** Name of connection to CosmosDB */ + connectionName: string; + /** Name of the CosmosDB Database */ + databaseName: string; + /** Name of CosmosDB Container */ + containerName: string; + /** Embedding model configuration */ + embeddingConfiguration: EmbeddingConfiguration; +} + +export function cosmosDBIndexSerializer(item: CosmosDBIndex): any { + return { + type: item["type"], + description: item["description"], + tags: item["tags"], + connectionName: item["connectionName"], + databaseName: item["databaseName"], + containerName: item["containerName"], + embeddingConfiguration: embeddingConfigurationSerializer( + item["embeddingConfiguration"], + ), + }; +} + +export function cosmosDBIndexDeserializer(item: any): CosmosDBIndex { + return { + type: item["type"], + id: item["id"], + name: item["name"], + version: item["version"], + description: item["description"], + tags: item["tags"], + connectionName: item["connectionName"], + databaseName: item["databaseName"], + containerName: item["containerName"], + embeddingConfiguration: embeddingConfigurationDeserializer( + item["embeddingConfiguration"], + ), + }; +} + +/** Embedding configuration class */ +export interface EmbeddingConfiguration { + /** Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. */ + modelDeploymentName: string; + /** Embedding field */ + embeddingField: string; +} + +export function embeddingConfigurationSerializer( + item: EmbeddingConfiguration, +): any { + return { + modelDeploymentName: item["modelDeploymentName"], + embeddingField: item["embeddingField"], + }; +} + +export function embeddingConfigurationDeserializer( + item: any, +): EmbeddingConfiguration { + return { + modelDeploymentName: item["modelDeploymentName"], + embeddingField: item["embeddingField"], + }; +} + +/** Model Deployment Definition */ +export interface Deployment { + /** The type of the deployment */ + /** The discriminator possible values: ModelDeployment */ + type: DeploymentType; + /** Name of the deployment */ + readonly name: string; +} + +export function deploymentDeserializer(item: any): Deployment { + return { + type: item["type"], + name: item["name"], + }; +} + +/** Alias for DeploymentUnion */ +export type DeploymentUnion = ModelDeployment | Deployment; + +export function deploymentUnionDeserializer(item: any): DeploymentUnion { + switch (item.type) { + case "ModelDeployment": + return modelDeploymentDeserializer(item as ModelDeployment); + + default: + return deploymentDeserializer(item); + } +} + +/** Type of DeploymentType */ +export type DeploymentType = "ModelDeployment"; + +/** Model Deployment Definition */ +export interface ModelDeployment extends Deployment { + /** The type of the deployment */ + type: "ModelDeployment"; + /** Publisher-specific name of the deployed model */ + readonly modelName: string; + /** Publisher-specific version of the deployed model */ + readonly modelVersion: string; + /** Name of the deployed model's publisher */ + readonly modelPublisher: string; + /** Capabilities of deployed model */ + readonly capabilities: Record; + /** Sku of the model deployment */ + readonly sku: Sku; + /** Name of the connection the deployment comes from */ + readonly connectionName?: string; +} + +export function modelDeploymentDeserializer(item: any): ModelDeployment { + return { + type: item["type"], + name: item["name"], + modelName: item["modelName"], + modelVersion: item["modelVersion"], + modelPublisher: item["modelPublisher"], + capabilities: item["capabilities"], + sku: skuDeserializer(item["sku"]), + connectionName: item["connectionName"], + }; +} + +/** Sku information */ +export interface Sku { + /** Sku capacity */ + capacity: number; + /** Sku family */ + family: string; + /** Sku name */ + name: string; + /** Sku size */ + size: string; + /** Sku tier */ + tier: string; +} + +export function skuDeserializer(item: any): Sku { + return { + capacity: item["capacity"], + family: item["family"], + name: item["name"], + size: item["size"], + tier: item["tier"], + }; +} + +/** Paged collection of Deployment items */ +export interface _PagedDeployment { + /** The Deployment items on this page */ + value: DeploymentUnion[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _pagedDeploymentDeserializer(item: any): _PagedDeployment { + return { + value: deploymentUnionArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function deploymentUnionArrayDeserializer( + result: Array, +): any[] { + return result.map((item) => { + return deploymentUnionDeserializer(item); + }); +} + +/** Red team details. */ +export interface RedTeam { + /** Identifier of the red team. */ + readonly name: string; + /** Name of the red-team scan. */ + scanName?: string; + /** Number of simulation rounds. */ + numTurns: number; + /** List of attack strategies or nested lists of attack strategies. */ + attackStrategies: AttackStrategy[]; + /** Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. */ + simulationOnly: boolean; + /** List of risk categories to generate attack objectives for. */ + riskCategories: RiskCategory[]; + /** Application scenario for the red team operation, to generate scenario specific attacks. */ + applicationScenario?: string; + /** Red team's tags. Unlike properties, tags are fully mutable. */ + tags?: Record; + /** Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ + properties?: Record; + /** Status of the red-team. It is set by service and is read-only. */ + readonly status?: string; + /** Target configuration for the red-team run. */ + targetConfig: TargetConfigUnion; +} + +export function redTeamSerializer(item: RedTeam): any { + return { + scanName: item["scanName"], + numTurns: item["numTurns"], + attackStrategies: item["attackStrategies"].map((p: any) => { + return p; + }), + simulationOnly: item["simulationOnly"], + riskCategories: item["riskCategories"].map((p: any) => { + return p; + }), + applicationScenario: item["applicationScenario"], + tags: item["tags"], + properties: item["properties"], + targetConfig: targetConfigUnionSerializer(item["targetConfig"]), + }; +} + +export function redTeamDeserializer(item: any): RedTeam { + return { + name: item["id"], + scanName: item["scanName"], + numTurns: item["numTurns"], + attackStrategies: item["attackStrategies"].map((p: any) => { + return p; + }), + simulationOnly: item["simulationOnly"], + riskCategories: item["riskCategories"].map((p: any) => { + return p; + }), + applicationScenario: item["applicationScenario"], + tags: item["tags"], + properties: item["properties"], + status: item["status"], + targetConfig: targetConfigUnionDeserializer(item["targetConfig"]), + }; +} + +/** Strategies for attacks. */ +export type AttackStrategy = + | "easy" + | "moderate" + | "difficult" + | "ascii_art" + | "ascii_smuggler" + | "atbash" + | "base64" + | "binary" + | "caesar" + | "character_space" + | "jailbreak" + | "ansii_attack" + | "character_swap" + | "suffix_append" + | "string_join" + | "unicode_confusable" + | "unicode_substitution" + | "diacritic" + | "flip" + | "leetspeak" + | "rot13" + | "morse" + | "url" + | "baseline"; +/** Risk category for the attack objective. */ +export type RiskCategory = + | "HateUnfairness" + | "Violence" + | "Sexual" + | "SelfHarm"; + +/** Abstract class for target configuration. */ +export interface TargetConfig { + /** Type of the model configuration. */ + /** The discriminator possible values: AzureOpenAIModel */ + type: string; +} + +export function targetConfigSerializer(item: TargetConfig): any { + return { type: item["type"] }; +} + +export function targetConfigDeserializer(item: any): TargetConfig { + return { + type: item["type"], + }; +} + +/** Alias for TargetConfigUnion */ +export type TargetConfigUnion = AzureOpenAIModelConfiguration | TargetConfig; + +export function targetConfigUnionSerializer(item: TargetConfigUnion): any { + switch (item.type) { + case "AzureOpenAIModel": + return azureOpenAIModelConfigurationSerializer( + item as AzureOpenAIModelConfiguration, + ); + + default: + return targetConfigSerializer(item); + } +} + +export function targetConfigUnionDeserializer(item: any): TargetConfigUnion { + switch (item.type) { + case "AzureOpenAIModel": + return azureOpenAIModelConfigurationDeserializer( + item as AzureOpenAIModelConfiguration, + ); + + default: + return targetConfigDeserializer(item); + } +} + +/** Azure OpenAI model configuration. The API version would be selected by the service for querying the model. */ +export interface AzureOpenAIModelConfiguration extends TargetConfig { + readonly type: "AzureOpenAIModel"; + /** Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (i.e. `my-aoai-connection/gpt-4o`. */ + modelDeploymentName: string; +} + +export function azureOpenAIModelConfigurationSerializer( + item: AzureOpenAIModelConfiguration, +): any { + return { modelDeploymentName: item["modelDeploymentName"] }; +} + +export function azureOpenAIModelConfigurationDeserializer( + item: any, +): AzureOpenAIModelConfiguration { + return { + type: item["type"], + modelDeploymentName: item["modelDeploymentName"], + }; +} + +/** Paged collection of RedTeam items */ +export interface _PagedRedTeam { + /** The RedTeam items on this page */ + value: RedTeam[]; + /** The link to the next page of items */ + nextLink?: string; +} + +export function _pagedRedTeamDeserializer(item: any): _PagedRedTeam { + return { + value: redTeamArrayDeserializer(item["value"]), + nextLink: item["nextLink"], + }; +} + +export function redTeamArraySerializer(result: Array): any[] { + return result.map((item) => { + return redTeamSerializer(item); + }); +} + +export function redTeamArrayDeserializer(result: Array): any[] { + return result.map((item) => { + return redTeamDeserializer(item); + }); +} + +/** The type of pending upload. */ +export type PendingUploadType = "None" | "BlobReference"; + +/** Azure AI Projects API versions */ +export enum KnownVersions { + /** Azure AI API version 2025-05-01. */ + V20250501 = "2025-05-01", + /** Azure AI API version 2025-05-15-preview. */ + V20250515Preview = "2025-05-15-preview", +} diff --git a/sdk/ai/ai-projects/src/static-helpers/pagingHelpers.ts b/sdk/ai/ai-projects/src/static-helpers/pagingHelpers.ts new file mode 100644 index 000000000000..97a81e74e301 --- /dev/null +++ b/sdk/ai/ai-projects/src/static-helpers/pagingHelpers.ts @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Client, + createRestError, + PathUncheckedResponse, +} from "@azure-rest/core-client"; +import { RestError } from "@azure/core-rest-pipeline"; + +/** + * Options for the byPage method + */ +export interface PageSettings { + /** + * A reference to a specific page to start iterating from. + */ + continuationToken?: string; +} + +/** + * An interface that describes a page of results. + */ +export type ContinuablePage = TPage & { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +}; + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: ( + settings?: TPageSettings, + ) => AsyncIterableIterator>; +} + +/** + * An interface that describes how to communicate with the service. + */ +export interface PagedResult< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +> { + /** + * Link to the first page of results. + */ + firstPageLink?: string; + /** + * A method that returns a page of results. + */ + getPage: ( + pageLink?: string, + ) => Promise<{ page: TPage; nextPageLink?: string } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: ( + settings?: TPageSettings, + ) => AsyncIterableIterator>; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => TElement[]; +} + +/** + * Options for the paging helper + */ +export interface BuildPagedAsyncIteratorOptions { + itemName?: string; + nextLinkName?: string; +} + +/** + * Helper to paginate results in a generic way and return a PagedAsyncIterableIterator + */ +export function buildPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, + TResponse extends PathUncheckedResponse = PathUncheckedResponse, +>( + client: Client, + getInitialResponse: () => PromiseLike, + processResponseBody: (result: TResponse) => PromiseLike, + expectedStatuses: string[], + options: BuildPagedAsyncIteratorOptions = {}, +): PagedAsyncIterableIterator { + const itemName = options.itemName ?? "value"; + const nextLinkName = options.nextLinkName ?? "nextLink"; + const pagedResult: PagedResult = { + getPage: async (pageLink?: string) => { + const result = + pageLink === undefined + ? await getInitialResponse() + : await client.pathUnchecked(pageLink).get(); + checkPagingRequest(result, expectedStatuses); + const results = await processResponseBody(result as TResponse); + const nextLink = getNextLink(results, nextLinkName); + const values = getElements(results, itemName) as TPage; + return { + page: values, + nextPageLink: nextLink, + }; + }, + byPage: (settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }, + }; + return getPagedAsyncIterator(pagedResult); +} + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ + +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings extends PageSettings = PageSettings, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator( + pagedResult, + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + ((settings?: TPageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken, + }); + }), + }; +} + +async function* getItemAsyncIterator< + TElement, + TPage, + TPageSettings extends PageSettings, +>( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + for await (const page of pages) { + yield* page as unknown as TElement[]; + } +} + +async function* getPageAsyncIterator< + TElement, + TPage, + TPageSettings extends PageSettings, +>( + pagedResult: PagedResult, + options: { + pageLink?: string; + } = {}, +): AsyncIterableIterator> { + const { pageLink } = options; + let response = await pagedResult.getPage( + pageLink ?? pagedResult.firstPageLink, + ); + if (!response) { + return; + } + let result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + result = response.page as ContinuablePage; + result.continuationToken = response.nextPageLink; + yield result; + } +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if ( + typeof nextLink !== "string" && + typeof nextLink !== "undefined" && + nextLink !== null + ) { + throw new RestError( + `Body Property ${nextLinkName} should be a string or undefined or null but got ${typeof nextLink}`, + ); + } + + if (nextLink === null) { + return undefined; + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + if (!Array.isArray(value)) { + throw new RestError( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest( + response: PathUncheckedResponse, + expectedStatuses: string[], +): void { + if (!expectedStatuses.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} diff --git a/sdk/ai/ai-projects/src/static-helpers/urlTemplate.ts b/sdk/ai/ai-projects/src/static-helpers/urlTemplate.ts new file mode 100644 index 000000000000..a19e628d347e --- /dev/null +++ b/sdk/ai/ai-projects/src/static-helpers/urlTemplate.ts @@ -0,0 +1,200 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//--------------------- +// interfaces +//--------------------- +interface ValueOptions { + isFirst: boolean; // is first value in the expression + op?: string; // operator + varValue?: any; // variable value + varName?: string; // variable name + modifier?: string; // modifier e.g * + reserved?: boolean; // if true we'll keep reserved words with not encoding +} + +export interface UrlTemplateOptions { + // if set to true, reserved characters will not be encoded + allowReserved?: boolean; +} + +// --------------------- +// helpers +// --------------------- +function encodeComponent(val: string, reserved?: boolean, op?: string) { + return (reserved ?? op === "+") || op === "#" + ? encodeReservedComponent(val) + : encodeRFC3986URIComponent(val); +} + +function encodeReservedComponent(str: string) { + return str + .split(/(%[0-9A-Fa-f]{2})/g) + .map((part) => (!/%[0-9A-Fa-f]/.test(part) ? encodeURI(part) : part)) + .join(""); +} + +function encodeRFC3986URIComponent(str: string) { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`, + ); +} + +function isDefined(val: any) { + return val !== undefined && val !== null; +} + +function getNamedAndIfEmpty(op?: string): [boolean, string] { + return [ + !!op && [";", "?", "&"].includes(op), + !!op && ["?", "&"].includes(op) ? "=" : "", + ]; +} + +function getFirstOrSep(op?: string, isFirst = false) { + if (isFirst) { + return !op || op === "+" ? "" : op; + } else if (!op || op === "+" || op === "#") { + return ","; + } else if (op === "?") { + return "&"; + } else { + return op; + } +} + +function getExpandedValue(option: ValueOptions) { + let isFirst = option.isFirst; + const { op, varName, varValue: value, reserved } = option; + const vals: string[] = []; + const [named, ifEmpty] = getNamedAndIfEmpty(op); + + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + // prepare the following parts: separator, varName, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (named && varName) { + vals.push(`${encodeURIComponent(varName)}`); + val === "" ? vals.push(ifEmpty) : vals.push("="); + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + const val = value[key]; + if (!isDefined(val)) { + continue; + } + // prepare the following parts: separator, key, value + vals.push(`${getFirstOrSep(op, isFirst)}`); + if (key) { + vals.push(`${encodeURIComponent(key)}`); + named && val === "" ? vals.push(ifEmpty) : vals.push("="); + } + vals.push(encodeComponent(val, reserved, op)); + isFirst = false; + } + } + return vals.join(""); +} + +function getNonExpandedValue(option: ValueOptions) { + const { op, varName, varValue: value, isFirst, reserved } = option; + const vals: string[] = []; + const first = getFirstOrSep(op, isFirst); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + if (named && varName) { + vals.push(encodeComponent(varName, reserved, op)); + if (value === "") { + if (!ifEmpty) { + vals.push(ifEmpty); + } + return !vals.join("") ? undefined : `${first}${vals.join("")}`; + } + vals.push("="); + } + + const items = []; + if (Array.isArray(value)) { + for (const val of value.filter(isDefined)) { + items.push(encodeComponent(val, reserved, op)); + } + } else if (typeof value === "object") { + for (const key of Object.keys(value)) { + if (!isDefined(value[key])) { + continue; + } + items.push(encodeRFC3986URIComponent(key)); + items.push(encodeComponent(value[key], reserved, op)); + } + } + vals.push(items.join(",")); + return !vals.join(",") ? undefined : `${first}${vals.join("")}`; +} + +function getVarValue(option: ValueOptions): string | undefined { + const { op, varName, modifier, isFirst, reserved, varValue: value } = option; + + if (!isDefined(value)) { + return undefined; + } else if (["string", "number", "boolean"].includes(typeof value)) { + let val = value.toString(); + const [named, ifEmpty] = getNamedAndIfEmpty(op); + const vals: string[] = [getFirstOrSep(op, isFirst)]; + if (named && varName) { + // No need to encode varName considering it is already encoded + vals.push(varName); + val === "" ? vals.push(ifEmpty) : vals.push("="); + } + if (modifier && modifier !== "*") { + val = val.substring(0, parseInt(modifier, 10)); + } + vals.push(encodeComponent(val, reserved, op)); + return vals.join(""); + } else if (modifier === "*") { + return getExpandedValue(option); + } else { + return getNonExpandedValue(option); + } +} + +// --------------------------------------------------------------------------------------------------- +// This is an implementation of RFC 6570 URI Template: https://datatracker.ietf.org/doc/html/rfc6570. +// --------------------------------------------------------------------------------------------------- +export function expandUrlTemplate( + template: string, + context: Record, + option?: UrlTemplateOptions, +): string { + return template.replace(/\{([^\{\}]+)\}|([^\{\}]+)/g, (_, expr, text) => { + if (!expr) { + return encodeReservedComponent(text); + } + let op; + if (["+", "#", ".", "/", ";", "?", "&"].includes(expr[0])) { + (op = expr[0]), (expr = expr.slice(1)); + } + const varList = expr.split(/,/g); + const result = []; + for (const varSpec of varList) { + const varMatch = /([^:\*]*)(?::(\d+)|(\*))?/.exec(varSpec); + if (!varMatch || !varMatch[1]) { + continue; + } + const varValue = getVarValue({ + isFirst: result.length === 0, + op, + varValue: context[varMatch[1]], + varName: varMatch[1], + modifier: varMatch[2] || varMatch[3], + reserved: option?.allowReserved, + }); + if (varValue) { + result.push(varValue); + } + } + return result.join(""); + }); +} diff --git a/sdk/ai/ai-projects/src/telemetry/index.ts b/sdk/ai/ai-projects/src/telemetry/index.ts deleted file mode 100644 index 625ede77e570..000000000000 --- a/sdk/ai/ai-projects/src/telemetry/index.ts +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Client } from "@azure-rest/core-client"; -import type { TelemetryOptions } from "./telemetry.js"; -import { - getConnectionString, - getTelemetryOptions, - resetTelemetryOptions, - updateTelemetryOptions, -} from "./telemetry.js"; -import type { ConnectionsInternalOperations } from "../connections/internalModels.js"; -import type { ConnectionsOperations } from "../connections/customModels.js"; -export { TelemetryOptions } from "./telemetry.js"; - -/** - * Telemetry operations - **/ -export interface TelemetryOperations { - /** - * Get the appinsights connection string confired in the workspace - * @returns The telemetry connection string - **/ - getConnectionString(): Promise; - - /** - * Update the telemetry settings - * @param options - The telemetry options - * @returns void - * */ - updateSettings(options: TelemetryOptions): void; - - /** - * get the telemetry settings - * @returns The telemetry options - * */ - getSettings(): TelemetryOptions; -} - -/** - * Get the telemetry operations - * @param connection - The connections operations - * @returns The telemetry operations - **/ -export function getTelemetryOperations( - context: Client, - connection: ConnectionsOperations, -): TelemetryOperations { - resetTelemetryOptions(); - return { - getConnectionString: () => - getConnectionString(context, connection as ConnectionsInternalOperations), - updateSettings: (options: TelemetryOptions) => updateTelemetryOptions(options), - getSettings: () => getTelemetryOptions(), - }; -} diff --git a/sdk/ai/ai-projects/src/telemetry/telemetry.ts b/sdk/ai/ai-projects/src/telemetry/telemetry.ts deleted file mode 100644 index 8b9102d41621..000000000000 --- a/sdk/ai/ai-projects/src/telemetry/telemetry.ts +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { GetAppInsightsResponseOutput } from "../customization/outputModels.js"; -import type { Client } from "@azure-rest/core-client"; -import { createRestError } from "@azure-rest/core-client"; -import type { ConnectionsInternalOperations } from "../connections/internalModels.js"; - -const expectedStatuses = ["200"]; - -/** - * Telemetry options - */ -export interface TelemetryOptions { - /** Enable content recording */ - enableContentRecording: boolean; -} - -const telemetryOptions: TelemetryOptions & { connectionString: string | undefined } = { - enableContentRecording: false, - connectionString: undefined, -}; - -/** - * Update the telemetry settings - * @param options - The telemetry options - */ -export function updateTelemetryOptions(options: TelemetryOptions): void { - telemetryOptions.enableContentRecording = options.enableContentRecording; -} - -/** - * Get the telemetry options - * @returns The telemetry options - */ -export function getTelemetryOptions(): TelemetryOptions { - return structuredClone(telemetryOptions); -} - -/** - * Reset the telemetry options - */ -export function resetTelemetryOptions(): void { - telemetryOptions.connectionString = undefined; - telemetryOptions.enableContentRecording = false; -} - -/** - * Get the appinsights connection string confired in the workspace - * @param connection - get the connection string - * @returns The telemetry connection string - */ -export async function getConnectionString( - context: Client, - connection: ConnectionsInternalOperations, -): Promise { - if (!telemetryOptions.connectionString) { - const workspace = await connection.getWorkspace(); - if (workspace.properties.applicationInsights) { - const result = await context - .path("/{appInsightsResourceUrl}", workspace.properties.applicationInsights) - .get({ skipUrlEncoding: true }); - if (!expectedStatuses.includes(result.status)) { - throw createRestError(result); - } - telemetryOptions.connectionString = ( - result.body as GetAppInsightsResponseOutput - ).properties.ConnectionString; - } else { - throw new Error("Application Insights connection string not found."); - } - } - return telemetryOptions.connectionString as string; -} diff --git a/sdk/ai/ai-projects/src/tracing.ts b/sdk/ai/ai-projects/src/tracing.ts deleted file mode 100644 index 50ce1eb044a2..000000000000 --- a/sdk/ai/ai-projects/src/tracing.ts +++ /dev/null @@ -1,318 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { - OperationTracingOptions, - Resolved, - SpanStatusError, - TracingSpan, -} from "@azure/core-tracing"; -import { createTracingClient } from "@azure/core-tracing"; -import { PACKAGE_NAME, SDK_VERSION } from "./constants.js"; -import { getErrorMessage } from "@azure/core-util"; -import { logger } from "./logger.js"; - -export enum TracingAttributes { - GEN_AI_MESSAGE_ID = "gen_ai.message.id", - GEN_AI_MESSAGE_STATUS = "gen_ai.message.status", - GEN_AI_THREAD_ID = "gen_ai.thread.id", - GEN_AI_THREAD_RUN_ID = "gen_ai.thread.run.id", - GEN_AI_AGENT_ID = "gen_ai.agent.id", - GEN_AI_AGENT_NAME = "gen_ai.agent.name", - GEN_AI_AGENT_DESCRIPTION = "gen_ai.agent.description", - GEN_AI_OPERATION_NAME = "gen_ai.operation.name", - GEN_AI_THREAD_RUN_STATUS = "gen_ai.thread.run.status", - GEN_AI_REQUEST_MODEL = "gen_ai.request.model", - GEN_AI_REQUEST_TEMPERATURE = "gen_ai.request.temperature", - GEN_AI_REQUEST_TOP_P = "gen_ai.request.top_p", - GEN_AI_REQUEST_MAX_INPUT_TOKENS = "gen_ai.request.max_input_tokens", - GEN_AI_REQUEST_MAX_OUTPUT_TOKENS = "gen_ai.request.max_output_tokens", - GEN_AI_RESPONSE_MODEL = "gen_ai.response.model", - GEN_AI_SYSTEM = "gen_ai.system", - SERVER_ADDRESS = "server.address", - AZ_AI_AGENT_SYSTEM = "az.ai.agents", - GEN_AI_TOOL_NAME = "gen_ai.tool.name", - GEN_AI_TOOL_CALL_ID = "gen_ai.tool.call.id", - GEN_AI_REQUEST_RESPONSE_FORMAT = "gen_ai.request.response_format", - GEN_AI_USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens", - GEN_AI_USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens", - GEN_AI_SYSTEM_MESSAGE = "gen_ai.system.message", - GEN_AI_EVENT_CONTENT = "gen_ai.event.content", - ERROR_TYPE = "error.type", -} -export enum TracingOperationName { - CREATE_AGENT = "create_agent", - CREATE_UPDATE_AGENT = "update_agent", - CREATE_THREAD = "create_thread", - CREATE_MESSAGE = "create_message", - CREATE_RUN = "create_run", - START_THREAD_RUN = "start_thread_run", - EXECUTE_TOOL = "execute_tool", - LIST_MESSAGES = "list_messages", - SUBMIT_TOOL_OUTPUTS = "submit_tool_outputs", - CREATE_THREAD_RUN = "create_thread_run", -} - -export interface TracingAttributeOptions { - operationName?: string; - name?: string; - description?: string; - serverAddress?: string; - threadId?: string; - agentId?: string; - instructions?: string; - additional_instructions?: string; - runId?: string; - runStatus?: string; - responseModel?: string; - model?: string; - temperature?: number; - topP?: number; - maxPromptTokens?: number; - maxCompletionTokens?: number; - responseFormat?: string; - genAiSystem?: string; - messageId?: string; - messageStatus?: string; - eventContent?: string; - usagePromptTokens?: number; - usageCompletionTokens?: number; -} - -export type Span = Omit; -export type OptionsWithTracing = { - tracingOptions?: OperationTracingOptions; - tracingAttributeOptions?: TracingAttributeOptions; -}; - -export class TracingUtility { - private static tracingClient = createTracingClient({ - namespace: "Microsoft.CognitiveServices", - packageName: PACKAGE_NAME, - packageVersion: SDK_VERSION, - }); - - static async withSpan< - Options extends OptionsWithTracing, - Request extends (updatedOptions: Options) => ReturnType, - >( - name: string, - options: Options, - request: Request, - startTrace?: (span: Span, updatedOptions: Options) => void, - endTrace?: (span: Span, updatedOptions: Options, result: ReturnType) => void, - ): Promise>> { - return TracingUtility.tracingClient.withSpan( - name, - options, - async (updatedOptions: Options, span: Span) => { - if (startTrace) { - try { - updatedOptions.tracingAttributeOptions = { - ...updatedOptions.tracingAttributeOptions, - operationName: name, - }; - startTrace(span, updatedOptions); - } catch (e) { - logger.warning( - `Skipping updating span before request execution due to an error: ${getErrorMessage(e)}`, - ); - } - } - let result: ReturnType | undefined; - try { - result = await request(updatedOptions); - } catch (error) { - const errorStatus: SpanStatusError = { status: "error" }; - if (error instanceof Error) { - errorStatus.error = error; - } - throw error; - } - - if (endTrace && result !== undefined) { - try { - endTrace(span, updatedOptions, result); - } catch (e) { - logger.warning( - `Skipping updating span after request execution due to an error: ${getErrorMessage(e)}`, - ); - } - } - return result; - }, - { spanKind: "client" }, - ); - } - - static updateSpanAttributes( - span: Span, - attributeOptions: Omit, - ): void { - TracingUtility.setAttributes(span, attributeOptions); - } - - static setSpanAttributes( - span: Span, - operationName: string, - attributeOptions: TracingAttributeOptions, - ): void { - attributeOptions.operationName = operationName; - TracingUtility.setAttributes(span, attributeOptions); - } - - static setAttributes(span: Span, attributeOptions: TracingAttributeOptions): void { - if (span.isRecording()) { - const { - name, - operationName, - description, - serverAddress, - threadId, - agentId, - messageId, - runId, - model, - temperature, - topP, - maxPromptTokens, - maxCompletionTokens, - responseFormat, - runStatus, - responseModel, - usageCompletionTokens, - usagePromptTokens, - genAiSystem = TracingAttributes.AZ_AI_AGENT_SYSTEM, - } = attributeOptions; - - if (genAiSystem) { - span.setAttribute(TracingAttributes.GEN_AI_SYSTEM, genAiSystem); - } - if (name) { - span.setAttribute(TracingAttributes.GEN_AI_AGENT_NAME, name); - } - if (description) { - span.setAttribute(TracingAttributes.GEN_AI_AGENT_DESCRIPTION, description); - } - - if (serverAddress) { - span.setAttribute(TracingAttributes.SERVER_ADDRESS, serverAddress); - } - - if (threadId) { - span.setAttribute(TracingAttributes.GEN_AI_THREAD_ID, threadId); - } - - if (agentId) { - span.setAttribute(TracingAttributes.GEN_AI_AGENT_ID, agentId); - } - - if (runId) { - span.setAttribute(TracingAttributes.GEN_AI_THREAD_RUN_ID, runId); - } - - if (messageId) { - span.setAttribute(TracingAttributes.GEN_AI_MESSAGE_ID, messageId); - } - if (model) { - span.setAttribute(TracingAttributes.GEN_AI_REQUEST_MODEL, model); - } - - if (temperature !== null) { - span.setAttribute(TracingAttributes.GEN_AI_REQUEST_TEMPERATURE, temperature); - } - - if (topP !== null) { - span.setAttribute(TracingAttributes.GEN_AI_REQUEST_TOP_P, topP); - } - - if (maxPromptTokens !== null) { - span.setAttribute(TracingAttributes.GEN_AI_REQUEST_MAX_INPUT_TOKENS, maxPromptTokens); - } - - if (maxCompletionTokens !== null) { - span.setAttribute(TracingAttributes.GEN_AI_REQUEST_MAX_OUTPUT_TOKENS, maxCompletionTokens); - } - - if (responseFormat) { - span.setAttribute(TracingAttributes.GEN_AI_REQUEST_RESPONSE_FORMAT, responseFormat); - } - - if (runStatus) { - span.setAttribute(TracingAttributes.GEN_AI_THREAD_RUN_STATUS, runStatus); - } - - if (responseModel) { - span.setAttribute(TracingAttributes.GEN_AI_RESPONSE_MODEL, responseModel); - } - - if (usagePromptTokens) { - span.setAttribute(TracingAttributes.GEN_AI_USAGE_INPUT_TOKENS, usagePromptTokens); - } - - if (usageCompletionTokens) { - span.setAttribute(TracingAttributes.GEN_AI_USAGE_OUTPUT_TOKENS, usageCompletionTokens); - } - if (operationName) { - span.setAttribute(TracingAttributes.GEN_AI_OPERATION_NAME, operationName); - } - } - return; - } - - static addSpanEvent( - span: Span, - eventName: string, - attributeOptions: Omit, - ): void { - if (span.isRecording()) { - const { - threadId, - agentId, - runId, - messageId, - eventContent, - usageCompletionTokens, - usagePromptTokens, - messageStatus, - } = attributeOptions; - const attributes: Record = {}; - - if (eventContent) { - attributes[TracingAttributes.GEN_AI_EVENT_CONTENT] = eventContent; - } - - if (threadId) { - attributes[TracingAttributes.GEN_AI_THREAD_ID] = threadId; - } - - if (agentId) { - attributes[TracingAttributes.GEN_AI_AGENT_ID] = agentId; - } - - if (runId) { - attributes[TracingAttributes.GEN_AI_THREAD_RUN_ID] = runId; - } - - if (messageId) { - attributes[TracingAttributes.GEN_AI_MESSAGE_ID] = messageId; - } - if (messageStatus) { - attributes[TracingAttributes.GEN_AI_MESSAGE_STATUS] = messageStatus; - } - - if (usagePromptTokens) { - attributes[TracingAttributes.GEN_AI_USAGE_INPUT_TOKENS] = usagePromptTokens; - } - - if (usageCompletionTokens) { - attributes[TracingAttributes.GEN_AI_USAGE_OUTPUT_TOKENS] = usageCompletionTokens; - } - - if (span.addEvent) { - span.addEvent(eventName, { attributes }); - } - } - return; - } -} diff --git a/sdk/ai/ai-projects/test.env b/sdk/ai/ai-projects/test.env deleted file mode 100644 index 167bfe7e6307..000000000000 --- a/sdk/ai/ai-projects/test.env +++ /dev/null @@ -1 +0,0 @@ -AZURE_AI_PROJECTS_CONNECTION_STRING="" diff --git a/sdk/ai/ai-projects/test/public/agents/assistants.spec.ts b/sdk/ai/ai-projects/test/public/agents/assistants.spec.ts deleted file mode 100644 index 13c577ce7e09..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/assistants.spec.ts +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - assistants", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and agents operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(agents); - }); - - it("should delete agent", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Delete agent - const deleted = await agents.deleteAgent(agent.id); - assert.isNotNull(deleted); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); - - it("should list assistants", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // List agents - const assistants = await agents.listAgents(); - assert.isNotEmpty(assistants); - assert.isAtLeast(assistants.data.length, 1); - console.log(`Listed agents, agents count: ${assistants.data.length}`); - - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); - - it("should create agent", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); - - it("should update agent", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Update agent - const updated = await agents.updateAgent(agent.id, { name: "my-updated-agent" }); - assert.isNotNull(updated); - assert.equal(updated.name, "my-updated-agent"); - console.log(`Updated agent name to ${updated.name}, agent ID: ${agent.id}`); - - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/files.spec.ts b/sdk/ai/ai-projects/test/public/agents/files.spec.ts deleted file mode 100644 index 68782e03fc72..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/files.spec.ts +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - files", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and agents operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(agents); - }); - - it("should list files", async function () { - const files = await agents.listFiles(); - assert.isNotEmpty(files); - }); - - it("should upload file", async function () { - const fileContent = new ReadableStream({ - start(controller) { - controller.enqueue(new TextEncoder().encode("fileContent")); - controller.close(); - }, - }); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - assert.isNotEmpty(file); - }); - - it("should upload file and poll (through original method)", async function () { - const fileContent = new ReadableStream({ - start(controller) { - controller.enqueue(new TextEncoder().encode("fileContent")); - controller.close(); - }, - }); - const filePoller = agents.uploadFileAndPoll(fileContent, "assistants", { - fileName: "filename.txt", - }); - const initialState = filePoller.poll(); - assert.isNotNull(initialState); - const file = await filePoller.pollUntilDone(); - assert.notInclude(["uploaded", "pending", "running"], file.status); - assert.isNotEmpty(file); - }); - - it("should upload file and poll (through creation method)", async function () { - const fileContent = new ReadableStream({ - start(controller) { - controller.enqueue(new TextEncoder().encode("fileContent")); - controller.close(); - }, - }); - const filePoller = agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - const initialState = filePoller.poll(); - assert.isNotNull(initialState); - const file = await filePoller.pollUntilDone(); - assert.notInclude(["uploaded", "pending", "running"], file.status); - assert.isNotEmpty(file); - }); - - it("should delete file", async function () { - const fileContent = new ReadableStream({ - start(controller) { - controller.enqueue(new TextEncoder().encode("fileContent")); - controller.close(); - }, - }); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - const deleted = await agents.deleteFile(file.id); - assert.isNotNull(deleted); - }); - - it("should retrieve file", async function () { - const fileContent = new ReadableStream({ - start(controller) { - controller.enqueue(new TextEncoder().encode("fileContent")); - controller.close(); - }, - }); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - const _file = await agents.getFile(file.id); - assert.isNotEmpty(_file); - assert.equal(_file.id, file.id); - await agents.deleteFile(file.id); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/functionTool.spec.ts b/sdk/ai/ai-projects/test/public/agents/functionTool.spec.ts deleted file mode 100644 index 379c686bfe39..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/functionTool.spec.ts +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import { delay } from "@azure-tools/test-recorder"; -import type { - AgentsOperations, - AIProjectsClient, - FunctionToolDefinition, - FunctionToolDefinitionOutput, - MessageContentOutput, - MessageImageFileContentOutput, - MessageTextContentOutput, - SubmitToolOutputsActionOutput, -} from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; -import { isOutputOfType } from "../../../src/agents/utils.js"; - -describe("Agents - function tool", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - let getCurrentDateTimeTool: FunctionToolDefinition; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - getCurrentDateTimeTool = { - type: "function", - function: { - name: "getCurrentDateTime", - description: "Get current date time", - parameters: {}, - }, - }; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - function getCurrentDateTime(): {} { - return { currentDateTime: "2024-10-10 12:30:19" }; - } - - it("should create agent with function tool", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [getCurrentDateTimeTool], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - assert.isNotEmpty(agent.tools); - assert.equal((agent.tools[0] as FunctionToolDefinition).function.name, "getCurrentDateTime"); - - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); - - it("should create agent with run function tool", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [getCurrentDateTimeTool], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - assert.isNotEmpty(agent.tools); - assert.equal((agent.tools[0] as FunctionToolDefinition).function.name, "getCurrentDateTime"); - - // Create thread - const thread = await agents.createThread(); - assert.isNotNull(thread); - assert.isNotNull(thread.id); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "Hello, what's the time?", - }); - assert.isNotNull(message.id); - console.log(`Created message, message ID ${message.id}`); - - // Create run - let run = await agents.createRun(thread.id, agent.id); - assert.isNotNull(run); - assert.isNotNull(run.id); - console.log(`Created Run, Run ID: ${run.id}`); - let toolCalled = false; - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await agents.getRun(thread.id, run.id); - if (run.status === "failed") { - console.log(`Run failed - ${run.lastError?.code} - ${run.lastError?.message}`); - break; - } - console.log(`Current Run status - ${run.status}, run ID: ${run.id}`); - if (run.status === "requires_action" && run.requiredAction) { - console.log(`Run requires action - ${run.requiredAction}`); - if ( - isOutputOfType(run.requiredAction, "submit_tool_outputs") - ) { - const submitToolOutputsActionOutput = run.requiredAction as SubmitToolOutputsActionOutput; - const toolCalls = submitToolOutputsActionOutput.submitToolOutputs.toolCalls; - for (const toolCall of toolCalls) { - if (isOutputOfType(toolCall, "function")) { - const functionOutput = toolCall as FunctionToolDefinitionOutput; - console.log(`Function tool call - ${functionOutput.function.name}`); - const toolResponse = getCurrentDateTime(); - toolCalled = true; - run = await agents.submitToolOutputsToRun(thread.id, run.id, [ - { toolCallId: toolCall.id, output: JSON.stringify(toolResponse) }, - ]); - console.log(`Submitted tool response - ${run.status}`); - } - } - } - } - } - assert.oneOf(run.status, ["cancelled", "failed", "completed", "expired"]); - assert.isTrue(toolCalled); - console.log(`Run status - ${run.status}, run ID: ${run.id}`); - const messages = await agents.listMessages(thread.id); - messages.data.forEach((threadMessage) => { - console.log( - `Thread Message Created at - ${threadMessage.createdAt} - Role - ${threadMessage.role}`, - ); - threadMessage.content.forEach((content: MessageContentOutput) => { - if (isOutputOfType(content, "text")) { - const textContent = content as MessageTextContentOutput; - console.log(`Text Message Content - ${textContent.text.value}`); - } else if (isOutputOfType(content, "image_file")) { - const imageContent = content as MessageImageFileContentOutput; - console.log(`Image Message Content - ${imageContent.imageFile.fileId}`); - } - }); - }); - - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/messages.spec.ts b/sdk/ai/ai-projects/test/public/agents/messages.spec.ts deleted file mode 100644 index dd3b8bd5c007..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/messages.spec.ts +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - messages", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and agents operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(agents); - }); - - it("should create message", async function () { - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - assert.isNotNull(message); - assert.isNotNull(message.id); - - // Delete thread - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - }); - - it("should list messages", async function () { - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create messages - const firstMessage = await agents.createMessage(thread.id, { - role: "user", - content: "knock knock", - }); - const secondMessage = await agents.createMessage(thread.id, { - role: "assistant", - content: "who's there?", - }); - console.log(`Created messages, message IDs: ${firstMessage.id}, ${secondMessage.id}`); - - // List messages - const messages = await agents.listMessages(thread.id); - assert.isNotEmpty(messages); - assert.equal(messages.data.length, 2); - assert.equal(messages.data[1].id, firstMessage.id); - assert.equal(messages.data[0].id, secondMessage.id); - console.log(`Listed ${messages.data.length} messages, thread ID: ${thread.id}`); - - // Delete thread - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - }); - - it("should update message", async function () { - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Update message - const updatedMessage = await agents.updateMessage(thread.id, message.id, { - metadata: { key: "value" }, - }); - assert.isNotNull(updatedMessage); - assert.equal(updatedMessage.id, message.id); - assert.equal(updatedMessage.metadata?.key, "value"); - console.log( - `Updated message to have metadata "key":"${updatedMessage.metadata?.key}", message ID: ${updatedMessage.id}`, - ); - - // Delete thread - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/runSteps.spec.ts b/sdk/ai/ai-projects/test/public/agents/runSteps.spec.ts deleted file mode 100644 index 86eda91364ed..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/runSteps.spec.ts +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import { delay } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - run steps", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("should list run steps", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - - // Wait for run to complete - assert.oneOf(run.status, ["queued", "in_progress", "requires_action", "completed"]); - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await agents.getRun(thread.id, run.id); - console.log(`Run status: ${run.status}`); - assert.include(["queued", "in_progress", "requires_action", "completed"], run.status); - } - - // List run steps - const runSteps = await agents.listRunSteps(thread.id, run.id); - assert.isNotNull(runSteps.data); - - // Clean up - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); - - it("should get steps", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Create run - let run = await agents.createRun(thread.id, agent.id); - console.log(`Created run, run ID: ${run.id}`); - - // Wait for run to complete - assert.oneOf(run.status, ["queued", "in_progress", "requires_action", "completed"]); - console.log(`Run status - ${run.status}, run ID: ${run.id}`); - while (["queued", "in_progress", "requires_action"].includes(run.status)) { - await delay(1000); - run = await agents.getRun(thread.id, run.id); - console.log(`Run status - ${run.status}, run ID: ${run.id}`); - assert.include(["queued", "in_progress", "requires_action", "completed"], run.status); - } - - // List run steps - const runSteps = await agents.listRunSteps(thread.id, run.id); - assert.isNotNull(runSteps.data); - assert.isTrue(runSteps.data.length > 0); - console.log(`Listed run steps, run ID: ${run.id}`); - - // Get specific run step - const stepId = runSteps.data[0].id; - const step = await agents.getRunStep(thread.id, run.id, stepId); - console.log(`Retrieved run, step ID: ${stepId}`); - assert.isNotNull(step); - assert.equal(step.id, stepId); - - // Clean up - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/runs.spec.ts b/sdk/ai/ai-projects/test/public/agents/runs.spec.ts deleted file mode 100644 index 21682dc31465..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/runs.spec.ts +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import { delay } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - Run", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("should create agent and run agent", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are helpful agent", - }); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - assert.isNotNull(thread); - assert.isNotNull(thread.id); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create run - const run = await agents.createRun(thread.id, agent.id); - assert.isNotNull(run); - assert.isNotNull(run.id); - console.log(`Created Run, Run ID: ${run.id}`); - - // Delete agent and thread - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - await agents.deleteThread(thread.id); - console.log(`Deleted Thread, thread ID: ${thread.id}`); - }); - - it("should create and get run", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are helpful agent", - }); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - assert.isNotNull(thread); - assert.isNotNull(thread.id); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create run - const run = await agents.createRun(thread.id, agent.id); - assert.isNotNull(run); - assert.isNotNull(run.id); - console.log(`Created Run, Run ID: ${run.id}`); - - // Get run - const runDetails = await agents.getRun(thread.id, run.id); - assert.isNotNull(runDetails); - assert.isNotNull(runDetails.id); - assert.equal(run.id, runDetails.id); - console.log(`Retrieved run, Run ID: ${runDetails.id}`); - - // Delete agent and thread - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - await agents.deleteThread(thread.id); - console.log(`Deleted Thread, thread ID: ${thread.id}`); - }); - - it("should create and get run status", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are helpful agent", - }); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - assert.isNotNull(thread); - assert.isNotNull(thread.id); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - assert.isNotNull(message.id); - console.log(`Created message, message ID ${message.id}`); - - // Create run - const run = await agents.createRun(thread.id, agent.id); - assert.isNotNull(run); - assert.isNotNull(run.id); - console.log(`Created Run, Run ID: ${run.id}`); - - // Get run status - let runDetails = await agents.getRun(thread.id, run.id); - assert.isNotNull(runDetails); - assert.isNotNull(runDetails.id); - assert.equal(run.id, runDetails.id); - console.log(`Retrieved run status - ${runDetails.status}, run ID: ${runDetails.id}`); - - // Wait for status to update - assert.oneOf(runDetails.status, [ - "queued", - "in_progress", - "requires_action", - "cancelling", - "cancelled", - "failed", - "completed", - "expired", - ]); - while (["queued", "in_progress", "requires_action"].includes(runDetails.status)) { - await delay(1000); - runDetails = await agents.getRun(thread.id, run.id); - if (runDetails.lastError) { - console.log( - `Run status ${runDetails.status} - ${runDetails.lastError.code} - ${runDetails.lastError.message}`, - "color:red", - ); - } - if (runDetails) { - console.log(`Run status - ${runDetails.status}, run ID: ${runDetails.id}`); - } else { - console.log("Run details are undefined."); - } - } - assert.oneOf(runDetails.status, ["cancelled", "failed", "completed", "expired"]); - console.log(`Run status - ${runDetails.status}, run ID: ${runDetails.id}`); - - // Delete agent and thread - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - await agents.deleteThread(thread.id); - console.log(`Deleted Thread, thread ID: ${thread.id}`); - }); - - it("should create and list runs", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are helpful agent", - }); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - assert.isNotNull(thread); - assert.isNotNull(thread.id); - console.log(`Created Thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - assert.isNotNull(message.id); - console.log(`Created message, message ID ${message.id}`); - - // Create run - const run = await agents.createRun(thread.id, agent.id); - assert.isNotNull(run); - assert.isNotNull(run.id); - console.log(`Created Run, Run ID: ${run.id}`); - - // Get run status - const runs = await agents.listRuns(thread.id); - assert.isNotNull(runs); - assert.isArray(runs.data); - console.log(`List - found no of runs: ${runs.data.length}, first run ID: ${runs.firstId}`); - const runDetails = runs.data.find((threadRun) => threadRun.id === run.id); - assert.isNotNull(runDetails); - if (runDetails) { - console.log(`Run status - ${runDetails.status}, run ID: ${runDetails.id}`); - } else { - console.log("Run details are undefined."); - } - - // Delete agent and thread - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - await agents.deleteThread(thread.id); - console.log(`Deleted Thread, thread ID: ${thread.id}`); - }); - - it("should create and run in single call", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are helpful agent", - }); - assert.isNotNull(agent); - assert.isNotNull(agent.id); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create run - const run = await agents.createThreadAndRun(agent.id, { - thread: { - messages: [ - { - role: "user", - content: "Hello, tell me a joke", - }, - ], - }, - }); - assert.isNotNull(run); - assert.isNotNull(run.id); - assert.isNotNull(run.threadId); - console.log(`Created Run, Run ID: ${run.id}, Thread ID: ${run.threadId}`); - console.log(`Started : ${run.createdAt}`); - - // Get run - const runDetails = await agents.getRun(run.threadId, run.id); - assert.isNotNull(runDetails); - assert.isNotNull(runDetails.id); - assert.equal(run.id, runDetails.id); - console.log(`Retrieved run, Run ID: ${runDetails.id}`); - - // Delete agent and thread - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - await agents.deleteThread(run.threadId); - console.log(`Deleted Thread, thread ID: ${run.threadId}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/streaming.spec.ts b/sdk/ai/ai-projects/test/public/agents/streaming.spec.ts deleted file mode 100644 index a22b42a134cf..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/streaming.spec.ts +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient, ThreadRunOutput } from "../../../src/index.js"; -import { MessageStreamEvent, RunStreamEvent } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - streaming", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("should run streaming", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4-1106-preview", { - name: "My Friendly Test Assistant", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Create message - const message = await agents.createMessage(thread.id, { - role: "user", - content: "Hello, tell me a joke", - }); - console.log(`Created message, message ID: ${message.id}`); - - // Run streaming - const streamEventMessages = await agents.createRun(thread.id, agent.id).stream(); - let hasEventMessages = false; - - for await (const eventMessage of streamEventMessages) { - hasEventMessages = true; - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`Thread Run Created - ${(eventMessage.data as ThreadRunOutput).assistantId}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - console.log(`Thread Message Delta, thread ID: ${thread.id}`); - break; - case RunStreamEvent.ThreadRunCompleted: - console.log(`Thread Run Completed, thread ID: ${thread.id}`); - break; - } - } - assert.isTrue(hasEventMessages); - assert.isNotNull(streamEventMessages); - - // Delete agent and thread - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - await agents.deleteThread(thread.id); - console.log(`Deleted Thread, thread ID: ${thread.id}`); - }); - - // eslint-disable-next-line no-only-tests/no-only-tests - it("should create thread and run streaming", async function () { - // Create agent - const agent = await agents.createAgent("gpt-4-1106-preview", { - name: "My Friendly Test Assistant", - instructions: "You are helpful agent", - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - // Create thread and run streaming - const streamEventMessages = await agents - .createThreadAndRun(agent.id, { - thread: { messages: [{ role: "user", content: "Hello, tell me a joke" }] }, - }) - .stream(); - - let hasEventMessages = false; - for await (const eventMessage of streamEventMessages) { - hasEventMessages = true; - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log("Thread Run Created"); - break; - case MessageStreamEvent.ThreadMessageDelta: - console.log("Thread Message Delta"); - break; - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - } - } - assert.isTrue(hasEventMessages); - assert.isNotNull(streamEventMessages); - - // Delete agent - await agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts b/sdk/ai/ai-projects/test/public/agents/threads.spec.ts deleted file mode 100644 index da8415a0eabc..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/threads.spec.ts +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - threads", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and agents operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(agents); - }); - - it("should create thread", async function () { - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - assert.isNotNull(thread); - assert.isNotNull(thread.id); - - // Delete thread - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - }); - - it("should retrieve thread", async function () { - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Retrieve thread - const _thread = await agents.getThread(thread.id); - assert.isNotEmpty(_thread); - assert.equal(_thread.id, thread.id); - console.log(`Retrieved thread, thread ID: ${_thread.id}`); - - // Delete thread - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - }); - - it("should update thread", async function () { - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Update thread - await agents.updateThread(thread.id, { metadata: { key: "value" } }); - const _thread = await agents.getThread(thread.id); - assert.equal(_thread.id, thread.id); - assert.isNotEmpty(_thread.metadata); - assert.equal(_thread.metadata?.key, "value"); - console.log( - `Updated thread to have metadata "key":"${_thread.metadata?.key}", thread ID: ${_thread.id}`, - ); - - // Delete thread - await agents.deleteThread(thread.id); - console.log(`Deleted thread, thread ID: ${thread.id}`); - }); - - it("should delete thread", async function () { - // Create thread - const thread = await agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - // Delete thread - const deleted = await agents.deleteThread(thread.id); - assert.isNotNull(deleted); - console.log(`Deleted thread, thread ID: ${thread.id}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/tracing.spec.ts b/sdk/ai/ai-projects/test/public/agents/tracing.spec.ts deleted file mode 100644 index 2b56026dd0cc..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/tracing.spec.ts +++ /dev/null @@ -1,233 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createMockProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe, vi } from "vitest"; -import type { MockTracingSpan } from "@azure-tools/test-utils-vitest"; -import { MockInstrumenter } from "@azure-tools/test-utils-vitest"; -import type { - AddEventOptions, - Instrumenter, - InstrumenterSpanOptions, - TracingContext, - TracingSpan, -} from "@azure/core-tracing"; -import { useInstrumenter } from "@azure/core-tracing"; -import type { - ThreadRunOutput, - ThreadMessageOutput, - AgentThreadOutput, - AgentOutput, -} from "../../../src/generated/src/index.js"; - -interface ExtendedMockTrackingSpan extends MockTracingSpan { - events?: { name: string; attributes: Record }[]; - addEvent?(eventName: string, options?: AddEventOptions): void; -} -class ExtendedMockInstrumenter extends MockInstrumenter { - extendSpan(span: any): void { - if (!span.events) { - span.events = []; - } - span.addEvent = (eventName: string, options?: AddEventOptions) => { - span.events.push({ name: eventName, ...options }); - }; - } - startSpan( - name: string, - spanOptions?: InstrumenterSpanOptions, - ): { span: TracingSpan; tracingContext: TracingContext } { - const { span, tracingContext } = super.startSpan(name, spanOptions); - this.extendSpan(span); - return { span, tracingContext }; - } -} - -describe("Agent Tracing", () => { - let instrumenter: Instrumenter; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - let response: any = {}; - let status = 200; - beforeEach(async function () { - instrumenter = new ExtendedMockInstrumenter(); - useInstrumenter(instrumenter); - - projectsClient = createMockProjectsClient(() => { - return { bodyAsText: JSON.stringify(response), status: status }; - }); - agents = projectsClient.agents; - }); - - afterEach(async function () { - (instrumenter as MockInstrumenter).reset(); - vi.clearAllMocks(); - response = {}; - status = 200; - }); - - it("create agent", async function () { - const agentResponse: Partial = { id: "agentId", object: "assistant" }; - response = agentResponse; - status = 200; - const request = { - name: "agentName", - instructions: "You are helpful agent", - response_format: "json", - }; - const model = "gpt-4o"; - await agents.createAgent(model, request); - const mockedInstrumenter = instrumenter as MockInstrumenter; - assert.isAbove(mockedInstrumenter.startedSpans.length, 0); - const span = mockedInstrumenter.startedSpans[0] as ExtendedMockTrackingSpan; - assert.equal(span.attributes["gen_ai.agent.id"], agentResponse.id); - assert.equal(span.attributes["gen_ai.operation.name"], "create_agent"); - assert.equal(span.attributes["gen_ai.agent.name"], request.name); - assert.equal(span.attributes["gen_ai.request.model"], model); - const event = span.events?.find((e) => e.name === "gen_ai.system.message"); - assert.isDefined(event); - assert.equal( - event?.attributes["gen_ai.event.content"], - JSON.stringify({ content: request.instructions }), - ); - }); - - it("create run", async function () { - const runResponse: Partial = { - id: "runId", - object: "thread.run", - status: "queued", - thread_id: "threadId", - assistant_id: "agentId", - }; - response = runResponse; - status = 200; - await agents.createRun("threadId", "agentId"); - const mockedInstrumenter = instrumenter as MockInstrumenter; - assert.isAbove(mockedInstrumenter.startedSpans.length, 0); - const span = mockedInstrumenter.startedSpans[0] as ExtendedMockTrackingSpan; - assert.equal(span.attributes["gen_ai.thread.id"], runResponse.thread_id); - assert.equal(span.attributes["gen_ai.operation.name"], "create_run"); - assert.equal(span.attributes["gen_ai.agent.id"], runResponse.assistant_id); - assert.equal(span.attributes["gen_ai.thread.run.status"], runResponse.status); - assert.equal(span.events!.length, 1); - }); - - it("create Thread", async function () { - const threadResponse: Partial = { id: "threadId", object: "thread" }; - response = threadResponse; - status = 200; - await agents.createThread(); - const mockedInstrumenter = instrumenter as MockInstrumenter; - assert.isAbove(mockedInstrumenter.startedSpans.length, 0); - const span = mockedInstrumenter.startedSpans[0]; - assert.equal(span.attributes["gen_ai.thread.id"], threadResponse.id); - assert.equal(span.attributes["gen_ai.operation.name"], "create_thread"); - }); - - it("create Message", async function () { - const messageResponse: Partial = { - id: "messageId", - object: "thread.message", - thread_id: "threadId", - }; - projectsClient.telemetry.updateSettings({ enableContentRecording: true }); - response = messageResponse; - status = 200; - const request = { content: "hello, world!", role: "user" }; - await agents.createMessage("threadId", request); - const mockedInstrumenter = instrumenter as MockInstrumenter; - assert.isAbove(mockedInstrumenter.startedSpans.length, 0); - const span = mockedInstrumenter.startedSpans[0] as ExtendedMockTrackingSpan; - assert.equal(span.attributes["gen_ai.thread.id"], messageResponse.thread_id); - assert.equal(span.attributes["gen_ai.operation.name"], "create_message"); - const event = span.events?.find((e) => e.name === "gen_ai.user.message"); - assert.isDefined(event); - assert.equal(event?.attributes["gen_ai.event.content"], JSON.stringify(request)); - assert.equal(event?.attributes["gen_ai.thread.id"], messageResponse.thread_id); - assert.equal(event?.name, "gen_ai.user.message"); - }); - - it("list messages", async function () { - const listMessages = { - object: "list", - data: [ - { - id: "messageId", - object: "thread.message", - thread_id: "threadId", - role: "assistant", - content: [{ type: "text", text: { value: "You are helpful agent" } }], - }, - { - id: "messageId2", - object: "thread.message", - thread_id: "threadId", - role: "user", - content: [{ type: "text", text: { value: "Hello, tell me a joke" } }], - }, - ], - }; - response = listMessages; - projectsClient.telemetry.updateSettings({ enableContentRecording: true }); - status = 200; - await agents.listMessages("threadId"); - const mockedInstrumenter = instrumenter as MockInstrumenter; - assert.isAbove(mockedInstrumenter.startedSpans.length, 0); - const span = mockedInstrumenter.startedSpans[0] as ExtendedMockTrackingSpan; - assert.isDefined(span.events); - assert.equal(span.events!.length, 2); - assert.equal( - span.events![0].attributes["gen_ai.event.content"], - JSON.stringify({ - content: { text: listMessages.data[0].content[0].text }, - role: listMessages.data[0].role, - }), - ); - assert.equal(span.events![0].name, "gen_ai.assistant.message"); - assert.equal( - span.events![1].attributes["gen_ai.event.content"], - JSON.stringify({ - content: { text: listMessages.data[1].content[0].text }, - role: listMessages.data[1].role, - }), - ); - assert.equal(span.events![1].name, "gen_ai.user.message"); - }); - - it("Submit tool outputs to run", async function () { - const submitToolOutputs = { - object: "thread.run", - id: "runId", - status: "queued", - thread_id: "threadId", - assistant_id: "agentId", - }; - response = submitToolOutputs; - status = 200; - const toolOutputs = [ - { toolCallId: "toolcallId1", output: "output1" }, - { toolCallId: "toolcallId2", output: "output2" }, - ]; - await agents.submitToolOutputsToRun("threadId", "runId", toolOutputs); - const mockedInstrumenter = instrumenter as MockInstrumenter; - assert.isAbove(mockedInstrumenter.startedSpans.length, 0); - const span = mockedInstrumenter.startedSpans[0] as ExtendedMockTrackingSpan; - assert.equal(span.attributes["gen_ai.thread.id"], submitToolOutputs.thread_id); - assert.equal(span.attributes["gen_ai.operation.name"], "submit_tool_outputs"); - assert.equal(span.attributes["gen_ai.thread.run.status"], submitToolOutputs.status); - assert.isDefined(span.events); - assert.equal(span.events!.length, 2); - assert.equal( - span.events![0].attributes["gen_ai.event.content"], - JSON.stringify({ content: toolOutputs[0].output, id: toolOutputs[0].toolCallId }), - ); - assert.equal(span.events![0].name, "gen_ai.tool.message"); - assert.equal( - span.events![1].attributes["gen_ai.event.content"], - JSON.stringify({ content: toolOutputs[1].output, id: toolOutputs[1].toolCallId }), - ); - assert.equal(span.events![1].name, "gen_ai.tool.message"); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/vectorStores.spec.ts b/sdk/ai/ai-projects/test/public/agents/vectorStores.spec.ts deleted file mode 100644 index cca79d247cbb..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/vectorStores.spec.ts +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - vector stores", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and agents operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(agents); - }); - - it("should create vector store", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - assert.isNotNull(vectorStore); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Delete vector store - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should delete vector store", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Delete vector store - const deletionStatus = await agents.deleteVectorStore(vectorStore.id); - assert.isTrue(deletionStatus.deleted); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("get vector store", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Retrieve vector store - const _vectorStore = await agents.getVectorStore(vectorStore.id); - assert.equal(_vectorStore.id, vectorStore.id); - console.log(`Retrieved vector store, vector store ID: ${_vectorStore.id}`); - - // Delete vector store - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("list vector stores", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // List vector stores - const vectorStores = await agents.listVectorStores(); - assert.isNotNull(vectorStores); - assert.isAtLeast(vectorStores.data.length, 1); - console.log(`Listed ${vectorStores.data.length} vector stores`); - - // Delete vector store - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("modify vector store", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Modify vector store - const updatedVectorStore = await agents.modifyVectorStore(vectorStore.id, { name: "updated" }); - assert.equal(updatedVectorStore.id, vectorStore.id); - assert.equal(updatedVectorStore.name, "updated"); - console.log( - `Updated vector store name to ${updatedVectorStore.name}, vector store ID: ${updatedVectorStore.id}`, - ); - - // Delete vector store - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should create vector store and poll (through original method)", async function () { - // Create vector store - const vectorStorePoller = agents.createVectorStoreAndPoll(); - const initialState = vectorStorePoller.poll(); - assert.isNotNull(initialState); - const vectorStore = await vectorStorePoller.pollUntilDone(); - assert.isNotNull(vectorStore); - assert.notEqual(vectorStore.status, "in_progress"); - console.log( - `Created vector store with status ${vectorStore.status}, vector store ID: ${vectorStore.id}`, - ); - - // Delete vector store - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should create vector store and poll (through creation method)", async function () { - // Create vector store - const vectorStorePoller = agents.createVectorStore({ - pollingOptions: { sleepIntervalInMs: 2000 }, - }); - const initialState = vectorStorePoller.poll(); - assert.isNotNull(initialState); - const vectorStore = await vectorStorePoller.pollUntilDone(); - assert.isNotNull(vectorStore); - assert.notEqual(vectorStore.status, "in_progress"); - console.log( - `Created vector store with status ${vectorStore.status}, vector store ID: ${vectorStore.id}`, - ); - - // Delete vector store - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/agents/vectorStoresFileBatches.spec.ts b/sdk/ai/ai-projects/test/public/agents/vectorStoresFileBatches.spec.ts deleted file mode 100644 index f6324cac2142..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/vectorStoresFileBatches.spec.ts +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; -import { isNodeLike } from "@azure/core-util"; - -describe("Agents - vector stores file batches", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and agents operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(agents); - }); - - it("should create a vector store file batch", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload files - const fileContent1 = await generateFileStream(); - const file1 = await agents.uploadFile(fileContent1, "assistants", { fileName: "filename.txt" }); - const fileContent2 = await generateFileStream(); - const file2 = await agents.uploadFile(fileContent2, "assistants", { fileName: "filename.txt" }); - - // Create vector store file batch - const vectorStoreFileBatch = await agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - assert.isNotNull(vectorStoreFileBatch); - assert.isNotEmpty(vectorStoreFileBatch.id); - assert.equal(vectorStoreFileBatch.vectorStoreId, vectorStore.id); - console.log( - `Created vector store file batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Clean up - await agents.deleteFile(file1.id); - console.log(`Deleted file, file ID: ${file1.id}`); - await agents.deleteFile(file2.id); - console.log(`Deleted file, file ID: ${file2.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should retrieve a vector store file batch", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload files - const fileContent1 = await generateFileStream(); - const file1 = await agents.uploadFile(fileContent1, "assistants", { fileName: "filename.txt" }); - const fileContent2 = await generateFileStream(); - const file2 = await agents.uploadFile(fileContent2, "assistants", { fileName: "filename.txt" }); - - // Create vector store file batch - const vectorStoreFileBatch = await agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - console.log( - `Created vector store file batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Retrieve vector store file batch - const _vectorStoreFileBatch = await agents.getVectorStoreFileBatch( - vectorStore.id, - vectorStoreFileBatch.id, - ); - assert.isNotNull(_vectorStoreFileBatch); - assert.equal(_vectorStoreFileBatch.id, vectorStoreFileBatch.id); - console.log( - `Retrieved vector store file batch, vector store file batch ID: ${_vectorStoreFileBatch.id}`, - ); - - // Clean up - await agents.deleteFile(file1.id); - console.log(`Deleted file, file ID: ${file1.id}`); - await agents.deleteFile(file2.id); - console.log(`Deleted file, file ID: ${file2.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should list vector store file batches", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload files - const fileContent1 = await generateFileStream(); - const file1 = await agents.uploadFile(fileContent1, "assistants", { fileName: "filename.txt" }); - const fileContent2 = await generateFileStream(); - const file2 = await agents.uploadFile(fileContent2, "assistants", { fileName: "filename.txt" }); - - // Create vector store file batch - const vectorStoreFileBatch = await agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - console.log( - `Created vector store file batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // List vector store files in the batch - const vectorStoreFiles = await agents.listVectorStoreFileBatchFiles( - vectorStore.id, - vectorStoreFileBatch.id, - ); - assert.isNotNull(vectorStoreFiles); - assert.equal(vectorStoreFiles.data.length, 2); - console.log( - `Listed ${vectorStoreFiles.data.length} vector store files in the batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Clean up - await agents.deleteFile(file1.id); - console.log(`Deleted file, file ID: ${file1.id}`); - await agents.deleteFile(file2.id); - console.log(`Deleted file, file ID: ${file2.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should cancel a vector store file batch", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload files - const fileContent1 = await generateFileStream(); - const file1 = await agents.uploadFile(fileContent1, "assistants", { fileName: "filename.txt" }); - const fileContent2 = await generateFileStream(); - const file2 = await agents.uploadFile(fileContent2, "assistants", { fileName: "filename.txt" }); - - // Create vector store file batch - const vectorStoreFileBatch = await agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - console.log( - `Created vector store file batch, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Cancel vector store file batch - const cancelled = await agents.cancelVectorStoreFileBatch( - vectorStore.id, - vectorStoreFileBatch.id, - ); - assert.isNotNull(cancelled.status); - - // Clean up - await agents.deleteFile(file1.id); - console.log(`Deleted file, file ID: ${file1.id}`); - await agents.deleteFile(file2.id); - console.log(`Deleted file, file ID: ${file2.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should create a vector store file batch and poll (through original method)", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload files - const fileContent1 = await generateFileStream(); - const file1 = await agents.uploadFile(fileContent1, "assistants", { fileName: "filename.txt" }); - const fileContent2 = await generateFileStream(); - const file2 = await agents.uploadFile(fileContent2, "assistants", { fileName: "filename.txt" }); - - // Create vector store file batch - const vectorStoreFileBatchPoller = agents.createVectorStoreFileBatchAndPoll(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - assert.isNotNull(vectorStoreFileBatchPoller); - const initialState = vectorStoreFileBatchPoller.poll(); - assert.isNotNull(initialState); - const vectorStoreFileBatch = await vectorStoreFileBatchPoller.pollUntilDone(); - assert.isNotNull(vectorStoreFileBatch); - assert.isNotEmpty(vectorStoreFileBatch.id); - assert.equal(vectorStoreFileBatch.vectorStoreId, vectorStore.id); - assert.notEqual(vectorStoreFileBatch.status, "in_progress"); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch.status}, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Clean up - await agents.deleteFile(file1.id); - console.log(`Deleted file, file ID: ${file1.id}`); - await agents.deleteFile(file2.id); - console.log(`Deleted file, file ID: ${file2.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should create a vector store file batch and poll (through creation method)", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload files - const fileContent1 = await generateFileStream(); - const file1 = await agents.uploadFile(fileContent1, "assistants", { fileName: "filename.txt" }); - const fileContent2 = await generateFileStream(); - const file2 = await agents.uploadFile(fileContent2, "assistants", { fileName: "filename.txt" }); - - // Create vector store file batch - const vectorStoreFileBatchPoller = agents.createVectorStoreFileBatch(vectorStore.id, { - fileIds: [file1.id, file2.id], - }); - assert.isNotNull(vectorStoreFileBatchPoller); - const initialState = vectorStoreFileBatchPoller.poll(); - assert.isNotNull(initialState); - const vectorStoreFileBatch = await vectorStoreFileBatchPoller.pollUntilDone(); - assert.isNotEmpty(vectorStoreFileBatch.id); - assert.equal(vectorStoreFileBatch.vectorStoreId, vectorStore.id); - assert.notEqual(vectorStoreFileBatch.status, "in_progress"); - console.log( - `Created vector store file batch with status ${vectorStoreFileBatch.status}, vector store file batch ID: ${vectorStoreFileBatch.id}`, - ); - - // Clean up - await agents.deleteFile(file1.id); - console.log(`Deleted file, file ID: ${file1.id}`); - await agents.deleteFile(file2.id); - console.log(`Deleted file, file ID: ${file2.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); -}); - -async function generateFileStream(): Promise { - if (isNodeLike) { - const stream = await import("stream"); - return stream.Readable.from("fileContent"); - } else { - return new ReadableStream({ - start(controller) { - controller.enqueue(new TextEncoder().encode("fileContent")); - controller.close(); - }, - }); - } -} diff --git a/sdk/ai/ai-projects/test/public/agents/vectorStoresFiles.spec.ts b/sdk/ai/ai-projects/test/public/agents/vectorStoresFiles.spec.ts deleted file mode 100644 index b6ec25fe214b..000000000000 --- a/sdk/ai/ai-projects/test/public/agents/vectorStoresFiles.spec.ts +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AgentsOperations, AIProjectsClient } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; -import { isNodeLike } from "@azure/core-util"; - -describe("Agents - vector stores files", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let agents: AgentsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - agents = projectsClient.agents; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and agents operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(agents); - }); - - it("should create a vector store file", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload file - const fileContent = await generateFileStream(); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file - const vectorStoreFile = await agents.createVectorStoreFile(vectorStore.id, { fileId: file.id }); - assert.isNotNull(vectorStoreFile); - assert.isNotEmpty(vectorStoreFile.id); - console.log(`Created vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Clean up - await agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - await agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should retrieve a vector store file", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload file - const fileContent = await generateFileStream(); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file - const vectorStoreFile = await agents.createVectorStoreFile(vectorStore.id, { fileId: file.id }); - console.log(`Created vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Retrieve vector store file - const _vectorStoreFile = await agents.getVectorStoreFile(vectorStore.id, vectorStoreFile.id); - assert.isNotNull(_vectorStoreFile); - assert.equal(_vectorStoreFile.id, vectorStoreFile.id); - console.log(`Retrieved vector store file, vector store file ID: ${_vectorStoreFile.id}`); - - // Clean up - await agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - await agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should list vector store files", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload file - const fileContent = await generateFileStream(); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file - const vectorStoreFile = await agents.createVectorStoreFile(vectorStore.id, { fileId: file.id }); - console.log(`Created vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Clean up - await agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - await agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should delete a vector store file", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload file - const fileContent = await generateFileStream(); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file - const vectorStoreFile = await agents.createVectorStoreFile(vectorStore.id, { fileId: file.id }); - console.log(`Created vector store file, vector store file ID: ${vectorStoreFile.id}`); - - // Clean up - const deletionStatus = await agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - assert(deletionStatus.deleted); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - await agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should create a vector store file and poll (through original method)", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload file - const fileContent = await generateFileStream(); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file and poll - const vectorStoreFilePoller = agents.createVectorStoreFileAndPoll(vectorStore.id, { - fileId: file.id, - }); - assert.isNotNull(vectorStoreFilePoller); - const initialState = vectorStoreFilePoller.poll(); - assert.isNotNull(initialState); - const vectorStoreFile = await vectorStoreFilePoller.pollUntilDone(); - assert.isNotNull(vectorStoreFile); - assert.isNotEmpty(vectorStoreFile.id); - assert.notEqual(vectorStoreFile.status, "in_progress"); - console.log( - `Created vector store file with status ${vectorStoreFile.status}, vector store file ID: ${vectorStoreFile.id}`, - ); - - // Clean up - await agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - await agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); - - it("should create a vector store file and poll (through creation method)", async function () { - // Create vector store - const vectorStore = await agents.createVectorStore(); - console.log(`Created vector store, vector store ID: ${vectorStore.id}`); - - // Upload file - const fileContent = await generateFileStream(); - const file = await agents.uploadFile(fileContent, "assistants", { fileName: "filename.txt" }); - console.log(`Uploaded file, file ID: ${file.id}`); - - // Create vector store file and poll - const vectorStoreFilePoller = agents.createVectorStoreFile(vectorStore.id, { - fileId: file.id, - }); - assert.isNotNull(vectorStoreFilePoller); - const initialState = vectorStoreFilePoller.poll(); - assert.isNotNull(initialState); - const vectorStoreFile = await vectorStoreFilePoller.pollUntilDone(); - assert.isNotNull(vectorStoreFile); - assert.isNotEmpty(vectorStoreFile.id); - assert.notEqual(vectorStoreFile.status, "in_progress"); - console.log( - `Created vector store file with status ${vectorStoreFile.status}, vector store file ID: ${vectorStoreFile.id}`, - ); - - // Clean up - await agents.deleteVectorStoreFile(vectorStore.id, vectorStoreFile.id); - console.log(`Deleted vector store file, vector store file ID: ${vectorStoreFile.id}`); - await agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - await agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - }); -}); - -async function generateFileStream(): Promise { - if (isNodeLike) { - const stream = await import("stream"); - return stream.Readable.from("fileContent"); - } else { - return new ReadableStream({ - start(controller) { - controller.enqueue(new TextEncoder().encode("fileContent")); - controller.close(); - }, - }); - } -} diff --git a/sdk/ai/ai-projects/test/public/connections/connections.spec.ts b/sdk/ai/ai-projects/test/public/connections/connections.spec.ts deleted file mode 100644 index 639ed77daf3a..000000000000 --- a/sdk/ai/ai-projects/test/public/connections/connections.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AIProjectsClient, ConnectionsOperations } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("Agents - assistants", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let connections: ConnectionsOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - connections = projectsClient.connections; - }); - - afterEach(async function () { - await recorder.stop(); - }); - - it("client and connection operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(connections); - }); - - it("should list connections", async function () { - // List connections - const connectionsList = await connections.listConnections(); - assert.isNotNull(connectionsList); - assert.isAtLeast(connectionsList.length, 1); - console.log(`Retrieved ${connectionsList.length} connections`); - }); - - it("should retrieve a connection without secrets", async function () { - // List connections - const connectionsList = await connections.listConnections(); - assert.isNotNull(connectionsList); - assert.isAtLeast(connectionsList.length, 1); - - // Retrieve one connection - for (const _connection of connectionsList) { - const connectionName = _connection.name; - const connection = await connections.getConnection(connectionName); - assert.isNotNull(connection); - assert.equal(connection.name, connectionName); - console.log(`Retrieved connection, connection name: ${connection.name}`); - } - }); - - it("should retrieve a connection with secrets", async function () { - // List connections - const connectionsList = await connections.listConnections(); - assert.isNotNull(connectionsList); - assert.isAtLeast(connectionsList.length, 1); - - // Retrieve one connection with secrets - for (const _connection of connectionsList) { - const connectionName = _connection.name; - const connection = await connections.getConnectionWithSecrets(connectionName); - assert.isNotNull(connection); - assert.equal(connection.name, connectionName); - console.log(`Retrieved connection with secrets, connection name: ${connection.name}`); - } - }); -}); diff --git a/sdk/ai/ai-projects/test/public/sampleTest.spec.ts b/sdk/ai/ai-projects/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..d4919ac91ac5 --- /dev/null +++ b/sdk/ai/ai-projects/test/public/sampleTest.spec.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createRecorder } from "./utils/recordedClient.js"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + beforeEach(async function () { + // recorder = await createRecorder(this); + }); + + afterEach(async function () { + // await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/ai/ai-projects/test/public/telemetry/telemetry.spec.ts b/sdk/ai/ai-projects/test/public/telemetry/telemetry.spec.ts deleted file mode 100644 index 1f19f895196f..000000000000 --- a/sdk/ai/ai-projects/test/public/telemetry/telemetry.spec.ts +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { Recorder, VitestTestContext } from "@azure-tools/test-recorder"; -import type { AIProjectsClient, TelemetryOperations } from "../../../src/index.js"; -import { createRecorder, createProjectsClient } from "../utils/createClient.js"; -import { assert, beforeEach, afterEach, it, describe } from "vitest"; - -describe("AI Projects - Telemetry", () => { - let recorder: Recorder; - let projectsClient: AIProjectsClient; - let telemetry: TelemetryOperations; - - beforeEach(async function (context: VitestTestContext) { - recorder = await createRecorder(context); - projectsClient = createProjectsClient(recorder); - telemetry = projectsClient.telemetry; - }); - - afterEach(async function () { - await recorder.stop(); - }); - it("client and connection operations are accessible", async function () { - assert.isNotNull(projectsClient); - assert.isNotNull(telemetry); - }); - - it("update settings", async function () { - assert.equal(telemetry.getSettings().enableContentRecording, false); - telemetry.updateSettings({ enableContentRecording: true }); - assert.equal(telemetry.getSettings().enableContentRecording, true); - }); - - it("get settings", async function () { - const options = telemetry.getSettings(); - assert.equal(options.enableContentRecording, false); - options.enableContentRecording = true; - assert.equal(telemetry.getSettings().enableContentRecording, false); - }); - - it("get app insights connection string", async function () { - const connectionString = await telemetry.getConnectionString(); - assert.isNotEmpty(connectionString); - console.log(`Connection string retrieved ${connectionString}`); - }); -}); diff --git a/sdk/ai/ai-projects/test/public/utils/createClient.ts b/sdk/ai/ai-projects/test/public/utils/createClient.ts deleted file mode 100644 index 4232d503bf3e..000000000000 --- a/sdk/ai/ai-projects/test/public/utils/createClient.ts +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { RecorderStartOptions, VitestTestContext } from "@azure-tools/test-recorder"; -import { Recorder } from "@azure-tools/test-recorder"; -import { createTestCredential } from "@azure-tools/test-credential"; -import { AIProjectsClient } from "../../../src/index.js"; -import type { ClientOptions } from "@azure-rest/core-client"; -import type { PipelineRequest, PipelineResponse } from "@azure/core-rest-pipeline"; -import { createHttpHeaders } from "@azure/core-rest-pipeline"; - -const replaceableVariables: Record = { - GENERIC_STRING: "Sanitized", - ENDPOINT: "Sanitized.azure.com", - SUBSCRIPTION_ID: "00000000-0000-0000-0000-000000000000", - RESOURCE_GROUP_NAME: "00000", - WORKSPACE_NAME: "00000", - DATASET_NAME: "00000", - TENANT_ID: "00000000-0000-0000-0000-000000000000", - USER_OBJECT_ID: "00000000-0000-0000-0000-000000000000", - API_KEY: "00000000000000000000000000000000000000000000000000000000000000000000", - AZURE_AI_PROJECTS_CONNECTION_STRING: `Sanitized.azure.com;00000000-0000-0000-0000-000000000000;00000;00000`, -}; - -const recorderEnvSetup: RecorderStartOptions = { - envSetupForPlayback: replaceableVariables, - sanitizerOptions: { - generalSanitizers: [ - { - regex: true, - target: "(%2F|/)?subscriptions(%2F|/)([-\\w\\._\\(\\)]+)", - value: replaceableVariables.SUBSCRIPTION_ID, - groupForReplace: "3", - }, - { - regex: true, - target: "(%2F|/)?resource[gG]roups(%2F|/)([-\\w\\._\\(\\)]+)", - value: replaceableVariables.RESOURCE_GROUP_NAME, - groupForReplace: "3", - }, - { - regex: true, - target: "/workspaces/([-\\w\\._\\(\\)]+)", - value: replaceableVariables.WORKSPACE_NAME, - groupForReplace: "1", - }, - { - regex: true, - target: "/userAssignedIdentities/([-\\w\\._\\(\\)]+)", - value: replaceableVariables.GENERIC_STRING, - groupForReplace: "1", - }, - { - regex: true, - target: "/components/([-\\w\\._\\(\\)]+)", - value: replaceableVariables.GENERIC_STRING, - groupForReplace: "1", - }, - { - regex: true, - target: "/vaults/([-\\w\\._\\(\\)]+)", - value: replaceableVariables.GENERIC_STRING, - groupForReplace: "1", - }, - { - regex: true, - target: "(azureml|http|https):\\/\\/([^\\/]+)", - value: replaceableVariables.ENDPOINT, - groupForReplace: "2", - }, - ], - bodyKeySanitizers: [ - { - jsonPath: "properties.ConnectionString", - value: - "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://region.applicationinsights.azure.com/;LiveEndpoint=https://region.livediagnostics.monitor.azure.com/;ApplicationId=00000000-0000-0000-0000-000000000000", - }, - { jsonPath: "properties.credentials.key", value: replaceableVariables.API_KEY }, - ], - }, - removeCentralSanitizers: ["AZSDK3430", "AZSDK3493"], -}; - -/** - * creates the recorder and reads the environment variables from the `.env` file. - * Should be called first in the test suite to make sure environment variables are - * read before they are being used. - */ -export async function createRecorder(context: VitestTestContext): Promise { - const recorder = new Recorder(context); - await recorder.start(recorderEnvSetup); - return recorder; -} - -export function createProjectsClient( - recorder?: Recorder, - options?: ClientOptions, -): AIProjectsClient { - const credential = createTestCredential(); - const connectionString = process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - return AIProjectsClient.fromConnectionString( - connectionString, - credential, - recorder ? recorder.configureClientOptions(options ?? {}) : options, - ); -} - -export function createMockProjectsClient( - responseFn: (request: PipelineRequest) => Partial, -): AIProjectsClient { - const options: ClientOptions = { additionalPolicies: [] }; - options.additionalPolicies?.push({ - policy: { - name: "RequestMockPolicy", - sendRequest: async (req) => { - const response = responseFn(req); - return { - headers: createHttpHeaders(), - status: 200, - request: req, - ...response, - } as PipelineResponse; - }, - }, - position: "perCall", - }); - const credential = createTestCredential(); - const connectionString = process.env["AZURE_AI_PROJECTS_CONNECTION_STRING"] || ""; - return AIProjectsClient.fromConnectionString(connectionString, credential, options); -} diff --git a/sdk/ai/ai-projects/test/public/utils/env.ts b/sdk/ai/ai-projects/test/public/utils/env.ts deleted file mode 100644 index 866412f4082d..000000000000 --- a/sdk/ai/ai-projects/test/public/utils/env.ts +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import * as dotenv from "dotenv"; - -dotenv.config(); diff --git a/sdk/ai/ai-projects/test/public/utils/recordedClient.ts b/sdk/ai/ai-projects/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..6e425fdcfdf9 --- /dev/null +++ b/sdk/ai/ai-projects/test/public/utils/recordedClient.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Recorder, + RecorderStartOptions, + VitestTestContext, +} from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder( + context: VitestTestContext, +): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/ai/ai-projects/test/snippets.spec.ts b/sdk/ai/ai-projects/test/snippets.spec.ts deleted file mode 100644 index 34432fceb747..000000000000 --- a/sdk/ai/ai-projects/test/snippets.spec.ts +++ /dev/null @@ -1,685 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import type { VitestTestContext } from "@azure-tools/test-recorder"; -import { - AIProjectsClient, - ToolSet, - ToolUtility, - connectionToolType, - FunctionToolDefinition, - RequiredToolCallOutput, - FunctionToolDefinitionOutput, - ToolOutput, - DoneEvent, - MessageDeltaChunk, - MessageDeltaTextContent, - MessageStreamEvent, - RunStreamEvent, - ThreadRunOutput, - MessageContentOutput, - isOutputOfType, - MessageTextContentOutput, - MessageImageFileContentOutput, -} from "@azure/ai-projects"; -import { createProjectsClient } from "./public/utils/createClient.js"; -import { DefaultAzureCredential } from "@azure/identity"; -import { beforeEach, it, describe } from "vitest"; -import * as fs from "fs"; -import { delay } from "@azure/core-util"; -import { trace } from "@opentelemetry/api"; -import { AzureMonitorTraceExporter } from "@azure/monitor-opentelemetry-exporter"; -import { - ConsoleSpanExporter, - NodeTracerProvider, - SimpleSpanProcessor, -} from "@opentelemetry/sdk-trace-node"; -import { RestError } from "@azure/core-rest-pipeline"; - -describe("snippets", function () { - let client: AIProjectsClient; - - beforeEach(async function (context: VitestTestContext) { - client = createProjectsClient(); - }); - - it("setup", async function () { - const connectionString = - process.env.AZURE_AI_PROJECTS_CONNECTION_STRING ?? ""; - const client = AIProjectsClient.fromConnectionString( - connectionString, - new DefaultAzureCredential(), - ); - }); - - it("listConnections", async function () { - const connections = await client.connections.listConnections(); - for (const connection of connections) { - console.log(connection); - } - }); - - it("filterConnections", async function () { - const connections = await client.connections.listConnections({ category: "AzureOpenAI" }); - for (const connection of connections) { - console.log(connection); - } - }); - - it("getConnection", async function () { - const connection = await client.connections.getConnection("connectionName"); - console.log(connection); - }); - - it("getConnectionWithSecrets", async function () { - const connection = await client.connections.getConnectionWithSecrets("connectionName"); - console.log(connection); - }); - - it("createAgent", async function () { - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful assistant", - }); - }); - - it("toolSet", async function () { - const toolSet = new ToolSet(); - toolSet.addFileSearchTool([vectorStore.id]); - toolSet.addCodeInterpreterTool([codeInterpreterFile.id]); - - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: toolSet.toolDefinitions, - toolResources: toolSet.toolResources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - }); - - it("fileSearch", async function () { - const localFileStream = fs.createReadStream(filePath); - const file = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "sample_file_for_upload.txt", - }); - console.log(`Uploaded file, ID: ${file.id}`); - - const vectorStore = await client.agents.createVectorStore({ - fileIds: [file.id], - name: "my_vector_store", - }); - console.log(`Created vector store, ID: ${vectorStore.id}`); - - const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]); - - const agent = await client.agents.createAgent("gpt-4o", { - name: "SDK Test Agent - Retrieval", - instructions: "You are helpful agent that can help fetch data from files you know about.", - tools: [fileSearchTool.definition], - toolResources: fileSearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - }); - - it("codeInterpreter", async function () { - const localFileStream = fs.createReadStream(filePath); - const localFile = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "localFile", - }); - console.log(`Uploaded local file, file ID : ${localFile.id}`); - - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool([localFile.id]); - - // Notice that CodeInterpreter must be enabled in the agent creation, otherwise the agent will not be able to see the file attachment - const agent = await client.agents.createAgent("gpt-4o-mini", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [codeInterpreterTool.definition], - toolResources: codeInterpreterTool.resources, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - }); - - it("bingGrounding", async function () { - const bingConnection = await client.connections.getConnection( - process.env.BING_CONNECTION_NAME ?? "", - ); - const connectionId = bingConnection.id; - - const bingTool = ToolUtility.createConnectionTool(connectionToolType.BingGrounding, [ - connectionId, - ]); - - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [bingTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - }); - - it("AISearch", async function () { - const connectionName = - process.env.AZURE_AI_SEARCH_CONNECTION_NAME ?? ""; - const connection = await client.connections.getConnection(connectionName); - - const azureAISearchTool = ToolUtility.createAzureAISearchTool(connection.id, connection.name); - - const agent = await client.agents.createAgent("gpt-4-0125-preview", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [azureAISearchTool.definition], - toolResources: azureAISearchTool.resources, - }); - console.log(`Created agent, agent ID : ${agent.id}`); - }); - - it("functionTools", async function () { - class FunctionToolExecutor { - private functionTools: { func: Function; definition: FunctionToolDefinition }[]; - - constructor() { - this.functionTools = [ - { - func: this.getUserFavoriteCity, - ...ToolUtility.createFunctionTool({ - name: "getUserFavoriteCity", - description: "Gets the user's favorite city.", - parameters: {}, - }), - }, - { - func: this.getCityNickname, - ...ToolUtility.createFunctionTool({ - name: "getCityNickname", - description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - }, - }, - }), - }, - { - func: this.getWeather, - ...ToolUtility.createFunctionTool({ - name: "getWeather", - description: "Gets the weather for a location.", - parameters: { - type: "object", - properties: { - location: { type: "string", description: "The city and state, e.g. Seattle, Wa" }, - unit: { type: "string", enum: ["c", "f"] }, - }, - }, - }), - }, - ]; - } - - private getUserFavoriteCity(): {} { - return { location: "Seattle, WA" }; - } - - private getCityNickname(location: string): {} { - return { nickname: "The Emerald City" }; - } - - private getWeather(location: string, unit: string): {} { - return { weather: unit === "f" ? "72f" : "22c" }; - } - - public invokeTool( - toolCall: RequiredToolCallOutput & FunctionToolDefinitionOutput, - ): ToolOutput | undefined { - console.log(`Function tool call - ${toolCall.function.name}`); - const args = []; - if (toolCall.function.parameters) { - try { - const params = JSON.parse(toolCall.function.parameters); - for (const key in params) { - if (Object.prototype.hasOwnProperty.call(params, key)) { - args.push(params[key]); - } - } - } catch (error) { - console.error(`Failed to parse parameters: ${toolCall.function.parameters}`, error); - return undefined; - } - } - const result = this.functionTools - .find((tool) => tool.definition.function.name === toolCall.function.name) - ?.func(...args); - return result - ? { - toolCallId: toolCall.id, - output: JSON.stringify(result), - } - : undefined; - } - - public getFunctionDefinitions(): FunctionToolDefinition[] { - return this.functionTools.map((tool) => { - return tool.definition; - }); - } - } - - const functionToolExecutor = new FunctionToolExecutor(); - const functionTools = functionToolExecutor.getFunctionDefinitions(); - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: - "You are a weather bot. Use the provided functions to help answer questions. Customize your responses to the user's preferences as much as possible and use friendly nicknames for cities whenever possible.", - tools: functionTools, - }); - console.log(`Created agent, agent ID: ${agent.id}`); - }); - - it("createAgentWithOpenApi", async function () { - // Read in OpenApi spec - const filePath = "./data/weatherOpenApi.json"; - const openApiSpec = JSON.parse(fs.readFileSync(filePath, "utf-8")); - - // Define OpenApi function - const openApiFunction = { - name: "getWeather", - spec: openApiSpec, - description: "Retrieve weather information for a location", - auth: { - type: "anonymous", - }, - default_params: ["format"], // optional - }; - - // Create OpenApi tool - const openApiTool = ToolUtility.createOpenApiTool(openApiFunction); - - // Create agent with OpenApi tool - const agent = await client.agents.createAgent("gpt-4o-mini", { - name: "myAgent", - instructions: "You are a helpful agent", - tools: [openApiTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - }); - - it("createAgentWithFabric", async function () { - const fabricConnection = await client.connections.getConnection( - process.env["FABRIC_CONNECTION_NAME"] || "", - ); - - const connectionId = fabricConnection.id; - - // Initialize agent Microsoft Fabric tool with the connection id - const fabricTool = ToolUtility.createFabricTool(connectionId); - - // Create agent with the Microsoft Fabric tool and process assistant run - const agent = await client.agents.createAgent("gpt-4o", { - name: "my-agent", - instructions: "You are a helpful agent", - tools: [fabricTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - }); - - it("createThread", async function () { - const thread = await client.agents.createThread(); - }); - - it("threadWithTool", async function () { - const localFileStream = fs.createReadStream(filePath); - const file = await client.agents.uploadFile(localFileStream, "assistants", { - fileName: "sample_file_for_upload.csv", - }); - console.log(`Uploaded file, ID: ${file.id}`); - - const vectorStore = await client.agents.createVectorStore({ - fileIds: [file.id], - }); - console.log(`Created vector store, ID: ${vectorStore.id}`); - - const fileSearchTool = ToolUtility.createFileSearchTool([vectorStore.id]); - - const agent = await client.agents.createAgent("gpt-4o", { - name: "myAgent", - instructions: "You are helpful agent that can help fetch data from files you know about.", - tools: [fileSearchTool.definition], - }); - console.log(`Created agent, agent ID : ${agent.id}`); - - // Create thread with file resources. - // If the agent has multiple threads, only this thread can search this file. - const thread = await client.agents.createThread({ toolResources: fileSearchTool.resources }); - }); - - it("listThreads", async function () { - const threads = await client.agents.listThreads(); - console.log(`Threads for agent ${agent.id}:`); - for await (const t of (await threads).data) { - console.log(`Thread ID: ${t.id}`); - console.log(`Created at: ${t.createdAt}`); - console.log(`Metadata: ${t.metadata}`); - console.log(`---- `); - } - }); - - it("createMessage", async function () { - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "hello, world!", - }); - console.log(`Created message, message ID: ${message.id}`); - }); - - it("messageWithFileSearch", async function () { - const fileSearchTool = ToolUtility.createFileSearchTool(); - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: "What feature does Smart Eyewear offer?", - attachments: { - fileId: file.id, - tools: [fileSearchTool.definition], - }, - }); - }); - - it("messageWithCodeInterpreter", async function () { - // notice that CodeInterpreter must be enabled in the agent creation, - // otherwise the agent will not be able to see the file attachment for code interpretation - const codeInterpreterTool = ToolUtility.createCodeInterpreterTool(); - const agent = await client.agents.createAgent("gpt-4-1106-preview", { - name: "my-assistant", - instructions: "You are helpful assistant", - tools: [codeInterpreterTool.definition], - }); - console.log(`Created agent, agent ID: ${agent.id}`); - - const thread = await client.agents.createThread(); - console.log(`Created thread, thread ID: ${thread.id}`); - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: - "Could you please create bar chart in TRANSPORTATION sector for the operating profit from the uploaded csv file and provide file to me?", - attachments: { - fileId: file.id, - tools: [codeInterpreterTool.definition], - }, - }); - console.log(`Created message, message ID: ${message.id}`); - }); - - it("imageInputWithFile", async function () { - // Upload the local image file - const fileStream = fs.createReadStream(imagePath); - const imageFile = await client.agents.uploadFile(fileStream, "assistants", { - fileName: "image_file.png", - }); - console.log(`Uploaded file, file ID: ${imageFile.id}`); - - // Create a message with both text and image content - console.log("Creating message with image content..."); - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_file", - image_file: { - file_id: imageFile.id, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - }); - - it("imageInputWithUrl", async function () { - // Specify the public image URL - const imageUrl = - "https://github.com/Azure/azure-sdk-for-js/blob/0aa88ceb18d865726d423f73b8393134e783aea6/sdk/ai/ai-projects/data/image_file.png?raw=true"; - - // Create content directly referencing image URL - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageUrl, - detail: "high", - }, - }, - ]; - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - }); - - it("imageInputWithBase64", async function () { - function imageToBase64DataUrl(imagePath: string, mimeType: string): string { - try { - // Read the image file as binary - const imageBuffer = fs.readFileSync(imagePath); - // Convert to base64 - const base64Data = imageBuffer.toString("base64"); - // Format as a data URL - return `data:${mimeType};base64,${base64Data}`; - } catch (error) { - console.error(`Error reading image file at ${imagePath}:`, error); - throw error; - } - } - - // Convert your image file to base64 format - const imageDataUrl = imageToBase64DataUrl(filePath, "image/png"); - - // Create a message with both text and image content - const inputMessage = "Hello, what is in the image?"; - const content = [ - { - type: "text", - text: inputMessage, - }, - { - type: "image_url", - image_url: { - url: imageDataUrl, - detail: "high", - }, - }, - ]; - - const message = await client.agents.createMessage(thread.id, { - role: "user", - content: content, - }); - console.log(`Created message, message ID: ${message.id}`); - }); - it("createRun", async function () { - let run = await client.agents.createRun(thread.id, agent.id); - - // Poll the run as long as run status is queued or in progress - while ( - run.status === "queued" || - run.status === "in_progress" || - run.status === "requires_action" - ) { - // Wait for a second - await new Promise((resolve) => setTimeout(resolve, 1000)); - run = await client.agents.getRun(thread.id, run.id); - } - }); - - it("createThreadAndRun", async function () { - const run = await client.agents.createThreadAndRun(agent.id, { - thread: { - messages: [ - { - role: "user", - content: "hello, world!", - }, - ], - }, - }); - }); - - it("createRunStream", async function () { - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - }); - - it("eventHandling", async function () { - const streamEventMessages = await client.agents.createRun(thread.id, agent.id).stream(); - for await (const eventMessage of streamEventMessages) { - switch (eventMessage.event) { - case RunStreamEvent.ThreadRunCreated: - console.log(`ThreadRun status: ${(eventMessage.data as ThreadRunOutput).status}`); - break; - case MessageStreamEvent.ThreadMessageDelta: - { - const messageDelta = eventMessage.data as MessageDeltaChunk; - messageDelta.delta.content.forEach((contentPart) => { - if (contentPart.type === "text") { - const textContent = contentPart as MessageDeltaTextContent; - const textValue = textContent.text?.value || "No text"; - console.log(`Text delta received:: ${textValue}`); - } - }); - } - break; - - case RunStreamEvent.ThreadRunCompleted: - console.log("Thread Run Completed"); - break; - case ErrorEvent.Error: - console.log(`An error occurred. Data ${eventMessage.data}`); - break; - case DoneEvent.Done: - console.log("Stream completed."); - break; - } - } - }); - - it("listMessages", async function () { - const messages = await client.agents.listMessages(thread.id); - while (messages.hasMore) { - const nextMessages = await client.agents.listMessages(currentRun.threadId, { - after: messages.lastId, - }); - messages.data = messages.data.concat(nextMessages.data); - messages.hasMore = nextMessages.hasMore; - messages.lastId = nextMessages.lastId; - } - - // The messages are following in the reverse order, - // we will iterate them and output only text contents. - for (const dataPoint of messages.data.reverse()) { - const lastMessageContent: MessageContentOutput = - dataPoint.content[dataPoint.content.length - 1]; - console.log(lastMessageContent); - if (isOutputOfType(lastMessageContent, "text")) { - console.log( - `${dataPoint.role}: ${(lastMessageContent as MessageTextContentOutput).text.value}`, - ); - } - } - }); - - it("retrieveFile", async function () { - const messages = await client.agents.listMessages(thread.id); - - // Get most recent message from the assistant - const assistantMessage = messages.data.find((msg) => msg.role === "assistant"); - if (assistantMessage) { - const textContent = assistantMessage.content.find((content) => - isOutputOfType(content, "text"), - ) as MessageTextContentOutput; - if (textContent) { - console.log(`Last message: ${textContent.text.value}`); - } - } - - const imageFile = (messages.data[0].content[0] as MessageImageFileContentOutput).imageFile; - const imageFileName = (await client.agents.getFile(imageFile.fileId)).filename; - - const fileContent = await ( - await client.agents.getFileContent(imageFile.fileId).asNodeStream() - ).body; - if (fileContent) { - const chunks: Buffer[] = []; - for await (const chunk of fileContent) { - chunks.push(Buffer.from(chunk)); - } - const buffer = Buffer.concat(chunks); - fs.writeFileSync(imageFileName, buffer); - } else { - console.error("Failed to retrieve file content: fileContent is undefined"); - } - console.log(`Saved image file to: ${imageFileName}`); - }); - - it("teardown", async function () { - await client.agents.deleteVectorStore(vectorStore.id); - console.log(`Deleted vector store, vector store ID: ${vectorStore.id}`); - - await client.agents.deleteFile(file.id); - console.log(`Deleted file, file ID: ${file.id}`); - - client.agents.deleteAgent(agent.id); - console.log(`Deleted agent, agent ID: ${agent.id}`); - }); - - it("tracing", async function () { - const provider = new NodeTracerProvider(); - provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter())); - provider.register(); - - const tracer = trace.getTracer("Agents Sample", "1.0.0"); - - let appInsightsConnectionString = - process.env.APP_INSIGHTS_CONNECTION_STRING ?? ""; - - if (appInsightsConnectionString == "") { - appInsightsConnectionString = await client.telemetry.getConnectionString(); - } - - if (appInsightsConnectionString) { - const exporter = new AzureMonitorTraceExporter({ - connectionString: appInsightsConnectionString, - }); - provider.addSpanProcessor(new SimpleSpanProcessor(exporter)); - } - - await tracer.startActiveSpan("main", async (span) => { - client.telemetry.updateSettings({ enableContentRecording: true }); - // ... - }); - }); - - it("exceptions", async function () { - try { - const result = await client.connections.listConnections(); - } catch (e) { - if (e instanceof RestError) { - console.log(`Status code: ${e.code}`); - console.log(e.message); - } else { - console.error(e); - } - } - }); -}); diff --git a/sdk/ai/ai-projects/tsconfig.browser.config.json b/sdk/ai/ai-projects/tsconfig.browser.config.json deleted file mode 100644 index 75871518e3a0..000000000000 --- a/sdk/ai/ai-projects/tsconfig.browser.config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"] -} diff --git a/sdk/ai/ai-projects/tsconfig.json b/sdk/ai/ai-projects/tsconfig.json deleted file mode 100644 index 273d9078a24a..000000000000 --- a/sdk/ai/ai-projects/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "references": [ - { "path": "./tsconfig.src.json" }, - { "path": "./tsconfig.samples.json" }, - { "path": "./tsconfig.test.json" } - ] -} diff --git a/sdk/ai/ai-projects/tsconfig.samples.json b/sdk/ai/ai-projects/tsconfig.samples.json deleted file mode 100644 index 2d4719a40861..000000000000 --- a/sdk/ai/ai-projects/tsconfig.samples.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../../tsconfig.samples.base.json", - "compilerOptions": { - "paths": { - "@azure-rest/ai-projects": ["./dist/esm"] - } - } -} diff --git a/sdk/ai/ai-projects/tsconfig.src.json b/sdk/ai/ai-projects/tsconfig.src.json deleted file mode 100644 index a244b17dbda6..000000000000 --- a/sdk/ai/ai-projects/tsconfig.src.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../../../tsconfig.lib.json", - "compilerOptions": { - "skipLibCheck": true - } -} diff --git a/sdk/ai/ai-projects/tsconfig.test.json b/sdk/ai/ai-projects/tsconfig.test.json deleted file mode 100644 index c3b436a98976..000000000000 --- a/sdk/ai/ai-projects/tsconfig.test.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"], - "compilerOptions": { - "skipLibCheck": true - } -} diff --git a/sdk/ai/ai-projects/tsp-location.yaml b/sdk/ai/ai-projects/tsp-location.yaml index 95a2db669486..4f85de27c9dd 100644 --- a/sdk/ai/ai-projects/tsp-location.yaml +++ b/sdk/ai/ai-projects/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/ai/Azure.AI.Projects -commit: 66f3f5a1184215abf25d93f185b55dfbc75b0050 -repo: Azure/azure-rest-api-specs +commit: 53cb7424a2a6e6f3e77e707c30bddce3334307f7 +repo: ../azure-rest-api-specs additionalDirectories: diff --git a/sdk/ai/ai-projects/vitest.browser.config.ts b/sdk/ai/ai-projects/vitest.browser.config.ts deleted file mode 100644 index 542aefc53980..000000000000 --- a/sdk/ai/ai-projects/vitest.browser.config.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { defineConfig, mergeConfig } from "vitest/config"; -import viteConfig from "../../../vitest.browser.shared.config.ts"; - -export default mergeConfig( - viteConfig, - defineConfig({ - test: { - testTimeout: 1200000, - hookTimeout: 1200000, - include: [ - "dist-test/browser/**/**/*.spec.js", - ], - }, - }), -); diff --git a/sdk/ai/ai-projects/vitest.config.ts b/sdk/ai/ai-projects/vitest.config.ts deleted file mode 100644 index 4f63c6363819..000000000000 --- a/sdk/ai/ai-projects/vitest.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { defineConfig, mergeConfig } from "vitest/config"; -import viteConfig from "../../../vitest.shared.config.ts"; - -export default mergeConfig( - viteConfig, - defineConfig({ - test: { - testTimeout: 1200000, - hookTimeout: 1200000, - }, - }) -); diff --git a/sdk/ai/ai-projects/vitest.esm.config.ts b/sdk/ai/ai-projects/vitest.esm.config.ts deleted file mode 100644 index 2f6e757a54f7..000000000000 --- a/sdk/ai/ai-projects/vitest.esm.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -import { mergeConfig } from "vitest/config"; -import vitestConfig from "./vitest.config.ts"; -import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; - -export default mergeConfig( - vitestConfig, - vitestEsmConfig -);