- Refined entitlements to work with MiB for both embeddings and storage
- Improved DocumentVersion storage attributes to reflect Minio settings - Added size to DocumentVersions to easily calculate usage - License / LicenseTier forms and views added
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
from datetime import date
|
||||
|
||||
from common.extensions import db
|
||||
from flask_security import UserMixin, RoleMixin
|
||||
from sqlalchemy.dialects.postgresql import ARRAY
|
||||
import sqlalchemy as sa
|
||||
|
||||
from common.models.entitlements import License
|
||||
|
||||
|
||||
class Tenant(db.Model):
|
||||
"""Tenant model"""
|
||||
@@ -50,9 +54,6 @@ class Tenant(db.Model):
|
||||
fallback_algorithms = db.Column(ARRAY(sa.String(50)), nullable=True)
|
||||
|
||||
# Licensing Information
|
||||
license_start_date = db.Column(db.Date, nullable=True)
|
||||
license_end_date = db.Column(db.Date, nullable=True)
|
||||
allowed_monthly_interactions = db.Column(db.Integer, nullable=True)
|
||||
encrypted_chat_api_key = db.Column(db.String(500), nullable=True)
|
||||
encrypted_api_key = db.Column(db.String(500), nullable=True)
|
||||
|
||||
@@ -60,9 +61,24 @@ class Tenant(db.Model):
|
||||
embed_tuning = db.Column(db.Boolean, nullable=True, default=False)
|
||||
rag_tuning = db.Column(db.Boolean, nullable=True, default=False)
|
||||
|
||||
# Entitlements
|
||||
currency = db.Column(db.String(20), nullable=True)
|
||||
usage_email = db.Column(db.String(255), nullable=True)
|
||||
|
||||
# Relations
|
||||
users = db.relationship('User', backref='tenant')
|
||||
domains = db.relationship('TenantDomain', backref='tenant')
|
||||
licenses = db.relationship('License', back_populates='tenant')
|
||||
license_usages = db.relationship('LicenseUsage', backref='tenant')
|
||||
|
||||
@property
|
||||
def current_license(self):
|
||||
today = date.today()
|
||||
return License.query.filter(
|
||||
License.tenant_id == self.id,
|
||||
License.start_date <= today,
|
||||
(License.end_date.is_(None) | (License.end_date >= today))
|
||||
).order_by(License.start_date.desc()).first()
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Tenant {self.id}: {self.name}>"
|
||||
@@ -91,11 +107,10 @@ class Tenant(db.Model):
|
||||
'chat_RAG_temperature': self.chat_RAG_temperature,
|
||||
'chat_no_RAG_temperature': self.chat_no_RAG_temperature,
|
||||
'fallback_algorithms': self.fallback_algorithms,
|
||||
'license_start_date': self.license_start_date,
|
||||
'license_end_date': self.license_end_date,
|
||||
'allowed_monthly_interactions': self.allowed_monthly_interactions,
|
||||
'embed_tuning': self.embed_tuning,
|
||||
'rag_tuning': self.rag_tuning,
|
||||
'currency': self.currency,
|
||||
'usage_email': self.usage_email,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user