Created
October 19, 2025 09:20
-
-
Save ynkdir/d97b2ac1ea906b39a473d4eb7e64517b to your computer and use it in GitHub Desktop.
Test Phi Silica
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://learn.microsoft.com/en-us/windows/ai/apis/phi-silica | |
| import asyncio | |
| from win32more.Microsoft.Windows.AI import AIFeatureReadyState | |
| from win32more.Microsoft.Windows.AI.Text import LanguageModel | |
| from win32more.Windows.ApplicationModel import LimitedAccessFeatures, LimitedAccessFeatureStatus | |
| # You need to obtain LAF access token. See url above. | |
| LAF_FEATURE_ID = "" | |
| LAF_TOKEN = "" | |
| LAF_ATTESTATION = "" | |
| async def main(): | |
| # 2025-10-19: Currently Microsoft is unable to generate a token. | |
| # Use experintmal version which is accessible without token. | |
| # > py .\scripts\build_selfcontained.py --appsdk=2.0.250930001-experimental1 --target=testapp | |
| #result = LimitedAccessFeatures.TryUnlockFeature(LAF_FEATURE_ID, LAF_TOKEN, LAF_ATTESTATION) | |
| #if result.Status != LimitedAccessFeatureStatus.Available: | |
| # raise RuntimeError("unlock feature failed") | |
| if LanguageModel.GetReadyState() == AIFeatureReadyState.NotReady: | |
| await LanguageModel.EnsureReadyAsync() | |
| language_model = await LanguageModel.CreateAsync() | |
| prompt = "Provide the molecular formula for glucose." | |
| result = await language_model.GenerateResponseAsync(prompt) | |
| print(result.Text) | |
| if __name__ == "__main__": | |
| asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment