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 in China nicht verfügbar.
- Entpackte Apps werden nicht unterstützt.
Erfahren Sie mehr über die Windows App SDK-APIs , die auf lokale Sprachmodelle wie Phi Silica zugreifen können, das NPU-orientierte lokale Sprachmodell von Microsoft, das die Verarbeitung und Generierung von Chats ermöglicht, gründe für Text, mathematische Lösung, 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
In nicht implementiert.
ImageDescriptionGenerator.CreateAsync-Methode
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageDescriptionGenerator> CreateAsync ();
ImageDescriptionGenerator.DescribeAsync(Microsoft.Windows.Imaging.ImageBuffer)-Methode
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Windows.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
auswählen
Gibt zurück
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
auswählen
contentFilterOptions
Gibt zurück
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-Enumerator
public enum ImageDescriptionScenario
Felder
Barrierefreiheit: 1
Untertitel: 2
DetailedNarration: 3
OfficeCharts: 4
Klasse ImageLLMAdapterCreator
public sealed class ImageLLMAdapterCreator : System.IDisposable
ImageLLMAdapterCreator.Close-Methode
// This member is not implemented in C#
Hinweise
In nicht implementiert.
ImageLLMAdapterCreator.CreateAsync-Methode
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageLLMAdapterCreator> CreateAsync ();
Gibt zurück
ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector)-Methode
public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parameter
embeddings
Gibt zurück
ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector)-Methode
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parameter
embeddings
Gibt zurück
ImageLLMAdapterCreator.GetModelInputSize-Methode
public uint GetModelInputSize ();
Gibt zurück
ImageLLMAdapterCreator.GetModelOutputSize-Methode
public uint GetModelOutputSize ();
Gibt zurück
ImageLLMAdapterCreator.IsAvailable-Methode
public static bool IsAvailable ();
Gibt zurück
ImageLLMAdapterCreator.MakeAvailableAsync-Methode
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
Gibt zurück
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
In nicht implementiert.
LanguageModel.CreateAsync-Methode
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModel> CreateAsync ();
Erstellt asynchron eine neue Instanz der LanguageModel-Klasse.
Gibt zurück
Eine neue Instanz der TextRecognizer-Klasse.
LanguageModel.CreateContext-Methode
public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
Gibt zurück
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
Gibt zurück
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
Gibt zurück
Hinweise
LanguageModel.GenerateEmbeddingVector(System.String)-Methode
public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Parameter
prompt
Gibt zurück
Hinweise
LanguageModel.GenerateEmbeddingVectorAsync(System.String)-Methode
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Parameter
prompt
Gibt zurück
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
Gibt zurück
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
Gibt zurück
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.
Gibt zurück
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
context
Gibt zurück
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
Gibt zurück
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
context
Gibt zurück
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
Gibt zurück
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
Gibt zurück
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
Gibt zurück
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
Gibt zurück
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
context
Gibt zurück
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
Gibt zurück
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
Gibt zurück
LanguageModel.GenerateResponseWithProgressAsync(System.String)-Methode
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Parameter
prompt
Gibt zurück
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
Gibt zurück
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
context
Gibt zurück
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
Gibt zurück
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
Gibt zurück
LanguageModel.GenerateTokensAsync(System.String)-Methode
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Parameter
Text
Gibt zurück
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
Gibt zurück
LanguageModel.IsAvailable-Methode
public static bool IsAvailable ();
Gibt zurück
LanguageModel.IsPromptLargerThanContext(Microsoft.Windows.AI.Generative.LanguageModelContext,System.String)-Methode
public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Parameter
context
prompt
Gibt zurück
LanguageModel.IsPromptLargerThanContext(System.String)-Methode
public bool IsPromptLargerThanContext (string prompt);
Parameter
prompt
Gibt zurück
LanguageModel.MakeAvailableAsync-Methode
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
Gibt zurück
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
skill
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
automatisieren
status
LanguageModelResponse.Response-Eigenschaft
public string Response { get; }
Eigenschaftswert
LanguageModelResponse.Status-Eigenschaft
public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Eigenschaftswert
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