|
34 | 34 | import com.azure.core.http.rest.Response; |
35 | 35 | import com.azure.core.util.BinaryData; |
36 | 36 | import com.azure.core.util.FluxUtil; |
| 37 | +import com.openai.models.conversations.Conversation; |
37 | 38 | import java.util.Map; |
38 | 39 | import java.util.stream.Collectors; |
39 | 40 | import reactor.core.publisher.Flux; |
@@ -1432,4 +1433,154 @@ public Mono<AgentVersionDetails> createAgentVersion(String agentName, AgentDefin |
1432 | 1433 | .flatMap(FluxUtil::toMono) |
1433 | 1434 | .map(protocolMethodData -> protocolMethodData.toObject(AgentVersionDetails.class)); |
1434 | 1435 | } |
| 1436 | + |
| 1437 | + /** |
| 1438 | + * Returns the list of all conversations. |
| 1439 | + * <p><strong>Query Parameters</strong></p> |
| 1440 | + * <table border="1"> |
| 1441 | + * <caption>Query Parameters</caption> |
| 1442 | + * <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr> |
| 1443 | + * <tr><td>limit</td><td>Integer</td><td>No</td><td>A limit on the number of objects to be returned. Limit can range |
| 1444 | + * between 1 and 100, and the |
| 1445 | + * default is 20.</td></tr> |
| 1446 | + * <tr><td>order</td><td>String</td><td>No</td><td>Sort order by the `created_at` timestamp of the objects. `asc` |
| 1447 | + * for ascending order and`desc` |
| 1448 | + * for descending order. Allowed values: "asc", "desc".</td></tr> |
| 1449 | + * <tr><td>after</td><td>String</td><td>No</td><td>A cursor for use in pagination. `after` is an object ID that |
| 1450 | + * defines your place in the list. |
| 1451 | + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your |
| 1452 | + * subsequent call can include after=obj_foo in order to fetch the next page of the list.</td></tr> |
| 1453 | + * <tr><td>before</td><td>String</td><td>No</td><td>A cursor for use in pagination. `before` is an object ID that |
| 1454 | + * defines your place in the list. |
| 1455 | + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your |
| 1456 | + * subsequent call can include before=obj_foo in order to fetch the previous page of the list.</td></tr> |
| 1457 | + * <tr><td>agent_name</td><td>String</td><td>No</td><td>Filter by agent name. If provided, only items associated |
| 1458 | + * with the specified agent will be returned.</td></tr> |
| 1459 | + * <tr><td>agent_id</td><td>String</td><td>No</td><td>Filter by agent ID in the format `name:version`. If provided, |
| 1460 | + * only items associated with the specified agent ID will be returned.</td></tr> |
| 1461 | + * </table> |
| 1462 | + * You can add these to a request with {@link RequestOptions#addQueryParam} |
| 1463 | + * <p><strong>Response Body Schema</strong></p> |
| 1464 | + * |
| 1465 | + * <pre> |
| 1466 | + * {@code |
| 1467 | + * { |
| 1468 | + * id: String (Required) |
| 1469 | + * object: String (Required) |
| 1470 | + * metadata (Required): { |
| 1471 | + * (Optional): { |
| 1472 | + * String: String (Required) |
| 1473 | + * } |
| 1474 | + * } |
| 1475 | + * created_at: long (Required) |
| 1476 | + * } |
| 1477 | + * } |
| 1478 | + * </pre> |
| 1479 | + * |
| 1480 | + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. |
| 1481 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 1482 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 1483 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 1484 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 1485 | + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. |
| 1486 | + */ |
| 1487 | + @Generated |
| 1488 | + @ServiceMethod(returns = ReturnType.COLLECTION) |
| 1489 | + public PagedFlux<BinaryData> listAgentConversations(RequestOptions requestOptions) { |
| 1490 | + return this.serviceClient.listAgentConversationsAsync(requestOptions); |
| 1491 | + } |
| 1492 | + |
| 1493 | + /** |
| 1494 | + * Returns the list of all conversations. |
| 1495 | + * |
| 1496 | + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the |
| 1497 | + * default is 20. |
| 1498 | + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` |
| 1499 | + * for descending order. |
| 1500 | + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. |
| 1501 | + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your |
| 1502 | + * subsequent call can include after=obj_foo in order to fetch the next page of the list. |
| 1503 | + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. |
| 1504 | + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your |
| 1505 | + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. |
| 1506 | + * @param agentName Filter by agent name. If provided, only items associated with the specified agent will be |
| 1507 | + * returned. |
| 1508 | + * @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the |
| 1509 | + * specified agent ID will be returned. |
| 1510 | + * @throws IllegalArgumentException thrown if parameters fail the validation. |
| 1511 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 1512 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 1513 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 1514 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 1515 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 1516 | + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. |
| 1517 | + */ |
| 1518 | + @Generated |
| 1519 | + @ServiceMethod(returns = ReturnType.COLLECTION) |
| 1520 | + public PagedFlux<Conversation> listAgentConversations(Integer limit, PageOrder order, String after, String before, |
| 1521 | + String agentName, String agentId) { |
| 1522 | + // Generated convenience method for listAgentConversations |
| 1523 | + RequestOptions requestOptions = new RequestOptions(); |
| 1524 | + if (limit != null) { |
| 1525 | + requestOptions.addQueryParam("limit", String.valueOf(limit), false); |
| 1526 | + } |
| 1527 | + if (order != null) { |
| 1528 | + requestOptions.addQueryParam("order", order.toString(), false); |
| 1529 | + } |
| 1530 | + if (after != null) { |
| 1531 | + requestOptions.addQueryParam("after", after, false); |
| 1532 | + } |
| 1533 | + if (before != null) { |
| 1534 | + requestOptions.addQueryParam("before", before, false); |
| 1535 | + } |
| 1536 | + if (agentName != null) { |
| 1537 | + requestOptions.addQueryParam("agent_name", agentName, false); |
| 1538 | + } |
| 1539 | + if (agentId != null) { |
| 1540 | + requestOptions.addQueryParam("agent_id", agentId, false); |
| 1541 | + } |
| 1542 | + PagedFlux<BinaryData> pagedFluxResponse = listAgentConversations(requestOptions); |
| 1543 | + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { |
| 1544 | + Flux<PagedResponse<BinaryData>> flux = (continuationTokenParam == null) |
| 1545 | + ? pagedFluxResponse.byPage().take(1) |
| 1546 | + : pagedFluxResponse.byPage(continuationTokenParam).take(1); |
| 1547 | + return flux.map(pagedResponse -> new PagedResponseBase<Void, Conversation>(pagedResponse.getRequest(), |
| 1548 | + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), |
| 1549 | + pagedResponse.getValue() |
| 1550 | + .stream() |
| 1551 | + .map(protocolMethodData -> protocolMethodData.toObject(Conversation.class)) |
| 1552 | + .collect(Collectors.toList()), |
| 1553 | + pagedResponse.getContinuationToken(), null)); |
| 1554 | + }); |
| 1555 | + } |
| 1556 | + |
| 1557 | + /** |
| 1558 | + * Returns the list of all conversations. |
| 1559 | + * |
| 1560 | + * @throws HttpResponseException thrown if the request is rejected by server. |
| 1561 | + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. |
| 1562 | + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. |
| 1563 | + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. |
| 1564 | + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. |
| 1565 | + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. |
| 1566 | + */ |
| 1567 | + @Generated |
| 1568 | + @ServiceMethod(returns = ReturnType.COLLECTION) |
| 1569 | + public PagedFlux<Conversation> listAgentConversations() { |
| 1570 | + // Generated convenience method for listAgentConversations |
| 1571 | + RequestOptions requestOptions = new RequestOptions(); |
| 1572 | + PagedFlux<BinaryData> pagedFluxResponse = listAgentConversations(requestOptions); |
| 1573 | + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { |
| 1574 | + Flux<PagedResponse<BinaryData>> flux = (continuationTokenParam == null) |
| 1575 | + ? pagedFluxResponse.byPage().take(1) |
| 1576 | + : pagedFluxResponse.byPage(continuationTokenParam).take(1); |
| 1577 | + return flux.map(pagedResponse -> new PagedResponseBase<Void, Conversation>(pagedResponse.getRequest(), |
| 1578 | + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), |
| 1579 | + pagedResponse.getValue() |
| 1580 | + .stream() |
| 1581 | + .map(protocolMethodData -> protocolMethodData.toObject(Conversation.class)) |
| 1582 | + .collect(Collectors.toList()), |
| 1583 | + pagedResponse.getContinuationToken(), null)); |
| 1584 | + }); |
| 1585 | + } |
1435 | 1586 | } |
0 commit comments