feat: question classify node

This commit is contained in:
Joel
2024-02-20 17:28:58 +08:00
parent f14a5c7346
commit c441a848e7
7 changed files with 111 additions and 13 deletions

View File

@ -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,
},
},
}

View File

@ -1,8 +1,34 @@
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 { provider, name: modelId } = mockData.model
const topics = mockData.topics
const {
textGenerationModelList,
} = useTextGenerationCurrentProviderAndModelAndModelList()
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>
)
}

View File

@ -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
}