Merge branch 'feat/plugins' into dev/plugin-deploy
This commit is contained in:
commit
76d7a64c37
@ -355,7 +355,7 @@ function Form<
|
||||
label={label[language] || label.en_US}
|
||||
required={required}
|
||||
tooltip={tooltip?.[language] || tooltip?.en_US}
|
||||
value={value[variable]}
|
||||
value={value[variable] || []}
|
||||
onChange={item => handleFormChange(variable, item as any)}
|
||||
/>
|
||||
{fieldMoreInfo?.(formSchema)}
|
||||
|
@ -25,7 +25,7 @@ type Props = {
|
||||
|
||||
const MultipleToolSelector = ({
|
||||
disabled,
|
||||
value,
|
||||
value = [],
|
||||
label,
|
||||
required,
|
||||
tooltip,
|
||||
|
@ -179,7 +179,7 @@ export const AgentStrategy = (props: AgentStrategyProps) => {
|
||||
return (
|
||||
<MultipleToolSelector
|
||||
scope={schema.scope}
|
||||
value={value}
|
||||
value={value || []}
|
||||
label={schema.label[language]}
|
||||
tooltip={schema.tooltip?.[language]}
|
||||
onChange={onChange}
|
||||
|
@ -12,9 +12,11 @@ import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||
|
||||
type AgentLogItemProps = {
|
||||
item: AgentLogItemWithChildren
|
||||
onShowAgentOrToolLog: (detail: AgentLogItemWithChildren) => void
|
||||
}
|
||||
const AgentLogItem = ({
|
||||
item,
|
||||
onShowAgentOrToolLog,
|
||||
}: AgentLogItemProps) => {
|
||||
const {
|
||||
label,
|
||||
@ -51,7 +53,7 @@ const AgentLogItem = ({
|
||||
<Button
|
||||
className='flex items-center justify-between mb-1 w-full'
|
||||
variant='tertiary'
|
||||
onClick={() => {}}
|
||||
onClick={() => onShowAgentOrToolLog(item)}
|
||||
>
|
||||
<div className='flex items-center'>
|
||||
<RiListView className='mr-1 w-4 h-4 text-components-button-tertiary-text shrink-0' />
|
||||
|
@ -6,12 +6,15 @@ import {
|
||||
PortalToFollowElemTrigger,
|
||||
} from '@/app/components/base/portal-to-follow-elem'
|
||||
import Button from '@/app/components/base/button'
|
||||
import type { AgentLogItemWithChildren } from '@/types/workflow'
|
||||
|
||||
type AgentLogNavMoreProps = {
|
||||
options: { id: string; label: string }[]
|
||||
onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void
|
||||
}
|
||||
const AgentLogNavMore = ({
|
||||
options,
|
||||
onShowAgentOrToolLog,
|
||||
}: AgentLogNavMoreProps) => {
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
@ -40,6 +43,10 @@ const AgentLogNavMore = ({
|
||||
<div
|
||||
key={option.id}
|
||||
className='flex items-center px-2 h-8 rounded-lg system-md-regular text-text-secondary hover:bg-state-base-hover cursor-pointer'
|
||||
onClick={() => {
|
||||
onShowAgentOrToolLog(option as AgentLogItemWithChildren)
|
||||
setOpen(false)
|
||||
}}
|
||||
>
|
||||
{option.label}
|
||||
</div>
|
||||
|
@ -1,15 +1,25 @@
|
||||
import { RiArrowLeftLine } from '@remixicon/react'
|
||||
import AgentLogNavMore from './agent-log-nav-more'
|
||||
import Button from '@/app/components/base/button'
|
||||
import type { AgentLogItemWithChildren } from '@/types/workflow'
|
||||
|
||||
type AgentLogNavProps = {
|
||||
agentOrToolLogItemStack: { id: string; label: string }[]
|
||||
onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void
|
||||
}
|
||||
const AgentLogNav = ({
|
||||
agentOrToolLogItemStack,
|
||||
onShowAgentOrToolLog,
|
||||
}: AgentLogNavProps) => {
|
||||
const options = agentOrToolLogItemStack.slice(2)
|
||||
|
||||
const AgentLogNav = () => {
|
||||
return (
|
||||
<div className='flex items-center p-1 pr-3 h-8'>
|
||||
<Button
|
||||
className='shrink-0 px-[5px]'
|
||||
size='small'
|
||||
variant='ghost-accent'
|
||||
onClick={() => {}}
|
||||
onClick={() => onShowAgentOrToolLog()}
|
||||
>
|
||||
<RiArrowLeftLine className='mr-1 w-3.5 h-3.5' />
|
||||
Agent
|
||||
@ -24,10 +34,17 @@ const AgentLogNav = () => {
|
||||
<RiArrowLeftLine className='mr-1 w-3.5 h-3.5' />
|
||||
Agent strategy
|
||||
</Button>
|
||||
<div className='shrink-0 mx-0.5 system-xs-regular text-divider-deep'>/</div>
|
||||
<AgentLogNavMore
|
||||
options={[]}
|
||||
/>
|
||||
{
|
||||
!!options.length && (
|
||||
<>
|
||||
<div className='shrink-0 mx-0.5 system-xs-regular text-divider-deep'>/</div>
|
||||
<AgentLogNavMore
|
||||
options={options}
|
||||
onShowAgentOrToolLog={onShowAgentOrToolLog}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
<div className='shrink-0 mx-0.5 system-xs-regular text-divider-deep'>/</div>
|
||||
<div className='flex items-center px-[5px] system-xs-medium-uppercase text-text-tertiary'>
|
||||
Run Actions
|
||||
|
@ -6,11 +6,11 @@ import type {
|
||||
|
||||
type AgentLogTriggerProps = {
|
||||
nodeInfo: NodeTracing
|
||||
onShowAgentResultList: (agentLogs: AgentLogItemWithChildren[]) => void
|
||||
onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void
|
||||
}
|
||||
const AgentLogTrigger = ({
|
||||
nodeInfo,
|
||||
onShowAgentResultList,
|
||||
onShowAgentOrToolLog,
|
||||
}: AgentLogTriggerProps) => {
|
||||
const { agentLog } = nodeInfo
|
||||
|
||||
@ -24,7 +24,7 @@ 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={() => onShowAgentResultList(agentLog || [])}
|
||||
onClick={() => onShowAgentOrToolLog({ id: nodeInfo.id, children: agentLog || [] } as AgentLogItemWithChildren)}
|
||||
>
|
||||
Detail
|
||||
<RiArrowRightLine className='ml-0.5 w-3.5 h-3.5' />
|
||||
|
@ -3,15 +3,24 @@ import AgentLogNav from './agent-log-nav'
|
||||
import type { AgentLogItemWithChildren } from '@/types/workflow'
|
||||
|
||||
type AgentResultPanelProps = {
|
||||
list: AgentLogItemWithChildren[]
|
||||
setAgentResultList: (list: AgentLogItemWithChildren[]) => void
|
||||
agentOrToolLogItemStack: { id: string; label: string }[]
|
||||
agentOrToolLogListMap: Record<string, AgentLogItemWithChildren[]>
|
||||
onShowAgentOrToolLog: (detail?: AgentLogItemWithChildren) => void
|
||||
}
|
||||
const AgentResultPanel = ({
|
||||
list,
|
||||
agentOrToolLogItemStack,
|
||||
agentOrToolLogListMap,
|
||||
onShowAgentOrToolLog,
|
||||
}: AgentResultPanelProps) => {
|
||||
const top = agentOrToolLogItemStack[agentOrToolLogItemStack.length - 1]
|
||||
const list = agentOrToolLogListMap[top.id]
|
||||
|
||||
return (
|
||||
<div className='overflow-y-auto'>
|
||||
<AgentLogNav />
|
||||
<AgentLogNav
|
||||
agentOrToolLogItemStack={agentOrToolLogItemStack}
|
||||
onShowAgentOrToolLog={onShowAgentOrToolLog}
|
||||
/>
|
||||
{
|
||||
<div className='p-2'>
|
||||
{
|
||||
@ -19,6 +28,7 @@ const AgentResultPanel = ({
|
||||
<AgentLogItem
|
||||
key={item.id}
|
||||
item={item}
|
||||
onShowAgentOrToolLog={onShowAgentOrToolLog}
|
||||
/>
|
||||
))
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
import {
|
||||
useCallback,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react'
|
||||
import { useBoolean } from 'ahooks'
|
||||
@ -32,10 +33,38 @@ export const useLogs = () => {
|
||||
setIterationResultDurationMap(iterDurationMap)
|
||||
}, [setShowIteratingDetailTrue, setIterationResultList, setIterationResultDurationMap])
|
||||
|
||||
const [agentResultList, setAgentResultList] = useState<AgentLogItemWithChildren[]>([])
|
||||
const [agentOrToolLogItemStack, setAgentOrToolLogItemStack] = useState<{ id: string; label: string }[]>([])
|
||||
const agentOrToolLogItemStackRef = useRef(agentOrToolLogItemStack)
|
||||
const [agentOrToolLogListMap, setAgentOrToolLogListMap] = useState<Record<string, AgentLogItemWithChildren[]>>({})
|
||||
const agentOrToolLogListMapRef = useRef(agentOrToolLogListMap)
|
||||
const handleShowAgentOrToolLog = useCallback((detail?: AgentLogItemWithChildren) => {
|
||||
if (!detail) {
|
||||
setAgentOrToolLogItemStack([])
|
||||
agentOrToolLogItemStackRef.current = []
|
||||
return
|
||||
}
|
||||
const { id, label, children } = detail
|
||||
let currentAgentOrToolLogItemStack = agentOrToolLogItemStackRef.current.slice()
|
||||
const index = currentAgentOrToolLogItemStack.findIndex(logItem => logItem.id === id)
|
||||
|
||||
if (index > -1)
|
||||
currentAgentOrToolLogItemStack = currentAgentOrToolLogItemStack.slice(0, index + 1)
|
||||
else
|
||||
currentAgentOrToolLogItemStack = [...currentAgentOrToolLogItemStack.slice(), { id, label }]
|
||||
|
||||
setAgentOrToolLogItemStack(currentAgentOrToolLogItemStack)
|
||||
agentOrToolLogItemStackRef.current = currentAgentOrToolLogItemStack
|
||||
|
||||
if (children) {
|
||||
setAgentOrToolLogListMap({
|
||||
...agentOrToolLogListMapRef.current,
|
||||
[id]: children,
|
||||
})
|
||||
}
|
||||
}, [setAgentOrToolLogItemStack, setAgentOrToolLogListMap])
|
||||
|
||||
return {
|
||||
showSpecialResultPanel: showRetryDetail || showIteratingDetail || !!agentResultList.length,
|
||||
showSpecialResultPanel: showRetryDetail || showIteratingDetail || !!agentOrToolLogItemStack.length,
|
||||
showRetryDetail,
|
||||
setShowRetryDetailTrue,
|
||||
setShowRetryDetailFalse,
|
||||
@ -52,7 +81,8 @@ export const useLogs = () => {
|
||||
setIterationResultDurationMap,
|
||||
handleShowIterationResultList,
|
||||
|
||||
agentResultList,
|
||||
setAgentResultList,
|
||||
agentOrToolLogItemStack,
|
||||
agentOrToolLogListMap,
|
||||
handleShowAgentOrToolLog,
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ type Props = {
|
||||
hideProcessDetail?: boolean
|
||||
onShowIterationDetail?: (detail: NodeTracing[][], iterDurationMap: IterationDurationMap) => void
|
||||
onShowRetryDetail?: (detail: NodeTracing[]) => void
|
||||
onShowAgentResultList?: (detail: AgentLogItemWithChildren[]) => void
|
||||
onShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void
|
||||
notShowIterationNav?: boolean
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ const NodePanel: FC<Props> = ({
|
||||
hideProcessDetail,
|
||||
onShowIterationDetail,
|
||||
onShowRetryDetail,
|
||||
onShowAgentResultList,
|
||||
onShowAgentOrToolLog,
|
||||
notShowIterationNav,
|
||||
}) => {
|
||||
const [collapseState, doSetCollapseState] = useState<boolean>(true)
|
||||
@ -144,10 +144,10 @@ const NodePanel: FC<Props> = ({
|
||||
/>
|
||||
)}
|
||||
{
|
||||
isAgentNode && onShowAgentResultList && (
|
||||
isAgentNode && onShowAgentOrToolLog && (
|
||||
<AgentLogTrigger
|
||||
nodeInfo={nodeInfo}
|
||||
onShowAgentResultList={onShowAgentResultList}
|
||||
onShowAgentOrToolLog={onShowAgentOrToolLog}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -6,7 +6,10 @@ import MetaData from './meta'
|
||||
import CodeEditor from '@/app/components/workflow/nodes/_base/components/editor/code-editor'
|
||||
import { CodeLanguage } from '@/app/components/workflow/nodes/code/types'
|
||||
import ErrorHandleTip from '@/app/components/workflow/nodes/_base/components/error-handle/error-handle-tip'
|
||||
import type { NodeTracing } from '@/types/workflow'
|
||||
import type {
|
||||
AgentLogItemWithChildren,
|
||||
NodeTracing,
|
||||
} from '@/types/workflow'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import { hasRetryNode } from '@/app/components/workflow/utils'
|
||||
import { IterationLogTrigger } from '@/app/components/workflow/run/iteration-log'
|
||||
@ -31,7 +34,7 @@ type ResultPanelProps = {
|
||||
execution_metadata?: any
|
||||
handleShowIterationResultList?: (detail: NodeTracing[][], iterDurationMap: any) => void
|
||||
onShowRetryDetail?: (detail: NodeTracing[]) => void
|
||||
onShowAgentResultList?: () => void
|
||||
handleShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void
|
||||
}
|
||||
|
||||
const ResultPanel: FC<ResultPanelProps> = ({
|
||||
@ -51,7 +54,7 @@ const ResultPanel: FC<ResultPanelProps> = ({
|
||||
execution_metadata,
|
||||
handleShowIterationResultList,
|
||||
onShowRetryDetail,
|
||||
onShowAgentResultList,
|
||||
handleShowAgentOrToolLog,
|
||||
}) => {
|
||||
const { t } = useTranslation()
|
||||
const isIterationNode = nodeInfo?.node_type === BlockEnum.Iteration
|
||||
@ -87,10 +90,10 @@ const ResultPanel: FC<ResultPanelProps> = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
isAgentNode && onShowAgentResultList && (
|
||||
isAgentNode && handleShowAgentOrToolLog && (
|
||||
<AgentLogTrigger
|
||||
nodeInfo={nodeInfo}
|
||||
onShowAgentResultList={onShowAgentResultList}
|
||||
onShowAgentOrToolLog={handleShowAgentOrToolLog}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -17,8 +17,9 @@ export type SpecialResultPanelProps = {
|
||||
iterationResultList?: NodeTracing[][]
|
||||
iterationResultDurationMap?: IterationDurationMap
|
||||
|
||||
agentResultList?: AgentLogItemWithChildren[]
|
||||
setAgentResultList?: (list: AgentLogItemWithChildren[]) => void
|
||||
agentOrToolLogItemStack?: { id: string; label: string }[]
|
||||
agentOrToolLogListMap?: Record<string, AgentLogItemWithChildren[]>
|
||||
handleShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void
|
||||
}
|
||||
const SpecialResultPanel = ({
|
||||
showRetryDetail,
|
||||
@ -30,8 +31,9 @@ const SpecialResultPanel = ({
|
||||
iterationResultList,
|
||||
iterationResultDurationMap,
|
||||
|
||||
agentResultList,
|
||||
setAgentResultList,
|
||||
agentOrToolLogItemStack,
|
||||
agentOrToolLogListMap,
|
||||
handleShowAgentOrToolLog,
|
||||
}: SpecialResultPanelProps) => {
|
||||
return (
|
||||
<>
|
||||
@ -53,10 +55,11 @@ const SpecialResultPanel = ({
|
||||
)
|
||||
}
|
||||
{
|
||||
!!agentResultList?.length && setAgentResultList && (
|
||||
!!agentOrToolLogItemStack?.length && agentOrToolLogListMap && handleShowAgentOrToolLog && (
|
||||
<AgentResultPanel
|
||||
list={agentResultList}
|
||||
setAgentResultList={setAgentResultList}
|
||||
agentOrToolLogItemStack={agentOrToolLogItemStack}
|
||||
agentOrToolLogListMap={agentOrToolLogListMap}
|
||||
onShowAgentOrToolLog={handleShowAgentOrToolLog}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -79,8 +79,9 @@ const TracingPanel: FC<TracingPanelProps> = ({
|
||||
iterationResultDurationMap,
|
||||
handleShowIterationResultList,
|
||||
|
||||
agentResultList,
|
||||
setAgentResultList,
|
||||
agentOrToolLogItemStack,
|
||||
agentOrToolLogListMap,
|
||||
handleShowAgentOrToolLog,
|
||||
} = useLogs()
|
||||
|
||||
const renderNode = (node: NodeTracing) => {
|
||||
@ -136,7 +137,7 @@ const TracingPanel: FC<TracingPanelProps> = ({
|
||||
nodeInfo={node!}
|
||||
onShowIterationDetail={handleShowIterationResultList}
|
||||
onShowRetryDetail={handleShowRetryResultList}
|
||||
onShowAgentResultList={setAgentResultList}
|
||||
onShowAgentOrToolLog={handleShowAgentOrToolLog}
|
||||
hideInfo={hideNodeInfo}
|
||||
hideProcessDetail={hideNodeProcessDetail}
|
||||
/>
|
||||
@ -157,8 +158,9 @@ const TracingPanel: FC<TracingPanelProps> = ({
|
||||
iterationResultList={iterationResultList}
|
||||
iterationResultDurationMap={iterationResultDurationMap}
|
||||
|
||||
agentResultList={agentResultList}
|
||||
setAgentResultList={setAgentResultList}
|
||||
agentOrToolLogItemStack={agentOrToolLogItemStack}
|
||||
agentOrToolLogListMap={agentOrToolLogListMap}
|
||||
handleShowAgentOrToolLog={handleShowAgentOrToolLog}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
@ -3,9 +3,10 @@ import formatIterationNode from './iteration'
|
||||
import formatParallelNode from './parallel'
|
||||
import formatRetryNode from './retry'
|
||||
import formatAgentNode from './agent'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
|
||||
const formatToTracingNodeList = (list: NodeTracing[], t: any) => {
|
||||
const allItems = [...list].sort((a, b) => a.index - b.index)
|
||||
const allItems = cloneDeep([...list]).sort((a, b) => a.index - b.index)
|
||||
/*
|
||||
* First handle not change list structure node
|
||||
* Because Handle struct node will put the node in different
|
||||
|
@ -69,8 +69,10 @@ function addTitle({
|
||||
}
|
||||
|
||||
// list => group by parallel_id(parallel tree).
|
||||
const format = (list: NodeTracing[], t: any): NodeTracing[] => {
|
||||
// console.log(list)
|
||||
const format = (list: NodeTracing[], t: any, isPrint?: boolean): NodeTracing[] => {
|
||||
if (isPrint)
|
||||
console.log(list)
|
||||
|
||||
const result: NodeTracing[] = [...list]
|
||||
const parallelFirstNodeMap: Record<string, string> = {}
|
||||
// list to tree by parent_parallel_start_node_id and branch by parallel_start_node_id. Each parallel may has more than one branch.
|
||||
@ -119,6 +121,7 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
|
||||
|
||||
// append to parallel start node and after the same branch
|
||||
const parallelStartNode = result.find(item => item.node_id === parallelFirstNodeMap[parallel_id])
|
||||
|
||||
if (parallelStartNode && parallelStartNode.parallelDetail && parallelStartNode!.parallelDetail!.children) {
|
||||
const sameBranchNodesLastIndex = parallelStartNode.parallelDetail.children.findLastIndex((node) => {
|
||||
const currStartNodeId = node.parallel_start_node_id ?? node.execution_metadata?.parallel_start_node_id ?? null
|
||||
@ -153,12 +156,14 @@ const format = (list: NodeTracing[], t: any): NodeTracing[] => {
|
||||
})
|
||||
|
||||
// print node structure for debug
|
||||
// filteredInParallelSubNodes.forEach((node) => {
|
||||
// const now = Date.now()
|
||||
// console.log(`----- p: ${now} start -----`)
|
||||
// printNodeStructure(node, 0)
|
||||
// console.log(`----- p: ${now} end -----`)
|
||||
// })
|
||||
if (isPrint) {
|
||||
filteredInParallelSubNodes.forEach((node) => {
|
||||
const now = Date.now()
|
||||
console.log(`----- p: ${now} start -----`)
|
||||
printNodeStructure(node, 0)
|
||||
console.log(`----- p: ${now} end -----`)
|
||||
})
|
||||
}
|
||||
|
||||
addTitle({
|
||||
list: filteredInParallelSubNodes,
|
||||
|
Loading…
Reference in New Issue
Block a user