gooddata-eval 1.81.1.dev3__py3-none-any.whl → 1.81.1.dev4__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.
@@ -12,6 +12,7 @@ import re
12
12
  from dataclasses import dataclass, field
13
13
  from typing import Any
14
14
 
15
+ from gooddata_eval.core.chat.sse_client import UNHANDLED_PART_TYPES
15
16
  from gooddata_eval.core.models import ChatResult, ToolCallEvent
16
17
 
17
18
  SEARCH_TOOL = "search_objects"
@@ -30,6 +31,10 @@ SEARCH_OPTION_KEYS = frozenset(
30
31
  "no_raw_ids",
31
32
  "setup_turns",
32
33
  "report_only",
34
+ "expect_user_requested_search",
35
+ "widget_objects",
36
+ "forbidden_parts",
37
+ "no_object_urls",
33
38
  }
34
39
  )
35
40
  _KNOWN_KEYS = SEARCH_OPTION_KEYS | {"tool_call"}
@@ -69,6 +74,34 @@ _TYPED_ID = re.compile(rf"\b(?:{'|'.join(sorted(_OBJECT_TYPES))})/([A-Za-z0-9_](
69
74
  # a dot or a digit, as the workspace ids have, counts. A one-word id such as metric/revenue is not caught.
70
75
  _ID_MARK = re.compile(r"[_.0-9]")
71
76
 
77
+ # ``forbidden_parts`` may only name a type that lands in ``unhandled_parts`` (a draft: document, report,
78
+ # dashboard), so a misspelt type cannot read as a pass.
79
+ _UNHANDLED_PART_TYPES = UNHANDLED_PART_TYPES
80
+ # A link: an absolute ``http(s)`` or ``gooddata://`` URL, or a markdown link to an app path. The UI opens an
81
+ # object from the Search list, so an object link in the text is one the model wrote itself.
82
+ _LINK = re.compile(r"(?:https?|gooddata)://[^\s<>()\[\]\"'`]+|\]\(\s*<?(/[^\s)>]+)")
83
+ # The routes that open one object, so an id segment follows the type: an app route
84
+ # (``/workspace/<ws>/reports/document/<id>``, ``/dashboards/#/workspace/<ws>/dashboard/<id>``), the entity API
85
+ # (``/entities/workspaces/<ws>/<type>/<id>``) and Analytical Designer (``/analyze/#/<ws>/<id>``). A list page
86
+ # (``/workspace/<ws>/reports``) and a help page with a ``workspaces`` segment are none of them.
87
+ _OBJECT_PATH = re.compile(
88
+ r"/workspace/[^/\s#?]+/(?:reports?|dashboards?|documents?|visualizations?|metrics?|analyze)/[^/\s#?]+"
89
+ r"|/entities/workspaces/[^/\s]+/[^/\s]+/[^/\s?#]+"
90
+ r"|/analyze/#/[^/\s]+/[^/\s]+",
91
+ re.IGNORECASE,
92
+ )
93
+ # A made-up object link on any host: the path ends in an object type and an id
94
+ # (``https://analytics.gooddata.com/documents/<id>``). An id has a ``_``, a dot or a digit; a help page slug
95
+ # (``/docs/cloud/dashboards/filters/``) has none, and a path under ``/docs/`` is never read this way.
96
+ _TYPED_ID_PATH = re.compile(
97
+ r"/(?:documents?|dashboards?|reports?|visualizations?|metrics?)/([^/\s?#]*[_.0-9][^/\s?#]*)/?(?:[?#].*)?$",
98
+ re.IGNORECASE,
99
+ )
100
+ # Sentence punctuation the link pattern takes in after a URL ("see https://h/x.").
101
+ _TRAILING_PUNCTUATION = ".,;:!?*_"
102
+ # The parts of a link an id can fill on its own: path segments and query values.
103
+ _LINK_PARTS = re.compile(r"[/#?&=]")
104
+
72
105
 
73
106
  @dataclass(frozen=True)
74
107
  class SearchExpectation:
@@ -89,6 +122,10 @@ class SearchExpectation:
89
122
  no_raw_ids: bool = False
90
123
  setup_turns: tuple[str, ...] = ()
91
124
  report_only: bool = False
125
+ expect_user_requested_search: bool | None = None
126
+ widget_objects: tuple[str, ...] = ()
127
+ forbidden_parts: tuple[str, ...] = ()
128
+ no_object_urls: bool = False
92
129
 
93
130
  @property
94
131
  def has_turn_checks(self) -> bool:
@@ -101,6 +138,10 @@ class SearchExpectation:
101
138
  or self.answer_rubric
102
139
  or self.expected_limit is not None
103
140
  or self.no_raw_ids
141
+ or self.expect_user_requested_search is not None
142
+ or self.widget_objects
143
+ or self.forbidden_parts
144
+ or self.no_object_urls
104
145
  )
