Skip to content

Commit f01e2fe

Browse files
authored
Use RunStepFileSearchToolCallResults instead of a string in search tool deserialization step during streaming. (Azure#48344)
* Add unit test * Fix deserialization of a streaming response from the file search tool. * Record new tests and update changelog
1 parent a2bd19a commit f01e2fe

File tree

10 files changed

+107
-42
lines changed

10 files changed

+107
-42
lines changed

sdk/ai/Azure.AI.Projects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
### Bugs Fixed
1010

1111
* Fixed deserialization failure for AzureBlobStorage connection [issue](https://github.com/Azure/azure-sdk-for-net/issues/47874)
12+
* Fixed a bug on deserialization of RunStepDeltaFileSearchToolCall [issue](https://github.com/Azure/azure-sdk-for-net/issues/48333)
1213

1314
### Other Changes
1415

sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.net8.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public static partial class AIProjectsModelFactory
528528
public static Azure.AI.Projects.RunStepDeltaCodeInterpreterLogOutput RunStepDeltaCodeInterpreterLogOutput(int index = 0, string logs = null) { throw null; }
529529
public static Azure.AI.Projects.RunStepDeltaCodeInterpreterOutput RunStepDeltaCodeInterpreterOutput(int index = 0, string type = null) { throw null; }
530530
public static Azure.AI.Projects.RunStepDeltaCodeInterpreterToolCall RunStepDeltaCodeInterpreterToolCall(int index = 0, string id = null, Azure.AI.Projects.RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = null) { throw null; }
531-
public static Azure.AI.Projects.RunStepDeltaFileSearchToolCall RunStepDeltaFileSearchToolCall(int index = 0, string id = null, System.Collections.Generic.IReadOnlyDictionary<string, string> fileSearch = null) { throw null; }
531+
public static Azure.AI.Projects.RunStepDeltaFileSearchToolCall RunStepDeltaFileSearchToolCall(int index = 0, string id = null, Azure.AI.Projects.RunStepFileSearchToolCallResults fileSearch = null) { throw null; }
532532
public static Azure.AI.Projects.RunStepDeltaFunction RunStepDeltaFunction(string name = null, string arguments = null, string output = null) { throw null; }
533533
public static Azure.AI.Projects.RunStepDeltaFunctionToolCall RunStepDeltaFunctionToolCall(int index = 0, string id = null, Azure.AI.Projects.RunStepDeltaFunction function = null) { throw null; }
534534
public static Azure.AI.Projects.RunStepDeltaMessageCreation RunStepDeltaMessageCreation(Azure.AI.Projects.RunStepDeltaMessageCreationObject messageCreation = null) { throw null; }
@@ -2070,7 +2070,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
20702070
public partial class RunStepDeltaFileSearchToolCall : Azure.AI.Projects.RunStepDeltaToolCall, System.ClientModel.Primitives.IJsonModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>
20712071
{
20722072
internal RunStepDeltaFileSearchToolCall() : base (default(int), default(string)) { }
2073-
public System.Collections.Generic.IReadOnlyDictionary<string, string> FileSearch { get { throw null; } }
2073+
public Azure.AI.Projects.RunStepFileSearchToolCallResults FileSearch { get { throw null; } }
20742074
protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
20752075
Azure.AI.Projects.RunStepDeltaFileSearchToolCall System.ClientModel.Primitives.IJsonModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
20762076
void System.ClientModel.Primitives.IJsonModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }

sdk/ai/Azure.AI.Projects/api/Azure.AI.Projects.netstandard2.0.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public static partial class AIProjectsModelFactory
528528
public static Azure.AI.Projects.RunStepDeltaCodeInterpreterLogOutput RunStepDeltaCodeInterpreterLogOutput(int index = 0, string logs = null) { throw null; }
529529
public static Azure.AI.Projects.RunStepDeltaCodeInterpreterOutput RunStepDeltaCodeInterpreterOutput(int index = 0, string type = null) { throw null; }
530530
public static Azure.AI.Projects.RunStepDeltaCodeInterpreterToolCall RunStepDeltaCodeInterpreterToolCall(int index = 0, string id = null, Azure.AI.Projects.RunStepDeltaCodeInterpreterDetailItemObject codeInterpreter = null) { throw null; }
531-
public static Azure.AI.Projects.RunStepDeltaFileSearchToolCall RunStepDeltaFileSearchToolCall(int index = 0, string id = null, System.Collections.Generic.IReadOnlyDictionary<string, string> fileSearch = null) { throw null; }
531+
public static Azure.AI.Projects.RunStepDeltaFileSearchToolCall RunStepDeltaFileSearchToolCall(int index = 0, string id = null, Azure.AI.Projects.RunStepFileSearchToolCallResults fileSearch = null) { throw null; }
532532
public static Azure.AI.Projects.RunStepDeltaFunction RunStepDeltaFunction(string name = null, string arguments = null, string output = null) { throw null; }
533533
public static Azure.AI.Projects.RunStepDeltaFunctionToolCall RunStepDeltaFunctionToolCall(int index = 0, string id = null, Azure.AI.Projects.RunStepDeltaFunction function = null) { throw null; }
534534
public static Azure.AI.Projects.RunStepDeltaMessageCreation RunStepDeltaMessageCreation(Azure.AI.Projects.RunStepDeltaMessageCreationObject messageCreation = null) { throw null; }
@@ -2070,7 +2070,7 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
20702070
public partial class RunStepDeltaFileSearchToolCall : Azure.AI.Projects.RunStepDeltaToolCall, System.ClientModel.Primitives.IJsonModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>, System.ClientModel.Primitives.IPersistableModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>
20712071
{
20722072
internal RunStepDeltaFileSearchToolCall() : base (default(int), default(string)) { }
2073-
public System.Collections.Generic.IReadOnlyDictionary<string, string> FileSearch { get { throw null; } }
2073+
public Azure.AI.Projects.RunStepFileSearchToolCallResults FileSearch { get { throw null; } }
20742074
protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
20752075
Azure.AI.Projects.RunStepDeltaFileSearchToolCall System.ClientModel.Primitives.IJsonModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
20762076
void System.ClientModel.Primitives.IJsonModel<Azure.AI.Projects.RunStepDeltaFileSearchToolCall>.Write(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }

sdk/ai/Azure.AI.Projects/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "net",
44
"TagPrefix": "net/ai/Azure.AI.Projects",
5-
"Tag": "net/ai/Azure.AI.Projects_c34fc3243d"
5+
"Tag": "net/ai/Azure.AI.Projects_8d76f03633"
66
}

sdk/ai/Azure.AI.Projects/src/Generated/AIProjectsModelFactory.cs

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFileSearchToolCall.Serialization.cs

Lines changed: 5 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/Azure.AI.Projects/src/Generated/RunStepDeltaFileSearchToolCall.cs

Lines changed: 2 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/ai/Azure.AI.Projects/tests/AgentClientTests.cs

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class AgentClientTests : RecordedTestBase<AIProjectsTestEnvironment>
2626
private const string TEMP_DIR = "cs_e2e_temp_dir";
2727

2828
private const string FILE_UPLOAD_CONSTRAINT = "The file is being uploaded as a multipart multipart/form-data, which cannot be recorded.";
29+
private const string STREAMING_CONSTRAINT = "The test framework does not support iteration of stream in Sync mode.";
2930

3031
public AgentClientTests(bool isAsync) : base(isAsync) {
3132
TestDiagnostics = false;
@@ -617,16 +618,24 @@ public async Task TestSubmitToolOutputs(ArgumentType argType, bool parallelToolC
617618
}
618619

619620
[RecordedTest]
620-
[TestCase(VecrorStoreTestType.JustVectorStore, true)]
621-
[TestCase(VecrorStoreTestType.Batch, true)]
622-
[TestCase(VecrorStoreTestType.File, true)]
623-
[TestCase(VecrorStoreTestType.JustVectorStore, false)]
624-
[TestCase(VecrorStoreTestType.Batch, false)]
625-
[TestCase(VecrorStoreTestType.File, false)]
626-
public async Task TestCreateVectorStore(VecrorStoreTestType testType, bool useFileSource)
621+
[TestCase(VecrorStoreTestType.JustVectorStore, true, false)]
622+
[TestCase(VecrorStoreTestType.Batch, true, false)]
623+
[TestCase(VecrorStoreTestType.File, true, false)]
624+
[TestCase(VecrorStoreTestType.JustVectorStore, false, false)]
625+
[TestCase(VecrorStoreTestType.Batch, false, false)]
626+
[TestCase(VecrorStoreTestType.File, false, false)]
627+
[TestCase(VecrorStoreTestType.JustVectorStore, true, true)]
628+
[TestCase(VecrorStoreTestType.Batch, true, true)]
629+
[TestCase(VecrorStoreTestType.File, true, true)]
630+
[TestCase(VecrorStoreTestType.JustVectorStore, false, true)]
631+
[TestCase(VecrorStoreTestType.Batch, false, true)]
632+
[TestCase(VecrorStoreTestType.File, false, true)]
633+
public async Task TestCreateVectorStore(VecrorStoreTestType testType, bool useFileSource, bool useStreaming)
627634
{
628635
if (useFileSource && Mode != RecordedTestMode.Live)
629636
Assert.Inconclusive(FILE_UPLOAD_CONSTRAINT);
637+
if (useStreaming && !IsAsync)
638+
Assert.Inconclusive(STREAMING_CONSTRAINT);
630639
AgentsClient client = GetClient();
631640
VectorStore vectorStore;
632641

@@ -693,11 +702,29 @@ await client.CreateVectorStoreFileAsync(
693702
role: MessageRole.User,
694703
content: "What does the attachment say?"
695704
));
696-
ThreadRun fileSearchRun = await client.CreateThreadAndRunAsync(
697-
assistantId: agent.Id,
698-
thread: threadOp
699-
);
700-
fileSearchRun = await WaitForRun(client, fileSearchRun);
705+
ThreadRun fileSearchRun = default;
706+
if (useStreaming)
707+
{
708+
AgentThread thread = await client.CreateThreadAsync(messages: [new ThreadMessageOptions(
709+
role: MessageRole.User,
710+
content: "What does the attachment say?"
711+
)]);
712+
await foreach (StreamingUpdate streamingUpdate in client.CreateRunStreamingAsync(thread.Id, agent.Id))
713+
{
714+
if (streamingUpdate is RunUpdate runUpdate)
715+
fileSearchRun = runUpdate.Value;
716+
}
717+
Assert.AreEqual(RunStatus.Completed, fileSearchRun.Status, fileSearchRun.LastError?.ToString());
718+
}
719+
else
720+
{
721+
fileSearchRun = await client.CreateThreadAndRunAsync(
722+
assistantId: agent.Id,
723+
thread: threadOp
724+
);
725+
fileSearchRun = await WaitForRun(client, fileSearchRun);
726+
}
727+
Assert.IsNotNull(fileSearchRun);
701728
PageableList<ThreadMessage> messages = await client.GetMessagesAsync(fileSearchRun.ThreadId, fileSearchRun.Id);
702729
Assert.Greater(messages.Data.Count, 1);
703730
// Check list, get and delete operations.
@@ -892,7 +919,7 @@ public async Task TestCreateVectorStoreOnline()
892919
public async Task TestIncludeFileSearchContent(bool useStream, bool includeContent)
893920
{
894921
if (useStream && !IsAsync)
895-
Assert.Inconclusive("The test framework does not support iteration of stream in Sync mode.");
922+
Assert.Inconclusive(STREAMING_CONSTRAINT);
896923
AgentsClient client = GetClient();
897924
VectorStoreDataSource vectorStoreDataSource = new(
898925
assetIdentifier: TestEnvironment.AZURE_BLOB_URI,
@@ -1229,7 +1256,7 @@ private async Task<ThreadRun> WaitForRun(AgentsClient client, ThreadRun run)
12291256
while (run.Status == RunStatus.Queued
12301257
|| run.Status == RunStatus.InProgress
12311258
|| run.Status == RunStatus.RequiresAction);
1232-
Assert.AreEqual(RunStatus.Completed, run.Status);
1259+
Assert.AreEqual(RunStatus.Completed, run.Status, message: run.LastError?.ToString());
12331260
return run;
12341261
}
12351262

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Information about product item_number: 1
2+
3+
## Brand
4+
Contoso Galaxy Innovations
5+
6+
## Category
7+
Smart Eyewear
8+
9+
## Features
10+
- Augmented Reality interface
11+
- Voice-controlled AI assistant
12+
- HD video recording with 3D audio
13+
- UV protection and blue light filtering
14+
- Wireless charging with extended battery life
15+
16+
## User Guide
17+
18+
### 1. Introduction
19+
Introduction to your new SmartView Glasses
20+
21+
### 2. Product Overview
22+
Overview of features and controls
23+
24+
### 3. Sizing and Fit
25+
Finding your perfect fit and style adjustments
26+
27+
### 4. Proper Care and Maintenance
28+
Cleaning and caring for your SmartView Glasses
29+
30+
### 5. Break-in Period
31+
Adjusting to the augmented reality experience
32+
33+
### 6. Safety Tips
34+
Safety guidelines for public and private spaces
35+
36+
### 7. Troubleshooting
37+
Quick fixes for common issues
38+
39+
## Warranty Information
40+
Two-year limited warranty on all electronic components
41+
42+
## Contact Information
43+
Customer Support at [email protected]
44+
45+
## Return Policy
46+
30-day return policy with no questions asked
47+
48+
## FAQ
49+
- How to sync your SmartView Glasses with your devices
50+
- Troubleshooting connection issues
51+
- Customizing your augmented reality environment
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
directory: specification/ai/Azure.AI.Projects
2-
commit: 6e507701253408679175e95176995c437f8e00d4
2+
commit: 27e45fc03fd2698e3ad9b2799b313f289daeb142
33
repo: Azure/azure-rest-api-specs
44
additionalDirectories:

0 commit comments

Comments
 (0)