mirror of
https://github.com/langgenius/dify.git
synced 2026-06-07 16:23:44 +08:00
refactor: remove unused Flask-RESTX field dicts from end_user and conversation_variable fields (#28015) (#36929)
This commit is contained in:
parent
888483a2f8
commit
3cd0da303a
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from flask_restx import Namespace, fields
|
||||
from flask_restx import fields
|
||||
from pydantic import field_validator
|
||||
|
||||
from fields.base import ResponseModel
|
||||
@ -22,20 +22,6 @@ conversation_variable_fields = {
|
||||
"updated_at": TimestampField,
|
||||
}
|
||||
|
||||
paginated_conversation_variable_fields = {
|
||||
"page": fields.Integer,
|
||||
"limit": fields.Integer,
|
||||
"total": fields.Integer,
|
||||
"has_more": fields.Boolean,
|
||||
"data": fields.List(fields.Nested(conversation_variable_fields), attribute="data"),
|
||||
}
|
||||
|
||||
conversation_variable_infinite_scroll_pagination_fields = {
|
||||
"limit": fields.Integer,
|
||||
"has_more": fields.Boolean,
|
||||
"data": fields.List(fields.Nested(conversation_variable_fields)),
|
||||
}
|
||||
|
||||
|
||||
class ConversationVariableResponse(ResponseModel):
|
||||
id: str
|
||||
@ -97,19 +83,3 @@ class ConversationVariableInfiniteScrollPaginationResponse(ResponseModel):
|
||||
limit: int
|
||||
has_more: bool
|
||||
data: list[ConversationVariableResponse]
|
||||
|
||||
|
||||
def build_conversation_variable_model(api_or_ns: Namespace):
|
||||
"""Build the conversation variable model for the API or Namespace."""
|
||||
return api_or_ns.model("ConversationVariable", conversation_variable_fields)
|
||||
|
||||
|
||||
def build_conversation_variable_infinite_scroll_pagination_model(api_or_ns: Namespace):
|
||||
"""Build the conversation variable infinite scroll pagination model for the API or Namespace."""
|
||||
# Build the nested variable model first
|
||||
conversation_variable_model = build_conversation_variable_model(api_or_ns)
|
||||
|
||||
copied_fields = conversation_variable_infinite_scroll_pagination_fields.copy()
|
||||
copied_fields["data"] = fields.List(fields.Nested(conversation_variable_model))
|
||||
|
||||
return api_or_ns.model("ConversationVariableInfiniteScrollPagination", copied_fields)
|
||||
|
||||
@ -2,31 +2,10 @@ from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from flask_restx import fields
|
||||
from pydantic import Field
|
||||
|
||||
from fields.base import ResponseModel
|
||||
|
||||
simple_end_user_fields = {
|
||||
"id": fields.String,
|
||||
"type": fields.String,
|
||||
"is_anonymous": fields.Boolean,
|
||||
"session_id": fields.String,
|
||||
}
|
||||
|
||||
end_user_detail_fields = {
|
||||
"id": fields.String,
|
||||
"tenant_id": fields.String,
|
||||
"app_id": fields.String,
|
||||
"type": fields.String,
|
||||
"external_user_id": fields.String,
|
||||
"name": fields.String,
|
||||
"is_anonymous": fields.Boolean,
|
||||
"session_id": fields.String,
|
||||
"created_at": fields.DateTime,
|
||||
"updated_at": fields.DateTime,
|
||||
}
|
||||
|
||||
|
||||
class SimpleEndUser(ResponseModel):
|
||||
id: str
|
||||
|
||||
Loading…
Reference in New Issue
Block a user