mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-18 18:25:54 +08:00
annotation reply
This commit is contained in:
parent
565a835947
commit
b0e7a22a27
@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Main from '@/app/components/app/log-annotation'
|
import Main from '@/app/components/app/log-annotation'
|
||||||
import { PageType } from '@/app/components/app/configuration/toolbox/annotation/type'
|
import { PageType } from '@/app/components/base/features/new-feature-panel/annotation-reply/type'
|
||||||
|
|
||||||
export type IProps = {
|
export type IProps = {
|
||||||
params: { appId: string }
|
params: { appId: string }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import Main from '@/app/components/app/log-annotation'
|
import Main from '@/app/components/app/log-annotation'
|
||||||
import { PageType } from '@/app/components/app/configuration/toolbox/annotation/type'
|
import { PageType } from '@/app/components/base/features/new-feature-panel/annotation-reply/type'
|
||||||
|
|
||||||
const Logs = async () => {
|
const Logs = async () => {
|
||||||
return (
|
return (
|
||||||
|
@ -18,7 +18,7 @@ import Switch from '@/app/components/base/switch'
|
|||||||
import { addAnnotation, delAnnotation, fetchAnnotationConfig as doFetchAnnotationConfig, editAnnotation, fetchAnnotationList, queryAnnotationJobStatus, updateAnnotationScore, updateAnnotationStatus } from '@/service/annotation'
|
import { addAnnotation, delAnnotation, fetchAnnotationConfig as doFetchAnnotationConfig, editAnnotation, fetchAnnotationList, queryAnnotationJobStatus, updateAnnotationScore, updateAnnotationStatus } from '@/service/annotation'
|
||||||
import Loading from '@/app/components/base/loading'
|
import Loading from '@/app/components/base/loading'
|
||||||
import { APP_PAGE_LIMIT } from '@/config'
|
import { APP_PAGE_LIMIT } from '@/config'
|
||||||
import ConfigParamModal from '@/app/components/app/configuration/toolbox/annotation/config-param-modal'
|
import ConfigParamModal from '@/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal'
|
||||||
import type { AnnotationReplyConfig } from '@/models/debug'
|
import type { AnnotationReplyConfig } from '@/models/debug'
|
||||||
import { sleep } from '@/utils'
|
import { sleep } from '@/utils'
|
||||||
import { useProviderContext } from '@/context/provider-context'
|
import { useProviderContext } from '@/context/provider-context'
|
||||||
|
@ -1,25 +1,86 @@
|
|||||||
import React, { useCallback } from 'react'
|
import React, { useCallback, useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import produce from 'immer'
|
||||||
import type { AppPublisherProps } from '@/app/components/app/app-publisher'
|
import type { AppPublisherProps } from '@/app/components/app/app-publisher'
|
||||||
|
import Confirm from '@/app/components/base/confirm'
|
||||||
import AppPublisher from '@/app/components/app/app-publisher'
|
import AppPublisher from '@/app/components/app/app-publisher'
|
||||||
import { useFeatures } from '@/app/components/base/features/hooks'
|
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
|
||||||
import type { ModelAndParameter } from '@/app/components/app/configuration/debug/types'
|
import type { ModelAndParameter } from '@/app/components/app/configuration/debug/types'
|
||||||
|
import type { FileUpload } from '@/app/components/base/features/types'
|
||||||
|
import { Resolution } from '@/types/app'
|
||||||
|
import { FILE_EXTS } from '@/app/components/base/prompt-editor/constants'
|
||||||
|
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
type Props = Omit<AppPublisherProps, 'onPublish'> & {
|
type Props = Omit<AppPublisherProps, 'onPublish'> & {
|
||||||
onPublish?: (modelAndParameter?: ModelAndParameter, features?: any) => Promise<any> | any
|
onPublish?: (modelAndParameter?: ModelAndParameter, features?: any) => Promise<any> | any
|
||||||
|
publishedConfig?: any
|
||||||
|
resetAppConfig?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const FeaturesWrappedAppPublisher = (props: Props) => {
|
const FeaturesWrappedAppPublisher = (props: Props) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
const features = useFeatures(s => s.features)
|
const features = useFeatures(s => s.features)
|
||||||
|
const featuresStore = useFeaturesStore()
|
||||||
|
const [restoreConfirmOpen, setRestoreConfirmOpen] = useState(false)
|
||||||
|
const handleConfirm = useCallback(() => {
|
||||||
|
console.log('resetAppConfig')
|
||||||
|
props.resetAppConfig?.()
|
||||||
|
const {
|
||||||
|
features,
|
||||||
|
setFeatures,
|
||||||
|
} = featuresStore!.getState()
|
||||||
|
const newFeatures = produce(features, (draft) => {
|
||||||
|
draft.moreLikeThis = props.publishedConfig.modelConfig.more_like_this || { enabled: false }
|
||||||
|
draft.opening = {
|
||||||
|
enabled: !!props.publishedConfig.modelConfig.opening_statement,
|
||||||
|
opening_statement: props.publishedConfig.modelConfig.opening_statement || '',
|
||||||
|
suggested_questions: props.publishedConfig.modelConfig.suggested_questions || [],
|
||||||
|
}
|
||||||
|
draft.moderation = props.publishedConfig.modelConfig.sensitive_word_avoidance || { enabled: false }
|
||||||
|
draft.speech2text = props.publishedConfig.modelConfig.speech_to_text || { enabled: false }
|
||||||
|
draft.text2speech = props.publishedConfig.modelConfig.text_to_speech || { enabled: false }
|
||||||
|
draft.suggested = props.publishedConfig.modelConfig.suggested_questions_after_answer || { enabled: false }
|
||||||
|
draft.citation = props.publishedConfig.modelConfig.retriever_resource || { enabled: false }
|
||||||
|
draft.annotationReply = props.publishedConfig.modelConfig.annotation_reply || { enabled: false }
|
||||||
|
draft.file = {
|
||||||
|
image: {
|
||||||
|
detail: props.publishedConfig.modelConfig.file_upload?.image?.detail || Resolution.high,
|
||||||
|
enabled: !!props.publishedConfig.modelConfig.file_upload?.image?.enabled,
|
||||||
|
number_limits: props.publishedConfig.modelConfig.file_upload?.image?.number_limits || 3,
|
||||||
|
transfer_methods: props.publishedConfig.modelConfig.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
||||||
|
},
|
||||||
|
enabled: !!(props.publishedConfig.modelConfig.file_upload?.enabled || props.publishedConfig.modelConfig.file_upload?.image?.enabled),
|
||||||
|
allowed_file_types: props.publishedConfig.modelConfig.file_upload?.allowed_file_types || [SupportUploadFileTypes.image],
|
||||||
|
allowed_file_extensions: props.publishedConfig.modelConfig.file_upload?.allowed_file_extensions || FILE_EXTS[SupportUploadFileTypes.image].map(ext => `.${ext}`),
|
||||||
|
allowed_file_upload_methods: props.publishedConfig.modelConfig.file_upload?.allowed_file_upload_methods || props.publishedConfig.modelConfig.file_upload?.image?.transfer_methods || ['local_file', 'remote_url'],
|
||||||
|
number_limits: props.publishedConfig.modelConfig.file_upload?.number_limits || props.publishedConfig.modelConfig.file_upload?.image?.number_limits || 3,
|
||||||
|
} as FileUpload
|
||||||
|
})
|
||||||
|
setFeatures(newFeatures)
|
||||||
|
setRestoreConfirmOpen(false)
|
||||||
|
}, [featuresStore, props])
|
||||||
|
|
||||||
const handlePublish = useCallback((modelAndParameter?: ModelAndParameter) => {
|
const handlePublish = useCallback((modelAndParameter?: ModelAndParameter) => {
|
||||||
return props.onPublish?.(modelAndParameter, features)
|
return props.onPublish?.(modelAndParameter, features)
|
||||||
}, [features, props])
|
}, [features, props])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppPublisher {...{
|
<>
|
||||||
...props,
|
<AppPublisher {...{
|
||||||
onPublish: handlePublish,
|
...props,
|
||||||
}}/>
|
onPublish: handlePublish,
|
||||||
|
onRestore: () => setRestoreConfirmOpen(true),
|
||||||
|
}}/>
|
||||||
|
{restoreConfirmOpen && (
|
||||||
|
<Confirm
|
||||||
|
title={t('appDebug.resetConfig.title')}
|
||||||
|
content={t('appDebug.resetConfig.message')}
|
||||||
|
isShow={restoreConfirmOpen}
|
||||||
|
onConfirm={handleConfirm}
|
||||||
|
onCancel={() => setRestoreConfirmOpen(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import { useFormattingChangedDispatcher } from '../debug/hooks'
|
|||||||
import DatasetConfig from '../dataset-config'
|
import DatasetConfig from '../dataset-config'
|
||||||
import HistoryPanel from '../config-prompt/conversation-histroy/history-panel'
|
import HistoryPanel from '../config-prompt/conversation-histroy/history-panel'
|
||||||
import ConfigVision from '../config-vision'
|
import ConfigVision from '../config-vision'
|
||||||
import useAnnotationConfig from '../toolbox/annotation/use-annotation-config'
|
|
||||||
import AgentTools from './agent/agent-tools'
|
import AgentTools from './agent/agent-tools'
|
||||||
import ConfigContext from '@/context/debug-configuration'
|
import ConfigContext from '@/context/debug-configuration'
|
||||||
import ConfigPrompt from '@/app/components/app/configuration/config-prompt'
|
import ConfigPrompt from '@/app/components/app/configuration/config-prompt'
|
||||||
@ -15,25 +14,18 @@ import ConfigVar from '@/app/components/app/configuration/config-var'
|
|||||||
import { type ModelConfig, type PromptVariable } from '@/models/debug'
|
import { type ModelConfig, type PromptVariable } from '@/models/debug'
|
||||||
import type { AppType } from '@/types/app'
|
import type { AppType } from '@/types/app'
|
||||||
import { ModelModeType } from '@/types/app'
|
import { ModelModeType } from '@/types/app'
|
||||||
import ConfigParamModal from '@/app/components/app/configuration/toolbox/annotation/config-param-modal'
|
|
||||||
import AnnotationFullModal from '@/app/components/billing/annotation-full/modal'
|
|
||||||
|
|
||||||
const Config: FC = () => {
|
const Config: FC = () => {
|
||||||
const {
|
const {
|
||||||
appId,
|
|
||||||
mode,
|
mode,
|
||||||
isAdvancedMode,
|
isAdvancedMode,
|
||||||
modelModeType,
|
modelModeType,
|
||||||
isAgent,
|
isAgent,
|
||||||
// canReturnToSimpleMode,
|
|
||||||
// setPromptMode,
|
|
||||||
hasSetBlockStatus,
|
hasSetBlockStatus,
|
||||||
showHistoryModal,
|
showHistoryModal,
|
||||||
modelConfig,
|
modelConfig,
|
||||||
setModelConfig,
|
setModelConfig,
|
||||||
setPrevPromptConfig,
|
setPrevPromptConfig,
|
||||||
annotationConfig,
|
|
||||||
setAnnotationConfig,
|
|
||||||
} = useContext(ConfigContext)
|
} = useContext(ConfigContext)
|
||||||
const isChatApp = ['advanced-chat', 'agent-chat', 'chat'].includes(mode)
|
const isChatApp = ['advanced-chat', 'agent-chat', 'chat'].includes(mode)
|
||||||
const formattingChangedDispatcher = useFormattingChangedDispatcher()
|
const formattingChangedDispatcher = useFormattingChangedDispatcher()
|
||||||
@ -61,20 +53,6 @@ const Config: FC = () => {
|
|||||||
setModelConfig(newModelConfig)
|
setModelConfig(newModelConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
|
||||||
handleEnableAnnotation,
|
|
||||||
// setScore,
|
|
||||||
// handleDisableAnnotation,
|
|
||||||
isShowAnnotationConfigInit,
|
|
||||||
setIsShowAnnotationConfigInit,
|
|
||||||
isShowAnnotationFullModal,
|
|
||||||
setIsShowAnnotationFullModal,
|
|
||||||
} = useAnnotationConfig({
|
|
||||||
appId,
|
|
||||||
annotationConfig,
|
|
||||||
setAnnotationConfig,
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@ -111,27 +89,6 @@ const Config: FC = () => {
|
|||||||
onShowEditModal={showHistoryModal}
|
onShowEditModal={showHistoryModal}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ConfigParamModal
|
|
||||||
appId={appId}
|
|
||||||
isInit
|
|
||||||
isShow={isShowAnnotationConfigInit}
|
|
||||||
onHide={() => {
|
|
||||||
setIsShowAnnotationConfigInit(false)
|
|
||||||
// showChooseFeatureTrue()
|
|
||||||
}}
|
|
||||||
onSave={async (embeddingModel, score) => {
|
|
||||||
await handleEnableAnnotation(embeddingModel, score)
|
|
||||||
setIsShowAnnotationConfigInit(false)
|
|
||||||
}}
|
|
||||||
annotationConfig={annotationConfig}
|
|
||||||
/>
|
|
||||||
{isShowAnnotationFullModal && (
|
|
||||||
<AnnotationFullModal
|
|
||||||
show={isShowAnnotationFullModal}
|
|
||||||
onHide={() => setIsShowAnnotationFullModal(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
@ -58,7 +58,7 @@ const ChatItem: FC<ChatItemProps> = ({
|
|||||||
file_upload: features.file,
|
file_upload: features.file,
|
||||||
suggested_questions_after_answer: features.suggested,
|
suggested_questions_after_answer: features.suggested,
|
||||||
retriever_resource: features.citation,
|
retriever_resource: features.citation,
|
||||||
// ##TODO## annotation_reply
|
annotation_reply: features.annotationReply,
|
||||||
} as ChatConfig
|
} as ChatConfig
|
||||||
}, [configTemplate, features])
|
}, [configTemplate, features])
|
||||||
const {
|
const {
|
||||||
|
@ -58,7 +58,7 @@ const DebugWithSingleModel = forwardRef<DebugWithSingleModelRefType, DebugWithSi
|
|||||||
file_upload: features.file,
|
file_upload: features.file,
|
||||||
suggested_questions_after_answer: features.suggested,
|
suggested_questions_after_answer: features.suggested,
|
||||||
retriever_resource: features.citation,
|
retriever_resource: features.citation,
|
||||||
// ##TODO## annotation_reply
|
annotation_reply: features.annotationReply,
|
||||||
} as ChatConfig
|
} as ChatConfig
|
||||||
}, [configTemplate, features])
|
}, [configTemplate, features])
|
||||||
const {
|
const {
|
||||||
|
@ -284,7 +284,7 @@ const Configuration: FC = () => {
|
|||||||
setModelConfig(_publishedConfig.modelConfig)
|
setModelConfig(_publishedConfig.modelConfig)
|
||||||
setCompletionParams(_publishedConfig.completionParams)
|
setCompletionParams(_publishedConfig.completionParams)
|
||||||
setDataSets(modelConfig.dataSets || [])
|
setDataSets(modelConfig.dataSets || [])
|
||||||
// feature
|
// reset feature
|
||||||
setIntroduction(modelConfig.opening_statement!)
|
setIntroduction(modelConfig.opening_statement!)
|
||||||
setMoreLikeThisConfig(modelConfig.more_like_this || {
|
setMoreLikeThisConfig(modelConfig.more_like_this || {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
@ -446,6 +446,7 @@ const Configuration: FC = () => {
|
|||||||
text2speech: modelConfig.text_to_speech || { enabled: false },
|
text2speech: modelConfig.text_to_speech || { enabled: false },
|
||||||
file: {
|
file: {
|
||||||
image: {
|
image: {
|
||||||
|
detail: modelConfig.file_upload?.image?.detail || Resolution.high,
|
||||||
enabled: !!modelConfig.file_upload?.image?.enabled,
|
enabled: !!modelConfig.file_upload?.image?.enabled,
|
||||||
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'],
|
||||||
@ -741,12 +742,6 @@ const Configuration: FC = () => {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
const [restoreConfirmOpen, setRestoreConfirmOpen] = useState(false)
|
|
||||||
const resetAppConfig = () => {
|
|
||||||
syncToPublishedConfig(publishedConfig!)
|
|
||||||
setRestoreConfirmOpen(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
const [showUseGPT4Confirm, setShowUseGPT4Confirm] = useState(false)
|
const [showUseGPT4Confirm, setShowUseGPT4Confirm] = useState(false)
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -907,7 +902,8 @@ const Configuration: FC = () => {
|
|||||||
debugWithMultipleModel,
|
debugWithMultipleModel,
|
||||||
multipleModelConfigs,
|
multipleModelConfigs,
|
||||||
onPublish,
|
onPublish,
|
||||||
onRestore: () => setRestoreConfirmOpen(true),
|
publishedConfig: publishedConfig!,
|
||||||
|
resetAppConfig: () => syncToPublishedConfig(publishedConfig!),
|
||||||
}} />
|
}} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -933,15 +929,6 @@ const Configuration: FC = () => {
|
|||||||
</div>}
|
</div>}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{restoreConfirmOpen && (
|
|
||||||
<Confirm
|
|
||||||
title={t('appDebug.resetConfig.title')}
|
|
||||||
content={t('appDebug.resetConfig.message')}
|
|
||||||
isShow={restoreConfirmOpen}
|
|
||||||
onConfirm={resetAppConfig}
|
|
||||||
onCancel={() => setRestoreConfirmOpen(false)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{showUseGPT4Confirm && (
|
{showUseGPT4Confirm && (
|
||||||
<Confirm
|
<Confirm
|
||||||
title={t('appDebug.trailUseGPT4Info.title')}
|
title={t('appDebug.trailUseGPT4Info.title')}
|
||||||
|
@ -8,7 +8,7 @@ import Log from '@/app/components/app/log'
|
|||||||
import WorkflowLog from '@/app/components/app/workflow-log'
|
import WorkflowLog from '@/app/components/app/workflow-log'
|
||||||
import Annotation from '@/app/components/app/annotation'
|
import Annotation from '@/app/components/app/annotation'
|
||||||
import Loading from '@/app/components/base/loading'
|
import Loading from '@/app/components/base/loading'
|
||||||
import { PageType } from '@/app/components/app/configuration/toolbox/annotation/type'
|
import { PageType } from '@/app/components/base/features/new-feature-panel/annotation-reply/type'
|
||||||
import TabSlider from '@/app/components/base/tab-slider-plain'
|
import TabSlider from '@/app/components/base/tab-slider-plain'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import { Bookmark } from '@/app/components/base/icons/src/vender/line/general'
|
|||||||
import { Stars02 } from '@/app/components/base/icons/src/vender/line/weather'
|
import { Stars02 } from '@/app/components/base/icons/src/vender/line/weather'
|
||||||
import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'
|
import { RefreshCcw01 } from '@/app/components/base/icons/src/vender/line/arrows'
|
||||||
import { fetchTextGenerationMessge } from '@/service/debug'
|
import { fetchTextGenerationMessge } from '@/service/debug'
|
||||||
import AnnotationCtrlBtn from '@/app/components/app/configuration/toolbox/annotation/annotation-ctrl-btn'
|
import AnnotationCtrlBtn from '@/app/components/base/features/new-feature-panel/annotation-reply/annotation-ctrl-btn'
|
||||||
import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal'
|
import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal'
|
||||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||||
import WorkflowProcessItem from '@/app/components/base/chat/chat/answer/workflow-process'
|
import WorkflowProcessItem from '@/app/components/base/chat/chat/answer/workflow-process'
|
||||||
|
@ -11,7 +11,7 @@ import cn from '@/utils/classnames'
|
|||||||
import CopyBtn from '@/app/components/base/copy-btn'
|
import CopyBtn from '@/app/components/base/copy-btn'
|
||||||
import { MessageFast } from '@/app/components/base/icons/src/vender/solid/communication'
|
import { MessageFast } from '@/app/components/base/icons/src/vender/solid/communication'
|
||||||
import AudioBtn from '@/app/components/base/audio-btn'
|
import AudioBtn from '@/app/components/base/audio-btn'
|
||||||
import AnnotationCtrlBtn from '@/app/components/app/configuration/toolbox/annotation/annotation-ctrl-btn'
|
import AnnotationCtrlBtn from '@/app/components/base/features/new-feature-panel/annotation-reply/annotation-ctrl-btn'
|
||||||
import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal'
|
import EditReplyModal from '@/app/components/app/annotation/edit-annotation-modal'
|
||||||
import {
|
import {
|
||||||
ThumbsDown,
|
ThumbsDown,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React, { useState } from 'react'
|
import React, { useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import ScoreSlider from '../score-slider'
|
import ScoreSlider from './score-slider'
|
||||||
import { Item } from './config-param'
|
import { Item } from './config-param'
|
||||||
import Modal from '@/app/components/base/modal'
|
import Modal from '@/app/components/base/modal'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
@ -0,0 +1,152 @@
|
|||||||
|
import React, { useCallback, useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { usePathname, useRouter } from 'next/navigation'
|
||||||
|
import produce from 'immer'
|
||||||
|
import { RiEqualizer2Line, RiExternalLinkLine } from '@remixicon/react'
|
||||||
|
import { MessageFast } from '@/app/components/base/icons/src/vender/features'
|
||||||
|
import FeatureCard from '@/app/components/base/features/new-feature-panel/feature-card'
|
||||||
|
import Button from '@/app/components/base/button'
|
||||||
|
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
|
||||||
|
import type { OnFeaturesChange } from '@/app/components/base/features/types'
|
||||||
|
import useAnnotationConfig from '@/app/components/base/features/new-feature-panel/annotation-reply/use-annotation-config'
|
||||||
|
import ConfigParamModal from '@/app/components/base/features/new-feature-panel/annotation-reply/config-param-modal'
|
||||||
|
import AnnotationFullModal from '@/app/components/billing/annotation-full/modal'
|
||||||
|
import { ANNOTATION_DEFAULT } from '@/config'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
disabled?: boolean
|
||||||
|
onChange?: OnFeaturesChange
|
||||||
|
}
|
||||||
|
|
||||||
|
const AnnotationReply = ({
|
||||||
|
disabled,
|
||||||
|
onChange,
|
||||||
|
}: Props) => {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const router = useRouter()
|
||||||
|
const pathname = usePathname()
|
||||||
|
const matched = pathname.match(/\/app\/([^/]+)/)
|
||||||
|
const appId = (matched?.length && matched[1]) ? matched[1] : ''
|
||||||
|
const featuresStore = useFeaturesStore()
|
||||||
|
const annotationReply = useFeatures(s => s.features.annotationReply)
|
||||||
|
|
||||||
|
const updateAnnotationReply = useCallback((newConfig: any) => {
|
||||||
|
const {
|
||||||
|
features,
|
||||||
|
setFeatures,
|
||||||
|
} = featuresStore!.getState()
|
||||||
|
const newFeatures = produce(features, (draft) => {
|
||||||
|
draft.annotationReply = newConfig
|
||||||
|
})
|
||||||
|
setFeatures(newFeatures)
|
||||||
|
if (onChange)
|
||||||
|
onChange(newFeatures)
|
||||||
|
}, [featuresStore, onChange])
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleEnableAnnotation,
|
||||||
|
handleDisableAnnotation,
|
||||||
|
isShowAnnotationConfigInit,
|
||||||
|
setIsShowAnnotationConfigInit,
|
||||||
|
isShowAnnotationFullModal,
|
||||||
|
setIsShowAnnotationFullModal,
|
||||||
|
} = useAnnotationConfig({
|
||||||
|
appId,
|
||||||
|
annotationConfig: annotationReply as any || {
|
||||||
|
id: '',
|
||||||
|
enabled: false,
|
||||||
|
score_threshold: ANNOTATION_DEFAULT.score_threshold,
|
||||||
|
embedding_model: {
|
||||||
|
embedding_provider_name: '',
|
||||||
|
embedding_model_name: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
setAnnotationConfig: updateAnnotationReply,
|
||||||
|
})
|
||||||
|
|
||||||
|
const handleSwitch = useCallback((enabled: boolean) => {
|
||||||
|
if (enabled)
|
||||||
|
setIsShowAnnotationConfigInit(true)
|
||||||
|
else
|
||||||
|
handleDisableAnnotation(annotationReply?.embedding_model as any)
|
||||||
|
}, [annotationReply?.embedding_model, handleDisableAnnotation, setIsShowAnnotationConfigInit])
|
||||||
|
|
||||||
|
const [isHovering, setIsHovering] = useState(false)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<FeatureCard
|
||||||
|
icon={
|
||||||
|
<div className='shrink-0 p-1 rounded-lg border-[0.5px] border-divider-subtle shadow-xs bg-util-colors-indigo-indigo-600'>
|
||||||
|
<MessageFast className='w-4 h-4 text-text-primary-on-surface' />
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
title={t('appDebug.feature.annotation.title')}
|
||||||
|
value={!!annotationReply?.enabled}
|
||||||
|
onChange={state => handleSwitch(state)}
|
||||||
|
onMouseEnter={() => setIsHovering(true)}
|
||||||
|
onMouseLeave={() => setIsHovering(false)}
|
||||||
|
disabled={disabled}
|
||||||
|
>
|
||||||
|
<>
|
||||||
|
{!annotationReply?.enabled && (
|
||||||
|
<div className='min-h-8 text-text-tertiary system-xs-regular line-clamp-2'>{t('appDebug.feature.annotation.description')}</div>
|
||||||
|
)}
|
||||||
|
{!!annotationReply?.enabled && (
|
||||||
|
<>
|
||||||
|
{!isHovering && (
|
||||||
|
<div className='pt-0.5 flex items-center gap-4'>
|
||||||
|
<div className=''>
|
||||||
|
<div className='mb-0.5 text-text-tertiary system-2xs-medium-uppercase'>{t('appDebug.feature.annotation.scoreThreshold.title')}</div>
|
||||||
|
<div className='text-text-secondary system-xs-regular'>{annotationReply.score_threshold || '-'}</div>
|
||||||
|
</div>
|
||||||
|
<div className='w-px h-[27px] bg-divider-subtle rotate-12'></div>
|
||||||
|
<div className=''>
|
||||||
|
<div className='mb-0.5 text-text-tertiary system-2xs-medium-uppercase'>{t('common.modelProvider.embeddingModel.key')}</div>
|
||||||
|
<div className='text-text-secondary system-xs-regular'>{annotationReply.embedding_model?.embedding_model_name}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{isHovering && (
|
||||||
|
<div className='flex items-center justify-between'>
|
||||||
|
<Button className='w-[178px]' onClick={() => setIsShowAnnotationConfigInit(true)} disabled={disabled}>
|
||||||
|
<RiEqualizer2Line className='mr-1 w-4 h-4' />
|
||||||
|
{t('common.operation.params')}
|
||||||
|
</Button>
|
||||||
|
<Button className='w-[178px]' onClick={() => {
|
||||||
|
router.push(`/app/${appId}/annotations`)
|
||||||
|
}}>
|
||||||
|
<RiExternalLinkLine className='mr-1 w-4 h-4' />
|
||||||
|
{t('appDebug.feature.annotation.cacheManagement')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
</FeatureCard>
|
||||||
|
<ConfigParamModal
|
||||||
|
appId={appId}
|
||||||
|
isInit
|
||||||
|
isShow={isShowAnnotationConfigInit}
|
||||||
|
onHide={() => {
|
||||||
|
setIsShowAnnotationConfigInit(false)
|
||||||
|
// showChooseFeatureTrue()
|
||||||
|
}}
|
||||||
|
onSave={async (embeddingModel, score) => {
|
||||||
|
await handleEnableAnnotation(embeddingModel, score)
|
||||||
|
setIsShowAnnotationConfigInit(false)
|
||||||
|
}}
|
||||||
|
annotationConfig={annotationReply as any}
|
||||||
|
/>
|
||||||
|
{isShowAnnotationFullModal && (
|
||||||
|
<AnnotationFullModal
|
||||||
|
show={isShowAnnotationFullModal}
|
||||||
|
onHide={() => setIsShowAnnotationFullModal(false)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default AnnotationReply
|
@ -2,7 +2,7 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import Slider from '@/app/components/app/configuration/toolbox/score-slider/base-slider'
|
import Slider from '@/app/components/base/features/new-feature-panel/annotation-reply/score-slider/base-slider'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
className?: string
|
className?: string
|
@ -1,7 +1,7 @@
|
|||||||
import React, { useMemo, useState } from 'react'
|
import React, { useMemo, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { RiApps2AddLine, RiArrowRightLine, RiSparklingFill } from '@remixicon/react'
|
import { RiApps2AddLine, RiArrowRightLine, RiSparklingFill } from '@remixicon/react'
|
||||||
import { Citations, ContentModeration, FolderUpload, LoveMessage, Microphone01, TextToAudio, VirtualAssistant } from '@/app/components/base/icons/src/vender/features'
|
import { Citations, ContentModeration, FolderUpload, LoveMessage, MessageFast, Microphone01, TextToAudio, VirtualAssistant } from '@/app/components/base/icons/src/vender/features'
|
||||||
import Button from '@/app/components/base/button'
|
import Button from '@/app/components/base/button'
|
||||||
import Tooltip from '@/app/components/base/tooltip'
|
import Tooltip from '@/app/components/base/tooltip'
|
||||||
import VoiceSettings from '@/app/components/base/features/new-feature-panel/text-to-speech/voice-settings'
|
import VoiceSettings from '@/app/components/base/features/new-feature-panel/text-to-speech/voice-settings'
|
||||||
@ -118,7 +118,15 @@ const FeatureBar = ({
|
|||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
{/* ##TODO## annotation_reply */}
|
{isChatMode && !!features.annotationReply?.enabled && (
|
||||||
|
<Tooltip
|
||||||
|
popupContent={t('appDebug.feature.annotation.title')}
|
||||||
|
>
|
||||||
|
<div className='shrink-0 p-1 rounded-lg border-[0.5px] border-divider-subtle shadow-xs bg-util-colors-indigo-indigo-600'>
|
||||||
|
<MessageFast className='w-3.5 h-3.5 text-text-primary-on-surface' />
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className='grow text-text-tertiary body-xs-regular'>{t('appDebug.feature.bar.enableText')}</div>
|
<div className='grow text-text-tertiary body-xs-regular'>{t('appDebug.feature.bar.enableText')}</div>
|
||||||
<Button className='shrink-0' variant='ghost-accent' size='small' onClick={() => onFeatureBarClick?.(true)}>
|
<Button className='shrink-0' variant='ghost-accent' size='small' onClick={() => onFeatureBarClick?.(true)}>
|
||||||
|
@ -1,21 +1,10 @@
|
|||||||
import React, { useCallback } from 'react'
|
import React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { usePathname, useRouter } from 'next/navigation'
|
import { RiCloseLine } from '@remixicon/react'
|
||||||
import produce from 'immer'
|
|
||||||
import {
|
|
||||||
RiCloseLine,
|
|
||||||
RiEqualizer2Line,
|
|
||||||
RiExternalLinkLine,
|
|
||||||
} from '@remixicon/react'
|
|
||||||
import { MessageFast } from '@/app/components/base/icons/src/vender/features'
|
|
||||||
import DialogWrapper from '@/app/components/base/features/new-feature-panel/dialog-wrapper'
|
import DialogWrapper from '@/app/components/base/features/new-feature-panel/dialog-wrapper'
|
||||||
import { useFeatures, useFeaturesStore } from '@/app/components/base/features/hooks'
|
|
||||||
import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
import { useDefaultModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||||
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||||
import type { OnFeaturesChange } from '@/app/components/base/features/types'
|
import type { OnFeaturesChange } from '@/app/components/base/features/types'
|
||||||
import { FeatureEnum } from '@/app/components/base/features/types'
|
|
||||||
import Switch from '@/app/components/base/switch'
|
|
||||||
import Button from '@/app/components/base/button'
|
|
||||||
|
|
||||||
import MoreLikeThis from '@/app/components/base/features/new-feature-panel/more-like-this'
|
import MoreLikeThis from '@/app/components/base/features/new-feature-panel/more-like-this'
|
||||||
import ConversationOpener from '@/app/components/base/features/new-feature-panel/conversation-opener'
|
import ConversationOpener from '@/app/components/base/features/new-feature-panel/conversation-opener'
|
||||||
@ -25,11 +14,11 @@ import TextToSpeech from '@/app/components/base/features/new-feature-panel/text-
|
|||||||
import FileUpload from '@/app/components/base/features/new-feature-panel/file-upload'
|
import FileUpload from '@/app/components/base/features/new-feature-panel/file-upload'
|
||||||
import FollowUp from '@/app/components/base/features/new-feature-panel/follow-up'
|
import FollowUp from '@/app/components/base/features/new-feature-panel/follow-up'
|
||||||
import Citation from '@/app/components/base/features/new-feature-panel/citation'
|
import Citation from '@/app/components/base/features/new-feature-panel/citation'
|
||||||
|
import AnnotationReply from '@/app/components/base/features/new-feature-panel/annotation-reply'
|
||||||
import type { PromptVariable } from '@/models/debug'
|
import type { PromptVariable } from '@/models/debug'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
show: boolean
|
show: boolean
|
||||||
showAnnotation?: boolean
|
|
||||||
isChatMode: boolean
|
isChatMode: boolean
|
||||||
disabled: boolean
|
disabled: boolean
|
||||||
onChange?: OnFeaturesChange
|
onChange?: OnFeaturesChange
|
||||||
@ -41,7 +30,6 @@ type Props = {
|
|||||||
|
|
||||||
const NewFeaturePanel = ({
|
const NewFeaturePanel = ({
|
||||||
show,
|
show,
|
||||||
showAnnotation = false,
|
|
||||||
isChatMode,
|
isChatMode,
|
||||||
disabled,
|
disabled,
|
||||||
onChange,
|
onChange,
|
||||||
@ -51,31 +39,8 @@ const NewFeaturePanel = ({
|
|||||||
onAutoAddPromptVariable,
|
onAutoAddPromptVariable,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const router = useRouter()
|
|
||||||
const pathname = usePathname()
|
|
||||||
const matched = pathname.match(/\/app\/([^/]+)/)
|
|
||||||
const appId = (matched?.length && matched[1]) ? matched[1] : ''
|
|
||||||
const { data: speech2textDefaultModel } = useDefaultModel(ModelTypeEnum.speech2text)
|
const { data: speech2textDefaultModel } = useDefaultModel(ModelTypeEnum.speech2text)
|
||||||
const { data: text2speechDefaultModel } = useDefaultModel(ModelTypeEnum.tts)
|
const { data: text2speechDefaultModel } = useDefaultModel(ModelTypeEnum.tts)
|
||||||
const features = useFeatures(s => s.features)
|
|
||||||
const featuresStore = useFeaturesStore()
|
|
||||||
|
|
||||||
const handleChange = useCallback((type: FeatureEnum, enabled: boolean) => {
|
|
||||||
const {
|
|
||||||
features,
|
|
||||||
setFeatures,
|
|
||||||
} = featuresStore!.getState()
|
|
||||||
|
|
||||||
const newFeatures = produce(features, (draft) => {
|
|
||||||
draft[type] = {
|
|
||||||
...draft[type],
|
|
||||||
enabled,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
setFeatures(newFeatures)
|
|
||||||
if (onChange)
|
|
||||||
onChange(newFeatures)
|
|
||||||
}, [featuresStore, onChange])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DialogWrapper
|
<DialogWrapper
|
||||||
@ -119,43 +84,8 @@ const NewFeaturePanel = ({
|
|||||||
{isChatMode && (
|
{isChatMode && (
|
||||||
<Citation disabled={disabled} onChange={onChange} />
|
<Citation disabled={disabled} onChange={onChange} />
|
||||||
)}
|
)}
|
||||||
{/* ##TODO## annotation_reply */}
|
{!inWorkflow && isChatMode && (
|
||||||
{showAnnotation && (
|
<AnnotationReply disabled={disabled} onChange={onChange} />
|
||||||
<div className='group mb-1 p-3 border-t-[0.5px] border-l-[0.5px] border-effects-highlight rounded-xl bg-background-section-burn'>
|
|
||||||
<div className='mb-2 flex items-center gap-2'>
|
|
||||||
<div className='shrink-0 p-1 rounded-lg border-[0.5px] border-divider-subtle shadow-xs bg-util-colors-indigo-indigo-600'>
|
|
||||||
<MessageFast className='w-4 h-4 text-text-primary-on-surface' />
|
|
||||||
</div>
|
|
||||||
<div className='grow flex items-center text-text-secondary system-sm-semibold'>
|
|
||||||
{t('appDebug.feature.annotation.title')}
|
|
||||||
</div>
|
|
||||||
<Switch className='shrink-0' onChange={value => handleChange(FeatureEnum.text2speech, value)} defaultValue={!!features.text2speech?.enabled} />
|
|
||||||
</div>
|
|
||||||
<div className='min-h-8 text-text-tertiary system-xs-regular line-clamp-2'>{t('appDebug.feature.annotation.description')}</div>
|
|
||||||
<div className='group-hover:hidden pt-0.5 flex items-center gap-4'>
|
|
||||||
<div className=''>
|
|
||||||
<div className='mb-0.5 text-text-tertiary system-2xs-medium-uppercase'>{t('appDebug.feature.annotation.scoreThreshold.title')}</div>
|
|
||||||
{/* <div className='text-text-secondary system-xs-regular'>{languageInfo?.name || '-'}</div> */}
|
|
||||||
</div>
|
|
||||||
<div className='w-px h-[27px] bg-divider-subtle rotate-12'></div>
|
|
||||||
<div className=''>
|
|
||||||
<div className='mb-0.5 text-text-tertiary system-2xs-medium-uppercase'>{t('common.modelProvider.embeddingModel.key')}</div>
|
|
||||||
{/* <div className='text-text-secondary system-xs-regular'>{features.text2speech?.voice || '-'}</div> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className='hidden group-hover:flex items-center justify-between'>
|
|
||||||
<Button className='w-[178px]'>
|
|
||||||
<RiEqualizer2Line className='mr-1 w-4 h-4' />
|
|
||||||
{t('common.operation.params')}
|
|
||||||
</Button>
|
|
||||||
<Button className='w-[178px]' onClick={() => {
|
|
||||||
router.push(`/app/${appId}/annotations`)
|
|
||||||
}}>
|
|
||||||
<RiExternalLinkLine className='mr-1 w-4 h-4' />
|
|
||||||
{t('appDebug.feature.annotation.cacheManagement')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -46,6 +46,7 @@ export const createFeaturesStore = (initProps?: Partial<FeaturesState>) => {
|
|||||||
file: {
|
file: {
|
||||||
image: {
|
image: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
|
detail: 'high',
|
||||||
number_limits: 3,
|
number_limits: 3,
|
||||||
transfer_methods: [TransferMethod.local_file, TransferMethod.remote_url],
|
transfer_methods: [TransferMethod.local_file, TransferMethod.remote_url],
|
||||||
},
|
},
|
||||||
|
@ -30,6 +30,7 @@ export type SensitiveWordAvoidance = EnabledOrDisabled & {
|
|||||||
|
|
||||||
export type FileUpload = {
|
export type FileUpload = {
|
||||||
image?: EnabledOrDisabled & {
|
image?: EnabledOrDisabled & {
|
||||||
|
detail?: 'high' | 'low'
|
||||||
number_limits?: number
|
number_limits?: number
|
||||||
transfer_methods?: TransferMethod[]
|
transfer_methods?: TransferMethod[]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user