chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
+192
@@ -0,0 +1,192 @@
|
||||
import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
|
||||
import type { FileEntity } from '@/app/components/base/file-uploader/types'
|
||||
import type { VarInInspect } from '@/types/workflow'
|
||||
import { Textarea } from '@langgenius/dify-ui/textarea'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader'
|
||||
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||
import ErrorMessage from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/error-message'
|
||||
import SchemaEditor from '@/app/components/workflow/nodes/llm/components/json-schema-config-modal/schema-editor'
|
||||
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||
import { TransferMethod } from '@/types/app'
|
||||
import { PreviewMode } from '../../base/features/types'
|
||||
import BoolValue from '../panel/chat-variable-panel/components/bool-value'
|
||||
import { DisplayContent } from './display-content'
|
||||
import LargeDataAlert from './large-data-alert'
|
||||
import { PreviewType } from './types'
|
||||
|
||||
type TextEditorSectionProps = {
|
||||
currentVar: VarInInspect
|
||||
value: unknown
|
||||
textEditorDisabled: boolean
|
||||
isTruncated: boolean
|
||||
onTextChange: (value: string) => void
|
||||
}
|
||||
|
||||
export const TextEditorSection = ({
|
||||
currentVar,
|
||||
value,
|
||||
textEditorDisabled,
|
||||
isTruncated,
|
||||
onTextChange,
|
||||
}: TextEditorSectionProps) => {
|
||||
const { t } = useTranslation(['workflow'])
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
{isTruncated && <LargeDataAlert className="mx-3 mt-1 mb-1 shrink-0" />}
|
||||
<div className="min-h-0 grow">
|
||||
{currentVar.value_type === 'string' ? (
|
||||
<DisplayContent
|
||||
previewType={PreviewType.Markdown}
|
||||
varType={currentVar.value_type}
|
||||
mdString={typeof value === 'string' ? value : String(value ?? '')}
|
||||
readonly={textEditorDisabled || isTruncated}
|
||||
handleTextChange={onTextChange}
|
||||
/>
|
||||
) : (
|
||||
<Textarea
|
||||
aria-label={t(($) => $['errorMsg.fields.variableValue'], { ns: 'workflow' })}
|
||||
readOnly={textEditorDisabled}
|
||||
disabled={textEditorDisabled || isTruncated}
|
||||
className="h-full"
|
||||
value={typeof value === 'number' ? value : String(value ?? '')}
|
||||
onValueChange={(value) => onTextChange(value)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
type BoolArraySectionProps = {
|
||||
values: boolean[]
|
||||
onChange: (nextValue: boolean[]) => void
|
||||
}
|
||||
|
||||
export const BoolArraySection = ({ values, onChange }: BoolArraySectionProps) => {
|
||||
return (
|
||||
<div className="w-73.75 space-y-1">
|
||||
{values.map((value, index) => (
|
||||
<BoolValue
|
||||
key={`${index}-${String(value)}`}
|
||||
value={value}
|
||||
onChange={(newValue) => {
|
||||
const nextValue = [...values]
|
||||
nextValue[index] = newValue
|
||||
onChange(nextValue)
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
type JsonEditorSectionProps = {
|
||||
hasChunks: boolean
|
||||
schemaType?: string
|
||||
valueType: VarInInspect['value_type']
|
||||
json: string
|
||||
readonly: boolean
|
||||
isTruncated: boolean
|
||||
onChange: (value: string) => void
|
||||
}
|
||||
|
||||
export const JsonEditorSection = ({
|
||||
hasChunks,
|
||||
schemaType,
|
||||
valueType,
|
||||
json,
|
||||
readonly,
|
||||
isTruncated,
|
||||
onChange,
|
||||
}: JsonEditorSectionProps) => {
|
||||
if (hasChunks) {
|
||||
return (
|
||||
<DisplayContent
|
||||
previewType={PreviewType.Chunks}
|
||||
varType={valueType}
|
||||
schemaType={schemaType ?? ''}
|
||||
jsonString={json ?? '{}'}
|
||||
readonly={readonly}
|
||||
handleEditorChange={onChange}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<SchemaEditor
|
||||
readonly={readonly || isTruncated}
|
||||
className="overflow-y-auto"
|
||||
hideTopMenu
|
||||
schema={json}
|
||||
onUpdate={onChange}
|
||||
isTruncated={isTruncated}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
type FileEditorSectionProps = {
|
||||
currentVar: VarInInspect
|
||||
fileValue: FileEntity[]
|
||||
fileUploadConfig?: UploadConfig
|
||||
textEditorDisabled: boolean
|
||||
onChange: (files: FileEntity[]) => void
|
||||
}
|
||||
|
||||
export const FileEditorSection = ({
|
||||
currentVar,
|
||||
fileValue,
|
||||
fileUploadConfig,
|
||||
textEditorDisabled,
|
||||
onChange,
|
||||
}: FileEditorSectionProps) => {
|
||||
return (
|
||||
<div className="max-w-115">
|
||||
<FileUploaderInAttachmentWrapper
|
||||
value={fileValue}
|
||||
onChange={onChange}
|
||||
fileConfig={{
|
||||
allowed_file_types: [
|
||||
SupportUploadFileTypes.image,
|
||||
SupportUploadFileTypes.document,
|
||||
SupportUploadFileTypes.audio,
|
||||
SupportUploadFileTypes.video,
|
||||
],
|
||||
allowed_file_extensions: [
|
||||
...(FILE_EXTS[SupportUploadFileTypes.image] ?? []),
|
||||
...(FILE_EXTS[SupportUploadFileTypes.document] ?? []),
|
||||
...(FILE_EXTS[SupportUploadFileTypes.audio] ?? []),
|
||||
...(FILE_EXTS[SupportUploadFileTypes.video] ?? []),
|
||||
],
|
||||
allowed_file_upload_methods: [TransferMethod.local_file, TransferMethod.remote_url],
|
||||
number_limits:
|
||||
currentVar.value_type === 'file'
|
||||
? 1
|
||||
: fileUploadConfig?.workflow_file_upload_limit || 5,
|
||||
fileUploadConfig,
|
||||
preview_config: {
|
||||
mode: PreviewMode.NewPage,
|
||||
file_type_list: ['application/pdf'],
|
||||
},
|
||||
}}
|
||||
isDisabled={textEditorDisabled}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export const ErrorMessages = ({
|
||||
parseError,
|
||||
validationError,
|
||||
}: {
|
||||
parseError: Error | null
|
||||
validationError: string
|
||||
}) => {
|
||||
return (
|
||||
<>
|
||||
{parseError && <ErrorMessage className="mt-1" message={parseError.message} />}
|
||||
{validationError && <ErrorMessage className="mt-1" message={validationError} />}
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user