Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion eng/versioning/external_dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ com.microsoft.sqlserver:mssql-jdbc;10.2.3.jre8
com.microsoft.azure:azure-functions-maven-plugin;1.30.0
com.microsoft.azure.functions:azure-functions-java-library;2.2.0
com.mysql:mysql-connector-j;9.0.0
com.openai:openai-java;4.6.1
com.openai:openai-java;4.14.0
com.squareup.okhttp3:okhttp;4.12.0
commons-codec:commons-codec;1.15
commons-net:commons-net;3.9.0
Expand Down
3 changes: 3 additions & 0 deletions sdk/ai/azure-ai-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- New `MemorySearchAgent` sample was added demonstrating memory search functionality
- Tests for `MemoryStoresClient` and `MemoryStoresAsyncClient`
- Various documentation updates
- Using unified `HttpClient` setup for Azure specifics and `openai` client library wrapping methods

### Breaking Changes

Expand All @@ -16,6 +17,8 @@

### Other Changes

- Updated version of `openai` client library to `4.14.0`

## 1.0.0-beta.1 (2025-11-12)

### Features Added
Expand Down
4 changes: 2 additions & 2 deletions sdk/ai/azure-ai-agents/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>4.6.1</version> <!-- {x-version-update;com.openai:openai-java;external_dependency} -->
<version>4.14.0</version> <!-- {x-version-update;com.openai:openai-java;external_dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
Expand Down Expand Up @@ -97,7 +97,7 @@
<rules>
<bannedDependencies>
<includes>
<include>com.openai:openai-java:[4.6.1]</include> <!-- {x-include-update;com.openai:openai-java;external_dependency} -->
<include>com.openai:openai-java:[4.14.0]</include> <!-- {x-include-update;com.openai:openai-java;external_dependency} -->
</includes>
</bannedDependencies>
<requireReleaseDeps>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
import com.openai.errors.UnauthorizedException;
import com.openai.errors.UnexpectedStatusCodeException;
import com.openai.errors.UnprocessableEntityException;
import reactor.core.publisher.Mono;

import java.io.ByteArrayOutputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -82,10 +85,14 @@ public HttpResponse execute(HttpRequest request, RequestOptions requestOptions)
Objects.requireNonNull(request, "request");
Objects.requireNonNull(requestOptions, "requestOptions");

com.azure.core.http.HttpRequest azureRequest = buildAzureRequest(request);

return new AzureHttpResponseAdapter(
this.httpPipeline.sendSync(azureRequest, buildRequestContext(requestOptions)));
try {
com.azure.core.http.HttpRequest azureRequest = buildAzureRequest(request);
return new AzureHttpResponseAdapter(
this.httpPipeline.sendSync(azureRequest, buildRequestContext(requestOptions)));
} catch (MalformedURLException exception) {
throw new OpenAIException("Invalid URL in request: " + exception.getMessage(),
LOGGER.logThrowableAsError(exception));
}
}

@Override
Expand All @@ -98,9 +105,8 @@ public CompletableFuture<HttpResponse> executeAsync(HttpRequest request, Request
Objects.requireNonNull(request, "request");
Objects.requireNonNull(requestOptions, "requestOptions");

final com.azure.core.http.HttpRequest azureRequest = buildAzureRequest(request);

return this.httpPipeline.send(azureRequest, buildRequestContext(requestOptions))
return Mono.fromCallable(() -> buildAzureRequest(request))
.flatMap(azureRequest -> this.httpPipeline.send(azureRequest, buildRequestContext(requestOptions)))
.map(response -> (HttpResponse) new AzureHttpResponseAdapter(response))
.onErrorMap(HttpClientWrapper::mapAzureExceptionToOpenAI)
.toFuture();
Expand Down Expand Up @@ -163,7 +169,7 @@ private static Throwable mapAzureExceptionToOpenAI(Throwable throwable) {
} else if (throwable instanceof TimeoutException) {
return throwable;
} else {
return new OpenAIException(throwable.getMessage(), throwable.getCause());
return new OpenAIException(throwable.getMessage(), throwable);
}
}

Expand All @@ -179,7 +185,8 @@ private static Headers toOpenAIHeaders(HttpHeaders azureHeaders) {
/**
* Converts the OpenAI request metadata and body into an Azure {@link com.azure.core.http.HttpRequest}.
*/
private static com.azure.core.http.HttpRequest buildAzureRequest(HttpRequest request) {
private static com.azure.core.http.HttpRequest buildAzureRequest(HttpRequest request)
throws MalformedURLException {
HttpRequestBody requestBody = request.body();
String contentType = requestBody != null ? requestBody.contentType() : null;
BinaryData bodyData = null;
Expand All @@ -196,7 +203,7 @@ private static com.azure.core.http.HttpRequest buildAzureRequest(HttpRequest req
}

com.azure.core.http.HttpRequest azureRequest = new com.azure.core.http.HttpRequest(
HttpMethod.valueOf(request.method().name()), OpenAiRequestUrlBuilder.buildUrl(request), headers);
HttpMethod.valueOf(request.method().name()), URI.create(request.url()).toURL(), headers);

if (bodyData != null) {
azureRequest.setBody(bodyData);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
package com.azure.ai.agents.implementation.http;

import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.HttpHeaders;
import com.azure.core.http.HttpMethod;
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
Expand All @@ -27,7 +25,6 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand All @@ -36,39 +33,6 @@

class HttpClientHelperTests {

private static final HttpHeaderName REQUEST_ID_HEADER = HttpHeaderName.fromString("x-request-id");
private static final HttpHeaderName CUSTOM_HEADER_NAME = HttpHeaderName.fromString("custom-header");
private static final HttpHeaderName X_TEST_HEADER = HttpHeaderName.fromString("X-Test");
private static final HttpHeaderName X_MULTI_HEADER = HttpHeaderName.fromString("X-Multi");

@Test
void executeMapsRequestAndResponse() {
RecordingHttpClient recordingClient = new RecordingHttpClient(request -> createMockResponse(request, 201,
new HttpHeaders().set(REQUEST_ID_HEADER, "req-123").set(CUSTOM_HEADER_NAME, "custom-value"), "pong"));
com.openai.core.http.HttpClient openAiClient
= HttpClientHelper.mapToOpenAIHttpClient(new HttpPipelineBuilder().httpClient(recordingClient).build());

com.openai.core.http.HttpRequest openAiRequest = createOpenAiRequest();

try (com.openai.core.http.HttpResponse response = openAiClient.execute(openAiRequest)) {
HttpRequest sentRequest = recordingClient.getLastRequest();
assertNotNull(sentRequest, "Azure HttpClient should receive a request");
assertEquals(HttpMethod.POST, sentRequest.getHttpMethod());
assertEquals("https://example.com/path/segment?q=a%20b", sentRequest.getUrl().toString());
assertEquals("alpha", sentRequest.getHeaders().getValue(X_TEST_HEADER));
assertArrayEquals(new String[] { "first", "second" }, sentRequest.getHeaders().getValues(X_MULTI_HEADER));
assertEquals("text/plain", sentRequest.getHeaders().getValue(HttpHeaderName.CONTENT_TYPE));
assertEquals("payload", new String(sentRequest.getBodyAsBinaryData().toBytes(), StandardCharsets.UTF_8));

assertEquals(201, response.statusCode());
assertEquals("req-123", response.requestId().orElseThrow(() -> new AssertionError("Missing request id")));
assertEquals("custom-value", response.headers().values("custom-header").get(0));
assertEquals("pong", new String(readAllBytes(response.body()), StandardCharsets.UTF_8));
} catch (Exception e) {
fail("Exception thrown while reading response", e);
}
}

@Test
void executeAsyncCompletesSuccessfully() {
RecordingHttpClient recordingClient
Expand Down
2 changes: 2 additions & 0 deletions sdk/ai/azure-ai-projects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Other Changes

- Updated version of `openai` client library to `4.14.0`

## 1.0.0-beta.3 (2025-11-12)

### Features Added
Expand Down
4 changes: 2 additions & 2 deletions sdk/ai/azure-ai-projects/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Code generated by Microsoft (R) TypeSpec Code Generator.
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>4.6.1</version> <!-- {x-version-update;com.openai:openai-java;external_dependency} -->
<version>4.14.0</version> <!-- {x-version-update;com.openai:openai-java;external_dependency} -->
</dependency>

<!-- test Dependencies -->
Expand Down Expand Up @@ -106,7 +106,7 @@ Code generated by Microsoft (R) TypeSpec Code Generator.
<rules>
<bannedDependencies>
<includes>
<include>com.openai:openai-java:[4.6.1]</include> <!-- {x-include-update;com.openai:openai-java;external_dependency} -->
<include>com.openai:openai-java:[4.14.0]</include> <!-- {x-include-update;com.openai:openai-java;external_dependency} -->
</includes>
</bannedDependencies>
</rules>
Expand Down
4 changes: 2 additions & 2 deletions sdk/openai/azure-ai-openai-stainless/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<dependency>
<groupId>com.openai</groupId>
<artifactId>openai-java</artifactId>
<version>4.6.1</version> <!-- {x-version-update;com.openai:openai-java;external_dependency} -->
<version>4.14.0</version> <!-- {x-version-update;com.openai:openai-java;external_dependency} -->
</dependency>

<!-- provided scope -->
Expand Down Expand Up @@ -132,7 +132,7 @@
<rules>
<bannedDependencies>
<includes>
<include>com.openai:openai-java:[4.6.1]</include> <!-- {x-include-update;com.openai:openai-java;external_dependency} -->
<include>com.openai:openai-java:[4.14.0]</include> <!-- {x-include-update;com.openai:openai-java;external_dependency} -->
</includes>
</bannedDependencies>
<requireReleaseDeps>
Expand Down
Loading