| 12345678910111213141516171819202122 |
- from app.models import CommonLlmModel, group_llm_table
- from app.models.user_model import UserModel
- async def get_llm_list(db, user_id):
- user = db.query(UserModel).filter(UserModel.id == user_id).first()
- if user is None:
- return {"rows": []}
- if user.permission == "admin":
- query = db.query(CommonLlmModel)
- else:
- group_list = [i.id for i in user.groups]
- query = db.query(CommonLlmModel)
- query = query.intersect(
- db.query(CommonLlmModel).join(
- group_llm_table,
- CommonLlmModel.id == group_llm_table.c.llm_id
- ).filter(
- group_llm_table.c.group_id.in_(group_list)
- )
- )
- return {"rows": [kld.to_json() for kld in query.all()]}
|