Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(agent): add canvas_type filter and field to list_agents API (#15754)

天海蒼灆3c946a7e58a1
diff --git a/api/apps/restful_apis/agent_api.py b/api/apps/restful_apis/agent_api.py
index 2bd157b77f..859719bba8 100644
--- a/api/apps/restful_apis/agent_api.py
+++ b/api/apps/restful_apis/agent_api.py
@@ -641,6 +641,7 @@ def prompts():
def list_agents(tenant_id):
keywords = request.args.get("keywords", "")
canvas_category = request.args.get("canvas_category")
+ canvas_type = request.args.get("canvas_type")
owner_ids = [item for item in request.args.get("owner_ids", "").strip().split(",") if item]
tags = [item for item in request.args.get("tags", "").strip().split(",") if item]
@@ -675,6 +676,7 @@ def list_agents(tenant_id):
keywords,
canvas_category,
tags,
+ canvas_type,
)
return get_json_result(data={"canvas": canvas, "total": total})
diff --git a/api/db/services/canvas_service.py b/api/db/services/canvas_service.py
index c560b0bac8..561535259c 100644
--- a/api/db/services/canvas_service.py
+++ b/api/db/services/canvas_service.py
@@ -152,6 +152,7 @@ class UserCanvasService(CommonService):
keywords,
canvas_category=None,
tags=None,
+ canvas_type=None,
):
fields = [
cls.model.id,
@@ -163,6 +164,7 @@ class UserCanvasService(CommonService):
User.nickname,
User.avatar.alias('tenant_avatar'),
cls.model.update_time,
+ cls.model.canvas_type,
cls.model.canvas_category,
cls.model.tags,
]
@@ -177,6 +179,8 @@ class UserCanvasService(CommonService):
)
if canvas_category:
agents = agents.where(cls.model.canvas_category == canvas_category)
+ if canvas_type:
+ agents = agents.where(cls.model.canvas_type == canvas_type)
if tags:
tag_list = [t.strip() for t in tags if t and t.strip()] if isinstance(tags, (list, tuple)) else [t.strip() for t in str(tags).split(",") if t.strip()]
if tag_list: