Merge branch 'feat/plugins' into dev/plugin-deploy

This commit is contained in:
zxhlyh
2025-01-08 14:20:36 +08:00
42 changed files with 316 additions and 146 deletions

View File

@ -22,6 +22,7 @@ import { useMarketplacePlugins } from '../../plugins/marketplace/hooks'
type AllToolsProps = {
className?: string
toolContentClassName?: string
searchText: string
tags: string[]
buildInTools: ToolWithProvider[]
@ -34,6 +35,7 @@ type AllToolsProps = {
}
const AllTools = ({
className,
toolContentClassName,
searchText,
tags = [],
onSelect,
@ -130,6 +132,7 @@ const AllTools = ({
onScroll={(pluginRef.current as any)?.handleScroll}
>
<Tools
className={toolContentClassName}
showWorkflowEmpty={activeTab === ToolTypeEnum.Workflow}
tools={tools}
onSelect={onSelect}

View File

@ -1,6 +1,6 @@
import type { FC } from 'react'
import { memo } from 'react'
import { useStore } from '../store'
import { useAllBuiltInTools, useAllCustomTools, useAllWorkflowTools } from '@/service/use-tools'
import type { BlockEnum } from '../types'
import { useTabs } from './hooks'
import type { ToolDefaultValue } from './types'
@ -28,9 +28,9 @@ const Tabs: FC<TabsProps> = ({
noBlocks,
}) => {
const tabs = useTabs()
const buildInTools = useStore(s => s.buildInTools)
const customTools = useStore(s => s.customTools)
const workflowTools = useStore(s => s.workflowTools)
const { data: buildInTools } = useAllBuiltInTools()
const { data: customTools } = useAllCustomTools()
const { data: workflowTools } = useAllWorkflowTools()
return (
<div onClick={e => e.stopPropagation()}>

View File

@ -150,6 +150,7 @@ const ToolPicker: FC<Props> = ({
</div>
<AllTools
className='mt-1'
toolContentClassName='max-w-[360px]'
tags={tags}
searchText={searchText}
onSelect={handleSelect}

View File

@ -404,6 +404,7 @@ export const SUPPORT_OUTPUT_VARS_NODE = [
BlockEnum.HttpRequest, BlockEnum.Tool, BlockEnum.VariableAssigner, BlockEnum.VariableAggregator, BlockEnum.QuestionClassifier,
BlockEnum.ParameterExtractor, BlockEnum.Iteration,
BlockEnum.DocExtractor, BlockEnum.ListFilter,
BlockEnum.Agent,
]
export const LLM_OUTPUT_STRUCT: Var[] = [

View File

@ -20,6 +20,7 @@ import { useStrategyInfo } from '../../agent/use-config'
import { SwitchPluginVersion } from './switch-plugin-version'
import PluginList from '@/app/components/workflow/block-selector/market-place-plugin/list'
import { useMarketplacePlugins } from '@/app/components/plugins/marketplace/hooks'
import { ToolTipContent } from '@/app/components/base/tooltip/content'
const NotFoundWarn = (props: {
title: ReactNode,
@ -178,7 +179,10 @@ export const AgentStrategySelector = memo((props: AgentStrategySelectorProps) =>
}
{showSwitchVersion && <SwitchPluginVersion
uniqueIdentifier={'langgenius/openai:12'}
tooltip={t('workflow.nodes.agent.switchToNewVersion')}
tooltip={<ToolTipContent
title={t('workflow.nodes.agent.unsupportedStrategy')}>
{t('workflow.nodes.agent.strategyNotFoundDescAndSwitchVersion')}
</ToolTipContent>}
onChange={() => {
// TODO: refresh all strategies
}}

View File

@ -4,20 +4,22 @@ import Badge from '@/app/components/base/badge'
import Tooltip from '@/app/components/base/tooltip'
import PluginVersionPicker from '@/app/components/plugins/update-plugin/plugin-version-picker'
import { RiArrowLeftRightLine } from '@remixicon/react'
import type { ReactNode } from 'react'
import { type FC, useCallback, useState } from 'react'
import cn from '@/utils/classnames'
import UpdateFromMarketplace from '@/app/components/plugins/update-plugin/from-market-place'
import { useBoolean } from 'ahooks'
import { useCheckInstalled } from '@/service/use-plugins'
import cn from '@/utils/classnames'
export type SwitchPluginVersionProps = {
uniqueIdentifier: string
tooltip?: string
tooltip?: ReactNode
onChange?: (version: string) => void
className?: string
}
export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
const { uniqueIdentifier, tooltip, onChange } = props
const { uniqueIdentifier, tooltip, onChange, className } = props
const [pluginId] = uniqueIdentifier.split(':')
const [isShow, setIsShow] = useState(false)
const [isShowUpdateModal, { setTrue: showUpdateModal, setFalse: hideUpdateModal }] = useBoolean(false)
@ -33,8 +35,13 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
pluginDetails.refetch()
onChange?.(targetVersion!)
}, [hideUpdateModal, onChange, pluginDetails, targetVersion])
const targetUniqueIdentifier = (() => {
if (!targetVersion || !pluginDetail) return uniqueIdentifier
return uniqueIdentifier.replaceAll(pluginDetail.version, targetVersion)
})()
return <Tooltip popupContent={!isShow && !isShowUpdateModal && tooltip} triggerMethod='hover'>
<div className='w-fit'>
<div className={cn('w-fit', className)}>
{isShowUpdateModal && pluginDetail && <UpdateFromMarketplace
payload={{
originalPackageInfo: {
@ -42,7 +49,7 @@ export const SwitchPluginVersion: FC<SwitchPluginVersionProps> = (props) => {
payload: pluginDetail.declaration,
},
targetPackageInfo: {
id: uniqueIdentifier,
id: targetUniqueIdentifier,
version: targetVersion!,
},
}}

View File

@ -319,16 +319,13 @@ const formatItem = (
case BlockEnum.Agent: {
const payload = data as AgentNodeType
const outputs: Var[] = []
Object.keys(payload.output_schema.properties).forEach((outputKey) => {
Object.keys(payload.output_schema?.properties || {}).forEach((outputKey) => {
const output = payload.output_schema.properties[outputKey]
outputs.push({
variable: outputKey,
type: output.type === 'array'
? `Array[${output.items?.type.slice(0, 1).toLocaleUpperCase()}${output.items?.type.slice(1)}]` as VarType
: `${output.type.slice(0, 1).toLocaleUpperCase()}${output.type.slice(1)}` as VarType,
// TODO: is this required?
// @ts-expect-error todo added
description: output.description,
})
})
res.vars = [

View File

@ -111,7 +111,7 @@ const AgentNode: FC<NodeProps<AgentNodeType>> = (props) => {
return <ModelSelector
key={model.param}
modelList={modelList}
triggerClassName='bg-workflow-block-parma-bg'
triggerClassName='bg-workflow-block-parma-bg !h-6 !rounded-md'
defaultModel={
'provider' in model
? {

View File

@ -25,6 +25,7 @@ const Node: FC<NodeProps<LLMNodeType>> = ({
<ModelSelector
defaultModel={{ provider, model: modelId }}
modelList={textGenerationModelList}
triggerClassName='!h-6 !rounded-md'
readonly
/>
)}

View File

@ -21,6 +21,7 @@ const Node: FC<NodeProps<ParameterExtractorNodeType>> = ({
<ModelSelector
defaultModel={{ provider, model: modelId }}
modelList={textGenerationModelList}
triggerClassName='!h-6 !rounded-md'
readonly
/>
)}

View File

@ -32,6 +32,7 @@ const Node: FC<NodeProps<QuestionClassifierNodeType>> = (props) => {
{hasSetModel && (
<ModelSelector
defaultModel={{ provider, model: modelId }}
triggerClassName='!h-6 !rounded-md'
modelList={textGenerationModelList}
readonly
/>

View File

@ -30,26 +30,26 @@ const AgentLogItem = ({
<div className='border-[0.5px] border-components-panel-border rounded-[10px]'>
<div
className={cn(
'flex items-center pl-1.5 pt-2 pr-3 pb-2',
'flex items-center pl-1.5 pt-2 pr-3 pb-2 cursor-pointer',
expanded && 'pb-1',
)}
onClick={() => setExpanded(!expanded)}
>
{
expanded
? <RiArrowRightSLine className='shrink-0 w-4 h-4 rotate-90' />
: <RiArrowRightSLine className='shrink-0 w-4 h-4' />
? <RiArrowRightSLine className='shrink-0 w-4 h-4 rotate-90 text-text-quaternary' />
: <RiArrowRightSLine className='shrink-0 w-4 h-4 text-text-quaternary' />
}
<div className='shrink-0 mr-1.5 w-5 h-5'></div>
<div className='grow system-sm-semibold-uppercase text-text-secondary truncate'>{label}</div>
<div className='shrink-0 mr-2 system-xs-regular text-text-tertiary'>0.02s</div>
{/* <div className='shrink-0 mr-2 system-xs-regular text-text-tertiary'>0.02s</div> */}
<NodeStatusIcon status={status} />
</div>
{
expanded && (
<div className='p-1 pt-0'>
{
!!children.length && (
!!children?.length && (
<Button
className='flex items-center justify-between mb-1 w-full'
variant='tertiary'

View File

@ -19,7 +19,9 @@ const AgentLogNav = ({
className='shrink-0 px-[5px]'
size='small'
variant='ghost-accent'
onClick={() => onShowAgentOrToolLog()}
onClick={() => {
onShowAgentOrToolLog()
}}
>
<RiArrowLeftLine className='mr-1 w-3.5 h-3.5' />
Agent
@ -31,7 +33,6 @@ const AgentLogNav = ({
variant='ghost-accent'
onClick={() => {}}
>
<RiArrowLeftLine className='mr-1 w-3.5 h-3.5' />
Agent strategy
</Button>
{

View File

@ -24,7 +24,9 @@ const AgentLogTrigger = ({
<div className='grow mx-0.5 px-1 system-xs-medium text-text-secondary'></div>
<div
className='shrink-0 flex items-center px-[1px] system-xs-regular-uppercase text-text-tertiary cursor-pointer'
onClick={() => onShowAgentOrToolLog({ id: nodeInfo.id, children: agentLog || [] } as AgentLogItemWithChildren)}
onClick={() => {
onShowAgentOrToolLog({ id: nodeInfo.id, children: agentLog || [] } as AgentLogItemWithChildren)
}}
>
Detail
<RiArrowRightLine className='ml-0.5 w-3.5 h-3.5' />

View File

@ -36,7 +36,10 @@ const SpecialResultPanel = ({
handleShowAgentOrToolLog,
}: SpecialResultPanelProps) => {
return (
<>
<div onClick={(e) => {
e.stopPropagation()
e.nativeEvent.stopImmediatePropagation()
}}>
{
!!showRetryDetail && !!retryResultList?.length && setShowRetryDetailFalse && (
<RetryResultPanel
@ -63,7 +66,7 @@ const SpecialResultPanel = ({
/>
)
}
</>
</div>
)
}

View File

@ -166,7 +166,13 @@ const TracingPanel: FC<TracingPanelProps> = ({
}
return (
<div className={cn(className || 'bg-components-panel-bg', 'py-2')}>
<div
className={cn(className || 'bg-components-panel-bg', 'py-2')}
onClick={(e) => {
e.stopPropagation()
e.nativeEvent.stopImmediatePropagation()
}}
>
{treeNodes.map(renderNode)}
</div>
)