Referência de API para Phi Silica no SDK do Aplicativo Windows
Importante
Disponível na versão de lançamento mais recente do canal experimental do SDK do Aplicativo do Windows.
O canal experimental do SDK do Aplicativo do Windows inclui APIs e recursos em estágios iniciais de desenvolvimento. Todas as APIs no canal experimental estão sujeitas a extensas revisões e alterações interruptivas, podendo ser removidas de versões subsequentes a qualquer momento. Não há suporte para recursos experimentais para uso em ambientes de produção e aplicativos que os usam não podem ser publicados na Microsoft Store.
- Phi Silica não está disponível na China continental.
- Não há suporte para aplicativos independentes.
Saiba mais sobre as APIs do SDK do Aplicativo Windows que podem acessar modelos de linguagem local, como Phi Silica, o modelo de linguagem ajustado local para NPU mais poderoso da Microsoft que permite o processamento no dispositivo e a geração de chat, raciocínio sobre texto, resolução matemática, geração de código e muito mais.
Para obter mais detalhes, consulte Introdução ao Phi Silica no SDK do Aplicativo Windows.
Dica
Forneça feedback sobre essas APIs e suas funcionalidades criando um novo problema no repositório GitHub do SDK do Aplicativo Windows (inclua Phi Silica no título) ou respondendo a um problema existente.
Namespace Microsoft.Windows.AI.Generative
Fornece APIs para processamento e respostas de IA generativa local no dispositivo.
Classe ImageDescriptionGenerator
public sealed class ImageDescriptionGenerator : System.IDisposable
Método ImageDescriptionGenerator.Close
// This member is not implemented in C#
Comentários
Não implementado em C#.
Método ImageDescriptionGenerator.CreateAsync
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageDescriptionGenerator> CreateAsync ();
Método ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer)
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Graphics.Imaging.ImageBuffer image);
Aviso
Ao chamar ImageDescriptionGenerator.DescribeAsync()
em uma imagem, às vezes ocorre um erro. Esse erro pode ser ignorado, permitindo que o depurador continue e gere a saída correta. O erro só fica visível no ambiente do desenvolvedor, não para usuários finais (clientes que usam seu aplicativo). O uso de compilações de Depuração ou de Versão disparará este erro. O erro aparece intermitentemente e não ocorre em todas as vezes.
Método 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);
Parâmetros
imagem
cenário
Retornos
Comentários
Método 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);
Parâmetros
imagem
cenário
opções de filtro de conteúdo
Retornos
Comentários
Método ImageDescriptionGenerator.IsAvailable
public static bool IsAvailable ();
Método ImageDescriptionGenerator.MakeAvailableAsync
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
Enumerador ImageDescriptionScenario
public enum ImageDescriptionScenario
Fields
Acessibilidade: 1
Legenda: 2
DetailedNarration: 3
OfficeCharts: 4
Classe ImageLLMAdapterCreator
public sealed class ImageLLMAdapterCreator : System.IDisposable
Método ImageLLMAdapterCreator.Close
// This member is not implemented in C#
Comentários
Não implementado em C#.
Método ImageLLMAdapterCreator.CreateAsync
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageLLMAdapterCreator> CreateAsync ();
Retornos
Método ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector)
public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parâmetros
Inserções
Retornos
Método ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector)
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parâmetros
Inserções
Retornos
Método ImageLLMAdapterCreator.GetModelInputSize
public uint GetModelInputSize ();
Retornos
Método ImageLLMAdapterCreator.GetModelOutputSize
public uint GetModelOutputSize ();
Retornos
Método ImageLLMAdapterCreator.IsAvailable
public static bool IsAvailable ();
Retornos
Método ImageLLMAdapterCreator.MakeAvailableAsync
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
Retornos
Classe LanguageModel
public sealed class LanguageModel : System.IDisposable
Representa um objeto que pode interagir com um modelo de linguagem local de modo a gerar respostas para uma solicitação fornecida.
Método LanguageModel.Close
Descarta o objeto e os recursos associados.
Comentários
Não implementado em C#.
Método LanguageModel.CreateAsync
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModel> CreateAsync ();
Cria de forma assíncrona uma instância da classe LanguageModel.
Retornos
Uma nova instância da classe TextRecognizer.
Método LanguageModel.CreateContext
public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
Retornos
Comentários
Método LanguageModel.CreateContext(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)
public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext (string systemPrompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parâmetros
systemPrompt
opções de filtro de conteúdo
Retornos
Comentários
Método 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);
Parâmetros
prompt
opções de filtro de conteúdo
Retornos
Comentários
Método LanguageModel.GenerateEmbeddingVector(System.String)
public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Parâmetros
prompt
Retornos
Comentários
Método LanguageModel.GenerateEmbeddingVectorAsync(System.String)
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Parâmetros
prompt
Retornos
Comentários
Método 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);
Parâmetros
prompt
opções de filtro de conteúdo
Retornos
Comentários
Método LanguageModel.GenerateResponseAsync(Microsoft.Windows.AI.Generative.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);
Parâmetros
options
prompt
opções de filtro de conteúdo
Retornos
Comentários
Método LanguageModel.GenerateResponseAsync(System.String)
public Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.LanguageModelResponse> GenerateResponseAsync (string prompt);
Gera e retorna uma resposta completa para uma única solicitação.
Parâmetros
prompt
Uma solicitação em forma de pergunta.
Retornos
Uma sequência de resposta e status.
Exceções
ArgumentException: a solicitação especificada é maior do que o número máximo de tokens que o modelo pode aceitar.
Método 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);
Parâmetros
options
prompt
opções de filtro de conteúdo
contexto
Retornos
Comentários
Método 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);
Parâmetros
options
prompt
Retornos
Comentários
Método 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);
Parâmetros
options
promptEmbedding
opções de filtro de conteúdo
contexto
Retornos
Comentários
Método 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);
Parâmetros
options
promptEmbedding
opções de filtro de conteúdo
Retornos
Comentários
Método 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);
Parâmetros
promptEmbedding
Retornos
Comentários
Método 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);
Parâmetros
options
promptEmbedding
Retornos
Método 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);
Parâmetros
options
promptTokens
Retornos
Método 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);
Parâmetros
options
promptTokens
opções de filtro de conteúdo
contexto
Retornos
Método 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);
Parâmetros
options
promptTokens
opções de filtro de conteúdo
Retornos
Método LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.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);
Parâmetros
options
prompt
opções de filtro de conteúdo
Retornos
Método LanguageModel.GenerateResponseWithProgressAsync(System.String)
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Parâmetros
prompt
Retornos
Método LanguageModel.GenerateResponseWithProgressAsync(Microsoft.Windows.AI.Generative.LanguageModelOptions,System.String)
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (Microsoft.Windows.AI.Generative.LanguageModelOptions options, string prompt);
Parâmetros
options
prompt
Retornos
Método 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);
Parâmetros
options
prompt
opções de filtro de conteúdo
contexto
Retornos
Método LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)
public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parâmetros
text
opções de filtro de conteúdo
Retornos
Método LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)
public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parâmetros
text
opções de filtro de conteúdo
Retornos
Método LanguageModel.GenerateTokensAsync(System.String)
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Parâmetros
text
Retornos
Método 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);
Parâmetros
text
opções de filtro de conteúdo
Retornos
Método LanguageModel.IsAvailable
public static bool IsAvailable ();
Retornos
Método LanguageModel.IsPromptLargerThanContext(Microsoft.Windows.AI.Generative.LanguageModelContext,System.String)
public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Parâmetros
contexto
prompt
Retornos
Método LanguageModel.IsPromptLargerThanContext(System.String)
public bool IsPromptLargerThanContext (string prompt);
Parâmetros
prompt
Retornos
Método LanguageModel.MakeAvailableAsync
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
Retornos
Classe LanguageModelContext
public sealed class LanguageModelContext
Classe LanguageModelOptions
public sealed class LanguageModelOptions
Construtor LanguageModelOptions.#ctor
public LanguageModelOptions ();
Construtor 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);
Parâmetros
skill
temp
top_p
top_k
Propriedade LanguageModelOptions.Skill
public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
Valor da propriedade
Propriedade LanguageModelOptions.Temp
public float Temp { get; set; }
Valor da propriedade
Propriedade LanguageModelOptions.Top_k
public uint Top_k { get; set; }
Valor da propriedade
Propriedade Top_p de LanguageModelOptions
public float Top_p { get; set; }
Valor da propriedade
Classe LanguageModelResponse
public sealed class LanguageModelResponse
Construtor LanguageModelResponse.#ctor(System.String,Microsoft.Windows.AI.Generative.LanguageModelResponseStatus)
public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
Parâmetros
response
status
Propriedade LanguageModelResponse.Response
public string Response { get; }
Valor da propriedade
Propriedade LanguageModelResponse.Status
public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Valor da propriedade
Enumeração LanguageModelResponseStatus
public enum LanguageModelResponseStatus
Fields
Concluído: 0
Em progresso: 1
Bloqueado pela política: 2
PromptLargerThanContext: 3
PromptBlockedByPolicy: 4
ResponseBlockedByPolicy: 5
Enumeração LanguageModelSkill
public enum LanguageModelSkill