-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
31 lines (24 loc) · 1.12 KB
/
Copy pathmodels.py
File metadata and controls
31 lines (24 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from sqlalchemy import Column, Integer, String, Float, ForeignKey, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from datetime import datetime
Base = declarative_base()
class Budget(Base):
__tablename__ = 'budgets'
id = Column(Integer, primary_key=True)
budget_id = Column(String(255), unique=True, nullable=False)
max_budget = Column(Float, nullable=False)
tpm = Column(Integer) # Tokens per minute
rpm = Column(Integer) # Requests per minute
created_at = Column(DateTime, default=datetime.utcnow)
# Relationships
customers = relationship("CustomerBudget", back_populates="budget")
class CustomerBudget(Base):
__tablename__ = 'customer_budgets'
id = Column(Integer, primary_key=True)
customer_id = Column(Integer, ForeignKey('customers.id'))
budget_id = Column(Integer, ForeignKey('budgets.id'))
created_at = Column(DateTime, default=datetime.utcnow)
# Relationships
customer = relationship("Customer", back_populates="budgets")
budget = relationship("Budget", back_populates="customers")