Condividi tramite


Riferimento API per Phi Silica nel SDK per app di Windows

Importante

Disponibile nell'ultimo rilascio del canale sperimentale di Windows App SDK.

Il canale sperimentale di Windows App SDK include API e funzionalità nelle fasi iniziali dello sviluppo. Tutte le API nel canale sperimentale sono soggette a revisioni estese e modifiche di rilievo e possono essere rimosse dalle versioni successive in qualsiasi momento. Le funzionalità sperimentali non sono supportate per l'uso in ambienti di produzione e le app che le usano non possono essere pubblicate in Microsoft Store.

  • Phi Silica non è disponibile in Cina.
  • Le app non in pacchetto non sono supportate.

Informazioni sulle API di SDK per app di Windows che possono accedere a modelli linguistici locali, ad esempio Phi Silica, il modello di linguaggio locale più potente di NPU ottimizzato di Microsoft che consente l'elaborazione e la generazione di chat su dispositivo, ragionamento su testo, risoluzione matematica, generazione di codice e altro ancora.

Per altre informazioni, vedere Introduzione a Phi Silica nel SDK per app di Windows.

Suggerimento

Inviare commenti e suggerimenti su queste API e le relative funzionalità creando un nuovo problema nel repository GitHub di Windows App SDK (includere Phi Silica nel titolo) o rispondendo a un problema esistente .


Spazio dei nomi Microsoft.Windows.AI.Generative

Fornisce API per l'elaborazione e le risposte dei prompt di intelligenza artificiale locali e generativi sul dispositivo.

Classe ImageDescriptionGenerator

public sealed class ImageDescriptionGenerator : System.IDisposable

Metodo ImageDescriptionGenerator.Close

// This member is not implemented in C#
Osservazioni:

Non implementato in C#.

Metodo ImageDescriptionGenerator.CreateAsync per la creazione asincrona di descrizioni delle immagini

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

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

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

Avvertimento

Quando si chiama ImageDescriptionGenerator.DescribeAsync() su un'immagine, a volte viene generato un errore. Questo errore può essere ignorato, consentendo al debugger di continuare e generare l'output corretto. L'errore è visibile solo nell'ambiente di sviluppo, non per gli utenti finali (i clienti che usano l'app). L'uso di build di debug o build di release attiverà questo errore. L'errore viene visualizzato in modo intermittente e non in ogni esecuzione.

Metodo 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);
Parametri
immagine
scenario
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
immagine
scenario
opzioniFiltroContenuti
Valori restituiti
Osservazioni:

Metodo ImageDescriptionGenerator.IsAvailable

public static bool IsAvailable ();

Metodo ImageDescriptionGenerator.MakeAvailableAsync

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

Enumeratore ImageDescriptionScenario

public enum ImageDescriptionScenario

Campi

Accessibilità: 1
Didascalia: 2
Narrazione Dettagliata: 3
OfficeCharts: 4

Classe ImageLLMAdapterCreator

public sealed class ImageLLMAdapterCreator : System.IDisposable

Metodo Close di ImageLLMAdapterCreator

// This member is not implemented in C#
Osservazioni:

Non implementato in C#.

Metodo ImageLLMAdapterCreator.CreateAsync

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

Il metodo ImageLLMAdapterCreator.GetImageLLMEmbeddings(Microsoft.Windows.SemanticSearch.EmbeddingVector)

public System.Collections.Generic.IReadOnlyList<float> GetImageLLMEmbeddings (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parametri
embeddings
Valori restituiti

Metodo ImageLLMAdapterCreator.GetImageLLMEmbeddingsAsync(Microsoft.Windows.SemanticSearch.EmbeddingVector)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<float>> GetImageLLMEmbeddingsAsync (Microsoft.Windows.SemanticSearch.EmbeddingVector embeddings);
Parametri
embeddings
Valori restituiti

Metodo ImageLLMAdapterCreator.GetModelInputSize

public uint GetModelInputSize ();
Valori restituiti

Metodo ImageLLMAdapterCreator.GetModelOutputSize

public uint GetModelOutputSize ();
Valori restituiti

Metodo ImageLLMAdapterCreator.IsAvailable

public static bool IsAvailable ();
Valori restituiti

Metodo ImageLLMAdapterCreator.MakeAvailableAsync

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

Classe ModelloLinguaggio

public sealed class LanguageModel : System.IDisposable

Rappresenta un oggetto che può interagire con un modello linguistico locale per generare risposte per una richiesta fornita.

Metodo LanguageModel.Close

Elimina l'oggetto e le risorse associate.

Osservazioni:

Non implementato in C#.

Metodo LanguageModel.CreateAsync

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

Crea in modo asincrono una nuova istanza della classe LanguageModel.

Valori restituiti

Nuova istanza della classe TextRecognizer.

Il metodo LanguageModel.CreateContext

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext ();
Valori restituiti
Osservazioni:

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

public Microsoft.Windows.AI.Generative.LanguageModelContext CreateContext (string systemPrompt, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametri
systemPrompt
opzioniFiltroContenuti
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
prompt
opzioniFiltroContenuti
Valori restituiti
Osservazioni:

Metodo LanguageModel.GenerateEmbeddingVector(System.String)

public System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector> GenerateEmbeddingVector (string prompt);
Parametri
prompt
Valori restituiti
Osservazioni:

Metodo LanguageModel.GenerateEmbeddingVectorAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<Microsoft.Windows.SemanticSearch.EmbeddingVector>> GenerateEmbeddingVectorAsync (string prompt);
Parametri
prompt
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
prompt
opzioniFiltroContenuti
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
Opzioni
prompt
opzioniFiltroContenuti
Valori restituiti
Osservazioni:

Metodo LanguageModel.GenerateResponseAsync(System.String)

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

Genera e restituisce una risposta completa per un singolo prompt.

Parametri
prompt

Una richiesta sotto forma di domanda.

Valori restituiti

Stringa di risposta e stato.

Eccezioni

ArgumentException: il prompt specificato è più lungo del numero massimo di token che il modello può accettare.

Metodo 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);
Parametri
Opzioni
prompt
opzioniFiltroContenuti
contesto
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
Opzioni
prompt
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
Opzioni
promptEmbedding
opzioniFiltroContenuti
contesto
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
Opzioni
promptEmbedding
opzioniFiltroContenuti
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
promptEmbedding
Valori restituiti
Osservazioni:

Metodo 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);
Parametri
Opzioni
promptEmbedding
Valori restituiti

Metodo 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);
Parametri
Opzioni
promptTokens
Valori restituiti

Metodo 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);
Parametri
Opzioni
promptTokens
opzioniFiltroContenuti
contesto
Valori restituiti

Metodo 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);
Parametri
Opzioni
promptTokens
opzioniFiltroContenuti
Valori restituiti

Metodo 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);
Parametri
Opzioni
prompt
opzioniFiltroContenuti
Valori restituiti

Metodo LanguageModel.GenerateResponseWithProgressAsync(System.String)

public Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.AI.Generative.LanguageModelResponse,string> GenerateResponseWithProgressAsync (string prompt);
Parametri
prompt
Valori restituiti

Metodo 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);
Parametri
Opzioni
prompt
Valori restituiti

Metodo 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);
Parametri
Opzioni
prompt
opzioniFiltroContenuti
contesto
Valori restituiti

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

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametri
Testo
opzioniFiltroContenuti
Valori restituiti

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

public System.Collections.Generic.IReadOnlyList<long> GenerateTokens (string text, Microsoft.Windows.AI.ContentModeration.ContentFilterOptions contentFilterOptions);
Parametri
Testo
opzioniFiltroContenuti
Valori restituiti

Metodo LanguageModel.GenerateTokensAsync(System.String)

public Windows.Foundation.IAsyncOperation<System.Collections.Generic.IReadOnlyList<long>> GenerateTokensAsync (string text);
Parametri
Testo
Valori restituiti

Metodo 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);
Parametri
Testo
opzioniFiltroContenuti
Valori restituiti

Metodo LanguageModel.IsAvailable

public static bool IsAvailable ();
Valori restituiti

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

public bool IsPromptLargerThanContext (Microsoft.Windows.AI.Generative.LanguageModelContext context, string prompt);
Parametri
contesto
prompt
Valori restituiti

Metodo LanguageModel.IsPromptLargerThanContext(System.String)

public bool IsPromptLargerThanContext (string prompt);
Parametri
prompt
Valori restituiti

Metodo di LanguageModel.MakeAvailableAsync

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

Classe LanguageModelContext

public sealed class LanguageModelContext

Classe LanguageModelOptions

public sealed class LanguageModelOptions

Costruttore LanguageModelOptions.#ctor

public LanguageModelOptions ();

Costruttore 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);
Parametri
skill
temp
top_p
top_k

Proprietà Abilità del modello di linguaggio

public Microsoft.Windows.AI.Generative.LanguageModelSkill Skill { get; set; }
Valore proprietà

Proprietà LanguageModelOptions.Temp

public float Temp { get; set; }
Valore proprietà

LanguageModelOptions.Top_k (proprietà)

public uint Top_k { get; set; }
Valore proprietà

Proprietà LanguageModelOptions.Top_p

public float Top_p { get; set; }
Valore proprietà

Classe LanguageModelResponse

public sealed class LanguageModelResponse

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

public LanguageModelResponse (string response, Microsoft.Windows.AI.Generative.LanguageModelResponseStatus status);
Parametri
risposta
stato

Proprietà LanguageModelResponse.Response

public string Response { get; }
Valore proprietà

Proprietà Status di LanguageModelResponse

public Microsoft.Windows.AI.Generative.LanguageModelResponseStatus Status { get; }
Valore proprietà

Enumerazione StatoRispostaModelloLinguistico

public enum LanguageModelResponseStatus

Campi

Completamento: 0
InProgress: 1
BlockedByPolicy: 2
PromptLargerThanContext: 3
PromptBloccatoDallaPolitica: 4
RispostaBloccataDallaPolitica: 5

Enumerazione Abilità del Modello di Linguaggio

public enum LanguageModelSkill

Campi

Generale: 0
TextToTable: 1
Riepilogo: 2
Riscrittura: 3