mirror of
https://github.com/dograh-hq/dograh.git
synced 2026-07-13 11:22:14 +02:00
feat: show model pricing in configuration UI (#528)
* feat: show model pricing in configuration UI * fix: display effective pricing rounding policy
This commit is contained in:
parent
e7494e9c21
commit
c76076fb93
13 changed files with 445 additions and 9 deletions
|
|
@ -68,6 +68,7 @@ from api.services.configuration.registry import (
|
|||
ServiceType,
|
||||
)
|
||||
from api.services.mps_billing import ensure_hosted_mps_billing_account_v2
|
||||
from api.services.mps_service_key_client import mps_service_key_client
|
||||
from api.services.organization_context import (
|
||||
OrganizationContextResponse,
|
||||
get_organization_context,
|
||||
|
|
@ -147,6 +148,22 @@ class TelephonyConfigWarningsResponse(BaseModel):
|
|||
vonage_missing_signature_secret_count: int
|
||||
|
||||
|
||||
class ModelConfigurationMetricPrice(BaseModel):
|
||||
metric_code: str
|
||||
display_name: str
|
||||
unit: str
|
||||
price_per_minute: float
|
||||
currency: str
|
||||
rounding_policy: str
|
||||
|
||||
|
||||
class ModelConfigurationPricingResponse(BaseModel):
|
||||
"""MPS-owned effective prices relevant to model configuration choices."""
|
||||
|
||||
platform_usage: ModelConfigurationMetricPrice | None = None
|
||||
dograh_model: ModelConfigurationMetricPrice | None = None
|
||||
|
||||
|
||||
@router.get("/context", response_model=OrganizationContextResponse)
|
||||
async def get_current_organization_context(user: UserModel = Depends(get_user)):
|
||||
"""Return organization-scoped configuration signals owned by Dograh."""
|
||||
|
|
@ -312,6 +329,34 @@ async def get_model_configuration_v2(
|
|||
return await _model_configuration_v2_response(user=user)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/model-configurations/v2/pricing",
|
||||
response_model=ModelConfigurationPricingResponse,
|
||||
)
|
||||
async def get_model_configuration_pricing(
|
||||
user: UserModel = Depends(get_user_with_selected_organization),
|
||||
) -> ModelConfigurationPricingResponse:
|
||||
"""Return the hosted organization prices shown in Model Configurations."""
|
||||
if DEPLOYMENT_MODE == "oss":
|
||||
return ModelConfigurationPricingResponse()
|
||||
|
||||
try:
|
||||
pricing = await mps_service_key_client.get_billing_pricing(
|
||||
user.selected_organization_id,
|
||||
)
|
||||
return ModelConfigurationPricingResponse.model_validate(pricing)
|
||||
except Exception as exc:
|
||||
logger.error(
|
||||
"Failed to get MPS model-configuration pricing for organization {}: {}",
|
||||
user.selected_organization_id,
|
||||
exc,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=502,
|
||||
detail="Failed to retrieve model configuration pricing",
|
||||
) from exc
|
||||
|
||||
|
||||
@router.put(
|
||||
"/model-configurations/v2",
|
||||
response_model=OrganizationAIModelConfigurationResponse,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue