diff --git a/web/app/components/app/annotation/mock-data.ts b/web/app/components/app/annotation/mock-data.ts deleted file mode 100644 index a944381d0d..0000000000 --- a/web/app/components/app/annotation/mock-data.ts +++ /dev/null @@ -1,265 +0,0 @@ -import type { AnnotationItem, HitHistoryItem } from './type' - -const list: AnnotationItem[] = [ - // create some mock data - { - id: '1', - question: 'What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?', - answer: 'What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?', - created_at: '2020-01-01T00:00:00Z', - hit_count: 1, - }, - { - id: '2', - question: 'What is the capital of Canada?', - answer: 'Ottawa', - created_at: '2020-01-02T00:00:00Z', - hit_count: 2, - }, - { - id: '3', - question: 'What is the capital of Mexico?', - answer: 'Mexico City', - created_at: '2020-01-03T00:00:00Z', - hit_count: 3, - }, - { - id: '4', - question: 'What is the capital of Brazil?', - answer: 'Brasilia', - created_at: '2020-01-04T00:00:00Z', - hit_count: 4, - }, - { - id: '5', - question: 'What is the capital of Argentina?', - answer: 'Buenos Aires', - created_at: '2020-01-05T00:00:00Z', - hit_count: 5, - }, - { - id: '6', - question: 'What is the capital of Chile?', - answer: 'Santiago', - created_at: '2020-01-06T00:00:00Z', - hit_count: 6, - }, - { - id: '7', - question: 'What is the capital of Peru?', - answer: 'Lima', - created_at: '2020-01-07T00:00:00Z', - hit_count: 7, - }, - { - id: '8', - question: 'What is the capital of Ecuador?', - answer: 'Quito', - created_at: '2020-01-08T00:00:00Z', - hit_count: 8, - }, - { - id: '9', - question: 'What is the capital of Colombia?', - answer: 'Bogota', - created_at: '2020-01-09T00:00:00Z', - hit_count: 9, - }, -] - -export const hitHistoryList: HitHistoryItem[] = [ - // create some mock data. source can only be: API/Webapp/Explore/Debug - { - id: '1', - question: 'What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?What is the capital of the United States?', - source: 'API', - score: 0.9, - created_at: '2020-01-01T00:00:00Z', - }, - { - id: '2', - question: 'What is the capital of Canada?', - source: 'Webapp', - score: 0.8, - created_at: '2020-01-02T00:00:00Z', - }, - { - id: '3', - question: 'What is the capital of Mexico?', - source: 'Explore', - score: 0.7, - created_at: '2020-01-03T00:00:00Z', - }, - { - id: '4', - question: 'What is the capital of Brazil?', - source: 'Debug', - score: 0.6, - created_at: '2020-01-04T00:00:00Z', - }, - { - id: '5', - question: 'What is the capital of Argentina?', - source: 'API', - score: 0.5, - created_at: '2020-01-05T00:00:00Z', - }, - { - id: '6', - question: 'What is the capital of Chile?', - source: 'Webapp', - score: 0.4, - created_at: '2020-01-06T00:00:00Z', - }, - { - id: '7', - question: 'What is the capital of Peru?', - source: 'Explore', - score: 0.3, - created_at: '2020-01-07T00:00:00Z', - }, - { - id: '8', - question: 'What is the capital of Ecuador?', - source: 'Debug', - score: 0.2, - created_at: '2020-01-08T00:00:00Z', - }, - { - id: '9', - question: 'What is the capital of Colombia?', - source: 'API', - score: 0.1, - created_at: '2020-01-09T00:00:00Z', - }, - // make more mock data - { - id: '10', - question: 'What is the capital of the United States?', - source: 'API', - score: 0.9, - created_at: '2020-01-01T00:00:00Z', - }, - { - id: '11', - question: 'What is the capital of Canada?', - source: 'Webapp', - score: 0.8, - created_at: '2020-01-02T00:00:00Z', - }, - { - id: '12', - question: 'What is the capital of Mexico?', - source: 'Explore', - score: 0.7, - created_at: '2020-01-03T00:00:00Z', - }, - { - id: '13', - question: 'What is the capital of Brazil?', - source: 'Debug', - score: 0.6, - created_at: '2020-01-04T00:00:00Z', - }, - { - id: '14', - question: 'What is the capital of Argentina?', - source: 'API', - score: 0.5, - created_at: '2020-01-05T00:00:00Z', - }, - { - id: '15', - question: 'What is the capital of Chile?', - source: 'Webapp', - score: 0.4, - created_at: '2020-01-06T00:00:00Z', - }, - { - id: '16', - question: 'What is the capital of Peru?', - source: 'Explore', - score: 0.3, - created_at: '2020-01-07T00:00:00Z', - }, - { - id: '17', - question: 'What is the capital of Ecuador?', - source: 'Debug', - score: 0.2, - created_at: '2020-01-08T00:00:00Z', - }, - { - id: '18', - question: 'What is the capital of Colombia?', - source: 'API', - score: 0.1, - created_at: '2020-01-09T00:00:00Z', - }, - // make more mock data - { - id: '19', - question: 'What is the capital of the United States?', - source: 'API', - score: 0.9, - created_at: '2020-01-01T00:00:00Z', - }, - { - id: '20', - question: 'What is the capital of Canada?', - source: 'Webapp', - score: 0.8, - created_at: '2020-01-02T00:00:00Z', - }, - { - id: '21', - question: 'What is the capital of Mexico?', - source: 'Explore', - score: 0.7, - created_at: '2020-01-03T00:00:00Z', - }, - { - id: '22', - question: 'What is the capital of Brazil?', - source: 'Debug', - score: 0.6, - created_at: '2020-01-04T00:00:00Z', - }, - { - id: '23', - question: 'What is the capital of Argentina?', - source: 'API', - score: 0.5, - created_at: '2020-01-05T00:00:00Z', - }, - { - id: '24', - question: 'What is the capital of Chile?', - source: 'Webapp', - score: 0.4, - created_at: '2020-01-06T00:00:00Z', - }, - { - id: '25', - question: 'What is the capital of Peru?', - source: 'Explore', - score: 0.3, - created_at: '2020-01-07T00:00:00Z', - }, - { - id: '26', - question: 'What is the capital of Ecuador?', - source: 'Debug', - score: 0.2, - created_at: '2020-01-08T00:00:00Z', - }, - { - id: '27', - question: 'What is the capital of Colombia?', - source: 'API', - score: 0.1, - created_at: '2020-01-09T00:00:00Z', - }, -] - -export default list diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx b/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx index 2e7ae7c46c..30b47aedfa 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx +++ b/web/app/components/workflow/nodes/knowledge-retrieval/panel.tsx @@ -46,6 +46,7 @@ const Panel: FC> = ({ return (
+ {/* {JSON.stringify(inputs, null, 2)} */} diff --git a/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts b/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts index 60980f429f..d34ed90260 100644 --- a/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts +++ b/web/app/components/workflow/nodes/knowledge-retrieval/use-config.ts @@ -17,7 +17,18 @@ const useConfig = (id: string, payload: KnowledgeRetrievalNodeType) => { const { getBeforeNodesInSameBranch } = useWorkflow() const startNode = getBeforeNodesInSameBranch(id).find(node => node.data.type === BlockEnum.Start) const startNodeId = startNode?.id - const { inputs, setInputs } = useNodeCrud(id, payload) + const { inputs, setInputs: doSetInputs } = useNodeCrud(id, payload) + + const setInputs = useCallback((s: KnowledgeRetrievalNodeType) => { + const newInputs = produce(s, (draft) => { + if (s.retrieval_mode === RETRIEVE_TYPE.multiWay) + delete draft.single_retrieval_config + else + delete draft.multiple_retrieval_config + }) + // not work in pass to draft... + doSetInputs(newInputs) + }, [doSetInputs]) const inputRef = useRef(inputs) useEffect(() => { diff --git a/web/app/components/workflow/nodes/llm/default.ts b/web/app/components/workflow/nodes/llm/default.ts index 352b040e03..ef045e261c 100644 --- a/web/app/components/workflow/nodes/llm/default.ts +++ b/web/app/components/workflow/nodes/llm/default.ts @@ -26,7 +26,7 @@ const nodeDefault: NodeDefault = { text: '', }], context: { - enabled: false, + enabled: true, variable_selector: [], }, vision: { diff --git a/web/app/components/workflow/nodes/mock.ts b/web/app/components/workflow/nodes/mock.ts deleted file mode 100644 index d40be4bbe7..0000000000 --- a/web/app/components/workflow/nodes/mock.ts +++ /dev/null @@ -1,82 +0,0 @@ -import type { NodeOutPutVar } from '@/app/components/workflow/types' -import { BlockEnum } from '@/app/components/workflow/types' - -export const mockNodesData: Record = { - aaa: { - title: 'Start', - type: BlockEnum.Start, - }, - bbb: { - title: 'Knowledge', - type: BlockEnum.KnowledgeRetrieval, - }, - ccc: { - title: 'Code', - type: BlockEnum.Code, - }, -} - -export const mockNodeOutputVars: NodeOutPutVar[] = [ - { - nodeId: 'aaa', - title: 'Start', - vars: [ - { - variable: 'query', - type: 'string', - }, - { - variable: 'age', - type: 'number', - }, - ], - }, - { - nodeId: 'bbb', - title: 'LLM', - vars: [ - { - variable: 'usage', - type: 'object', - children: [ - { - variable: 'token', - type: 'object', - children: [ - { - variable: 'num', - type: 'number', - }, - { - variable: 'price', - type: 'number', - }, - ], - }, - ], - }, - { - variable: 'other', - type: 'object', - children: [ - { - variable: 'a', - type: 'object', - children: [ - { - variable: 'b', - type: 'object', - children: [ - { - variable: 'c', - type: 'string', - }, - ], - }, - ], - }, - ], - }, - ], - }, -]