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.
Files changed (93) hide show
  1. inspect_ai/_cli/info.py +2 -2
  2. inspect_ai/_cli/log.py +2 -2
  3. inspect_ai/_cli/score.py +2 -2
  4. inspect_ai/_display/core/display.py +19 -0
  5. inspect_ai/_display/core/panel.py +37 -7
  6. inspect_ai/_display/core/progress.py +29 -2
  7. inspect_ai/_display/core/results.py +79 -40
  8. inspect_ai/_display/core/textual.py +21 -0
  9. inspect_ai/_display/rich/display.py +28 -8
  10. inspect_ai/_display/textual/app.py +107 -1
  11. inspect_ai/_display/textual/display.py +1 -1
  12. inspect_ai/_display/textual/widgets/samples.py +132 -91
  13. inspect_ai/_display/textual/widgets/task_detail.py +236 -0
  14. inspect_ai/_display/textual/widgets/tasks.py +74 -6
  15. inspect_ai/_display/textual/widgets/toggle.py +32 -0
  16. inspect_ai/_eval/context.py +2 -0
  17. inspect_ai/_eval/eval.py +4 -3
  18. inspect_ai/_eval/loader.py +1 -1
  19. inspect_ai/_eval/run.py +35 -2
  20. inspect_ai/_eval/task/log.py +13 -11
  21. inspect_ai/_eval/task/results.py +12 -3
  22. inspect_ai/_eval/task/run.py +139 -36
  23. inspect_ai/_eval/task/sandbox.py +2 -1
  24. inspect_ai/_util/_async.py +30 -1
  25. inspect_ai/_util/file.py +31 -4
  26. inspect_ai/_util/html.py +3 -0
  27. inspect_ai/_util/logger.py +6 -5
  28. inspect_ai/_util/platform.py +5 -6
  29. inspect_ai/_util/registry.py +1 -1
  30. inspect_ai/_view/server.py +9 -9
  31. inspect_ai/_view/www/App.css +2 -2
  32. inspect_ai/_view/www/dist/assets/index.css +2 -2
  33. inspect_ai/_view/www/dist/assets/index.js +352 -294
  34. inspect_ai/_view/www/log-schema.json +13 -0
  35. inspect_ai/_view/www/package.json +1 -0
  36. inspect_ai/_view/www/src/components/MessageBand.mjs +1 -1
  37. inspect_ai/_view/www/src/components/Tools.mjs +16 -13
  38. inspect_ai/_view/www/src/samples/SampleDisplay.mjs +1 -3
  39. inspect_ai/_view/www/src/samples/SampleScoreView.mjs +52 -77
  40. inspect_ai/_view/www/src/samples/SamplesDescriptor.mjs +38 -13
  41. inspect_ai/_view/www/src/samples/transcript/ModelEventView.mjs +15 -2
  42. inspect_ai/_view/www/src/samples/transcript/state/StateEventRenderers.mjs +4 -2
  43. inspect_ai/_view/www/src/types/log.d.ts +2 -0
  44. inspect_ai/_view/www/src/workspace/WorkSpace.mjs +2 -0
  45. inspect_ai/_view/www/yarn.lock +9 -4
  46. inspect_ai/approval/__init__.py +1 -1
  47. inspect_ai/approval/_human/approver.py +35 -0
  48. inspect_ai/approval/_human/console.py +62 -0
  49. inspect_ai/approval/_human/manager.py +108 -0
  50. inspect_ai/approval/_human/panel.py +233 -0
  51. inspect_ai/approval/_human/util.py +51 -0
  52. inspect_ai/dataset/_sources/hf.py +2 -2
  53. inspect_ai/dataset/_sources/util.py +1 -1
  54. inspect_ai/log/_file.py +106 -36
  55. inspect_ai/log/_recorders/eval.py +226 -158
  56. inspect_ai/log/_recorders/file.py +9 -6
  57. inspect_ai/log/_recorders/json.py +35 -12
  58. inspect_ai/log/_recorders/recorder.py +15 -15
  59. inspect_ai/log/_samples.py +52 -0
  60. inspect_ai/model/_model.py +14 -0
  61. inspect_ai/model/_model_output.py +4 -0
  62. inspect_ai/model/_providers/azureai.py +1 -1
  63. inspect_ai/model/_providers/hf.py +106 -4
  64. inspect_ai/model/_providers/util/__init__.py +2 -0
  65. inspect_ai/model/_providers/util/hf_handler.py +200 -0
  66. inspect_ai/scorer/_common.py +1 -1
  67. inspect_ai/solver/_plan.py +0 -8
  68. inspect_ai/solver/_task_state.py +18 -1
  69. inspect_ai/solver/_use_tools.py +9 -1
  70. inspect_ai/tool/_tool_def.py +2 -2
  71. inspect_ai/tool/_tool_info.py +14 -2
  72. inspect_ai/tool/_tool_params.py +2 -1
  73. inspect_ai/tool/_tools/_execute.py +1 -1
  74. inspect_ai/tool/_tools/_web_browser/_web_browser.py +6 -0
  75. inspect_ai/util/__init__.py +5 -6
  76. inspect_ai/util/_panel.py +91 -0
  77. inspect_ai/util/_sandbox/__init__.py +2 -6
  78. inspect_ai/util/_sandbox/context.py +4 -3
  79. inspect_ai/util/_sandbox/docker/compose.py +12 -2
  80. inspect_ai/util/_sandbox/docker/docker.py +19 -9
  81. inspect_ai/util/_sandbox/docker/util.py +10 -2
  82. inspect_ai/util/_sandbox/environment.py +47 -41
  83. inspect_ai/util/_sandbox/local.py +15 -10
  84. inspect_ai/util/_subprocess.py +43 -3
  85. {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/METADATA +2 -2
  86. {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/RECORD +90 -82
  87. inspect_ai/_view/www/node_modules/flatted/python/flatted.py +0 -149
  88. inspect_ai/_view/www/node_modules/flatted/python/test.py +0 -63
  89. inspect_ai/approval/_human.py +0 -123
  90. {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/LICENSE +0 -0
  91. {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/WHEEL +0 -0
  92. {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/entry_points.txt +0 -0
  93. {inspect_ai-0.3.49.dist-info → inspect_ai-0.3.51.dist-info}/top_level.txt +0 -0
@@ -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