Token counting and context management for LLMs
ctx_context - Track token usage (total/used/left)ctx_compact - Compress text using zlib/gzip algorithmsctx_remove - Clear context and reset usagectx_token_count - Count tokens for various LLM providersctx_memory_store - Store data in-memory (process lifetime)ctx_memory_recall - Retrieve stored datactx_estimate_cost - Estimate API costs for various providers{
"name": "ctx_token_count",
"arguments": {
"text": "Your text here",
"model": "gpt-4"
}
}
{
"name": "ctx_estimate_cost",
"arguments": {
"provider": "anthropic",
"model": "claude-3-opus",
"input_tokens": 1000,
"output_tokens": 500
}
}
Calculates the estimated cost for API usage based on the provider's pricing model.
{
"name": "ctx_compact",
"arguments": {
"text": "Long text to compress...",
"algorithm": "gzip"
}
}
{
"name": "ctx_memory_store",
"arguments": {
"key": "user_preferences",
"value": "{\"theme\": \"dark\"}"
}
}
{
"name": "ctx_memory_recall",
"arguments": {
"key": "user_preferences"
}
}
{
"name": "ctx_context",
"arguments": {
"action": "status"
}
}
{
"name": "ctx_remove",
"arguments": {
"scope": "all"
}
}