Skip to content
Open
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
1 change: 1 addition & 0 deletions sdk/ai/azure-ai-agents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Added type-safe accessors on `McpTool` for the `allowedTools` property: `setAllowedTools(List<String>)`, `setAllowedTools(McpToolFilter)`, `getAllowedToolsAsStringList()`, and `getAllowedToolsAsMcpToolFilter()`.
- Added type-safe accessors on `McpTool` for the `requireApproval` property: `setRequireApproval(String)`, `setRequireApproval(McpToolRequireApproval)`, `getRequireApprovalAsString()`, and `getRequireApprovalAsMcpToolRequireApproval()`.
- Added `setComparisonFilter(ComparisonFilter)` and `setCompoundFilter(CompoundFilter)` convenience methods on `FileSearchTool`, accepting the openai-java filter types directly.
- Added `listConversations` operation to `ConversationsClient` and `ConversationsAsyncClient` for listing all conversations. Returns `PagedIterable<Conversation>` / `PagedFlux<Conversation>` using `com.openai.models.conversations.Conversation` from the openai-java library. Supports optional filtering by `limit`, `order`, `after`, `before`, `agentName`, and `agentId`.
- Added streaming response methods to `ResponsesClient` and `ResponsesAsyncClient`:
- `createStreamingWithAgent` and `createStreamingWithAgentConversation` on `ResponsesClient` return `IterableStream<ResponseStreamEvent>` for synchronous streaming.
- `createStreamingWithAgent` and `createStreamingWithAgentConversation` on `ResponsesAsyncClient` return `Flux<ResponseStreamEvent>` for asynchronous streaming.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@
serviceClients = {
AgentsClient.class,
MemoryStoresClient.class,
ConversationsClient.class,
AgentsAsyncClient.class,
MemoryStoresAsyncClient.class })
MemoryStoresAsyncClient.class,
ConversationsAsyncClient.class })
public final class AgentsClientBuilder
implements HttpTrait<AgentsClientBuilder>, ConfigurationTrait<AgentsClientBuilder>,
TokenCredentialTrait<AgentsClientBuilder>, EndpointTrait<AgentsClientBuilder> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.
package com.azure.ai.agents;

import com.azure.ai.agents.implementation.ConversationsImpl;
import com.azure.ai.agents.models.PageOrder;
import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;

import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.util.BinaryData;
import com.openai.client.OpenAIClientAsync;
import com.openai.models.conversations.Conversation;
import com.openai.services.async.ConversationServiceAsync;
import java.util.stream.Collectors;
import reactor.core.publisher.Flux;

/**
* Initializes a new instance of the asynchronous ConversationsClient type.
* Initializes a new instance of the asynchronous AgentsClient type.
*/
@ServiceClient(builder = AgentsClientBuilder.class, isAsync = true)
public final class ConversationsAsyncClient {
Expand All @@ -32,4 +49,157 @@ public final class ConversationsAsyncClient {
public ConversationServiceAsync getConversationServiceAsync() {
return this.conversationServiceAsync;
}

@Generated
private final ConversationsImpl serviceClient;

/**
* Returns the list of all conversations.
* <p><strong>Query Parameters</strong></p>
* <table border="1">
* <caption>Query Parameters</caption>
* <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
* <tr><td>limit</td><td>Integer</td><td>No</td><td>A limit on the number of objects to be returned. Limit can range
* between 1 and 100, and the
* default is 20.</td></tr>
* <tr><td>order</td><td>String</td><td>No</td><td>Sort order by the `created_at` timestamp of the objects. `asc`
* for ascending order and`desc`
* for descending order. Allowed values: "asc", "desc".</td></tr>
* <tr><td>after</td><td>String</td><td>No</td><td>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.</td></tr>
* <tr><td>before</td><td>String</td><td>No</td><td>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.</td></tr>
* <tr><td>agent_name</td><td>String</td><td>No</td><td>Filter by agent name. If provided, only items associated
* with the specified agent will be returned.</td></tr>
* <tr><td>agent_id</td><td>String</td><td>No</td><td>Filter by agent ID in the format `name:version`. If provided,
* only items associated with the specified agent ID will be returned.</td></tr>
* </table>
* You can add these to a request with {@link RequestOptions#addQueryParam}
* <p><strong>Response Body Schema</strong></p>
*
* <pre>
* {@code
* {
* id: String (Required)
* object: String (Required)
* metadata (Required): {
* (Optional): {
* String: String (Required)
* }
* }
* created_at: long (Required)
* }
* }
* </pre>
*
* @param requestOptions The options to configure the HTTP request before HTTP client sends it.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @return the response data for a requested list of items as paginated response with {@link PagedFlux}.
*/
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<BinaryData> listConversations(RequestOptions requestOptions) {
return this.serviceClient.listConversationsAsync(requestOptions);
}

/**
* Returns the list of all conversations.
*
* @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the
* default is 20.
* @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc`
* for descending order.
* @param after 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.
* @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list.
* For instance, if you make a list request and receive 100 objects, ending with obj_foo, your
* subsequent call can include before=obj_foo in order to fetch the previous page of the list.
* @param agentName Filter by agent name. If provided, only items associated with the specified agent will be
* returned.
* @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the
* specified agent ID will be returned.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response data for a requested list of items as paginated response with {@link PagedFlux}.
*/
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<Conversation> listConversations(Integer limit, PageOrder order, String after, String before,
String agentName, String agentId) {
// Generated convenience method for listConversations
RequestOptions requestOptions = new RequestOptions();
if (limit != null) {
requestOptions.addQueryParam("limit", String.valueOf(limit), false);
}
if (order != null) {
requestOptions.addQueryParam("order", order.toString(), false);
}
if (after != null) {
requestOptions.addQueryParam("after", after, false);
}
if (before != null) {
requestOptions.addQueryParam("before", before, false);
}
if (agentName != null) {
requestOptions.addQueryParam("agent_name", agentName, false);
}
if (agentId != null) {
requestOptions.addQueryParam("agent_id", agentId, false);
}
PagedFlux<BinaryData> pagedFluxResponse = listConversations(requestOptions);
return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> {
Flux<PagedResponse<BinaryData>> flux = (continuationTokenParam == null)
? pagedFluxResponse.byPage().take(1)
: pagedFluxResponse.byPage(continuationTokenParam).take(1);
return flux.map(pagedResponse -> new PagedResponseBase<Void, Conversation>(pagedResponse.getRequest(),
pagedResponse.getStatusCode(), pagedResponse.getHeaders(),
pagedResponse.getValue()
.stream()
.map(protocolMethodData -> protocolMethodData.toObject(Conversation.class))
.collect(Collectors.toList()),
pagedResponse.getContinuationToken(), null));
});
Comment on lines +137 to +173
}

/**
* Returns the list of all conversations.
*
* @throws HttpResponseException thrown if the request is rejected by server.
* @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
* @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
* @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return the response data for a requested list of items as paginated response with {@link PagedFlux}.
*/
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<Conversation> listConversations() {
// Generated convenience method for listConversations
RequestOptions requestOptions = new RequestOptions();
PagedFlux<BinaryData> pagedFluxResponse = listConversations(requestOptions);
return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> {
Flux<PagedResponse<BinaryData>> flux = (continuationTokenParam == null)
? pagedFluxResponse.byPage().take(1)
: pagedFluxResponse.byPage(continuationTokenParam).take(1);
return flux.map(pagedResponse -> new PagedResponseBase<Void, Conversation>(pagedResponse.getRequest(),
pagedResponse.getStatusCode(), pagedResponse.getHeaders(),
pagedResponse.getValue()
.stream()
.map(protocolMethodData -> protocolMethodData.toObject(Conversation.class))
.collect(Collectors.toList()),
pagedResponse.getContinuationToken(), null));
});
}
}
Loading
Loading