mirror of https://github.com/langgenius/dify.git
fix max length for paragraph
This commit is contained in:
parent
c8db4d8a08
commit
aee669f67d
|
|
@ -46,7 +46,6 @@ const Apps = () => {
|
|||
const { isCurrentWorkspaceManager } = useAppContext()
|
||||
const [activeTab, setActiveTab] = useTabSearchParams({
|
||||
defaultTab: 'all',
|
||||
disableSearchParams: true, // use search params will distroy app list mutation
|
||||
})
|
||||
const [keywords, setKeywords] = useState('')
|
||||
const [searchKeywords, setSearchKeywords] = useState('')
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ import Modal from '@/app/components/base/modal'
|
|||
import Switch from '@/app/components/base/switch'
|
||||
import { ChangeType, InputVarType } from '@/app/components/workflow/types'
|
||||
|
||||
const TEXT_MAX_LENGTH = 256
|
||||
const PARAGRAPH_MAX_LENGTH = 1024
|
||||
|
||||
export type IConfigModalProps = {
|
||||
isCreate?: boolean
|
||||
payload?: InputVar
|
||||
|
|
@ -165,7 +168,7 @@ const ConfigModal: FC<IConfigModalProps> = ({
|
|||
|
||||
{isStringInput && (
|
||||
<Field title={t('appDebug.variableConig.maxLength')}>
|
||||
<ConfigString modelId={modelConfig.model_id} value={max_length} onChange={handlePayloadChange('max_length')} />
|
||||
<ConfigString maxLength={type === InputVarType.textInput ? TEXT_MAX_LENGTH : PARAGRAPH_MAX_LENGTH} modelId={modelConfig.model_id} value={max_length} onChange={handlePayloadChange('max_length')} />
|
||||
</Field>
|
||||
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -4,32 +4,32 @@ import React, { useEffect } from 'react'
|
|||
|
||||
export type IConfigStringProps = {
|
||||
value: number | undefined
|
||||
maxLength: number
|
||||
modelId: string
|
||||
onChange: (value: number | undefined) => void
|
||||
}
|
||||
|
||||
const MAX_LENGTH = 256
|
||||
|
||||
const ConfigString: FC<IConfigStringProps> = ({
|
||||
value,
|
||||
onChange,
|
||||
maxLength,
|
||||
}) => {
|
||||
useEffect(() => {
|
||||
if (value && value > MAX_LENGTH)
|
||||
onChange(MAX_LENGTH)
|
||||
}, [value, MAX_LENGTH])
|
||||
if (value && value > maxLength)
|
||||
onChange(maxLength)
|
||||
}, [value, maxLength, onChange])
|
||||
|
||||
return (
|
||||
<div>
|
||||
<input
|
||||
type="number"
|
||||
max={MAX_LENGTH}
|
||||
max={maxLength}
|
||||
min={1}
|
||||
value={value || ''}
|
||||
onChange={(e) => {
|
||||
let value = parseInt(e.target.value, 10)
|
||||
if (value > MAX_LENGTH)
|
||||
value = MAX_LENGTH
|
||||
if (value > maxLength)
|
||||
value = maxLength
|
||||
|
||||
else if (value < 1)
|
||||
value = 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue