Skip to content

Commit 7ccb7af

Browse files
Incorporate code changes for Windows App SDK 1.8-experimental1
1 parent c5b8751 commit 7ccb7af

File tree

6 files changed

+44
-44
lines changed

6 files changed

+44
-44
lines changed

docs/apis/get-started.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,18 @@ The following snippet shows how to check for model availability and generate a r
197197
if (LanguageModel.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
198198
{
199199
var result = await LanguageModel.EnsureReadyAsync();
200-
if (result.Status != PackageDeploymentStatus.CompletedSuccess)
200+
if (result.Status != AIFeatureReadyResultState.Success)
201201
{
202-
throw new Exception(result.ExtendedError().Message);
202+
throw new Exception(result.ExtendedError.Message);
203203
}
204204
}
205205

206206
using LanguageModel languageModel =
207207
await LanguageModel.CreateAsync();
208208

209209
string prompt = "Provide the molecular formula of glucose.";
210-
var result = await languageModel.GenerateResponseAsync(prompt);
211-
OutputText.Text = result.Response;
210+
var response = await languageModel.GenerateResponseAsync(prompt);
211+
OutputText.Text = response.Text;
212212
}
213213
}
214214
```
@@ -249,17 +249,17 @@ The following snippet shows how to check for model availability and generate a r
249249
if (LanguageModel.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
250250
{
251251
var result = await LanguageModel.EnsureReadyAsync();
252-
if (result.Status != PackageDeploymentStatus.CompletedSuccess)
252+
if (result.Status != AIFeatureReadyResultState.Success)
253253
{
254-
throw new Exception(result.ExtendedError().Message);
254+
throw new Exception(result.ExtendedError.Message);
255255
}
256256
}
257257

258258
using LanguageModel languageModel = await LanguageModel.CreateAsync();
259259

260260
string prompt = "Provide the molecular formula for glucose.";
261-
var result = await languageModel.GenerateResponseAsync(prompt);
262-
OutputText.Text = result.Response;
261+
var response = await languageModel.GenerateResponseAsync(prompt);
262+
OutputText.Text = response.Text;
263263
}
264264
}
265265
```
@@ -296,17 +296,17 @@ The following snippet shows how to check for model availability and generate a r
296296
if (LanguageModel.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
297297
{
298298
var result = await LanguageModel.EnsureReadyAsync();
299-
if (result.Status != PackageDeploymentStatus.CompletedSuccess)
299+
if (result.Status != AIFeatureReadyResultState.Success)
300300
{
301-
throw new Exception(result.ExtendedError().Message);
301+
throw new Exception(result.ExtendedError.Message);
302302
}
303303
}
304304

305305
using LanguageModel languageModel = await LanguageModel.CreateAsync();
306306

307307
string prompt = "Provide the molecular formula for glucose.";
308-
var result = await languageModel.GenerateResponseAsync(prompt);
309-
OutputLabel.Text = result.Response;
308+
var response = await languageModel.GenerateResponseAsync(prompt);
309+
OutputLabel.Text = response.Text;
310310
}
311311
}
312312
```

docs/apis/imaging-tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ In the second file listed above, you'll find the following function, which demon
5656
if (ImageScaler.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
5757
{
5858
var op = await ImageScaler.EnsureReadyAsync();
59-
if (op.Status != PackageDeploymentStatus.CompletedSuccess)
59+
if (op.Status != AIFeatureReadyResultState.Success)
6060
{
61-
throw new Exception(op.ExtendedError().Message);
61+
throw new Exception(op.ExtendedError.Message);
6262
}
6363
}
6464

docs/apis/imaging.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using Windows.Graphics.Imaging;
4646
if (ImageScaler.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
4747
{
4848
var result = await ImageScaler.EnsureReadyAsync();
49-
if (result.Status != PackageDeploymentStatus.CompletedSuccess)
49+
if (result.Status != AIFeatureReadyResultState.Success)
5050
{
5151
throw result.ExtendedError;
5252
}
@@ -69,7 +69,7 @@ using namespace winrt::Windows::Graphics::Imaging;
6969
if (ImageScaler::GetReadyState() == AIFeatureReadyState::EnsureNeeded)
7070
{
7171
winrt::PackageDeploymentResult result = ImageScaler::EnsureReadyAsync().get();
72-
if (result.Status() != PackageDeploymentStatus::CompletedSuccess)
72+
if (result.Status() != AIFeatureReadyResultState::Success)
7373
{
7474
throw result.ExtendedError();
7575
}
@@ -128,7 +128,7 @@ using Windows.Graphics.Imaging;
128128
if (ImageDescriptionGenerator.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
129129
{
130130
var result = await ImageDescriptionGenerator.EnsureReadyAsync();
131-
if (result.Status != PackageDeploymentStatus.CompletedSuccess)
131+
if (result.Status != AIFeatureReadyResultState.Success)
132132
{
133133
throw result.ExtendedError;
134134
}
@@ -145,8 +145,8 @@ filterOptions.PromptMinSeverityLevelToBlock.ViolentContentSeverity = SeverityLev
145145
filterOptions.ResponseMinSeverityLevelToBlock.ViolentContentSeverity = SeverityLevel.Medium;
146146

147147
// Get text description.
148-
LanguageModelResponse languageModelResponse = await imageDescriptionGenerator.DescribeAsync(inputImage, ImageDescriptionScenario.Caption, filterOptions);
149-
string response = languageModelResponse.Response;
148+
LanguageModelResponseResult languageModelResponseResult = await imageDescriptionGenerator.DescribeAsync(inputImage, ImageDescriptionScenario.Caption, filterOptions);
149+
string response = languageModelResponseResult.Text;
150150

151151
```
152152