105
146
 
106
147
  @property
@@ -124,10 +165,10 @@ def _flag(key: str, value: Any) -> bool:
124
165
  return value
125
166
 
126
167
 
127
- def _object_ref(ref: str) -> tuple[str, str]:
168
+ def _object_ref(key: str, ref: str) -> tuple[str, str]:
128
169
  object_type, sep, object_id = ref.partition("/")
129
170
  if not sep or object_type not in _OBJECT_TYPES or not object_id or object_id != object_id.strip():
130
- raise ValueError(f"expected_objects entry must be '<type>/<id>' with a known type, got {ref!r}")
171
+ raise ValueError(f"{key} entry must be '<type>/<id>' with a known type, got {ref!r}")
131
172
  return object_type, object_id
132
173
 
133
174
 
@@ -178,12 +219,21 @@ def parse_expectation(expected_output: Any) -> SearchExpectation:
178
219
  if "expected_objects" in raw:
179
220
  expected_objects = _string_list("expected_objects", raw["expected_objects"])
180
221
  for ref in expected_objects:
181
- _object_ref(ref)
222
+ _object_ref("expected_objects", ref)
182
223
  required = _string_list("required_tools", raw["required_tools"]) if "required_tools" in raw else ()
183
224
  forbidden = _string_list("forbidden_tools", raw["forbidden_tools"]) if "forbidden_tools" in raw else ()
184
225
  both = sorted(set(required) & set(forbidden))
185
226
  if both:
186
227
  raise ValueError(f"tools {both} are both required and forbidden")
228
+ widget_objects: tuple[str, ...] = ()
229
+ if "widget_objects" in raw:
230
+ widget_objects = _string_list("widget_objects", raw["widget_objects"])
231
+ for ref in widget_objects:
232
+ _object_ref("widget_objects", ref)
233
+ forbidden_parts = _string_list("forbidden_parts", raw["forbidden_parts"]) if "forbidden_parts" in raw else ()
234
+ unknown_parts = sorted(set(forbidden_parts) - _UNHANDLED_PART_TYPES)
235
+ if unknown_parts:
236
+ raise ValueError(f"forbidden_parts {unknown_parts} are not among {sorted(_UNHANDLED_PART_TYPES)}")
187
237
  limit = raw.get("expected_limit")
188
238
  if "expected_limit" in raw and (not isinstance(limit, int) or isinstance(limit, bool) or limit < 1):
189
239
  raise ValueError(f"expected_limit must be a positive integer, got {limit!r}")
@@ -200,6 +250,14 @@ def parse_expectation(expected_output: Any) -> SearchExpectation:
200
250
  no_raw_ids=_flag("no_raw_ids", raw["no_raw_ids"]) if "no_raw_ids" in raw else False,
201
251
  setup_turns=_string_list("setup_turns", raw["setup_turns"]) if "setup_turns" in raw else (),
202
252
  report_only=_flag("report_only", raw["report_only"]) if "report_only" in raw else False,
253
+ expect_user_requested_search=(
254
+ _flag("expect_user_requested_search", raw["expect_user_requested_search"])
255
+ if "expect_user_requested_search" in raw
256
+ else None
257
+ ),
258
+ widget_objects=widget_objects,
259
+ forbidden_parts=forbidden_parts,
260
+ no_object_urls=_flag("no_object_urls", raw["no_object_urls"]) if "no_object_urls" in raw else False,
203
261
  )
204
262
  if "tool_call" not in raw and not spec.has_checks:
205
263
  raise ValueError("expected_output asserts nothing: give tool_call or at least one check")
@@ -274,6 +332,38 @@ def raw_ids(text: str) -> list[str]:
274
332
  return _UUID.findall(outside) + typed
275
333
 
276
334
 
