mirror of
https://github.com/langgenius/dify.git
synced 2026-04-24 17:16:37 +08:00
feat: question classify node
This commit is contained in:
parent
f14a5c7346
commit
c441a848e7
@ -6,7 +6,7 @@ import Workflow from '@/app/components/workflow'
|
|||||||
import { BlockEnum } from '@/app/components/workflow/types'
|
import { BlockEnum } from '@/app/components/workflow/types'
|
||||||
const nodes = [
|
const nodes = [
|
||||||
BlockEnum.Start, BlockEnum.DirectAnswer, BlockEnum.LLM, BlockEnum.KnowledgeRetrieval, BlockEnum.QuestionClassifier,
|
BlockEnum.Start, BlockEnum.DirectAnswer, BlockEnum.LLM, BlockEnum.KnowledgeRetrieval, BlockEnum.QuestionClassifier,
|
||||||
BlockEnum.QuestionClassifier, BlockEnum.IfElse, BlockEnum.Code, BlockEnum.TemplateTransform, BlockEnum.HttpRequest,
|
BlockEnum.IfElse, BlockEnum.Code, BlockEnum.TemplateTransform, BlockEnum.HttpRequest,
|
||||||
BlockEnum.Tool,
|
BlockEnum.Tool,
|
||||||
].map((item, i) => ({
|
].map((item, i) => ({
|
||||||
id: `${i + 1}`,
|
id: `${i + 1}`,
|
||||||
@ -45,9 +45,9 @@ const Page: FC = () => {
|
|||||||
edges={initialEdges}
|
edges={initialEdges}
|
||||||
/*
|
/*
|
||||||
* TODO: for debug.
|
* TODO: for debug.
|
||||||
* 2 directAnswer 3: llm
|
* 2 directAnswer 3: llm 5: questionClassifier
|
||||||
*/
|
*/
|
||||||
selectedNodeId='2'
|
selectedNodeId='5'
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@ -0,0 +1,27 @@
|
|||||||
|
'use client'
|
||||||
|
import type { FC } from 'react'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
title: string
|
||||||
|
content: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const InfoPanel: FC<Props> = ({
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className='px-[5px] py-[3px] bg-gray-100 rounded-md'>
|
||||||
|
<div className='leading-4 text-[10px] font-medium text-gray-500 uppercase'>
|
||||||
|
{title}
|
||||||
|
</div>
|
||||||
|
<div className='leading-4 text-xs font-normal text-gray-700'>
|
||||||
|
{content}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
export default React.memo(InfoPanel)
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import InfoPanel from '../_base/components/info-panel'
|
||||||
import { mockData } from './mock'
|
import { mockData } from './mock'
|
||||||
|
|
||||||
const Node: FC = () => {
|
const Node: FC = () => {
|
||||||
@ -7,14 +8,7 @@ const Node: FC = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='px-3'>
|
<div className='px-3'>
|
||||||
<div className='px-[5px] py-[3px] bg-gray-100 rounded-md'>
|
<InfoPanel title={t('workflow.nodes.directAnswer.answer')} content={mockData.answer} />
|
||||||
<div className='leading-4 text-[10px] font-medium text-gray-500 uppercase'>
|
|
||||||
{t('workflow.nodes.directAnswer.answer')}
|
|
||||||
</div>
|
|
||||||
<div className='leading-4 text-xs font-normal text-gray-700'>
|
|
||||||
{mockData.answer}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import ModelSelector from '@/app/components/header/account-setting/model-provide
|
|||||||
const Node: FC = () => {
|
const Node: FC = () => {
|
||||||
const { provider, name: modelId } = mockData.model
|
const { provider, name: modelId } = mockData.model
|
||||||
const {
|
const {
|
||||||
|
|
||||||
textGenerationModelList,
|
textGenerationModelList,
|
||||||
} = useTextGenerationCurrentProviderAndModelAndModelList()
|
} = useTextGenerationCurrentProviderAndModelAndModelList()
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -0,0 +1,37 @@
|
|||||||
|
import { MemoryRole } from '../../types'
|
||||||
|
import type { QuestionClassifierNodeType } from './types'
|
||||||
|
|
||||||
|
export const mockData: QuestionClassifierNodeType = {
|
||||||
|
title: 'Test',
|
||||||
|
desc: 'Test',
|
||||||
|
type: 'Test',
|
||||||
|
query_variable_selector: ['aaa', 'name'],
|
||||||
|
model: {
|
||||||
|
provider: 'openai',
|
||||||
|
name: 'gpt-4',
|
||||||
|
mode: 'chat',
|
||||||
|
completion_params: {
|
||||||
|
temperature: 0.7,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
topics: [
|
||||||
|
{
|
||||||
|
id: '1',
|
||||||
|
name: 'topic 1',
|
||||||
|
topic: 'xxxxx',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
name: 'topic 2',
|
||||||
|
topic: 'xxxxx2',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
instruction: 'You are an entity extraction model that accepts an input',
|
||||||
|
memory: {
|
||||||
|
role_prefix: MemoryRole.assistant,
|
||||||
|
window: {
|
||||||
|
enabled: false,
|
||||||
|
size: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
@ -1,8 +1,34 @@
|
|||||||
import type { FC } from 'react'
|
import type { FC } from 'react'
|
||||||
|
import InfoPanel from '../_base/components/info-panel'
|
||||||
|
import { mockData } from './mock'
|
||||||
|
import {
|
||||||
|
useTextGenerationCurrentProviderAndModelAndModelList,
|
||||||
|
} from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||||
|
import ModelSelector from '@/app/components/header/account-setting/model-provider-page/model-selector'
|
||||||
|
|
||||||
const Node: FC = () => {
|
const Node: FC = () => {
|
||||||
|
const { provider, name: modelId } = mockData.model
|
||||||
|
const topics = mockData.topics
|
||||||
|
const {
|
||||||
|
textGenerationModelList,
|
||||||
|
} = useTextGenerationCurrentProviderAndModelAndModelList()
|
||||||
return (
|
return (
|
||||||
<div>question-classifier</div>
|
<div className='px-3'>
|
||||||
|
<ModelSelector
|
||||||
|
defaultModel={(provider || modelId) ? { provider, model: modelId } : undefined}
|
||||||
|
modelList={textGenerationModelList}
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
<div className='mt-2 space-y-0.5'>
|
||||||
|
{topics.map(topic => (
|
||||||
|
<InfoPanel
|
||||||
|
key={topic.id}
|
||||||
|
title={topic.name}
|
||||||
|
content={topic.topic}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,15 @@
|
|||||||
|
import type { CommonNodeType, Memory, ModelConfig, ValueSelector } from '@/app/components/workflow/types'
|
||||||
|
|
||||||
|
type Topic = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
topic: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type QuestionClassifierNodeType = CommonNodeType & {
|
||||||
|
query_variable_selector: ValueSelector
|
||||||
|
model: ModelConfig
|
||||||
|
topics: Topic[]
|
||||||
|
instruction: string
|
||||||
|
memory: Memory
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user