feat: restore core admin modules and harden ai model fallback

This commit is contained in:
2026-06-22 01:21:01 +08:00
parent f180fff020
commit 524c027a4a
15 changed files with 1896 additions and 21 deletions
+4 -1
View File
@@ -16,7 +16,7 @@ from app.base_schema import PaginatedResponse, ResponseModel
from utils.context import get_current_user_id_from_context
from ai_platform.models import (
Agent, AgentConversation, AgentMessage,
LLMModel, AIWorkflow,
LLMModel, LLMProvider, AIWorkflow,
)
from core.application.model import Application
from ai_platform.schemas.agent_schema import (
@@ -59,10 +59,13 @@ CODEX_AGENT_PROMPT = """
async def _resolve_default_chat_model_id(db: AsyncSession) -> Optional[str]:
result = await db.execute(
select(LLMModel)
.join(LLMProvider, LLMProvider.id == LLMModel.provider_id)
.where(
LLMModel.is_deleted == False,
LLMModel.is_active == True,
LLMModel.model_type == "chat",
LLMProvider.is_deleted == False,
LLMProvider.is_active == True,
)
.order_by(LLMModel.sort.desc(), LLMModel.sys_create_datetime.desc())
)