Ver código fonte

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

Signed-off-by: -LAN- <laipz8200@outlook.com>
Co-authored-by: twwu <twwu@dify.ai>
tags/1.1.0
-LAN- 7 meses atrás
pai
commit
cefec44070
Nenhuma conta vinculada ao e-mail do autor do commit

+ 1
- 0
api/fields/app_fields.py Ver arquivo

@@ -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,

+ 1
- 1
api/models/model.py Ver arquivo

@@ -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))

+ 4
- 1
api/services/app_dsl_service.py Ver arquivo

@@ -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"),
)

+ 1
- 1
web/app/components/app/create-app-dialog/app-list/index.tsx Ver arquivo

@@ -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') })

+ 4
- 5
web/app/components/app/create-from-dsl-modal/index.tsx Ver arquivo

@@ -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') })

+ 1
- 1
web/app/components/explore/app-list/index.tsx Ver arquivo

@@ -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') })

+ 2
- 1
web/models/app.ts Ver arquivo

@@ -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

+ 3
- 1
web/utils/app-redirection.ts Ver arquivo

@@ -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) {

Carregando…
Cancelar
Salvar