mirror of https://github.com/langgenius/dify.git
Merge branch 'feat/plugins' of https://github.com/langgenius/dify into feat/plugins
This commit is contained in:
commit
d78719a6f8
|
|
@ -223,7 +223,7 @@ const SettingBuiltInTool: FC<Props> = ({
|
|||
{isInfoActive ? infoUI : settingUI}
|
||||
</div>
|
||||
{!readonly && !isInfoActive && (
|
||||
<div className='mt-2 shrink-0 flex justify-end py-4 px-6 space-x-2 rounded-b-[10px] bg-gray-50 border-t border-black/5'>
|
||||
<div className='mt-2 shrink-0 flex justify-end py-4 px-6 space-x-2 rounded-b-[10px] bg-components-panel-bg border-t border-divider-regular'>
|
||||
<Button className='flex items-center h-8 !px-3 !text-[13px] font-medium !text-gray-700' onClick={onHide}>{t('common.operation.cancel')}</Button>
|
||||
<Button className='flex items-center h-8 !px-3 !text-[13px] font-medium' variant='primary' disabled={!isValid} onClick={() => onSave?.(addDefaultValue(tempSetting, formSchemas))}>{t('common.operation.save')}</Button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import { useModalContext } from '@/context/modal-context'
|
|||
import { LanguagesSupported } from '@/i18n/language'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { Plan } from '@/app/components/billing/type'
|
||||
import WorkplaceSelector from './workplace-selector'
|
||||
|
||||
export type IAppSelector = {
|
||||
isMobile: boolean
|
||||
|
|
@ -101,10 +100,6 @@ export default function AppSelector({ isMobile }: IAppSelector) {
|
|||
</div>
|
||||
</div>
|
||||
</Menu.Item>
|
||||
<div className='px-1 py-1'>
|
||||
<div className='mt-2 px-3 text-xs font-medium text-text-tertiary'>{t('common.userProfile.workspace')}</div>
|
||||
<WorkplaceSelector />
|
||||
</div>
|
||||
<div className="px-1 py-1">
|
||||
<Menu.Item>
|
||||
<Link
|
||||
|
|
|
|||
|
|
@ -148,25 +148,24 @@ export default function AccountSetting({
|
|||
show
|
||||
onClose={onCancel}
|
||||
>
|
||||
<div className='flex'>
|
||||
<div className='w-[44px] sm:w-[200px] px-[1px] py-4 sm:p-4 border border-divider-burn shrink-0 sm:shrink-1 flex flex-col items-center sm:items-start'>
|
||||
<div className='mb-8 ml-0 sm:ml-2 sm:text-base title-2xl-semi-bold text-text-primary'>{t('common.userProfile.settings')}</div>
|
||||
<div className='mx-auto max-w-[1048px] h-[100vh] flex'>
|
||||
<div className='w-[44px] sm:w-[224px] pl-4 pr-6 border-r border-divider-burn flex flex-col'>
|
||||
<div className='mt-6 mb-8 px-3 py-2 text-text-primary title-2xl-semi-bold'>{t('common.userProfile.settings')}</div>
|
||||
<div className='w-full'>
|
||||
{
|
||||
menuItems.map(menuItem => (
|
||||
<div key={menuItem.key} className='mb-2'>
|
||||
{!isCurrentWorkspaceDatasetOperator && (
|
||||
<div className='px-2 mb-[6px] sm:text-xs system-xs-medium-uppercase text-text-tertiary'>{menuItem.name}</div>
|
||||
<div className='py-2 pl-3 pb-1 mb-0.5 system-xs-medium-uppercase text-text-tertiary'>{menuItem.name}</div>
|
||||
)}
|
||||
<div>
|
||||
{
|
||||
menuItem.items.map(item => (
|
||||
<div
|
||||
key={item.key}
|
||||
className={`
|
||||
flex items-center h-[37px] mb-[2px] text-sm cursor-pointer rounded-lg
|
||||
${activeMenu === item.key ? 'system-sm-semibold text-components-menu-item-text-active bg-state-base-active' : 'system-sm-medium text-components-menu-item-text'}
|
||||
`}
|
||||
className={cn(
|
||||
'flex items-center mb-0.5 p-1 pl-3 h-[37px] text-sm cursor-pointer rounded-lg',
|
||||
activeMenu === item.key ? 'bg-state-base-active text-components-menu-item-text-active system-sm-semibold' : 'text-components-menu-item-text system-sm-medium')}
|
||||
title={item.name}
|
||||
onClick={() => setActiveMenu(item.key)}
|
||||
>
|
||||
|
|
@ -181,19 +180,17 @@ export default function AccountSetting({
|
|||
}
|
||||
</div>
|
||||
</div>
|
||||
<div ref={scrollRef} className='relative w-[824px] h-[720px] pb-4 overflow-y-auto'>
|
||||
<div className={cn('sticky top-0 px-6 py-4 flex items-center h-14 mb-4 bg-components-panel-bg title-2xl-semi-bold text-text-primary z-20', scrolled && scrolledClassName)}>
|
||||
<div className='shrink-0'>{activeItem?.name}</div>
|
||||
{
|
||||
activeItem?.description && (
|
||||
<div className='shrink-0 ml-2 text-xs text-gray-600'>{activeItem?.description}</div>
|
||||
)
|
||||
}
|
||||
<div className='grow flex justify-end'>
|
||||
<div className='z-[10] flex items-center justify-center -mr-4 p-2 cursor-pointer rounded-[10px] hover:bg-components-button-tertiary-bg' onClick={onCancel}>
|
||||
<RiCloseLine className='w-5 h-5 text-components-button-tertiary-text' />
|
||||
</div>
|
||||
</div>
|
||||
<div className='relative flex w-[824px]'>
|
||||
<div className='absolute top-6 -right-11 flex flex-col items-center z-[9999]'>
|
||||
<Button
|
||||
variant='tertiary'
|
||||
size='large'
|
||||
className='px-2'
|
||||
onClick={onCancel}
|
||||
>
|
||||
<RiCloseLine className='w-5 h-5' />
|
||||
</Button>
|
||||
<div className='mt-1 text-text-tertiary system-2xs-medium-uppercase'>ESC</div>
|
||||
</div>
|
||||
<div ref={scrollRef} className='w-full pb-4 bg-components-panel-bg overflow-y-auto'>
|
||||
<div className={cn('sticky top-0 mx-8 pt-[27px] pb-2 mb-[18px] flex items-center bg-components-panel-bg z-20', scrolled && 'border-b border-divider-regular')}>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
import React, { useMemo } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import ToolItem from '@/app/components/tools/provider/tool-item'
|
||||
import {
|
||||
useAllToolProviders,
|
||||
useBuiltinTools,
|
||||
} from '@/service/use-tools'
|
||||
import type { PluginDetail } from '@/app/components/plugins/types'
|
||||
|
||||
type Props = {
|
||||
detail: PluginDetail
|
||||
}
|
||||
|
||||
const AgentStrategyList = ({
|
||||
detail,
|
||||
}: Props) => {
|
||||
const { t } = useTranslation()
|
||||
const providerBriefInfo = detail.declaration.agent_strategy.identity
|
||||
const providerKey = `${detail.plugin_id}/${providerBriefInfo.name}`
|
||||
const { data: collectionList = [] } = useAllToolProviders()
|
||||
|
||||
const provider = useMemo(() => {
|
||||
return collectionList.find(collection => collection.name === providerKey)
|
||||
}, [collectionList, providerKey])
|
||||
const { data } = useBuiltinTools(providerKey)
|
||||
|
||||
if (!data || !provider)
|
||||
return null
|
||||
|
||||
return (
|
||||
<div className='px-4 pt-2 pb-4'>
|
||||
<div className='mb-1 py-1'>
|
||||
<div className='mb-1 h-6 flex items-center justify-between text-text-secondary system-sm-semibold-uppercase'>
|
||||
{t('plugin.detailPanel.strategyNum', { num: data.length, strategy: data.length > 1 ? 'strategies' : 'strategy' })}
|
||||
</div>
|
||||
</div>
|
||||
<div className='flex flex-col gap-2'>
|
||||
{data.map(tool => (
|
||||
<ToolItem
|
||||
key={`${detail.plugin_id}${tool.name}`}
|
||||
collection={provider}
|
||||
tool={tool}
|
||||
isBuiltIn
|
||||
isModel={false}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default AgentStrategyList
|
||||
|
|
@ -5,6 +5,7 @@ import DetailHeader from './detail-header'
|
|||
import EndpointList from './endpoint-list'
|
||||
import ActionList from './action-list'
|
||||
import ModelList from './model-list'
|
||||
import AgentStrategyList from './agent-strategy-list'
|
||||
import Drawer from '@/app/components/base/drawer'
|
||||
import type { PluginDetail } from '@/app/components/plugins/types'
|
||||
import cn from '@/utils/classnames'
|
||||
|
|
@ -48,6 +49,7 @@ const PluginDetailPanel: FC<Props> = ({
|
|||
/>
|
||||
<div className='grow overflow-y-auto'>
|
||||
{!!detail.declaration.tool && <ActionList detail={detail} />}
|
||||
{!!detail.declaration.agent_strategy && <AgentStrategyList detail={detail} />}
|
||||
{!!detail.declaration.endpoint && <EndpointList detail={detail} />}
|
||||
{!!detail.declaration.model && <ModelList detail={detail} />}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -69,8 +69,9 @@ export type PluginDeclaration = {
|
|||
verified: boolean
|
||||
endpoint: PluginEndpointDeclaration
|
||||
tool: PluginToolDeclaration
|
||||
model: any // TODO
|
||||
model: any
|
||||
tags: string[]
|
||||
agent_strategy: any
|
||||
}
|
||||
|
||||
export type PluginManifestInMarket = {
|
||||
|
|
@ -374,3 +375,47 @@ export type VersionProps = {
|
|||
installedVersion?: string
|
||||
toInstallVersion: string
|
||||
}
|
||||
|
||||
export type StrategyParamItem = {
|
||||
name: string
|
||||
label: Record<Locale, string>
|
||||
placeholder: Record<Locale, string>
|
||||
type: string
|
||||
scope: string
|
||||
required: boolean
|
||||
default: any
|
||||
options: any[]
|
||||
}
|
||||
|
||||
export type StrategyDetail = {
|
||||
identity: {
|
||||
author: string
|
||||
name: string
|
||||
icon: string
|
||||
label: Record<Locale, string>
|
||||
provider: string
|
||||
},
|
||||
parameters: StrategyParamItem[]
|
||||
description: Record<Locale, string>
|
||||
output_schema: Record<string, any>
|
||||
}
|
||||
|
||||
export type StrategyDeclaration = {
|
||||
identity: {
|
||||
author: string
|
||||
name: string
|
||||
description: Record<Locale, string>
|
||||
icon: string
|
||||
label: Record<Locale, string>
|
||||
tags: string[]
|
||||
},
|
||||
plugin_id: string
|
||||
strategies: StrategyDetail[]
|
||||
}
|
||||
|
||||
export type StrategyPluginDetail = {
|
||||
provider: string
|
||||
plugin_unique_identifier: string
|
||||
plugin_id: string
|
||||
declaration: StrategyDeclaration
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import { fetchRunDetail, fetchTracingList } from '@/service/log'
|
|||
import type { IterationDurationMap, NodeTracing } from '@/types/workflow'
|
||||
import type { WorkflowRunDetailResponse } from '@/models/log'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import formatNodeList from './utils/format-to-tracing-node-list'
|
||||
import formatNodeList from './utils/format-log'
|
||||
export type RunProps = {
|
||||
hideResult?: boolean
|
||||
activeTab?: 'RESULT' | 'DETAIL' | 'TRACING'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import type { NodeTracing } from '@/types/workflow'
|
||||
import { BlockEnum } from '../../types'
|
||||
import { BlockEnum } from '../../../types'
|
||||
|
||||
type IterationNodeId = string
|
||||
type RunIndex = string
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import formatToTracingNodeList from '.'
|
||||
import { simpleIterationData } from '../spec-test-data'
|
||||
|
||||
describe('format api data to tracing panel data', () => {
|
||||
test('iteration should put nodes in details', () => {
|
||||
expect(formatToTracingNodeList(simpleIterationData.in as any)).toEqual(simpleIterationData.output)
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
import type { NodeTracing } from '@/types/workflow'
|
||||
import { BlockEnum } from '../../../types'
|
||||
|
||||
type IterationNodeId = string
|
||||
type RunIndex = string
|
||||
type IterationGroupMap = Map<IterationNodeId, Map<RunIndex, NodeTracing[]>>
|
||||
|
||||
const processIterationNode = (item: NodeTracing) => {
|
||||
return {
|
||||
...item,
|
||||
details: [], // to add the sub nodes in the iteration
|
||||
}
|
||||
}
|
||||
|
||||
const updateParallelModeGroup = (nodeGroupMap: IterationGroupMap, runIndex: string, item: NodeTracing, iterationNode: NodeTracing) => {
|
||||
if (!nodeGroupMap.has(iterationNode.node_id))
|
||||
nodeGroupMap.set(iterationNode.node_id, new Map())
|
||||
|
||||
const groupMap = nodeGroupMap.get(iterationNode.node_id)!
|
||||
|
||||
if (!groupMap.has(runIndex))
|
||||
groupMap.set(runIndex, [item])
|
||||
|
||||
else
|
||||
groupMap.get(runIndex)!.push(item)
|
||||
|
||||
if (item.status === 'failed') {
|
||||
iterationNode.status = 'failed'
|
||||
iterationNode.error = item.error
|
||||
}
|
||||
|
||||
iterationNode.details = Array.from(groupMap.values())
|
||||
}
|
||||
|
||||
const updateSequentialModeGroup = (runIndex: number, item: NodeTracing, iterationNode: NodeTracing) => {
|
||||
const { details } = iterationNode
|
||||
if (details) {
|
||||
if (!details[runIndex])
|
||||
details[runIndex] = [item]
|
||||
else
|
||||
details[runIndex].push(item)
|
||||
}
|
||||
|
||||
if (item.status === 'failed') {
|
||||
iterationNode.status = 'failed'
|
||||
iterationNode.error = item.error
|
||||
}
|
||||
}
|
||||
|
||||
const addRetryDetail = (result: NodeTracing[], item: NodeTracing) => {
|
||||
const retryNode = result.find(node => node.node_id === item.node_id)
|
||||
|
||||
if (retryNode) {
|
||||
if (retryNode?.retryDetail)
|
||||
retryNode.retryDetail.push(item)
|
||||
else
|
||||
retryNode.retryDetail = [item]
|
||||
}
|
||||
}
|
||||
|
||||
const processNonIterationNode = (result: NodeTracing[], nodeGroupMap: IterationGroupMap, item: NodeTracing) => {
|
||||
const { execution_metadata } = item
|
||||
if (!execution_metadata?.iteration_id) {
|
||||
if (item.status === 'retry') {
|
||||
addRetryDetail(result, item)
|
||||
return
|
||||
}
|
||||
result.push(item)
|
||||
return
|
||||
}
|
||||
|
||||
const parentIterationNode = result.find(node => node.node_id === execution_metadata.iteration_id)
|
||||
const isInIteration = !!parentIterationNode && Array.isArray(parentIterationNode.details)
|
||||
if (!isInIteration)
|
||||
return
|
||||
|
||||
// the parallel in the iteration in mode.
|
||||
const { parallel_mode_run_id, iteration_index = 0 } = execution_metadata
|
||||
const isInParallel = !!parallel_mode_run_id
|
||||
|
||||
if (isInParallel)
|
||||
updateParallelModeGroup(nodeGroupMap, parallel_mode_run_id, item, parentIterationNode)
|
||||
else
|
||||
updateSequentialModeGroup(iteration_index, item, parentIterationNode)
|
||||
}
|
||||
|
||||
// list => tree. Put the iteration node's children into the details field.
|
||||
const formatToTracingNodeList = (list: NodeTracing[]) => {
|
||||
const allItems = [...list].reverse()
|
||||
const result: NodeTracing[] = []
|
||||
const iterationGroupMap = new Map<string, Map<string, NodeTracing[]>>()
|
||||
|
||||
allItems.forEach((item) => {
|
||||
item.node_type === BlockEnum.Iteration
|
||||
? result.push(processIterationNode(item))
|
||||
: processNonIterationNode(result, iterationGroupMap, item)
|
||||
})
|
||||
|
||||
// console.log(allItems)
|
||||
// console.log(result)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export default formatToTracingNodeList
|
||||
|
|
@ -0,0 +1,481 @@
|
|||
export const simpleIterationData = {
|
||||
// start -> code(output: [1, 2, 3]) -> iteration(output: ['aaa', 'aaa', 'aaa']) -> end(output: ['aaa', 'aaa', 'aaa'])
|
||||
in: [
|
||||
{
|
||||
id: '36c9860a-39e6-4107-b750-655b07895f47',
|
||||
index: 1,
|
||||
predecessor_node_id: null,
|
||||
node_id: '1735023354069',
|
||||
node_type: 'start',
|
||||
title: 'Start',
|
||||
inputs: {
|
||||
'sys.files': [],
|
||||
'sys.user_id': '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
'sys.app_id': '8a5e87f8-6433-40f4-a67a-4be78a558dc7',
|
||||
'sys.workflow_id': 'bb5e2b89-40ac-45c9-9ccb-4f2cd926e080',
|
||||
'sys.workflow_run_id': '76adf675-a7d3-4cc1-9282-ed7ecfe4f65d',
|
||||
},
|
||||
process_data: null,
|
||||
outputs: {
|
||||
'sys.files': [],
|
||||
'sys.user_id': '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
'sys.app_id': '8a5e87f8-6433-40f4-a67a-4be78a558dc7',
|
||||
'sys.workflow_id': 'bb5e2b89-40ac-45c9-9ccb-4f2cd926e080',
|
||||
'sys.workflow_run_id': '76adf675-a7d3-4cc1-9282-ed7ecfe4f65d',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.011458,
|
||||
execution_metadata: null,
|
||||
extras: {},
|
||||
created_at: 1735023510,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023510,
|
||||
},
|
||||
{
|
||||
id: 'a3105c5d-ff9e-44ea-9f4c-ab428958af20',
|
||||
index: 2,
|
||||
predecessor_node_id: '1735023354069',
|
||||
node_id: '1735023361224',
|
||||
node_type: 'code',
|
||||
title: 'Code',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
],
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.103333,
|
||||
execution_metadata: null,
|
||||
extras: {},
|
||||
created_at: 1735023510,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
{
|
||||
id: 'a823134d-9f1a-45a4-8977-db838d076316',
|
||||
index: 3,
|
||||
predecessor_node_id: '1735023361224',
|
||||
node_id: '1735023391914',
|
||||
node_type: 'iteration',
|
||||
title: 'Iteration',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
output: [
|
||||
'aaa',
|
||||
'aaa',
|
||||
'aaa',
|
||||
],
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.408383,
|
||||
execution_metadata: {
|
||||
iteration_duration_map: {
|
||||
0: 0.118153,
|
||||
1: 0.135956,
|
||||
2: 0.128251,
|
||||
},
|
||||
total_tokens: 0,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
{
|
||||
id: 'a84a22d8-0f08-4006-bee2-fa7a7aef0420',
|
||||
index: 4,
|
||||
predecessor_node_id: '1735023391914start',
|
||||
node_id: '1735023409906',
|
||||
node_type: 'code',
|
||||
title: 'Code 2',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: 'aaa',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.112688,
|
||||
execution_metadata: {
|
||||
iteration_id: '1735023391914',
|
||||
iteration_index: 0,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
{
|
||||
id: 'ff71d773-a916-4513-960f-d7dcc4fadd86',
|
||||
index: 5,
|
||||
predecessor_node_id: '1735023391914start',
|
||||
node_id: '1735023409906',
|
||||
node_type: 'code',
|
||||
title: 'Code 2',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: 'aaa',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.126034,
|
||||
execution_metadata: {
|
||||
iteration_id: '1735023391914',
|
||||
iteration_index: 1,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
{
|
||||
id: 'd91c3ef9-0162-4013-9272-d4cc7fb1f188',
|
||||
index: 6,
|
||||
predecessor_node_id: '1735023391914start',
|
||||
node_id: '1735023409906',
|
||||
node_type: 'code',
|
||||
title: 'Code 2',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: 'aaa',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.122716,
|
||||
execution_metadata: {
|
||||
iteration_id: '1735023391914',
|
||||
iteration_index: 2,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
{
|
||||
id: 'e6ad6560-1aa3-43f3-89e3-e5287c9ea272',
|
||||
index: 7,
|
||||
predecessor_node_id: '1735023391914',
|
||||
node_id: '1735023417757',
|
||||
node_type: 'end',
|
||||
title: 'End',
|
||||
inputs: {
|
||||
output: [
|
||||
'aaa',
|
||||
'aaa',
|
||||
'aaa',
|
||||
],
|
||||
},
|
||||
process_data: null,
|
||||
outputs: {
|
||||
output: [
|
||||
'aaa',
|
||||
'aaa',
|
||||
'aaa',
|
||||
],
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.017552,
|
||||
execution_metadata: null,
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
],
|
||||
output: [
|
||||
{
|
||||
id: '36c9860a-39e6-4107-b750-655b07895f47',
|
||||
index: 1,
|
||||
predecessor_node_id: null,
|
||||
node_id: '1735023354069',
|
||||
node_type: 'start',
|
||||
title: 'Start',
|
||||
inputs: {
|
||||
'sys.files': [],
|
||||
'sys.user_id': '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
'sys.app_id': '8a5e87f8-6433-40f4-a67a-4be78a558dc7',
|
||||
'sys.workflow_id': 'bb5e2b89-40ac-45c9-9ccb-4f2cd926e080',
|
||||
'sys.workflow_run_id': '76adf675-a7d3-4cc1-9282-ed7ecfe4f65d',
|
||||
},
|
||||
process_data: null,
|
||||
outputs: {
|
||||
'sys.files': [],
|
||||
'sys.user_id': '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
'sys.app_id': '8a5e87f8-6433-40f4-a67a-4be78a558dc7',
|
||||
'sys.workflow_id': 'bb5e2b89-40ac-45c9-9ccb-4f2cd926e080',
|
||||
'sys.workflow_run_id': '76adf675-a7d3-4cc1-9282-ed7ecfe4f65d',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.011458,
|
||||
execution_metadata: null,
|
||||
extras: {},
|
||||
created_at: 1735023510,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023510,
|
||||
},
|
||||
{
|
||||
id: 'a3105c5d-ff9e-44ea-9f4c-ab428958af20',
|
||||
index: 2,
|
||||
predecessor_node_id: '1735023354069',
|
||||
node_id: '1735023361224',
|
||||
node_type: 'code',
|
||||
title: 'Code',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: [
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
],
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.103333,
|
||||
execution_metadata: null,
|
||||
extras: {},
|
||||
created_at: 1735023510,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
{
|
||||
id: 'a823134d-9f1a-45a4-8977-db838d076316',
|
||||
index: 3,
|
||||
predecessor_node_id: '1735023361224',
|
||||
node_id: '1735023391914',
|
||||
node_type: 'iteration',
|
||||
title: 'Iteration',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
output: [
|
||||
'aaa',
|
||||
'aaa',
|
||||
'aaa',
|
||||
],
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.408383,
|
||||
execution_metadata: {
|
||||
iteration_duration_map: {
|
||||
0: 0.118153,
|
||||
1: 0.135956,
|
||||
2: 0.128251,
|
||||
},
|
||||
total_tokens: 0,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
details: [
|
||||
[
|
||||
{
|
||||
id: 'a84a22d8-0f08-4006-bee2-fa7a7aef0420',
|
||||
index: 4,
|
||||
predecessor_node_id: '1735023391914start',
|
||||
node_id: '1735023409906',
|
||||
node_type: 'code',
|
||||
title: 'Code 2',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: 'aaa',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.112688,
|
||||
execution_metadata: {
|
||||
iteration_id: '1735023391914',
|
||||
iteration_index: 0,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
id: 'ff71d773-a916-4513-960f-d7dcc4fadd86',
|
||||
index: 5,
|
||||
predecessor_node_id: '1735023391914start',
|
||||
node_id: '1735023409906',
|
||||
node_type: 'code',
|
||||
title: 'Code 2',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: 'aaa',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.126034,
|
||||
execution_metadata: {
|
||||
iteration_id: '1735023391914',
|
||||
iteration_index: 1,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
id: 'd91c3ef9-0162-4013-9272-d4cc7fb1f188',
|
||||
index: 6,
|
||||
predecessor_node_id: '1735023391914start',
|
||||
node_id: '1735023409906',
|
||||
node_type: 'code',
|
||||
title: 'Code 2',
|
||||
inputs: null,
|
||||
process_data: null,
|
||||
outputs: {
|
||||
result: 'aaa',
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.122716,
|
||||
execution_metadata: {
|
||||
iteration_id: '1735023391914',
|
||||
iteration_index: 2,
|
||||
},
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
],
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'e6ad6560-1aa3-43f3-89e3-e5287c9ea272',
|
||||
index: 7,
|
||||
predecessor_node_id: '1735023391914',
|
||||
node_id: '1735023417757',
|
||||
node_type: 'end',
|
||||
title: 'End',
|
||||
inputs: {
|
||||
output: [
|
||||
'aaa',
|
||||
'aaa',
|
||||
'aaa',
|
||||
],
|
||||
},
|
||||
process_data: null,
|
||||
outputs: {
|
||||
output: [
|
||||
'aaa',
|
||||
'aaa',
|
||||
'aaa',
|
||||
],
|
||||
},
|
||||
status: 'succeeded',
|
||||
error: null,
|
||||
elapsed_time: 0.017552,
|
||||
execution_metadata: null,
|
||||
extras: {},
|
||||
created_at: 1735023511,
|
||||
created_by_role: 'account',
|
||||
created_by_account: {
|
||||
id: '5ee03762-1d1a-46e8-ba0b-5f419a77da96',
|
||||
name: 'Joel',
|
||||
email: 'iamjoel007@gmail.com',
|
||||
},
|
||||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
],
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import format from '.'
|
||||
import { simpleIterationData } from './data'
|
||||
|
||||
describe('format api data to tracing panel data', () => {
|
||||
test('iteration should put nodes in details', () => {
|
||||
// console.log(format(simpleIterationData.in as any))
|
||||
expect(format(simpleIterationData.in as any)).toEqual(simpleIterationData.output)
|
||||
})
|
||||
})
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import type { NodeTracing } from '@/types/workflow'
|
||||
|
||||
function addChildrenToIterationNode(iterationNode: NodeTracing, childrenNodes: NodeTracing[]): NodeTracing {
|
||||
const details: NodeTracing[][] = []
|
||||
childrenNodes.forEach((item) => {
|
||||
if (!item.execution_metadata) return
|
||||
const { parallel_mode_run_id, iteration_index = 0 } = item.execution_metadata
|
||||
const runIndex: number = (parallel_mode_run_id || iteration_index) as number
|
||||
if (!details[runIndex])
|
||||
details[runIndex] = []
|
||||
|
||||
details[runIndex].push(item)
|
||||
})
|
||||
return {
|
||||
...iterationNode,
|
||||
details,
|
||||
}
|
||||
}
|
||||
|
||||
const format = (list: NodeTracing[]): NodeTracing[] => {
|
||||
const iterationNodeIds = list
|
||||
.filter(item => item.node_type === BlockEnum.Iteration)
|
||||
.map(item => item.node_id)
|
||||
const iterationChildrenNodeIds = list
|
||||
.filter(item => item.execution_metadata?.iteration_id && iterationNodeIds.includes(item.execution_metadata.iteration_id))
|
||||
.map(item => item.node_id)
|
||||
// move iteration children nodes to iteration node's details field
|
||||
const result = list
|
||||
.filter(item => !iterationChildrenNodeIds.includes(item.node_id))
|
||||
.map((item) => {
|
||||
if (item.node_type === BlockEnum.Iteration) {
|
||||
const childrenNodes = list.filter(child => child.execution_metadata?.iteration_id === item.node_id)
|
||||
return addChildrenToIterationNode(item, childrenNodes)
|
||||
}
|
||||
|
||||
return item
|
||||
})
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export default format
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
import formatToTracingNodeList from './format-to-tracing-node-list'
|
||||
import { simpleIterationData } from './spec-test-data'
|
||||
|
||||
describe('format api data to tracing panel data', () => {
|
||||
test('iteration should put nodes in details', () => {
|
||||
expect(formatToTracingNodeList(simpleIterationData.in)).toEqual(simpleIterationData.out)
|
||||
})
|
||||
})
|
||||
|
|
@ -234,7 +234,7 @@ export const simpleIterationData = {
|
|||
created_by_end_user: null,
|
||||
finished_at: 1735023511,
|
||||
},
|
||||
],
|
||||
].reverse(),
|
||||
output: [
|
||||
{
|
||||
id: '36c9860a-39e6-4107-b750-655b07895f47',
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ const translation = {
|
|||
remove: 'Remove',
|
||||
},
|
||||
actionNum: '{{num}} {{action}} INCLUDED',
|
||||
strategyNum: '{{num}} {{strategy}} INCLUDED',
|
||||
endpoints: 'Endpoints',
|
||||
endpointsTip: 'This plugin provides specific functionalities via endpoints, and you can configure multiple endpoint sets for current workspace.',
|
||||
endpointsDocLink: 'View the document',
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ const translation = {
|
|||
remove: '移除',
|
||||
},
|
||||
actionNum: '包含 {{num}} 个 {{action}}',
|
||||
strategyNum: '包含 {{num}} 个 {{strategy}}',
|
||||
endpoints: 'API 端点',
|
||||
endpointsTip: '此插件通过 API 端点提供特定功能,您可以为当前工作区配置多个 API 端点集。',
|
||||
endpointsDocLink: '查看文档',
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
import { get } from './base'
|
||||
import type {
|
||||
StrategyPluginDetail,
|
||||
} from '@/app/components/plugins/types'
|
||||
import { useInvalid } from './use-base'
|
||||
import {
|
||||
useQuery,
|
||||
} from '@tanstack/react-query'
|
||||
|
||||
const NAME_SPACE = 'agent-strategy'
|
||||
|
||||
const useStrategyListKey = [NAME_SPACE, 'strategyList']
|
||||
export const useStrategyProviders = () => {
|
||||
return useQuery<StrategyPluginDetail[]>({
|
||||
queryKey: useStrategyListKey,
|
||||
queryFn: () => get<StrategyPluginDetail[]>('/workspaces/current/agent-providers'),
|
||||
})
|
||||
}
|
||||
|
||||
export const useInvalidateStrategyProviders = () => {
|
||||
return useInvalid(useStrategyListKey)
|
||||
}
|
||||
|
||||
export const useStrategyProviderDetail = (agentProvider: string) => {
|
||||
return useQuery<StrategyPluginDetail>({
|
||||
queryKey: [NAME_SPACE, 'detail', agentProvider],
|
||||
queryFn: () => get<StrategyPluginDetail>(`/workspaces/current/agent-providers/${agentProvider}`),
|
||||
})
|
||||
}
|
||||
|
||||
export const useInvalidateStrategyProviderDetail = (agentProvider: string) => {
|
||||
return useInvalid([NAME_SPACE, 'detail', agentProvider])
|
||||
}
|
||||
7740
web/yarn.lock
7740
web/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue