mirror of https://github.com/langgenius/dify.git
fix
This commit is contained in:
parent
3823ae5890
commit
0469edcc0c
|
|
@ -29,7 +29,7 @@ const FeaturePanel = ({
|
|||
}, [features])
|
||||
|
||||
const showToolFeature = useMemo(() => {
|
||||
return features.moderation.enabled || features.annotation.enabled
|
||||
return features.moderation.enabled
|
||||
}, [features])
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -39,9 +39,6 @@ export const createFeaturesStore = (initProps?: Partial<FeaturesState>) => {
|
|||
moderation: {
|
||||
enabled: false,
|
||||
},
|
||||
annotation: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
return createStore<FeatureStoreState>()(set => ({
|
||||
|
|
|
|||
|
|
@ -23,15 +23,6 @@ export type SensitiveWordAvoidance = EnabledOrDisabled & {
|
|||
config?: any
|
||||
}
|
||||
|
||||
export type AnnotationReply = EnabledOrDisabled & {
|
||||
id?: string
|
||||
score_threshold?: number
|
||||
embedding_model?: {
|
||||
embedding_model_name: string
|
||||
embedding_provider_name: string
|
||||
}
|
||||
}
|
||||
|
||||
export enum FeatureEnum {
|
||||
opening = 'opening',
|
||||
suggested = 'suggested',
|
||||
|
|
@ -39,7 +30,6 @@ export enum FeatureEnum {
|
|||
speech2text = 'speech2text',
|
||||
citation = 'citation',
|
||||
moderation = 'moderation',
|
||||
annotation = 'annotation',
|
||||
}
|
||||
|
||||
export type Features = {
|
||||
|
|
@ -49,7 +39,6 @@ export type Features = {
|
|||
[FeatureEnum.speech2text]: SpeechToText
|
||||
[FeatureEnum.citation]: RetrieverResource
|
||||
[FeatureEnum.moderation]: SensitiveWordAvoidance
|
||||
[FeatureEnum.annotation]: AnnotationReply
|
||||
}
|
||||
|
||||
export type OnFeaturesChange = (features: Features) => void
|
||||
|
|
|
|||
|
|
@ -41,10 +41,6 @@ const Features = () => {
|
|||
openingStatementProps={{
|
||||
onAutoAddPromptVariable: () => {},
|
||||
}}
|
||||
annotationProps={{
|
||||
onEmbeddingChange: () => {},
|
||||
onScoreChange: () => {},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -112,7 +112,6 @@ export const useWorkflow = () => {
|
|||
speech_to_text: features.speech2text,
|
||||
retriever_resource: features.citation,
|
||||
sensitive_word_avoidance: features.moderation,
|
||||
annotation_reply: features.annotation,
|
||||
},
|
||||
},
|
||||
}).then((res) => {
|
||||
|
|
@ -156,7 +155,8 @@ export const useWorkflow = () => {
|
|||
|
||||
const handleSetViewport = useCallback((viewPort: Viewport) => {
|
||||
reactFlow.setViewport(viewPort)
|
||||
}, [reactFlow])
|
||||
handleSyncWorkflowDraft()
|
||||
}, [reactFlow, handleSyncWorkflowDraft])
|
||||
|
||||
const handleNodeDragStart = useCallback<NodeDragHandler>(() => {
|
||||
const {
|
||||
|
|
@ -854,6 +854,7 @@ export const useWorkflow = () => {
|
|||
|
||||
export const useWorkflowRun = () => {
|
||||
const store = useStoreApi()
|
||||
const reactflow = useReactFlow()
|
||||
|
||||
const run = useCallback((params: any, callback?: IOtherOptions) => {
|
||||
const {
|
||||
|
|
@ -890,10 +891,22 @@ export const useWorkflowRun = () => {
|
|||
useStore.setState({ runningStatus: data.status as WorkflowRunningStatus })
|
||||
},
|
||||
onNodeStarted: ({ data }) => {
|
||||
const newNodes = produce(getNodes(), (draft) => {
|
||||
const currentNode = draft.find(node => node.id === data.node_id)!
|
||||
|
||||
currentNode.data._runningStatus = NodeRunningStatus.Running
|
||||
const nodes = getNodes()
|
||||
const {
|
||||
getViewport,
|
||||
setViewport,
|
||||
} = reactflow
|
||||
const viewport = getViewport()
|
||||
const currentNodeIndex = nodes.findIndex(node => node.id === data.node_id)
|
||||
const position = nodes[currentNodeIndex].position
|
||||
const zoom = 1
|
||||
setViewport({
|
||||
zoom,
|
||||
x: 200 / viewport.zoom - position.x,
|
||||
y: 200 / viewport.zoom - position.y,
|
||||
})
|
||||
const newNodes = produce(nodes, (draft) => {
|
||||
draft[currentNodeIndex].data._runningStatus = NodeRunningStatus.Running
|
||||
})
|
||||
setNodes(newNodes)
|
||||
},
|
||||
|
|
@ -908,7 +921,7 @@ export const useWorkflowRun = () => {
|
|||
...callback,
|
||||
},
|
||||
)
|
||||
}, [store])
|
||||
}, [store, reactflow])
|
||||
|
||||
return run
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,6 @@ const WorkflowWrap: FC<WorkflowProps> = ({
|
|||
text2speech: features.text_to_speech || { enabled: false },
|
||||
citation: features.retriever_resource || { enabled: false },
|
||||
moderation: features.sensitive_word_avoidance || { enabled: false },
|
||||
annotation: features.annotation_reply || { enabled: false },
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,12 +1,14 @@
|
|||
import {
|
||||
memo,
|
||||
useCallback,
|
||||
useMemo,
|
||||
} from 'react'
|
||||
import { useStore } from '../../store'
|
||||
import UserInput from './user-input'
|
||||
import { useChat } from './hooks'
|
||||
import Chat from '@/app/components/base/chat/chat'
|
||||
import type { OnSend } from '@/app/components/base/chat/types'
|
||||
import { useFeaturesStore } from '@/app/components/base/features/hooks'
|
||||
|
||||
const ChatWrapper = () => {
|
||||
const {
|
||||
|
|
@ -17,6 +19,20 @@ const ChatWrapper = () => {
|
|||
suggestedQuestions,
|
||||
handleSend,
|
||||
} = useChat()
|
||||
const featuresStore = useFeaturesStore()
|
||||
const features = featuresStore!.getState().features
|
||||
|
||||
const config = useMemo(() => {
|
||||
return {
|
||||
opening_statement: features.opening.opening_statement,
|
||||
suggested_questions: features.opening.suggested_questions,
|
||||
suggested_questions_after_answer: features.suggested,
|
||||
text_to_speech: features.text2speech,
|
||||
speech_to_text: features.speech2text,
|
||||
retriever_resource: features.citation,
|
||||
sensitive_word_avoidance: features.moderation,
|
||||
}
|
||||
}, [features])
|
||||
|
||||
const doSend = useCallback<OnSend>((query, files) => {
|
||||
handleSend({
|
||||
|
|
@ -29,6 +45,7 @@ const ChatWrapper = () => {
|
|||
|
||||
return (
|
||||
<Chat
|
||||
config={config as any}
|
||||
chatList={chatList}
|
||||
isResponding={isResponding}
|
||||
chatContainerclassName='px-4'
|
||||
|
|
|
|||
Loading…
Reference in New Issue