Référence d’API pour Phi Silicon dans le Kit de développement logiciel (SDK) d’application Windows
Important
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 du canal expérimental font l’objet de révisions approfondies et de changements cassants 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.
- Les applications non empaquetées ne sont pas prises en charge.
Découvrez les API du KIT de développement logiciel (SDK) d’application Windows qui peuvent accéder aux modèles de langage local tels que Phi Silicon, le modèle de langage local le plus puissant de Microsoft qui permet le traitement et la génération de conversation sur l’appareil, le raisonnement sur le texte, la résolution mathématique, la génération de code, etc.
Pour plus d’informations, consultez Prise en main de Phi Silicon dans le Kit de développement logiciel (SDK) d’application 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 le traitement et les réponses locales des invites d’IA génératives sur l’appareil.
La classe ImageDescriptionGenerator
public sealed class ImageDescriptionGenerator : System.IDisposable
Méthode ImageDescriptionGenerator.Close
// This member is not implemented in C#
Notes
Non implémenté dans C#.
Méthode ImageDescriptionGenerator.CreateAsync
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageDescriptionGenerator> CreateAsync ();
Méthode ImageDescriptionGenerator.DescribeAsync(Microsoft.Windows.Imaging.ImageBuffer)
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> DescribeAsync (Microsoft.Windows.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);
Paramètres
image
scenario
Retours
Notes
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);
Paramètres
image
scenario
optionsDeFiltrageDeContenu
Retours
Notes
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#
Notes
Non implémenté dans C#.
Méthode ImageLLMAdapterCreator.CreateAsync
public static Windows.Foundation.IAsyncOperation<Microsoft.Windows.AI.Generative.ImageLLMAdapterCreator> CreateAsync ();
Retours
Méthode ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector)
public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Paramètres
incorporations
Retours
Méthode ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector)
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Paramètres
incorporations
Retours
Méthode ImageLLMAdapterCreator.GetModelInputSize
public uint GetModelInputSize ();
Retours
Méthode ImageLLMAdapterCreator.GetModelOutputSize
public uint GetModelOutputSize ();
Retours
Méthode ImageLLMAdapterCreator.IsAvailable
public static bool IsAvailable ();
Retours
Méthode ImageLLMAdapterCreator.MakeAvailableAsync
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
Retours
Classe LanguageModel
public sealed class LanguageModel : System.IDisposable
Représente un objet qui peut interagir avec un modèle de langage local pour générer des réponses à une invite fournie.
Méthode LanguageModel.Close
Supprime l’objet et les ressources associées.
Notes
Non implémenté dans 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.
Retours
Une nouvelle instance de la classe TextRecognizer.
Méthode LanguageModel.CreateContext
public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
Retours
Notes
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);
Paramètres
systemPrompt
optionsDeFiltrageDeContenu
Retours
Notes
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);
Paramètres
prompt
optionsDeFiltrageDeContenu
Retours
Notes
Méthode LanguageModel.GenerateEmbeddingVector(System.String)
public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Paramètres
prompt
Retours
Notes
Méthode LanguageModel.GenerateEmbeddingVectorAsync(System.String)
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Paramètres
prompt
Retours
Notes
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);
Paramètres
prompt
optionsDeFiltrageDeContenu
Retours
Notes
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);
Paramètres
options
prompt
optionsDeFiltrageDeContenu
Retours
Notes
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 pour une seule invite.
Paramètres
prompt
Une invite sous forme de question.
Retours
Une chaîne de réponse et un statut.
Exceptions
ArgumentException : l’invite spécifiée est plus longue que le nombre maximum de jetons que le modèle peut accepter.
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);
Paramètres
options
prompt
optionsDeFiltrageDeContenu
contexte
Retours
Notes
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);
Paramètres
options
prompt
Retours
Notes
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);
Paramètres
options
promptEmbedding
optionsDeFiltrageDeContenu
contexte
Retours
Notes
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);
Paramètres
options
promptEmbedding
optionsDeFiltrageDeContenu
Retours
Notes
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);
Paramètres
promptEmbedding
Retours
Notes
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);
Paramètres
options
promptEmbedding
Retours
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);
Paramètres
options
promptTokens
Retours
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);
Paramètres
options
promptTokens
optionsDeFiltrageDeContenu
contexte
Retours
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);
Paramètres
options
promptTokens
optionsDeFiltrageDeContenu
Retours
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);
Paramètres
options
prompt
optionsDeFiltrageDeContenu
Retours
Méthode LanguageModel.GenerateResponseWithProgressAsync(System.String)
public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Paramètres
prompt
Retours
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);
Paramètres
options
prompt
Retours
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);
Paramètres
options
prompt
optionsDeFiltrageDeContenu
contexte
Retours
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);
Paramètres
texte
optionsDeFiltrageDeContenu
Retours
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);
Paramètres
texte
optionsDeFiltrageDeContenu
Retours
Méthode LanguageModel.GenerateTokensAsync(System.String)
public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Paramètres
texte
Retours
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);
Paramètres
texte
optionsDeFiltrageDeContenu
Retours
Méthode LanguageModel.IsAvailable
public static bool IsAvailable ();
Retours
Méthode LanguageModel.IsPromptLargerThanContext(Microsoft.Windows.AI.Generative.LanguageModelContext,System.String)
public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Paramètres
contexte
prompt
Retours
Méthode LanguageModel.IsPromptLargerThanContext(System.String)
public bool IsPromptLargerThanContext (string prompt);
Paramètres
prompt
Retours
Méthode LanguageModel::MakeAvailableAsync
public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
Retours
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);
Paramètres
skill
temp
top_p
top_k
Propriété LanguageModelOptions.Skill
public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
Valeur de la propriété
Propriété LanguageModelOptions.Temp
public float Temp { get; set; }
Valeur de la propriété
Propriété LanguageModelOptions.Top_k
public uint Top_k { get; set; }
Valeur de la propriété
Propriété LanguageModelOptions.Top_p
public float Top_p { get; set; }
Valeur de la 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);
Paramètres
réponse
status
Propriété LanguageModelResponse.Response
public string Response { get; }
Valeur de la propriété
Propriété LanguageModelResponse.Status
public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Valeur de la propriété
LanguageModelResponseStatus, énumération
public enum LanguageModelResponseStatus
Champs
Terminé : 0
InProgress : 1
BlockedByPolicy : 2
PromptLargerThanContext : 3
PromptBlockedByPolicy: 4
ResponseBlockedByPolicy: 5
LanguageModelSkill, énumération
public enum LanguageModelSkill
Champs
Général : 0
TextToTable : 1
Résumer : 2
Rewrite: 3
Contenu connexe
- Le développement d’applications et fonctionnalités d’intelligence artificielle générative responsable sur Windows
- Prise en main de Phi Silicon dans le Kit de développement logiciel (SDK) d’application Windows
- Kit de développement logiciel (SDK) pour application Windows
- Notes de la dernière version pour le SDK d'application Windows