소스 검색

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 달 전
부모
커밋
cefec44070
No account linked to committer's email address

+ 1
- 0
api/fields/app_fields.py 파일 보기

"id": fields.String, "id": fields.String,
"status": fields.String, "status": fields.String,
"app_id": fields.String, "app_id": fields.String,
"app_mode": fields.String,
"current_dsl_version": fields.String, "current_dsl_version": fields.String,
"imported_dsl_version": fields.String, "imported_dsl_version": fields.String,
"error": fields.String, "error": fields.String,

+ 1
- 1
api/models/model.py 파일 보기

tenant_id: Mapped[str] = db.Column(StringUUID, nullable=False) tenant_id: Mapped[str] = db.Column(StringUUID, nullable=False)
name = db.Column(db.String(255), nullable=False) name = db.Column(db.String(255), nullable=False)
description = db.Column(db.Text, nullable=False, server_default=db.text("''::character varying")) 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_type = db.Column(db.String(255), nullable=True) # image, emoji
icon = db.Column(db.String(255)) icon = db.Column(db.String(255))
icon_background = db.Column(db.String(255)) icon_background = db.Column(db.String(255))

+ 4
- 1
api/services/app_dsl_service.py 파일 보기

id: str id: str
status: ImportStatus status: ImportStatus
app_id: Optional[str] = None app_id: Optional[str] = None
app_mode: Optional[str] = None
current_dsl_version: str = CURRENT_DSL_VERSION current_dsl_version: str = CURRENT_DSL_VERSION
imported_dsl_version: str = "" imported_dsl_version: str = ""
error: str = "" error: str = ""
error="App not found", 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( return Import(
id=import_id, id=import_id,
status=ImportStatus.FAILED, status=ImportStatus.FAILED,
id=import_id, id=import_id,
status=status, status=status,
app_id=app.id, app_id=app.id,
app_mode=app.mode,
imported_dsl_version=imported_version, imported_dsl_version=imported_version,
) )


id=import_id, id=import_id,
status=ImportStatus.COMPLETED, status=ImportStatus.COMPLETED,
app_id=app.id, app_id=app.id,
app_mode=app.mode,
current_dsl_version=CURRENT_DSL_VERSION, current_dsl_version=CURRENT_DSL_VERSION,
imported_dsl_version=data.get("version", "0.1.0"), imported_dsl_version=data.get("version", "0.1.0"),
) )

+ 1
- 1
web/app/components/app/create-app-dialog/app-list/index.tsx 파일 보기

if (app.app_id) if (app.app_id)
await handleCheckPluginDependencies(app.app_id) await handleCheckPluginDependencies(app.app_id)
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') 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) { catch (e) {
Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') })

+ 4
- 5
web/app/components/app/create-from-dsl-modal/index.tsx 파일 보기



if (!response) if (!response)
return 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 (status === DSLImportStatus.COMPLETED || status === DSLImportStatus.COMPLETED_WITH_WARNINGS) {
if (onSuccess) if (onSuccess)
onSuccess() onSuccess()
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1')
if (app_id) if (app_id)
await handleCheckPluginDependencies(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) { else if (status === DSLImportStatus.PENDING) {
setVersions({ setVersions({
import_id: importId, import_id: importId,
}) })


const { status, app_id } = response
const { status, app_id, app_mode } = response


if (status === DSLImportStatus.COMPLETED) { if (status === DSLImportStatus.COMPLETED) {
if (onSuccess) if (onSuccess)
if (app_id) if (app_id)
await handleCheckPluginDependencies(app_id) await handleCheckPluginDependencies(app_id)
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') 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) { else if (status === DSLImportStatus.FAILED) {
notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) notify({ type: 'error', message: t('app.newApp.appCreateFailed') })

+ 1
- 1
web/app/components/explore/app-list/index.tsx 파일 보기

if (app.app_id) if (app.app_id)
await handleCheckPluginDependencies(app.app_id) await handleCheckPluginDependencies(app.app_id)
localStorage.setItem(NEED_REFRESH_APP_LIST_KEY, '1') 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) { catch (e) {
Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') }) Toast.notify({ type: 'error', message: t('app.newApp.appCreateFailed') })

+ 2
- 1
web/models/app.ts 파일 보기

import type { LangFuseConfig, LangSmithConfig, OpikConfig, TracingProvider } from '@/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/type' 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' import type { Dependency } from '@/app/components/plugins/types'


/* export type App = { /* export type App = {
export type DSLImportResponse = { export type DSLImportResponse = {
id: string id: string
status: DSLImportStatus status: DSLImportStatus
app_mode: AppMode
app_id?: string app_id?: string
current_dsl_version?: string current_dsl_version?: string
imported_dsl_version?: string imported_dsl_version?: string

+ 3
- 1
web/utils/app-redirection.ts 파일 보기

import type { AppMode } from '@/types/app'

export const getRedirection = ( export const getRedirection = (
isCurrentWorkspaceEditor: boolean, isCurrentWorkspaceEditor: boolean,
app: any,
app: { id: string, mode: AppMode },
redirectionFunc: (href: string) => void, redirectionFunc: (href: string) => void,
) => { ) => {
if (!isCurrentWorkspaceEditor) { if (!isCurrentWorkspaceEditor) {

Loading…
취소
저장