Udostępnij za pośrednictwem


Dokumentacja API dla krzemionki Phi w SDK dla aplikacji Windows

Ważny

Dostępne w najnowszej wersji eksperymentalnego kanału zestawu SDK aplikacji systemu Windows.

Eksperymentalny kanał zestawu SDK aplikacji systemu Windows obejmuje interfejsy API i funkcje we wczesnych etapach programowania. Wszystkie interfejsy API w kanale eksperymentalnym podlegają rozbudowanym poprawkom i zmianom powodujących niezgodność i mogą zostać usunięte z kolejnych wersji w dowolnym momencie. Funkcje eksperymentalne nie są obsługiwane w środowiskach produkcyjnych i aplikacjach, które ich używają, nie mogą być publikowane w sklepie Microsoft Store.

  • Silica Phi nie jest dostępna w Chinach.
  • Niezapakowane aplikacje nie są obsługiwane.

Dowiedz się więcej o interfejsach API zestawu SDK aplikacji systemu Windows, które umożliwiają dostęp do lokalnych modeli językowych, takich jak Phi Silica, najbardziej zaawansowany lokalny model językowy dostosowany do NPU firmy Microsoft. Model ten umożliwia przetwarzanie i generowanie czatu na urządzeniu, rozumowanie na podstawie tekstu, rozwiązywanie zadań matematycznych, generowanie kodu i wiele więcej.

Aby uzyskać więcej informacji, zobacz Wprowadzenie do Phi Silica w Windows App SDK.

Napiwek

Prześlij opinię na temat tych interfejsów API i ich funkcjonalności, tworząc nowe zgłoszenie w repozytorium GitHub zestawu SDK aplikacji systemu Windows (w tym Phi Silica w tytule) lub odpowiadając na istniejące zgłoszenie.


Microsoft.Windows.AI.Generative, przestrzeń nazw

Udostępnia interfejsy API do lokalnego przetwarzania i generowania odpowiedzi na monity przez sztuczną inteligencję na urządzeniu.

klasa ImageDescriptionGenerator

public sealed class ImageDescriptionGenerator : System.IDisposable

Metoda ImageDescriptionGenerator.Close

// This member is not implemented in C#
Uwagi

Nie zaimplementowano w języku C#.

Metoda ImageDescriptionGenerator.CreateAsync

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

ImageDescriptionGenerator.DescribeAsync(Microsoft.Windows.Imaging.ImageBuffer) metoda

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

Ostrzeżenie

Podczas wywoływania ImageDescriptionGenerator.DescribeAsync() w odniesieniu do obrazu czasami występuje błąd. Ten błąd można pominąć, umożliwiając debugerowi kontynuowanie i generowanie poprawnych danych wyjściowych. Błąd jest widoczny tylko w środowisku dewelopera, a nie dla użytkowników końcowych (klientów korzystających z aplikacji). Użycie kompilacji debug lub release spowoduje wystąpienie tego błędu. Błąd pojawia się sporadycznie, a nie przy każdym uruchomieniu.

ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer,Microsoft.Windows.AI.Generative.ImageDescriptionScenario) — metoda

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image, Microsoft.Windows.AI.Generative.ImageDescriptionScenario scenario);
Parametry
obraz
scenariusz
Zwraca
Uwagi

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

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);
Parametry
obraz
scenariusz
opcje filtrowania treści
Zwraca
Uwagi

Metoda ImageDescriptionGenerator.IsAvailable

public static bool IsAvailable ();

Metoda ImageDescriptionGenerator.MakeAvailableAsync

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

ImageDescriptionScenario enumerator

public enum ImageDescriptionScenario

Pola

Ułatwienia dostępu: 1
Podpis: 2
Szczegółowa Narracja: 3
OfficeCharts: 4

Klasa "ImageLLMAdapterCreator"

public sealed class ImageLLMAdapterCreator : System.IDisposable

ImageLLMAdapterCreator.Close metoda

// This member is not implemented in C#
Uwagi

Nie zaimplementowano w języku C#.

metoda CreateAsync w ImageLLMAdapterCreator

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

ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector) — metoda

public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parametry
osadzanie
Zwraca

ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector) — metoda

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parametry
osadzanie
Zwraca

ImageLLMAdapterCreator.GetModelInputSize metoda

public uint GetModelInputSize ();
Zwraca

Metoda "ImageLLMAdapterCreator.GetModelOutputSize"

public uint GetModelOutputSize ();
Zwraca

Metoda ImageLLMAdapterCreator.IsAvailable

public static bool IsAvailable ();
Zwraca

Metoda ImageLLMAdapterCreator.MakeAvailableAsync

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

Klasa LanguageModel

public sealed class LanguageModel : System.IDisposable

Reprezentuje obiekt, który może wchodzić w interakcje z lokalnym modelem językowym w celu wygenerowania odpowiedzi dla podanego monitu.

Metoda LanguageModel.Close

Usuwa obiekt i skojarzone zasoby.

Uwagi

Nie zaimplementowano w języku C#.

Metoda LanguageModel.CreateAsync

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

Asynchronicznie tworzy nowe wystąpienie klasy LanguageModel.

Zwraca

Nowe wystąpienie klasy TextRecognizer.

Metoda LanguageModel.CreateContext

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
Zwraca
Uwagi

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

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext (string systemPrompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametry
systemPrompt
opcjeFiltrowaniaTreści
Zwraca
Uwagi

LanguageModel.GenerateEmbeddingVector(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) — metoda

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametry
podpowiedź
opcje filtru treści
Zwraca
Uwagi

Metoda LanguageModel.GenerateEmbeddingVector(System.String)

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Parametry
podpowiedź
Zwraca
Uwagi

Metoda LanguageModel.GenerateEmbeddingVectorAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Parametry
podpowiedź
Zwraca
Uwagi

Metoda 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);
Parametry
podpowiedź
OpcjeFiltrowaniaTreści
Zwraca
Uwagi

LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) — metoda

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametry
Opcje
podpowiedź
opcjeFiltrowaniaTreści
Zwraca
Uwagi

Metoda LanguageModel.GenerateResponseAsync(System.String)

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

Generuje i zwraca pełną odpowiedź dla pojedynczego monitu.

Parametry
podpowiedź

Monit w postaci pytania.

Zwraca

Ciąg odpowiedzi i stan.

Wyjątki

ArgumentException: określony monit jest dłuższy niż maksymalna liczba tokenów, które może zaakceptować model.

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

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);
Parametry
Opcje
podpowiedź
opcjeFiltrowaniaZawartości
kontekst
Zwraca
Uwagi

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

public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
Parametry
Opcje
podpowiedź
Zwraca
Uwagi

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) — metoda

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);
Parametry
Opcje
promptEmbedding
OpcjeFiltrówZawartości
kontekst
Zwraca
Uwagi

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);
Parametry
Opcje
promptEmbedding
opcje filtra treści
Zwraca
Uwagi

Metoda 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);
Parametry
promptEmbedding
Zwraca
Uwagi

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

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);
Parametry
Opcje
promptEmbedding
Zwraca

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

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseFromTokensWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, System.Collections.Generic.IReadOnlyList<long> promptTokens);
Parametry
Opcje
promptTokens
Zwraca

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);
Parametry
Opcje
promptTokens
opcje filtru treści
kontekst
Zwraca

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

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);
Parametry
Opcje
promptTokens
opcjeFiltruTreści
Zwraca

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) — metoda

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);
Parametry
Opcje
podpowiedź
opcje filtra treści
Zwraca

Metoda LanguageModel.GenerateResponseWithProgressAsync(System.String)

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Parametry
podpowiedź
Zwraca

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

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
Parametry
Opcje
podpowiedź
Zwraca

LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions,Microsoft.Windows.AI.Generative.LanguageModelContext) — metoda

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);
Parametry
Opcje
podpowiedź
opcje filtrowania treści
kontekst
Zwraca

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

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametry
Tekst
opcjeFiltrowaniaTreści
Zwraca

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

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametry
Tekst
opcje filtrowania treści
Zwraca

Metoda LanguageModel.GenerateTokensAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Parametry
Tekst
Zwraca

LanguageModel.GenerateTokensAsync(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions) — metoda

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametry
Tekst
opcje filtrów treści
Zwraca

metoda LanguageModel.IsAvailable

public static bool IsAvailable ();
Zwraca

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

public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Parametry
kontekst
podpowiedź
Zwraca

Metoda LanguageModel.IsPromptLargerThanContext(System.String)

public bool IsPromptLargerThanContext (string prompt);
Parametry
podpowiedź
Zwraca

Metoda LanguageModel.MakeAvailableAsync

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

Klasa LanguageModelContext

public sealed class LanguageModelContext

Klasa LanguageModelOptions

public sealed class LanguageModelOptions

Konstruktor LanguageModelOptions.#ctor

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);
Parametry
umiejętność
tymczasowe
top_p
top_k

LanguageModelOptions.Skill, właściwość

public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
Wartość właściwości

LanguageModelOptions.Temp, właściwość

public float Temp { get; set; }
Wartość właściwości

Właściwość „LanguageModelOptions.Top_k”

public uint Top_k { get; set; }
Wartość właściwości

Właściwość Top_p z LanguageModelOptions

public float Top_p { get; set; }
Wartość właściwości

klasa LanguageModelResponse

public sealed class LanguageModelResponse

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

public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
Parametry
odpowiedź
stan

LanguageModelResponse, właściwość Response

public string Response { get; }
Wartość właściwości

Właściwość LanguageModelResponse.Status

public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Wartość właściwości

Wyliczenie LanguageModelResponseStatus

public enum LanguageModelResponseStatus

Pola

Ukończono: 0
W trakcie: 1
ZablokowanePrzezPolitykę: 2
PromptLargerThanContext: 3
BlokadaWedługPolityki: 4
OdpowiedźZablokowanaPrzezPolitykę: 5

LanguageModelSkill, wyliczenie

public enum LanguageModelSkill

Pola

Ogólne: 0
TextToTable: 1
Podsumowanie: 2
Ponowne zapisywanie: 3