Skip to content

armgit / dify

Public Imported from GitHub
0

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.

refactor: migrate tag list API query parameters to Pydantic (#31097)

Xiangxuan Qu1a9fdd9a6538
diff --git a/api/controllers/console/tag/tags.py b/api/controllers/console/tag/tags.py
index e9fbb515e42..023ffc991a7 100644
--- a/api/controllers/console/tag/tags.py
+++ b/api/controllers/console/tag/tags.py
@@ -30,6 +30,11 @@ class TagBindingRemovePayload(BaseModel):
type: Literal["knowledge", "app"] | None = Field(default=None, description="Tag type")
+class TagListQueryParam(BaseModel):
+ type: Literal["knowledge", "app", ""] = Field("", description="Tag type filter")
+ keyword: str | None = Field(None, description="Search keyword")
+
+
register_schema_models(
console_ns,
TagBasePayload,
@@ -43,12 +48,15 @@ class TagListApi(Resource):
@setup_required
@login_required
@account_initialization_required
+ @console_ns.doc(
+ params={"type": 'Tag type filter. Can be "knowledge" or "app".', "keyword": "Search keyword for tag name."}
+ )
@marshal_with(dataset_tag_fields)
def get(self):
_, current_tenant_id = current_account_with_tenant()
- tag_type = request.args.get("type", type=str, default="")
- keyword = request.args.get("keyword", default=None, type=str)
- tags = TagService.get_tags(tag_type, current_tenant_id, keyword)
+ raw_args = request.args.to_dict()
+ param = TagListQueryParam.model_validate(raw_args)
+ tags = TagService.get_tags(param.type, current_tenant_id, param.keyword)
return tags, 200