inspect-ai 0.3.62__py3-none-any.whl → 0.3.64__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- inspect_ai/_cli/cache.py +8 -7
- inspect_ai/_cli/common.py +0 -12
- inspect_ai/_cli/eval.py +32 -4
- inspect_ai/_cli/info.py +1 -0
- inspect_ai/_cli/list.py +1 -1
- inspect_ai/_cli/log.py +2 -0
- inspect_ai/_cli/main.py +1 -1
- inspect_ai/_cli/sandbox.py +4 -1
- inspect_ai/_cli/score.py +181 -32
- inspect_ai/_cli/trace.py +10 -0
- inspect_ai/_cli/view.py +4 -2
- inspect_ai/_display/core/active.py +2 -3
- inspect_ai/_display/core/config.py +7 -1
- inspect_ai/_display/textual/widgets/samples.py +4 -3
- inspect_ai/_display/textual/widgets/sandbox.py +6 -0
- inspect_ai/_eval/eval.py +104 -101
- inspect_ai/_eval/evalset.py +75 -75
- inspect_ai/_eval/loader.py +122 -12
- inspect_ai/_eval/registry.py +1 -1
- inspect_ai/_eval/run.py +14 -0
- inspect_ai/_eval/score.py +125 -36
- inspect_ai/_eval/task/log.py +105 -4
- inspect_ai/_eval/task/results.py +92 -38
- inspect_ai/_eval/task/run.py +9 -2
- inspect_ai/_eval/task/sandbox.py +35 -2
- inspect_ai/_eval/task/task.py +49 -46
- inspect_ai/_util/constants.py +1 -1
- inspect_ai/_util/content.py +8 -0
- inspect_ai/_util/error.py +2 -0
- inspect_ai/_util/file.py +15 -1
- inspect_ai/_util/hash.py +1 -1
- inspect_ai/_util/logger.py +4 -2
- inspect_ai/_util/registry.py +7 -1
- inspect_ai/_view/view.py +1 -2
- inspect_ai/_view/www/.vscode/extensions.json +3 -0
- inspect_ai/_view/www/.vscode/settings.json +8 -0
- inspect_ai/_view/www/App.css +97 -29
- inspect_ai/_view/www/README.md +1 -1
- inspect_ai/_view/www/dist/assets/index.css +16663 -14674
- inspect_ai/_view/www/dist/assets/index.js +58808 -51348
- inspect_ai/_view/www/dist/index.html +1 -1
- inspect_ai/_view/www/index.html +2 -2
- inspect_ai/_view/www/log-schema.json +87 -73
- inspect_ai/_view/www/package.json +22 -4
- inspect_ai/_view/www/postcss.config.cjs +8 -9
- inspect_ai/_view/www/src/{App.mjs → App.tsx} +356 -365
- inspect_ai/_view/www/src/AppErrorBoundary.tsx +47 -0
- inspect_ai/_view/www/src/api/api-browser.ts +2 -2
- inspect_ai/_view/www/src/api/api-http.ts +3 -5
- inspect_ai/_view/www/src/api/api-vscode.ts +6 -6
- inspect_ai/_view/www/src/api/client-api.ts +4 -4
- inspect_ai/_view/www/src/api/index.ts +4 -4
- inspect_ai/_view/www/src/api/{Types.ts → types.ts} +25 -9
- inspect_ai/_view/www/src/appearance/colors.ts +9 -0
- inspect_ai/_view/www/src/appearance/fonts.ts +39 -0
- inspect_ai/_view/www/src/appearance/icons.ts +100 -0
- inspect_ai/_view/www/src/appearance/{Styles.mjs → styles.ts} +2 -32
- inspect_ai/_view/www/src/components/AnsiDisplay.tsx +198 -0
- inspect_ai/_view/www/src/components/AsciinemaPlayer.tsx +86 -0
- inspect_ai/_view/www/src/components/Card.css +60 -0
- inspect_ai/_view/www/src/components/Card.tsx +109 -0
- inspect_ai/_view/www/src/components/CopyButton.module.css +11 -0
- inspect_ai/_view/www/src/components/CopyButton.tsx +58 -0
- inspect_ai/_view/www/src/components/DownloadButton.css +4 -0
- inspect_ai/_view/www/src/components/DownloadButton.tsx +25 -0
- inspect_ai/_view/www/src/components/DownloadPanel.css +10 -0
- inspect_ai/_view/www/src/components/DownloadPanel.tsx +30 -0
- inspect_ai/_view/www/src/components/EmptyPanel.css +12 -0
- inspect_ai/_view/www/src/components/EmptyPanel.tsx +15 -0
- inspect_ai/_view/www/src/components/ErrorPanel.css +37 -0
- inspect_ai/_view/www/src/components/ErrorPanel.tsx +39 -0
- inspect_ai/_view/www/src/components/ExpandablePanel.css +40 -0
- inspect_ai/_view/www/src/components/ExpandablePanel.tsx +115 -0
- inspect_ai/_view/www/src/components/FindBand.css +49 -0
- inspect_ai/_view/www/src/components/FindBand.tsx +130 -0
- inspect_ai/_view/www/src/components/HumanBaselineView.css +41 -0
- inspect_ai/_view/www/src/components/HumanBaselineView.tsx +162 -0
- inspect_ai/_view/www/src/components/JsonPanel.css +20 -0
- inspect_ai/_view/www/src/components/JsonPanel.tsx +82 -0
- inspect_ai/_view/www/src/components/LabeledValue.css +20 -0
- inspect_ai/_view/www/src/components/LabeledValue.tsx +41 -0
- inspect_ai/_view/www/src/components/LargeModal.module.css +54 -0
- inspect_ai/_view/www/src/components/LargeModal.tsx +189 -0
- inspect_ai/_view/www/src/components/LightboxCarousel.css +95 -0
- inspect_ai/_view/www/src/components/LightboxCarousel.tsx +132 -0
- inspect_ai/_view/www/src/components/MarkdownDiv.css +3 -0
- inspect_ai/_view/www/src/components/MarkdownDiv.tsx +133 -0
- inspect_ai/_view/www/src/components/MessageBand.css +43 -0
- inspect_ai/_view/www/src/components/MessageBand.tsx +39 -0
- inspect_ai/_view/www/src/components/MorePopOver.css +0 -0
- inspect_ai/_view/www/src/components/MorePopOver.tsx +67 -0
- inspect_ai/_view/www/src/components/NavPills.module.css +18 -0
- inspect_ai/_view/www/src/components/NavPills.tsx +101 -0
- inspect_ai/_view/www/src/components/ProgressBar.module.css +37 -0
- inspect_ai/_view/www/src/components/ProgressBar.tsx +22 -0
- inspect_ai/_view/www/src/components/TabSet.module.css +40 -0
- inspect_ai/_view/www/src/components/TabSet.tsx +215 -0
- inspect_ai/_view/www/src/components/ToolButton.css +3 -0
- inspect_ai/_view/www/src/components/ToolButton.tsx +27 -0
- inspect_ai/_view/www/src/components/VirtualList.module.css +19 -0
- inspect_ai/_view/www/src/components/VirtualList.tsx +292 -0
- inspect_ai/_view/www/src/{index.js → index.tsx} +45 -19
- inspect_ai/_view/www/src/{log → logfile}/remoteLogFile.ts +3 -8
- inspect_ai/_view/www/src/{utils/remoteZipFile.mjs → logfile/remoteZipFile.ts} +86 -80
- inspect_ai/_view/www/src/metadata/MetaDataGrid.tsx +83 -0
- inspect_ai/_view/www/src/metadata/MetaDataView.module.css +35 -0
- inspect_ai/_view/www/src/metadata/MetaDataView.tsx +95 -0
- inspect_ai/_view/www/src/metadata/MetadataGrid.module.css +15 -0
- inspect_ai/_view/www/src/metadata/RenderedContent.module.css +12 -0
- inspect_ai/_view/www/src/{components/RenderedContent/RenderedContent.mjs → metadata/RenderedContent.tsx} +92 -73
- inspect_ai/_view/www/src/metadata/types.ts +18 -0
- inspect_ai/_view/www/src/plan/DatasetDetailView.module.css +3 -0
- inspect_ai/_view/www/src/plan/DatasetDetailView.tsx +37 -0
- inspect_ai/_view/www/src/plan/DetailStep.module.css +9 -0
- inspect_ai/_view/www/src/plan/DetailStep.tsx +31 -0
- inspect_ai/_view/www/src/plan/PlanCard.tsx +28 -0
- inspect_ai/_view/www/src/plan/PlanDetailView.module.css +48 -0
- inspect_ai/_view/www/src/plan/PlanDetailView.tsx +324 -0
- inspect_ai/_view/www/src/plan/ScorerDetailView.module.css +3 -0
- inspect_ai/_view/www/src/plan/ScorerDetailView.tsx +30 -0
- inspect_ai/_view/www/src/plan/SolverDetailView.module.css +15 -0
- inspect_ai/_view/www/src/plan/SolverDetailView.tsx +32 -0
- inspect_ai/_view/www/src/samples/InlineSampleDisplay.module.css +8 -0
- inspect_ai/_view/www/src/samples/InlineSampleDisplay.tsx +53 -0
- inspect_ai/_view/www/src/samples/SampleDialog.tsx +122 -0
- inspect_ai/_view/www/src/samples/SampleDisplay.module.css +29 -0
- inspect_ai/_view/www/src/samples/SampleDisplay.tsx +331 -0
- inspect_ai/_view/www/src/samples/SampleSummaryView.module.css +24 -0
- inspect_ai/_view/www/src/samples/SampleSummaryView.tsx +177 -0
- inspect_ai/_view/www/src/samples/SamplesTools.tsx +52 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessage.module.css +29 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessage.tsx +76 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessageRenderer.tsx +60 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessageRow.module.css +9 -0
- inspect_ai/_view/www/src/samples/chat/ChatMessageRow.tsx +57 -0
- inspect_ai/_view/www/src/samples/chat/ChatView.tsx +47 -0
- inspect_ai/_view/www/src/samples/chat/ChatViewVirtualList.module.css +4 -0
- inspect_ai/_view/www/src/samples/chat/ChatViewVirtualList.tsx +58 -0
- inspect_ai/_view/www/src/samples/chat/MessageContent.module.css +4 -0
- inspect_ai/_view/www/src/samples/chat/MessageContent.tsx +157 -0
- inspect_ai/_view/www/src/samples/chat/MessageContents.module.css +3 -0
- inspect_ai/_view/www/src/samples/chat/MessageContents.tsx +133 -0
- inspect_ai/_view/www/src/samples/chat/messages.ts +112 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolCallView.tsx +147 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolInput.module.css +14 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolInput.tsx +76 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolOutput.module.css +19 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolOutput.tsx +60 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolTitle.module.css +4 -0
- inspect_ai/_view/www/src/samples/chat/tools/ToolTitle.tsx +18 -0
- inspect_ai/_view/www/src/samples/chat/tools/tool.ts +92 -0
- inspect_ai/_view/www/src/samples/descriptor/samplesDescriptor.tsx +365 -0
- inspect_ai/_view/www/src/samples/descriptor/score/BooleanScoreDescriptor.module.css +22 -0
- inspect_ai/_view/www/src/samples/descriptor/score/BooleanScoreDescriptor.tsx +26 -0
- inspect_ai/_view/www/src/samples/descriptor/score/CategoricalScoreDescriptor.tsx +18 -0
- inspect_ai/_view/www/src/samples/descriptor/score/NumericScoreDescriptor.tsx +27 -0
- inspect_ai/_view/www/src/samples/descriptor/score/ObjectScoreDescriptor.module.css +18 -0
- inspect_ai/_view/www/src/samples/descriptor/score/ObjectScoreDescriptor.tsx +71 -0
- inspect_ai/_view/www/src/samples/descriptor/score/OtherScoreDescriptor.tsx +20 -0
- inspect_ai/_view/www/src/samples/descriptor/score/PassFailScoreDescriptor.module.css +28 -0
- inspect_ai/_view/www/src/samples/descriptor/score/PassFailScoreDescriptor.tsx +81 -0
- inspect_ai/_view/www/src/samples/descriptor/score/ScoreDescriptor.tsx +99 -0
- inspect_ai/_view/www/src/samples/descriptor/types.ts +55 -0
- inspect_ai/_view/www/src/samples/error/FlatSampleErrorView.module.css +19 -0
- inspect_ai/_view/www/src/samples/error/FlatSampleErrorView.tsx +22 -0
- inspect_ai/_view/www/src/samples/error/SampleErrorView.module.css +17 -0
- inspect_ai/_view/www/src/samples/error/SampleErrorView.tsx +31 -0
- inspect_ai/_view/www/src/samples/error/error.ts +15 -0
- inspect_ai/_view/www/src/samples/list/SampleFooter.module.css +9 -0
- inspect_ai/_view/www/src/samples/list/SampleFooter.tsx +14 -0
- inspect_ai/_view/www/src/samples/list/SampleHeader.module.css +13 -0
- inspect_ai/_view/www/src/samples/list/SampleHeader.tsx +36 -0
- inspect_ai/_view/www/src/samples/list/SampleList.module.css +11 -0
- inspect_ai/_view/www/src/samples/list/SampleList.tsx +247 -0
- inspect_ai/_view/www/src/samples/list/SampleRow.module.css +33 -0
- inspect_ai/_view/www/src/samples/list/SampleRow.tsx +98 -0
- inspect_ai/_view/www/src/samples/list/SampleSeparator.module.css +6 -0
- inspect_ai/_view/www/src/samples/list/SampleSeparator.tsx +24 -0
- inspect_ai/_view/www/src/samples/sample-tools/EpochFilter.module.css +9 -0
- inspect_ai/_view/www/src/samples/sample-tools/EpochFilter.tsx +51 -0
- inspect_ai/_view/www/src/samples/sample-tools/SelectScorer.module.css +16 -0
- inspect_ai/_view/www/src/samples/sample-tools/SelectScorer.tsx +175 -0
- inspect_ai/_view/www/src/samples/sample-tools/SortFilter.module.css +9 -0
- inspect_ai/_view/www/src/samples/sample-tools/SortFilter.tsx +186 -0
- inspect_ai/_view/www/src/samples/{tools/filters.mjs → sample-tools/filters.ts} +86 -81
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/SampleFilter.module.css +16 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/SampleFilter.tsx +288 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/completions.ts +346 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/language.ts +19 -0
- inspect_ai/_view/www/src/samples/sample-tools/sample-filter/tokenize.ts +97 -0
- inspect_ai/_view/www/src/samples/{SampleLimit.mjs → sampleLimit.ts} +3 -6
- inspect_ai/_view/www/src/samples/scores/SampleScoreView.module.css +53 -0
- inspect_ai/_view/www/src/samples/scores/SampleScoreView.tsx +168 -0
- inspect_ai/_view/www/src/samples/scores/SampleScores.module.css +5 -0
- inspect_ai/_view/www/src/samples/scores/SampleScores.tsx +37 -0
- inspect_ai/_view/www/src/samples/transcript/ApprovalEventView.tsx +66 -0
- inspect_ai/_view/www/src/samples/transcript/ErrorEventView.tsx +51 -0
- inspect_ai/_view/www/src/samples/transcript/InfoEventView.module.css +3 -0
- inspect_ai/_view/www/src/samples/transcript/InfoEventView.tsx +54 -0
- inspect_ai/_view/www/src/samples/transcript/InputEventView.tsx +48 -0
- inspect_ai/_view/www/src/samples/transcript/LoggerEventView.module.css +6 -0
- inspect_ai/_view/www/src/samples/transcript/LoggerEventView.tsx +36 -0
- inspect_ai/_view/www/src/samples/transcript/ModelEventView.module.css +43 -0
- inspect_ai/_view/www/src/samples/transcript/ModelEventView.tsx +223 -0
- inspect_ai/_view/www/src/samples/transcript/SampleInitEventView.module.css +23 -0
- inspect_ai/_view/www/src/samples/transcript/SampleInitEventView.tsx +112 -0
- inspect_ai/_view/www/src/samples/transcript/SampleLimitEventView.tsx +75 -0
- inspect_ai/_view/www/src/samples/transcript/SampleTranscript.tsx +22 -0
- inspect_ai/_view/www/src/samples/transcript/ScoreEventView.module.css +15 -0
- inspect_ai/_view/www/src/samples/transcript/ScoreEventView.tsx +100 -0
- inspect_ai/_view/www/src/samples/transcript/StepEventView.tsx +171 -0
- inspect_ai/_view/www/src/samples/transcript/SubtaskEventView.module.css +19 -0
- inspect_ai/_view/www/src/samples/transcript/SubtaskEventView.tsx +133 -0
- inspect_ai/_view/www/src/samples/transcript/ToolEventView.module.css +10 -0
- inspect_ai/_view/www/src/samples/transcript/ToolEventView.tsx +92 -0
- inspect_ai/_view/www/src/samples/transcript/TranscriptView.module.css +49 -0
- inspect_ai/_view/www/src/samples/transcript/TranscriptView.tsx +449 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNav.module.css +5 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNav.tsx +43 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNavs.module.css +3 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventNavs.tsx +39 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventPanel.module.css +25 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventPanel.tsx +191 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventRow.module.css +13 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventRow.tsx +32 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventSection.module.css +8 -0
- inspect_ai/_view/www/src/samples/transcript/event/EventSection.tsx +29 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateDiffView.tsx +67 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventRenderers.tsx +285 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventRenders.module.css +10 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventView.module.css +9 -0
- inspect_ai/_view/www/src/samples/transcript/state/StateEventView.tsx +346 -0
- inspect_ai/_view/www/src/samples/transcript/types.ts +58 -0
- inspect_ai/_view/www/src/types/log.d.ts +108 -19
- inspect_ai/_view/www/src/types/prism.d.ts +11 -0
- inspect_ai/_view/www/src/types.ts +71 -0
- inspect_ai/_view/www/src/usage/ModelTokenTable.tsx +28 -0
- inspect_ai/_view/www/src/usage/ModelUsagePanel.module.css +24 -0
- inspect_ai/_view/www/src/usage/ModelUsagePanel.tsx +97 -0
- inspect_ai/_view/www/src/usage/TokenTable.module.css +17 -0
- inspect_ai/_view/www/src/usage/TokenTable.tsx +91 -0
- inspect_ai/_view/www/src/usage/UsageCard.module.css +15 -0
- inspect_ai/_view/www/src/usage/UsageCard.tsx +67 -0
- inspect_ai/_view/www/src/utils/attachments.ts +42 -0
- inspect_ai/_view/www/src/utils/{Base64.mjs → base64.ts} +1 -6
- inspect_ai/_view/www/src/{components/Browser.mjs → utils/browser.ts} +0 -1
- inspect_ai/_view/www/src/utils/debugging.ts +28 -0
- inspect_ai/_view/www/src/utils/dom.ts +30 -0
- inspect_ai/_view/www/src/utils/format.ts +194 -0
- inspect_ai/_view/www/src/utils/git.ts +7 -0
- inspect_ai/_view/www/src/utils/html.ts +6 -0
- inspect_ai/_view/www/src/utils/http.ts +14 -0
- inspect_ai/_view/www/src/utils/{Path.mjs → path.ts} +2 -9
- inspect_ai/_view/www/src/utils/{Print.mjs → print.ts} +34 -26
- inspect_ai/_view/www/src/utils/queue.ts +51 -0
- inspect_ai/_view/www/src/utils/sync.ts +114 -0
- inspect_ai/_view/www/src/utils/{Type.mjs → type.ts} +3 -6
- inspect_ai/_view/www/src/utils/vscode.ts +13 -0
- inspect_ai/_view/www/src/workspace/WorkSpace.tsx +324 -0
- inspect_ai/_view/www/src/workspace/WorkSpaceView.module.css +33 -0
- inspect_ai/_view/www/src/workspace/WorkSpaceView.tsx +158 -0
- inspect_ai/_view/www/src/workspace/error/TaskErrorPanel.module.css +3 -0
- inspect_ai/_view/www/src/workspace/error/TaskErrorPanel.tsx +28 -0
- inspect_ai/_view/www/src/workspace/navbar/Navbar.module.css +54 -0
- inspect_ai/_view/www/src/workspace/navbar/Navbar.tsx +68 -0
- inspect_ai/_view/www/src/workspace/navbar/PrimaryBar.module.css +52 -0
- inspect_ai/_view/www/src/workspace/navbar/PrimaryBar.tsx +114 -0
- inspect_ai/_view/www/src/workspace/navbar/ResultsPanel.module.css +90 -0
- inspect_ai/_view/www/src/workspace/navbar/ResultsPanel.tsx +180 -0
- inspect_ai/_view/www/src/workspace/navbar/SecondaryBar.module.css +28 -0
- inspect_ai/_view/www/src/workspace/navbar/SecondaryBar.tsx +226 -0
- inspect_ai/_view/www/src/workspace/navbar/StatusPanel.module.css +14 -0
- inspect_ai/_view/www/src/workspace/navbar/StatusPanel.tsx +61 -0
- inspect_ai/_view/www/src/workspace/sidebar/EvalStatus.module.css +15 -0
- inspect_ai/_view/www/src/workspace/sidebar/EvalStatus.tsx +71 -0
- inspect_ai/_view/www/src/workspace/sidebar/LogDirectoryTitleView.module.css +5 -0
- inspect_ai/_view/www/src/workspace/sidebar/LogDirectoryTitleView.tsx +56 -0
- inspect_ai/_view/www/src/workspace/sidebar/Sidebar.module.css +68 -0
- inspect_ai/_view/www/src/workspace/sidebar/Sidebar.tsx +85 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarLogEntry.module.css +29 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarLogEntry.tsx +95 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoreView.module.css +23 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoreView.tsx +43 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoresView.module.css +35 -0
- inspect_ai/_view/www/src/workspace/sidebar/SidebarScoresView.tsx +63 -0
- inspect_ai/_view/www/src/workspace/tabs/InfoTab.module.css +0 -0
- inspect_ai/_view/www/src/workspace/tabs/InfoTab.tsx +70 -0
- inspect_ai/_view/www/src/workspace/tabs/JsonTab.module.css +5 -0
- inspect_ai/_view/www/src/workspace/tabs/JsonTab.tsx +46 -0
- inspect_ai/_view/www/src/workspace/tabs/SamplesTab.tsx +204 -0
- inspect_ai/_view/www/src/workspace/tabs/grouping.ts +195 -0
- inspect_ai/_view/www/src/workspace/tabs/types.ts +19 -0
- inspect_ai/_view/www/src/workspace/types.ts +10 -0
- inspect_ai/_view/www/src/workspace/utils.ts +34 -0
- inspect_ai/_view/www/tsconfig.json +23 -9
- inspect_ai/_view/www/vite.config.js +8 -17
- inspect_ai/_view/www/yarn.lock +627 -556
- inspect_ai/approval/_approval.py +2 -0
- inspect_ai/approval/_approver.py +4 -4
- inspect_ai/approval/_auto.py +1 -1
- inspect_ai/approval/_human/approver.py +3 -0
- inspect_ai/approval/_policy.py +5 -0
- inspect_ai/approval/_registry.py +2 -2
- inspect_ai/dataset/_dataset.py +64 -37
- inspect_ai/dataset/_sources/__init__.py +0 -0
- inspect_ai/dataset/_sources/csv.py +20 -12
- inspect_ai/dataset/_sources/file.py +4 -0
- inspect_ai/dataset/_sources/hf.py +39 -29
- inspect_ai/dataset/_sources/json.py +17 -9
- inspect_ai/log/__init__.py +2 -0
- inspect_ai/log/_convert.py +3 -3
- inspect_ai/log/_file.py +24 -9
- inspect_ai/log/_log.py +101 -13
- inspect_ai/log/_message.py +4 -2
- inspect_ai/log/_recorders/file.py +4 -0
- inspect_ai/log/_recorders/json.py +5 -7
- inspect_ai/log/_recorders/recorder.py +3 -0
- inspect_ai/log/_transcript.py +19 -8
- inspect_ai/model/__init__.py +2 -0
- inspect_ai/model/_cache.py +39 -21
- inspect_ai/model/_call_tools.py +4 -3
- inspect_ai/model/_chat_message.py +14 -4
- inspect_ai/model/_generate_config.py +1 -1
- inspect_ai/model/_model.py +31 -24
- inspect_ai/model/_model_output.py +14 -1
- inspect_ai/model/_openai.py +10 -18
- inspect_ai/model/_providers/anthropic.py +3 -3
- inspect_ai/model/_providers/google.py +9 -5
- inspect_ai/model/_providers/openai.py +5 -9
- inspect_ai/model/_providers/openai_o1.py +3 -5
- inspect_ai/model/_providers/openrouter.py +86 -0
- inspect_ai/model/_providers/providers.py +11 -0
- inspect_ai/scorer/__init__.py +6 -1
- inspect_ai/scorer/_answer.py +7 -7
- inspect_ai/scorer/_classification.py +38 -18
- inspect_ai/scorer/_common.py +2 -8
- inspect_ai/scorer/_match.py +4 -5
- inspect_ai/scorer/_metric.py +87 -28
- inspect_ai/scorer/_metrics/__init__.py +3 -3
- inspect_ai/scorer/_metrics/accuracy.py +8 -10
- inspect_ai/scorer/_metrics/mean.py +3 -17
- inspect_ai/scorer/_metrics/std.py +111 -30
- inspect_ai/scorer/_model.py +12 -12
- inspect_ai/scorer/_pattern.py +3 -3
- inspect_ai/scorer/_reducer/reducer.py +36 -21
- inspect_ai/scorer/_reducer/registry.py +2 -2
- inspect_ai/scorer/_reducer/types.py +7 -1
- inspect_ai/scorer/_score.py +11 -1
- inspect_ai/scorer/_scorer.py +110 -16
- inspect_ai/solver/__init__.py +1 -1
- inspect_ai/solver/_basic_agent.py +19 -22
- inspect_ai/solver/_bridge/__init__.py +0 -3
- inspect_ai/solver/_bridge/bridge.py +3 -3
- inspect_ai/solver/_chain.py +1 -2
- inspect_ai/solver/_critique.py +3 -3
- inspect_ai/solver/_fork.py +2 -2
- inspect_ai/solver/_human_agent/__init__.py +0 -0
- inspect_ai/solver/_human_agent/agent.py +5 -8
- inspect_ai/solver/_human_agent/commands/clock.py +14 -10
- inspect_ai/solver/_human_agent/commands/note.py +1 -1
- inspect_ai/solver/_human_agent/commands/score.py +0 -11
- inspect_ai/solver/_multiple_choice.py +38 -26
- inspect_ai/solver/_prompt.py +7 -7
- inspect_ai/solver/_solver.py +53 -52
- inspect_ai/solver/_task_state.py +80 -69
- inspect_ai/solver/_use_tools.py +9 -9
- inspect_ai/tool/__init__.py +4 -1
- inspect_ai/tool/_tool.py +43 -14
- inspect_ai/tool/_tool_call.py +6 -2
- inspect_ai/tool/_tool_choice.py +3 -1
- inspect_ai/tool/_tool_def.py +10 -8
- inspect_ai/tool/_tool_params.py +24 -0
- inspect_ai/tool/_tool_with.py +7 -7
- inspect_ai/tool/_tools/__init__.py +0 -0
- inspect_ai/tool/{beta → _tools}/_computer/_common.py +2 -2
- inspect_ai/tool/{beta → _tools}/_computer/_computer.py +13 -5
- inspect_ai/tool/_tools/_computer/_resources/tool/__init__.py +0 -0
- inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_x11_client.py +1 -1
- inspect_ai/tool/_tools/_computer/_resources/tool/requirements.txt +0 -0
- inspect_ai/tool/_tools/_execute.py +23 -11
- inspect_ai/tool/_tools/_web_browser/_resources/README.md +2 -2
- inspect_ai/tool/_tools/_web_browser/_web_browser.py +5 -3
- inspect_ai/tool/_tools/_web_search.py +7 -5
- inspect_ai/tool/beta.py +3 -0
- inspect_ai/util/_concurrency.py +3 -3
- inspect_ai/util/_panel.py +2 -0
- inspect_ai/util/_resource.py +12 -12
- inspect_ai/util/_sandbox/docker/compose.py +23 -20
- inspect_ai/util/_sandbox/docker/config.py +2 -1
- inspect_ai/util/_sandbox/docker/docker.py +42 -86
- inspect_ai/util/_sandbox/docker/service.py +100 -0
- inspect_ai/util/_sandbox/environment.py +99 -96
- inspect_ai/util/_sandbox/self_check.py +124 -16
- inspect_ai/util/_subprocess.py +5 -3
- inspect_ai/util/_subtask.py +15 -16
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/LICENSE +1 -1
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/METADATA +11 -6
- inspect_ai-0.3.64.dist-info/RECORD +625 -0
- inspect_ai/_view/www/src/Register.mjs +0 -3
- inspect_ai/_view/www/src/Types.mjs +0 -38
- inspect_ai/_view/www/src/appearance/Colors.mjs +0 -27
- inspect_ai/_view/www/src/appearance/Fonts.mjs +0 -66
- inspect_ai/_view/www/src/appearance/Icons.mjs +0 -240
- inspect_ai/_view/www/src/components/AnsiDisplay.mjs +0 -184
- inspect_ai/_view/www/src/components/AppErrorBoundary.mjs +0 -34
- inspect_ai/_view/www/src/components/AsciiCinemaPlayer.mjs +0 -74
- inspect_ai/_view/www/src/components/Card.mjs +0 -126
- inspect_ai/_view/www/src/components/ChatView.mjs +0 -441
- inspect_ai/_view/www/src/components/CopyButton.mjs +0 -48
- inspect_ai/_view/www/src/components/Dialog.mjs +0 -61
- inspect_ai/_view/www/src/components/DownloadButton.mjs +0 -15
- inspect_ai/_view/www/src/components/DownloadPanel.mjs +0 -29
- inspect_ai/_view/www/src/components/EmptyPanel.mjs +0 -23
- inspect_ai/_view/www/src/components/ErrorPanel.mjs +0 -66
- inspect_ai/_view/www/src/components/ExpandablePanel.mjs +0 -136
- inspect_ai/_view/www/src/components/FindBand.mjs +0 -157
- inspect_ai/_view/www/src/components/HumanBaselineView.mjs +0 -168
- inspect_ai/_view/www/src/components/JsonPanel.mjs +0 -61
- inspect_ai/_view/www/src/components/LabeledValue.mjs +0 -32
- inspect_ai/_view/www/src/components/LargeModal.mjs +0 -190
- inspect_ai/_view/www/src/components/LightboxCarousel.mjs +0 -217
- inspect_ai/_view/www/src/components/MarkdownDiv.mjs +0 -118
- inspect_ai/_view/www/src/components/MessageBand.mjs +0 -48
- inspect_ai/_view/www/src/components/MessageContent.mjs +0 -111
- inspect_ai/_view/www/src/components/MetaDataGrid.mjs +0 -92
- inspect_ai/_view/www/src/components/MetaDataView.mjs +0 -109
- inspect_ai/_view/www/src/components/MorePopOver.mjs +0 -50
- inspect_ai/_view/www/src/components/NavPills.mjs +0 -63
- inspect_ai/_view/www/src/components/ProgressBar.mjs +0 -51
- inspect_ai/_view/www/src/components/RenderedContent/ChatMessageRenderer.mjs +0 -54
- inspect_ai/_view/www/src/components/RenderedContent/Types.mjs +0 -19
- inspect_ai/_view/www/src/components/TabSet.mjs +0 -184
- inspect_ai/_view/www/src/components/ToolButton.mjs +0 -16
- inspect_ai/_view/www/src/components/Tools.mjs +0 -376
- inspect_ai/_view/www/src/components/VirtualList.mjs +0 -280
- inspect_ai/_view/www/src/components/ansi-output.js +0 -932
- inspect_ai/_view/www/src/json/JsonTab.mjs +0 -48
- inspect_ai/_view/www/src/log-reader/Log-Reader.mjs +0 -25
- inspect_ai/_view/www/src/log-reader/Native-Log-Reader.mjs +0 -13
- inspect_ai/_view/www/src/log-reader/Open-AI-Log-Reader.mjs +0 -263
- inspect_ai/_view/www/src/navbar/Navbar.mjs +0 -418
- inspect_ai/_view/www/src/navbar/SecondaryBar.mjs +0 -175
- inspect_ai/_view/www/src/plan/PlanCard.mjs +0 -418
- inspect_ai/_view/www/src/samples/SampleDialog.mjs +0 -123
- inspect_ai/_view/www/src/samples/SampleDisplay.mjs +0 -516
- inspect_ai/_view/www/src/samples/SampleError.mjs +0 -99
- inspect_ai/_view/www/src/samples/SampleList.mjs +0 -427
- inspect_ai/_view/www/src/samples/SampleScoreView.mjs +0 -172
- inspect_ai/_view/www/src/samples/SampleScores.mjs +0 -34
- inspect_ai/_view/www/src/samples/SampleTranscript.mjs +0 -20
- inspect_ai/_view/www/src/samples/SamplesDescriptor.mjs +0 -771
- inspect_ai/_view/www/src/samples/SamplesTab.mjs +0 -399
- inspect_ai/_view/www/src/samples/SamplesTools.mjs +0 -64
- inspect_ai/_view/www/src/samples/tools/EpochFilter.mjs +0 -38
- inspect_ai/_view/www/src/samples/tools/SampleFilter.mjs +0 -756
- inspect_ai/_view/www/src/samples/tools/SelectScorer.mjs +0 -141
- inspect_ai/_view/www/src/samples/tools/SortFilter.mjs +0 -151
- inspect_ai/_view/www/src/samples/transcript/ApprovalEventView.mjs +0 -71
- inspect_ai/_view/www/src/samples/transcript/ErrorEventView.mjs +0 -44
- inspect_ai/_view/www/src/samples/transcript/EventPanel.mjs +0 -271
- inspect_ai/_view/www/src/samples/transcript/EventRow.mjs +0 -46
- inspect_ai/_view/www/src/samples/transcript/EventSection.mjs +0 -33
- inspect_ai/_view/www/src/samples/transcript/InfoEventView.mjs +0 -59
- inspect_ai/_view/www/src/samples/transcript/InputEventView.mjs +0 -44
- inspect_ai/_view/www/src/samples/transcript/LoggerEventView.mjs +0 -32
- inspect_ai/_view/www/src/samples/transcript/ModelEventView.mjs +0 -216
- inspect_ai/_view/www/src/samples/transcript/SampleInitEventView.mjs +0 -107
- inspect_ai/_view/www/src/samples/transcript/SampleLimitEventView.mjs +0 -74
- inspect_ai/_view/www/src/samples/transcript/ScoreEventView.mjs +0 -100
- inspect_ai/_view/www/src/samples/transcript/StepEventView.mjs +0 -187
- inspect_ai/_view/www/src/samples/transcript/SubtaskEventView.mjs +0 -133
- inspect_ai/_view/www/src/samples/transcript/ToolEventView.mjs +0 -88
- inspect_ai/_view/www/src/samples/transcript/TranscriptView.mjs +0 -459
- inspect_ai/_view/www/src/samples/transcript/Types.mjs +0 -44
- inspect_ai/_view/www/src/samples/transcript/state/StateDiffView.mjs +0 -53
- inspect_ai/_view/www/src/samples/transcript/state/StateEventRenderers.mjs +0 -254
- inspect_ai/_view/www/src/samples/transcript/state/StateEventView.mjs +0 -313
- inspect_ai/_view/www/src/sidebar/Sidebar.mjs +0 -418
- inspect_ai/_view/www/src/usage/ModelTokenTable.mjs +0 -72
- inspect_ai/_view/www/src/usage/UsageCard.mjs +0 -159
- inspect_ai/_view/www/src/utils/Format.mjs +0 -260
- inspect_ai/_view/www/src/utils/Git.mjs +0 -12
- inspect_ai/_view/www/src/utils/Html.mjs +0 -21
- inspect_ai/_view/www/src/utils/attachments.mjs +0 -31
- inspect_ai/_view/www/src/utils/debugging.mjs +0 -23
- inspect_ai/_view/www/src/utils/http.mjs +0 -18
- inspect_ai/_view/www/src/utils/queue.mjs +0 -67
- inspect_ai/_view/www/src/utils/sync.mjs +0 -101
- inspect_ai/_view/www/src/workspace/TaskErrorPanel.mjs +0 -17
- inspect_ai/_view/www/src/workspace/WorkSpace.mjs +0 -516
- inspect_ai/tool/beta/__init__.py +0 -5
- inspect_ai-0.3.62.dist-info/RECORD +0 -481
- /inspect_ai/{tool/beta/_computer/_resources/tool → _eval}/__init__.py +0 -0
- /inspect_ai/{tool/beta/_computer/_resources/tool/requirements.txt → _util/__init__.py} +0 -0
- /inspect_ai/_view/www/src/{constants.mjs → constants.ts} +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/__init__.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_computer_split.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/Dockerfile +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/README.md +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/entrypoint.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/novnc_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/x11vnc_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/xfce_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/entrypoint/xvfb_startup.sh +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/Code/User/globalStorage/state.vscdb +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/Code/User/settings.json +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-panel.xml +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-screensaver.xml +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/Desktop/Firefox Web Browser.desktop +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/Desktop/Terminal.desktop +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/image_home_dir/Desktop/Visual Studio Code.desktop +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_logger.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_run.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/_tool_result.py +0 -0
- /inspect_ai/tool/{beta → _tools}/_computer/_resources/tool/computer_tool.py +0 -0
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/WHEEL +0 -0
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/entry_points.txt +0 -0
- {inspect_ai-0.3.62.dist-info → inspect_ai-0.3.64.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,91 @@
|
|
1
|
+
import clsx from "clsx";
|
2
|
+
import { ModelUsage1 } from "../types/log";
|
3
|
+
import { ModelUsagePanel } from "./ModelUsagePanel";
|
4
|
+
import styles from "./TokenTable.module.css";
|
5
|
+
|
6
|
+
interface TokenTableProps {
|
7
|
+
className?: string | string[];
|
8
|
+
children?: React.ReactNode;
|
9
|
+
}
|
10
|
+
|
11
|
+
export const TokenTable: React.FC<TokenTableProps> = ({
|
12
|
+
className,
|
13
|
+
children,
|
14
|
+
}) => {
|
15
|
+
return (
|
16
|
+
<table
|
17
|
+
className={clsx(
|
18
|
+
"table",
|
19
|
+
"table-sm",
|
20
|
+
"text-size-smaller",
|
21
|
+
styles.table,
|
22
|
+
className,
|
23
|
+
)}
|
24
|
+
>
|
25
|
+
{children}
|
26
|
+
</table>
|
27
|
+
);
|
28
|
+
};
|
29
|
+
|
30
|
+
export const TokenHeader = () => {
|
31
|
+
return (
|
32
|
+
<thead>
|
33
|
+
<tr>
|
34
|
+
<td></td>
|
35
|
+
<td
|
36
|
+
colSpan={3}
|
37
|
+
className={clsx(
|
38
|
+
"card-subheading",
|
39
|
+
styles.tableTokens,
|
40
|
+
"text-size-small",
|
41
|
+
"text-style-label",
|
42
|
+
"text-style-secondary",
|
43
|
+
)}
|
44
|
+
align="center"
|
45
|
+
>
|
46
|
+
Tokens
|
47
|
+
</td>
|
48
|
+
</tr>
|
49
|
+
<tr>
|
50
|
+
<th
|
51
|
+
className={clsx(
|
52
|
+
styles.tableH,
|
53
|
+
"text-sixe-small",
|
54
|
+
"text-style-label",
|
55
|
+
"text-style-secondary",
|
56
|
+
)}
|
57
|
+
>
|
58
|
+
Model
|
59
|
+
</th>
|
60
|
+
<th
|
61
|
+
className={clsx(
|
62
|
+
styles.tableH,
|
63
|
+
"text-sixe-small",
|
64
|
+
"text-style-label",
|
65
|
+
"text-style-secondary",
|
66
|
+
)}
|
67
|
+
>
|
68
|
+
Usage
|
69
|
+
</th>
|
70
|
+
</tr>
|
71
|
+
</thead>
|
72
|
+
);
|
73
|
+
};
|
74
|
+
|
75
|
+
interface TokenRowProps {
|
76
|
+
model: string;
|
77
|
+
usage: ModelUsage1;
|
78
|
+
}
|
79
|
+
|
80
|
+
export const TokenRow: React.FC<TokenRowProps> = ({ model, usage }) => {
|
81
|
+
return (
|
82
|
+
<tr>
|
83
|
+
<td>
|
84
|
+
<div className={styles.model}>{model}</div>
|
85
|
+
</td>
|
86
|
+
<td>
|
87
|
+
<ModelUsagePanel usage={usage} />
|
88
|
+
</td>
|
89
|
+
</tr>
|
90
|
+
);
|
91
|
+
};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import clsx from "clsx";
|
2
|
+
import { FontSize } from "../appearance/fonts";
|
3
|
+
import { ApplicationIcons } from "../appearance/icons";
|
4
|
+
import { Card, CardBody, CardHeader } from "../components/Card";
|
5
|
+
import { MetaDataView } from "../metadata/MetaDataView";
|
6
|
+
import { EvalStats } from "../types/log";
|
7
|
+
import { formatDuration } from "../utils/format";
|
8
|
+
import { ModelTokenTable } from "./ModelTokenTable";
|
9
|
+
|
10
|
+
import styles from "./UsageCard.module.css";
|
11
|
+
|
12
|
+
const kUsageCardBodyId = "usage-card-body";
|
13
|
+
|
14
|
+
interface UsageCardProps {
|
15
|
+
stats?: EvalStats;
|
16
|
+
}
|
17
|
+
|
18
|
+
/**
|
19
|
+
* Renders the UsageCard component.
|
20
|
+
*/
|
21
|
+
export const UsageCard: React.FC<UsageCardProps> = ({ stats }) => {
|
22
|
+
if (!stats) {
|
23
|
+
return null;
|
24
|
+
}
|
25
|
+
|
26
|
+
const totalDuration = formatDuration(
|
27
|
+
new Date(stats.started_at),
|
28
|
+
new Date(stats.completed_at),
|
29
|
+
);
|
30
|
+
const usageMetadataStyle = {
|
31
|
+
fontSize: FontSize.smaller,
|
32
|
+
};
|
33
|
+
|
34
|
+
return (
|
35
|
+
<Card>
|
36
|
+
<CardHeader icon={ApplicationIcons.usage} label="Usage" />
|
37
|
+
<CardBody id={kUsageCardBodyId}>
|
38
|
+
<div className={styles.wrapper}>
|
39
|
+
<div className={styles.col1}>
|
40
|
+
<div
|
41
|
+
className={clsx(
|
42
|
+
"text-size-smaller",
|
43
|
+
"text-style-label",
|
44
|
+
"text-style-secondary",
|
45
|
+
)}
|
46
|
+
>
|
47
|
+
Duration
|
48
|
+
</div>
|
49
|
+
<MetaDataView
|
50
|
+
entries={{
|
51
|
+
["Start"]: new Date(stats.started_at).toLocaleString(),
|
52
|
+
["End"]: new Date(stats.completed_at).toLocaleString(),
|
53
|
+
["Duration"]: totalDuration,
|
54
|
+
}}
|
55
|
+
tableOptions="borderless,sm"
|
56
|
+
style={usageMetadataStyle}
|
57
|
+
/>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div className={styles.col2}>
|
61
|
+
<ModelTokenTable model_usage={stats.model_usage} />
|
62
|
+
</div>
|
63
|
+
</div>
|
64
|
+
</CardBody>
|
65
|
+
</Card>
|
66
|
+
);
|
67
|
+
};
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/**
|
2
|
+
* Resolves individual value by replacing protocol references with attachment content
|
3
|
+
*/
|
4
|
+
export const resolveAttachments = (
|
5
|
+
value: any,
|
6
|
+
attachments: Record<string, string>,
|
7
|
+
): any => {
|
8
|
+
const kContentProtocol = "tc://";
|
9
|
+
const kAttachmentProtocol = "attachment://";
|
10
|
+
|
11
|
+
// Handle arrays recursively
|
12
|
+
if (Array.isArray(value)) {
|
13
|
+
return value.map((v) => resolveAttachments(v, attachments));
|
14
|
+
}
|
15
|
+
|
16
|
+
// Handle objects recursively
|
17
|
+
if (value && typeof value === "object") {
|
18
|
+
const resolvedObject: Record<string, unknown> = {};
|
19
|
+
for (const key of Object.keys(value)) {
|
20
|
+
resolvedObject[key] = resolveAttachments(value[key], attachments);
|
21
|
+
}
|
22
|
+
return resolvedObject;
|
23
|
+
}
|
24
|
+
|
25
|
+
// Handle string values with protocol references
|
26
|
+
if (typeof value === "string") {
|
27
|
+
let resolvedValue = value;
|
28
|
+
if (resolvedValue.startsWith(kContentProtocol)) {
|
29
|
+
resolvedValue = resolvedValue.replace(
|
30
|
+
kContentProtocol,
|
31
|
+
kAttachmentProtocol,
|
32
|
+
);
|
33
|
+
}
|
34
|
+
if (resolvedValue.startsWith(kAttachmentProtocol)) {
|
35
|
+
return attachments[resolvedValue.replace(kAttachmentProtocol, "")];
|
36
|
+
}
|
37
|
+
return resolvedValue;
|
38
|
+
}
|
39
|
+
|
40
|
+
// Return unchanged for other types
|
41
|
+
return value;
|
42
|
+
};
|
@@ -1,12 +1,7 @@
|
|
1
|
-
// @ts-check
|
2
|
-
|
3
1
|
/**
|
4
2
|
* Determines whether a string is a base64 encoded string
|
5
|
-
*
|
6
|
-
* @param {string} str - The string to check
|
7
|
-
* @returns {boolean} - Whether the string is a base64 encoded string
|
8
3
|
*/
|
9
|
-
export const isBase64 = (str) => {
|
4
|
+
export const isBase64 = (str: string): boolean => {
|
10
5
|
const base64Pattern =
|
11
6
|
/^(?:[A-Za-z0-9+/]{4})*?(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
|
12
7
|
return base64Pattern.test(str);
|
@@ -0,0 +1,28 @@
|
|
1
|
+
export function printCircularReferences(obj: Record<string, unknown>): void {
|
2
|
+
const seenObjects = new WeakMap<object, string>();
|
3
|
+
|
4
|
+
function detect(value: unknown, path: string = ""): void {
|
5
|
+
// Only proceed if value is an object (not null)
|
6
|
+
if (value !== null && typeof value === "object") {
|
7
|
+
// Check if we've seen this object before
|
8
|
+
if (seenObjects.has(value as object)) {
|
9
|
+
console.log(
|
10
|
+
`Circular reference detected at path: ${seenObjects.get(value as object)}`,
|
11
|
+
);
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
|
15
|
+
// Store the current path for this object
|
16
|
+
seenObjects.set(value as object, path);
|
17
|
+
|
18
|
+
// Recursively check all properties
|
19
|
+
for (const key in value) {
|
20
|
+
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
21
|
+
detect((value as Record<string, unknown>)[key], `${path}.${key}`);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
detect(obj, "root");
|
28
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { useEffect, useRef } from "react";
|
2
|
+
|
3
|
+
// Custom hook to observe size changes
|
4
|
+
export const useResizeObserver = (
|
5
|
+
callback: (entry: ResizeObserverEntry) => void,
|
6
|
+
) => {
|
7
|
+
const elementRef = useRef<HTMLDivElement>(null);
|
8
|
+
const observerRef = useRef<ResizeObserver | null>(null);
|
9
|
+
|
10
|
+
useEffect(() => {
|
11
|
+
const element = elementRef.current;
|
12
|
+
if (!element) return;
|
13
|
+
|
14
|
+
observerRef.current = new ResizeObserver((entries) => {
|
15
|
+
if (entries[0]) {
|
16
|
+
callback(entries[0]);
|
17
|
+
}
|
18
|
+
});
|
19
|
+
|
20
|
+
observerRef.current.observe(element);
|
21
|
+
|
22
|
+
return () => {
|
23
|
+
if (observerRef.current) {
|
24
|
+
observerRef.current.disconnect();
|
25
|
+
}
|
26
|
+
};
|
27
|
+
}, [callback]);
|
28
|
+
|
29
|
+
return elementRef;
|
30
|
+
};
|
@@ -0,0 +1,194 @@
|
|
1
|
+
import {
|
2
|
+
ChatMessageAssistant,
|
3
|
+
ChatMessageSystem,
|
4
|
+
ChatMessageTool,
|
5
|
+
ChatMessageUser,
|
6
|
+
} from "../types/log";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Converts an array or a single value to a comma-separated string.
|
10
|
+
*/
|
11
|
+
export const arrayToString = (val: string | string[]): string => {
|
12
|
+
val = Array.isArray(val) ? val : [val];
|
13
|
+
return val.join(", ");
|
14
|
+
};
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Gets a string for a sample input.
|
18
|
+
*/
|
19
|
+
export const inputString = (
|
20
|
+
input:
|
21
|
+
| string
|
22
|
+
| Array<
|
23
|
+
| ChatMessageUser
|
24
|
+
| ChatMessageSystem
|
25
|
+
| ChatMessageAssistant
|
26
|
+
| ChatMessageTool
|
27
|
+
>,
|
28
|
+
): string[] => {
|
29
|
+
if (typeof input === "string") {
|
30
|
+
return [input];
|
31
|
+
} else {
|
32
|
+
return input.map((inp) => {
|
33
|
+
if (typeof inp === "string") {
|
34
|
+
return inp;
|
35
|
+
} else {
|
36
|
+
const content = inp.content;
|
37
|
+
if (typeof content === "string") {
|
38
|
+
return content;
|
39
|
+
} else {
|
40
|
+
const result = content.map((con) => {
|
41
|
+
if (con.type === "text") {
|
42
|
+
return con.text;
|
43
|
+
} else {
|
44
|
+
return "";
|
45
|
+
}
|
46
|
+
});
|
47
|
+
return result.join("\n");
|
48
|
+
}
|
49
|
+
}
|
50
|
+
});
|
51
|
+
}
|
52
|
+
};
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Formats dataset information into a string.
|
56
|
+
*/
|
57
|
+
export const formatDataset = (
|
58
|
+
samples: number,
|
59
|
+
epochs: number,
|
60
|
+
name: string | null,
|
61
|
+
): string => {
|
62
|
+
const perEpochSamples = epochs > 0 ? samples / epochs : samples;
|
63
|
+
const namePrefix = name ? `${name} — ` : "";
|
64
|
+
|
65
|
+
const terms: string[] = [
|
66
|
+
namePrefix,
|
67
|
+
String(perEpochSamples),
|
68
|
+
epochs > 1 ? `x ${epochs} ` : "",
|
69
|
+
samples === 1 ? "sample" : "samples",
|
70
|
+
];
|
71
|
+
|
72
|
+
return terms.join(" ");
|
73
|
+
};
|
74
|
+
|
75
|
+
/**
|
76
|
+
* Formats a duration given in seconds into a human-readable string.
|
77
|
+
*/
|
78
|
+
export const formatTime = (seconds: number): string => {
|
79
|
+
if (seconds < 60) {
|
80
|
+
return `${seconds} sec`;
|
81
|
+
} else if (seconds < 60 * 60) {
|
82
|
+
return `${Math.floor(seconds / 60)} min ${seconds % 60} sec`;
|
83
|
+
} else if (seconds < 60 * 60 * 24) {
|
84
|
+
const hours = Math.floor(seconds / (60 * 60));
|
85
|
+
const minutes = Math.floor((seconds % (60 * 60)) / 60);
|
86
|
+
const remainingSeconds = seconds % 60;
|
87
|
+
return `${hours} hr ${minutes} min ${remainingSeconds} sec`;
|
88
|
+
} else {
|
89
|
+
const days = Math.floor(seconds / (60 * 60 * 24));
|
90
|
+
const hours = Math.floor((seconds % (60 * 60 * 24)) / (60 * 60));
|
91
|
+
const minutes = Math.floor((seconds % (60 * 60)) / 60);
|
92
|
+
const remainingSeconds = seconds % 60;
|
93
|
+
return `${days} days ${hours} hr ${minutes} min ${remainingSeconds} sec`;
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
/**
|
98
|
+
* Formats a number to a string with specific decimal places for prettiness.
|
99
|
+
*/
|
100
|
+
export function formatPrettyDecimal(num: number): string {
|
101
|
+
const numDecimalPlaces = num.toString().includes(".")
|
102
|
+
? num.toString().split(".")[1].length
|
103
|
+
: 0;
|
104
|
+
|
105
|
+
if (numDecimalPlaces === 0) {
|
106
|
+
return num.toFixed(1);
|
107
|
+
} else if (numDecimalPlaces > 3) {
|
108
|
+
return num.toFixed(3);
|
109
|
+
} else {
|
110
|
+
return num.toString();
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
/**
|
115
|
+
* Formats a number to a string without trailing zeroes after the decimal point.
|
116
|
+
*/
|
117
|
+
export function formatDecimalNoTrailingZeroes(num: number): string {
|
118
|
+
// This isn't a number, continue
|
119
|
+
// TODO: Remove this, its crazy
|
120
|
+
if (typeof num !== "number") {
|
121
|
+
return num;
|
122
|
+
}
|
123
|
+
|
124
|
+
if (num.toString().includes(".")) {
|
125
|
+
const decimal = num.toString().split(".")[1];
|
126
|
+
const trimmed = decimal.replace(/\.?0+$/, "");
|
127
|
+
return num.toFixed(trimmed.length);
|
128
|
+
} else {
|
129
|
+
return num.toFixed(0);
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Converts a string to title case.
|
135
|
+
*/
|
136
|
+
export function toTitleCase(str: string): string {
|
137
|
+
return str
|
138
|
+
.split(" ")
|
139
|
+
.map((w) => w[0].toUpperCase() + w.substr(1).toLowerCase())
|
140
|
+
.join(" ");
|
141
|
+
}
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Formats a number to a string without trailing zeroes after the decimal point.
|
145
|
+
*/
|
146
|
+
export function formatNoDecimal(num: number): string {
|
147
|
+
// This isn't a number, continue
|
148
|
+
// TODO: remove This is crazy
|
149
|
+
if (typeof num !== "number") {
|
150
|
+
return num;
|
151
|
+
}
|
152
|
+
|
153
|
+
// Round to a whole number
|
154
|
+
const rounded = Math.round(num);
|
155
|
+
return rounded.toFixed(0);
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
* Formats a number to a string without trailing zeroes after the decimal point.
|
160
|
+
*/
|
161
|
+
export function formatNumber(num: number): string {
|
162
|
+
return num.toLocaleString(navigator.language, {
|
163
|
+
minimumFractionDigits: 0,
|
164
|
+
maximumFractionDigits: 5,
|
165
|
+
});
|
166
|
+
}
|
167
|
+
|
168
|
+
/**
|
169
|
+
* Formats a number to a string without trailing zeroes after the decimal point.
|
170
|
+
*/
|
171
|
+
export function formatDateTime(date: Date): string {
|
172
|
+
const options = {
|
173
|
+
year: "2-digit",
|
174
|
+
month: "2-digit",
|
175
|
+
day: "2-digit",
|
176
|
+
hour: "numeric",
|
177
|
+
minute: "2-digit",
|
178
|
+
second: "2-digit",
|
179
|
+
hour12: true,
|
180
|
+
};
|
181
|
+
|
182
|
+
// Use the default system locale and timezone
|
183
|
+
// @ts-ignore
|
184
|
+
return new Intl.DateTimeFormat(undefined, options).format(date);
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Returns the formatted duration between two dates
|
189
|
+
*/
|
190
|
+
export function formatDuration(start: Date, end: Date): string {
|
191
|
+
const durationMs = end.getTime() - start.getTime();
|
192
|
+
const durationSec = durationMs / 1000;
|
193
|
+
return formatTime(durationSec);
|
194
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Fetches a range of bytes from a remote resource and returns it as a `Uint8Array`.
|
3
|
+
*/
|
4
|
+
export const fetchRange = async (
|
5
|
+
url: string,
|
6
|
+
start: number,
|
7
|
+
end: number,
|
8
|
+
): Promise<Uint8Array> => {
|
9
|
+
const response = await fetch(url, {
|
10
|
+
headers: { Range: `bytes=${start}-${end}` },
|
11
|
+
});
|
12
|
+
const arrayBuffer = await response.arrayBuffer();
|
13
|
+
return new Uint8Array(arrayBuffer);
|
14
|
+
};
|
@@ -1,11 +1,7 @@
|
|
1
|
-
// @ts-check
|
2
1
|
/**
|
3
2
|
* Extracts the filename without extension from a given path.
|
4
|
-
*
|
5
|
-
* @param {string} path - The full path of the file.
|
6
|
-
* @returns {string} - The filename without its extension, or the original path if no extension is found.
|
7
3
|
*/
|
8
|
-
export const filename = (path) => {
|
4
|
+
export const filename = (path: string): string => {
|
9
5
|
const pathparts = path.split("/");
|
10
6
|
const basename = pathparts.slice(-1)[0];
|
11
7
|
const match = basename.match(/(.*)\.\S+$/);
|
@@ -18,11 +14,8 @@ export const filename = (path) => {
|
|
18
14
|
|
19
15
|
/**
|
20
16
|
* Extracts the directory name from a given path.
|
21
|
-
*
|
22
|
-
* @param {string} path - The full path of the file.
|
23
|
-
* @returns {string} - The directory name, or an empty string if no directory is found.
|
24
17
|
*/
|
25
|
-
export const dirname = (path) => {
|
18
|
+
export const dirname = (path: string): string => {
|
26
19
|
const pathparts = path.split("/");
|
27
20
|
|
28
21
|
// If the path ends with a filename (or no slashes), remove the last part (filename)
|
@@ -1,22 +1,19 @@
|
|
1
1
|
/**
|
2
2
|
* Opens a new window and prints the provided HTML content with optional custom CSS for printing.
|
3
3
|
*
|
4
|
-
* @param {string} html - The HTML content to be printed in the new window.
|
5
|
-
* @param {string} css - Custom CSS that will be applied when the print media is active.
|
6
|
-
*
|
7
|
-
* @example
|
8
4
|
* // Example usage:
|
9
5
|
* printHtml('<h1>Hello World</h1>', 'h1 { color: red; }');
|
10
6
|
*/
|
11
|
-
export const printHtml = (html, css) => {
|
7
|
+
export const printHtml = (html: string, css: string) => {
|
12
8
|
// Open a new window
|
13
9
|
const printWindow = window.open("", "", "height=600,width=800");
|
14
10
|
|
15
|
-
|
16
|
-
|
11
|
+
if (printWindow !== null) {
|
12
|
+
// Write the element's content into the new window
|
13
|
+
printWindow.document.write("<html><head><title>Print</title>");
|
17
14
|
|
18
|
-
|
19
|
-
|
15
|
+
// Inject custom print CSS
|
16
|
+
printWindow.document.write(`
|
20
17
|
<link rel="stylesheet" crossorigin="" href="./assets/index.css">
|
21
18
|
<style>
|
22
19
|
@media print {
|
@@ -25,19 +22,22 @@ export const printHtml = (html, css) => {
|
|
25
22
|
</style>
|
26
23
|
`);
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
printWindow.document.write("</head><body>");
|
26
|
+
printWindow.document.write(html);
|
27
|
+
printWindow.document.write("</body></html>");
|
31
28
|
|
32
|
-
|
33
|
-
|
29
|
+
// Close the document to complete the writing process
|
30
|
+
printWindow.document.close();
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
// Wait for the window to load fully before triggering the print
|
33
|
+
printWindow.onload = function () {
|
34
|
+
printWindow.focus(); // Ensure the window is focused
|
35
|
+
printWindow.print(); // Trigger the print
|
36
|
+
printWindow.close(); // Close the window after printing
|
37
|
+
};
|
38
|
+
} else {
|
39
|
+
console.error("Print window failed to open.");
|
40
|
+
}
|
41
41
|
};
|
42
42
|
|
43
43
|
/**
|
@@ -47,17 +47,25 @@ export const printHtml = (html, css) => {
|
|
47
47
|
* 'task-model', and 'task-created', respectively. The generated HTML will display these elements in a
|
48
48
|
* three-column grid with custom styling.
|
49
49
|
*
|
50
|
-
* @returns {string} - The generated HTML string containing the task information.
|
51
|
-
*
|
52
50
|
* @example
|
53
51
|
* // Example usage:
|
54
52
|
* const headingHtml = printHeadingHtml();
|
55
53
|
* console.log(headingHtml);
|
56
54
|
*/
|
57
|
-
export const printHeadingHtml = () => {
|
58
|
-
const
|
59
|
-
const
|
60
|
-
const
|
55
|
+
export const printHeadingHtml = (): string => {
|
56
|
+
const taskEl = document.getElementById("task-title");
|
57
|
+
const modelEl = document.getElementById("task-model");
|
58
|
+
const timeEl = document.getElementById("task-created");
|
59
|
+
|
60
|
+
if (!taskEl || !modelEl || !timeEl) {
|
61
|
+
throw new Error(
|
62
|
+
"Failed to compute heading HTML. The task, model, or time element can't be found.",
|
63
|
+
);
|
64
|
+
}
|
65
|
+
|
66
|
+
const task = taskEl.innerText;
|
67
|
+
const model = modelEl.innerText;
|
68
|
+
const time = timeEl.innerText;
|
61
69
|
|
62
70
|
// Get the task name, date, model
|
63
71
|
const headingHtml = `
|