Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
chore: add UUID/str type annotations to api endpoints for files in api/controllers/console/app (#36559)
Lillian5645ea0deff7
diff --git a/api/controllers/console/app/annotation.py b/api/controllers/console/app/annotation.pyindex bf8b57685fc..d066177df3c 100644--- a/api/controllers/console/app/annotation.py+++ b/api/controllers/console/app/annotation.py@@ -159,13 +159,15 @@ class AppAnnotationSettingUpdateApi(Resource):@login_required@account_initialization_required@edit_permission_required- def post(self, app_id: UUID, annotation_setting_id):- annotation_setting_id = str(annotation_setting_id)+ def post(self, app_id: UUID, annotation_setting_id: UUID):+ annotation_setting_id_str = str(annotation_setting_id)args = AnnotationSettingUpdatePayload.model_validate(console_ns.payload)setting_args: UpdateAnnotationSettingArgs = {"score_threshold": args.score_threshold}- result = AppAnnotationService.update_app_annotation_setting(str(app_id), annotation_setting_id, setting_args)+ result = AppAnnotationService.update_app_annotation_setting(+ str(app_id), annotation_setting_id_str, setting_args+ )return result, 200@@ -181,9 +183,9 @@ class AnnotationReplyActionStatusApi(Resource):@account_initialization_required@cloud_edition_billing_resource_check("annotation")@edit_permission_required- def get(self, app_id: UUID, job_id, action):- job_id = str(job_id)- app_annotation_job_key = f"{action}_app_annotation_job_{str(job_id)}"+ def get(self, app_id: UUID, job_id: UUID, action: str):+ job_id_str = str(job_id)+ app_annotation_job_key = f"{action}_app_annotation_job_{job_id_str}"cache_result = redis_client.get(app_annotation_job_key)if cache_result is None:raise ValueError("The job does not exist.")@@ -191,10 +193,10 @@ class AnnotationReplyActionStatusApi(Resource):job_status = cache_result.decode()error_msg = ""if job_status == "error":- app_annotation_error_key = f"{action}_app_annotation_error_{str(job_id)}"+ app_annotation_error_key = f"{action}_app_annotation_error_{job_id_str}"error_msg = redis_client.get(app_annotation_error_key).decode()- return {"job_id": job_id, "job_status": job_status, "error_msg": error_msg}, 200+ return {"job_id": job_id_str, "job_status": job_status, "error_msg": error_msg}, 200@console_ns.route("/apps/<uuid:app_id>/annotations")diff --git a/api/controllers/console/app/app_import.py b/api/controllers/console/app/app_import.pyindex b6530163193..e8e8234ac4e 100644--- a/api/controllers/console/app/app_import.py+++ b/api/controllers/console/app/app_import.py@@ -97,7 +97,7 @@ class AppImportConfirmApi(Resource):@login_required@account_initialization_required@edit_permission_required- def post(self, import_id):+ def post(self, import_id: str):# Check user role firstcurrent_user, _ = current_account_with_tenant()diff --git a/api/controllers/console/app/completion.py b/api/controllers/console/app/completion.pyindex 817623bf7f3..fddfe2f4bcc 100644--- a/api/controllers/console/app/completion.py+++ b/api/controllers/console/app/completion.py@@ -131,7 +131,7 @@ class CompletionMessageStopApi(Resource):@login_required@account_initialization_required@get_app_model(mode=AppMode.COMPLETION)- def post(self, app_model, task_id):+ def post(self, app_model, task_id: str):if not isinstance(current_user, Account):raise ValueError("current_user must be an Account instance")@@ -212,7 +212,7 @@ class ChatMessageStopApi(Resource):@login_required@account_initialization_required@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])- def post(self, app_model, task_id):+ def post(self, app_model, task_id: str):if not isinstance(current_user, Account):raise ValueError("current_user must be an Account instance")diff --git a/api/controllers/console/app/conversation.py b/api/controllers/console/app/conversation.pyindex 19780183664..6216a7bcbe2 100644--- a/api/controllers/console/app/conversation.py+++ b/api/controllers/console/app/conversation.py@@ -1,4 +1,5 @@from typing import Literal+from uuid import UUIDimport sqlalchemy as safrom flask import abort, request@@ -164,10 +165,10 @@ class CompletionConversationDetailApi(Resource):@account_initialization_required@get_app_model(mode=AppMode.COMPLETION)@edit_permission_required- def get(self, app_model, conversation_id):- conversation_id = str(conversation_id)+ def get(self, app_model, conversation_id: UUID):+ conversation_id_str = str(conversation_id)return ConversationMessageDetailResponse.model_validate(- _get_conversation(app_model, conversation_id), from_attributes=True+ _get_conversation(app_model, conversation_id_str), from_attributes=True).model_dump(mode="json")@console_ns.doc("delete_completion_conversation")@@ -181,12 +182,12 @@ class CompletionConversationDetailApi(Resource):@account_initialization_required@get_app_model(mode=AppMode.COMPLETION)@edit_permission_required- def delete(self, app_model, conversation_id):+ def delete(self, app_model, conversation_id: UUID):current_user, _ = current_account_with_tenant()- conversation_id = str(conversation_id)+ conversation_id_str = str(conversation_id)try:- ConversationService.delete(app_model, conversation_id, current_user)+ ConversationService.delete(app_model, conversation_id_str, current_user)except ConversationNotExistsError:raise NotFound("Conversation Not Exists.")@@ -317,10 +318,10 @@ class ChatConversationDetailApi(Resource):@account_initialization_required@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])@edit_permission_required- def get(self, app_model, conversation_id):- conversation_id = str(conversation_id)+ def get(self, app_model, conversation_id: UUID):+ conversation_id_str = str(conversation_id)return ConversationDetailResponse.model_validate(- _get_conversation(app_model, conversation_id), from_attributes=True+ _get_conversation(app_model, conversation_id_str), from_attributes=True).model_dump(mode="json")@console_ns.doc("delete_chat_conversation")@@ -334,12 +335,12 @@ class ChatConversationDetailApi(Resource):@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])@account_initialization_required@edit_permission_required- def delete(self, app_model, conversation_id):+ def delete(self, app_model, conversation_id: UUID):current_user, _ = current_account_with_tenant()- conversation_id = str(conversation_id)+ conversation_id_str = str(conversation_id)try:- ConversationService.delete(app_model, conversation_id, current_user)+ ConversationService.delete(app_model, conversation_id_str, current_user)except ConversationNotExistsError:raise NotFound("Conversation Not Exists.")diff --git a/api/controllers/console/app/mcp_server.py b/api/controllers/console/app/mcp_server.pyindex 13f6e098baa..a5259527eae 100644--- a/api/controllers/console/app/mcp_server.py+++ b/api/controllers/console/app/mcp_server.py@@ -1,6 +1,7 @@import jsonfrom datetime import datetimefrom typing import Any+from uuid import UUIDfrom flask_restx import Resourcefrom pydantic import BaseModel, Field, field_validator@@ -162,7 +163,7 @@ class AppMCPServerRefreshController(Resource):@login_required@account_initialization_required@edit_permission_required- def get(self, server_id):+ def get(self, server_id: UUID):_, current_tenant_id = current_account_with_tenant()server = db.session.scalar(select(AppMCPServer)diff --git a/api/controllers/console/app/message.py b/api/controllers/console/app/message.pyindex 06afe15548d..faa1e0fcdad 100644--- a/api/controllers/console/app/message.py+++ b/api/controllers/console/app/message.py@@ -1,6 +1,7 @@import loggingfrom datetime import datetimefrom typing import Literal+from uuid import UUIDfrom flask import requestfrom flask_restx import Resource@@ -336,13 +337,13 @@ class MessageSuggestedQuestionApi(Resource):@login_required@account_initialization_required@get_app_model(mode=[AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT])- def get(self, app_model, message_id):+ def get(self, app_model, message_id: UUID):current_user, _ = current_account_with_tenant()- message_id = str(message_id)+ message_id_str = str(message_id)try:questions = MessageService.get_suggested_questions_after_answer(- app_model=app_model, message_id=message_id, user=current_user, invoke_from=InvokeFrom.DEBUGGER+ app_model=app_model, message_id=message_id_str, user=current_user, invoke_from=InvokeFrom.DEBUGGER)except MessageNotExistsError:raise NotFound("Message not found")@@ -417,10 +418,10 @@ class MessageApi(Resource):@login_required@account_initialization_requireddef get(self, app_model, message_id: str):- message_id = str(message_id)+ message_id_str = str(message_id)message = db.session.scalar(- select(Message).where(Message.id == message_id, Message.app_id == app_model.id).limit(1)+ select(Message).where(Message.id == message_id_str, Message.app_id == app_model.id).limit(1))if not message:diff --git a/api/controllers/console/app/workflow_run.py b/api/controllers/console/app/workflow_run.pyindex 97d2003209e..2d48b59de28 100644--- a/api/controllers/console/app/workflow_run.py+++ b/api/controllers/console/app/workflow_run.py@@ -1,5 +1,6 @@from datetime import UTC, datetime, timedeltafrom typing import Literal, cast+from uuid import UUIDfrom flask import requestfrom flask_restx import Resource@@ -367,14 +368,14 @@ class WorkflowRunDetailApi(Resource):@login_required@account_initialization_required@get_app_model(mode=[AppMode.ADVANCED_CHAT, AppMode.WORKFLOW])- def get(self, app_model: App, run_id):+ def get(self, app_model: App, run_id: UUID):"""Get workflow run detail"""- run_id = str(run_id)+ run_id_str = str(run_id)workflow_run_service = WorkflowRunService()- workflow_run = workflow_run_service.get_workflow_run(app_model=app_model, run_id=run_id)+ workflow_run = workflow_run_service.get_workflow_run(app_model=app_model, run_id=run_id_str)if workflow_run is None:raise NotFoundError("Workflow run not found")@@ -396,17 +397,17 @@ class WorkflowRunNodeExecutionListApi(Resource):@login_required@account_initialization_required@get_app_model(mode=[AppMode.ADVANCED_CHAT, AppMode.WORKFLOW])- def get(self, app_model: App, run_id):+ def get(self, app_model: App, run_id: UUID):"""Get workflow run node execution list"""- run_id = str(run_id)+ run_id_str = str(run_id)workflow_run_service = WorkflowRunService()user = cast("Account | EndUser", current_user)node_executions = workflow_run_service.get_workflow_run_node_executions(app_model=app_model,- run_id=run_id,+ run_id=run_id_str,user=user,)