Commit c441a848 authored by Joel's avatar Joel

feat: question classify node

parent f14a5c73
...@@ -6,7 +6,7 @@ import Workflow from '@/app/components/workflow' ...@@ -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 = () => { ...@@ -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>
) )
......
'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)
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 = () => { ...@@ -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 ...@@ -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 (
......
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,
},
},
}
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>
) )
} }
......
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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment