次の方法で共有


Windows アプリ SDK の Phi Silica API の API リファレンス

重要

Windows App SDK の最新の 試験的チャネル リリースで使用できます。

Windows App SDK の実験用チャネルには、開発の初期段階の API と機能が含まれています。 試験段階チャネルに含まれる API はすべて、大幅な改訂および重大な変更の対象であり、後続のリリースからいつでも削除される可能性があります。 試験段階の機能は運用環境での使用はサポートされておらず、使用するアプリは Microsoft Store に公開できません。

  • Phi Silica は中国大陸では利用できません。
  • 自己完結型アプリはサポートされていません。

デバイス上でのチャットの処理と生成、テキストに対する推論、数学の解決、コード生成などを可能にする、Microsoft の最も強力な NPU で調整された言語モデルである Phi Silica などのローカル言語モデルにアクセスできる Windows アプリ SDK API について説明します。

詳細については、「Windows アプリ SDK の Phi Silica の概要」を参照してください。

ヒント

これらの API とその機能に関するフィードバックをご提供ください。これには、Windows App SDK GitHub リポジトリで新しい問題を作成する (タイトルに Phi Silica を含める) 方法と、既存の問題に返信する方法があります。


Microsoft.Windows.AI.Generative 名前空間

ローカルのデバイス上にある生成 AI プロンプトの処理と応答に対応した API を提供します。

ImageDescriptionGenerator クラス

public sealed class ImageDescriptionGenerator : System.IDisposable

ImageDescriptionGenerator.Close メソッド

// This member is not implemented in C#
注釈

C# には実装されていません。

ImageDescriptionGenerator.CreateAsync メソッド

public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageDescriptionGenerator> CreateAsync ();

ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image);

警告

画像を ImageDescriptionGenerator.DescribeAsync() と呼び出すと、エラーが発生することがあります。 このエラーはスキップして、デバッガーが続行して正しい出力を生成できるようにします。 このエラーは開発環境でのみ表示され、エンド ユーザー (アプリを使用しているユーザー) には表示されません。 デバッグ ビルドまたはリリース ビルドを使用すると、このエラーがトリガーされます。 エラーは、すべての実行でではなく、時々表示されます。

ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer,Microsoft.Windows.AI.Generative.ImageDescriptionScenario) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image, Microsoft.Windows.AI.Generative.ImageDescriptionScenario scenario);
パラメーター
image
scenario
戻り値
注釈

ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer,Microsoft.Windows.AI.Generative.ImageDescriptionScenario,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image, Microsoft.Windows.AI.Generative.ImageDescriptionScenario scenario, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
image
scenario
コンテンツフィルターオプション
戻り値
注釈

ImageDescriptionGenerator.IsAvailable メソッド

public static bool IsAvailable ();

ImageDescriptionGenerator.MakeAvailableAsync メソッド

public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();

ImageDescriptionScenario 列挙子

public enum ImageDescriptionScenario

Fields

アクセシビリティ: 1
キャプション: 2
DetailedNarration: 3
OfficeCharts: 4

ImageLLMAdapterCreator クラス

public sealed class ImageLLMAdapterCreator : System.IDisposable

ImageLLMAdapterCreator.Close メソッド

// This member is not implemented in C#
注釈

C# には実装されていません。

ImageLLMAdapterCreator.CreateAsync メソッド

public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageLLMAdapterCreator> CreateAsync ();
戻り値

ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector) メソッド

public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
パラメーター
embeddings
戻り値

ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector) メソッド

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
パラメーター
embeddings
戻り値

ImageLLMAdapterCreator.GetModelInputSize メソッド

public uint GetModelInputSize ();
戻り値

ImageLLMAdapterCreator.GetModelOutputSize メソッド

public uint GetModelOutputSize ();
戻り値

ImageLLMAdapterCreator.IsAvailable メソッド

public static bool IsAvailable ();
戻り値

ImageLLMAdapterCreator.MakeAvailableAsync メソッド

public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
戻り値

LanguageModel クラス

public sealed class LanguageModel : System.IDisposable

ローカル言語モデルと対話して、指定されたプロンプトの応答を生成できるオブジェクトを表します。

LanguageModel.Close メソッド

オブジェクトおよび関連付けられているリソースを破棄します。

注釈

C# には実装されていません。

LanguageModel.CreateAsync メソッド

public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModel> CreateAsync ();

LanguageModel クラスの新しいインスタンスを非同期的に作成します。

戻り値

TextRecognizer クラスの新しいインスタンス。

LanguageModel.CreateContext メソッド

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
戻り値
注釈

