feat(#160): implement token budget monitoring gateway for enterprise RAG - #199
Open
anshul23102 wants to merge 1 commit into
Open
feat(#160): implement token budget monitoring gateway for enterprise RAG#199anshul23102 wants to merge 1 commit into
anshul23102 wants to merge 1 commit into
Conversation
…or enterprise RAG Add token budget management and monitoring for enterprise AI workloads: - app/core/token_budget.py: Core token budget management with: * Token usage tracking per request/user/API key/tenant * Cost estimation based on LLM provider pricing * Budget limit configuration and enforcement * Budget status tracking (healthy/warning/critical/exceeded) * Monthly budget tracking with automatic reset * Non-blocking budget checks with timeout handling * Graceful degradation on Redis failures - tests/test_token_budget.py: Comprehensive test suite with: * Token usage tracking across models (GPT-4, GPT-3.5, Claude) * Budget limit checking and enforcement * Budget status calculation * Cost estimation accuracy * Error handling and graceful failures Features: - Tenant-level budget configuration with USD limits - Per-user and per-API-key usage tracking - Cost estimation metrics exported for billing - Budget exceeded prevention with status alerts - Support for multiple LLM provider pricing models Enterprise benefits: - Visibility into token consumption across tenants - Cost control through configurable budget limits - Accurate cost estimation for billing - Usage metrics for capacity planning Fixes devloperdevesh#160
|
@anshul23102 is attempting to deploy a commit to the devloperdevesh's projects Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Hi @devloperdevesh! 👋 I've completed the implementation for Issue #160 (Token Budget Monitoring Gateway). What's Included
Key Features
Enterprise ImpactThis implementation provides:
For ReviewWhen reviewing, you might consider these labels for GSSoC scoring:
Ready for review! 🚀 Contributed as part of GSSoC 2026 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement token budget monitoring and management system for enterprise RAG workloads with tenant-level cost control and visibility.
Problem
Enterprise AI workloads generate unpredictable LLM costs due to excessive context sizes, repeated requests, and inefficient retrieval. The platform lacks visibility and control over token consumption per user, tenant, or API key.
Solution
Add token budget management layer with comprehensive tracking:
Core Features:
Supported Models:
Implementation
Acceptance Criteria
Enterprise Benefits
Fixes #160
GSSoC 2026 Contribution