From 60e62a15e4a1aefbaca340d1fb2edc81f7c39abc Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Fri, 28 Feb 2025 11:34:49 -0800 Subject: [PATCH] ui with traceback of error --- .../src/components/view_logs/ErrorViewer.tsx | 82 +++++++++++++++---- 1 file changed, 64 insertions(+), 18 deletions(-) diff --git a/ui/litellm-dashboard/src/components/view_logs/ErrorViewer.tsx b/ui/litellm-dashboard/src/components/view_logs/ErrorViewer.tsx index 0b0fcb6316e..8ada7d2da8a 100644 --- a/ui/litellm-dashboard/src/components/view_logs/ErrorViewer.tsx +++ b/ui/litellm-dashboard/src/components/view_logs/ErrorViewer.tsx @@ -12,6 +12,31 @@ interface ErrorViewerProps { } export const ErrorViewer: React.FC = ({ errorInfo }) => { + const [expandedFrames, setExpandedFrames] = React.useState<{[key: number]: boolean}>({}); + const [allExpanded, setAllExpanded] = React.useState(false); + + // Toggle individual frame + const toggleFrame = (index: number) => { + setExpandedFrames(prev => ({ + ...prev, + [index]: !prev[index] + })); + }; + + // Toggle all frames + const toggleAllFrames = () => { + const newState = !allExpanded; + setAllExpanded(newState); + + if (tracebackFrames.length > 0) { + const newExpandedState: {[key: number]: boolean} = {}; + tracebackFrames.forEach((_, idx) => { + newExpandedState[idx] = newState; + }); + setExpandedFrames(newExpandedState); + } + }; + // Parse traceback into frames const parseTraceback = (traceback: string) => { if (!traceback) return []; @@ -81,29 +106,50 @@ export const ErrorViewer: React.FC = ({ errorInfo }) => {

Traceback

- +
+ + +
{tracebackFrames.map((frame, index) => ( -
-
- {frame.lineNumber} - {frame.fileName} - in - {frame.inFunction || frame.fileName} +
+
toggleFrame(index)} + > +
+ {frame.lineNumber} + {frame.fileName} + in + {frame.inFunction || frame.fileName} +
+ + +
- {frame.code && ( + {(expandedFrames[index] || false) && frame.code && (
{frame.code}