fix: show rag vars names

pull/21398/head
Joel 12 months ago
parent dfe091789c
commit 7080c9f279

@ -13,7 +13,7 @@ import { useReactFlow, useStoreApi } from 'reactflow'
import RemoveButton from '../remove-button' import RemoveButton from '../remove-button'
import useAvailableVarList from '../../hooks/use-available-var-list' import useAvailableVarList from '../../hooks/use-available-var-list'
import VarReferencePopup from './var-reference-popup' import VarReferencePopup from './var-reference-popup'
import { getNodeInfoById, isConversationVar, isENV, isSystemVar, varTypeToStructType } from './utils' import { getNodeInfoById, isConversationVar, isENV, isRagVariableVar, isSystemVar, varTypeToStructType } from './utils'
import ConstantField from './constant-field' import ConstantField from './constant-field'
import cn from '@/utils/classnames' import cn from '@/utils/classnames'
import type { Node, NodeOutPutVar, ValueSelector, Var } from '@/app/components/workflow/types' import type { Node, NodeOutPutVar, ValueSelector, Var } from '@/app/components/workflow/types'
@ -40,6 +40,7 @@ import Tooltip from '@/app/components/base/tooltip'
import { isExceptionVariable } from '@/app/components/workflow/utils' import { isExceptionVariable } from '@/app/components/workflow/utils'
import VarFullPathPanel from './var-full-path-panel' import VarFullPathPanel from './var-full-path-panel'
import { noop } from 'lodash-es' import { noop } from 'lodash-es'
import { InputField } from '@/app/components/base/icons/src/vender/pipeline'
const TRIGGER_DEFAULT_WIDTH = 227 const TRIGGER_DEFAULT_WIDTH = 227
@ -274,14 +275,16 @@ const VarReferencePicker: FC<Props> = ({
isConstant: !!isConstant, isConstant: !!isConstant,
}) })
const { isEnv, isChatVar, isValidVar, isException } = useMemo(() => { const { isEnv, isChatVar, isRagVar, isValidVar, isException } = useMemo(() => {
const isEnv = isENV(value as ValueSelector) const isEnv = isENV(value as ValueSelector)
const isChatVar = isConversationVar(value as ValueSelector) const isChatVar = isConversationVar(value as ValueSelector)
const isRagVar = isRagVariableVar(value as ValueSelector)
const isValidVar = Boolean(outputVarNode) || isEnv || isChatVar const isValidVar = Boolean(outputVarNode) || isEnv || isChatVar
const isException = isExceptionVariable(varName, outputVarNode?.type) const isException = isExceptionVariable(varName, outputVarNode?.type)
return { return {
isEnv, isEnv,
isChatVar, isChatVar,
isRagVar,
isValidVar, isValidVar,
isException, isException,
} }
@ -385,7 +388,7 @@ const VarReferencePicker: FC<Props> = ({
{hasValue {hasValue
? ( ? (
<> <>
{isShowNodeName && !isEnv && !isChatVar && ( {isShowNodeName && !isEnv && !isChatVar && !isRagVar && (
<div className='flex items-center' onClick={(e) => { <div className='flex items-center' onClick={(e) => {
if (e.metaKey || e.ctrlKey) { if (e.metaKey || e.ctrlKey) {
e.stopPropagation() e.stopPropagation()
@ -414,6 +417,7 @@ const VarReferencePicker: FC<Props> = ({
{!hasValue && <Variable02 className='h-3.5 w-3.5' />} {!hasValue && <Variable02 className='h-3.5 w-3.5' />}
{isEnv && <Env className='h-3.5 w-3.5 text-util-colors-violet-violet-600' />} {isEnv && <Env className='h-3.5 w-3.5 text-util-colors-violet-violet-600' />}
{isChatVar && <BubbleX className='h-3.5 w-3.5 text-util-colors-teal-teal-700' />} {isChatVar && <BubbleX className='h-3.5 w-3.5 text-util-colors-teal-teal-700' />}
{isRagVar && <InputField className='h-3.5 w-3.5 text-text-accent' />}
<div className={cn('ml-0.5 truncate text-xs font-medium', isEnv && '!text-text-secondary', isChatVar && 'text-util-colors-teal-teal-700', isException && 'text-text-warning')} title={varName} style={{ <div className={cn('ml-0.5 truncate text-xs font-medium', isEnv && '!text-text-secondary', isChatVar && 'text-util-colors-teal-teal-700', isException && 'text-text-warning')} title={varName} style={{
maxWidth: maxVarNameWidth, maxWidth: maxVarNameWidth,
}}>{varName}</div> }}>{varName}</div>

@ -125,7 +125,7 @@ const Item: FC<ItemProps> = ({
if (!isSupportFileVar && isFile) if (!isSupportFileVar && isFile)
return return
if (isSys || isEnv || isChatVar) { // system variable | environment variable | conversation variable if (isSys || isEnv || isChatVar || isRagVariable) { // system variable | environment variable | conversation variable
onChange([...objPath, ...itemData.variable.split('.')], itemData) onChange([...objPath, ...itemData.variable.split('.')], itemData)
} }
else { else {
@ -155,7 +155,7 @@ const Item: FC<ItemProps> = ({
{isChatVar && <BubbleX className='h-3.5 w-3.5 shrink-0 text-util-colors-teal-teal-700' />} {isChatVar && <BubbleX className='h-3.5 w-3.5 shrink-0 text-util-colors-teal-teal-700' />}
{isLoopVar && <Loop className='h-3.5 w-3.5 shrink-0 text-util-colors-cyan-cyan-500' />} {isLoopVar && <Loop className='h-3.5 w-3.5 shrink-0 text-util-colors-cyan-cyan-500' />}
{isRagVariable && <InputField className='h-3.5 w-3.5 shrink-0 text-text-accent' />} {isRagVariable && <InputField className='h-3.5 w-3.5 shrink-0 text-text-accent' />}
{!isEnv && !isChatVar && ( {!isEnv && !isChatVar && !isRagVariable && (
<div title={itemData.variable} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable}</div> <div title={itemData.variable} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable}</div>
)} )}
{isEnv && ( {isEnv && (
@ -164,6 +164,9 @@ const Item: FC<ItemProps> = ({
{isChatVar && ( {isChatVar && (
<div title={itemData.des} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable.replace('conversation.', '')}</div> <div title={itemData.des} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable.replace('conversation.', '')}</div>
)} )}
{isRagVariable && (
<div title={itemData.des} className='system-sm-medium ml-1 w-0 grow truncate text-text-secondary'>{itemData.variable.replace('rag.', '')}</div>
)}
</div> </div>
<div className='ml-1 shrink-0 text-xs font-normal capitalize text-text-tertiary'>{itemData.type}</div> <div className='ml-1 shrink-0 text-xs font-normal capitalize text-text-tertiary'>{itemData.type}</div>
{ {

Loading…
Cancel
Save