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.

feat: add app_mode field to app import and model definitions (#15729)

-LAN-cefec4407066
diff --git a/api/fields/app_fields.py b/api/fields/app_fields.py
index eaf684f16ad..f42364f1104 100644
--- a/api/fields/app_fields.py
+++ b/api/fields/app_fields.py
@@ -204,6 +204,7 @@ app_import_fields = {
"id": fields.String,
"status": fields.String,
"app_id": fields.String,
+ "app_mode": fields.String,
"current_dsl_version": fields.String,
"imported_dsl_version": fields.String,
"error": fields.String,
diff --git a/api/models/model.py b/api/models/model.py
index bf212e80366..0a5256c3355 100644
--- a/api/models/model.py
+++ b/api/models/model.py
@@ -82,7 +82,7 @@ class App(Base):
tenant_id: Mapped[str] = db.Column(StringUUID, nullable=False)
name = db.Column(db.String(255), nullable=False)
description = db.Column(db.Text, nullable=False, server_default=db.text("''::character varying"))
- mode = db.Column(db.String(255), nullable=False)
+ mode: Mapped[str] = mapped_column(db.String(255), nullable=False)
icon_type = db.Column(db.String(255), nullable=True) # image, emoji
icon = db.Column(db.String(255))
icon_background = db.Column(db.String(255))
diff --git a/api/services/app_dsl_service.py b/api/services/app_dsl_service.py
index 4ddb56981eb..d33d277d4ba 100644
--- a/api/services/app_dsl_service.py
+++ b/api/services/app_dsl_service.py
@@ -55,6 +55,7 @@ class Import(BaseModel):
id: str
status: ImportStatus
app_id: Optional[str] = None
+ app_mode: Optional[str] = None
current_dsl_version: str = CURRENT_DSL_VERSION
imported_dsl_version: str = ""
error: str = ""
@@ -220,7 +221,7 @@ class AppDslService:
error="App not found",
)
- if app.mode not in [AppMode.WORKFLOW.value, AppMode.ADVANCED_CHAT.value]:
+ if app.mode not in [AppMode.WORKFLOW, AppMode.ADVANCED_CHAT]:
return Import(
id=import_id,
status=ImportStatus.FAILED,
@@ -285,6 +286,7 @@ class AppDslService:
id=import_id,
status=status,
app_id=app.id,
+ app_mode=app.mode,
imported_dsl_version=imported_version,
)
@@ -351,6 +353,7 @@ class AppDslService:
id=import_id,
status=ImportStatus.COMPLETED,
app_id=app.id,
+ app_mode=app.mode,
current_dsl_version=CURRENT_DSL_VERSION,
imported_dsl_version=data.get("version", "0.1.0"),
)
diff --git a/web/app/components/app/create-app-dialog/app-list/index.tsx b/web/app/components/app/create-app-dialog/app-list/index.tsx
index 69990f9311a..091e32ed549 100644
--- a/web/app/components/app/create-app-dialog/app-list/index.tsx
+++ b/web/app/components/app/create-app-dialog/app-list/index.tsx
@@ -151,7 +151,7 @@ const Apps = ({
if (app.app_id)
await handleCheckPluginDependencies(app.app_id)
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
- getRedirection(isCurrentWorkspaceEditor, { id: app.app_id, mode }, push)
+ getRedirection(isCurrentWorkspaceEditor, { id: app.app_id!, mode }, push)
}
catch (e) {
Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
diff --git a/web/app/components/app/create-from-dsl-modal/index.tsx b/web/app/components/app/create-from-dsl-modal/index.tsx
index 26e175eb565..c975cd697b8 100644
--- a/web/app/components/app/create-from-dsl-modal/index.tsx
+++ b/web/app/components/app/create-from-dsl-modal/index.tsx
@@ -102,8 +102,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
if (!response)
return
-
- const { id, status, app_id, imported_dsl_version, current_dsl_version } = response
+ const { id, status, app_id, app_mode, imported_dsl_version, current_dsl_version } = response
if (status === DSLImportStatus.COMPLETED || status === DSLImportStatus.COMPLETED_WITH_WARNINGS) {
if (onSuccess)
onSuccess()
@@ -118,7 +117,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
if (app_id)
await handleCheckPluginDependencies(app_id)
- getRedirection(isCurrentWorkspaceEditor, { id: app_id }, push)
+ getRedirection(isCurrentWorkspaceEditor, { id: app_id!, mode: app_mode }, push)
}
else if (status === DSLImportStatus.PENDING) {
setVersions({
@@ -151,7 +150,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
import_id: importId,
})
- const { status, app_id } = response
+ const { status, app_id, app_mode } = response
if (status === DSLImportStatus.COMPLETED) {
if (onSuccess)
@@ -166,7 +165,7 @@ const CreateFromDSLModal = ({ show, onSuccess, onClose, activeTab = CreateFromDS
if (app_id)
await handleCheckPluginDependencies(app_id)
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
- getRedirection(isCurrentWorkspaceEditor, { id: app_id }, push)
+ getRedirection(isCurrentWorkspaceEditor, { id: app_id!, mode: app_mode }, push)
}
else if (status === DSLImportStatus.FAILED) {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
diff --git a/web/app/components/explore/app-list/index.tsx b/web/app/components/explore/app-list/index.tsx
index df15348dd3e..a1a2bafd710 100644
--- a/web/app/components/explore/app-list/index.tsx
+++ b/web/app/components/explore/app-list/index.tsx
@@ -146,7 +146,7 @@ const Apps = ({
if (app.app_id)
await handleCheckPluginDependencies(app.app_id)
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
- getRedirection(isCurrentWorkspaceEditor, { id: app.app_id, mode }, push)
+ getRedirection(isCurrentWorkspaceEditor, { id: app.app_id!, mode }, push)
}
catch (e) {
Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') })
diff --git a/web/models/app.ts b/web/models/app.ts
index b6094b85e92..737df6bfae1 100644
--- a/web/models/app.ts
+++ b/web/models/app.ts
@@ -1,5 +1,5 @@
import type { LangFuseConfig, LangSmithConfig, OpikConfig, TracingProvider } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/type'
-import type { App, AppSSO, AppTemplate, SiteConfig } from '@/types/app'
+import type { App, AppMode, AppSSO, AppTemplate, SiteConfig } from '@/types/app'
import type { Dependency } from '@/app/components/plugins/types'
/* export type App = {
@@ -84,6 +84,7 @@ export type AppDetailResponse = App
export type DSLImportResponse = {
id: string
status: DSLImportStatus
+ app_mode: AppMode
app_id?: string
current_dsl_version?: string
imported_dsl_version?: string
diff --git a/web/utils/app-redirection.ts b/web/utils/app-redirection.ts
index 534b019250c..93273129dcd 100644
--- a/web/utils/app-redirection.ts
+++ b/web/utils/app-redirection.ts
@@ -1,6 +1,8 @@
+import type { AppMode } from '@/types/app'
+
export const getRedirection = (
isCurrentWorkspaceEditor: boolean,
- app: any,
+ app: { id: string, mode: AppMode },
redirectionFunc: (href: string) => void,
) => {
if (!isCurrentWorkspaceEditor) {