Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
238 commits
Select commit Hold shift + click to select a range
e8507e3
Added WRC APIs.
azchohfi Dec 12, 2024
de4ef5f
Merge branch 'main' into alzollin/wcrapis
nmetulev Dec 13, 2024
3eae6d3
combine image enhance samples in the same scenario
nmetulev Dec 13, 2024
2d63ce8
Merge branch 'main' into alzollin/wcrapis
azchohfi Dec 13, 2024
30bc603
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
azchohfi Dec 13, 2024
f3a78ff
Small comment.
azchohfi Dec 13, 2024
8e1b849
loading message when models are downloading in Windows Update
nmetulev Dec 13, 2024
e9e0f2c
changed apis to qnn hardware accelerator
nmetulev Dec 16, 2024
9bada3c
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
azchohfi Jan 6, 2025
572adb4
Merge branch 'main' into alzollin/wcrapis
azchohfi Jan 6, 2025
a0b5275
Update WCR icon
niels9001 Jan 7, 2025
9e29510
Merge branch 'main' into alzollin/wcrapis
azchohfi Jan 9, 2025
39d92a2
Fix NavBar
niels9001 Jan 11, 2025
331cd19
WCR Image Description Sample
brunosonnino Jan 14, 2025
5e8be5a
Fix warnings
brunosonnino Jan 14, 2025
14b7949
Merge with public main
brunosonnino Jan 27, 2025
cd3b92e
Custom parameters for Phi-Silica
brunosonnino Jan 29, 2025
34bb84d
OCR Lines Sample
brunosonnino Jan 29, 2025
f549cae
Cange method names
brunosonnino Jan 29, 2025
cb977f5
Fix warnings
brunosonnino Jan 29, 2025
d3313b2
WCR UX
niels9001 Feb 4, 2025
3d1bb4f
WCR page
niels9001 Feb 4, 2025
e2a0e0f
Making API nav work
niels9001 Feb 6, 2025
ef37ead
Make navigation work
niels9001 Feb 6, 2025
ec7d08e
Update WCROverview.xaml
niels9001 Feb 6, 2025
01d4ead
Better subnavi
niels9001 Feb 6, 2025
01b6031
Fixing gradient brushes
niels9001 Feb 6, 2025
7d33697
Merge branch 'main' into alzollin/wcrapis
azchohfi Feb 6, 2025
df38c71
Updated WinAppSDK version.
azchohfi Feb 6, 2025
2a45ad1
Update apis.json
niels9001 Feb 6, 2025
6208f68
Merge branch 'alzollin/wcrapis' into niels9001/wcr-ux
niels9001 Feb 6, 2025
05de1e6
Merge branch 'main' into alzollin/wcrapis
azchohfi Feb 7, 2025
18e3b4a
Update to stable winappsdk.
azchohfi Feb 7, 2025
9f5ec8c
Merge pull request #3 from microsoft/niels9001/wcr-ux
nmetulev Feb 7, 2025
4a0e999
Small fix.
azchohfi Feb 7, 2025
ee6547d
Removed unused using statement.
azchohfi Feb 7, 2025
4161dc3
handle IsAvailable exception
nmetulev Feb 7, 2025
ccdbf8c
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
nmetulev Feb 7, 2025
eb7b203
Small fix for project export.
azchohfi Feb 7, 2025
3de88a6
Fix image description sample name.
azchohfi Feb 7, 2025
dadcbac
Changed to official marketing names.
azchohfi Feb 7, 2025
91c6691
UX tweaks
niels9001 Feb 10, 2025
4803fc4
OCR sample cleanup
niels9001 Feb 10, 2025
60740c0
Update OCRSample.xaml
niels9001 Feb 10, 2025
9c36db3
Clean OCR lines sample
niels9001 Feb 10, 2025
321e43d
More cleanup of WCR samples
niels9001 Feb 10, 2025
cd40176
CI fixes
niels9001 Feb 10, 2025
95e77d3
Lowered the max points for WCR Remove background
Jaylyn-Barbee Feb 10, 2025
e66acc7
Merge pull request #177 from microsoft/jay/thirty-two-limit
zateutsch Feb 10, 2025
7039748
Merge branch 'main' into alzollin/wcrapis
nmetulev Feb 11, 2025
054f096
testing wcr api compatibility
nmetulev Feb 11, 2025
55c85e5
improve api checker to use types instead of strings
nmetulev Feb 11, 2025
4a583ab
added all api compatibility checker
nmetulev Feb 11, 2025
008a51b
added new hardware accelerator and added wcr api filter option
nmetulev Feb 11, 2025
d06526e
sort wcr apis first
nmetulev Feb 11, 2025
81f0a7f
Paste images from Explorer Copy
brunosonnino Feb 11, 2025
1d130e3
put scale image in a task
zateutsch Feb 11, 2025
7697366
Fixes issues related to API naming, capitilization, and scenario nami…
zateutsch Feb 11, 2025
140d58d
Merge pull request #191 from microsoft/zt/171-capitlization-and-naming
niels9001 Feb 11, 2025
ea445ef
Merge with current version
brunosonnino Feb 11, 2025
f1adc2f
Fixes for merge
brunosonnino Feb 11, 2025
2302522
minor cleanup
nmetulev Feb 12, 2025
ccc75df
Adding WcrModelDownloader
nmetulev Feb 12, 2025
3f4f9bb
Fix duplicate sample name in tests
zateutsch Feb 12, 2025
ae7b9a4
Added regex to replace MS Docs specific md callouts
Jaylyn-Barbee Feb 12, 2025
c50780b
Support for user controls as shared code
nmetulev Feb 12, 2025
547bd32
Merge branch 'alzollin/wcrapis' into nmetulev/wcrapis2
azchohfi Feb 12, 2025
833bae2
Fix for user controls in project generator
nmetulev Feb 12, 2025
fb1e795
Added WcrModelDownloader to WCR samples
nmetulev Feb 12, 2025
01f1b3f
Merge pull request #195 from microsoft/jay/md-format
nmetulev Feb 12, 2025
e525be2
Make sure image doesn't take all the space
nmetulev Feb 12, 2025
18d7cf3
Merge branch 'alzollin/wcrapis' into bsonnino/paste_from_explorer
nmetulev Feb 12, 2025
2e3cc98
Merge branch 'alzollin/wcrapis' into nmetulev/wcrapis2
nmetulev Feb 12, 2025
a480951
APIs in ModelPicker have the right options that work
nmetulev Feb 12, 2025
d3abf8e
Remove IsImageFile function from Utils.cs
brunosonnino Feb 13, 2025
0433f21
Merge branch 'bsonnino/paste_from_explorer' of https://github.com/mic…
brunosonnino Feb 13, 2025
4aec77e
Merge pull request #193 from microsoft/bsonnino/paste_from_explorer
nmetulev Feb 13, 2025
c47ad1a
Merge branch 'alzollin/wcrapis' into nmetulev/wcrapis2
nmetulev Feb 13, 2025
68d2e74
Merge branch 'main' into alzollin/wcrapis
azchohfi Feb 13, 2025
2241160
addressing pr feedback
nmetulev Feb 13, 2025
61924b7
Merge branch 'alzollin/wcrapis' into nmetulev/wcrapis2
nmetulev Feb 13, 2025
fc8f5bd
fix relative links in wcr docs
zateutsch Feb 13, 2025
653402e
try to describe image duplicate
zateutsch Feb 13, 2025
15067ef
Update AIDevGallery/Pages/ModelPage.xaml.cs
zateutsch Feb 13, 2025
b5fb777
Merge branch 'zt/182-wcr-fixes' into zt/wcr-scenario-fixes
zateutsch Feb 13, 2025
f1dd908
Merge branch 'alzollin/wcrapis' into zt/183-image-scaling-freezes
zateutsch Feb 13, 2025
6c80038
fix identing
zateutsch Feb 13, 2025
4e6acda
Addressed PR Comments
nmetulev Feb 13, 2025
6d87b2b
Merge branch 'nmetulev/wcrapis2' of https://github.com/microsoft/ai-d…
nmetulev Feb 13, 2025
b1191fa
fixed bug with multiple samples per scenario
nmetulev Feb 13, 2025
9850f89
Merge pull request #203 from microsoft/zt/183-image-scaling-freezes
nmetulev Feb 13, 2025
ee6e0bb
Merge branch 'alzollin/wcrapis' into zt/184-wcr-fixes
nmetulev Feb 13, 2025
ae27c90
Update AIDevGallery/Pages/ModelPage.xaml.cs
nmetulev Feb 13, 2025
fbc2036
Merge pull request #202 from microsoft/zt/184-wcr-fixes
nmetulev Feb 13, 2025
f60d141
Merge branch 'alzollin/wcrapis' into nmetulev/wcrapis2
nmetulev Feb 13, 2025
dcfdb6b
Merge branch 'main' into alzollin/wcrapis
nmetulev Feb 13, 2025
f6d54f6
Merge branch 'alzollin/wcrapis' into nmetulev/wcrapis2
nmetulev Feb 13, 2025
f9de27f
Merge pull request #194 from microsoft/nmetulev/wcrapis2
nmetulev Feb 13, 2025
26686d6
Update AIDevGallery.SourceGenerator/SamplesSourceGenerator.cs
nmetulev Feb 13, 2025
1260ef9
Added missing log events to wcr samples
nmetulev Feb 13, 2025
7358041
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
nmetulev Feb 13, 2025
62a6654
Merge branch 'main' into alzollin/wcrapis
niels9001 Feb 14, 2025
1643bb6
Merge branch 'main' into alzollin/wcrapis
niels9001 Feb 14, 2025
3806ab2
Fixes
niels9001 Feb 14, 2025
9a00676
API page
niels9001 Feb 14, 2025
6e3756f
More UI tweaks
niels9001 Feb 14, 2025
8e08ac9
Merge branch 'alzollin/wcrapis' into zt/wcr-scenario-fixes
zateutsch Feb 14, 2025
f56484a
Merge pull request #210 from microsoft/zt/wcr-scenario-fixes
nmetulev Feb 14, 2025
0618552
Merge branch 'main' into alzollin/wcrapis
nmetulev Feb 14, 2025
d60825a
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
nmetulev Feb 14, 2025
51d16c1
Rollback Behaviors to 2.x.
azchohfi Feb 14, 2025
fdefde4
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
nmetulev Feb 15, 2025
7954ec6
Hooking up samples and code snippets in api page
nmetulev Feb 16, 2025
641e5e5
Update APIPage.xaml
niels9001 Feb 17, 2025
c02093b
Updated background removal and UX flow
zateutsch Feb 18, 2025
e9355f9
style and bug fix
nmetulev Feb 18, 2025
c23ac05
sample container can handle phi silica samples, and cache download re…
nmetulev Feb 18, 2025
04b3289
UI tweaks
niels9001 Feb 18, 2025
7865a8c
Add a note about building for ARM64 v/s x64 in README.md
shyamnamboodiripad Feb 18, 2025
01cb267
Update AIDevGallery/Samples/WCRAPIs/BackgroundRemover.xaml
zateutsch Feb 18, 2025
a207451
Make sure Api code can be viewed if unavailable, clean up code
nmetulev Feb 18, 2025
2dc71d5
fix default state in downloader
nmetulev Feb 18, 2025
5797a9b
Merge pull request #216 from shyamnamboodiripad/update-readme
nmetulev Feb 19, 2025
d7011dd
Merge branch 'alzollin/wcrapis' into nmetulev/better-wcr-model-downlo…
nmetulev Feb 19, 2025
3e34e3c
Merge branch 'main' into alzollin/wcrapis
nmetulev Feb 19, 2025
d84594b
Merge branch 'alzollin/wcrapis' into nmetulev/better-wcr-model-downlo…
nmetulev Feb 19, 2025
0a1805e
Added WcrApiDownload Log events
nmetulev Feb 19, 2025
e4582c7
Added missing events
nmetulev Feb 19, 2025
378f428
Tweaks
niels9001 Feb 19, 2025
331f581
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
niels9001 Feb 19, 2025
659c6b0
Added NPU check
nmetulev Feb 19, 2025
ab66ca6
removed empty scenario
nmetulev Feb 19, 2025
beff8b2
Merge branch 'alzollin/wcrapis' into zt/209-wcr-sample-cleanup
nmetulev Feb 19, 2025
54c318b
Moved HasNpu method to AppUtils.
azchohfi Feb 20, 2025
8096344
Added tests for PhiSilica vs GenAI project exports.
azchohfi Feb 20, 2025
d6ce3cd
Apply suggestions from code review
nmetulev Feb 20, 2025
009573a
PR feedback
nmetulev Feb 20, 2025
2b80d5b
Merge pull request #217 from microsoft/nmetulev/better-wcr-model-down…
nmetulev Feb 20, 2025
d558d35
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
nmetulev Feb 20, 2025
fae573f
post merge cleanup
nmetulev Feb 20, 2025
092732f
Merge branch 'alzollin/wcrapis' into alzollin/moreTests
nmetulev Feb 20, 2025
46a2e82
fix build
nmetulev Feb 20, 2025
6e94de6
Merge branch 'alzollin/wcrapis' into alzollin/moreTests
azchohfi Feb 20, 2025
f8e76b6
Fix build.
azchohfi Feb 20, 2025
69cc553
Decreased path length.
azchohfi Feb 20, 2025
77b9413
Adding missing file for PhiSilica exported projects.
azchohfi Feb 20, 2025
da4c68e
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
niels9001 Feb 20, 2025
082f4e7
Fixes
niels9001 Feb 20, 2025
47c33e4
Address feedback + minor bugfixes
niels9001 Feb 20, 2025
3107bd0
Update BackgroundRemover.xaml
niels9001 Feb 20, 2025
8e4654c
Update BackgroundRemover.xaml
niels9001 Feb 20, 2025
bf2db80
Merge pull request #215 from microsoft/zt/209-wcr-sample-cleanup
niels9001 Feb 20, 2025
faf18f3
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
niels9001 Feb 20, 2025
07b16b9
Update BackgroundRemover.xaml.cs
niels9001 Feb 20, 2025
128fdc9
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
niels9001 Feb 20, 2025
d705b42
New card control
niels9001 Feb 20, 2025
99a94f7
Changes
niels9001 Feb 20, 2025
203b115
Changes in the prompt sytem for Phi-Silica
brunosonnino Feb 20, 2025
d61917c
More tweaks
niels9001 Feb 20, 2025
167ae72
Making it POP ✨
niels9001 Feb 20, 2025
4e5c3ad
Update SampleContainer.xaml
niels9001 Feb 20, 2025
6e0920b
Update BackgroundRemover.xaml
niels9001 Feb 20, 2025
f97c7a4
Merge branch 'alzollin/wcrapis' into bsonnino/system_prompt_pi_silica
azchohfi Feb 20, 2025
f88adf6
Refactor creation of LanguageModelContext
brunosonnino Feb 20, 2025
c2d488b
Merge branch 'bsonnino/system_prompt_pi_silica' of https://github.com…
brunosonnino Feb 20, 2025
1838cf4
Merge branch 'main' into alzollin/wcrapis
azchohfi Feb 20, 2025
d42604d
Merge branch 'alzollin/wcrapis' into bsonnino/system_prompt_pi_silica
azchohfi Feb 20, 2025
099c25c
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
azchohfi Feb 20, 2025
bc806e8
Merge branch 'alzollin/wcrapis' into alzollin/moreTests
azchohfi Feb 20, 2025
dbeb62f
Merge pull request #222 from microsoft/bsonnino/system_prompt_pi_silica
brunosonnino Feb 20, 2025
813bf8d
Fixed BackgroundRemover LoadMoedelAsync signature.
azchohfi Feb 20, 2025
5abe610
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
azchohfi Feb 20, 2025
b9d8e6b
Fixed build.
azchohfi Feb 20, 2025
169ccfd
Merge branch 'alzollin/wcrapis' into alzollin/moreTests
azchohfi Feb 20, 2025
3c3ffa8
Merge branch 'alzollin/wcrapis' into niels9001/wcr-page
azchohfi Feb 20, 2025
946a2b2
Removed LlmPromptTemplate from PhiSilica exported samples.
azchohfi Feb 20, 2025
ad30020
Slight cleanup of describe image wcr
zateutsch Feb 20, 2025
d8d0d35
Merge pull request #207 from microsoft/niels9001/wcr-page
nmetulev Feb 20, 2025
75fd022
Merge branch 'alzollin/wcrapis' into alzollin/moreTests
nmetulev Feb 20, 2025
914e1ed
Merge branch 'alzollin/wcrapis' into zt/describe-image-wcr-update
nmetulev Feb 20, 2025
b41393d
minor fix for wcrmodeldownloader
nmetulev Feb 20, 2025
7aee9d8
Merge branch 'main' into alzollin/wcrapis
nmetulev Feb 20, 2025
a81f745
fix build
nmetulev Feb 20, 2025
082eb4e
Merge branch 'alzollin/wcrapis' into alzollin/moreTests
nmetulev Feb 20, 2025
e612b13
Cleaned up shared folder a bit
nmetulev Feb 20, 2025
b4f884f
Removed ChatOptionsHelper
nmetulev Feb 21, 2025
f7adb81
Small fix.
azchohfi Feb 21, 2025
f5cae7e
Merge pull request #220 from microsoft/alzollin/moreTests
azchohfi Feb 21, 2025
9267c0c
Merge branch 'alzollin/wcrapis' into zt/describe-image-wcr-update
azchohfi Feb 21, 2025
3f61f2e
Fixed build for shipping.
azchohfi Feb 21, 2025
4c7caae
Updated version to 0.3.0
azchohfi Feb 21, 2025
4352a7d
Set version to '0.3.0'
azchohfi Feb 21, 2025
d04dfae
Set version to '0.3.1-alpha'
azchohfi Feb 21, 2025
c1f936a
Merge branch 'rel/v0.3.0'
azchohfi Feb 21, 2025
cf10ba3
Merged ocr to one sample with text overlay and toggle
zateutsch Feb 21, 2025
e69df32
resolve merge
zateutsch Feb 21, 2025
538da08
Fixed tests.
azchohfi Feb 21, 2025
10d36ef
Removed un-used xaml usings.
azchohfi Feb 21, 2025
6ce5f3d
Revert "Fixed build for shipping."
azchohfi Feb 21, 2025
f1ca7e0
Split ExpFix.
azchohfi Feb 21, 2025
b34be5e
Rollback version.
azchohfi Feb 21, 2025
bb71a62
Set version to '0.3.0'
azchohfi Feb 21, 2025
68cdd4c
Set version to '0.3.1-alpha'
azchohfi Feb 21, 2025
b65bda6
Merge branch 'rel/v0.3.0'
azchohfi Feb 21, 2025
a390e6c
Revert "removing titlebar in favor of winui titlebar"
azchohfi Feb 21, 2025
bf5c57a
Revert version once more.
azchohfi Feb 21, 2025
176801e
Set version to '0.3.0'
azchohfi Feb 21, 2025
8de5ef3
Set version to '0.3.1-alpha'
azchohfi Feb 21, 2025
80dc8cd
Merge branch 'rel/v0.3.0'
azchohfi Feb 21, 2025
3addd9a
Improvements
niels9001 Feb 21, 2025
c0f8932
Merge pull request #224 from microsoft/zt/describe-image-wcr-update
niels9001 Feb 21, 2025
9a9e6a9
Fixing image description sample
niels9001 Feb 21, 2025
612321a
Super resolution changes
niels9001 Feb 21, 2025
fbe82ce
Improved error message and width handling of API and model pages
niels9001 Feb 21, 2025
d53e4d1
Fixes for modeldownload view
niels9001 Feb 21, 2025
e8aeddb
Update WcrModelDownloader.xaml
niels9001 Feb 21, 2025
cbd038c
Fix link
niels9001 Feb 21, 2025
a4bbf5a
Update APIPage.xaml
niels9001 Feb 21, 2025
bc1c264
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
niels9001 Feb 21, 2025
120c345
Merge branch 'alzollin/wcrapis' into zt/update-ocr
niels9001 Feb 21, 2025
f7c793b
Making the sample show up on API page
niels9001 Feb 21, 2025
722c891
Fixes
niels9001 Feb 21, 2025
d4f009f
Update WcrModelDownloader.xaml
niels9001 Feb 21, 2025
5320155
Merge pull request #227 from microsoft/zt/update-ocr
nmetulev Feb 21, 2025
5cdd8b4
Name change for OCR demo
niels9001 Feb 21, 2025
831e356
Push changes
niels9001 Feb 21, 2025
69afa61
Merge branch 'main' into alzollin/wcrapis
niels9001 Feb 21, 2025
83f71b0
Fix build.
azchohfi Feb 21, 2025
f6fe746
Revert "Split ExpFix."
azchohfi Feb 21, 2025
d2677ff
Reapply "removing titlebar in favor of winui titlebar"
azchohfi Feb 21, 2025
a06893e
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
azchohfi Feb 21, 2025
655d697
Fix infobar / requirements links
niels9001 Feb 21, 2025
f77d6ab
Merge branch 'alzollin/wcrapis' of https://github.com/microsoft/ai-de…
niels9001 Feb 21, 2025
9c4881d
Update WcrModelDownloader.xaml
niels9001 Feb 21, 2025
9f756b4
Update WcrModelDownloader.xaml
niels9001 Feb 21, 2025
146dae4
Better enhance image
niels9001 Feb 21, 2025
8d3875c
Fix SelfContained.
azchohfi Feb 21, 2025
c308125
Small fix.
azchohfi Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions AIDevGallery.SourceGenerator/Models/ApiDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ internal class ApiDefinition
public required string Id { get; init; }
public required string Name { get; init; }
public required string Icon { get; init; }
public required string IconGlyph { get; init; }
public required string Description { get; init; }
public required string ReadmeUrl { get; init; }
public required string License { get; init; }
public required string SampleIdToShowInDocs { get; init; }
}
3 changes: 2 additions & 1 deletion AIDevGallery.SourceGenerator/Models/HardwareAccelerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ internal enum HardwareAccelerator
{
CPU,
DML,
QNN
QNN,
WCRAPI
}
6 changes: 4 additions & 2 deletions AIDevGallery.SourceGenerator/ModelsSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ internal class ModelSourceGenerator : IIncrementalGenerator
public void Initialize(IncrementalGeneratorInitializationContext context)
{
IncrementalValuesProvider<AdditionalText> modelJsons = context.AdditionalTextsProvider.Where(
static file => file.Path.EndsWith(".json") &&
Path.GetFileName(Path.GetDirectoryName(file.Path)).Equals("ModelsDefinitions", StringComparison.OrdinalIgnoreCase));
static file => file.Path.EndsWith(".json") && file.Path.Contains(@"\Samples\Definitions\"));

var pathsAndContents = modelJsons.Select((text, cancellationToken) =>
(text.Path, Content: text.GetText(cancellationToken)!.ToString(), CancellationToken: cancellationToken))
Expand Down Expand Up @@ -322,8 +321,11 @@ private void GenerateApiDefinitionDetails(StringBuilder sourceBuilder, Dictionar
Id = "{{apiDefinition.Id}}",
Name = "{{apiDefinition.Name}}",
Icon = "{{apiDefinition.Icon}}",
IconGlyph = "{{apiDefinition.IconGlyph}}",
Description = "{{apiDefinition.Description}}",
ReadmeUrl = "{{apiDefinition.ReadmeUrl}}",
License = "{{apiDefinition.License}}",
{{(!string.IsNullOrWhiteSpace(apiDefinition.SampleIdToShowInDocs) ? $"SampleIdToShowInDocs = \"{apiDefinition.SampleIdToShowInDocs}\"" : string.Empty)}}
}
},
"""");
Expand Down
38 changes: 32 additions & 6 deletions AIDevGallery.SourceGenerator/SamplesSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void ExecuteSharedCodeEnumGeneration(SourceProductionContext context, Im
{
var filePath = type!.Locations[0].SourceTree?.FilePath;

if (filePath != null)
if (filePath != null && !filePath.Contains(@"\obj\"))
{
if (!filePaths.Contains(filePath))
{
Expand All @@ -66,7 +66,15 @@ private void ExecuteSharedCodeEnumGeneration(SourceProductionContext context, Im
foreach (var filePath in filePaths)
{
var fileName = Path.GetFileNameWithoutExtension(filePath);
if (File.Exists(Path.ChangeExtension(filePath, ".xaml")))
var extension = Path.GetExtension(filePath);
var filePathWithoutExtension = filePath.Substring(0, filePath.Length - extension.Length);
if (fileName.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase) && File.Exists(filePathWithoutExtension))
{
fileName = Path.GetFileNameWithoutExtension(filePathWithoutExtension);
sourceBuilder.AppendLine($" {fileName}Cs,");
sourceBuilder.AppendLine($" {fileName}Xaml,");
}
else if (File.Exists(Path.ChangeExtension(filePath, ".xaml")))
{
sourceBuilder.AppendLine($" {fileName}Cs,");
sourceBuilder.AppendLine($" {fileName}Xaml,");
Expand All @@ -89,14 +97,22 @@ private void ExecuteSharedCodeEnumGeneration(SourceProductionContext context, Im
{
var fileName = Path.GetFileNameWithoutExtension(filePath);
var filePathXaml = Path.ChangeExtension(filePath, ".xaml");
if (File.Exists(filePathXaml))
var extension = Path.GetExtension(filePath);
var filePathWithoutExtension = filePath.Substring(0, filePath.Length - extension.Length);
if (fileName.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase) && File.Exists(filePathWithoutExtension))
{
sourceBuilder.AppendLine($" SharedCodeEnum.{Path.GetFileNameWithoutExtension(filePath)}Xaml => \"{Path.GetFileName(filePathXaml)}\",");
sourceBuilder.AppendLine($" SharedCodeEnum.{Path.GetFileNameWithoutExtension(filePath)}Cs => \"{Path.GetFileName(filePath)}\",");
fileName = Path.GetFileNameWithoutExtension(fileName);
sourceBuilder.AppendLine($" SharedCodeEnum.{fileName}Cs => \"{fileName}.xaml.cs\",");
sourceBuilder.AppendLine($" SharedCodeEnum.{fileName}Xaml => \"{fileName}.xaml\",");
}
else if (File.Exists(filePathXaml))
{
sourceBuilder.AppendLine($" SharedCodeEnum.{fileName}Xaml => \"{Path.GetFileName(filePathXaml)}\",");
sourceBuilder.AppendLine($" SharedCodeEnum.{fileName}Cs => \"{Path.GetFileName(filePath)}\",");
}
else
{
sourceBuilder.AppendLine($" SharedCodeEnum.{Path.GetFileNameWithoutExtension(filePath)} => \"{Path.GetFileName(filePath)}\",");
sourceBuilder.AppendLine($" SharedCodeEnum.{fileName} => \"{Path.GetFileName(filePath)}\",");
}
}

Expand All @@ -111,6 +127,16 @@ private void ExecuteSharedCodeEnumGeneration(SourceProductionContext context, Im
{
var fileName = Path.GetFileNameWithoutExtension(filePath);
var filePathXaml = Path.ChangeExtension(filePath, ".xaml");
var extension = Path.GetExtension(filePath);
var filePathWithoutExtension = filePath.Substring(0, filePath.Length - extension.Length);

// handle .xaml.cs files
if (File.Exists(filePathWithoutExtension))
{
filePathXaml = filePathWithoutExtension;
fileName = Path.GetFileNameWithoutExtension(fileName);
}

if (File.Exists(filePathXaml))
{
var fileContentXaml = XamlSourceCleanUp(File.ReadAllText(filePathXaml));
Expand Down
81 changes: 60 additions & 21 deletions AIDevGallery.UnitTests/ProjectGeneratorUnitTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -62,7 +63,9 @@ private class SampleUIData : INotifyPropertyChanged
{
private Brush? statusColor;

public required string SampleName { get; init; }
public required Sample Sample { get; init; }
public required Dictionary<ModelType, (string CachedModelDirectoryPath, string ModelUrl, HardwareAccelerator HardwareAccelerator)> CachedModelsToGenerator { get; init; }
public Brush? StatusColor
{
get => statusColor;
Expand Down Expand Up @@ -93,11 +96,7 @@ public async Task GenerateForAllSamples()

UITestMethodAttribute.DispatcherQueue?.TryEnqueue(() =>
{
source = SampleDetails.Samples.Select(s => new SampleUIData
{
Sample = s,
StatusColor = new SolidColorBrush(Colors.LightGray)
}).ToList();
source = SampleDetails.Samples.SelectMany(s => GetAllForSample(s)).ToList();

green = new SolidColorBrush(Colors.Green);
red = new SolidColorBrush(Colors.Red);
Expand All @@ -119,49 +118,89 @@ public async Task GenerateForAllSamples()

// write test count
TestContext.WriteLine($"Running {source.Count} tests");

int currentId = 0;
await Parallel.ForEachAsync(source, new ParallelOptions { MaxDegreeOfParallelism = 4 }, async (item, ct) =>
{
listView.DispatcherQueue.TryEnqueue(() =>
{
item.StatusColor = yellow;
});

var success = await GenerateForSample(item.Sample, ct);
Interlocked.Increment(ref currentId);

TestContext.WriteLine($"Built {item.Sample.Name} with status {success}");
Debug.WriteLine($"Built {item.Sample.Name} with status {success}");
var success = await GenerateForSample(currentId, item, ct);

TestContext.WriteLine($"Built {item.SampleName} with status {success}");
Debug.WriteLine($"Built {item.SampleName} with status {success}");

listView.DispatcherQueue.TryEnqueue(() =>
{
item.StatusColor = success ? green : red;
});
successDict.Add(item.Sample.Name, success);
successDict.Add(item.SampleName, success);
});

successDict.Should().AllSatisfy(kvp => kvp.Value.Should().BeTrue($"{kvp.Key} should build successfully"));
}

private async Task<bool> GenerateForSample(Sample sample, CancellationToken cancellationToken)
private static IEnumerable<SampleUIData> GetAllForSample(Sample s)
{
var modelsDetails = ModelDetailsHelper.GetModelDetails(sample);
var modelsDetails = ModelDetailsHelper.GetModelDetails(s);

if (modelsDetails[0].ContainsKey(ModelType.LanguageModels) &&
modelsDetails[0].ContainsKey(ModelType.PhiSilica))
{
yield return new SampleUIData
{
Sample = s,
SampleName = $"{s.Name} GenAI",
CachedModelsToGenerator = GetModelsToGenerator(s, modelsDetails, modelsDetails[0].First(md => md.Key == ModelType.LanguageModels)),
StatusColor = new SolidColorBrush(Colors.LightGray)
};

ModelDetails modelDetails1 = modelsDetails[0].Values.First().First();
Dictionary<ModelType, (string CachedModelDirectoryPath, string ModelUrl, HardwareAccelerator HardwareAccelerator)> cachedModelsToGenerator = new()
yield return new SampleUIData
{
Sample = s,
SampleName = $"{s.Name} PhiSilica",
CachedModelsToGenerator = GetModelsToGenerator(s, modelsDetails, modelsDetails[0].First(md => md.Key == ModelType.PhiSilica)),
StatusColor = new SolidColorBrush(Colors.LightGray)
};
}
else
{
[sample.Model1Types.First()] = ("FakePath", modelsDetails[0].Values.First().First().Url, modelDetails1.HardwareAccelerators.First())
};
yield return new SampleUIData
{
Sample = s,
SampleName = s.Name,
CachedModelsToGenerator = GetModelsToGenerator(s, modelsDetails, modelsDetails[0].First()),
StatusColor = new SolidColorBrush(Colors.LightGray)
};
}

if (sample.Model2Types != null && modelsDetails.Count > 1)
static Dictionary<ModelType, (string CachedModelDirectoryPath, string ModelUrl, HardwareAccelerator HardwareAccelerator)> GetModelsToGenerator(Sample s, List<Dictionary<ModelType, List<ModelDetails>>> modelsDetails, KeyValuePair<ModelType, List<ModelDetails>> keyValuePair)
{
ModelDetails modelDetails2 = modelsDetails[1].Values.First().First();
cachedModelsToGenerator[sample.Model2Types.First()] = ("FakePath", modelDetails2.Url, modelDetails2.HardwareAccelerators.First());
Dictionary<ModelType, (string CachedModelDirectoryPath, string ModelUrl, HardwareAccelerator HardwareAccelerator)> cachedModelsToGenerator = new();

ModelDetails modelDetails1 = keyValuePair.Value.First();
cachedModelsToGenerator[keyValuePair.Key] = (modelDetails1.Url, modelDetails1.Url, modelDetails1.HardwareAccelerators.First());

if (s.Model2Types != null && modelsDetails.Count > 1)
{
ModelDetails modelDetails2 = modelsDetails[1].Values.First().First();
cachedModelsToGenerator[s.Model2Types.First()] = (modelDetails2.Url, modelDetails2.Url, modelDetails2.HardwareAccelerators.First());
}

return cachedModelsToGenerator;
}
}

var projectPath = await generator.GenerateAsync(sample, cachedModelsToGenerator, false, TmpPathProjectGenerator, cancellationToken);
private async Task<bool> GenerateForSample(int id, SampleUIData sampleUIData, CancellationToken cancellationToken)
{
var outputPath = Path.Join(TmpPathProjectGenerator, id.ToString(CultureInfo.InvariantCulture));
var projectPath = await generator.GenerateAsync(sampleUIData.Sample, sampleUIData.CachedModelsToGenerator, false, outputPath, cancellationToken);

var safeProjectName = Path.GetFileName(projectPath);
string logFileName = $"build_{safeProjectName}.log";
string logFileName = $"build_{id}_{sampleUIData.SampleName.Replace(' ', '_')}.log";

var arch = DeviceUtils.IsArm64() ? "arm64" : "x64";

Expand Down
2 changes: 1 addition & 1 deletion AIDevGallery.UnitTests/UnitTestApp.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<DataTemplate x:Key="SampleItemTemplate">
<Grid>
<Border Background="{Binding StatusColor}">
<TextBlock Text="{Binding Sample.Name}" FontSize="16"/>
<TextBlock Text="{Binding SampleName}" FontSize="16"/>
</Border>
</Grid>
</DataTemplate>
Expand Down
2 changes: 2 additions & 0 deletions AIDevGallery/AIDevGallery.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -322,4 +322,6 @@
<UserProperties />
</VisualStudio>
</ProjectExtensions>

<Import Project="$(MSBuildThisFileDirectory)\WinAppSDKSelfContainedFix.targets" Condition="'$(WindowsAppSDKSelfContained)'=='true'" />
</Project>
11 changes: 7 additions & 4 deletions AIDevGallery/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,25 @@
x:Class="AIDevGallery.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AIDevGallery">
xmlns:local="using:AIDevGallery"
xmlns:models="using:AIDevGallery.Models">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<ResourceDictionary Source="/Styles/Button.xaml" />
<ResourceDictionary Source="/Styles/Colors.xaml" />
<ResourceDictionary Source="/Styles/ComboBox.xaml" />
<ResourceDictionary Source="/Styles/Card.xaml" />
<ResourceDictionary Source="/Styles/NavigationView.xaml" />
<ResourceDictionary Source="/Styles/SelectorBar.xaml" />
<ResourceDictionary Source="/Controls/CopyButton.xaml" />
<ResourceDictionary Source="/Controls/Shimmer.xaml" />
<ResourceDictionary Source="/Controls/OpacityMask.xaml" />
<ResourceDictionary Source="/Controls/HomePage/Header/HeaderTile/HeaderTile.xaml" />
<ResourceDictionary Source="/Samples/SharedCode/SemanticComboBox.xaml" />
<ResourceDictionary Source="/Samples/SharedCode/SmartPasteForm.xaml" />
<ResourceDictionary Source="/Samples/SharedCode/SmartTextBox.xaml" />
<ResourceDictionary Source="/Samples/SharedCode/Controls/SemanticComboBox.xaml" />
<ResourceDictionary Source="/Samples/SharedCode/Controls/SmartPasteForm.xaml" />
<ResourceDictionary Source="/Samples/SharedCode/Controls/SmartTextBox.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->

Expand Down
Binary file added AIDevGallery/Assets/Enhance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading