Spaces:
Running
Running
Upload app/models/billing_schemas.py with huggingface_hub
Browse files
app/models/billing_schemas.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Pydantic schemas for billing endpoints.
|
| 3 |
+
"""
|
| 4 |
+
from pydantic import BaseModel
|
| 5 |
+
from typing import Optional, List
|
| 6 |
+
from datetime import datetime
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class UsageResponse(BaseModel):
|
| 10 |
+
"""Usage statistics response."""
|
| 11 |
+
tenant_id: str
|
| 12 |
+
period: str # "day" or "month"
|
| 13 |
+
total_requests: int
|
| 14 |
+
total_tokens: int
|
| 15 |
+
total_cost_usd: float
|
| 16 |
+
gemini_requests: int = 0
|
| 17 |
+
openai_requests: int = 0
|
| 18 |
+
start_date: datetime
|
| 19 |
+
end_date: datetime
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class PlanLimitsResponse(BaseModel):
|
| 23 |
+
"""Current plan limits response."""
|
| 24 |
+
tenant_id: str
|
| 25 |
+
plan_name: str
|
| 26 |
+
monthly_chat_limit: int # -1 for unlimited
|
| 27 |
+
current_month_usage: int
|
| 28 |
+
remaining_chats: Optional[int] # None if unlimited
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
class CostReportResponse(BaseModel):
|
| 32 |
+
"""Cost report response."""
|
| 33 |
+
tenant_id: str
|
| 34 |
+
period: str
|
| 35 |
+
total_cost_usd: float
|
| 36 |
+
total_requests: int
|
| 37 |
+
total_tokens: int
|
| 38 |
+
breakdown_by_provider: dict
|
| 39 |
+
breakdown_by_model: dict
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
class SetPlanRequest(BaseModel):
|
| 43 |
+
"""Request to set tenant plan."""
|
| 44 |
+
tenant_id: str
|
| 45 |
+
plan_name: str # "starter", "growth", or "pro"
|
| 46 |
+
|