Compartir a través de


Api ref for PhiLice in the SDK de Aplicaciones para Windows

Importante

Disponible en la versión más reciente del canal experimental del SDK de aplicaciones de Windows.

El canal experimental del SDK de aplicaciones de Windows incluye API y características en las primeras fases de desarrollo. Todas las API del canal experimental están sujetas a revisiones exhaustivas y cambios importantes y se pueden eliminar de versiones posteriores en cualquier momento. Las características experimentales no se admiten para su uso en entornos de producción y las aplicaciones que las usan no se pueden publicar en Microsoft Store.

  • PhiLice no está disponible en China.
  • No se admiten aplicaciones desempaquetadas.

Obtenga información sobre las API de SDK de Aplicaciones para Windows que pueden acceder a modelos de lenguaje local como PhiLice, el modelo de lenguaje local más eficaz de NPU optimizado para NPU que permite el procesamiento en el dispositivo y la generación de chats, razonamiento sobre texto, resolución matemática, generación de código, etc.

Para obtener más información, consulte Introducción a PhiLice en la SDK de Aplicaciones para Windows.

Sugerencia

Proporcione comentarios sobre estas API y su funcionalidad creando una nueva incidencia en el repositorio de GitHub de Windows App SDK (incluya Phi Silica en el título) o respondiendo a una incidencia existente.


Espacio de nombres Microsoft.Windows.AI.Generative

Proporcione API para el procesamiento local y en el dispositivo de consultas de IA generativa y las respuestas.

Clase ImageDescriptionGenerator

public sealed class ImageDescriptionGenerator : System.IDisposable

Método ImageDescriptionGenerator.Close

// This member is not implemented in C#
Comentarios

No se implementa en C#.

Método ImageDescriptionGenerator.CreateAsync

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

Método ImageDescriptionGenerator.DescribeAsync(Microsoft.Windows.Imaging.ImageBuffer)

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

Advertencia

Cuando se llama a ImageDescriptionGenerator.DescribeAsync() en una imagen, a veces se lanza un error. Este error se puede omitir, lo que permite que el depurador continúe y genere una salida correcta. El error solo está visible en el entorno de desarrollador, no para los usuarios finales (clientes que usan la aplicación). Usando Debug o Release builds se lanzará este error. El error aparece de forma intermitente y no en cada ejecución.

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
imagen
scenario
Devoluciones
Comentarios

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
imagen
scenario
opcionesDeFiltroDeContenido
Devoluciones
Comentarios

Método ImageDescriptionGenerator.IsAvailable

public static bool IsAvailable ();

Método MakeAvailableAsync de ImageDescriptionGenerator

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

Enumerador ImageDescriptionScenario

public enum ImageDescriptionScenario

Fields

Accesibilidad: 1
Subtítulo: 2
DetailedNarration: 3
OfficeCharts: 4

Clase ImageLLMAdapterCreator

public sealed class ImageLLMAdapterCreator : System.IDisposable

Método ImageLLMAdapterCreator.Close

// This member is not implemented in C#
Comentarios

No se implementa en C#.

Método ImageLLMAdapterCreator.CreateAsync

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

Método ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector)

public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parámetros
embeddings
Devoluciones

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
embeddings
Devoluciones

Método ImageLLMAdapterCreator.GetModelInputSize

public uint GetModelInputSize ();
Devoluciones

Método ImageLLMAdapterCreator.GetModelOutputSize

public uint GetModelOutputSize ();
Devoluciones

Método `ImageLLMAdapterCreator.IsAvailable`

public static bool IsAvailable ();
Devoluciones

Método ImageLLMAdapterCreator.MakeAvailableAsync

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

Clase LanguageModel

public sealed class LanguageModel : System.IDisposable

Representa un objeto que puede interactuar con un modelo de lenguaje local para generar respuestas para un mensaje proporcionado.

Método LanguageModel.Close

Elimina el objeto y los recursos asociados.

Comentarios

No se implementa en C#.

Método LanguageModel.CreateAsync

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

Crea de forma asíncrona una nueva instancia de la clase LanguageModel.

Devoluciones

Nueva instancia de la clase TextRecognizer.

