diff --git a/frontend/src/routes/_layout.tsx b/frontend/src/routes/_layout.tsx index b6f85a1..2f19b4b 100644 --- a/frontend/src/routes/_layout.tsx +++ b/frontend/src/routes/_layout.tsx @@ -20,7 +20,7 @@ function Layout() { const { isLoading } = useAuth() return ( - + {isLoading ? ( diff --git a/frontend/src/routes/_layout/events.tsx b/frontend/src/routes/_layout/events.tsx index 002e555..6ae502d 100644 --- a/frontend/src/routes/_layout/events.tsx +++ b/frontend/src/routes/_layout/events.tsx @@ -29,14 +29,21 @@ export const Route = createFileRoute('/_layout/events')({ component: Events, }) -function format_event(e: EventOut) { +function clipText(text: string, maxLength: number = 10000): string { + if (text.length > maxLength) { + return text.slice(0, maxLength) + '...'; + } + return text; +} + +function formatEvent(e: EventOut) { try { if (e.name === "request" || e.name === "modified_request") { - return format_chat_request(JSON.parse(e.content)); + return formatChatRequest(JSON.parse(e.content)); } else if (e.name === "response" || e.name === "modified_response") { - return format_chat_response(JSON.parse(e.content)); + return formatChatResponse(JSON.parse(e.content)); } else if (e.name === "user_evaluation" || e.name === "lm_judge_evaluation") { - return format_evaluation(JSON.parse(e.content)); + return formatEvaluation(JSON.parse(e.content)); } else { return format_json(e.content || 'N/A'); } @@ -45,24 +52,24 @@ function format_event(e: EventOut) { } } -function format_chat_request(content: { content: { model: string; messages: Array<{ role: string; content: string | Array }> } }) { +function formatChatRequest(content: { content: { model: string; messages: Array<{ role: string; content: string | Array }> } }) { return model: {content.content.model} - {content.content.messages.map((message: { role: string; content: string | Array }, index: number) => - {message.role}: {Array.isArray(message.content) ? not displayable : message.content} + {content.content.messages.map((message: { role: string; content: string | Array }, index: number) => + {message.role}: {Array.isArray(message.content) ? not displayable : clipText(message.content)} )}; } -function format_chat_response(content: { content: { choices: Array<{ message: { role: string; content: string | Array } }> } }) { +function formatChatResponse(content: { content: { choices: Array<{ message: { role: string; content: string | Array } }> } }) { return - {content.content.choices.map((choice, index: number) => - {choice.message.role}: {Array.isArray(choice.message.content) ? not displayable : choice.message.content} + {content.content.choices.map((choice, index: number) => + {choice.message.role}: {Array.isArray(choice.message.content) ? not displayable : clipText(choice.message.content)} )}; } -function format_evaluation(content: { type: string, value: number }) { +function formatEvaluation(content: { type: string, value: number }) { return - {content.type}: {content.value} + {content.type}: {content.value} ; } @@ -166,7 +173,7 @@ function Events() { {event.name} {event.timestamp.slice(0, 19)} - {format_event(event)} + {formatEvent(event)} {event.parent_id} {owners.get(event.owner_id) || "Unknown"}