gooddata-eval 1.81.1.dev5__py3-none-any.whl → 1.81.1.dev6__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.
- gooddata_eval/cli/agentic_runner.py +3 -1
- gooddata_eval/core/agentic/_conversation_context.py +226 -0
- gooddata_eval/core/agentic/dashboard_skill.py +96 -6
- gooddata_eval/core/agentic/forecasting.py +158 -7
- {gooddata_eval-1.81.1.dev5.dist-info → gooddata_eval-1.81.1.dev6.dist-info}/METADATA +2 -2
- {gooddata_eval-1.81.1.dev5.dist-info → gooddata_eval-1.81.1.dev6.dist-info}/RECORD +9 -9
- {gooddata_eval-1.81.1.dev5.dist-info → gooddata_eval-1.81.1.dev6.dist-info}/WHEEL +0 -0
- {gooddata_eval-1.81.1.dev5.dist-info → gooddata_eval-1.81.1.dev6.dist-info}/entry_points.txt +0 -0
- {gooddata_eval-1.81.1.dev5.dist-info → gooddata_eval-1.81.1.dev6.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -338,7 +338,9 @@ def _dispatch_agentic(
|
|
|
338
338
|
token=token,
|
|
339
339
|
workspace_id=workspace_id,
|
|
340
340
|
question=item.question,
|
|
341
|
-
|
|
341
|
+
# Passed as stored: the evaluator rejects a non-object expectation, None included, instead
|
|
342
|
+
# of running it with nothing pinned.
|
|
343
|
+
expected_output=eo,
|
|
342
344
|
k=k,
|
|
343
345
|
gate=gate,
|
|
344
346
|
agent_id=agent_id,
|
|
@@ -26,6 +26,7 @@ import re
|
|
|
26
26
|
from dataclasses import dataclass
|
|
27
27
|
from typing import Literal
|
|
28
28
|
|
|
29
|
+
from gooddata_eval.core.chat.sse_client import ADHOC_VIZ_ID
|
|
29
30
|
from gooddata_eval.core.config import judge_model
|
|
30
31
|
from gooddata_eval.core.evaluators._llm_judge import JudgeResponseError, LLMJudge, _message_content
|
|
31
32
|
from gooddata_eval.core.models import ChatResult
|
|
@@ -77,6 +78,136 @@ _REQUEST_RE = re.compile(
|
|
|
77
78
|
re.IGNORECASE,
|
|
78
79
|
)
|
|
79
80
|
|
|
81
|
+
# The dashboard editor shows an existing chart and then stops until the user asks for it to be
|
|
82
|
+
# placed, so that turn ends by asking to go ahead with a placement, in words the approval phrases
|
|
83
|
+
# above do not cover. Read on a dashboard edit only (classify_edit_reply): elsewhere "Should I
|
|
84
|
+
# replace the filter?" is not a step any skill's flow defines.
|
|
85
|
+
_PLACEMENT_VERBS = r"replace|place|put|swap|add|insert|move"
|
|
86
|
+
_PLACEMENT_VERB_RE = re.compile(rf"\b(?:{_PLACEMENT_VERBS})\b", re.IGNORECASE)
|
|
87
|
+
# The verbs name filters and other widgets too ("Do you want me to add anything else?", "Should I replace
|
|
88
|
+
# the date filter?"), so one counts only when a chart is what it places: a pronoun or a chart noun close
|
|
89
|
+
# after it ("put it there", "replace Order breakdown with this chart", "replace Order breakdown with it"),
|
|
90
|
+
# or, once the conversation has shown a chart, any object but a lowercase "filter" (a title such as
|
|
91
|
+
# "Filter Usage" is a chart) or an open "anything else" ("I'll replace Order Breakdown in the same
|
|
92
|
+
# position"). "With it" names the chart, so "replace the date filter with it" still places one.
|
|
93
|
+
_CHART_NOUNS = r"charts?|visualizations?|insights?"
|
|
94
|
+
_PLACED_CHART_RE = re.compile(
|
|
95
|
+
rf"\b(?:{_PLACEMENT_VERBS})\s+(?:\S+\s+)?(?:it|them)\b"
|
|
96
|
+
rf"|\b(?:{_PLACEMENT_VERBS})\s+(?:\S+\s+){{0,5}}?(?:{_CHART_NOUNS})\b"
|
|
97
|
+
rf"|\b(?:{_PLACEMENT_VERBS})\b[^,;]*?\bwith\s+(?:it|them|(?:this|that|the)\s+(?:new\s+)?(?:{_CHART_NOUNS}))\b",
|
|
98
|
+
re.IGNORECASE,
|
|
99
|
+
)
|
|
100
|
+
_PLACED_ANYTHING_RE = re.compile(
|
|
101
|
+
rf"\b(?:{_PLACEMENT_VERBS})\b(?!\s+(?:anything|something|more|else|another)\b)"
|
|
102
|
+
r"(?!\s+(?:\S+\s+){0,3}?(?-i:filters?)\b)",
|
|
103
|
+
re.IGNORECASE,
|
|
104
|
+
)
|
|
105
|
+
_IF_YOU_WANT_ME_TO = r"\b(?:if|when|once|whether)\s+you(?:['’]d|\s+would)?\s+(?:want|like)\s+me\s+to\s+"
|
|
106
|
+
_PLACEMENT_ASK_RE = re.compile(
|
|
107
|
+
rf"(?:{_SHOULD_I}|{_WANT_ME_TO}|{_IF_YOU_WANT_ME_TO})(?:{_PLACEMENT_VERBS})\b",
|
|
108
|
+
re.IGNORECASE,
|
|
109
|
+
)
|
|
110
|
+
# These name no placement of their own ("Once you confirm the new title, I'll rename it"), so they
|
|
111
|
+
# count only in a sentence that places a chart (_PLACED_CHART_RE).
|
|
112
|
+
_GO_AHEAD_RE = re.compile(
|
|
113
|
+
r"\b(?:once|when|after|if)\s+you\s+confirm\b"
|
|
114
|
+
r"|\bconfirm,?\s+and\s+i(?:['’]ll|\s+will)\b"
|
|
115
|
+
rf"|\b(?:tell|ask)\s+me\s+to\s+(?:{_PLACEMENT_VERBS}|{_APPROVAL_VERBS})\b",
|
|
116
|
+
re.IGNORECASE,
|
|
117
|
+
)
|
|
118
|
+
# Beside a chart the same reply shows, an offer to place it ("I can replace Order breakdown with it",
|
|
119
|
+
# "Top 10 Buyers is ready to replace Order breakdown") is that same stop, put as a statement. Without a
|
|
120
|
+
# chart shown it is no step of the flow, so it stays a reply that did nothing.
|
|
121
|
+
_PLACEMENT_OFFER_RE = re.compile(
|
|
122
|
+
rf"\b(?:i\s+can|i\s+could|(?:is|are|am|i['’]m)\s+ready\s+to)\s+(?:{_PLACEMENT_VERBS})\b",
|
|
123
|
+
re.IGNORECASE,
|
|
124
|
+
)
|
|
125
|
+
# "Where should I place them?" and "Which chart should I replace?" ask for something a yes does not
|
|
126
|
+
# supply, so the placement verb in them is no request to go ahead.
|
|
127
|
+
_WH_ASK_RE = re.compile(
|
|
128
|
+
r"\b(?:where|which|what|how|when|who|whom|whose)\b(?:\s+\w+){0,3}?\s+(?:should|shall|may|can|do|would)\s+(?:i|you)\b",
|
|
129
|
+
re.IGNORECASE,
|
|
130
|
+
)
|
|
131
|
+
# What a yes does not supply either: something to confirm other than going ahead ("once you confirm
|
|
132
|
+
# which section"; "confirm the placement" is going ahead), a value to provide ("please specify the
|
|
133
|
+
# size", "let me know the section") or a numbered list of placement options. A chart's description
|
|
134
|
+
# ("it lets you select a buyer", "it ranks 1. Alice 2. Bob", "1. Net orders on the left axis") asks
|
|
135
|
+
# nothing ("please select a buyer in the filter bar" included), so a request for a place counts anywhere,
|
|
136
|
+
# any other request only from the first placement sentence on, and a numbered list only when two of its
|
|
137
|
+
# items are placements.
|
|
138
|
+
_CONFIRM_WHAT_RE = re.compile(
|
|
139
|
+
r"\bconfirm\s+(?:which|where|what|how|the\s+(?:\w+\s+)?(?:size|section|tab|width|height)s?)\b",
|
|
140
|
+
re.IGNORECASE,
|
|
141
|
+
)
|
|
142
|
+
_PLACE_VALUES = r"size|section|tab|width|height|position|row|column|spot"
|
|
143
|
+
_REQUEST_VERBS = r"select|choose|pick|specify|provide|clarify|share"
|
|
144
|
+
_PLACE_REQUEST_RE = re.compile(
|
|
145
|
+
rf"\bplease\s+(?:{_REQUEST_VERBS})\s+(?:\S+\s+){{0,2}}?(?:which|where|(?:{_PLACE_VALUES})s?)\b"
|
|
146
|
+
rf"|\b(?:let\s+me\s+know|tell\s+me)\s+(?:which|where|(?:what|the)\s+(?:\w+\s+)?(?:{_PLACE_VALUES})s?\b"
|
|
147
|
+
r"|how\s+(?:wide|tall|big|large|many)\b)",
|
|
148
|
+
re.IGNORECASE,
|
|
149
|
+
)
|
|
150
|
+
_EDIT_REQUEST_RE = re.compile(
|
|
151
|
+
rf"\bplease\s+(?:{_REQUEST_VERBS})\b|\breply\s+with\b|^\s*(?:select|choose|pick)\s+(?:one|a|an|the)\b",
|
|
152
|
+
re.IGNORECASE,
|
|
153
|
+
)
|
|
154
|
+
_PLACE_WORDS = (
|
|
155
|
+
rf"{_PLACEMENT_VERBS}|above|below|before|after|left|right|top|bottom|next\s+to|section|row|tab|instead"
|
|
156
|
+
r"|at\s+the\s+(?:end|start|beginning)"
|
|
157
|
+
)
|
|
158
|
+
# An item of a numbered list is a placement when it opens with a placement verb ("Replace Order breakdown"),
|
|
159
|
+
# places "it" ("Keep Order breakdown and add it below") or opens with where to put it ("above Orders over
|
|
160
|
+
# time"). The noun ("Net orders per place") is no placement. A chart's
|
|
161
|
+
# description can name a place in every item ("1. Net orders on the left axis"), seldom a placement.
|
|
162
|
+
_LIST_MARKER_RE = re.compile(r"(?:^|(?<=\s))\(?([1-9])[.)](?=\s)")
|
|
163
|
+
_LIST_ITEM_END_RE = re.compile(r"[\n?]|\.(?:\s|$)")
|
|
164
|
+
_ITEM_PLACEMENT_RE = re.compile(
|
|
165
|
+
rf"^\s*(?:{_PLACEMENT_VERBS})\b|\b(?:{_PLACEMENT_VERBS})\s+(?:\S+\s+)?(?:it|them)\b", re.IGNORECASE
|
|
166
|
+
)
|
|
167
|
+
_ITEM_OPENS_WITH_PLACE_RE = re.compile(
|
|
168
|
+
r"^\s*(?:above|below|before|after|beside|under|next\s+to|instead\s+of|in\s+place\s+of"
|
|
169
|
+
r"|at\s+the\s+(?:top|bottom|end|start|beginning))\b",
|
|
170
|
+
re.IGNORECASE,
|
|
171
|
+
)
|
|
172
|
+
# A second option offered in a sentence after the placement ask: "I can also add it next to it instead".
|
|
173
|
+
# The sentence must offer a placement: "The chart uses net orders instead of gross orders" describes it.
|
|
174
|
+
_LATER_OPTION_RE = re.compile(r"\b(?:instead|otherwise)\b|\bif\s+you(?:['’]d|\s+would)?\s+prefer\b", re.IGNORECASE)
|
|
175
|
+
# "Should I place it before or after Orders over time?" asks where, which a yes does not answer, and
|
|
176
|
+
# so does "Should I place it now, or would you like to review it first?". An "or" that hands the turn
|
|
177
|
+
# back without a second option ("or not?", "or let me know") is no choice. Any case counts: a
|
|
178
|
+
# placement sentence holds no MAQL, the formula spans are masked before this is read.
|
|
179
|
+
# A widget's name can hold an "or" too ("Should I replace Won or Lost Deals with it?", "the same width or
|
|
180
|
+
# height"), so "or" offers a choice only when a place, a placement verb or a question of its own follows it
|
|
181
|
+
# within two words; "alternatively" always does.
|
|
182
|
+
_PLACEMENT_NOT_AN_OPTION = r"not\b|(?:is|are)\s+there\b|anything\b|something\b|if\s+you\b|let\s+me\s+know\b"
|
|
183
|
+
_OR_CHOICE_FOLLOWS = rf"{_PLACE_WORDS}|(?:would|do)\s+you\s+(?:like|want|prefer)|(?:should|shall|can)\s+i"
|
|
184
|
+
_PLACEMENT_CHOICE_RE = re.compile(
|
|
185
|
+
rf"\bor\b(?![\s,]+(?:{_PLACEMENT_NOT_AN_OPTION}))[\s,]+(?:[\w'’-]+[\s,]+){{0,2}}?(?:{_OR_CHOICE_FOLLOWS})\b"
|
|
186
|
+
rf"|\balternatively\b(?![\s,]+(?:{_PLACEMENT_NOT_AN_OPTION}))",
|
|
187
|
+
re.IGNORECASE,
|
|
188
|
+
)
|
|
189
|
+
# "Should I place it in Sales or Finance?" names two destinations: an "or" that follows the placement's
|
|
190
|
+
# "in", "to" or "on" within two words ("in Sales or", "to the Sales tab or") and opens another name
|
|
191
|
+
# ("Finance", "the Finance tab") is a choice. A lowercase word after it is no place ("or leave it", "or
|
|
192
|
+
# keep it as a draft", "now or later"), and the window keeps out a widget's name further on ("in place of
|
|
193
|
+
# Won or Lost Deals").
|
|
194
|
+
_DESTINATION_CHOICE_RE = re.compile(
|
|
195
|
+
rf"\b(?:{_PLACEMENT_VERBS})\b[^,;]*?\b(?:in|into|to|on|onto)\s+(?:the\s+)?"
|
|
196
|
+
rf"[“\"'‘]?[\w'’-]+[”\"'’]?(?:\s+[“\"'‘]?[\w'’-]+[”\"'’]?)?\s+or[\s,]+(?:(?:the|a|an)\s+)?(?-i:[“\"'‘]?[A-Z])",
|
|
197
|
+
re.IGNORECASE,
|
|
198
|
+
)
|
|
199
|
+
# "Should I place it, and how wide should it be?" asks a second thing inside the placement sentence. A
|
|
200
|
+
# relative clause (", which keeps the same width") asks nothing, so the clause must open with "and" or
|
|
201
|
+
# "but" and hold a question verb of its own.
|
|
202
|
+
_SECOND_ASK_RE = re.compile(
|
|
203
|
+
r"\b(?:and|but)\s+(?:how|which|where|what|when)\b[^?]*\b(?:should|shall|would|do|does|can|could)\b[^?]*\?",
|
|
204
|
+
re.IGNORECASE,
|
|
205
|
+
)
|
|
206
|
+
_OR_WORD_RE = re.compile(r"\bor\b", re.IGNORECASE)
|
|
207
|
+
_LEADING_CHOICE_RE = re.compile(r"\s*(?:or|alternatively)\b", re.IGNORECASE)
|
|
208
|
+
# "Which **section** should I place it in?": Markdown emphasis would split the words the checks read.
|
|
209
|
+
_EMPHASIS_RE = re.compile(r"\*+|(?<!\w)_+|_+(?!\w)")
|
|
210
|
+
|
|
80
211
|
_MESSAGE_CHARS = 800
|
|
81
212
|
_TRANSCRIPT_MESSAGES = 40
|
|
82
213
|
|
|
@@ -122,6 +253,101 @@ def asks_in_text(chat_result: ChatResult, rendered_text: str) -> bool:
|
|
|
122
253
|
return any(s.rstrip().endswith("?") and not _CONFIRMATION_RE.search(s) for s in sentences)
|
|
123
254
|
|
|
124
255
|
|
|
256
|
+
def _numbered_placements(text: str) -> int:
|
|
257
|
+
"""How many items of the reply's first numbered list (1., 2., ...) are placements."""
|
|
258
|
+
markers = list(_LIST_MARKER_RE.finditer(text))
|
|
259
|
+
start = next((i for i, m in enumerate(markers) if m.group(1) == "1"), None)
|
|
260
|
+
if start is None:
|
|
261
|
+
return 0
|
|
262
|
+
items: list[str] = []
|
|
263
|
+
for expected, (marker, following) in enumerate(
|
|
264
|
+
zip(markers[start:], [*markers[start + 1 :], None], strict=False), start=1
|
|
265
|
+
):
|
|
266
|
+
if marker.group(1) != str(expected):
|
|
267
|
+
break
|
|
268
|
+
item = text[marker.end() : following.start() if following else len(text)]
|
|
269
|
+
if following is None or following.group(1) != str(expected + 1):
|
|
270
|
+
end = _LIST_ITEM_END_RE.search(item)
|
|
271
|
+
item = item[: end.start()] if end else item
|
|
272
|
+
items.append(item)
|
|
273
|
+
break
|
|
274
|
+
items.append(item)
|
|
275
|
+
return sum(bool(_ITEM_PLACEMENT_RE.search(i) or _ITEM_OPENS_WITH_PLACE_RE.match(i)) for i in items)
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def classify_edit_reply(chat_result: ChatResult, rendered_text: str, *, shown_earlier: bool = False) -> ReplyKind:
|
|
279
|
+
"""Kind of a dashboard-edit reply that did not produce the patch.
|
|
280
|
+
|
|
281
|
+
``classify_reply``, plus the editor's own confirmation step: a reply that only asks to go
|
|
282
|
+
ahead with placing a chart ("Should I replace Order breakdown with it?", "Once you confirm,
|
|
283
|
+
I'll place it", "ask me to place it when you're ready") is a confirmation, so it is told yes. So is
|
|
284
|
+
an offer to place it ("I can replace Order breakdown with it") once a chart has been shown: in this
|
|
285
|
+
reply, or anywhere in the conversation so far (``shown_earlier``), as when the editor asks again in a
|
|
286
|
+
turn after its preview.
|
|
287
|
+
Either kind of confirmation turns into a question when the reply also asks for something a yes
|
|
288
|
+
does not supply: another question ("Which size should it have? Once you confirm, I'll place it."),
|
|
289
|
+
a choice in the placement itself ("Should I put it before or after Orders over time?", "in Sales or
|
|
290
|
+
Finance"), a numbered list with two placement items, something to confirm other than going ahead
|
|
291
|
+
("once you confirm which section"), a request for a place ("Please specify the size") or, from the
|
|
292
|
+
ask on, any other request.
|
|
293
|
+
"""
|
|
294
|
+
if has_structured_question(chat_result):
|
|
295
|
+
return "question"
|
|
296
|
+
text = (rendered_text or "").strip()
|
|
297
|
+
kind = classify_reply(chat_result, text)
|
|
298
|
+
if chat_result.alert_proposals:
|
|
299
|
+
return kind
|
|
300
|
+
plain = _EMPHASIS_RE.sub("", _FORMULA_SPAN_RE.sub(" ", text))
|
|
301
|
+
sentences = [s for s in _SENTENCE_END_RE.split(plain) if s.strip()]
|
|
302
|
+
# ADHOC_VIZ_ID stands for a chart the reply did not show, so it makes no offer.
|
|
303
|
+
created = chat_result.created_visualizations
|
|
304
|
+
shown = [viz for viz in (created.objects if created else []) if viz.id != ADHOC_VIZ_ID]
|
|
305
|
+
offers = bool(shown) or shown_earlier
|
|
306
|
+
placing = [
|
|
307
|
+
bool(_PLACEMENT_ASK_RE.search(s) or _GO_AHEAD_RE.search(s) or (offers and _PLACEMENT_OFFER_RE.search(s)))
|
|
308
|
+
and bool(_PLACED_CHART_RE.search(s) or (offers and _PLACED_ANYTHING_RE.search(s)))
|
|
309
|
+
and not _WH_ASK_RE.search(s)
|
|
310
|
+
for s in sentences
|
|
311
|
+
]
|
|
312
|
+
if not any(placing):
|
|
313
|
+
return "question" if kind == "confirmation" and asks_in_text(chat_result, text) else kind
|
|
314
|
+
# A shown chart's title is a name, so an "or" inside one ("Orders or Returns") is no choice. Only a
|
|
315
|
+
# title of three words or more with an "or" in it is masked, and only as whole words: a title like
|
|
316
|
+
# "a" or "or" would otherwise eat into the sentence around it.
|
|
317
|
+
shown_titles = [
|
|
318
|
+
re.escape(title)
|
|
319
|
+
for viz in shown
|
|
320
|
+
if (title := (viz.title or "").strip()) and len(title.split()) >= 3 and _OR_WORD_RE.search(title)
|
|
321
|
+
]
|
|
322
|
+
title_re = re.compile(rf"(?<!\w)(?:{'|'.join(shown_titles)})(?!\w)", re.IGNORECASE) if shown_titles else None
|
|
323
|
+
first = placing.index(True)
|
|
324
|
+
# The second option can come as a sentence of its own after the ask: "Should I replace it? Alternatively, ...".
|
|
325
|
+
masked = [title_re.sub(" ", s) if title_re else s for s in sentences]
|
|
326
|
+
if any(
|
|
327
|
+
_PLACEMENT_CHOICE_RE.search(s) or (is_placing and _DESTINATION_CHOICE_RE.search(s))
|
|
328
|
+
for i, (s, is_placing) in enumerate(zip(masked, placing, strict=True))
|
|
329
|
+
if is_placing or (i > first and _LEADING_CHOICE_RE.match(s))
|
|
330
|
+
):
|
|
331
|
+
return "question"
|
|
332
|
+
# A request for a place counts wherever it stands ("Please specify the section. Should I place it?").
|
|
333
|
+
if any(_CONFIRM_WHAT_RE.search(s) or _PLACE_REQUEST_RE.search(s) for s in sentences):
|
|
334
|
+
return "question"
|
|
335
|
+
if any(_EDIT_REQUEST_RE.search(s) for s in sentences[first:]):
|
|
336
|
+
return "question"
|
|
337
|
+
# Any sentence after the ask counts, an offer too: "Should I replace it? Otherwise, I can add it as a new row."
|
|
338
|
+
if any(_LATER_OPTION_RE.search(s) and _PLACEMENT_VERB_RE.search(s) for s in sentences[first + 1 :]):
|
|
339
|
+
return "question"
|
|
340
|
+
if _numbered_placements(plain) >= 2:
|
|
341
|
+
return "question"
|
|
342
|
+
asks_more = any(
|
|
343
|
+
s.rstrip().endswith("?")
|
|
344
|
+
and not _CONFIRMATION_RE.search(s)
|
|
345
|
+
and (not is_placing or bool(_SECOND_ASK_RE.search(s)))
|
|
346
|
+
for s, is_placing in zip(sentences, placing, strict=True)
|
|
347
|
+
)
|
|
348
|
+
return "question" if asks_more else "confirmation"
|
|
349
|
+
|
|
350
|
+
|
|
125
351
|
@dataclass
|
|
126
352
|
class TranscriptEntry:
|
|
127
353
|
role: Literal["user", "assistant"]
|
|
@@ -5,13 +5,19 @@ from __future__ import annotations
|
|
|
5
5
|
|
|
6
6
|
import re
|
|
7
7
|
import time
|
|
8
|
+
from collections import Counter
|
|
8
9
|
from dataclasses import dataclass, field
|
|
9
10
|
from typing import Any
|
|
10
11
|
|
|
11
12
|
import jsonpatch
|
|
12
13
|
|
|
13
14
|
from gooddata_eval.core.agentic._clarification import all_questions
|
|
14
|
-
from gooddata_eval.core.agentic._conversation_context import
|
|
15
|
+
from gooddata_eval.core.agentic._conversation_context import (
|
|
16
|
+
CONFIRMATION_REPLY,
|
|
17
|
+
classify_edit_reply,
|
|
18
|
+
classify_reply,
|
|
19
|
+
clip,
|
|
20
|
+
)
|
|
15
21
|
from gooddata_eval.core.agentic._failed_runs import build_failed_runs
|
|
16
22
|
from gooddata_eval.core.agentic._failure_message import failed_checks_from
|
|
17
23
|
from gooddata_eval.core.agentic._filters import describe_selection, same_unordered_values, selection_of
|
|
@@ -41,7 +47,7 @@ from gooddata_eval.core.agentic._trace_linker import (
|
|
|
41
47
|
utc_now,
|
|
42
48
|
)
|
|
43
49
|
from gooddata_eval.core.chat.render import render_answer_text
|
|
44
|
-
from gooddata_eval.core.chat.sse_client import ChatClient, ChatError
|
|
50
|
+
from gooddata_eval.core.chat.sse_client import ADHOC_VIZ_ID, ChatClient, ChatError
|
|
45
51
|
from gooddata_eval.core.config import ReasoningEffort
|
|
46
52
|
from gooddata_eval.core.langfuse.item_scope import item_scope
|
|
47
53
|
from gooddata_eval.core.models import (
|
|
@@ -764,6 +770,58 @@ def _bodies_by_id(*references: dict) -> dict[str, dict]:
|
|
|
764
770
|
return bodies
|
|
765
771
|
|
|
766
772
|
|
|
773
|
+
def _shown_visualization_ids(chat_result: ChatResult) -> set[str]:
|
|
774
|
+
"""Ids of the charts one turn showed the user as visualization parts.
|
|
775
|
+
|
|
776
|
+
A chart shown with ``preview_existing_visualization`` carries its object id in the part, the
|
|
777
|
+
id a patch places it by. The sentinel standing in for an authored chart the reply did not show
|
|
778
|
+
is not a chart anyone saw.
|
|
779
|
+
"""
|
|
780
|
+
created = chat_result.created_visualizations
|
|
781
|
+
return {viz.id for viz in (created.objects if created else []) if viz.id and viz.id != ADHOC_VIZ_ID}
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
def _placed_existing_visualizations(base: dict, document: dict, new_ids: set[str]) -> list[str]:
|
|
785
|
+
"""Existing charts the patch puts on the dashboard, in document order.
|
|
786
|
+
|
|
787
|
+
A chart counts when the document shows it more often than the base did, so a second copy of a
|
|
788
|
+
chart already on the dashboard counts and a widget moved elsewhere does not. A switcher's member
|
|
789
|
+
charts count like charts of their own: the editor can build a switcher out of existing charts. A
|
|
790
|
+
chart authored in this conversation is shown with the ref it was created under, never previewed.
|
|
791
|
+
"""
|
|
792
|
+
|
|
793
|
+
def charts(widget: dict) -> list[object]:
|
|
794
|
+
if "visualizations" in widget:
|
|
795
|
+
return [m.get("visualization") for m in widget["visualizations"] or [] if isinstance(m, dict)]
|
|
796
|
+
return [widget.get("visualization")]
|
|
797
|
+
|
|
798
|
+
def counts(dashboard: dict) -> Counter[str]:
|
|
799
|
+
return Counter(v for w in _widgets_of(dashboard) for v in charts(w) if isinstance(v, str))
|
|
800
|
+
|
|
801
|
+
return [viz_id for viz_id in counts(document) - counts(base) if viz_id not in new_ids]
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
def _check_previewed(placed: list[str], shown_ids: frozenset[str], bodies: dict[str, dict]) -> list[str]:
|
|
805
|
+
"""One failure per placed existing chart that no reply showed the user, in an earlier turn or with the patch.
|
|
806
|
+
|
|
807
|
+
A case asks for this only when its edit places an existing chart, so a patch that places none
|
|
808
|
+
fails too: there was no preview to check, and the check would otherwise pass on nothing.
|
|
809
|
+
"""
|
|
810
|
+
if not placed:
|
|
811
|
+
return ["preview_before_placing is set, but the patch places no existing chart"]
|
|
812
|
+
failures: list[str] = []
|
|
813
|
+
for viz_id in placed:
|
|
814
|
+
if viz_id in shown_ids:
|
|
815
|
+
continue
|
|
816
|
+
title = (bodies.get(viz_id) or {}).get("title")
|
|
817
|
+
name = f"{title!r} ({viz_id})" if title else repr(viz_id)
|
|
818
|
+
failures.append(
|
|
819
|
+
f"the patch places {name}, but no reply up to the patch showed it as a visualization part "
|
|
820
|
+
"(preview_existing_visualization)"
|
|
821
|
+
)
|
|
822
|
+
return failures
|
|
823
|
+
|
|
824
|
+
|
|
767
825
|
def _check_chart_types(
|
|
768
826
|
widgets: list[dict], new_ids: set[str], expected: list[dict], bodies: dict[str, dict]
|
|
769
827
|
) -> tuple[list[str], list[str]]:
|
|
@@ -1534,6 +1592,15 @@ def _validate_expectation(expected_output: dict) -> None:
|
|
|
1534
1592
|
"built from its charts and date range"
|
|
1535
1593
|
)
|
|
1536
1594
|
|
|
1595
|
+
if "preview_before_placing" in expected_output:
|
|
1596
|
+
if expected_output["preview_before_placing"] is not True:
|
|
1597
|
+
raise ValueError(
|
|
1598
|
+
"preview_before_placing must be true when present; leave it out to skip the check, "
|
|
1599
|
+
f"got {expected_output['preview_before_placing']!r}"
|
|
1600
|
+
)
|
|
1601
|
+
if not _is_edit(expected_output):
|
|
1602
|
+
raise ValueError("preview_before_placing is for an edit case; a new draft places nothing it showed")
|
|
1603
|
+
|
|
1537
1604
|
forbidden = _forbidden_visualizations(expected_output)
|
|
1538
1605
|
if not isinstance(forbidden, list):
|
|
1539
1606
|
raise ValueError(f"must_not_contain must be a list of chart expectations, got {forbidden!r}")
|
|
@@ -1980,6 +2047,7 @@ class _Applies:
|
|
|
1980
2047
|
parameters: bool = False
|
|
1981
2048
|
forbidden: bool = False
|
|
1982
2049
|
answer: bool = False
|
|
2050
|
+
preview: bool = False
|
|
1983
2051
|
# Not a check of its own but a switch over the whole set: a refusal case is scored on the
|
|
1984
2052
|
# absence of a draft and on what the answer said, so publishing the document checks beside
|
|
1985
2053
|
# it would report six passes for a document that was never produced.
|
|
@@ -2007,6 +2075,7 @@ class _Applies:
|
|
|
2007
2075
|
layout="layout" in expected_output,
|
|
2008
2076
|
filter_bar="filter_bar" in expected_output,
|
|
2009
2077
|
parameters="parameters" in expected_output,
|
|
2078
|
+
preview=expected_output.get("preview_before_placing") is True,
|
|
2010
2079
|
forbidden=forbidden,
|
|
2011
2080
|
answer=answer,
|
|
2012
2081
|
refusal=refusal,
|
|
@@ -2054,6 +2123,7 @@ class DashboardEvaluation:
|
|
|
2054
2123
|
layout_correct: bool = False
|
|
2055
2124
|
filter_bar_correct: bool = False
|
|
2056
2125
|
parameters_correct: bool = False
|
|
2126
|
+
previewed_before_placing: bool = False
|
|
2057
2127
|
forbidden_absent: bool = True
|
|
2058
2128
|
answer_matched: bool = True
|
|
2059
2129
|
# Whether EITHER dashboard-producing tool was called at all, successful or not. Only a
|
|
@@ -2127,6 +2197,8 @@ class DashboardEvaluation:
|
|
|
2127
2197
|
checks["dashboard_filter_bar_correct"] = self.filter_bar_correct
|
|
2128
2198
|
if self.applies.parameters:
|
|
2129
2199
|
checks["dashboard_parameters_correct"] = self.parameters_correct
|
|
2200
|
+
if self.applies.preview:
|
|
2201
|
+
checks["dashboard_previewed_before_placing"] = self.previewed_before_placing
|
|
2130
2202
|
if self.applies.forbidden:
|
|
2131
2203
|
checks["forbidden_charts_absent"] = self.forbidden_absent
|
|
2132
2204
|
if self.applies.answer:
|
|
@@ -2198,6 +2270,7 @@ def evaluate_dashboard_response(
|
|
|
2198
2270
|
patch_part: dict | None = None,
|
|
2199
2271
|
answer_text: str = "",
|
|
2200
2272
|
producing_tool_called: bool = False,
|
|
2273
|
+
shown_visualization_ids: frozenset[str] = frozenset(),
|
|
2201
2274
|
) -> DashboardEvaluation:
|
|
2202
2275
|
"""Score one dashboard response against its expectation.
|
|
2203
2276
|
|
|
@@ -2420,6 +2493,11 @@ def evaluate_dashboard_response(
|
|
|
2420
2493
|
layout_failures = _check_layout(document, new_ids, expected_output["layout"]) if applies.layout else []
|
|
2421
2494
|
filter_bar_failures = _check_filter_bar(document, expected_output["filter_bar"]) if applies.filter_bar else []
|
|
2422
2495
|
parameter_failures = _check_parameters(document, expected_output["parameters"]) if applies.parameters else []
|
|
2496
|
+
preview_failures = (
|
|
2497
|
+
_check_previewed(_placed_existing_visualizations(base, document, new_ids), shown_visualization_ids, bodies)
|
|
2498
|
+
if applies.preview
|
|
2499
|
+
else []
|
|
2500
|
+
)
|
|
2423
2501
|
|
|
2424
2502
|
return DashboardEvaluation(
|
|
2425
2503
|
drafted=True,
|
|
@@ -2443,6 +2521,7 @@ def evaluate_dashboard_response(
|
|
|
2443
2521
|
layout_correct=not layout_failures,
|
|
2444
2522
|
filter_bar_correct=not filter_bar_failures,
|
|
2445
2523
|
parameters_correct=not parameter_failures,
|
|
2524
|
+
previewed_before_placing=not preview_failures,
|
|
2446
2525
|
forbidden_absent=not forbidden_failures,
|
|
2447
2526
|
answer_matched=not answer_failures,
|
|
2448
2527
|
failures=[
|
|
@@ -2460,6 +2539,7 @@ def evaluate_dashboard_response(
|
|
|
2460
2539
|
*layout_failures,
|
|
2461
2540
|
*filter_bar_failures,
|
|
2462
2541
|
*parameter_failures,
|
|
2542
|
+
*preview_failures,
|
|
2463
2543
|
*new_failures,
|
|
2464
2544
|
*answer_failures,
|
|
2465
2545
|
],
|
|
@@ -2539,6 +2619,10 @@ def _execute_single_dashboard_run(
|
|
|
2539
2619
|
response_id: str | None = None
|
|
2540
2620
|
all_tool_call_events: list[ToolCallEvent] = []
|
|
2541
2621
|
all_reasoning_step_events: list[ReasoningStepEvent] = []
|
|
2622
|
+
# Every chart shown to the user as a visualization part, in any turn up to and including the one
|
|
2623
|
+
# that produced the patch: the editor usually shows a chart and places it after the user's yes, and
|
|
2624
|
+
# sometimes shows and places it in one turn. Both put the chart in front of the user.
|
|
2625
|
+
shown_visualization_ids: set[str] = set()
|
|
2542
2626
|
timings = PhaseTimings()
|
|
2543
2627
|
turn_offset = 0.0
|
|
2544
2628
|
tool_index_offset = 0
|
|
@@ -2591,6 +2675,7 @@ def _execute_single_dashboard_run(
|
|
|
2591
2675
|
all_tool_call_events.extend(chat_result.tool_call_events or [])
|
|
2592
2676
|
all_reasoning_step_events.extend(chat_result.reasoning_step_events or [])
|
|
2593
2677
|
steps += chat_result.reasoning_step_count
|
|
2678
|
+
shown_visualization_ids |= _shown_visualization_ids(chat_result)
|
|
2594
2679
|
|
|
2595
2680
|
# Read every turn, not only the ones that answer without drafting: the turn that
|
|
2596
2681
|
# produces the draft carries the text describing it, and that text is exactly what the
|
|
@@ -2632,10 +2717,14 @@ def _execute_single_dashboard_run(
|
|
|
2632
2717
|
# agent would be talked out of the right answer by the harness.
|
|
2633
2718
|
exit_reason = LoopExit.STOPPED_EARLY
|
|
2634
2719
|
break
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2720
|
+
# On an edit, "Which widget should I resize? Please confirm." asks something a yes does not
|
|
2721
|
+
# answer, and "Should I replace Order breakdown with it?" is the editor's own step before it
|
|
2722
|
+
# places a chart it has shown, in this turn or an earlier one (the set already holds this turn's).
|
|
2723
|
+
reply_kind = (
|
|
2724
|
+
classify_edit_reply(chat_result, response_text, shown_earlier=bool(shown_visualization_ids))
|
|
2725
|
+
if is_edit
|
|
2726
|
+
else classify_reply(chat_result, response_text)
|
|
2727
|
+
)
|
|
2639
2728
|
if is_edit:
|
|
2640
2729
|
# The creation reply names charts and a date range, which answers nothing a rename
|
|
2641
2730
|
# or a resize could have asked, and nothing here can guess what an edit question
|
|
@@ -2689,6 +2778,7 @@ def _execute_single_dashboard_run(
|
|
|
2689
2778
|
_skill_activated(all_tool_call_events, _required_skill(expected_output)),
|
|
2690
2779
|
patch_part=patch_part,
|
|
2691
2780
|
answer_text=answer_text,
|
|
2781
|
+
shown_visualization_ids=frozenset(shown_visualization_ids),
|
|
2692
2782
|
# Any call, not just a successful one -- see DashboardEvaluation. BOTH tools,
|
|
2693
2783
|
# not the one this case selected: a refusal is a creation shape, so `tool` is
|
|
2694
2784
|
# `draft_dashboard`, and an agent that routed to the editor and had a
|
|
@@ -44,6 +44,7 @@ from gooddata_eval.core.agentic._trace_linker import (
|
|
|
44
44
|
from gooddata_eval.core.chat.render import render_answer_text
|
|
45
45
|
from gooddata_eval.core.chat.sse_client import ChatClient
|
|
46
46
|
from gooddata_eval.core.config import ReasoningEffort
|
|
47
|
+
from gooddata_eval.core.granularity import granularity_of
|
|
47
48
|
from gooddata_eval.core.models import (
|
|
48
49
|
AgenticAssertionError,
|
|
49
50
|
AgenticEvalOutcome,
|
|
@@ -62,6 +63,106 @@ _DEFAULT_K = 1
|
|
|
62
63
|
# disambiguation rounds plus slack, matching kda_skill's reasoning.
|
|
63
64
|
_DEFAULT_MAX_ITERATIONS = 4
|
|
64
65
|
|
|
66
|
+
# execute_forecast and the AAC convertor both run an absent forecast_confidence at 0.95.
|
|
67
|
+
_DEFAULT_CONFIDENCE = 0.95
|
|
68
|
+
# The forecast_* keys whose non-null value makes execute_forecast run the chart (its has_forecast_config).
|
|
69
|
+
_FORECAST_KEYS = ("forecast_enabled", "forecast_period", "forecast_confidence", "forecast_seasonal")
|
|
70
|
+
# The members of the platform enum a forecast can trend by. Of-period granularities
|
|
71
|
+
# (MONTH_OF_YEAR) are not trends and match nothing.
|
|
72
|
+
_TREND_GRANULARITIES = ("MINUTE", "HOUR", "DAY", "WEEK", "MONTH", "QUARTER", "YEAR")
|
|
73
|
+
_KNOWN_KEYS = frozenset(
|
|
74
|
+
{"metric", "forecast_period", "forecast_confidence", "forecast_seasonal", "granularity", "date_dataset"}
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _is_number(value: object) -> bool:
|
|
79
|
+
return isinstance(value, int | float) and not isinstance(value, bool)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _string_or_list(key: str, value: object) -> list[str]:
|
|
83
|
+
values = [value] if isinstance(value, str) else value
|
|
84
|
+
if not isinstance(values, list) or not values or not all(isinstance(v, str) and v.strip() for v in values):
|
|
85
|
+
raise ValueError(f"{key} must be a non-empty string or a non-empty list of them, got {value!r}")
|
|
86
|
+
return values
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _validate_expectation(expected_output: object) -> None:
|
|
90
|
+
"""Reject an expectation the run could not score, before the first API call.
|
|
91
|
+
|
|
92
|
+
Every check is opt-in, so a misspelt key (``forecast_periods``) or a value of the wrong type would
|
|
93
|
+
otherwise assert nothing and read green. A ``None`` value is the same as an absent key.
|
|
94
|
+
|
|
95
|
+
Raises:
|
|
96
|
+
ValueError: the expectation is unusable.
|
|
97
|
+
"""
|
|
98
|
+
if not isinstance(expected_output, dict):
|
|
99
|
+
raise ValueError(f"expected_output must be an object, got {expected_output!r}")
|
|
100
|
+
# test_kind routes the item to this evaluator (langfuse_source._infer_test_kind) and stays in it.
|
|
101
|
+
unknown = sorted(set(expected_output) - _KNOWN_KEYS - {"test_kind"})
|
|
102
|
+
if unknown:
|
|
103
|
+
raise ValueError(f"expected_output has unknown keys {unknown}; known keys are {sorted(_KNOWN_KEYS)}")
|
|
104
|
+
|
|
105
|
+
metric = expected_output.get("metric")
|
|
106
|
+
if metric is not None:
|
|
107
|
+
for uri in _string_or_list("metric", metric):
|
|
108
|
+
if not uri.startswith(("metric/", "fact/")):
|
|
109
|
+
raise ValueError(f"metric must be a metric/<id> or fact/<id> reference, got {uri!r}")
|
|
110
|
+
|
|
111
|
+
period = expected_output.get("forecast_period")
|
|
112
|
+
if period is not None and (not isinstance(period, int) or isinstance(period, bool) or period < 1):
|
|
113
|
+
raise ValueError(f"forecast_period must be a positive integer, got {period!r}")
|
|
114
|
+
|
|
115
|
+
confidence = expected_output.get("forecast_confidence")
|
|
116
|
+
if confidence is not None and (not _is_number(confidence) or not 0 < confidence < 1):
|
|
117
|
+
raise ValueError(f"forecast_confidence must be a number between 0 and 1 (0.9, not 90), got {confidence!r}")
|
|
118
|
+
|
|
119
|
+
seasonal = expected_output.get("forecast_seasonal")
|
|
120
|
+
if seasonal is not None and not isinstance(seasonal, bool):
|
|
121
|
+
raise ValueError(f"forecast_seasonal must be true or false, got {seasonal!r}")
|
|
122
|
+
|
|
123
|
+
granularity = expected_output.get("granularity")
|
|
124
|
+
if granularity is not None and (
|
|
125
|
+
not isinstance(granularity, str) or granularity.upper() not in _TREND_GRANULARITIES
|
|
126
|
+
):
|
|
127
|
+
raise ValueError(f"granularity must be one of {list(_TREND_GRANULARITIES)}, got {granularity!r}")
|
|
128
|
+
|
|
129
|
+
date_dataset = expected_output.get("date_dataset")
|
|
130
|
+
if date_dataset is not None:
|
|
131
|
+
if granularity is None:
|
|
132
|
+
raise ValueError("date_dataset narrows the granularity check, so granularity must be set too")
|
|
133
|
+
for dataset in _string_or_list("date_dataset", date_dataset):
|
|
134
|
+
# An id may contain dots; a reference or a full date label (order_date.month) may not.
|
|
135
|
+
if "/" in dataset or granularity_of(dataset) is not None:
|
|
136
|
+
raise ValueError(f"date_dataset takes a dataset id such as order_date, got {dataset!r}")
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _date_attribute(viz_args: dict | None) -> tuple[str, str] | None:
|
|
140
|
+
"""The (dataset, granularity enum) the chart trends by, read from its view_by field.
|
|
141
|
+
|
|
142
|
+
``label/order_date.month`` and ``attribute/order_date.month`` both give
|
|
143
|
+
``("order_date", "MONTH")``: the agent's tools accept either. None when the chart has no
|
|
144
|
+
date trend, or when the field is not one of the trend granularities.
|
|
145
|
+
"""
|
|
146
|
+
viz = viz_args or {}
|
|
147
|
+
query = viz.get("query")
|
|
148
|
+
fields = query.get("fields") if isinstance(query, dict) else None
|
|
149
|
+
if not isinstance(fields, dict):
|
|
150
|
+
return None
|
|
151
|
+
view_by = viz.get("view_by")
|
|
152
|
+
aliases = view_by if isinstance(view_by, list) else []
|
|
153
|
+
for alias in aliases:
|
|
154
|
+
name = alias.get("field") if isinstance(alias, dict) else alias
|
|
155
|
+
field_def = fields.get(name) if isinstance(name, str) else None
|
|
156
|
+
using = field_def.get("using") if isinstance(field_def, dict) else field_def
|
|
157
|
+
if not isinstance(using, str):
|
|
158
|
+
continue
|
|
159
|
+
if not using.startswith(("label/", "attribute/")):
|
|
160
|
+
continue
|
|
161
|
+
granularity = granularity_of(using)
|
|
162
|
+
if granularity in _TREND_GRANULARITIES:
|
|
163
|
+
return using.split("/", 1)[1].rpartition(".")[0], granularity
|
|
164
|
+
return None
|
|
165
|
+
|
|
65
166
|
|
|
66
167
|
def _build_clarification_prompt(agent_message: str, expected_output: dict) -> str:
|
|
67
168
|
"""The simulated-user reply, mentioning only the hints the fixture actually supplies.
|
|
@@ -72,13 +173,20 @@ def _build_clarification_prompt(agent_message: str, expected_output: dict) -> st
|
|
|
72
173
|
hints: list[str] = []
|
|
73
174
|
metric = expected_output.get("metric")
|
|
74
175
|
if metric:
|
|
75
|
-
hints.append(f"the measure to forecast is {metric}")
|
|
176
|
+
hints.append(f"the measure to forecast is {metric if isinstance(metric, str) else ' or '.join(metric)}")
|
|
76
177
|
period = expected_output.get("forecast_period")
|
|
77
178
|
if period is not None:
|
|
78
179
|
hints.append(f"the forecast horizon is {period} periods ahead")
|
|
79
180
|
granularity = expected_output.get("granularity")
|
|
80
181
|
if granularity:
|
|
81
182
|
hints.append(f"the time granularity is {granularity}")
|
|
183
|
+
# The agent often asks which date to trend by ("Order date or Date?"). Without this hint the
|
|
184
|
+
# simulated user answers only the granularity and the agent asks again. The first listed
|
|
185
|
+
# dataset is the answer; the others are only also accepted by the check.
|
|
186
|
+
date_dataset = expected_output.get("date_dataset")
|
|
187
|
+
if date_dataset:
|
|
188
|
+
first = date_dataset if isinstance(date_dataset, str) else date_dataset[0]
|
|
189
|
+
hints.append(f"the date dataset to trend by has the id {first}")
|
|
82
190
|
# Both are scored when the fixture pins them, so withholding them here would let the
|
|
83
191
|
# harness fail a run on a value it refused to supply: the agent asks which confidence
|
|
84
192
|
# level to use, the simulated user guesses, and `confidence_correct` reports the guess
|
|
@@ -179,8 +287,9 @@ class ForecastEvaluation:
|
|
|
179
287
|
"""Scores for a single forecasting run.
|
|
180
288
|
|
|
181
289
|
``triggered``/``executed``/``success``/``turn_completed`` are the process checks every
|
|
182
|
-
skill kind shares. ``forecast_enabled
|
|
183
|
-
content checks, and each is True when
|
|
290
|
+
skill kind shares. ``forecast_enabled`` and the ``*_correct`` fields (period, metric,
|
|
291
|
+
confidence, seasonal, granularity) are content checks, and each ``*_correct`` is True when
|
|
292
|
+
the fixture did not ask for it -- an unstated
|
|
184
293
|
expectation must not fail a run, and must not silently pass one either, which is why
|
|
185
294
|
``asserted`` records which of them the fixture actually pinned.
|
|
186
295
|
"""
|
|
@@ -194,8 +303,11 @@ class ForecastEvaluation:
|
|
|
194
303
|
metric_correct: bool
|
|
195
304
|
confidence_correct: bool
|
|
196
305
|
seasonal_correct: bool
|
|
306
|
+
granularity_correct: bool
|
|
197
307
|
asserted: list[str] = field(default_factory=list)
|
|
198
308
|
disambiguated: bool = False
|
|
309
|
+
# "order_date.month": what the chart trends by, for the report. None when it has no date trend.
|
|
310
|
+
actual_date_attribute: str | None = None
|
|
199
311
|
|
|
200
312
|
@property
|
|
201
313
|
def strict_pass(self) -> bool:
|
|
@@ -210,6 +322,7 @@ class ForecastEvaluation:
|
|
|
210
322
|
self.metric_correct,
|
|
211
323
|
self.confidence_correct,
|
|
212
324
|
self.seasonal_correct,
|
|
325
|
+
self.granularity_correct,
|
|
213
326
|
]
|
|
214
327
|
)
|
|
215
328
|
|
|
@@ -255,6 +368,10 @@ def _evaluate_run(
|
|
|
255
368
|
config = _forecast_config(viz_args)
|
|
256
369
|
# None is "not set", which the tool treats as disabled -- only an explicit true enables it.
|
|
257
370
|
forecast_enabled = config.get("forecast_enabled") is True
|
|
371
|
+
# The tool's defaults apply only to a chart it would run. Without forecast config nothing was
|
|
372
|
+
# checked, so a pinned confidence or seasonality must not read as met. A null key is not config:
|
|
373
|
+
# the strict schema makes the agent send every key, and the tool drops nulls before its own check.
|
|
374
|
+
has_forecast_config = any(config.get(key) is not None for key in _FORECAST_KEYS)
|
|
258
375
|
|
|
259
376
|
asserted: list[str] = []
|
|
260
377
|
expected_period = expected_output.get("forecast_period")
|
|
@@ -278,9 +395,15 @@ def _evaluate_run(
|
|
|
278
395
|
confidence_correct = True
|
|
279
396
|
else:
|
|
280
397
|
asserted.append("forecast_confidence")
|
|
398
|
+
# An absent value runs at the tool's default, so it is that default, not a mismatch:
|
|
399
|
+
# "with 95% confidence" is met by an agent that leaves the key out.
|
|
281
400
|
actual_confidence = config.get("forecast_confidence")
|
|
282
|
-
|
|
283
|
-
|
|
401
|
+
if actual_confidence is None and has_forecast_config:
|
|
402
|
+
actual_confidence = _DEFAULT_CONFIDENCE
|
|
403
|
+
confidence_correct = (
|
|
404
|
+
isinstance(actual_confidence, int | float)
|
|
405
|
+
and not isinstance(actual_confidence, bool)
|
|
406
|
+
and float(actual_confidence) == float(expected_confidence)
|
|
284
407
|
)
|
|
285
408
|
|
|
286
409
|
expected_seasonal = expected_output.get("forecast_seasonal")
|
|
@@ -291,7 +414,22 @@ def _evaluate_run(
|
|
|
291
414
|
# The tool defaults seasonal to False, so an absent value means "not seasonal" --
|
|
292
415
|
# reading it as a mismatch would fail an agent that simply left the default alone.
|
|
293
416
|
actual_seasonal = config.get("forecast_seasonal")
|
|
294
|
-
seasonal_correct = bool(actual_seasonal) == bool(expected_seasonal)
|
|
417
|
+
seasonal_correct = has_forecast_config and bool(actual_seasonal) == bool(expected_seasonal)
|
|
418
|
+
|
|
419
|
+
date_attribute = _date_attribute(viz_args)
|
|
420
|
+
expected_granularity = expected_output.get("granularity")
|
|
421
|
+
if expected_granularity is None:
|
|
422
|
+
granularity_correct = True
|
|
423
|
+
else:
|
|
424
|
+
asserted.append("granularity")
|
|
425
|
+
expected_datasets = expected_output.get("date_dataset")
|
|
426
|
+
if isinstance(expected_datasets, str):
|
|
427
|
+
expected_datasets = [expected_datasets]
|
|
428
|
+
granularity_correct = (
|
|
429
|
+
date_attribute is not None
|
|
430
|
+
and date_attribute[1] == str(expected_granularity).upper()
|
|
431
|
+
and (not expected_datasets or date_attribute[0] in expected_datasets)
|
|
432
|
+
)
|
|
295
433
|
|
|
296
434
|
return ForecastEvaluation(
|
|
297
435
|
triggered=triggered,
|
|
@@ -303,8 +441,10 @@ def _evaluate_run(
|
|
|
303
441
|
metric_correct=metric_correct,
|
|
304
442
|
confidence_correct=confidence_correct,
|
|
305
443
|
seasonal_correct=seasonal_correct,
|
|
444
|
+
granularity_correct=granularity_correct,
|
|
306
445
|
asserted=asserted,
|
|
307
446
|
disambiguated=disambiguated,
|
|
447
|
+
actual_date_attribute=f"{date_attribute[0]}.{date_attribute[1].lower()}" if date_attribute else None,
|
|
308
448
|
)
|
|
309
449
|
|
|
310
450
|
|
|
@@ -330,6 +470,7 @@ def run_agentic_forecasting(
|
|
|
330
470
|
"""
|
|
331
471
|
if k < 1:
|
|
332
472
|
raise ValueError(f"k must be >= 1, got {k}")
|
|
473
|
+
_validate_expectation(expected_output)
|
|
333
474
|
run_results: list[ForecastRunResult] = []
|
|
334
475
|
client = ChatClient(
|
|
335
476
|
host=host,
|
|
@@ -449,6 +590,7 @@ def run_agentic_forecasting(
|
|
|
449
590
|
r.evaluation.metric_correct,
|
|
450
591
|
r.evaluation.confidence_correct,
|
|
451
592
|
r.evaluation.seasonal_correct,
|
|
593
|
+
r.evaluation.granularity_correct,
|
|
452
594
|
]
|
|
453
595
|
),
|
|
454
596
|
)
|
|
@@ -476,12 +618,16 @@ def _detail(best: ForecastRunResult) -> dict[str, Any]:
|
|
|
476
618
|
"metric_correct": ev.metric_correct,
|
|
477
619
|
"confidence_correct": ev.confidence_correct,
|
|
478
620
|
"seasonal_correct": ev.seasonal_correct,
|
|
621
|
+
# Only when pinned: ItemReport.quality_score counts every boolean here, and an always-true
|
|
622
|
+
# key would raise the score of every item that does not pin a granularity.
|
|
623
|
+
**({"granularity_correct": ev.granularity_correct} if "granularity" in ev.asserted else {}),
|
|
479
624
|
# Which content checks the fixture pinned. Without it a run where nothing was
|
|
480
625
|
# asserted is indistinguishable in the report from one where everything matched.
|
|
481
626
|
"asserted": ev.asserted,
|
|
482
627
|
"disambiguated": ev.disambiguated,
|
|
483
628
|
"actual_forecast_config": _forecast_config(best.actual_visualization),
|
|
484
629
|
"actual_metrics": sorted(_metric_uris(best.actual_visualization)),
|
|
630
|
+
"actual_date_attribute": ev.actual_date_attribute,
|
|
485
631
|
"actual_execute_result": best.actual_execute_result,
|
|
486
632
|
"latency_breakdown": build_latency_breakdown(best.tool_call_events, best.reasoning_step_events),
|
|
487
633
|
}
|
|
@@ -509,6 +655,8 @@ def evaluate_agentic_forecasting(
|
|
|
509
655
|
user_context: dict | None = None,
|
|
510
656
|
) -> AgenticEvalOutcome:
|
|
511
657
|
"""Run forecasting evaluation, log to Langfuse, and raise ForecastingAssertionError on failure."""
|
|
658
|
+
# Before the trace window opens: a malformed item must fail without touching Langfuse or the chat.
|
|
659
|
+
_validate_expectation(expected_output)
|
|
512
660
|
langfuse, window_start = open_trace_window(langfuse)
|
|
513
661
|
summary = run_agentic_forecasting(
|
|
514
662
|
host=host,
|
|
@@ -552,6 +700,7 @@ def evaluate_agentic_forecasting(
|
|
|
552
700
|
("metric", "forecast_metric_correct", ev.metric_correct),
|
|
553
701
|
("forecast_confidence", "forecast_confidence_correct", ev.confidence_correct),
|
|
554
702
|
("forecast_seasonal", "forecast_seasonal_correct", ev.seasonal_correct),
|
|
703
|
+
("granularity", "forecast_granularity_correct", ev.granularity_correct),
|
|
555
704
|
)
|
|
556
705
|
if name in ev.asserted
|
|
557
706
|
}
|
|
@@ -614,7 +763,9 @@ def evaluate_agentic_forecasting(
|
|
|
614
763
|
f"(triggered={ev.triggered}, executed={ev.executed}, success={ev.success}, "
|
|
615
764
|
f"turn_completed={ev.turn_completed}, forecast_enabled={ev.forecast_enabled}, "
|
|
616
765
|
f"period_correct={ev.period_correct}, metric_correct={ev.metric_correct}, "
|
|
617
|
-
f"confidence_correct={ev.confidence_correct}, seasonal_correct={ev.seasonal_correct}
|
|
766
|
+
f"confidence_correct={ev.confidence_correct}, seasonal_correct={ev.seasonal_correct}, "
|
|
767
|
+
f"granularity_correct={ev.granularity_correct}). "
|
|
768
|
+
f"Actual date attribute: {ev.actual_date_attribute}. "
|
|
618
769
|
f"Actual forecast config: {detail['actual_forecast_config']}. "
|
|
619
770
|
f"Actual execute result: {best.actual_execute_result}."
|
|
620
771
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: gooddata-eval
|
|
3
|
-
Version: 1.81.1.
|
|
3
|
+
Version: 1.81.1.dev6
|
|
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.
|
|
21
|
+
Requires-Dist: gooddata-sdk~=1.81.1.dev6
|
|
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
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
gooddata_eval/__init__.py,sha256=9Nz0iJXzkJWiL40PijM6AMpAqQOH-dbYNfDtDysBPYc,186
|
|
2
2
|
gooddata_eval/_version.py,sha256=L4nT6RJQ2vc_F9stvO59xZv92xsRUqbpUh1sGlb-UNU,195
|
|
3
3
|
gooddata_eval/cli/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
|
|
4
|
-
gooddata_eval/cli/agentic_runner.py,sha256=
|
|
4
|
+
gooddata_eval/cli/agentic_runner.py,sha256=1oKBGydaw15dA1EA323p8PjGF5SU0VkQV4oU7MmdGgM,34823
|
|
5
5
|
gooddata_eval/cli/main.py,sha256=_SEw16H2Hc772K-TB9tZyZKUlL_k695KM--aYitaIa8,34790
|
|
6
6
|
gooddata_eval/core/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
|
|
7
7
|
gooddata_eval/core/_output.py,sha256=sFbNtKg1lx431jpb15jISLlOXGTZ-r_KodfaTVyka6I,580
|
|
@@ -21,7 +21,7 @@ gooddata_eval/core/agentic/__init__.py,sha256=3KSedkCBOsozAZ-kvPxryIf9SltV1Wl5KE
|
|
|
21
21
|
gooddata_eval/core/agentic/_alert_update.py,sha256=-GKQa2FoXZcYn2X8i7e55IpzdF0H6rXDj7MK_am-5fM,25940
|
|
22
22
|
gooddata_eval/core/agentic/_catalog.py,sha256=7Ke9OOocxuorHgP4SqEwuSl8VXRU3hZkoQKFLpGbQp4,4479
|
|
23
23
|
gooddata_eval/core/agentic/_clarification.py,sha256=oCghvd7aO0yIn4kkQcjdFm5-j2zfIGmw1Et0MkT_dAM,22770
|
|
24
|
-
gooddata_eval/core/agentic/_conversation_context.py,sha256=
|
|
24
|
+
gooddata_eval/core/agentic/_conversation_context.py,sha256=rSZmQhcEVuQbNCOq2M5xeUcP8ZTjMtIjCXlB7O7P0pU,30826
|
|
25
25
|
gooddata_eval/core/agentic/_editor_takeaways.py,sha256=WCd_lTBEC5plPIyiPx7Q7j4XN42qQZAxTrXDMHfLLas,11757
|
|
26
26
|
gooddata_eval/core/agentic/_failed_runs.py,sha256=1D3vFCKG4TUnNUdci6NO1yJlBFZ8GQOSypfow7eMuq4,5927
|
|
27
27
|
gooddata_eval/core/agentic/_failure_message.py,sha256=PvjDyyBHni-m69UskjSs6oXEJcQVKAfcKkNJ5R-Xjm4,8036
|
|
@@ -39,10 +39,10 @@ gooddata_eval/core/agentic/agent_switcher.py,sha256=DWkv2iB0RGzM4-wLkhoru4b8fPYH
|
|
|
39
39
|
gooddata_eval/core/agentic/alert_skill.py,sha256=fgwxAMcdtZbjLuyc92egHmclVG0yvt7MhH_rO3cGe50,111660
|
|
40
40
|
gooddata_eval/core/agentic/anomaly_detection.py,sha256=XMd0zsS3hgASJND6UwhNXdoBXUzDm_pMuGS2Dv-1FNg,30053
|
|
41
41
|
gooddata_eval/core/agentic/conversation.py,sha256=AC-k4ju2Ic_X8UkERLWHstNKKBGTtrj7p-Ld-82K8T8,75946
|
|
42
|
-
gooddata_eval/core/agentic/dashboard_skill.py,sha256=
|
|
42
|
+
gooddata_eval/core/agentic/dashboard_skill.py,sha256=TaDKpGgnWf7gVNICAYm08zwSzwOkukF91hFipS6Czw4,150293
|
|
43
43
|
gooddata_eval/core/agentic/dashboard_summary.py,sha256=6H-IXJvEkQQ69454GGayDSXzEa9apgoih18U_6so6gI,24438
|
|
44
44
|
gooddata_eval/core/agentic/document_skill.py,sha256=GPxMlXurtROqODPcJEJgHoLorbb4nQGHPb472x3nytY,92616
|
|
45
|
-
gooddata_eval/core/agentic/forecasting.py,sha256=
|
|
45
|
+
gooddata_eval/core/agentic/forecasting.py,sha256=RHSKxWUAeots7csI5fRLy2r6fzauXXbc3jdAMkQlqMU,35337
|
|
46
46
|
gooddata_eval/core/agentic/general_question.py,sha256=YPaz7tbeV0lTHlfmUPNvJ5FD6y-nh5ZqpwLSQqpJI4Y,20480
|
|
47
47
|
gooddata_eval/core/agentic/guardrail.py,sha256=_7-nlBNVnGaYJx9Oq8V08npe1IunxgwH1bqKs0yplhY,17904
|
|
48
48
|
gooddata_eval/core/agentic/kda_skill.py,sha256=V8wSxZG0C3DbGt1dQe339dvwq3pircc6hCsNXvPv9BA,42384
|
|
@@ -99,8 +99,8 @@ gooddata_eval/core/summary/http_client.py,sha256=Umae42fiiJQ0e4hv63NRROHYvcFAGgX
|
|
|
99
99
|
gooddata_eval/core/takeaway/__init__.py,sha256=U54lANKm34yjqm7dZL9KkGouPbwAaQWC9wiAmb5B5g4,32
|
|
100
100
|
gooddata_eval/core/takeaway/evaluate.py,sha256=AjS_rCHWUSJKv0jfEfL0-dVPoDaf3RkGdmeZiIwjd6A,11312
|
|
101
101
|
gooddata_eval/core/takeaway/http_client.py,sha256=YMfafOcHJ184i49Qoh0ZNPKKTMKBSgeDUM4zk_H3yM8,3955
|
|
102
|
-
gooddata_eval-1.81.1.
|
|
103
|
-
gooddata_eval-1.81.1.
|
|
104
|
-
gooddata_eval-1.81.1.
|
|
105
|
-
gooddata_eval-1.81.1.
|
|
106
|
-
gooddata_eval-1.81.1.
|
|
102
|
+
gooddata_eval-1.81.1.dev6.dist-info/METADATA,sha256=Ryvmkw32O5mAJWo0AnNeZQVtXazDu-up_FTfcqHpZ5U,85131
|
|
103
|
+
gooddata_eval-1.81.1.dev6.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
104
|
+
gooddata_eval-1.81.1.dev6.dist-info/entry_points.txt,sha256=28nFp5Viknx4haPYgzK9QHlwPFfC6rPF6RmjC2ht8EI,56
|
|
105
|
+
gooddata_eval-1.81.1.dev6.dist-info/licenses/LICENSE.txt,sha256=LVfVlC9maU3K9lgMwdZnClQQsOIbOekdcdVKr9qzJtk,256836
|
|
106
|
+
gooddata_eval-1.81.1.dev6.dist-info/RECORD,,
|
|
File without changes
|
{gooddata_eval-1.81.1.dev5.dist-info → gooddata_eval-1.81.1.dev6.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{gooddata_eval-1.81.1.dev5.dist-info → gooddata_eval-1.81.1.dev6.dist-info}/licenses/LICENSE.txt
RENAMED
|
File without changes
|