335
+ def widget_refs(result: ChatResult) -> list[str]:
336
+ """Every object the turn's ``searchResults`` parts list, as ``type/id``, first sighting first."""
337
+ refs: dict[tuple[str, str], str] = {}
338
+ for part in result.search_results:
339
+ for obj in _objects(part):
340
+ object_type, object_id = obj.get("type"), obj.get("id")
341
+ if isinstance(object_type, str) and isinstance(object_id, str) and object_type and object_id:
342
+ refs.setdefault(_ref_key(object_type, object_id), f"{object_type}/{object_id}")
343
+ return list(refs.values())
344
+
345
+
346
+ def object_urls(text: str, object_ids: tuple[str, ...] = ()) -> list[str]:
347
+ """The links in ``text`` that point at a workspace object.
348
+
349
+ A link counts when it is a ``gooddata://`` link, follows an app or API route to one object, ends in an object
350
+ type and an id outside ``/docs/``, or has one of ``object_ids`` (the ids the turn's searches returned) as a
351
+ whole path segment or query value.
352
+ """
353
+ found: list[str] = []
354
+ for match in _LINK.finditer(text):
355
+ link = (match.group(1) or match.group(0)).rstrip(_TRAILING_PUNCTUATION)
356
+ parts = set(_LINK_PARTS.split(link))
357
+ if (
358
+ link.lower().startswith("gooddata://")
359
+ or _OBJECT_PATH.search(link)
360
+ or ("/docs/" not in link.lower() and _TYPED_ID_PATH.search(link))
361
+ or any(object_id in parts for object_id in object_ids)
362
+ ):
363
+ found.append(link)
364
+ return found
365
+
366
+
277
367
  def deterministic_checks(spec: SearchExpectation, result: ChatResult) -> tuple[dict[str, bool], dict[str, Any]]:
278
368
  """The checks of one scored turn that need no judge, with the evidence of each failure."""
279
369
  checks: dict[str, bool] = {}
@@ -307,4 +397,24 @@ def deterministic_checks(spec: SearchExpectation, result: ChatResult) -> tuple[d
307
397
  if spec.no_raw_ids:
308
398
  found = raw_ids(result.text_response or "")
309
399
  _check("search_no_raw_ids", not found, {"raw_ids": found})
400
+ if spec.expect_user_requested_search is not None:
401
+ flags = [call_args(tc).get("user_requested_search") for tc in search_calls(events)]
402
+ asked = any(flag is True for flag in flags)
403
+ _check(
404
+ "search_user_requested",
405
+ asked == spec.expect_user_requested_search,
406
+ {"expected": spec.expect_user_requested_search, "user_requested_search": flags},
407
+ )
408
+ if spec.widget_objects:
409
+ listed = widget_refs(result)
410
+ missing = missing_objects(spec.widget_objects, listed)
411
+ _check("search_widget_objects", not missing, {"missing": missing, "listed": listed[:30]})
412
+ if spec.forbidden_parts:
413
+ streamed = [part.get("type") for part in result.unhandled_parts]
414
+ forbidden = [ptype for ptype in streamed if ptype in spec.forbidden_parts]
415
+ _check("search_forbidden_parts", not forbidden, {"forbidden": forbidden, "parts": streamed})
416
+ if spec.no_object_urls:
417
+ ids = tuple(ref.partition("/")[2] for ref in returned_refs(result))
418
+ urls = object_urls(result.text_response or "", ids)
419
+ _check("search_no_object_urls", not urls, {"object_urls": urls})
310
420
  return checks, details
@@ -91,6 +91,10 @@ SEARCH_CONDITIONAL_SCORES = (
91
91
  "search_answer",
92
92
  "search_limit",
93
93
  "search_no_raw_ids",
94
+ "search_user_requested",
95
+ "search_widget_objects",
96
+ "search_forbidden_parts",
97
+ "search_no_object_urls",
94
98
  )
95
99
  # The names a score takes where it does not gate the item: every check of a report_only item, and tool_selection of
96
100
  # an item with search_required false. A score name then means the same on every item.
@@ -112,12 +116,10 @@ def _tool_selection(tool_call_events: list[ToolCallEvent]) -> bool:
112
116
  return any(tc.function_name == SEARCH_TOOL for tc in tool_call_events)
113
117
 
114
118
 
115
- # Arguments that do not determine search quality, so a fixture naming them must not
116
- # fail the call. `limit` has a server-side default the agent is free to choose;
117
- # `emit_widget` was renamed to `user_requested_search` in the tool schema. The
118
- # single-shot evaluator (core/evaluators/search_tool.py) has ignored these since the
119
- # rename -- this path did not, so every fixture written against the older signature
120
- # scored tool_correctness=False while still passing on tool_selection alone.
119
+ # Arguments `tool_correctness` does not compare, so a fixture naming them does not fail
120
+ # the call. `limit` has a server-side default the agent is free to choose; `emit_widget`
121
+ # is the old name of `user_requested_search`. To check `user_requested_search`, an item
122
+ # sets the option `expect_user_requested_search`, which gates the run.
121
123
  _IGNORED_SEARCH_ARGS = frozenset({"limit", "emit_widget", "user_requested_search"})
122
124
 
123
125
 
@@ -70,6 +70,7 @@ _KNOWN_PART_TYPES: frozenset[str] = frozenset(
70
70
  "dashboard",
71
71
  "dashboardPatch",
72
72
  "document",
73
+ "report",
73
74
  "kda",
74
75
  "whatIf",
75
76
  "searchResults",
@@ -78,6 +79,9 @@ _KNOWN_PART_TYPES: frozenset[str] = frozenset(
78
79
  }
79
80
  )
80
81
 
82
+ # The part types ``_handle_multipart`` leaves in ``unhandled_parts``: every known type but the four it routes.
83
+ UNHANDLED_PART_TYPES: frozenset[str] = _KNOWN_PART_TYPES - {"text", "visualization", "alertProposal", "searchResults"}
84
+
81
85
 
82
86
  class ChatError(RuntimeError):
83
87
  """Non-retryable error reported by the chat SSE stream.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: gooddata-eval
3
- Version: 1.81.1.dev3
3
+ Version: 1.81.1.dev4
4
4
  Summary: Evaluate the GoodData AI agent against your own questions and models.
5
5
  Project-URL: Source, https://github.com/gooddata/gooddata-python-sdk
6
6
  Author-email: GoodData <support@gooddata.com>
@@ -18,7 +18,7 @@ Classifier: Topic :: Scientific/Engineering
18
18
  Classifier: Topic :: Software Development
19
19
  Classifier: Typing :: Typed
20
20
  Requires-Python: >=3.11
21
- Requires-Dist: gooddata-sdk~=1.81.1.dev3
21
+ Requires-Dist: gooddata-sdk~=1.81.1.dev4
22
22
  Requires-Dist: httpx<1.0,>=0.27
23
23
  Requires-Dist: jsonpatch<2.0,>=1.33
24
24
  Requires-Dist: orjson<4.0.0,>=3.9.15
@@ -32,7 +32,7 @@ gooddata_eval/core/agentic/_langfuse.py,sha256=74_pf1XU6fQG6qrgRB18XYrMlO69tnH1u
32
32
  gooddata_eval/core/agentic/_metric_expectation.py,sha256=mlhmVDEDgg4pkfOXmPSjwa7i8D6p3fYaEoMisGLVdVw,20520
33
33
  gooddata_eval/core/agentic/_metric_workspace.py,sha256=5qQAdWtneniFqFtZoc4K7vQlrGD7cj8ErruQNgdu-po,11878
34
34
  gooddata_eval/core/agentic/_outcome.py,sha256=AL1ULyD9zpC8A-MhyLp2CW68Rnezl39heRkHr7xcbEA,13478
35
- gooddata_eval/core/agentic/_search_expectation.py,sha256=I_NSxfuT0r5uOwvGe6hCcgpeGvdtLAcCki_RgELJaes,13964
35
+ gooddata_eval/core/agentic/_search_expectation.py,sha256=EstJtdhFkfaU0LL7hB7HPAMQh06P7dUqY1DqLRDqlR8,19927
36
36
  gooddata_eval/core/agentic/_trace_linker.py,sha256=Bc-UOPB3bcJqb6kmHnkMnbNVbZPPB7Dn5awM7bNm-qY,15851
37
37
  gooddata_eval/core/agentic/agent_switcher.py,sha256=DWkv2iB0RGzM4-wLkhoru4b8fPYHDwYaBPcSVcjZ74g,37636
38
38
  gooddata_eval/core/agentic/alert_skill.py,sha256=fgwxAMcdtZbjLuyc92egHmclVG0yvt7MhH_rO3cGe50,111660
@@ -49,7 +49,7 @@ gooddata_eval/core/agentic/knowledge.py,sha256=hVAyQwCmewjTAdvfNHz6517obwxr3-KRb
49
49
  gooddata_eval/core/agentic/memory.py,sha256=HT89Ei3ZpV2AUlhW3DxV2jBx2BlrZQk4Ay8TbIeVmWY,24213
50
50
  gooddata_eval/core/agentic/metric_skill.py,sha256=PX-nSGsszJYZHC4tUu732rwSrXjfA23YpHtJOVccdqw,64702
51
51
  gooddata_eval/core/agentic/report_skill.py,sha256=ZpuKuQpor56ywDKauzQKAx18vFHcW6uq3nFgV2GjVvM,1583
52
- gooddata_eval/core/agentic/search_tool.py,sha256=oo5hPlEp4gabz_gsMzcn_dYn0T8tbjmq6PDA5K1Oak8,30553
52
+ gooddata_eval/core/agentic/search_tool.py,sha256=pHDKt9537OPKUWjYKPRyC0mUIACWFblG_TXCTgVJSb8,30517
53
53
  gooddata_eval/core/agentic/visualization.py,sha256=TmXCe5cUQoWebAUQlbJYO0LohVIamBHgb_-5uRsQDNI,39239
54
54
  gooddata_eval/core/agentic/what_if.py,sha256=AA3DJOrtezRLnUxzq48olwSgDQN6Qfwqfbx5XnsQhrA,28746
55
55
  gooddata_eval/core/catalog/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
@@ -57,7 +57,7 @@ gooddata_eval/core/catalog/evaluate.py,sha256=Uf4ABvlIY0ks5OKTUpJsoFKHBai390cPid
57
57
  gooddata_eval/core/catalog/http_client.py,sha256=OsT6tvSVXirSRkwKGGikJpAE1zETQO7V5KBLzvOm800,4439
58
58
  gooddata_eval/core/chat/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
59
59
  gooddata_eval/core/chat/render.py,sha256=wfA5opgrWt-H9L-H8hJm1zBR0kIEqvFros8gtG1_yXo,2116
60
- gooddata_eval/core/chat/sse_client.py,sha256=2aUc3WNrfVRy0aJL16gh9tA9SbSDpxBMqlH7uPLANkA,38386
60
+ gooddata_eval/core/chat/sse_client.py,sha256=Yg_Tt7J1oStClOdP7MfrL-3vBfhRndwtdXMuSCJ6Wdo,38635
61
61
  gooddata_eval/core/dataset/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
62
62
  gooddata_eval/core/dataset/from_insights.py,sha256=v4Ev_WZHFzRFnGBzEyDppe-JvKW1I-WQwVHMHXXJ6wU,41212
63
63
  gooddata_eval/core/dataset/langfuse_source.py,sha256=u_JaSGNQu4ztqdwnNHfS8v1dPSckM8DVCIzQGHYaQgg,12212
@@ -98,8 +98,8 @@ gooddata_eval/core/summary/http_client.py,sha256=Umae42fiiJQ0e4hv63NRROHYvcFAGgX
98
98
  gooddata_eval/core/takeaway/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
99
99
  gooddata_eval/core/takeaway/evaluate.py,sha256=AjS_rCHWUSJKv0jfEfL0-dVPoDaf3RkGdmeZiIwjd6A,11312
100
100
  gooddata_eval/core/takeaway/http_client.py,sha256=YMfafOcHJ184i49Qoh0ZNPKKTMKBSgeDUM4zk_H3yM8,3955
101
- gooddata_eval-1.81.1.dev3.dist-info/METADATA,sha256=Rrb_n4kHC3zGFZ38vcRRpxFo3qeuGL0fTpA0Wcpx2T8,82173
102
- gooddata_eval-1.81.1.dev3.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
103
- gooddata_eval-1.81.1.dev3.dist-info/entry_points.txt,sha256=28nFp5Viknx4haPYgzK9QHlwPFfC6rPF6RmjC2ht8EI,56
104
- gooddata_eval-1.81.1.dev3.dist-info/licenses/LICENSE.txt,sha256=LVfVlC9maU3K9lgMwdZnClQQsOIbOekdcdVKr9qzJtk,256836
105
- gooddata_eval-1.81.1.dev3.dist-info/RECORD,,
101
+ gooddata_eval-1.81.1.dev4.dist-info/METADATA,sha256=DCMGHd7eJvfiXl5ZMoF6vA51kNTq1n2F6hW99Ri45mk,82173
102
+ gooddata_eval-1.81.1.dev4.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
103
+ gooddata_eval-1.81.1.dev4.dist-info/entry_points.txt,sha256=28nFp5Viknx4haPYgzK9QHlwPFfC6rPF6RmjC2ht8EI,56
104
+ gooddata_eval-1.81.1.dev4.dist-info/licenses/LICENSE.txt,sha256=LVfVlC9maU3K9lgMwdZnClQQsOIbOekdcdVKr9qzJtk,256836
105
+ gooddata_eval-1.81.1.dev4.dist-info/RECORD,,