feat(Application): Application can configure specified model

This commit is contained in:
ulleo
2026-06-04 15:06:09 +08:00
committed by ulleo
parent c53ac8f720
commit d5d5e87b51
2 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -359,4 +359,4 @@ async def get_model_by_ws(
session: SessionDep,
current_user: CurrentUser
):
return get_ai_model_list_by_workspace(session, current_user.oid)
return get_ai_model_list_by_workspace(session, current_user.oid, False)
+7 -7
View File
@@ -31,7 +31,7 @@ async def async_model_info():
SQLBotLogUtil.info("✅ 异步加密已有模型的密钥和地址完成")
def get_ai_model_list_by_workspace(session: Session, workspace_id: int):
def get_ai_model_list_by_workspace(session: Session, workspace_id: int, with_default: bool = True):
sub_stmt = (
select(AiModelWorkspaceMapping.ai_model_id)
.where(AiModelWorkspaceMapping.workspace_id == workspace_id)
@@ -39,6 +39,11 @@ def get_ai_model_list_by_workspace(session: Session, workspace_id: int):
)
# 查询:关联的模型 + default_model 为 True 的模型,默认模型排第一
base_condition = AiModelDetail.id.in_(sub_stmt)
if with_default:
where_condition = or_(base_condition, AiModelDetail.default_model == True)
else:
where_condition = base_condition
stmt = (
select(
AiModelDetail.id,
@@ -46,12 +51,7 @@ def get_ai_model_list_by_workspace(session: Session, workspace_id: int):
AiModelDetail.default_model,
AiModelDetail.supplier,
)
.where(
or_(
AiModelDetail.id.in_(sub_stmt),
AiModelDetail.default_model == True,
)
)
.where(where_condition)
.order_by(AiModelDetail.default_model.desc())
)
rows = session.exec(stmt).all()