mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
Merge branch 'feat/support-free-try-app' of github.com:langgenius/dify into feat/support-free-try-app
This commit is contained in:
commit
cbc55c577b
@ -13,10 +13,14 @@ import ConfigContext from '@/context/debug-configuration'
|
|||||||
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
|
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
|
||||||
import Switch from '@/app/components/base/switch'
|
import Switch from '@/app/components/base/switch'
|
||||||
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||||
|
import OptionCard from '@/app/components/workflow/nodes/_base/components/option-card'
|
||||||
|
import { Resolution } from '@/types/app'
|
||||||
|
import { noop } from 'lodash'
|
||||||
|
import cn from '@/utils/classnames'
|
||||||
|
|
||||||
const ConfigVision: FC = () => {
|
const ConfigVision: FC = () => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const { isShowVisionConfig, isAllowVideoUpload } = useContext(ConfigContext)
|
const { isShowVisionConfig, isAllowVideoUpload, readonly } = useContext(ConfigContext)
|
||||||
const file = useFeatures(s => s.features.file)
|
const file = useFeatures(s => s.features.file)
|
||||||
const featuresStore = useFeaturesStore()
|
const featuresStore = useFeaturesStore()
|
||||||
|
|
||||||
@ -53,7 +57,7 @@ const ConfigVision: FC = () => {
|
|||||||
setFeatures(newFeatures)
|
setFeatures(newFeatures)
|
||||||
}, [featuresStore, isAllowVideoUpload])
|
}, [featuresStore, isAllowVideoUpload])
|
||||||
|
|
||||||
if (!isShowVisionConfig)
|
if (!isShowVisionConfig || (readonly && !isImageEnabled))
|
||||||
return null
|
return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -74,37 +78,49 @@ const ConfigVision: FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex shrink-0 items-center'>
|
<div className='flex shrink-0 items-center'>
|
||||||
{/* <div className='mr-2 flex items-center gap-0.5'>
|
{readonly ? (<>
|
||||||
<div className='text-text-tertiary system-xs-medium-uppercase'>{t('appDebug.vision.visionSettings.resolution')}</div>
|
<div className='mr-2 flex items-center gap-0.5'>
|
||||||
<Tooltip
|
<div className='system-xs-medium-uppercase text-text-tertiary'>{t('appDebug.vision.visionSettings.resolution')}</div>
|
||||||
popupContent={
|
<Tooltip
|
||||||
<div className='w-[180px]' >
|
popupContent={
|
||||||
{t('appDebug.vision.visionSettings.resolutionTooltip').split('\n').map(item => (
|
<div className='w-[180px]' >
|
||||||
<div key={item}>{item}</div>
|
{t('appDebug.vision.visionSettings.resolutionTooltip').split('\n').map(item => (
|
||||||
))}
|
<div key={item}>{item}</div>
|
||||||
</div>
|
))}
|
||||||
}
|
</div>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className='flex items-center gap-1'>
|
||||||
|
<OptionCard
|
||||||
|
title={t('appDebug.vision.visionSettings.high')}
|
||||||
|
selected={file?.image?.detail === Resolution.high}
|
||||||
|
onSelect={noop}
|
||||||
|
className={cn(
|
||||||
|
'cursor-not-allowed rounded-lg px-3 hover:shadow-none',
|
||||||
|
file?.image?.detail !== Resolution.high && 'hover:border-components-option-card-option-border',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<OptionCard
|
||||||
|
title={t('appDebug.vision.visionSettings.low')}
|
||||||
|
selected={file?.image?.detail === Resolution.low}
|
||||||
|
onSelect={noop}
|
||||||
|
className={cn(
|
||||||
|
'cursor-not-allowed rounded-lg px-3 hover:shadow-none',
|
||||||
|
file?.image?.detail !== Resolution.low && 'hover:border-components-option-card-option-border',
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</>) : <>
|
||||||
|
<ParamConfig />
|
||||||
|
<div className='ml-1 mr-3 h-3.5 w-[1px] bg-divider-regular'></div>
|
||||||
|
<Switch
|
||||||
|
defaultValue={isImageEnabled}
|
||||||
|
onChange={handleChange}
|
||||||
|
size='md'
|
||||||
/>
|
/>
|
||||||
</div> */}
|
</>}
|
||||||
{/* <div className='flex items-center gap-1'>
|
|
||||||
<OptionCard
|
|
||||||
title={t('appDebug.vision.visionSettings.high')}
|
|
||||||
selected={file?.image?.detail === Resolution.high}
|
|
||||||
onSelect={() => handleChange(Resolution.high)}
|
|
||||||
/>
|
|
||||||
<OptionCard
|
|
||||||
title={t('appDebug.vision.visionSettings.low')}
|
|
||||||
selected={file?.image?.detail === Resolution.low}
|
|
||||||
onSelect={() => handleChange(Resolution.low)}
|
|
||||||
/>
|
|
||||||
</div> */}
|
|
||||||
<ParamConfig />
|
|
||||||
<div className='ml-1 mr-3 h-3.5 w-[1px] bg-divider-regular'></div>
|
|
||||||
<Switch
|
|
||||||
defaultValue={isImageEnabled}
|
|
||||||
onChange={handleChange}
|
|
||||||
size='md'
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const ConfigAudio: FC = () => {
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const file = useFeatures(s => s.features.file)
|
const file = useFeatures(s => s.features.file)
|
||||||
const featuresStore = useFeaturesStore()
|
const featuresStore = useFeaturesStore()
|
||||||
const { isShowAudioConfig } = useContext(ConfigContext)
|
const { isShowAudioConfig, readonly } = useContext(ConfigContext)
|
||||||
|
|
||||||
const isAudioEnabled = file?.allowed_file_types?.includes(SupportUploadFileTypes.audio) ?? false
|
const isAudioEnabled = file?.allowed_file_types?.includes(SupportUploadFileTypes.audio) ?? false
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ const ConfigAudio: FC = () => {
|
|||||||
setFeatures(newFeatures)
|
setFeatures(newFeatures)
|
||||||
}, [featuresStore])
|
}, [featuresStore])
|
||||||
|
|
||||||
if (!isShowAudioConfig)
|
if (!isShowAudioConfig || (readonly && !isAudioEnabled))
|
||||||
return null
|
return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -64,14 +64,16 @@ const ConfigAudio: FC = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex shrink-0 items-center'>
|
{!readonly && (
|
||||||
<div className='ml-1 mr-3 h-3.5 w-[1px] bg-divider-subtle'></div>
|
<div className='flex shrink-0 items-center'>
|
||||||
<Switch
|
<div className='ml-1 mr-3 h-3.5 w-[1px] bg-divider-subtle'></div>
|
||||||
defaultValue={isAudioEnabled}
|
<Switch
|
||||||
onChange={handleChange}
|
defaultValue={isAudioEnabled}
|
||||||
size='md'
|
onChange={handleChange}
|
||||||
/>
|
size='md'
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ const ConfigDocument: FC = () => {
|
|||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const file = useFeatures(s => s.features.file)
|
const file = useFeatures(s => s.features.file)
|
||||||
const featuresStore = useFeaturesStore()
|
const featuresStore = useFeaturesStore()
|
||||||
const { isShowDocumentConfig } = useContext(ConfigContext)
|
const { isShowDocumentConfig, readonly } = useContext(ConfigContext)
|
||||||
|
|
||||||
const isDocumentEnabled = file?.allowed_file_types?.includes(SupportUploadFileTypes.document) ?? false
|
const isDocumentEnabled = file?.allowed_file_types?.includes(SupportUploadFileTypes.document) ?? false
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ const ConfigDocument: FC = () => {
|
|||||||
setFeatures(newFeatures)
|
setFeatures(newFeatures)
|
||||||
}, [featuresStore])
|
}, [featuresStore])
|
||||||
|
|
||||||
if (!isShowDocumentConfig)
|
if (!isShowDocumentConfig || (readonly && !isDocumentEnabled))
|
||||||
return null
|
return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -64,14 +64,16 @@ const ConfigDocument: FC = () => {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className='flex shrink-0 items-center'>
|
{!readonly && (
|
||||||
<div className='ml-1 mr-3 h-3.5 w-[1px] bg-divider-subtle'></div>
|
<div className='flex shrink-0 items-center'>
|
||||||
<Switch
|
<div className='ml-1 mr-3 h-3.5 w-[1px] bg-divider-subtle'></div>
|
||||||
defaultValue={isDocumentEnabled}
|
<Switch
|
||||||
onChange={handleChange}
|
defaultValue={isDocumentEnabled}
|
||||||
size='md'
|
onChange={handleChange}
|
||||||
/>
|
size='md'
|
||||||
</div>
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,7 @@ const DebugWithSingleModel = (
|
|||||||
) => {
|
) => {
|
||||||
const { userProfile } = useAppContext()
|
const { userProfile } = useAppContext()
|
||||||
const {
|
const {
|
||||||
|
readonly,
|
||||||
modelConfig,
|
modelConfig,
|
||||||
appId,
|
appId,
|
||||||
inputs,
|
inputs,
|
||||||
@ -154,6 +155,7 @@ const DebugWithSingleModel = (
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Chat
|
<Chat
|
||||||
|
readonly={readonly}
|
||||||
config={config}
|
config={config}
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
isResponding={isResponding}
|
isResponding={isResponding}
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import Config from '@/app/components/app/configuration/config'
|
|||||||
import Debug from '@/app/components/app/configuration/debug'
|
import Debug from '@/app/components/app/configuration/debug'
|
||||||
import { ModelFeatureEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
import { ModelFeatureEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||||
import { ModelModeType, Resolution, TransferMethod } from '@/types/app'
|
import { ModelModeType, Resolution, TransferMethod } from '@/types/app'
|
||||||
|
import type { ModelConfig } from '@/models/debug'
|
||||||
import { PromptMode } from '@/models/debug'
|
import { PromptMode } from '@/models/debug'
|
||||||
import { ANNOTATION_DEFAULT, DEFAULT_AGENT_SETTING, DEFAULT_CHAT_PROMPT_CONFIG, DEFAULT_COMPLETION_PROMPT_CONFIG } from '@/config'
|
import { ANNOTATION_DEFAULT, DEFAULT_AGENT_SETTING, DEFAULT_CHAT_PROMPT_CONFIG, DEFAULT_COMPLETION_PROMPT_CONFIG } from '@/config'
|
||||||
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
|
import useBreakpoints, { MediaType } from '@/hooks/use-breakpoints'
|
||||||
@ -25,6 +26,7 @@ import { useGetTryAppDataSets, useGetTryAppInfo } from '@/service/use-try-app'
|
|||||||
import { noop } from 'lodash'
|
import { noop } from 'lodash'
|
||||||
import { correctModelProvider } from '@/utils'
|
import { correctModelProvider } from '@/utils'
|
||||||
import { userInputsFormToPromptVariables } from '@/utils/model-config'
|
import { userInputsFormToPromptVariables } from '@/utils/model-config'
|
||||||
|
import { useTextGenerationCurrentProviderAndModelAndModelList } from '../../header/account-setting/model-provider-page/hooks'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
appId: string
|
appId: string
|
||||||
@ -81,7 +83,7 @@ const Configuration: FC<Props> = ({
|
|||||||
const dataSets = dataSetData?.data || []
|
const dataSets = dataSetData?.data || []
|
||||||
const isLoading = isLoadingAppDetail || isLoadingDatasets
|
const isLoading = isLoadingAppDetail || isLoadingDatasets
|
||||||
|
|
||||||
const modelConfig = ((modelConfig?: BackendModelConfig) => {
|
const modelConfig: ModelConfig = ((modelConfig?: BackendModelConfig) => {
|
||||||
if(isLoading || !modelConfig)
|
if(isLoading || !modelConfig)
|
||||||
return defaultModelConfig
|
return defaultModelConfig
|
||||||
|
|
||||||
@ -138,7 +140,7 @@ const Configuration: FC<Props> = ({
|
|||||||
tools: [],
|
tools: [],
|
||||||
} : DEFAULT_AGENT_SETTING,
|
} : DEFAULT_AGENT_SETTING,
|
||||||
}
|
}
|
||||||
return newModelConfig
|
return (newModelConfig as any)
|
||||||
})(appDetail?.model_config)
|
})(appDetail?.model_config)
|
||||||
const mode = appDetail?.mode
|
const mode = appDetail?.mode
|
||||||
// const isChatApp = ['chat', 'advanced-chat', 'agent-chat'].includes(mode!)
|
// const isChatApp = ['chat', 'advanced-chat', 'agent-chat'].includes(mode!)
|
||||||
@ -172,12 +174,14 @@ const Configuration: FC<Props> = ({
|
|||||||
const query = ''
|
const query = ''
|
||||||
const completionParams = useState<FormValue>({})
|
const completionParams = useState<FormValue>({})
|
||||||
|
|
||||||
// todo
|
const {
|
||||||
const currModel: {
|
currentModel: currModel,
|
||||||
features: ModelFeatureEnum[]
|
} = useTextGenerationCurrentProviderAndModelAndModelList(
|
||||||
} = {
|
{
|
||||||
features: [],
|
provider: modelConfig.provider,
|
||||||
}
|
model: modelConfig.model_id,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
const isShowVisionConfig = !!currModel?.features?.includes(ModelFeatureEnum.vision)
|
const isShowVisionConfig = !!currModel?.features?.includes(ModelFeatureEnum.vision)
|
||||||
const isShowDocumentConfig = !!currModel?.features?.includes(ModelFeatureEnum.document)
|
const isShowDocumentConfig = !!currModel?.features?.includes(ModelFeatureEnum.document)
|
||||||
@ -208,7 +212,7 @@ const Configuration: FC<Props> = ({
|
|||||||
number_limits: modelConfig.file_upload?.image?.number_limits || 3,
|
number_limits: modelConfig.file_upload?.image?.number_limits || 3,
|
||||||
transfer_methods: modelConfig.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
transfer_methods: modelConfig.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
||||||
},
|
},
|
||||||
enabled: true,
|
enabled: !!(modelConfig.file_upload?.enabled || modelConfig.file_upload?.image?.enabled),
|
||||||
allowed_file_types: modelConfig.file_upload?.allowed_file_types || [],
|
allowed_file_types: modelConfig.file_upload?.allowed_file_types || [],
|
||||||
allowed_file_extensions: modelConfig.file_upload?.allowed_file_extensions || [...FILE_EXTS[SupportUploadFileTypes.image], ...FILE_EXTS[SupportUploadFileTypes.video]].map(ext => `.${ext}`),
|
allowed_file_extensions: modelConfig.file_upload?.allowed_file_extensions || [...FILE_EXTS[SupportUploadFileTypes.image], ...FILE_EXTS[SupportUploadFileTypes.video]].map(ext => `.${ext}`),
|
||||||
allowed_file_upload_methods: modelConfig.file_upload?.allowed_file_upload_methods || modelConfig.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
allowed_file_upload_methods: modelConfig.file_upload?.allowed_file_upload_methods || modelConfig.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
||||||
|
|||||||
@ -50,13 +50,14 @@ function getActionButtonState(state: ActionButtonState) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ActionButton = ({ className, size, state = ActionButtonState.Default, styleCss, children, ref, ...props }: ActionButtonProps) => {
|
const ActionButton = ({ className, size, state = ActionButtonState.Default, styleCss, children, ref, disabled, ...props }: ActionButtonProps) => {
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type='button'
|
type='button'
|
||||||
className={classNames(
|
className={classNames(
|
||||||
actionButtonVariants({ className, size }),
|
actionButtonVariants({ className, size }),
|
||||||
getActionButtonState(state),
|
getActionButtonState(state),
|
||||||
|
disabled && 'cursor-not-allowed text-text-disabled hover:bg-transparent hover:text-text-disabled',
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
style={styleCss}
|
style={styleCss}
|
||||||
|
|||||||
@ -27,8 +27,10 @@ import { useToastContext } from '@/app/components/base/toast'
|
|||||||
import FeatureBar from '@/app/components/base/features/new-feature-panel/feature-bar'
|
import FeatureBar from '@/app/components/base/features/new-feature-panel/feature-bar'
|
||||||
import type { FileUpload } from '@/app/components/base/features/types'
|
import type { FileUpload } from '@/app/components/base/features/types'
|
||||||
import { TransferMethod } from '@/types/app'
|
import { TransferMethod } from '@/types/app'
|
||||||
|
import { noop } from 'lodash-es'
|
||||||
|
|
||||||
type ChatInputAreaProps = {
|
type ChatInputAreaProps = {
|
||||||
|
readonly?: boolean
|
||||||
botName?: string
|
botName?: string
|
||||||
showFeatureBar?: boolean
|
showFeatureBar?: boolean
|
||||||
showFileUpload?: boolean
|
showFileUpload?: boolean
|
||||||
@ -44,6 +46,7 @@ type ChatInputAreaProps = {
|
|||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}
|
}
|
||||||
const ChatInputArea = ({
|
const ChatInputArea = ({
|
||||||
|
readonly,
|
||||||
botName,
|
botName,
|
||||||
showFeatureBar,
|
showFeatureBar,
|
||||||
showFileUpload,
|
showFileUpload,
|
||||||
@ -159,6 +162,7 @@ const ChatInputArea = ({
|
|||||||
const operation = (
|
const operation = (
|
||||||
<Operation
|
<Operation
|
||||||
ref={holdSpaceRef}
|
ref={holdSpaceRef}
|
||||||
|
readonly={readonly}
|
||||||
fileConfig={visionConfig}
|
fileConfig={visionConfig}
|
||||||
speechToTextConfig={speechToTextConfig}
|
speechToTextConfig={speechToTextConfig}
|
||||||
onShowVoiceInput={handleShowVoiceInput}
|
onShowVoiceInput={handleShowVoiceInput}
|
||||||
@ -194,7 +198,7 @@ const ChatInputArea = ({
|
|||||||
className={cn(
|
className={cn(
|
||||||
'body-lg-regular w-full resize-none bg-transparent p-1 leading-6 text-text-primary outline-none',
|
'body-lg-regular w-full resize-none bg-transparent p-1 leading-6 text-text-primary outline-none',
|
||||||
)}
|
)}
|
||||||
placeholder={t('common.chat.inputPlaceholder', { botName }) || ''}
|
placeholder={readonly ? t('common.chat.inputDisabledPlaceholder') : t('common.chat.inputPlaceholder', { botName }) || ''}
|
||||||
autoFocus
|
autoFocus
|
||||||
minRows={1}
|
minRows={1}
|
||||||
onResize={handleTextareaResize}
|
onResize={handleTextareaResize}
|
||||||
@ -211,6 +215,7 @@ const ChatInputArea = ({
|
|||||||
onDragLeave={handleDragFileLeave}
|
onDragLeave={handleDragFileLeave}
|
||||||
onDragOver={handleDragFileOver}
|
onDragOver={handleDragFileOver}
|
||||||
onDrop={handleDropFile}
|
onDrop={handleDropFile}
|
||||||
|
readOnly={readonly}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
@ -232,7 +237,12 @@ const ChatInputArea = ({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
{showFeatureBar && <FeatureBar showFileUpload={showFileUpload} disabled={featureBarDisabled} onFeatureBarClick={onFeatureBarClick} />}
|
{showFeatureBar && <FeatureBar
|
||||||
|
showFileUpload={showFileUpload}
|
||||||
|
disabled={featureBarDisabled}
|
||||||
|
onFeatureBarClick={readonly ? noop : onFeatureBarClick}
|
||||||
|
hideEditEntrance={readonly}
|
||||||
|
/>}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,8 +12,10 @@ import ActionButton from '@/app/components/base/action-button'
|
|||||||
import { FileUploaderInChatInput } from '@/app/components/base/file-uploader'
|
import { FileUploaderInChatInput } from '@/app/components/base/file-uploader'
|
||||||
import type { FileUpload } from '@/app/components/base/features/types'
|
import type { FileUpload } from '@/app/components/base/features/types'
|
||||||
import cn from '@/utils/classnames'
|
import cn from '@/utils/classnames'
|
||||||
|
import { noop } from 'lodash'
|
||||||
|
|
||||||
type OperationProps = {
|
type OperationProps = {
|
||||||
|
readonly?: boolean
|
||||||
fileConfig?: FileUpload
|
fileConfig?: FileUpload
|
||||||
speechToTextConfig?: EnableType
|
speechToTextConfig?: EnableType
|
||||||
onShowVoiceInput?: () => void
|
onShowVoiceInput?: () => void
|
||||||
@ -22,6 +24,7 @@ type OperationProps = {
|
|||||||
}
|
}
|
||||||
const Operation = (
|
const Operation = (
|
||||||
{
|
{
|
||||||
|
readonly,
|
||||||
ref,
|
ref,
|
||||||
fileConfig,
|
fileConfig,
|
||||||
speechToTextConfig,
|
speechToTextConfig,
|
||||||
@ -43,12 +46,13 @@ const Operation = (
|
|||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
<div className='flex items-center space-x-1'>
|
<div className='flex items-center space-x-1'>
|
||||||
{fileConfig?.enabled && <FileUploaderInChatInput fileConfig={fileConfig} />}
|
{fileConfig?.enabled && <FileUploaderInChatInput readonly={readonly} fileConfig={fileConfig} />}
|
||||||
{
|
{
|
||||||
speechToTextConfig?.enabled && (
|
speechToTextConfig?.enabled && (
|
||||||
<ActionButton
|
<ActionButton
|
||||||
size='l'
|
size='l'
|
||||||
onClick={onShowVoiceInput}
|
disabled={readonly}
|
||||||
|
onClick={readonly ? noop : onShowVoiceInput}
|
||||||
>
|
>
|
||||||
<RiMicLine className='h-5 w-5' />
|
<RiMicLine className='h-5 w-5' />
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
@ -58,7 +62,8 @@ const Operation = (
|
|||||||
<Button
|
<Button
|
||||||
className='ml-3 w-8 px-0'
|
className='ml-3 w-8 px-0'
|
||||||
variant='primary'
|
variant='primary'
|
||||||
onClick={onSend}
|
onClick={readonly ? noop : onSend}
|
||||||
|
disabled={readonly}
|
||||||
style={
|
style={
|
||||||
theme
|
theme
|
||||||
? {
|
? {
|
||||||
|
|||||||
@ -17,10 +17,13 @@ export type ChatContextValue = Pick<ChatProps, 'config'
|
|||||||
| 'onAnnotationRemoved'
|
| 'onAnnotationRemoved'
|
||||||
| 'disableFeedback'
|
| 'disableFeedback'
|
||||||
| 'onFeedback'
|
| 'onFeedback'
|
||||||
>
|
> & {
|
||||||
|
readonly?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
const ChatContext = createContext<ChatContextValue>({
|
const ChatContext = createContext<ChatContextValue>({
|
||||||
chatList: [],
|
chatList: [],
|
||||||
|
readonly: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
type ChatContextProviderProps = {
|
type ChatContextProviderProps = {
|
||||||
@ -29,6 +32,7 @@ type ChatContextProviderProps = {
|
|||||||
|
|
||||||
export const ChatContextProvider = ({
|
export const ChatContextProvider = ({
|
||||||
children,
|
children,
|
||||||
|
readonly = false,
|
||||||
config,
|
config,
|
||||||
isResponding,
|
isResponding,
|
||||||
chatList,
|
chatList,
|
||||||
@ -46,6 +50,7 @@ export const ChatContextProvider = ({
|
|||||||
return (
|
return (
|
||||||
<ChatContext.Provider value={{
|
<ChatContext.Provider value={{
|
||||||
config,
|
config,
|
||||||
|
readonly,
|
||||||
isResponding,
|
isResponding,
|
||||||
chatList: chatList || [],
|
chatList: chatList || [],
|
||||||
showPromptLog,
|
showPromptLog,
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import { useStore as useAppStore } from '@/app/components/app/store'
|
|||||||
import type { AppData } from '@/models/share'
|
import type { AppData } from '@/models/share'
|
||||||
|
|
||||||
export type ChatProps = {
|
export type ChatProps = {
|
||||||
|
readonly?: boolean
|
||||||
appData?: AppData
|
appData?: AppData
|
||||||
chatList: ChatItem[]
|
chatList: ChatItem[]
|
||||||
config?: ChatConfig
|
config?: ChatConfig
|
||||||
@ -77,6 +78,7 @@ export type ChatProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Chat: FC<ChatProps> = ({
|
const Chat: FC<ChatProps> = ({
|
||||||
|
readonly = false,
|
||||||
appData,
|
appData,
|
||||||
config,
|
config,
|
||||||
onSend,
|
onSend,
|
||||||
@ -221,6 +223,7 @@ const Chat: FC<ChatProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ChatContextProvider
|
<ChatContextProvider
|
||||||
|
readonly={readonly}
|
||||||
config={config}
|
config={config}
|
||||||
chatList={chatList}
|
chatList={chatList}
|
||||||
isResponding={isResponding}
|
isResponding={isResponding}
|
||||||
@ -324,6 +327,7 @@ const Chat: FC<ChatProps> = ({
|
|||||||
inputsForm={inputsForm}
|
inputsForm={inputsForm}
|
||||||
theme={themeBuilder?.theme}
|
theme={themeBuilder?.theme}
|
||||||
isResponding={isResponding}
|
isResponding={isResponding}
|
||||||
|
readonly={readonly}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,6 +13,7 @@ type Props = {
|
|||||||
showFileUpload?: boolean
|
showFileUpload?: boolean
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
onFeatureBarClick?: (state: boolean) => void
|
onFeatureBarClick?: (state: boolean) => void
|
||||||
|
hideEditEntrance?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const FeatureBar = ({
|
const FeatureBar = ({
|
||||||
@ -20,6 +21,7 @@ const FeatureBar = ({
|
|||||||
showFileUpload = true,
|
showFileUpload = true,
|
||||||
disabled,
|
disabled,
|
||||||
onFeatureBarClick,
|
onFeatureBarClick,
|
||||||
|
hideEditEntrance = false,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const features = useFeatures(s => s.features)
|
const features = useFeatures(s => s.features)
|
||||||
@ -132,10 +134,14 @@ const FeatureBar = ({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className='body-xs-regular grow text-text-tertiary'>{t('appDebug.feature.bar.enableText')}</div>
|
<div className='body-xs-regular grow text-text-tertiary'>{t('appDebug.feature.bar.enableText')}</div>
|
||||||
<Button className='shrink-0' variant='ghost-accent' size='small' onClick={() => onFeatureBarClick?.(true)}>
|
{
|
||||||
<div className='mx-1'>{t('appDebug.feature.bar.manage')}</div>
|
!hideEditEntrance && (
|
||||||
<RiArrowRightLine className='h-3.5 w-3.5 text-text-accent' />
|
<Button className='shrink-0' variant='ghost-accent' size='small' onClick={() => onFeatureBarClick?.(true)}>
|
||||||
</Button>
|
<div className='mx-1'>{t('appDebug.feature.bar.manage')}</div>
|
||||||
|
<RiArrowRightLine className='h-3.5 w-3.5 text-text-accent' />
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -13,21 +13,27 @@ import { TransferMethod } from '@/types/app'
|
|||||||
|
|
||||||
type FileUploaderInChatInputProps = {
|
type FileUploaderInChatInputProps = {
|
||||||
fileConfig: FileUpload
|
fileConfig: FileUpload
|
||||||
|
readonly?: boolean
|
||||||
}
|
}
|
||||||
const FileUploaderInChatInput = ({
|
const FileUploaderInChatInput = ({
|
||||||
fileConfig,
|
fileConfig,
|
||||||
|
readonly,
|
||||||
}: FileUploaderInChatInputProps) => {
|
}: FileUploaderInChatInputProps) => {
|
||||||
const renderTrigger = useCallback((open: boolean) => {
|
const renderTrigger = useCallback((open: boolean) => {
|
||||||
return (
|
return (
|
||||||
<ActionButton
|
<ActionButton
|
||||||
size='l'
|
size='l'
|
||||||
className={cn(open && 'bg-state-base-hover')}
|
className={cn(open && 'bg-state-base-hover')}
|
||||||
|
disabled={readonly}
|
||||||
>
|
>
|
||||||
<RiAttachmentLine className='h-5 w-5' />
|
<RiAttachmentLine className='h-5 w-5' />
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
)
|
)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
if(readonly)
|
||||||
|
return renderTrigger(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FileFromLinkOrLocal
|
<FileFromLinkOrLocal
|
||||||
trigger={renderTrigger}
|
trigger={renderTrigger}
|
||||||
|
|||||||
@ -663,6 +663,7 @@ const translation = {
|
|||||||
hitScore: 'Retrieval Score:',
|
hitScore: 'Retrieval Score:',
|
||||||
},
|
},
|
||||||
inputPlaceholder: 'Talk to {{botName}}',
|
inputPlaceholder: 'Talk to {{botName}}',
|
||||||
|
inputDisabledPlaceholder: 'Preview Only',
|
||||||
thinking: 'Thinking...',
|
thinking: 'Thinking...',
|
||||||
thought: 'Thought',
|
thought: 'Thought',
|
||||||
resend: 'Resend',
|
resend: 'Resend',
|
||||||
|
|||||||
@ -654,6 +654,7 @@ const translation = {
|
|||||||
hitScore: '検索スコア:',
|
hitScore: '検索スコア:',
|
||||||
},
|
},
|
||||||
inputPlaceholder: '{{botName}} と話す',
|
inputPlaceholder: '{{botName}} と話す',
|
||||||
|
inputDisabledPlaceholder: 'プレビューのみ',
|
||||||
thought: '思考',
|
thought: '思考',
|
||||||
thinking: '考え中...',
|
thinking: '考え中...',
|
||||||
resend: '再送信してください',
|
resend: '再送信してください',
|
||||||
|
|||||||
@ -657,6 +657,7 @@ const translation = {
|
|||||||
hitScore: '召回得分:',
|
hitScore: '召回得分:',
|
||||||
},
|
},
|
||||||
inputPlaceholder: '和 {{botName}} 聊天',
|
inputPlaceholder: '和 {{botName}} 聊天',
|
||||||
|
inputDisabledPlaceholder: '仅供试用',
|
||||||
thinking: '深度思考中...',
|
thinking: '深度思考中...',
|
||||||
thought: '已深度思考',
|
thought: '已深度思考',
|
||||||
resend: '重新发送',
|
resend: '重新发送',
|
||||||
|
|||||||
@ -132,6 +132,9 @@ export type ModelConfig = {
|
|||||||
provider: string // LLM Provider: for example "OPENAI"
|
provider: string // LLM Provider: for example "OPENAI"
|
||||||
model_id: string
|
model_id: string
|
||||||
mode: ModelModeType
|
mode: ModelModeType
|
||||||
|
prompt_type?: PromptMode
|
||||||
|
chat_prompt_config?: ChatPromptConfig | null
|
||||||
|
completion_prompt_config?: CompletionPromptConfig | null
|
||||||
configs: PromptConfig
|
configs: PromptConfig
|
||||||
opening_statement: string | null
|
opening_statement: string | null
|
||||||
more_like_this: MoreLikeThisConfig | null
|
more_like_this: MoreLikeThisConfig | null
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user