MCPcopy Index your code
hub / github.com/dataease/SQLBot / set_default

Function set_default

backend/apps/system/api/aimodel.py:67–83  ·  view source on GitHub ↗
(session: SessionDep, id: int = Path(description="ID"))

Source from the content-addressed store, hash-verified

65@require_permissions(permission=SqlbotPermission(role=['admin']))
66@system_log(LogConfig(operation_type=OperationType.UPDATE, module=OperationModules.AI_MODEL, resource_id_expr="id"))
67async def set_default(session: SessionDep, id: int = Path(description="ID")):
68 db_model = session.get(AiModelDetail, id)
69 if not db_model:
70 raise ValueError(f"AiModelDetail with id {id} not found")
71 if db_model.default_model:
72 return
73
74 try:
75 session.exec(
76 update(AiModelDetail).values(default_model=False)
77 )
78 db_model.default_model = True
79 session.add(db_model)
80 session.commit()
81 except Exception as e:
82 session.rollback()
83 raise e
84
85
86@router.get("", response_model=list[AiModelGridItem], summary=f"{PLACEHOLDER_PREFIX}system_model_grid",

Callers

nothing calls this directly

Calls 5

updateFunction · 0.70
getMethod · 0.65
addMethod · 0.65
execMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected