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(api): deduplicate I18nObject in datasource entities (#34701)

corevibe555b1adb5652e33
diff --git a/api/core/datasource/entities/common_entities.py b/api/core/datasource/entities/common_entities.py
index f2852027ecb..726dafaa62a 100644
--- a/api/core/datasource/entities/common_entities.py
+++ b/api/core/datasource/entities/common_entities.py
@@ -1,37 +1,3 @@
-from typing import TypedDict
+from core.tools.entities.common_entities import I18nObject, I18nObjectDict
-from pydantic import BaseModel, Field, model_validator
-
-
-class I18nObjectDict(TypedDict):
- zh_Hans: str | None
- en_US: str
- pt_BR: str | None
- ja_JP: str | None
-
-
-class I18nObject(BaseModel):
- """
- Model class for i18n object.
- """
-
- en_US: str
- zh_Hans: str | None = Field(default=None)
- pt_BR: str | None = Field(default=None)
- ja_JP: str | None = Field(default=None)
-
- @model_validator(mode="after")
- def _(self):
- self.zh_Hans = self.zh_Hans or self.en_US
- self.pt_BR = self.pt_BR or self.en_US
- self.ja_JP = self.ja_JP or self.en_US
- return self
-
- def to_dict(self) -> I18nObjectDict:
- result: I18nObjectDict = {
- "zh_Hans": self.zh_Hans,
- "en_US": self.en_US,
- "pt_BR": self.pt_BR,
- "ja_JP": self.ja_JP,
- }
- return result
+__all__ = ["I18nObject", "I18nObjectDict"]