inspect-ai 0.3.48__py3-none-any.whl → 0.3.50__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 (97) 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 +112 -3
  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 +232 -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 +47 -5
  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 +395 -307
  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 +27 -16
  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/tools/SortFilter.mjs +40 -18
  42. inspect_ai/_view/www/src/samples/transcript/ModelEventView.mjs +15 -2
  43. inspect_ai/_view/www/src/samples/transcript/state/StateEventRenderers.mjs +4 -2
  44. inspect_ai/_view/www/src/types/log.d.ts +2 -0
  45. inspect_ai/_view/www/src/utils/debugging.mjs +23 -0
  46. inspect_ai/_view/www/src/workspace/WorkSpace.mjs +2 -0
  47. inspect_ai/_view/www/yarn.lock +9 -4
  48. inspect_ai/approval/__init__.py +1 -1
  49. inspect_ai/approval/_human/approver.py +35 -0
  50. inspect_ai/approval/_human/console.py +62 -0
  51. inspect_ai/approval/_human/manager.py +108 -0
  52. inspect_ai/approval/_human/panel.py +233 -0
  53. inspect_ai/approval/_human/util.py +51 -0
  54. inspect_ai/dataset/_sources/hf.py +2 -2
  55. inspect_ai/dataset/_sources/util.py +1 -1
  56. inspect_ai/log/_file.py +106 -36
  57. inspect_ai/log/_recorders/eval.py +226 -158
  58. inspect_ai/log/_recorders/file.py +9 -6
  59. inspect_ai/log/_recorders/json.py +35 -12
  60. inspect_ai/log/_recorders/recorder.py +15 -15
  61. inspect_ai/log/_samples.py +52 -0
  62. inspect_ai/model/_model.py +14 -0
  63. inspect_ai/model/_model_output.py +4 -0
  64. inspect_ai/model/_providers/azureai.py +1 -1
  65. inspect_ai/model/_providers/hf.py +106 -4
  66. inspect_ai/model/_providers/util/__init__.py +2 -0
  67. inspect_ai/model/_providers/util/hf_handler.py +200 -0
  68. inspect_ai/scorer/_common.py +1 -1
  69. inspect_ai/solver/_plan.py +0 -8
  70. inspect_ai/solver/_task_state.py +18 -1
  71. inspect_ai/solver/_use_tools.py +9 -1
  72. inspect_ai/tool/_tool_call.py +1 -1
  73. inspect_ai/tool/_tool_def.py +2 -2
  74. inspect_ai/tool/_tool_info.py +14 -2
  75. inspect_ai/tool/_tool_params.py +2 -1
  76. inspect_ai/tool/_tools/_execute.py +1 -1
  77. inspect_ai/tool/_tools/_web_browser/_web_browser.py +6 -0
  78. inspect_ai/util/__init__.py +5 -6
  79. inspect_ai/util/_panel.py +91 -0
  80. inspect_ai/util/_sandbox/__init__.py +2 -6
  81. inspect_ai/util/_sandbox/context.py +4 -3
  82. inspect_ai/util/_sandbox/docker/compose.py +12 -2
  83. inspect_ai/util/_sandbox/docker/docker.py +19 -9
  84. inspect_ai/util/_sandbox/docker/util.py +10 -2
  85. inspect_ai/util/_sandbox/environment.py +47 -41
  86. inspect_ai/util/_sandbox/local.py +15 -10
  87. inspect_ai/util/_sandbox/self_check.py +6 -3
  88. inspect_ai/util/_subprocess.py +43 -3
  89. {inspect_ai-0.3.48.dist-info → inspect_ai-0.3.50.dist-info}/METADATA +2 -2
  90. {inspect_ai-0.3.48.dist-info → inspect_ai-0.3.50.dist-info}/RECORD +94 -85
  91. inspect_ai/_view/www/node_modules/flatted/python/flatted.py +0 -149
  92. inspect_ai/_view/www/node_modules/flatted/python/test.py +0 -63
  93. inspect_ai/approval/_human.py +0 -123
  94. {inspect_ai-0.3.48.dist-info → inspect_ai-0.3.50.dist-info}/LICENSE +0 -0
  95. {inspect_ai-0.3.48.dist-info → inspect_ai-0.3.50.dist-info}/WHEEL +0 -0
  96. {inspect_ai-0.3.48.dist-info → inspect_ai-0.3.50.dist-info}/entry_points.txt +0 -0
  97. {inspect_ai-0.3.48.dist-info → inspect_ai-0.3.50.dist-info}/top_level.txt +0 -0