@@ -171,7 +171,7 @@ using namespace winrt::Windows::Storage::StorageFile;
171171
if (ImageDescriptionGenerator::GetReadyState() == AIFeatureReadyState::EnsureNeeded)
172172
{
173173
winrt::PackageDeploymentResult result = ImageDescriptionGenerator::EnsureReadyAsync().get();
174-
if (result.Status() != PackageDeploymentStatus::CompletedSuccess)
174+
if (result.Status() != AIFeatureReadyResultState::Success)
175175
{
176176
throw result.ExtendedError();
177177
}
@@ -188,8 +188,8 @@ auto inputBuffer = ImageBuffer::CreateCopyFromBitmap(softwareBitmap);
188188

189189

190190
// Get text description.
191-
LanguageModelResponse languageModelResponse = imageDescriptionGenerator.DescribeAsync(inputImage, ImageDescriptionScenario::Caption, contentFilter).get();
192-
string text = languageModelResponse.Response();
191+
LanguageModelResponseResult languageModelResponseResult = imageDescriptionGenerator.DescribeAsync(inputImage, ImageDescriptionScenario::Caption, contentFilter).get();
192+
string text = languageModelResponseResult.Text();
193193
```
194194

195195
## What can I do with Image Segmentation?
@@ -233,7 +233,7 @@ using Windows.Graphics.Imaging;
233233
if (ImageObjectExtractor::GetReadyState() == AIFeatureReadyState.EnsureNeeded)
234234
{
235235
var result = await ImageObjectExtractor.EnsureReadyAsync();
236-
if (result.Status != PackageDeploymentStatus.CompletedSuccess)
236+
if (result.Status != AIFeatureReadyResultState.Success)
237237
{
238238
throw result.ExtendedError;
239239
}
@@ -263,7 +263,7 @@ using namespace winrt::Windows::Foundation;
263263
if (ImageObjectExtractor::GetReadyState() == AIFeatureReadyState::EnsureNeeded)
264264
{
265265
winrt::PackageDeploymentResult result = ImageObjectExtractor::EnsureReadyAsync().get();
266-
if (result.Status() != PackageDeploymentStatus::CompletedSuccess)
266+
if (result.Status() != AIFeatureReadyResultState::Success)
267267
{
268268
throw result.ExtendedError();
269269
}
@@ -355,7 +355,7 @@ using Windows.Graphics.Imaging;
355355
if (ImageObjectRemover::GetReadyState() == AIFeatureReadyState.EnsureNeeded)
356356
{
357357
var result = await ImageObjectRemover.EnsureReadyAsync();
358-
if (result.Status != PackageDeploymentStatus.CompletedSuccess)
358+
if (result.Status != AIFeatureReadyResultState.Success)
359359
{
360360
throw result.ExtendedError;
361361
}
@@ -377,7 +377,7 @@ using namespace winrt::Windows::Foundation;
377377
if (ImageObjectRemover::GetReadyState() == AIFeatureReadyState::EnsureNeeded)
378378
{
379379
winrt::PackageDeploymentResult result = ImageObjectRemover::EnsureReadyAsync().get();
380-
if (result.Status() != PackageDeploymentStatus::CompletedSuccess)
380+
if (result.Status() != AIFeatureReadyResultState::Success)
381381
{
382382
throw result.ExtendedError();
383383
}

docs/apis/phi-silica-tutorial.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ In the second file listed above, you'll find the following function, which demon
3232
{
3333
answer.Text = "Making LanguageModel available...";
3434
var op = await LanguageModel.EnsureReadyAsync();
35-
if (op.Status != PackageDeploymentStatus.CompletedSuccess)
35+
if (op.Status != AIFeatureReadyResultState.Success)
3636
{
37-
throw new Exception(op.ExtendedError().Message);
37+
throw new Exception(op.ExtendedError.Message);
3838
}
3939
}
4040

@@ -44,7 +44,7 @@ In the second file listed above, you'll find the following function, which demon
4444
string prompt = entryPrompt.Text;
4545

4646
answer.Text = "Generating response...";
47-
Windows.Foundation.AsyncOperationProgressHandler<LanguageModelResponse, string>
47+
Windows.Foundation.AsyncOperationProgressHandler<LanguageModelResponseResult, string>
4848
progressHandler = (asyncInfo, delta) =>
4949
{
5050
System.Diagnostics.Debug.WriteLine($"Progress: {delta}");
@@ -58,8 +58,8 @@ In the second file listed above, you'll find the following function, which demon
5858

5959
asyncOp.Progress = progressHandler;
6060

61-
var result = await asyncOp;
62-
System.Diagnostics.Debug.WriteLine("DONE: " + result.Response);
61+
var response = await asyncOp;
62+
System.Diagnostics.Debug.WriteLine("DONE: " + response.Text);
6363
}
6464
```
6565
![The sample app after calling the ImageScaler and LanguageModel APIs.](../images/API-Tutorial-MAUIappimage2(aftercallingSuperResandLanguageModelAPIs).png)

docs/apis/phi-silica.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,22 +135,22 @@ This example shows how to generate a response to a Q&A prompt where the response
135135

136136
1. Create a **LanguageModel** object to reference the local language model. *A check has already been performed to ensure the Phi Silica language model is available on the user's device in the previous snippet.
137137

138-
1. Asynchronously retrieve the **LanguageModelResponse** in a call to **GenerateResponseWithProgressAsync**. Write it to the console as the response is generated.
138+
1. Asynchronously retrieve the **LanguageModelResponseResult** in a call to **GenerateResponseAsync**. Write it to the console as the response is generated.
139139

140140
### [C#](#tab/csharp2)
141141
```csharp
142142
using LanguageModel languageModel = await LanguageModel.CreateAsync();
143143

144144
string prompt = "Introduce yourself.";
145145

146-
AsyncOperationProgressHandler<LanguageModelResponse, string>
146+
AsyncOperationProgressHandler<LanguageModelResponseResult, string>
147147
progressHandler = (asyncInfo, delta) =>
148148
{
149149
Console.WriteLine($"Progress: {delta}");
150-
Console.WriteLine($"Response so far: {asyncInfo.GetResults().Response}");
150+
Console.WriteLine($"Response so far: {asyncInfo.GetResults().Text}");
151151
};
152152

153-
var asyncOp = languageModel.GenerateResponseWithProgressAsync(prompt);
153+
var asyncOp = languageModel.GenerateResponseAsync(prompt);
154154

155155
asyncOp.Progress = progressHandler;
156156

@@ -165,14 +165,14 @@ auto languageModel = LanguageModel::CreateAsync().get();
165165

166166
std::string prompt = "Introduce yourself.";
167167

168-
AsyncOperationProgressHandler<LanguageModelResponse, std::string> progressHandler =
169-
[](const IAsyncOperationWithProgress<LanguageModelResponse, std::string>& asyncInfo, const std::string& delta)
168+
AsyncOperationProgressHandler<LanguageModelResponseResult, std::string> progressHandler =
169+
[](const IAsyncOperationWithProgress<LanguageModelResponseResult, std::string>& asyncInfo, const std::string& delta)
170170
{
171171
std::cout << "Progress: " << delta << std::endl;
172-
std::cout << "Response so far: " << asyncInfo.GetResults().Response << std::endl;
172+
std::cout << "Response so far: " << asyncInfo.GetResults().Text << std::endl;
173173
};
174174

175-
auto asyncOp = languageModel.GenerateResponseWithProgressAsync(prompt);
175+
auto asyncOp = languageModel.GenerateResponseAsync(prompt);
176176

177177
asyncOp.Progress(progressHandler);
178178

@@ -201,7 +201,7 @@ Phi Silica includes the ability to predefine text response formats for use in yo
201201
| **LanguageModelSkill.Summarize** | Return a summary based on the prompt text. |
202202
| **LanguageModelSkill.Rewrite** | Rewrite the prompt text response to improve clarity and comprehension. |
203203
204-
3. Then we asynchronously retrieve the **LanguageModelResponse** in a call to **GenerateResponseWithProgressAsync** and write it to the console as the response is generated.
204+
3. Then we asynchronously retrieve the **LanguageModelResponseResult** in a call to **GenerateResponseAsync** and write it to the console as the response is generated.
205205
206206
### [C#](#tab/csharp3)
207207
```csharp

docs/apis/text-recognition.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ public async Task<TextRecognizer> EnsureModelIsReady()
121121
if (TextRecognizer.GetReadyState() == AIFeatureReadyState.EnsureNeeded)
122122
{
123123
var loadResult = await TextRecognizer.EnsureReadyAsync();
124-
if (loadResult.Status != PackageDeploymentStatus.CompletedSuccess)
124+
if (loadResult.Status != AIFeatureReadyResultState.Success)
125125
{
126-
throw new Exception(loadResult.ExtendedError().Message);
126+
throw new Exception(loadResult.ExtendedError.Message);
127127
}
128128
}
129129
@@ -160,9 +160,9 @@ winrt::IAsyncOperation<winrt::TextRecognizer> EnsureModelIsReady()
160160
if (winrt::TextRecognizer::GetReadyState() == AIFeatureReadyState::EnsureNeeded)
161161
{
162162
auto loadResult = co_await winrt::TextRecognizer::EnsureReadyAsync();
163-
if (loadResult.Status() != winrt::PackageDeploymentStatus::CompletedSuccess)
163+
if (loadResult.Status() != winrt::AIFeatureReadyResultState::Success)
164164
{
165-
throw winrt::hresult_error(loadResult.ExtendedError());
165+
throw winrt::hresult_error(loadResult.ExtendedError);
166166
}
167167
}
168168

0 commit comments

Comments
 (0)