dotnet / dotnet/extensions

Interface for counting tokens

Open
#7,290 0 comments 0 reactions 0 assignees View on GitHub
area-ai enhancement
Dominant language
C#
Stars
3.2k
Forks
894
Avg merge
1d 12h
Merged PRs (30d)
23

Description

Most providers now have an API for counting tokens, i.e. submit the full request as you otherwise would, but get back a token count rather than an actual response. We should consider adding an interface for this purpose, e.g.
```csharp
Task CountTokensAsync(IEnumerable, ChatOptions, CancellationToken);
```
It could be implemented by IChatClients that support it and served up from their GetService implementations.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.