Método LanguageModel.CreateContext

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
Devoluciones
Comentarios

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
Opciones de filtro de contenido
Devoluciones
Comentarios

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
símbolo del sistema
opcionesDeFiltroDeContenido
Devoluciones
Comentarios

Método LanguageModel.GenerateEmbeddingVector(System.String)

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Parámetros
símbolo del sistema
Devoluciones
Comentarios

Método LanguageModel.GenerateEmbeddingVectorAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Parámetros
símbolo del sistema
Devoluciones
Comentarios

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
símbolo del sistema
opcionesDeFiltroDeContenido
Devoluciones
Comentarios

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
opciones
símbolo del sistema
opciones de filtro de contenido
Devoluciones
Comentarios

Método LanguageModel.GenerateResponseAsync(System.String)

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

Genera y devuelve una respuesta completa para una consulta única.

Parámetros
símbolo del sistema

Una consulta en forma de pregunta.

Devoluciones

Una cadena de respuesta y estado.

Excepciones

ArgumentException: la consulta especificada es mayor que el número máximo de tokens que puede aceptar el modelo.

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
opciones
símbolo del sistema
opciones de filtro de contenido
context
Devoluciones
Comentarios

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
opciones
símbolo del sistema
Devoluciones
Comentarios

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
opciones
promptEmbedding
opciones de filtro de contenido
context
Devoluciones
Comentarios

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
opciones
promptEmbedding
opciones de filtro de contenido
Devoluciones
Comentarios

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
Devoluciones
Comentarios

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
opciones
promptEmbedding
Devoluciones

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
opciones
promptTokens
Devoluciones

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
opciones
promptTokens
opciones de filtro de contenido
context
Devoluciones

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
opciones
promptTokens
opcionesDeFiltroDeContenido
Devoluciones

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
opciones
símbolo del sistema
opciones de filtro de contenido
Devoluciones

Método LanguageModel.GenerateResponseWithProgressAsync(System.String)

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Parámetros
símbolo del sistema
Devoluciones

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
opciones
símbolo del sistema
Devoluciones

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
opciones
símbolo del sistema
opcionesDeFiltroDeContenido
context
Devoluciones

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
opcionesDeFiltroDeContenido
Devoluciones

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
opcionesDeFiltroDeContenido
Devoluciones

Método LanguageModel.GenerateTokensAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Parámetros
text
Devoluciones

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
opciones de filtro de contenido
Devoluciones

Método LanguageModel.IsAvailable

public static bool IsAvailable ();
Devoluciones

Método LanguageModel.IsPromptLargerThanContext(Microsoft.Windows.AI.Generative.LanguageModelContext,System.String)

public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Parámetros
context
símbolo del sistema
Devoluciones

Método LanguageModel.IsPromptLargerThanContext(System.String)

public bool IsPromptLargerThanContext (string prompt);
Parámetros
símbolo del sistema
Devoluciones

Método MakeAvailableAsync de LanguageModel

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

Clase `LanguageModelContext`

public sealed class LanguageModelContext

Clase LanguageModelOptions

public sealed class LanguageModelOptions

Constructor LanguageModelOptions.#ctor

public LanguageModelOptions ();

Constructor 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
aptitudes
temp
top_p
top_k

Propiedad LanguageModelOptions.Skill

public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
Valor de propiedad

Propiedad LanguageModelOptions.Temp

public float Temp { get; set; }
Valor de propiedad

Propiedad LanguageModelOptions.Top_k

public uint Top_k { get; set; }
Valor de propiedad

Propiedad LanguageModelOptions.Top_p

public float Top_p { get; set; }
Valor de propiedad

Clase LanguageModelResponse

public sealed class LanguageModelResponse

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

public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
Parámetros
response
status

Propiedad LanguageModelResponse.Response

public string Response { get; }
Valor de propiedad

Propiedad LanguageModelResponse.Status

public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Valor de propiedad

Enumeración LanguageModelResponseStatus

public enum LanguageModelResponseStatus

Fields

Complete: 0
InProgress: 1
BlockedByPolicy: 2
PromptLargerThanContext: 3
PromptBlockedByPolicy: 4
ResponseBlockedByPolicy: 5

Enumeración LanguageModelSkill

public enum LanguageModelSkill

Fields

General: 0
TextToTable: 1
Resumen: 2
Reescritura: 3