Teilen über


API-Referenz für Phi Silika im Windows App SDK

Wichtig

Im neuesten experimentellen Kanal-Release für das Windows App SDK verfügbar.

Der experimentelle Kanal des Windows App SDK umfasst APIs und Features in frühen Entwicklungsphasen. Alle APIs im experimentellen Kanal unterliegen umfangreichen Überarbeitungen und Breaking Changes und können jederzeit aus nachfolgenden Versionen entfernt werden. Experimentelle Features werden nicht für die Verwendung in Produktionsumgebungen und Apps unterstützt, die sie verwenden, können nicht im Microsoft Store veröffentlicht werden.

  • Phi Silika ist nicht im Festland China verfügbar.
  • Eigenständige Apps werden nicht unterstützt.

Erfahren Sie mehr über die Windows App SDK-APIs, die auf lokale Sprachmodelle wie Phi Silica zugreifen können. Phi Silica ist das leistungsstärkste, NPU-optimierte lokale Sprachmodell von Microsoft und ermöglicht die Verarbeitung und Generierung von Chats, Textanalyse, das Lösen mathematischer Probleme, Codegenerierung und vieles mehr.

Weitere Details finden Sie unter "Erste Schritte mit Phi Silica" im Windows App SDK.

Tipp

Geben Sie Feedback zu diesen APIs und deren Funktionalität, indem Sie ein neues Problem im GitHub-Repository des Windows App SDK erstellen (einschließlich Phi Silica im Titel) oder indem Sie auf ein vorhandenes Problemreagieren.


Microsoft.Windows.AI.Generative Namespace

Stellt APIs für lokale, geräteinterne generative KI-Prompt-Verarbeitung und -Antworten bereit.

ImageDescriptionGenerator-Klasse

public sealed class ImageDescriptionGenerator : System.IDisposable

ImageDescriptionGenerator.Close-Methode

// This member is not implemented in C#
Hinweise

Nicht in C# implementiert.

ImageDescriptionGenerator.CreateAsync-Methode

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

ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer)-Methode

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

Warnung

Beim Aufrufen von ImageDescriptionGenerator.DescribeAsync() für ein Bild wird manchmal ein Fehler ausgelöst. Dieser Fehler kann übersprungen werden, sodass der Debugger fortfahren und die richtige Ausgabe generieren kann. Der Fehler ist nur in der Entwicklerumgebung sichtbar, nicht für Endbenutzer (Kunden, die Ihre App verwenden). Die Verwendung von Debug- oder Releasebuilds löst diesen Fehler aus. Der Fehler wird zeitweise und nicht bei jeder Ausführung angezeigt.

ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer,Microsoft.Windows.AI.Generative.ImageDescriptionScenario)-Methode

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image, Microsoft.Windows.AI.Generative.ImageDescriptionScenario scenario);
Parameter
image
Szenario
Rückgaben
Hinweise

ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer,Microsoft.Windows.AI.Generative.ImageDescriptionScenario,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) method

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);
Parameter
image
Szenario
contentFilterOptions
Rückgaben
Hinweise

ImageDescriptionGenerator.IsAvailable-Methode

public static bool IsAvailable ();

ImageDescriptionGenerator.MakeAvailableAsync-Methode

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

ImageDescriptionScenario-Enumeration

public enum ImageDescriptionScenario

Felder

Barrierefreiheit: 1
Untertitel: 2
DetailedNarration: 3
OfficeCharts: 4

LanguageModel-Klasse

public sealed class LanguageModel : System.IDisposable

Stellt ein Objekt dar, das mit einem lokalen Sprachmodell interagieren kann, um Antworten für eine bereitgestellte Eingabeaufforderung zu generieren.

LanguageModel.Close-Methode

Entfernt das Objekt und die zugeordneten Ressourcen.

Hinweise

Nicht in C# implementiert.

LanguageModel.CreateAsync-Methode

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

Erstellt asynchron eine neue Instanz der LanguageModel-Klasse.

Rückgaben

Eine neue Instanz der TextRecognizer-Klasse.

LanguageModel.CreateContext-Methode

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
Rückgaben
Hinweise

LanguageModel.CreateContext(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext (string systemPrompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameter
systemPrompt
contentFilterOptions
Rückgaben
Hinweise

LanguageModel.GenerateEmbeddingVector(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameter
prompt
contentFilterOptions
Rückgaben
Hinweise

LanguageModel.GenerateEmbeddingVector(System.String)-Methode

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Parameter
prompt
Rückgaben
Hinweise

LanguageModel.GenerateEmbeddingVectorAsync(System.String)-Methode

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Parameter
prompt
Rückgaben
Hinweise

LanguageModel.GenerateEmbeddingVectorAsync(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameter
prompt
contentFilterOptions
Rückgaben
Hinweise

LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameter
Optionen
prompt
contentFilterOptions
Rückgaben
Hinweise

LanguageModel.GenerateResponseAsync(System.String)-Methode

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

Generiert und gibt eine vollständige Antwort für eine einzelne Eingabeaufforderung zurück.

Parameter
prompt

Eine Eingabeaufforderung in Form einer Frage.

Rückgaben

Eine Antwortzeichenfolge und ein Status.

Ausnahmen

ArgumentException: Die angegebene Eingabeaufforderung ist länger als die maximale Anzahl von Token, die das Modell akzeptieren kann.

LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext)-Methode

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);
Parameter
Optionen
prompt
contentFilterOptions
Kontext
Rückgaben
Hinweise

LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String)-Methode

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
Parameter
Optionen
prompt
Rückgaben
Hinweise

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)-Methode

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);
Parameter
Optionen
promptEmbedding
contentFilterOptions
Kontext
Rückgaben
Hinweise

LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

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);
Parameter
Optionen
promptEmbedding
contentFilterOptions
Rückgaben
Hinweise

LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector})-Methode

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromEmbeddingsWithProgressAsync (System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> promptEmbedding);
Parameter
promptEmbedding
Rückgaben
Hinweise

LanguageModel.GenerateResponseFromEmbeddingsWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{Microsoft.Windows.SemanticSearch.EmbeddingVector})-Methode

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);
Parameter
Optionen
promptEmbedding
Rückgaben

LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64})-Methode

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens);
Parameter
Optionen
promptTokens
Rückgaben

LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext)-Methode

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);
Parameter
Optionen
promptTokens
contentFilterOptions
Kontext
Rückgaben

LanguageModel.GenerateResponseFromTokensWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,Windows.Foundation.Collections.IVectorView{System.Int64},Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

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);
Parameter
Optionen
promptTokens
contentFilterOptions
Rückgaben

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

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);
Parameter
Optionen
prompt
contentFilterOptions
Rückgaben

LanguageModel.GenerateResponseWithProgressAsync(System.String)-Methode

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Parameter
prompt
Rückgaben

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String) -Methode

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
Parameter
Optionen
prompt
Rückgaben

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext-Methode

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);
Parameter
Optionen
prompt
contentFilterOptions
Kontext
Rückgaben

LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameter
Text
contentFilterOptions
Rückgaben

LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameter
Text
contentFilterOptions
Rückgaben

LanguageModel.GenerateTokensAsync(System.String)-Methode

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Parameter
Text
Rückgaben

LanguageModel.GenerateTokensAsync(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)-Methode

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameter
Text
contentFilterOptions
Rückgaben

LanguageModel.IsAvailable-Methode

public static bool IsAvailable ();
Rückgaben

LanguageModel.IsPromptLargerThanContext(Microsoft.Windows.AI.Generative.LanguageModelContext,System.String)-Methode

public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Parameter
Kontext
prompt
Rückgaben

LanguageModel.IsPromptLargerThanContext(System.String)-Methode

public bool IsPromptLargerThanContext (string prompt);
Parameter
prompt
Rückgaben

LanguageModel.MakeAvailableAsync-Methode

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

LanguageModelContext-Klasse

public sealed class LanguageModelContext

LanguageModelOptions-Klasse

public sealed class LanguageModelOptions

LanguageModelOptions.#ctor-Konstruktor

public LanguageModelOptions ();

LanguageModelOptions.#ctor(Microsoft.Windows.AI.Generative.LanguageModelSkill,System.Single,System.Single,System.UInt32)-Konstruktor

public LanguageModelOptions (Microsoft.Windows.AI.Generative.LanguageModelSkill skill, float temp, float top_p, uint top_k);
Parameter
Fähigkeit
temp
top_p
top_k

LanguageModelOptions.Skill-Eigenschaft

public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
Eigenschaftswert

LanguageModelOptions.Temp-Eigenschaft

public float Temp { get; set; }
Eigenschaftswert

LanguageModelOptions.Top_k-Eigenschaft

public uint Top_k { get; set; }
Eigenschaftswert

LanguageModelOptions.Top_p-Eigenschaft

public float Top_p { get; set; }
Eigenschaftswert

LanguageModelResponse-Klasse

public sealed class LanguageModelResponse

LanguageModelResponse.#ctor(System.String,Microsoft.Windows.AI.Generative.LanguageModelResponseStatus)-Konstruktor

public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
Parameter
Antwort
Status

LanguageModelResponse.Response-Eigenschaft

public string Response { get; }
Immobilienwert

LanguageModelResponse.Status-Eigenschaft

public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Immobilienwert

LanguageModelResponseStatus-Enumeration

public enum LanguageModelResponseStatus

Felder

Abgeschlossen: 0
InProgress (In Bearbeitung): 1
BlockedByPolicy: 2
PromptLargerThanContext: 3
PromptBlockedByPolicy: 4
ResponseBlockedByPolicy: 5

LanguageModelSkill-Enumeration

public enum LanguageModelSkill

Felder

Allgemein: 0
TextToTable: 1
Zusammenfassung: 2
Rewrite: 3