Partager via


Référence d’API pour Phi Silica dans le SDK d’applications Windows

Importante

Disponible dans la dernière version de la chaîne expérimentale du SDK d’applications Windows.

Le canal expérimental du Kit de développement logiciel (SDK) d’application Windows inclut des API et des fonctionnalités au début du développement. Toutes les API de la chaîne expérimentale font l'objet de révisions approfondies et de changements radicaux et peuvent être supprimées des versions ultérieures à tout moment. Les fonctionnalités expérimentales ne sont pas prises en charge pour une utilisation dans les environnements de production et les applications qui les utilisent ne peuvent pas être publiées dans le Microsoft Store.

  • Phi Silicon n’est pas disponible en Chine continentale.
  • Les applications autonomes ne sont pas prises en charge.

Découvrez les API du SDK d’applications Windows capables d'accéder à des modèles de langage locaux tels que Phi Silica, le modèle de langage local optimisé pour NPU le plus puissant de Microsoft, qui permet de traiter et générer des conversations sur l’appareil, de raisonner sur des textes, de résoudre des problèmes mathématiques, de générer du code, etc.

Pour plus d’informations, consultez Bien démarrer avec Phi Silica dans le SDK d'applications Windows.

Conseil

Fournissez des commentaires sur ces API et leurs fonctionnalités en créant une nouvelle issue dans le dépôt GitHub du Kit de développement logiciel (SDK) d’application Windows (incluez Phi Silica dans le titre) ou en répondant à une issue existante.


Espace de noms Microsoft.Windows.AI.Generative

Fournit des API pour traiter et répondre à des prompts localement sur l'appareil grâce à l'IA générative.

La classe ImageDescriptionGenerator

public sealed class ImageDescriptionGenerator : System.IDisposable

Méthode ImageDescriptionGenerator.Close

// This member is not implemented in C#
Remarques

Non implémenté en C#.

Méthode ImageDescriptionGenerator.CreateAsync

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

Méthode ImageDescriptionGenerator.DescribeAsync(Microsoft.Graphics.Imaging.ImageBuffer)

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

Warning

Lors de l'appel à ImageDescriptionGenerator.DescribeAsync() sur une image, une erreur est parfois générée. Cette erreur peut être ignorée, ce qui permet au débogueur de continuer et de générer une sortie correcte. L’erreur est visible uniquement dans l’environnement du développeur, et non pour les utilisateurs finaux (clients utilisant votre application). L’utilisation des builds Debug ou Release déclenche cette erreur. L’erreur s’affiche par intermittence et non à chaque exécution du processus.

Méthode 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);
Parameters
image
scenario
retourne :
Remarques

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);
Parameters
image
scenario
optionsDeFiltrageDeContenu
retourne :
Remarques

Méthode ImageDescriptionGenerator.IsAvailable

public static bool IsAvailable ();

Méthode ImageDescriptionGenerator.MakeAvailableAsync

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

ImageDescriptionScenario enumerator

public enum ImageDescriptionScenario

Champs

Accessibilité : 1
Légende : 2
DetailedNarration: 3
OfficeCharts: 4

Class ImageLLMAdapterCreator

public sealed class ImageLLMAdapterCreator : System.IDisposable

Méthode ImageLLMAdapterCreator.Close

// This member is not implemented in C#
Remarques

Non implémenté en C#.

Méthode ImageLLMAdapterCreator.CreateAsync

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

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

public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parameters
incorporations
retourne :

Méthode ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parameters
incorporations
retourne :

Méthode ImageLLMAdapterCreator.GetModelInputSize

public uint GetModelInputSize ();
retourne :

Méthode ImageLLMAdapterCreator.GetModelOutputSize

public uint GetModelOutputSize ();
retourne :

Méthode ImageLLMAdapterCreator.IsAvailable

public static bool IsAvailable ();
retourne :

Méthode ImageLLMAdapterCreator.MakeAvailableAsync

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

Classe LanguageModel

public sealed class LanguageModel : System.IDisposable

Représente un objet qui peut interagir avec un modèle de langage local pour répondre à un prompt.

Méthode LanguageModel.Close

Libère l’objet et ses ressources associées.

Remarques

Non implémenté en C#.

Méthode LanguageModel.CreateAsync

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

Crée de manière asynchrone une nouvelle instance de la classe LanguageModel.

retourne :

Une nouvelle instance de la classe TextRecognizer.

Méthode LanguageModel.CreateContext

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
retourne :
Remarques

Méthode LanguageModel.CreateContext(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext (string systemPrompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameters
systemPrompt
optionsDeFiltrageDeContenu
retourne :
Remarques

Méthode 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);
Parameters
prompt
optionsDeFiltrageDeContenu
retourne :
Remarques

Méthode LanguageModel.GenerateEmbeddingVector(System.String)

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Parameters
prompt
retourne :
Remarques

Méthode LanguageModel.GenerateEmbeddingVectorAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Parameters
prompt
retourne :
Remarques

Méthode 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);
Parameters
prompt
optionsDeFiltrageDeContenu
retourne :
Remarques

Méthode 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);
Parameters
options
prompt
optionsDeFiltrageDeContenu
retourne :
Remarques

Méthode LanguageModel.GenerateResponseAsync(System.String)

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

Génère et renvoie une réponse complète à un seul prompt.

Parameters
prompt

Un prompt sous forme de question.

retourne :

Une chaîne et un statut de réponse.

Exceptions

ArgumentException : le prompt spécifié est plus long que le nombre maximum de jetons accepté par le modèle.

Méthode 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);
Parameters
options
prompt
optionsDeFiltrageDeContenu
contexte
retourne :
Remarques

Méthode 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);
Parameters
options
prompt
retourne :
Remarques

Méthode 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);
Parameters
options
promptEmbedding
optionsDeFiltrageDeContenu
contexte
retourne :
Remarques

Méthode 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);
Parameters
options
promptEmbedding
optionsDeFiltrageDeContenu
retourne :
Remarques

Méthode 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);
Parameters
promptEmbedding
retourne :
Remarques

Méthode 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);
Parameters
options
promptEmbedding
retourne :

Méthode 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);
Parameters
options
promptTokens
retourne :

Méthode 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);
Parameters
options
promptTokens
optionsDeFiltrageDeContenu
contexte
retourne :

Méthode 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);
Parameters
options
promptTokens
optionsDeFiltrageDeContenu
retourne :

Méthode 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);
Parameters
options
prompt
optionsDeFiltrageDeContenu
retourne :

Méthode LanguageModel.GenerateResponseWithProgressAsync(System.String)

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Parameters
prompt
retourne :

Méthode 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);
Parameters
options
prompt
retourne :

Méthode 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);
Parameters
options
prompt
optionsDeFiltrageDeContenu
contexte
retourne :

Méthode LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameters
texte
optionsDeFiltrageDeContenu
retourne :

Méthode LanguageModel.GenerateTokens(System.String,Microsoft.Windows.AI.ContentModeration.ContentFilterOptions)

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parameters
texte
optionsDeFiltrageDeContenu
retourne :

Méthode LanguageModel.GenerateTokensAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Parameters
texte
retourne :

Méthode 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);
Parameters
texte
optionsDeFiltrageDeContenu
retourne :

Méthode LanguageModel.IsAvailable

public static bool IsAvailable ();
retourne :

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

public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Parameters
contexte
prompt
retourne :

Méthode LanguageModel.IsPromptLargerThanContext(System.String)

public bool IsPromptLargerThanContext (string prompt);
Parameters
prompt
retourne :

Méthode LanguageModel::MakeAvailableAsync

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

Class LanguageModelContext

public sealed class LanguageModelContext

Classe LanguageModelOptions

public sealed class LanguageModelOptions

Constructeur LanguageModelOptions.#ctor

public LanguageModelOptions ();

Constructeur 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);
Parameters
skill
temp
top_p
top_k

Propriété LanguageModelOptions.Skill

public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
Valeur de propriété

Propriété LanguageModelOptions.Temp

public float Temp { get; set; }
Valeur de propriété

Propriété LanguageModelOptions.Top_k

public uint Top_k { get; set; }
Valeur de propriété

Propriété LanguageModelOptions.Top_p

public float Top_p { get; set; }
Valeur de propriété

Classe LanguageModelResponse

public sealed class LanguageModelResponse

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

public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
Parameters
réponse
status

Propriété LanguageModelResponse.Response

public string Response { get; }
Valeur de propriété

Propriété LanguageModelResponse.Status

public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Valeur de propriété

LanguageModelResponseStatus, énumération

public enum LanguageModelResponseStatus

Champs

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

LanguageModelSkill, énumération

public enum LanguageModelSkill

Champs

General : 0
TextToTable : 1
Résumer : 2
Rewrite: 3