@@ -1,63 +0,0 @@
1
- from flatted import stringify as _stringify, parse
2
-
3
- def stringify(value):
4
- return _stringify(value, separators=(',', ':'))
5
-
6
- assert stringify([None, None]) == '[[null,null]]'
7
-
8
- a = []
9
- o = {}
10
-
11
- assert stringify(a) == '[[]]'
12
- assert stringify(o) == '[{}]'
13
-
14
- a.append(a)
15
- o['o'] = o
16
-
17
- assert stringify(a) == '[["0"]]'
18
- assert stringify(o) == '[{"o":"0"}]'
19
-
20
- b = parse(stringify(a))
21
- assert isinstance(b, list) and b[0] == b
22
-
23
- a.append(1)
24
- a.append('two')
25
- a.append(True)
26
- o['one'] = 1
27
- o['two'] = 'two'
28
- o['three'] = True
29
-
30
- assert stringify(a) == '[["0",1,"1",true],"two"]'
31
- assert stringify(o) == '[{"o":"0","one":1,"two":"1","three":true},"two"]'
32
-
33
- a.append(o)
34
- o['a'] = a
35
-
36
- assert stringify(a) == '[["0",1,"1",true,"2"],"two",{"o":"2","one":1,"two":"1","three":true,"a":"0"}]'
37
- assert stringify(o) == '[{"o":"0","one":1,"two":"1","three":true,"a":"2"},"two",["2",1,"1",true,"0"]]'
38
-
39
- a.append({'test': 'OK'})
40
- a.append([1, 2, 3])
41
-
42
- o['test'] = {'test': 'OK'}
43
- o['array'] = [1, 2, 3]
44
-
45
- assert stringify(a) == '[["0",1,"1",true,"2","3","4"],"two",{"o":"2","one":1,"two":"1","three":true,"a":"0","test":"3","array":"4"},{"test":"5"},[1,2,3],"OK"]'
46
- assert stringify(o) == '[{"o":"0","one":1,"two":"1","three":true,"a":"2","test":"3","array":"4"},"two",["2",1,"1",true,"0","3","4"],{"test":"5"},[1,2,3],"OK"]'
47
-
48
- a2 = parse(stringify(a));
49
- o2 = parse(stringify(o));
50
-
51
- assert a2[0] == a2
52
- assert o2['o'] == o2
53
-
54
- assert a2[1] == 1 and a2[2] == 'two' and a2[3] == True and isinstance(a2[4], dict)
55
- assert a2[4] == a2[4]['o'] and a2 == a2[4]['o']['a']
56
-
57
- str = parse('[{"prop":"1","a":"2","b":"3"},{"value":123},["4","5"],{"e":"6","t":"7","p":4},{},{"b":"8"},"f",{"a":"9"},["10"],"sup",{"a":1,"d":2,"c":"7","z":"11","h":1},{"g":2,"a":"7","b":"12","f":6},{"r":4,"u":"7","c":5}]')
58
- assert str['b']['t']['a'] == 'sup' and str['a'][1]['b'][0]['c'] == str['b']['t']
59
-
60
- oo = parse('[{"a":"1","b":"0","c":"2"},{"aa":"3"},{"ca":"4","cb":"5","cc":"6","cd":"7","ce":"8","cf":"9"},{"aaa":"10"},{"caa":"4"},{"cba":"5"},{"cca":"2"},{"cda":"4"},"value2","value3","value1"]');
61
- assert oo['a']['aa']['aaa'] == 'value1' and oo == oo['b'] and oo['c']['ca']['caa'] == oo['c']['ca']
62
-
63
- print('OK')
@@ -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