LanguageModel.CreateContext(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext (string systemPrompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
システムプロンプト
コンテンツフィルターオプション
戻り値
注釈

LanguageModel.GenerateEmbeddingVector(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
prompt
コンテンツフィルターオプション
戻り値
注釈

LanguageModel.GenerateEmbeddingVector(System.String) メソッド

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
パラメーター
prompt
戻り値
注釈

LanguageModel.GenerateEmbeddingVectorAsync(System.String) メソッド

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
パラメーター
prompt
戻り値
注釈

LanguageModel.GenerateEmbeddingVectorAsync(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
prompt
コンテンツフィルターオプション
戻り値
注釈

LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generateive.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
prompt
コンテンツフィルターオプション
戻り値
注釈

LanguageModel.GenerateResponseAsync(System.String) メソッド

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (string prompt);

1 つのプロンプトに対する完全な応答を生成して返します。

パラメーター
prompt

質問の形式のプロンプト。

戻り値

応答文字列と状態。

例外

ArgumentException: 指定されたプロンプトが、モデルが受け入れ可能なトークンの最大数より長くなっています。

LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
prompt
コンテンツフィルターオプション
context
戻り値
注釈

LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String) メソッド

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
パラメーター
options
prompt
戻り値
注釈

LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
promptEmbedding
コンテンツフィルターオプション
context
戻り値
注釈

LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
promptEmbedding
コンテンツフィルターオプション
戻り値
注釈

LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector}) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding);
パラメーター
promptEmbedding
戻り値
注釈

LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector}) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding);
パラメーター
options
promptEmbedding
戻り値

LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64}) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens);
パラメーター
options
プロンプトトークンズ
戻り値

LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
プロンプトトークンズ
コンテンツフィルターオプション
context
戻り値

LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
プロンプトトークンズ
コンテンツフィルターオプション
戻り値

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generateive.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
options
prompt
コンテンツフィルターオプション
戻り値

LanguageModel.GenerateResponseWithProgressAsync(System.String) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
パラメーター
prompt
戻り値

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generateive.LanguageModelOptions,System.String) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
パラメーター
options
prompt
戻り値

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) メソッド

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions, Microsoft.Windows.AI.Generative.LanguageModelContext context);
パラメーター
options
prompt
コンテンツフィルターオプション
context
戻り値

LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
テキスト
コンテンツフィルターオプション
戻り値

LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
テキスト
コンテンツフィルターオプション
戻り値

LanguageModel.GenerateTokensAsync(System.String) メソッド

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
パラメーター
テキスト
戻り値

LanguageModel.GenerateTokensAsync(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) メソッド

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
パラメーター
テキスト
コンテンツフィルターオプション
戻り値

LanguageModel.IsAvailable メソッド

public static bool IsAvailable ();
戻り値

LanguageModel.IsPromptLargerThanContext(Microsoft.Windows.AI.Generative.LanguageModelContext,System.String) メソッド

public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
パラメーター
context
prompt
戻り値

LanguageModel.IsPromptLargerThanContext(System.String) メソッド

public bool IsPromptLargerThanContext (string prompt);
パラメーター
prompt
戻り値

LanguageModel.MakeAvailableAsync メソッド

public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
戻り値

LanguageModelContext クラス

public sealed class LanguageModelContext

LanguageModelOptions クラス

public sealed class LanguageModelOptions

LanguageModelOptions.#ctor コンストラクター

public LanguageModelOptions ();

LanguageModelOptions.#ctor(Microsoft.Windows.AI.Generative.LanguageModelSkill,System.Single,System.Single,System.UInt32) コンストラクター

public LanguageModelOptions (Microsoft.Windows.AI.Generative.LanguageModelSkill skill, float temp, float top_p, uint top_k);
パラメーター
skill
temp
top_p
top_k

LanguageModelOptions.Skill プロパティ

public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
プロパティ値

LanguageModelOptions.Temp プロパティ

public float Temp { get; set; }
プロパティ値

LanguageModelOptions.Top_k プロパティ

public uint Top_k { get; set; }
プロパティ値

LanguageModelOptions.Top_p プロパティ

public float Top_p { get; set; }
プロパティ値

LanguageModelResponse クラス

public sealed class LanguageModelResponse

LanguageModelResponse.#ctor(System.String,Microsoft.Windows.AI.Generative.LanguageModelResponseStatus) コンストラクター

public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
パラメーター
返答
ステータス

LanguageModelResponse.Response プロパティ

public string Response { get; }
プロパティ値

LanguageModelResponse.Status プロパティ

public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
プロパティ値

LanguageModelResponseStatus 列挙

public enum LanguageModelResponseStatus

Fields

完了: 0
InProgress: 1
BlockedByPolicy: 2
PromptLargerThanContext: 3
ポリシーによってプロンプトがブロックされました: 4
ポリシーにより応答がブロックされました: 5

LanguageModelSkill 列挙

public enum LanguageModelSkill

Fields

全般: 0
TextToTable: 1
Summarize: 2
Rewrite: 3