fix: llm logs

This commit is contained in:
zxhlyh
2026-03-06 18:04:18 +08:00
parent e0794020f7
commit 52dd4b82e6
8 changed files with 256 additions and 6 deletions

View File

@ -85,9 +85,12 @@ export const useLogs = () => {
setFalse: setShowLLMDetailFalse,
}] = useBoolean(false)
const [llmResultList, setLLMResultList] = useState<LLMTraceItem[]>([])
const handleShowLLMDetail = useCallback((detail: LLMTraceItem[]) => {
const [llmDetailNodeId, setLLMDetailNodeId] = useState('')
const handleShowLLMDetail = useCallback((detail: LLMTraceItem[], nodeId?: string) => {
setShowLLMDetailTrue()
setLLMResultList(detail)
if (nodeId)
setLLMDetailNodeId(nodeId)
}, [setShowLLMDetailTrue, setLLMResultList])
return {
@ -128,6 +131,7 @@ export const useLogs = () => {
setShowLLMDetailFalse,
llmResultList,
setLLMResultList,
llmDetailNodeId,
handleShowLLMDetail,
}
}

View File

@ -8,7 +8,7 @@ import { Thinking } from '@/app/components/base/icons/src/vender/workflow'
type LLMLogTriggerProps = {
nodeInfo: NodeTracing
onShowLLMDetail: (detail: LLMTraceItem[]) => void
onShowLLMDetail: (detail: LLMTraceItem[], nodeId?: string) => void
}
const LLMLogTrigger = ({
nodeInfo,
@ -20,7 +20,7 @@ const LLMLogTrigger = ({
const handleShowLLMDetail = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation()
e.nativeEvent.stopImmediatePropagation()
onShowLLMDetail(llmTrace || [])
onShowLLMDetail(llmTrace || [], nodeInfo.node_id)
}
return (

View File

@ -46,7 +46,7 @@ type Props = {
onShowLoopDetail?: (detail: NodeTracing[][], loopDurationMap: LoopDurationMap, loopVariableMap: LoopVariableMap) => void
onShowRetryDetail?: (detail: NodeTracing[]) => void
onShowAgentOrToolLog?: (detail?: AgentLogItemWithChildren) => void
onShowLLMDetail?: (detail: LLMTraceItem[]) => void
onShowLLMDetail?: (detail: LLMTraceItem[], nodeId?: string) => void
notShowIterationNav?: boolean
notShowLoopNav?: boolean
}

View File

@ -8,6 +8,7 @@ import {
import * as React from 'react'
import {
useCallback,
useMemo,
useState,
} from 'react'
import { useTranslation } from 'react-i18next'
@ -95,9 +96,17 @@ const TracingPanel: FC<TracingPanelProps> = ({
showLLMDetail,
setShowLLMDetailFalse,
llmResultList,
llmDetailNodeId,
handleShowLLMDetail,
} = useLogs()
const liveLLMResultList = useMemo(() => {
if (!showLLMDetail || !llmDetailNodeId)
return llmResultList
const node = list.find(n => n.node_id === llmDetailNodeId)
return node?.execution_metadata?.llm_trace || llmResultList
}, [showLLMDetail, llmDetailNodeId, list, llmResultList])
const renderNode = (node: NodeTracing) => {
const isParallelFirstNode = !!node.parallelDetail?.isParallelStartNode
if (isParallelFirstNode) {
@ -191,7 +200,7 @@ const TracingPanel: FC<TracingPanelProps> = ({
showLLMDetail={showLLMDetail}
setShowLLMDetailFalse={setShowLLMDetailFalse}
llmResultList={llmResultList}
llmResultList={liveLLMResultList}
/>
)
}