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: replace sa.String with EnumText for mapped_columns (#33547)

tmimmanuel3f1a12773541
diff --git a/api/models/enums.py b/api/models/enums.py
index eb478fe02c4..ac5545164ec 100644
--- a/api/models/enums.py
+++ b/api/models/enums.py
@@ -96,3 +96,213 @@ class ConversationStatus(StrEnum):
"""Conversation Status Enum"""
NORMAL = "normal"
+
+
+class DataSourceType(StrEnum):
+ """Data Source Type for Dataset and Document"""
+
+ UPLOAD_FILE = "upload_file"
+ NOTION_IMPORT = "notion_import"
+ WEBSITE_CRAWL = "website_crawl"
+ LOCAL_FILE = "local_file"
+ ONLINE_DOCUMENT = "online_document"
+
+
+class ProcessRuleMode(StrEnum):
+ """Dataset Process Rule Mode"""
+
+ AUTOMATIC = "automatic"
+ CUSTOM = "custom"
+ HIERARCHICAL = "hierarchical"
+
+
+class IndexingStatus(StrEnum):
+ """Document Indexing Status"""
+
+ WAITING = "waiting"
+ PARSING = "parsing"
+ CLEANING = "cleaning"
+ SPLITTING = "splitting"
+ INDEXING = "indexing"
+ PAUSED = "paused"
+ COMPLETED = "completed"
+ ERROR = "error"
+
+
+class DocumentCreatedFrom(StrEnum):
+ """Document Created From"""
+
+ WEB = "web"
+ API = "api"
+ RAG_PIPELINE = "rag-pipeline"
+
+
+class ConversationFromSource(StrEnum):
+ """Conversation / Message from_source"""
+
+ API = "api"
+ CONSOLE = "console"
+
+
+class FeedbackFromSource(StrEnum):
+ """MessageFeedback from_source"""
+
+ USER = "user"
+ ADMIN = "admin"
+
+
+class InvokeFrom(StrEnum):
+ """How a conversation/message was invoked"""
+
+ SERVICE_API = "service-api"
+ WEB_APP = "web-app"
+ TRIGGER = "trigger"
+ EXPLORE = "explore"
+ DEBUGGER = "debugger"
+ PUBLISHED_PIPELINE = "published"
+ VALIDATION = "validation"
+
+ @classmethod
+ def value_of(cls, value: str) -> "InvokeFrom":
+ return cls(value)
+
+ def to_source(self) -> str:
+ source_mapping = {
+ InvokeFrom.WEB_APP: "web_app",
+ InvokeFrom.DEBUGGER: "dev",
+ InvokeFrom.EXPLORE: "explore_app",
+ InvokeFrom.TRIGGER: "trigger",
+ InvokeFrom.SERVICE_API: "api",
+ }
+ return source_mapping.get(self, "dev")
+
+
+class DocumentDocType(StrEnum):
+ """Document doc_type classification"""
+
+ BOOK = "book"
+ WEB_PAGE = "web_page"
+ PAPER = "paper"
+ SOCIAL_MEDIA_POST = "social_media_post"
+ WIKIPEDIA_ENTRY = "wikipedia_entry"
+ PERSONAL_DOCUMENT = "personal_document"
+ BUSINESS_DOCUMENT = "business_document"
+ IM_CHAT_LOG = "im_chat_log"
+ SYNCED_FROM_NOTION = "synced_from_notion"
+ SYNCED_FROM_GITHUB = "synced_from_github"
+ OTHERS = "others"
+
+
+class TagType(StrEnum):
+ """Tag type"""
+
+ KNOWLEDGE = "knowledge"
+ APP = "app"
+
+
+class DatasetMetadataType(StrEnum):
+ """Dataset metadata value type"""
+
+ STRING = "string"
+ NUMBER = "number"
+ TIME = "time"
+
+
+class SegmentStatus(StrEnum):
+ """Document segment status"""
+
+ WAITING = "waiting"
+ INDEXING = "indexing"
+ COMPLETED = "completed"
+ ERROR = "error"
+
+
+class DatasetRuntimeMode(StrEnum):
+ """Dataset runtime mode"""
+
+ GENERAL = "general"
+ RAG_PIPELINE = "rag_pipeline"
+
+
+class CollectionBindingType(StrEnum):
+ """Dataset collection binding type"""
+
+ DATASET = "dataset"
+ ANNOTATION = "annotation"
+
+
+class DatasetQuerySource(StrEnum):
+ """Dataset query source"""
+
+ HIT_TESTING = "hit_testing"
+ APP = "app"
+
+
+class TidbAuthBindingStatus(StrEnum):
+ """TiDB auth binding status"""
+
+ CREATING = "CREATING"
+ ACTIVE = "ACTIVE"
+
+
+class MessageFileBelongsTo(StrEnum):
+ """MessageFile belongs_to"""
+
+ USER = "user"
+ ASSISTANT = "assistant"
+
+
+class CredentialSourceType(StrEnum):
+ """Load balancing credential source type"""
+
+ PROVIDER = "provider"
+ CUSTOM_MODEL = "custom_model"
+
+
+class PaymentStatus(StrEnum):
+ """Provider order payment status"""
+
+ WAIT_PAY = "wait_pay"
+ PAID = "paid"
+ FAILED = "failed"
+ REFUNDED = "refunded"
+
+
+class BannerStatus(StrEnum):
+ """ExporleBanner status"""
+
+ ENABLED = "enabled"
+ DISABLED = "disabled"
+
+
+class SummaryStatus(StrEnum):
+ """Document segment summary status"""
+
+ NOT_STARTED = "not_started"
+ GENERATING = "generating"
+ COMPLETED = "completed"
+ ERROR = "error"
+
+
+class MessageChainType(StrEnum):
+ """Message chain type"""
+
+ SYSTEM = "system"
+
+
+class ProviderQuotaType(StrEnum):
+ PAID = "paid"
+ """hosted paid quota"""
+
+ FREE = "free"
+ """third-party free quota"""
+
+ TRIAL = "trial"
+ """hosted trial quota"""
+
+ @staticmethod
+ def value_of(value: str) -> "ProviderQuotaType":
+ for member in ProviderQuotaType:
+ if member.value == value:
+ return member
+ raise ValueError(f"No matching enum found for value '{value}'")
diff --git a/api/pyrefly-local-excludes.txt b/api/pyrefly-local-excludes.txt
index 9a76de1927b..ad3c1e83895 100644
--- a/api/pyrefly-local-excludes.txt
+++ b/api/pyrefly-local-excludes.txt
@@ -182,4 +182,9 @@ tasks/app_generate/workflow_execute_task.py
tasks/regenerate_summary_index_task.py
tasks/trigger_processing_tasks.py
tasks/workflow_cfs_scheduler/cfs_scheduler.py
+tasks/add_document_to_index_task.py
+tasks/create_segment_to_index_task.py
+tasks/disable_segment_from_index_task.py
+tasks/enable_segment_to_index_task.py
+tasks/remove_document_from_index_task.py
tasks/workflow_execution_tasks.py