Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
"Esto",
"etag",
"euap",
"evals",
"eventhub",
"eventhubs",
"failondeprecatedstatus",
Expand Down
84 changes: 79 additions & 5 deletions sdk/ai/azure-ai-projects/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# Azure Projects client library for Java

Azure Projects client library for Java.
The AI Projects client library is part of the Azure AI Foundry SDK and provides easy access to resources in your Azure AI Foundry Project. Use it to:

This package contains Microsoft Azure Projects client library.
* **Create and run Agents** using the separate package `com.azure.azure-ai-agents`.
* **Enumerate AI Models** deployed to your Foundry Project using the `Deployments` operations.
* **Enumerate connected Azure resources** in your Foundry project using the `Connections` operations.
* **Upload documents and create Datasets** to reference them using the `Datasets` operations.
* **Create and enumerate Search Indexes** using the `Indexes` operations.

The client library uses version `v1` of the AI Foundry [data plane REST APIs](https://aka.ms/azsdk/azure-ai-projects/ga-rest-api-reference).

## Documentation

Expand Down Expand Up @@ -36,9 +42,74 @@ Various documentation is available to help you get started

## Key concepts

The Azure AI Foundry provides a centralized spot to manage your AI Foundry resources. In order to access each feature you need to initialize your builder and access the corresponding sub-client like it's shown in the following code snippet:

```java com.azure.ai.projects.clientInitialization
AIProjectClientBuilder builder = new AIProjectClientBuilder();

ConnectionsClient connectionsClient = builder.buildConnectionsClient();
DatasetsClient datasetsClient = builder.buildDatasetsClient();
DeploymentsClient deploymentsClient = builder.buildDeploymentsClient();
EvaluationRulesClient evaluationRulesClient = builder.buildEvaluationRulesClient();
EvaluationsClient evaluationsClient = builder.buildEvaluationsClient();
EvaluationTaxonomiesClient evaluationTaxonomiesClient = builder.buildEvaluationTaxonomiesClient();
EvaluatorsClient evaluatorsClient = builder.buildEvaluatorsClient();
IndexesClient indexesClient = builder.buildIndexesClient();
InsightsClient insightsClient = builder.buildInsightsClient();
RedTeamsClient redTeamsClient = builder.buildRedTeamsClient();
SchedulesClient schedulesClient = builder.buildSchedulesClient();
```

In the particular case of the `EvaluationsClient`, this client library exposes [OpenAI's official SDK][openai_java_sdk] directly, so you can use the [official OpenAI docs][openai_api_docs] to access this feature.

```java com.azure.ai.projects.evaluationsClientInit
EvalService evalService = evaluationsClient.getOpenAIClient();
```

## Examples

```java com.azure.ai.projects.readme
### Connections operations

The code below shows some Connection operations, which allow you to enumerate the Azure Resources connected to your AI Foundry Projects. These connections can be seen in the "Management Center", in the "Connected resources" tab in your AI Foundry Project. For more samples see the [package samples][package_samples].

```java com.azure.ai.projects.ConnectionsSample.listConnections
PagedIterable<Connection> connections = connectionsClient.listConnections();
for (Connection connection : connections) {
System.out.println("Connection name: " + connection.getName());
System.out.println("Connection type: " + connection.getType());
System.out.println("Connection credential type: " + connection.getCredentials().getType());
System.out.println("-------------------------------------------------");
}
```

### Indexes

The code below shows some Indexes operations to list and create indexes. For more samples see the [package samples][package_samples].

```java com.azure.ai.projects.IndexesListSample.listIndexes
indexesClient.listLatest().forEach(index -> {
System.out.println("Index name: " + index.getName());
System.out.println("Index version: " + index.getVersion());
System.out.println("Index description: " + index.getDescription());
System.out.println("-------------------------------------------------");
});
```

```java com.azure.ai.projects.IndexesGetSample.createOrUpdateIndex
String indexName = Configuration.getGlobalConfiguration().get("INDEX_NAME", "my-index");
String indexVersion = Configuration.getGlobalConfiguration().get("INDEX_VERSION", "2.0");
String aiSearchConnectionName = Configuration.getGlobalConfiguration().get("AI_SEARCH_CONNECTION_NAME", "");
String aiSearchIndexName = Configuration.getGlobalConfiguration().get("AI_SEARCH_INDEX_NAME", "");

Index index = indexesClient.createOrUpdate(
indexName,
indexVersion,
new AzureAISearchIndex()
.setConnectionName(aiSearchConnectionName)
.setIndexName(aiSearchIndexName)
);

System.out.println("Index created: " + index.getName());
```

### Service API versions
Expand Down Expand Up @@ -71,8 +142,11 @@ For details on contributing to this repository, see the [contributing guide](htt
1. Create new Pull Request

<!-- LINKS -->
[product_documentation]: https://azure.microsoft.com/services/
[docs]: https://azure.github.io/azure-sdk-for-java/
[product_documentation]: https://learn.microsoft.com/azure/ai-studio/
[docs]: https://learn.microsoft.com/rest/api/aifoundry/aiprojects/
[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/
[azure_subscription]: https://azure.microsoft.com/free/
[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity
[package_samples]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/ai/azure-ai-projects/src/samples/java/com/azure/ai/projects
[openai_java_sdk]: https://github.com/openai/openai-java
[openai_api_docs]: https://platform.openai.com/docs/overview
10 changes: 5 additions & 5 deletions sdk/ai/azure-ai-projects/_tsp-location.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
directory: specification/ai/Azure.AI.Projects/
commit: ff0bb49f83506566af01d38027029cd05469ab6a
repo: Azure/azure-rest-api-specs
additionalDirectories: []

directory: specification/ai/Azure.AI.Projects.java
commit: 78bfd335c31b8764578cfb9840f3b74349c10354
repo: Azure/azure-rest-api-specs-pr
additionalDirectories:
- specification/ai/Azure.AI.Projects
7 changes: 3 additions & 4 deletions sdk/ai/azure-ai-projects/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<!-- This file is generated by the /eng/scripts/linting_suppression_generator.py script. -->

<suppressions>
<suppress files="com.azure.ai.projects.AIProjectClientBuilder.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ExternalDependencyExposedCheck" />
<suppress files="com.azure.ai.projects.InferenceAsyncClient.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ExternalDependencyExposedCheck" />
<suppress files="com.azure.ai.projects.InferenceClient.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ExternalDependencyExposedCheck" />
</suppressions>
<suppress files="com.azure.ai.projects.EvaluationsClient.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ExternalDependencyExposedCheck" />
<suppress files="com.azure.ai.projects.EvaluationsAsyncClient.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ExternalDependencyExposedCheck" />
</suppressions>
18 changes: 18 additions & 0 deletions sdk/ai/azure-ai-projects/customizations/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.azure</groupId>
<artifactId>azure-code-customization-parent</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-code-customization-parent;current} -->
<relativePath>../../../parents/azure-code-customization-parent</relativePath>
</parent>

<groupId>com.azure.tools</groupId>
<artifactId>azure-ai-projects-customizations</artifactId>
<version>1.2.0-beta.1</version>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import com.azure.autorest.customization.Customization;
import com.azure.autorest.customization.LibraryCustomization;
import org.slf4j.Logger;


/**
* This class contains the customization code to customize the AutoRest generated code for the Agents Client library
*/
public class ProjectsCustomizations extends Customization {

@Override
public void customize(LibraryCustomization libraryCustomization, Logger logger) {
// removeConversationsClientBuilder(libraryCustomization, logger);
}

private void removeConversationsClientBuilder(LibraryCustomization customization, Logger logger) {
logger.info("Removing ConversationsClientBuilder class");
customization.getRawEditor().removeFile("src/main/java/com/azure/ai/agents/ConversationsClientBuilder.java");
}
}
24 changes: 13 additions & 11 deletions sdk/ai/azure-ai-projects/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ Code generated by Microsoft (R) TypeSpec Code Generator.
<name>Microsoft</name>
</developer>
</developers>


<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<jacoco.min.linecoverage>0.15</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.10</jacoco.min.branchcoverage>
<jacoco.min.linecoverage>0.0</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.0</jacoco.min.branchcoverage>
<javaModulesSurefireArgLine>
--add-exports com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
--add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
Expand All @@ -67,11 +69,11 @@ Code generated by Microsoft (R) TypeSpec Code Generator.
<artifactId>azure-storage-blob</artifactId>
<version>12.32.0</version> <!-- {x-version-update;com.azure:azure-storage-blob;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-ai-agents-persistent</artifactId>
<version>1.0.0-beta.3</version> <!-- {x-version-update;com.azure:azure-ai-agents-persistent;current} -->
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.azure</groupId>-->
<!-- <artifactId>azure-ai-agents-persistent</artifactId>-->
<!-- <version>1.0.0-beta.3</version> &lt;!&ndash; {x-version-update;com.azure:azure-ai-agents-persistent;current} &ndash;&gt;-->
<!-- </dependency>-->
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
Expand All @@ -82,14 +84,14 @@ Code generated by Microsoft (R) TypeSpec Code Generator.

<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-test</artifactId>
<version>1.27.0-beta.13</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<artifactId>azure-identity</artifactId>
<version>1.18.1</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.18.1</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
<artifactId>azure-core-test</artifactId>
<version>1.27.0-beta.13</version> <!-- {x-version-update;com.azure:azure-core-test;dependency} -->
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Loading