Skip to content

[AI Evaluation] Rationalize IEvaluationTokenCounter interface #6234

@shyamnamboodiripad

Description

@shyamnamboodiripad

Currently IEvaluationTokenCounter has a single int CountTokens(string message) function that takes a string and returns a token count. Ideally, this would also support other modalities like images, audio etc. We may also want to make the function asynchronous (to support cases where IO may be needed).

The proposal is to change the function to CountTokensAsync(AIContent content, CancellationToken cancellationToken) with extension method overloads for counting tokens in IEnumerable<AIContent> and ChatMessage.

AIContent already models all supported modalities so it seems like an ideal candidate.

Metadata

Metadata

Labels

area-ai-evalMicrosoft.Extensions.AI.Evaluation and relatedenhancementThis issue represents an ask for new feature or an enhancement to an existing one

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions