feat: support dialogue count in chatflow (#7440)

This commit is contained in:
Joel
2024-08-20 18:28:39 +08:00
committed by GitHub
parent e35e251863
commit c70d69322b
6 changed files with 69 additions and 29 deletions

View File

@@ -3,7 +3,9 @@ import type { FC } from 'react'
import React, { useCallback } from 'react'
import type { VariantProps } from 'class-variance-authority'
import { cva } from 'class-variance-authority'
import { RiQuestionLine } from '@remixicon/react'
import cn from '@/utils/classnames'
import TooltipPlus from '@/app/components/base/tooltip-plus'
const variants = cva([], {
variants: {
@@ -26,6 +28,7 @@ type Props = {
selected: boolean
disabled?: boolean
align?: 'left' | 'center' | 'right'
tooltip?: string
} & VariantProps<typeof variants>
const OptionCard: FC<Props> = ({
@@ -35,6 +38,7 @@ const OptionCard: FC<Props> = ({
selected,
disabled,
align = 'center',
tooltip,
}) => {
const handleSelect = useCallback(() => {
if (selected || disabled)
@@ -54,7 +58,14 @@ const OptionCard: FC<Props> = ({
)}
onClick={handleSelect}
>
{title}
<span>{title}</span>
{tooltip && <TooltipPlus
popupContent={<div className='w-[240px]'>
{tooltip}
</div>}
>
<RiQuestionLine className='ml-0.5 w-[14px] h-[14px] text-text-quaternary' />
</TooltipPlus>}
</div>
)
}

View File

@@ -99,6 +99,10 @@ const formatItem = (
variable: 'sys.query',
type: VarType.string,
})
res.vars.push({
variable: 'sys.dialogue_count',
type: VarType.number,
})
res.vars.push({
variable: 'sys.conversation_id',
type: VarType.string,

View File

@@ -49,7 +49,6 @@ const Panel: FC<NodePanelProps<AssignerNodeType>> = ({
</Field>
<Field
title={t(`${i18nPrefix}.writeMode`)}
tooltip={t(`${i18nPrefix}.writeModeTip`)!}
>
<div className={cn('grid gap-2 grid-cols-3')}>
{writeModeTypes.map(type => (
@@ -59,6 +58,7 @@ const Panel: FC<NodePanelProps<AssignerNodeType>> = ({
onSelect={handleWriteModeChange(type)}
selected={inputs.write_mode === type}
disabled={!isSupportAppend && type === WriteMode.Append}
tooltip={type === WriteMode.Append ? t(`${i18nPrefix}.writeModeTip`)! : undefined}
/>
))}
</div>

View File

@@ -84,17 +84,30 @@ const Panel: FC<NodePanelProps<StartNodeType>> = ({
/>
{
isChatMode && (
<VarItem
readonly
payload={{
variable: 'sys.conversation_id',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>
<>
<VarItem
readonly
payload={{
variable: 'sys.dialogue_count',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
Number
</div>
}
/>
<VarItem
readonly
payload={{
variable: 'sys.conversation_id',
} as any}
rightContent={
<div className='text-xs font-normal text-gray-500'>
String
</div>
}
/>
</>
)
}
<VarItem