inspect-ai 0.3.49__py3-none-any.whl → 0.3.51__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/info.py +2 -2
- inspect_ai/_cli/log.py +2 -2
- inspect_ai/_cli/score.py +2 -2
- inspect_ai/_display/core/display.py +19 -0
- inspect_ai/_display/core/panel.py +37 -7
- inspect_ai/_display/core/progress.py +29 -2
- inspect_ai/_display/core/results.py +79 -40
- inspect_ai/_display/core/textual.py +21 -0
- inspect_ai/_display/rich/display.py +28 -8
- inspect_ai/_display/textual/app.py +107 -1
- inspect_ai/_display/textual/display.py +1 -1
- inspect_ai/_display/textual/widgets/samples.py +132 -91
- inspect_ai/_display/textual/widgets/task_detail.py +236 -0
- inspect_ai/_display/textual/widgets/tasks.py +74 -6
- inspect_ai/_display/textual/widgets/toggle.py +32 -0
- inspect_ai/_eval/context.py +2 -0
- inspect_ai/_eval/eval.py +4 -3
- inspect_ai/_eval/loader.py +1 -1
- inspect_ai/_eval/run.py +35 -2
- inspect_ai/_eval/task/log.py +13 -11
- inspect_ai/_eval/task/results.py +12 -3
- inspect_ai/_eval/task/run.py +139 -36
- inspect_ai/_eval/task/sandbox.py +2 -1
- inspect_ai/_util/_async.py +30 -1
- inspect_ai/_util/file.py +31 -4
- inspect_ai/_util/html.py +3 -0
- inspect_ai/_util/logger.py +6 -5
- inspect_ai/_util/platform.py +5 -6
- inspect_ai/_util/registry.py +1 -1
- inspect_ai/_view/server.py +9 -9
- inspect_ai/_view/www/App.css +2 -2
- inspect_ai/_view/www/dist/assets/index.css +2 -2
- inspect_ai/_view/www/dist/assets/index.js +352 -294
- inspect_ai/_view/www/log-schema.json +13 -0
- inspect_ai/_view/www/package.json +1 -0
- inspect_ai/_view/www/src/components/MessageBand.mjs +1 -1
- inspect_ai/_view/www/src/components/Tools.mjs +16 -13
- inspect_ai/_view/www/src/samples/SampleDisplay.mjs +1 -3
- inspect_ai/_view/www/src/samples/SampleScoreView.mjs +52 -77
- inspect_ai/_view/www/src/samples/SamplesDescriptor.mjs +38 -13
- inspect_ai/_view/www/src/samples/transcript/ModelEventView.mjs +15 -2
- inspect_ai/_view/www/src/samples/transcript/state/StateEventRenderers.mjs +4 -2
- inspect_ai/_view/www/src/types/log.d.ts +2 -0
- inspect_ai/_view/www/src/workspace/WorkSpace.mjs +2 -0
- inspect_ai/_view/www/yarn.lock +9 -4
- inspect_ai/approval/__init__.py +1 -1
- inspect_ai/approval/_human/approver.py +35 -0
- inspect_ai/approval/_human/console.py +62 -0
- inspect_ai/approval/_human/manager.py +108 -0
- inspect_ai/approval/_human/panel.py +233 -0
- inspect_ai/approval/_human/util.py +51 -0
- inspect_ai/dataset/_sources/hf.py +2 -2
- inspect_ai/dataset/_sources/util.py +1 -1
- inspect_ai/log/_file.py +106 -36
- inspect_ai/log/_recorders/eval.py +226 -158
- inspect_ai/log/_recorders/file.py +9 -6
- inspect_ai/log/_recorders/json.py +35 -12
- inspect_ai/log/_recorders/recorder.py +15 -15
- inspect_ai/log/_samples.py +52 -0
- inspect_ai/model/_model.py +14 -0
- inspect_ai/model/_model_output.py +4 -0
- inspect_ai/model/_providers/azureai.py +1 -1
- inspect_ai/model/_providers/hf.py +106 -4
- inspect_ai/model/_providers/util/__init__.py +2 -0
- inspect_ai/model/_providers/util/hf_handler.py +200 -0
- inspect_ai/scorer/_common.py +1 -1
- inspect_ai/solver/_plan.py +0 -8
- inspect_ai/solver/_task_state.py +18 -1
- inspect_ai/solver/_use_tools.py +9 -1
- inspect_ai/tool/_tool_def.py +2 -2
- inspect_ai/tool/_tool_info.py +14 -2
- inspect_ai/tool/_tool_params.py +2 -1
- inspect_ai/tool/_tools/_execute.py +1 -1
- inspect_ai/tool/_tools/_web_browser/_web_browser.py +6 -0
- inspect_ai/util/__init__.py +5 -6
- inspect_ai/util/_panel.py +91 -0
- inspect_ai/util/_sandbox/__init__.py +2 -6
- inspect_ai/util/_sandbox/context.py +4 -3
- inspect_ai/util/_sandbox/docker/compose.py +12 -2
- inspect_ai/util/_sandbox/docker/docker.py +19 -9
- inspect_ai/util/_sandbox/docker/util.py +10 -2
- inspect_ai/util/_sandbox/environment.py +47 -41
- inspect_ai/util/_sandbox/local.py +15 -10
- inspect_ai/util/_subprocess.py +43 -3
- {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/METADATA +2 -2
- {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/RECORD +90 -82
- inspect_ai/_view/www/node_modules/flatted/python/flatted.py +0 -149
- inspect_ai/_view/www/node_modules/flatted/python/test.py +0 -63
- inspect_ai/approval/_human.py +0 -123
- {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/LICENSE +0 -0
- {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/WHEEL +0 -0
- {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/entry_points.txt +0 -0
- {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/top_level.txt +0 -0
inspect_ai/approval/_human.py
DELETED
@@ -1,123 +0,0 @@
|
|
1
|
-
from rich.console import RenderableType
|
2
|
-
from rich.highlighter import ReprHighlighter
|
3
|
-
from rich.prompt import Prompt
|
4
|
-
from rich.rule import Rule
|
5
|
-
from rich.text import Text
|
6
|
-
|
7
|
-
from inspect_ai._util.transcript import transcript_markdown, transcript_panel
|
8
|
-
from inspect_ai.solver._task_state import TaskState
|
9
|
-
from inspect_ai.tool._tool_call import ToolCall, ToolCallContent, ToolCallView
|
10
|
-
from inspect_ai.util._console import input_screen
|
11
|
-
from inspect_ai.util._trace import trace_enabled
|
12
|
-
|
13
|
-
from ._approval import Approval, ApprovalDecision
|
14
|
-
from ._approver import Approver
|
15
|
-
from ._registry import approver
|
16
|
-
|
17
|
-
|
18
|
-
@approver(name="human")
|
19
|
-
def human_approver(
|
20
|
-
choices: list[ApprovalDecision] = ["approve", "reject", "terminate"],
|
21
|
-
) -> Approver:
|
22
|
-
"""Interactive human approver.
|
23
|
-
|
24
|
-
Returns:
|
25
|
-
Approver: Interactive human approver.
|
26
|
-
"""
|
27
|
-
# text highlither
|
28
|
-
text_highlighter = ReprHighlighter()
|
29
|
-
|
30
|
-
async def approve(
|
31
|
-
message: str,
|
32
|
-
call: ToolCall,
|
33
|
-
view: ToolCallView,
|
34
|
-
state: TaskState | None = None,
|
35
|
-
) -> Approval:
|
36
|
-
with input_screen(width=None) as console:
|
37
|
-
renderables: list[RenderableType] = []
|
38
|
-
|
39
|
-
# ignore content if trace enabled
|
40
|
-
message = message if not trace_enabled() else ""
|
41
|
-
|
42
|
-
def add_view_content(view_content: ToolCallContent) -> None:
|
43
|
-
if view_content.title:
|
44
|
-
renderables.append(
|
45
|
-
Text.from_markup(f"[bold]{view_content.title}[/bold]\n")
|
46
|
-
)
|
47
|
-
if view_content.format == "markdown":
|
48
|
-
renderables.append(transcript_markdown(view_content.content))
|
49
|
-
else:
|
50
|
-
text_content = text_highlighter(Text(view_content.content))
|
51
|
-
renderables.append(text_content)
|
52
|
-
|
53
|
-
# assistant content (don't add if trace_enabled as we already have it in that case)
|
54
|
-
if message:
|
55
|
-
renderables.append(Text.from_markup("[bold]Assistant[/bold]\n"))
|
56
|
-
renderables.append(Text(f"{message.strip()}"))
|
57
|
-
|
58
|
-
# extra context provided by tool view
|
59
|
-
if view.context:
|
60
|
-
renderables.append(Text())
|
61
|
-
add_view_content(view.context)
|
62
|
-
renderables.append(Text())
|
63
|
-
|
64
|
-
# tool call view
|
65
|
-
if view.call:
|
66
|
-
if message or view.context:
|
67
|
-
renderables.append(Rule("", style="bold", align="left"))
|
68
|
-
renderables.append(Text())
|
69
|
-
add_view_content(view.call)
|
70
|
-
renderables.append(Text())
|
71
|
-
|
72
|
-
console.print(transcript_panel(title="Approve Tool", content=renderables))
|
73
|
-
|
74
|
-
# provide choices
|
75
|
-
prompts: dict[str, str] = {}
|
76
|
-
for choice in choices:
|
77
|
-
prompts[choice[0]] = f"{choice.capitalize()} ({choice[0]})"
|
78
|
-
values = list(prompts.values())
|
79
|
-
prompt = ", ".join(values[:-1])
|
80
|
-
prompt = f"{prompt}, or {values[-1]}"
|
81
|
-
|
82
|
-
def render_approval(approval: Approval) -> Approval:
|
83
|
-
console.print(f"Decision: {approval.decision.capitalize()}")
|
84
|
-
return approval
|
85
|
-
|
86
|
-
while True:
|
87
|
-
decision = Prompt.ask(
|
88
|
-
prompt=prompt,
|
89
|
-
console=console,
|
90
|
-
choices=list(prompts.keys()),
|
91
|
-
default="a",
|
92
|
-
).lower()
|
93
|
-
|
94
|
-
if decision == "a":
|
95
|
-
return render_approval(
|
96
|
-
Approval(
|
97
|
-
decision="approve",
|
98
|
-
explanation="Human operator approved tool call.",
|
99
|
-
)
|
100
|
-
)
|
101
|
-
elif decision == "r":
|
102
|
-
return render_approval(
|
103
|
-
Approval(
|
104
|
-
decision="reject",
|
105
|
-
explanation="Human operator rejected the tool call.",
|
106
|
-
)
|
107
|
-
)
|
108
|
-
elif decision == "t":
|
109
|
-
return render_approval(
|
110
|
-
Approval(
|
111
|
-
decision="terminate",
|
112
|
-
explanation="Human operator asked that the sample be terminated.",
|
113
|
-
)
|
114
|
-
)
|
115
|
-
elif decision == "e":
|
116
|
-
return render_approval(
|
117
|
-
Approval(
|
118
|
-
decision="escalate",
|
119
|
-
explanation="Human operator escalated the tool call approval.",
|
120
|
-
)
|
121
|
-
)
|
122
|
-
|
123
|
-
return approve
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|