Commit a192ae93 authored by Joel's avatar Joel

feat: remove useless file

parent 7a07d8c2
'use client'
import type { FC } from 'react'
import { memo } from 'react'
import Workflow from '@/app/components/workflow'
import { BlockEnum } from '@/app/components/workflow/types'
import { mockData as StartNodeMock } from '@/app/components/workflow/nodes/start/mock'
import { mockData as DirectAnswerNodeMock } from '@/app/components/workflow/nodes/direct-answer/mock'
import { mockData as LLMNodeMock } from '@/app/components/workflow/nodes/llm/mock'
import { mockData as KnowledgeRetrievalNodeMock } from '@/app/components/workflow/nodes/knowledge-retrieval/mock'
import { mockData as QuestionClassifierNodeMock } from '@/app/components/workflow/nodes/question-classifier/mock'
import { mockData as IfElseNodeMock } from '@/app/components/workflow/nodes/if-else/mock'
import { mockData as CodeNodeMock } from '@/app/components/workflow/nodes/code/mock'
import { mockData as TemplateTransformNodeMock } from '@/app/components/workflow/nodes/template-transform/mock'
import { mockData as HttpRequestNodeMock } from '@/app/components/workflow/nodes/http/mock'
import { mockData as ToolNodeMock } from '@/app/components/workflow/nodes/tool/mock'
import { mockData as VariableAssignerNodeMock } from '@/app/components/workflow/nodes/variable-assigner/mock'
import { mockData as EndNodeMock } from '@/app/components/workflow/nodes/end/mock'
const allMockData = {
[BlockEnum.Start]: StartNodeMock,
[BlockEnum.DirectAnswer]: DirectAnswerNodeMock,
[BlockEnum.LLM]: LLMNodeMock,
[BlockEnum.KnowledgeRetrieval]: KnowledgeRetrievalNodeMock,
[BlockEnum.QuestionClassifier]: QuestionClassifierNodeMock,
[BlockEnum.IfElse]: IfElseNodeMock,
[BlockEnum.Code]: CodeNodeMock,
[BlockEnum.TemplateTransform]: TemplateTransformNodeMock,
[BlockEnum.HttpRequest]: HttpRequestNodeMock,
[BlockEnum.Tool]: ToolNodeMock,
[BlockEnum.VariableAssigner]: VariableAssignerNodeMock,
[BlockEnum.End]: EndNodeMock,
}
const nodes = [
BlockEnum.Code/* 7 */, BlockEnum.KnowledgeRetrieval/* 4 */, BlockEnum.Start/* 1 */, BlockEnum.DirectAnswer/* 2 */, BlockEnum.LLM/* 3 */, BlockEnum.QuestionClassifier/* 5 */,
BlockEnum.IfElse/* 6 */, BlockEnum.TemplateTransform/* 8 */, BlockEnum.HttpRequest/* 9 */, BlockEnum.Tool/* 10 */,
BlockEnum.VariableAssigner/* 11 */, BlockEnum.End/* 12 */,
].map((item, i) => {
const payload = allMockData[item]
return ({
id: `${i + 1}`,
type: 'custom',
position: { x: 330, y: 30 + i * 300 },
data: {
selected: i === 0, // for test: always select the first node
name: item,
...payload,
},
})
})
const initialNodes = nodes
const initialEdges = [
{
id: '1',
source: '1',
target: '2',
type: 'custom',
},
{
id: '2',
source: '2',
target: '3',
type: 'custom',
},
{
id: '3',
source: '2',
target: '4',
type: 'custom',
},
]
const Page: FC = () => {
return (
<div className='min-w-[720px] w-full h-full overflow-x-auto'>
<Workflow
nodes={initialNodes}
edges={initialEdges}
/>
</div>
)
}
export default memo(Page)
import { BlockEnum } from '../../types'
import { CodeLanguage } from './types'
import type { CodeNodeType } from './types'
export const mockData: CodeNodeType = {
title: 'Code',
desc: '',
type: BlockEnum.Code,
variables: [
{
variable: 'name',
value_selector: ['aaa', 'name'],
},
{
variable: 'age',
value_selector: ['bbb', 'b', 'c'],
},
],
code_language: CodeLanguage.python3,
code: 'print("hello world")',
outputs: [
{
variable: 'output',
variable_type: 'string',
},
],
}
import { BlockEnum } from '../../types'
import type { DirectAnswerNodeType } from './types'
export const mockData: DirectAnswerNodeType = {
title: 'Direct answer',
desc: 'Test',
type: BlockEnum.DirectAnswer,
variables: [
{
variable: 'age',
value_selector: ['bbb', 'b', 'c'],
},
],
answer: 'Sorry, I cannot answer this question.',
}
import { BlockEnum } from '../../types'
import { EndVarType } from './types'
import type { EndNodeType } from './types'
export const mockData: EndNodeType = {
title: 'End',
desc: 'Test',
type: BlockEnum.End,
outputs: {
type: EndVarType.structured,
plain_text_selector: ['aaa', 'name'],
structured_variables: [
{
variable: 'test',
value_selector: ['aaa', 'name'],
},
],
},
}
import { BlockEnum } from '../../types'
import { APIType, AuthorizationType, BodyType, Method } from './types'
import type { HttpNodeType } from './types'
export const mockData: HttpNodeType = {
title: 'HTTP Request',
desc: 'Test',
type: BlockEnum.HttpRequest,
variables: [
{
variable: 'name',
value_selector: ['aaa', 'name'],
},
{
variable: 'age',
value_selector: ['bbb', 'b', 'c'],
},
],
method: Method.get,
url: 'https://api.dify.com/xx',
headers: 'Content-Type: application/json\nAccept: */*',
params: '',
body: {
type: BodyType.none,
data: '',
},
authorization: {
type: AuthorizationType.apiKey,
config: {
type: APIType.custom,
api_key: 'abc',
header: 'x-Authorization',
},
},
}
import { BlockEnum } from '../../types'
import type { IfElseNodeType } from './types'
import { ComparisonOperator, LogicalOperator } from './types'
export const mockData: IfElseNodeType = {
title: 'If Else',
desc: 'Test',
type: BlockEnum.IfElse,
logical_operator: LogicalOperator.and,
conditions: [
{
id: '1',
variable_selector: ['aaa', 'name'],
comparison_operator: ComparisonOperator.contains,
value: '22',
},
{
id: '2',
variable_selector: ['bbb', 'b', 'c'],
comparison_operator: ComparisonOperator.equal,
value: 'b',
},
],
}
import { BlockEnum } from '../../types'
import type { KnowledgeRetrievalNodeType } from './types'
import { RETRIEVE_TYPE } from '@/types/app'
export const mockData: KnowledgeRetrievalNodeType = {
type: BlockEnum.KnowledgeRetrieval,
desc: 'xxx',
title: 'Knowledge Retrieval',
query_variable_selector: ['aaa', 'name'],
dataset_ids: ['744a0635-2496-4a87-8e6d-fae410f610be'],
retrieval_mode: RETRIEVE_TYPE.oneWay,
multiple_retrieval_config: {
top_k: 10,
score_threshold: null,
reranking_model: {
provider: '',
model: '',
},
},
}
import { BlockEnum, PromptRole } from '../../types'
import type { LLMNodeType } from './types'
import { Resolution } from '@/types/app'
export const mockData: LLMNodeType = {
title: 'LLM',
desc: 'Test',
type: BlockEnum.LLM,
model: {
provider: 'openai',
name: 'gpt-4',
mode: 'chat',
completion_params: {
temperature: 0.7,
},
},
variables: [
{
variable: 'name',
value_selector: ['aaa', 'name'],
},
{
variable: 'age',
value_selector: ['bbb', 'b', 'c'],
},
{
variable: 'a1',
value_selector: ['aaa', 'name'],
},
{
variable: 'a2',
value_selector: ['aaa', 'name'],
},
],
prompt: [
{
role: PromptRole.system,
text: '',
},
],
memory: {
role_prefix: {
user: 'user: ',
assistant: 'assistant: ',
},
window: {
enabled: false,
size: 0,
},
},
context: {
enabled: false,
variable_selector: ['aaa', 'name'],
},
vision: {
enabled: true,
configs: {
detail: Resolution.low,
},
},
}
import { BlockEnum } from '../../types'
import type { QuestionClassifierNodeType } from './types'
export const mockData: QuestionClassifierNodeType = {
title: 'Question Classifier',
desc: 'Test',
type: BlockEnum.QuestionClassifier,
query_variable_selector: ['aaa', 'name'],
model: {
provider: 'openai',
name: 'gpt-4',
mode: 'chat',
completion_params: {
temperature: 0.7,
},
},
classes: [
{
id: '1',
name: 'topic 1',
},
{
id: '2',
name: 'topic 2',
},
],
instruction: 'You are an entity extraction model that accepts an input',
memory: {
window: {
enabled: false,
size: 0,
},
},
}
import type { StartNodeType } from './types'
import { BlockEnum, InputVarType } from '@/app/components/workflow/types'
export const mockData: StartNodeType = {
title: 'Start',
desc: 'Test',
type: BlockEnum.Start,
variables: [
{
type: InputVarType.textInput,
label: 'Test',
variable: 'a',
max_length: 10,
default: 'test',
required: true,
hint: 'Test',
},
{
type: InputVarType.paragraph,
label: 'Test',
variable: 'para',
default: 'test',
required: true,
hint: 'Test',
},
{
type: InputVarType.select,
label: 'Test',
variable: 'sel',
default: 'test',
required: false,
hint: 'Test',
options: ['op1', 'op2'],
},
{
type: InputVarType.number,
label: 'Test',
variable: 'num',
default: '1',
required: true,
hint: 'Test',
},
],
}
import { BlockEnum } from '../../types'
import type { TemplateTransformNodeType } from './types'
export const mockData: TemplateTransformNodeType = {
title: 'Template Transform',
desc: 'Test',
type: BlockEnum.TemplateTransform,
variables: [
{
variable: 'name',
value_selector: ['aaa', 'name'],
},
{
variable: 'age',
value_selector: ['bbb', 'b', 'c'],
},
],
template: 'print("hello world")',
}
import { BlockEnum } from '../../types'
import type { ToolNodeType } from './types'
import { VarType } from './types'
export const mockData: ToolNodeType = {
title: 'Tool',
desc: 'Test',
type: BlockEnum.Tool,
provider_id: 'test',
provider_type: 'builtin',
provider_name: 'test',
tool_name: 'test',
tool_label: 'test',
tool_inputs: [
{
variable: 'size',
variable_type: VarType.selector,
value_selector: ['aaa', 'name'],
},
{
variable: 'quality',
variable_type: VarType.static,
value: 'HD',
},
],
tool_parameters: {},
}
import { BlockEnum } from '../../types'
import type { VariableAssignerNodeType } from './types'
export const mockData: VariableAssignerNodeType = {
title: 'Variable Assigner',
desc: 'Test',
type: BlockEnum.VariableAssigner,
output_type: 'string',
variables: [
['aaa', 'name'],
['bbb', 'b', 'c'],
],
}
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