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/files and api/controllers/web (#36562)
Lillian7b1aa33ad4ce
diff --git a/api/controllers/files/image_preview.py b/api/controllers/files/image_preview.pyindex be7886e8319..0d4b89096ae 100644--- a/api/controllers/files/image_preview.py+++ b/api/controllers/files/image_preview.py@@ -1,4 +1,5 @@from urllib.parse import quote+from uuid import UUIDfrom flask import Response, requestfrom flask_restx import Resource@@ -49,8 +50,8 @@ class ImagePreviewApi(Resource):415: "Unsupported file type",})- def get(self, file_id):- file_id = str(file_id)+ def get(self, file_id: UUID):+ file_id_str = str(file_id)args = FileSignatureQuery.model_validate(request.args.to_dict(flat=True))timestamp = args.timestamp@@ -59,7 +60,7 @@ class ImagePreviewApi(Resource):try:generator, mimetype = FileService(db.engine).get_image_preview(- file_id=file_id,+ file_id=file_id_str,timestamp=timestamp,nonce=nonce,sign=sign,@@ -91,14 +92,14 @@ class FilePreviewApi(Resource):415: "Unsupported file type",})- def get(self, file_id):- file_id = str(file_id)+ def get(self, file_id: UUID):+ file_id_str = str(file_id)args = FilePreviewQuery.model_validate(request.args.to_dict(flat=True))try:generator, upload_file = FileService(db.engine).get_file_generator_by_file_id(- file_id=file_id,+ file_id=file_id_str,timestamp=args.timestamp,nonce=args.nonce,sign=args.sign,@@ -159,10 +160,10 @@ class WorkspaceWebappLogoApi(Resource):415: "Unsupported file type",})- def get(self, workspace_id):- workspace_id = str(workspace_id)+ def get(self, workspace_id: UUID):+ workspace_id_str = str(workspace_id)- custom_config = TenantService.get_custom_config(workspace_id)+ custom_config = TenantService.get_custom_config(workspace_id_str)webapp_logo_file_id = custom_config.get("replace_webapp_logo") if custom_config is not None else Noneif not webapp_logo_file_id:diff --git a/api/controllers/files/tool_files.py b/api/controllers/files/tool_files.pyindex 8ae16ce7f45..ef47485d800 100644--- a/api/controllers/files/tool_files.py+++ b/api/controllers/files/tool_files.py@@ -1,4 +1,5 @@from urllib.parse import quote+from uuid import UUIDfrom flask import Response, requestfrom flask_restx import Resource@@ -45,17 +46,19 @@ class ToolFileApi(Resource):415: "Unsupported file type",})- def get(self, file_id, extension):- file_id = str(file_id)+ def get(self, file_id: UUID, extension: str):+ file_id_str = str(file_id)args = ToolFileQuery.model_validate(request.args.to_dict())- if not verify_tool_file_signature(file_id=file_id, timestamp=args.timestamp, nonce=args.nonce, sign=args.sign):+ if not verify_tool_file_signature(+ file_id=file_id_str, timestamp=args.timestamp, nonce=args.nonce, sign=args.sign+ ):raise Forbidden("Invalid request.")try:tool_file_manager = ToolFileManager()stream, tool_file = tool_file_manager.get_file_generator_by_tool_file_id(- file_id,+ file_id_str,)if not stream or not tool_file:diff --git a/api/controllers/web/completion.py b/api/controllers/web/completion.pyindex 8f52988ef93..f08d08ab7da 100644--- a/api/controllers/web/completion.py+++ b/api/controllers/web/completion.py@@ -140,7 +140,7 @@ class CompletionStopApi(WebApiResource):})@web_ns.response(200, "Success", web_ns.models[SimpleResultResponse.__name__])- def post(self, app_model, end_user, task_id):+ def post(self, app_model, end_user, task_id: str):if app_model.mode != AppMode.COMPLETION:raise NotCompletionAppError()@@ -226,7 +226,7 @@ class ChatStopApi(WebApiResource):})@web_ns.response(200, "Success", web_ns.models[SimpleResultResponse.__name__])- def post(self, app_model, end_user, task_id):+ def post(self, app_model, end_user, task_id: str):app_mode = AppMode.value_of(app_model.mode)if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:raise NotChatAppError()diff --git a/api/controllers/web/conversation.py b/api/controllers/web/conversation.pyindex a99adb391f9..00db29a6063 100644--- a/api/controllers/web/conversation.py+++ b/api/controllers/web/conversation.py@@ -1,4 +1,5 @@from typing import Literal+from uuid import UUIDfrom flask import requestfrom pydantic import BaseModel, Field, TypeAdapter, field_validator@@ -126,7 +127,7 @@ class ConversationApi(WebApiResource):500: "Internal Server Error",})- def delete(self, app_model, end_user, c_id):+ def delete(self, app_model, end_user, c_id: UUID):app_mode = AppMode.value_of(app_model.mode)if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:raise NotChatAppError()@@ -165,7 +166,7 @@ class ConversationRenameApi(WebApiResource):500: "Internal Server Error",})- def post(self, app_model, end_user, c_id):+ def post(self, app_model, end_user, c_id: UUID):app_mode = AppMode.value_of(app_model.mode)if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:raise NotChatAppError()@@ -203,7 +204,7 @@ class ConversationPinApi(WebApiResource):})@web_ns.response(200, "Conversation pinned successfully", web_ns.models[ResultResponse.__name__])- def patch(self, app_model, end_user, c_id):+ def patch(self, app_model, end_user, c_id: UUID):app_mode = AppMode.value_of(app_model.mode)if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:raise NotChatAppError()@@ -234,7 +235,7 @@ class ConversationUnPinApi(WebApiResource):})@web_ns.response(200, "Conversation unpinned successfully", web_ns.models[ResultResponse.__name__])- def patch(self, app_model, end_user, c_id):+ def patch(self, app_model, end_user, c_id: UUID):app_mode = AppMode.value_of(app_model.mode)if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:raise NotChatAppError()diff --git a/api/controllers/web/message.py b/api/controllers/web/message.pyindex fc5e266c5ce..cf0363b66ea 100644--- a/api/controllers/web/message.py+++ b/api/controllers/web/message.py@@ -1,5 +1,6 @@import loggingfrom typing import Literal+from uuid import UUIDfrom flask import requestfrom pydantic import BaseModel, Field, TypeAdapter@@ -132,15 +133,15 @@ class MessageFeedbackApi(WebApiResource):})@web_ns.response(200, "Feedback submitted successfully", web_ns.models[ResultResponse.__name__])- def post(self, app_model, end_user, message_id):- message_id = str(message_id)+ def post(self, app_model, end_user, message_id: UUID):+ message_id_str = str(message_id)payload = MessageFeedbackPayload.model_validate(web_ns.payload or {})try:MessageService.create_feedback(app_model=app_model,- message_id=message_id,+ message_id=message_id_str,user=end_user,rating=FeedbackRating(payload.rating) if payload.rating else None,content=payload.content,@@ -166,11 +167,11 @@ class MessageMoreLikeThisApi(WebApiResource):500: "Internal Server Error",})- def get(self, app_model, end_user, message_id):+ def get(self, app_model, end_user, message_id: UUID):if app_model.mode != "completion":raise NotCompletionAppError()- message_id = str(message_id)+ message_id_str = str(message_id)raw_args = request.args.to_dict()query = MessageMoreLikeThisQuery.model_validate(raw_args)@@ -181,7 +182,7 @@ class MessageMoreLikeThisApi(WebApiResource):response = AppGenerateService.generate_more_like_this(app_model=app_model,user=end_user,- message_id=message_id,+ message_id=message_id_str,invoke_from=InvokeFrom.WEB_APP,streaming=streaming,)@@ -222,16 +223,16 @@ class MessageSuggestedQuestionApi(WebApiResource):500: "Internal Server Error",})- def get(self, app_model, end_user, message_id):+ def get(self, app_model, end_user, message_id: UUID):app_mode = AppMode.value_of(app_model.mode)if app_mode not in {AppMode.CHAT, AppMode.AGENT_CHAT, AppMode.ADVANCED_CHAT}:raise NotChatAppError()- message_id = str(message_id)+ message_id_str = str(message_id)try:questions = MessageService.get_suggested_questions_after_answer(- app_model=app_model, user=end_user, message_id=message_id, invoke_from=InvokeFrom.WEB_APP+ app_model=app_model, user=end_user, message_id=message_id_str, invoke_from=InvokeFrom.WEB_APP)# questions is a list of strings, not a list of Message objectsexcept MessageNotExistsError:diff --git a/api/controllers/web/saved_message.py b/api/controllers/web/saved_message.pyindex e307367b647..766cfc6c60d 100644--- a/api/controllers/web/saved_message.py+++ b/api/controllers/web/saved_message.py@@ -1,3 +1,5 @@+from uuid import UUID+from flask import requestfrom pydantic import TypeAdapterfrom werkzeug.exceptions import NotFound@@ -104,12 +106,12 @@ class SavedMessageApi(WebApiResource):500: "Internal Server Error",})- def delete(self, app_model, end_user, message_id):- message_id = str(message_id)+ def delete(self, app_model, end_user, message_id: UUID):+ message_id_str = str(message_id)if app_model.mode != "completion":raise NotCompletionAppError()- SavedMessageService.delete(app_model, end_user, message_id)+ SavedMessageService.delete(app_model, end_user, message_id_str)return "", 204