55
66import com .azure .ai .agents .implementation .AgentsImpl ;
77import com .azure .ai .agents .implementation .JsonMergePatchHelper ;
8+ import com .azure .ai .agents .implementation .SessionLogServerSentEvents ;
89import com .azure .ai .agents .implementation .models .CreateAgentFromManifestRequest ;
910import com .azure .ai .agents .implementation .models .CreateAgentOptions ;
1011import com .azure .ai .agents .implementation .models .CreateAgentRequest ;
4243import com .azure .core .util .BinaryData ;
4344import com .azure .core .util .FluxUtil ;
4445import com .openai .models .conversations .Conversation ;
46+ import java .nio .ByteBuffer ;
4547import java .util .Map ;
4648import java .util .stream .Collectors ;
4749import reactor .core .publisher .Flux ;
@@ -59,7 +61,7 @@ public final class AgentsAsyncClient {
5961 /**
6062 * Retrieves the agent.
6163 * <p><strong>Response Body Schema</strong></p>
62- *
64+ *
6365 * <pre>
6466 * {@code
6567 * {
@@ -162,7 +164,7 @@ public Mono<Response<BinaryData>> getAgentWithResponse(String agentName, Request
162164 * </table>
163165 * You can add these to a request with {@link RequestOptions#addHeader}
164166 * <p><strong>Request Body Schema</strong></p>
165- *
167+ *
166168 * <pre>
167169 * {@code
168170 * {
@@ -182,9 +184,9 @@ public Mono<Response<BinaryData>> getAgentWithResponse(String agentName, Request
182184 * }
183185 * }
184186 * </pre>
185- *
187+ *
186188 * <p><strong>Response Body Schema</strong></p>
187- *
189+ *
188190 * <pre>
189191 * {@code
190192 * {
@@ -308,7 +310,7 @@ public Mono<Void> deleteAgentVersion(String agentName, String agentVersion) {
308310 * </table>
309311 * You can add these to a request with {@link RequestOptions#addQueryParam}
310312 * <p><strong>Response Body Schema</strong></p>
311- *
313+ *
312314 * <pre>
313315 * {@code
314316 * {
@@ -478,7 +480,7 @@ public Mono<AgentVersionDetails> createAgentVersion(String agentName, AgentDefin
478480 * </table>
479481 * You can add these to a request with {@link RequestOptions#addHeader}
480482 * <p><strong>Request Body Schema</strong></p>
481- *
483+ *
482484 * <pre>
483485 * {@code
484486 * {
@@ -534,9 +536,9 @@ public Mono<AgentVersionDetails> createAgentVersion(String agentName, AgentDefin
534536 * }
535537 * }
536538 * </pre>
537- *
539+ *
538540 * <p><strong>Response Body Schema</strong></p>
539- *
541+ *
540542 * <pre>
541543 * {@code
542544 * {
@@ -640,7 +642,7 @@ Mono<Response<BinaryData>> createAgentWithResponse(BinaryData createAgentRequest
640642 * </table>
641643 * You can add these to a request with {@link RequestOptions#addHeader}
642644 * <p><strong>Request Body Schema</strong></p>
643- *
645+ *
644646 * <pre>
645647 * {@code
646648 * {
@@ -660,9 +662,9 @@ Mono<Response<BinaryData>> createAgentWithResponse(BinaryData createAgentRequest
660662 * }
661663 * }
662664 * </pre>
663- *
665+ *
664666 * <p><strong>Response Body Schema</strong></p>
665- *
667+ *
666668 * <pre>
667669 * {@code
668670 * {
@@ -793,7 +795,7 @@ Mono<AgentDetails> updateAgent(String agentName, AgentDefinition definition) {
793795 /**
794796 * Creates an agent from a manifest.
795797 * <p><strong>Request Body Schema</strong></p>
796- *
798+ *
797799 * <pre>
798800 * {@code
799801 * {
@@ -809,9 +811,9 @@ Mono<AgentDetails> updateAgent(String agentName, AgentDefinition definition) {
809811 * }
810812 * }
811813 * </pre>
812- *
814+ *
813815 * <p><strong>Response Body Schema</strong></p>
814- *
816+ *
815817 * <pre>
816818 * {@code
817819 * {
@@ -908,7 +910,7 @@ Mono<Response<BinaryData>> createAgentFromManifestWithResponse(BinaryData create
908910 * Updates the agent from a manifest by adding a new version if there are any changes to the agent definition.
909911 * If no changes, returns the existing agent version.
910912 * <p><strong>Request Body Schema</strong></p>
911- *
913+ *
912914 * <pre>
913915 * {@code
914916 * {
@@ -923,9 +925,9 @@ Mono<Response<BinaryData>> createAgentFromManifestWithResponse(BinaryData create
923925 * }
924926 * }
925927 * </pre>
926- *
928+ *
927929 * <p><strong>Response Body Schema</strong></p>
928- *
930+ *
929931 * <pre>
930932 * {@code
931933 * {
@@ -1022,7 +1024,7 @@ Mono<Response<BinaryData>> updateAgentFromManifestWithResponse(String agentName,
10221024 /**
10231025 * Create a new agent version from a manifest.
10241026 * <p><strong>Request Body Schema</strong></p>
1025- *
1027+ *
10261028 * <pre>
10271029 * {@code
10281030 * {
@@ -1037,9 +1039,9 @@ Mono<Response<BinaryData>> updateAgentFromManifestWithResponse(String agentName,
10371039 * }
10381040 * }
10391041 * </pre>
1040- *
1042+ *
10411043 * <p><strong>Response Body Schema</strong></p>
1042- *
1044+ *
10431045 * <pre>
10441046 * {@code
10451047 * {
@@ -1263,7 +1265,7 @@ public Mono<AgentVersionDetails> createAgentVersionFromManifest(String agentName
12631265 /**
12641266 * Retrieves a specific version of an agent.
12651267 * <p><strong>Response Body Schema</strong></p>
1266- *
1268+ *
12671269 * <pre>
12681270 * {@code
12691271 * {
@@ -1472,7 +1474,7 @@ public PagedFlux<AgentVersionDetails> listAgentVersions(String agentName, Intege
14721474 * </table>
14731475 * You can add these to a request with {@link RequestOptions#addQueryParam}
14741476 * <p><strong>Response Body Schema</strong></p>
1475- *
1477+ *
14761478 * <pre>
14771479 * {@code
14781480 * {
@@ -1628,7 +1630,7 @@ Mono<AgentDetails> createAgentFromManifest(String agentName, String manifestId,
16281630 * </table>
16291631 * You can add these to a request with {@link RequestOptions#addQueryParam}
16301632 * <p><strong>Response Body Schema</strong></p>
1631- *
1633+ *
16321634 * <pre>
16331635 * {@code
16341636 * {
@@ -1799,7 +1801,7 @@ public Mono<Response<Void>> deleteAgentWithResponse(String agentName, RequestOpt
17991801 /**
18001802 * Deletes an agent.
18011803 * <p><strong>Response Body Schema</strong></p>
1802- *
1804+ *
18031805 * <pre>
18041806 * {@code
18051807 * {
@@ -1827,7 +1829,7 @@ Mono<Response<BinaryData>> internalDeleteAgentWithResponse(String agentName, Req
18271829 /**
18281830 * Deletes a specific version of an agent.
18291831 * <p><strong>Response Body Schema</strong></p>
1830- *
1832+ *
18311833 * <pre>
18321834 * {@code
18331835 * {
@@ -1867,7 +1869,7 @@ Mono<Response<BinaryData>> internalDeleteAgentVersionWithResponse(String agentNa
18671869 * </table>
18681870 * You can add these to a request with {@link RequestOptions#addHeader}
18691871 * <p><strong>Request Body Schema</strong></p>
1870- *
1872+ *
18711873 * <pre>
18721874 * {@code
18731875 * {
@@ -1909,9 +1911,9 @@ Mono<Response<BinaryData>> internalDeleteAgentVersionWithResponse(String agentNa
19091911 * }
19101912 * }
19111913 * </pre>
1912- *
1914+ *
19131915 * <p><strong>Response Body Schema</strong></p>
1914- *
1916+ *
19151917 * <pre>
19161918 * {@code
19171919 * {
@@ -2018,7 +2020,7 @@ public Mono<Response<BinaryData>> patchAgentObjectWithResponse(String agentName,
20182020 * </table>
20192021 * You can add these to a request with {@link RequestOptions#addHeader}
20202022 * <p><strong>Request Body Schema</strong></p>
2021- *
2023+ *
20222024 * <pre>
20232025 * {@code
20242026 * {
@@ -2029,9 +2031,9 @@ public Mono<Response<BinaryData>> patchAgentObjectWithResponse(String agentName,
20292031 * }
20302032 * }
20312033 * </pre>
2032- *
2034+ *
20332035 * <p><strong>Response Body Schema</strong></p>
2034- *
2036+ *
20352037 * <pre>
20362038 * {@code
20372039 * {
@@ -2079,7 +2081,7 @@ public Mono<Response<BinaryData>> createSessionWithResponse(String agentName, St
20792081 * </table>
20802082 * You can add these to a request with {@link RequestOptions#addHeader}
20812083 * <p><strong>Response Body Schema</strong></p>
2082- *
2084+ *
20832085 * <pre>
20842086 * {@code
20852087 * {
@@ -2175,7 +2177,7 @@ public Mono<Response<Void>> deleteSessionWithResponse(String agentName, String s
21752177 * </table>
21762178 * You can add these to a request with {@link RequestOptions#addHeader}
21772179 * <p><strong>Response Body Schema</strong></p>
2178- *
2180+ *
21792181 * <pre>
21802182 * {@code
21812183 * {
@@ -2694,7 +2696,7 @@ public PagedFlux<AgentSessionResource> listSessions(String agentName) {
26942696 * </table>
26952697 * You can add these to a request with {@link RequestOptions#addHeader}
26962698 * <p><strong>Response Body Schema</strong></p>
2697- *
2699+ *
26982700 * <pre>
26992701 * {@code
27002702 * {
@@ -2765,22 +2767,20 @@ public Mono<Response<BinaryData>> getSessionLogStreamWithResponse(String agentNa
27652767 * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
27662768 * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
27672769 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
2768- * @return a single Server-Sent Event frame emitted by the hosted agent session log stream.
2769- *
2770- * Each frame contains an `event` field identifying the event type and a `data`
2771- * field carrying the payload as plain text on successful completion of {@link Mono}.
2770+ * @return a {@link Flux} of {@link SessionLogEvent} parsed from the SSE stream.
27722771 */
2773- @ Generated
2774- @ ServiceMethod (returns = ReturnType .SINGLE )
2775- public Mono <SessionLogEvent > getSessionLogStream (String agentName , String agentVersion , String sessionId ,
2772+ @ ServiceMethod (returns = ReturnType .COLLECTION )
2773+ public Flux <SessionLogEvent > getSessionLogStream (String agentName , String agentVersion , String sessionId ,
27762774 AgentDefinitionOptInKeys foundryFeatures ) {
2777- // Generated convenience method for getSessionLogStreamWithResponse
27782775 RequestOptions requestOptions = new RequestOptions ();
27792776 if (foundryFeatures != null ) {
27802777 requestOptions .setHeader (HttpHeaderName .fromString ("Foundry-Features" ), foundryFeatures .toString ());
27812778 }
27822779 return getSessionLogStreamWithResponse (agentName , agentVersion , sessionId , requestOptions )
2783- .flatMap (FluxUtil ::toMono );
2780+ .flatMapMany (response -> {
2781+ Flux <ByteBuffer > sseStream = response .getValue ().toFluxByteBuffer ();
2782+ return new SessionLogServerSentEvents (sseStream ).getEvents ();
2783+ });
27842784 }
27852785
27862786 /**
@@ -2821,17 +2821,10 @@ public Mono<SessionLogEvent> getSessionLogStream(String agentName, String agentV
28212821 * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
28222822 * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
28232823 * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
2824- * @return a single Server-Sent Event frame emitted by the hosted agent session log stream.
2825- *
2826- * Each frame contains an `event` field identifying the event type and a `data`
2827- * field carrying the payload as plain text on successful completion of {@link Mono}.
2824+ * @return a {@link Flux} of {@link SessionLogEvent} parsed from the SSE stream.
28282825 */
2829- @ Generated
2830- @ ServiceMethod (returns = ReturnType .SINGLE )
2831- public Mono <SessionLogEvent > getSessionLogStream (String agentName , String agentVersion , String sessionId ) {
2832- // Generated convenience method for getSessionLogStreamWithResponse
2833- RequestOptions requestOptions = new RequestOptions ();
2834- return getSessionLogStreamWithResponse (agentName , agentVersion , sessionId , requestOptions )
2835- .flatMap (FluxUtil ::toMono );
2826+ @ ServiceMethod (returns = ReturnType .COLLECTION )
2827+ public Flux <SessionLogEvent > getSessionLogStream (String agentName , String agentVersion , String sessionId ) {
2828+ return getSessionLogStream (agentName , agentVersion , sessionId , null );
28362829 }
28372830}
0 commit comments