feat: llm show vars

This commit is contained in:
Joel
2024-04-01 11:48:42 +08:00
parent e03367a188
commit 705d765a71
3 changed files with 40 additions and 10 deletions

View File

@ -1,4 +1,5 @@
import produce from 'immer'
import { isArray } from 'lodash-es'
import type { CodeNodeType } from '../../../code/types'
import type { EndNodeType } from '../../../end/types'
import type { AnswerNodeType } from '../../../answer/types'
@ -177,6 +178,12 @@ export const isSystemVar = (valueSelector: ValueSelector) => {
return valueSelector[0] === 'sys' || valueSelector[1] === 'sys'
}
export const getNodeInfoById = (nodes: any, id: string) => {
if (!isArray(nodes))
return
return nodes.find((node: any) => node.id === id)
}
export const getVarType = (value: ValueSelector, availableNodes: any[], isChatMode: boolean): VarType | undefined => {
const isSystem = isSystemVar(value)
const startNode = availableNodes.find((node: any) => {

View File

@ -3,10 +3,9 @@ import type { FC } from 'react'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
import { isArray } from 'lodash-es'
import produce from 'immer'
import VarReferencePopup from './var-reference-popup'
import { isSystemVar, toNodeOutputVars } from './utils'
import { getNodeInfoById, isSystemVar, toNodeOutputVars } from './utils'
import type { ValueSelector, Var } from '@/app/components/workflow/types'
import { BlockEnum, VarType } from '@/app/components/workflow/types'
import { VarBlockIcon } from '@/app/components/workflow/block-icon'
@ -42,12 +41,6 @@ type Props = {
filterVar?: (payload: Var, valueSelector: ValueSelector) => boolean
}
const getNodeInfoById = (nodes: any, id: string) => {
if (!isArray(nodes))
return
return nodes.find((node: any) => node.id === id)
}
const VarReferencePicker: FC<Props> = ({
nodeId,
readonly,