Some checks failed
Create and publish Docker images with specific build args / build-main-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-main-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-cuda126-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / build-slim-image (linux/amd64, ubuntu-latest) (push) Has been cancelled
Create and publish Docker images with specific build args / build-slim-image (linux/arm64, ubuntu-24.04-arm) (push) Has been cancelled
Create and publish Docker images with specific build args / merge-main-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-cuda126-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-ollama-images (push) Has been cancelled
Create and publish Docker images with specific build args / merge-slim-images (push) Has been cancelled
Python CI / Format Backend (3.11.x) (push) Has been cancelled
Python CI / Format Backend (3.12.x) (push) Has been cancelled
Frontend Build / Format & Build Frontend (push) Has been cancelled
Frontend Build / Frontend Unit Tests (push) Has been cancelled
Close inactive issues / close-issues (push) Has been cancelled
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
# credits model - deprecated, kept for backward compatibility
|
|
# this module is replaced by the subscription system
|
|
|
|
from decimal import Decimal
|
|
from typing import Optional, List
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class SetCreditFormDetail(BaseModel):
|
|
operator: str = ""
|
|
api_name: str = ""
|
|
api_params: dict = {}
|
|
|
|
|
|
class SetCreditForm(BaseModel):
|
|
user_id: str
|
|
credit: Decimal = Decimal("0")
|
|
detail: Optional[SetCreditFormDetail] = None
|
|
|
|
|
|
class AddCreditForm(BaseModel):
|
|
user_id: str
|
|
amount: Decimal = Decimal("0")
|
|
detail: Optional[SetCreditFormDetail] = None
|
|
|
|
|
|
class CreditModel(BaseModel):
|
|
user_id: str
|
|
credit: Decimal = Decimal("0")
|
|
|
|
|
|
class Credits:
|
|
"""
|
|
Deprecated credits class.
|
|
Kept for backward compatibility - returns dummy data.
|
|
The subscription system now handles billing.
|
|
"""
|
|
|
|
@classmethod
|
|
def init_credit_by_user_id(cls, user_id: str) -> CreditModel:
|
|
return CreditModel(user_id=user_id, credit=Decimal("0"))
|
|
|
|
@classmethod
|
|
def get_credit_by_user_id(cls, user_id: str) -> Optional[CreditModel]:
|
|
return CreditModel(user_id=user_id, credit=Decimal("0"))
|
|
|
|
@classmethod
|
|
def set_credit_by_user_id(cls, form_data: SetCreditForm) -> CreditModel:
|
|
return CreditModel(user_id=form_data.user_id, credit=form_data.credit)
|
|
|
|
@classmethod
|
|
def add_credit_by_user_id(cls, form_data: AddCreditForm) -> CreditModel:
|
|
return CreditModel(user_id=form_data.user_id, credit=form_data.amount)
|
|
|
|
@classmethod
|
|
def list_credits_by_user_id(cls, user_ids: List[str]) -> List[CreditModel]:
|
|
return [CreditModel(user_id=uid, credit=Decimal("0")) for uid in user_ids]
|