From 27ec5ea81f27e60186c5de6e511ced1ae6f6651d Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 2 Jan 2025 23:33:15 +0000 Subject: [PATCH] more panels --- packages/web/src/App.tsx | 111 +++++++++++++++++++++++++++++++++------ 1 file changed, 94 insertions(+), 17 deletions(-) diff --git a/packages/web/src/App.tsx b/packages/web/src/App.tsx index f4197f3ec2..c4da657143 100644 --- a/packages/web/src/App.tsx +++ b/packages/web/src/App.tsx @@ -42,7 +42,6 @@ import type { ServerEnvResponse, } from "../../core/src/server/messages" import { promptParametersSchemaToJSONSchema } from "../../core/src/parameters" -import LLMS from "../../core/src/llms.json" import { logprobToMarkdown, topLogprobsToMarkdown, @@ -555,6 +554,22 @@ function JSONSchemaObjectForm(props: { ) } +function CounterBadge(props: { collection: any | undefined }) { + const { collection } = props + let count: string | undefined = undefined + if (Array.isArray(collection)) { + if (collection.length > 0) count = "" + collection.length + } else if (collection) count = "1" + + return count ? ( + + {count} + + ) : ( + "" + ) +} + function TraceTabPanel() { const { runner } = useRunner() const [trace, setTrace] = useState("Run script to see trace.") @@ -595,14 +610,8 @@ function ProblemsTabPanel() { return ( <> - Problems{" "} - {annotations.length > 0 ? ( - - {annotations.length} - - ) : ( - "" - )} + Problems + {annotationsMarkdown} @@ -623,7 +632,10 @@ function OutputTabPanel() { //if (/^\s*\{/.test(text)) text = fenceMD(text, "json") return ( <> - Output + + Output + + {md} @@ -648,13 +660,7 @@ function FilesTabPanel() { <> Files - {files.length > 0 ? ( - - {files.length} - - ) : ( - "" - )} + {files.length > 0 && ( @@ -681,6 +687,75 @@ function FilesTabPanel() { ) } +function DataTabPanel() { + const result = useResult() + const { frames = [] } = result || {} + + return ( + <> + + Data + + + + {frames.map((frame, i) => ( + + {` +\`\`\`\`\`json +${JSON.stringify(frame, null, 2)}} +\`\`\`\`\` +`} + + ))} + + + ) +} + +function JSONTabPanel() { + const result = useResult() + const { json } = result || {} + return ( + <> + + JSON + + + + {json && ( + + {` +\`\`\`\`\`json +${JSON.stringify(json, null, 2)}} +\`\`\`\`\` +`} + + )} + + + ) +} + +function RawTabPanel() { + const result = useResult() + return ( + <> + Raw + + {result && ( + + {` +\`\`\`\`\`json +${JSON.stringify(result, null, 2)}} +\`\`\`\`\` +`} + + )} + + + ) +} + function toStringList(...token: (string | undefined | null)[]) { const md = token .filter((l) => l !== undefined && l !== null && l !== "") @@ -896,6 +971,8 @@ function WebApp() { + +