mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
fix: llm logs
This commit is contained in:
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 (
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user