Method ExtractKeywordsAsync
- Namespace
- LMKit.TextAnalysis
- Assembly
- LM-Kit.NET.dll
ExtractKeywordsAsync(string, CancellationToken)
Asynchronously extracts a set of keywords from the provided text content.
public Task<List<KeywordExtraction.KeywordItem>> ExtractKeywordsAsync(string content, CancellationToken cancellationToken = default)Parameters
- contentstring
- The text content from which to extract keywords. 
- cancellationTokenCancellationToken
- A token to cancel the operation if needed. 
Returns
- Task<List<KeywordExtraction.KeywordItem>>
- A task representing the asynchronous extraction operation that returns a list of extracted KeywordExtraction.KeywordItem instances upon completion. 
Examples
var keywords = await extractor.ExtractKeywordsAsync("Async example content about finance and banking.");
Console.WriteLine("Async Extraction Complete:");
foreach (var keyword in keywords)
{
    Console.WriteLine(keyword.Value);
}Exceptions
- ArgumentNullException
- Thrown when the content is null or empty. 
ExtractKeywordsAsync(Attachment, CancellationToken)
Asynchronously extracts a set of keywords from an image provided as an Attachment.
public Task<List<KeywordExtraction.KeywordItem>> ExtractKeywordsAsync(Attachment content, CancellationToken cancellationToken = default)Parameters
- contentAttachment
- The attachment representing the image from which to extract keywords. 
- cancellationTokenCancellationToken
- A token to cancel the operation if needed. 
Returns
- Task<List<KeywordExtraction.KeywordItem>>
- A task representing the asynchronous extraction operation that returns a list of extracted KeywordExtraction.KeywordItem instances upon completion. 
Examples
// Asynchronous extraction from an image attachment
var keywords = await extractor.ExtractKeywordsAsync(imageAttachment);
Console.WriteLine("Image Keyword Extraction Complete:");
foreach (var keyword in keywords)
{
    Console.WriteLine(keyword.Value);
}Exceptions
- ArgumentNullException
- Thrown when the attachment is null. 
- InvalidModelException
- Thrown when the underlying language model does not support vision input, which is required to analyze image attachments.