Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
93d116a9
Commit
93d116a9
authored
Mar 02, 2024
by
JzoNg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tracing panel
parent
7b2499c2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
109 additions
and
7 deletions
+109
-7
detail.tsx
web/app/components/app/workflow-log/detail.tsx
+1
-1
node.tsx
web/app/components/workflow/run/node.tsx
+90
-0
tracing.tsx
web/app/components/workflow/run/tracing.tsx
+18
-6
No files found.
web/app/components/app/workflow-log/detail.tsx
View file @
93d116a9
...
@@ -19,7 +19,7 @@ const DetailPanel: FC<ILogDetail> = ({ appDetail, onClose }) => {
...
@@ -19,7 +19,7 @@ const DetailPanel: FC<ILogDetail> = ({ appDetail, onClose }) => {
<
XClose
className=
'w-4 h-4 text-gray-500'
/>
<
XClose
className=
'w-4 h-4 text-gray-500'
/>
</
span
>
</
span
>
<
h1
className=
'shrink-0 px-4 py-1 text-md font-semibold text-gray-900'
>
{
t
(
'appLog.runDetail.workflowTitle'
)
}
</
h1
>
<
h1
className=
'shrink-0 px-4 py-1 text-md font-semibold text-gray-900'
>
{
t
(
'appLog.runDetail.workflowTitle'
)
}
</
h1
>
<
Run
activeTab=
'
RESULT
'
appId=
{
appDetail
?.
id
||
''
}
></
Run
>
<
Run
activeTab=
'
TRACING
'
appId=
{
appDetail
?.
id
||
''
}
></
Run
>
</
div
>
</
div
>
)
)
}
}
...
...
web/app/components/workflow/run/node.tsx
0 → 100644
View file @
93d116a9
'use client'
import
type
{
FC
}
from
'react'
import
cn
from
'classnames'
import
BlockIcon
from
'../block-icon'
import
type
{
BlockEnum
}
from
'../types'
import
{
AlertTriangle
}
from
'@/app/components/base/icons/src/vender/line/alertsAndFeedback'
import
{
CheckCircle
,
Loading02
}
from
'@/app/components/base/icons/src/vender/line/general'
import
{
ChevronRight
}
from
'@/app/components/base/icons/src/vender/line/arrows'
export
type
NodeInfo
=
{
type
:
BlockEnum
title
:
string
time
:
number
tokens
:
number
status
:
string
error
?:
string
}
type
Props
=
{
nodeInfo
:
NodeInfo
collapsed
:
boolean
collapseHandle
:
()
=>
void
}
const
NodePanel
:
FC
<
Props
>
=
({
nodeInfo
,
collapsed
,
collapseHandle
})
=>
{
const
getTime
=
(
time
:
number
)
=>
{
if
(
time
<
1
)
return
`
${
time
*
1000
}
ms`
if
(
time
>
60
)
return
`
${
parseInt
(
Math
.
round
(
time
/
60
).
toString
())}
m
${(
time
%
60
).
toFixed
(
3
)}
s`
}
const
getTokenCount
=
(
tokens
:
number
)
=>
{
if
(
tokens
<
1000
)
return
tokens
if
(
tokens
>=
1000
&&
tokens
<
1000000
)
return
`
${
parseFloat
((
tokens
/
1000
).
toFixed
(
3
))}
K`
if
(
tokens
>=
1000000
)
return
`
${
parseFloat
((
tokens
/
1000000
).
toFixed
(
3
))}
M`
}
return
(
<
div
className=
'px-4 py-1'
>
<
div
className=
'group transition-all bg-white border border-gray-100 rounded-2xl shadow-xs cursor-pointer hover:shadow-md'
onClick=
{
collapseHandle
}
>
<
div
className=
{
cn
(
'flex items-center pl-[6px] py-3 pr-3'
,
!
collapsed
&&
'pb-2'
,
)
}
>
<
ChevronRight
className=
{
cn
(
'shrink-0 w-3 h-3 mr-1 text-gray-400 transition-all group-hover:text-gray-500'
,
!
collapsed
&&
'rotate-90'
,
)
}
/>
<
BlockIcon
className=
'shrink-0 mr-2'
type=
{
nodeInfo
.
type
}
/>
<
div
className=
'grow text-gray-700 text-[13px] leading-[16px] font-semibold truncate'
title=
{
nodeInfo
.
title
}
>
{
nodeInfo
.
title
}
</
div
>
<
div
className=
'shrink-0 text-gray-500 text-xs leading-[18px]'
>
{
`${getTime(nodeInfo.time)} · ${getTokenCount(nodeInfo.tokens)} tokens`
}
</
div
>
{
nodeInfo
.
status
===
'succeeded'
&&
(
<
CheckCircle
className=
'shrink-0 ml-2 w-3.5 h-3.5 text-[#12B76A]'
/>
)
}
{
nodeInfo
.
status
===
'failed'
&&
(
<
AlertTriangle
className=
'shrink-0 ml-2 w-3 h-3 text-[#F79009]'
/>
)
}
{
nodeInfo
.
status
===
'stopped'
&&
(
<
AlertTriangle
className=
'shrink-0 ml-2 w-3 h-3 text-[#F79009]'
/>
)
}
{
nodeInfo
.
status
===
'running'
&&
(
<
div
className=
'shrink-0 text-primary-600 text-[13px] leading-[16px] font-medium'
>
<
Loading02
className=
'mr-1 w-3.5 h-3.5 animate-spin'
/>
<
span
>
Running
</
span
>
</
div
>
)
}
</
div
>
{
!
collapsed
&&
(
<
div
className=
'pb-2'
>
{
/* TODO */
}
<
div
className=
'px-[10px] py-1'
>
<
div
className=
'p-3 bg-gray-50 rounded-lg h-[120px] text-gray-700'
>
INPUT
</
div
>
</
div
>
<
div
className=
'px-[10px] py-1'
>
<
div
className=
'p-3 bg-gray-50 rounded-lg h-[120px] text-gray-700'
>
OUPUT
</
div
>
</
div
>
</
div
>
)
}
</
div
>
</
div
>
)
}
export
default
NodePanel
web/app/components/workflow/run/tracing.tsx
View file @
93d116a9
'use client'
'use client'
import
type
{
FC
}
from
'react'
import
type
{
FC
}
from
'react'
//
import React, { useState } from 'react'
import
React
,
{
useState
}
from
'react'
import
{
useTranslation
}
from
'react-i18next'
import
{
useTranslation
}
from
'react-i18next'
// import cn from 'classnames'
// import cn from 'classnames'
// import Loading from '@/app/components/base/loading
'
import
{
BlockEnum
}
from
'../types
'
// import Indicator from '@/app/components/header/indicator
'
import
NodePanel
from
'./node
'
type
TracingProps
=
{
type
TracingProps
=
{
appId
:
string
appId
:
string
}
}
const
nodeInfoFake
=
{
type
:
BlockEnum
.
Start
,
title
:
'START'
,
time
:
67.349
,
tokens
:
2708
,
status
:
'succeeded'
,
}
const
Tracing
:
FC
<
TracingProps
>
=
({
appId
})
=>
{
const
Tracing
:
FC
<
TracingProps
>
=
({
appId
})
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
// const [currentTab, setCurrentTab] = useState<string>(activeTab)
const
[
nodeCollapsed
,
setCurrentTab
]
=
useState
<
boolean
>
(
false
)
const
collapseStateChange
=
()
=>
{
setCurrentTab
(
!
nodeCollapsed
)
}
return
(
return
(
<
div
className=
'bg-gray-50'
>
<
div
className=
'bg-gray-50
py-2
'
>
Tracing panel = TODO
<
NodePanel
nodeInfo=
{
nodeInfoFake
}
collapsed=
{
nodeCollapsed
}
collapseHandle=
{
collapseStateChange
}
/>
</
div
>
</
div
>
)
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment