Skip to content

Commit 6b4fa90

Browse files
committed
Changes to resolve PR comments and updated typespec
commit bda4dac2fc4700d11f63c3a4df0d12f412be1bcc Author: Jayant Kumar <[email protected]> Date: Mon Apr 21 21:17:19 2025 +0530 updated commit b7ded3fa1dcd6d656b75e7f8e11eb593872227a5 Author: Jayant Kumar <[email protected]> Date: Mon Apr 21 20:39:59 2025 +0530 tests passing commit dcde6c06699a222afd0013ec2bd80c7776658b28 Author: Jayant Kumar <[email protected]> Date: Mon Apr 21 19:09:23 2025 +0530 updated commit 305e167747a6c9486b46f524b5c02d23831471a9 Author: Jayant Kumar <[email protected]> Date: Mon Apr 21 18:04:38 2025 +0530 tsp-client updated commit 9cfd86b Author: Jayant Kumar <[email protected]> Date: Thu Apr 17 12:55:09 2025 +0530 resolving PR comments
1 parent a591320 commit 6b4fa90

File tree

49 files changed

+2282
-399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2282
-399
lines changed

sdk/ai/azure-ai-projects/customization/src/main/java/AIProjectsCustomizations.java

-35
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,5 @@ public class AIProjectsCustomizations extends Customization {
1313
public void customize(LibraryCustomization customization, Logger logger) {
1414
// remove unused class (no reference to them, after partial-update)
1515

16-
ClassCustomization connectionsImpl = customization.getClass(
17-
"com.azure.ai.projects.implementation",
18-
"ConnectionsImpl");
19-
20-
List<Range> toReplace = connectionsImpl.getEditor().searchText(
21-
connectionsImpl.getFileName(),
22-
"{endpoint}/agents/v1.0");
23-
24-
for (Range r : toReplace) {
25-
logger.info("customizing");
26-
connectionsImpl.getEditor().replace(
27-
connectionsImpl.getFileName(),
28-
r.getStart(),
29-
r.getEnd(),
30-
"{endpoint}"
31-
);
32-
}
33-
34-
ClassCustomization telemetriesImpl = customization.getClass(
35-
"com.azure.ai.projects.implementation",
36-
"TelemetriesImpl");
37-
38-
toReplace = telemetriesImpl.getEditor().searchText(
39-
telemetriesImpl.getFileName(),
40-
"{endpoint}/agents/v1.0");
41-
42-
for (Range r : toReplace) {
43-
logger.info("customizing");
44-
telemetriesImpl.getEditor().replace(
45-
telemetriesImpl.getFileName(),
46-
r.getStart(),
47-
r.getEnd(),
48-
"{endpoint}"
49-
);
50-
}
5116
}
5217
}

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/AgentsAsyncClient.java

+289-74
Large diffs are not rendered by default.

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/AgentsClient.java

+286-74
Large diffs are not rendered by default.

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/AgentsImpl.java

+225-8
Large diffs are not rendered by default.

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/ConnectionsImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public ProjectsServiceVersion getServiceVersion() {
6868
* The interface defining all the services for AIProjectClientConnections to be used by the proxy service to perform
6969
* REST calls.
7070
*/
71-
@Host("{endpoint}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}")
71+
@Host("{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}")
7272
@ServiceInterface(name = "AIProjectClientConne")
7373
public interface ConnectionsService {
7474
@Get("/")

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/TelemetriesImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public ProjectsServiceVersion getServiceVersion() {
6666
* The interface defining all the services for AIProjectClientTelemetries to be used by the proxy service to perform
6767
* REST calls.
6868
*/
69-
@Host("{endpoint}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}")
69+
@Host("{endpoint}/agents/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{projectName}")
7070
@ServiceInterface(name = "AIProjectClientTelem")
7171
public interface TelemetriesService {
7272
@Get("/{appInsightsResourceUrl}")

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/implementation/models/CreateMessageRequest.java

+33-33
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.azure.ai.projects.models.MessageRole;
88
import com.azure.core.annotation.Fluent;
99
import com.azure.core.annotation.Generated;
10+
import com.azure.core.util.BinaryData;
1011
import com.azure.json.JsonReader;
1112
import com.azure.json.JsonSerializable;
1213
import com.azure.json.JsonToken;
@@ -23,22 +24,21 @@ public final class CreateMessageRequest implements JsonSerializable<CreateMessag
2324

2425
/*
2526
* The role of the entity that is creating the message. Allowed values include:
26-
* - `user`: Indicates the message is sent by an actual user and should be used in most
27-
* cases to represent user-generated messages.
28-
* - `assistant`: Indicates the message is generated by the agent. Use this value to insert
29-
* messages from the agent into the
30-
* conversation.
27+
* `user`, which indicates the message is sent by an actual user (and should be
28+
* used in most cases to represent user-generated messages), and `assistant`,
29+
* which indicates the message is generated by the agent (use this value to insert
30+
* messages from the agent into the conversation).
3131
*/
3232
@Generated
3333
private final MessageRole role;
3434

3535
/*
36-
* The textual content of the initial message. Currently, robust input including images and annotated text may only
37-
* be provided via
38-
* a separate call to the create message API.
36+
* The content of the initial message. This may be a basic string (if you only
37+
* need text) or an array of typed content blocks (for example, text, image_file,
38+
* image_url, and so on).
3939
*/
4040
@Generated
41-
private final String content;
41+
private final BinaryData content;
4242

4343
/*
4444
* A list of files attached to the message, and the tools they should be added to.
@@ -54,25 +54,12 @@ public final class CreateMessageRequest implements JsonSerializable<CreateMessag
5454
@Generated
5555
private Map<String, String> metadata;
5656

57-
/**
58-
* Creates an instance of CreateMessageRequest class.
59-
*
60-
* @param role the role value to set.
61-
* @param content the content value to set.
62-
*/
63-
@Generated
64-
public CreateMessageRequest(MessageRole role, String content) {
65-
this.role = role;
66-
this.content = content;
67-
}
68-
6957
/**
7058
* Get the role property: The role of the entity that is creating the message. Allowed values include:
71-
* - `user`: Indicates the message is sent by an actual user and should be used in most
72-
* cases to represent user-generated messages.
73-
* - `assistant`: Indicates the message is generated by the agent. Use this value to insert
74-
* messages from the agent into the
75-
* conversation.
59+
* `user`, which indicates the message is sent by an actual user (and should be
60+
* used in most cases to represent user-generated messages), and `assistant`,
61+
* which indicates the message is generated by the agent (use this value to insert
62+
* messages from the agent into the conversation).
7663
*
7764
* @return the role value.
7865
*/
@@ -82,14 +69,14 @@ public MessageRole getRole() {
8269
}
8370

8471
/**
85-
* Get the content property: The textual content of the initial message. Currently, robust input including images
86-
* and annotated text may only be provided via
87-
* a separate call to the create message API.
72+
* Get the content property: The content of the initial message. This may be a basic string (if you only
73+
* need text) or an array of typed content blocks (for example, text, image_file,
74+
* image_url, and so on).
8875
*
8976
* @return the content value.
9077
*/
9178
@Generated
92-
public String getContent() {
79+
public BinaryData getContent() {
9380
return this.content;
9481
}
9582

@@ -149,7 +136,8 @@ public CreateMessageRequest setMetadata(Map<String, String> metadata) {
149136
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
150137
jsonWriter.writeStartObject();
151138
jsonWriter.writeStringField("role", this.role == null ? null : this.role.toString());
152-
jsonWriter.writeStringField("content", this.content);
139+
jsonWriter.writeFieldName("content");
140+
this.content.writeTo(jsonWriter);
153141
jsonWriter.writeArrayField("attachments", this.attachments, (writer, element) -> writer.writeJson(element));
154142
jsonWriter.writeMapField("metadata", this.metadata, (writer, element) -> writer.writeString(element));
155143
return jsonWriter.writeEndObject();
@@ -168,7 +156,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
168156
public static CreateMessageRequest fromJson(JsonReader jsonReader) throws IOException {
169157
return jsonReader.readObject(reader -> {
170158
MessageRole role = null;
171-
String content = null;
159+
BinaryData content = null;
172160
List<MessageAttachment> attachments = null;
173161
Map<String, String> metadata = null;
174162
while (reader.nextToken() != JsonToken.END_OBJECT) {
@@ -177,7 +165,7 @@ public static CreateMessageRequest fromJson(JsonReader jsonReader) throws IOExce
177165
if ("role".equals(fieldName)) {
178166
role = MessageRole.fromString(reader.getString());
179167
} else if ("content".equals(fieldName)) {
180-
content = reader.getString();
168+
content = reader.getNullable(nonNullReader -> BinaryData.fromObject(nonNullReader.readUntyped()));
181169
} else if ("attachments".equals(fieldName)) {
182170
attachments = reader.readArray(reader1 -> MessageAttachment.fromJson(reader1));
183171
} else if ("metadata".equals(fieldName)) {
@@ -192,4 +180,16 @@ public static CreateMessageRequest fromJson(JsonReader jsonReader) throws IOExce
192180
return deserializedCreateMessageRequest;
193181
});
194182
}
183+
184+
/**
185+
* Creates an instance of CreateMessageRequest class.
186+
*
187+
* @param role the role value to set.
188+
* @param content the content value to set.
189+
*/
190+
@Generated
191+
public CreateMessageRequest(MessageRole role, BinaryData content) {
192+
this.role = role;
193+
this.content = content;
194+
}
195195
}

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AOAIModelConfig.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public final class AOAIModelConfig extends TargetModelConfig {
2626
private String type = "AOAI";
2727

2828
/*
29-
* Endpoint URL for AOAI model.
29+
* Endpoint targetURI for AOAI model.
3030
*/
3131
@Generated
3232
private String azureEndpoint;
@@ -68,7 +68,7 @@ public String getType() {
6868
}
6969

7070
/**
71-
* Get the azureEndpoint property: Endpoint URL for AOAI model.
71+
* Get the azureEndpoint property: Endpoint targetURI for AOAI model.
7272
*
7373
* @return the azureEndpoint value.
7474
*/
@@ -78,7 +78,7 @@ public String getAzureEndpoint() {
7878
}
7979

8080
/**
81-
* Set the azureEndpoint property: Endpoint URL for AOAI model.
81+
* Set the azureEndpoint property: Endpoint targetURI for AOAI model.
8282
* <p>Required when create the resource.</p>
8383
*
8484
* @param azureEndpoint the azureEndpoint value to set.

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AgentServerSentEvents.java

+26-9
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import com.azure.ai.projects.models.streaming.StreamTypeFactory;
66
import com.azure.ai.projects.models.streaming.StreamUpdate;
77
import com.azure.core.util.BinaryData;
8+
import com.azure.core.util.FluxUtil;
89
import com.azure.core.util.logging.ClientLogger;
910
import reactor.core.publisher.Flux;
1011
import reactor.core.scheduler.Schedulers;
11-
1212
import java.io.ByteArrayOutputStream;
1313
import java.io.IOException;
1414
import java.io.UncheckedIOException;
@@ -72,20 +72,22 @@ public Flux<StreamUpdate> getEvents() {
7272
private Flux<StreamUpdate> mapEventStream() {
7373
return source.publishOn(Schedulers.boundedElastic()).concatMap(byteBuffer -> {
7474
List<StreamUpdate> values = new ArrayList<>();
75-
byte[] byteArray = byteBuffer.array();
76-
// We check whether we ended the last byteBuffer with a line feed or not, in case we need to close this
77-
// chunk soon after
75+
byte[] byteArray = FluxUtil.byteBufferToArray(byteBuffer);
76+
7877
byte[] outByteArray = outStream.toByteArray();
7978
int lineBreakCharsEncountered
8079
= outByteArray.length > 0 && isByteLineFeed(outByteArray[outByteArray.length - 1]) ? 1 : 0;
8180

82-
for (byte currentByte : byteArray) {
83-
outStream.write(currentByte);
81+
int startIndex = 0;
82+
for (int i = 0; i < byteArray.length; i++) {
83+
byte currentByte = byteArray[i];
8484
if (isByteLineFeed(currentByte)) {
8585
lineBreakCharsEncountered++;
8686

87-
// We are looking for 2 line breaks to signify the end of a server sent event.
87+
// 2 line breaks signify the end of a server sent event.
8888
if (lineBreakCharsEncountered == SSE_CHUNK_LINE_BREAK_COUNT_MARKER) {
89+
outStream.write(byteArray, startIndex, i - startIndex + 1);
90+
8991
String currentLine;
9092
try {
9193
currentLine = outStream.toString(StandardCharsets.UTF_8.name());
@@ -94,6 +96,7 @@ private Flux<StreamUpdate> mapEventStream() {
9496
return Flux.error(e);
9597
}
9698
outStream = new ByteArrayOutputStream();
99+
startIndex = i + 1;
97100
}
98101
} else {
99102
// In some cases line breaks can contain both the line feed and carriage return characters.
@@ -106,6 +109,10 @@ private Flux<StreamUpdate> mapEventStream() {
106109
}
107110
}
108111

112+
if (startIndex < byteArray.length) {
113+
outStream.write(byteArray, startIndex, byteArray.length - startIndex);
114+
}
115+
109116
try {
110117
String remainingBytes = outStream.toString(StandardCharsets.UTF_8.name());
111118
// If this is in fact, the last event, it will be appropriately chunked. Otherwise, we will cache and
@@ -170,8 +177,18 @@ public void handleCurrentEvent(String currentEvent, List<StreamUpdate> outputVal
170177
return;
171178
}
172179

173-
String eventName = lines[0].substring(6).trim(); // removing "event:" prefix
174-
String eventJson = lines[1].substring(5).trim(); // removing "data:" prefix
180+
String[] eventParts = lines[0].split(":", 2);
181+
String[] dataParts = lines[1].split(":", 2);
182+
183+
if (eventParts.length != 2 || !eventParts[0].trim().equals("event")) {
184+
throw logger.logExceptionAsError(new IllegalArgumentException("Invalid event format: missing event name"));
185+
}
186+
String eventName = eventParts[1].trim();
187+
188+
if (dataParts.length != 2 || !dataParts[0].trim().equals("data")) {
189+
throw logger.logExceptionAsError(new IllegalArgumentException("Invalid event format: missing event data"));
190+
}
191+
String eventJson = dataParts[1].trim();
175192

176193
if (DONE.equals(AgentStreamEvent.fromString(eventName))) {
177194
return;

sdk/ai/azure-ai-projects/src/main/java/com/azure/ai/projects/models/AgentsNamedToolChoiceType.java

+12
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,16 @@ public static AgentsNamedToolChoiceType fromString(String name) {
8484
public static Collection<AgentsNamedToolChoiceType> values() {
8585
return values(AgentsNamedToolChoiceType.class);
8686
}
87+
88+
/**
89+
* Tool type `bing_custom_search`.
90+
*/
91+
@Generated
92+
public static final AgentsNamedToolChoiceType BING_CUSTOM_SEARCH = fromString("bing_custom_search");
93+
94+
/**
95+
* Tool type `connected_agent`.
96+
*/
97+
@Generated
98+
public static final AgentsNamedToolChoiceType CONNECTED_AGENT = fromString("connected_agent");
8799
}

0 commit comments

Comments
 (0)