mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
model_dump()
This commit is contained in:
parent
401630833f
commit
0af0de8a96
1 changed files with 66 additions and 1 deletions
|
@ -1,8 +1,9 @@
|
|||
#### CRUD ENDPOINTS for UI Settings #####
|
||||
from typing import List
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
|
||||
import litellm
|
||||
from litellm._logging import verbose_proxy_logger
|
||||
from litellm.proxy._types import *
|
||||
from litellm.proxy.auth.user_api_key_auth import user_api_key_auth
|
||||
|
@ -108,3 +109,67 @@ async def delete_allowed_ip(ip_address: IPAddress):
|
|||
await proxy_config.save_config(new_config=config)
|
||||
|
||||
return {"message": f"IP {ip_address.ip} deleted successfully", "status": "success"}
|
||||
|
||||
|
||||
@router.get(
|
||||
"/sso_settings",
|
||||
tags=["SSO Settings"],
|
||||
dependencies=[Depends(user_api_key_auth)],
|
||||
)
|
||||
async def get_sso_settings():
|
||||
"""
|
||||
Get all SSO settings from the litellm_settings configuration.
|
||||
Returns a structured object with values and descriptions for UI display.
|
||||
"""
|
||||
from pydantic import TypeAdapter
|
||||
|
||||
# Create the settings object first
|
||||
sso_settings = UISSOSettings(
|
||||
max_internal_user_budget=litellm.max_internal_user_budget,
|
||||
internal_user_budget_duration=litellm.internal_user_budget_duration,
|
||||
default_internal_user_params=DefaultInternalUserParams(
|
||||
**(
|
||||
litellm.default_internal_user_params
|
||||
if isinstance(litellm.default_internal_user_params, dict)
|
||||
else {}
|
||||
)
|
||||
),
|
||||
upperbound_key_generate_params=UpperboundKeyGenerateParams(
|
||||
**(
|
||||
litellm.upperbound_key_generate_params
|
||||
if isinstance(litellm.upperbound_key_generate_params, dict)
|
||||
else {}
|
||||
)
|
||||
),
|
||||
)
|
||||
|
||||
# Get the schema for UISSOSettings
|
||||
schema = TypeAdapter(UISSOSettings).json_schema(by_alias=True)
|
||||
|
||||
# Convert to dict for response
|
||||
settings_dict = sso_settings.model_dump()
|
||||
|
||||
# Add descriptions to the response
|
||||
result = {
|
||||
"values": settings_dict,
|
||||
"schema": {"description": schema.get("description", ""), "properties": {}},
|
||||
}
|
||||
|
||||
# Add property descriptions
|
||||
for field_name, field_info in schema["properties"].items():
|
||||
result["schema"]["properties"][field_name] = {
|
||||
"description": field_info.get("description", ""),
|
||||
"type": field_info.get("type", "string"),
|
||||
}
|
||||
|
||||
# Add nested object descriptions
|
||||
for def_name, def_schema in schema.get("definitions", {}).items():
|
||||
result["schema"][def_name] = {
|
||||
"description": def_schema.get("description", ""),
|
||||
"properties": {
|
||||
prop_name: {"description": prop_info.get("description", "")}
|
||||
for prop_name, prop_info in def_schema.get("properties", {}).items()
|
||||
},
|
||||
}
|
||||
|
||||
return result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue