unique_toolkit 2026.48.0.dev17__py3-none-any.whl → 2026.48.0.dev19__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.
- unique_toolkit/agentic/evaluation/hallucination/constants.py +6 -1
- unique_toolkit/agentic/evaluation/hallucination/utils.py +21 -4
- unique_toolkit/agentic/evaluation/tests/test_hallucination_constants.py +2 -2
- unique_toolkit/agentic/evaluation/tests/test_hallucination_utils.py +118 -0
- unique_toolkit/agentic/history_manager/history_manager.py +1 -1
- unique_toolkit/agentic/tools/openai_builtin/code_interpreter/tool/config.py +24 -4
- unique_toolkit/experimental/_internal/streaming/pattern_replacer.py +8 -0
- unique_toolkit/language_model/reference.py +2 -4
- {unique_toolkit-2026.48.0.dev17.dist-info → unique_toolkit-2026.48.0.dev19.dist-info}/METADATA +2 -2
- {unique_toolkit-2026.48.0.dev17.dist-info → unique_toolkit-2026.48.0.dev19.dist-info}/RECORD +11 -11
- {unique_toolkit-2026.48.0.dev17.dist-info → unique_toolkit-2026.48.0.dev19.dist-info}/WHEEL +0 -0
|
@@ -28,6 +28,11 @@ class SourceSelectionMode(StrEnum):
|
|
|
28
28
|
FROM_ORIGINAL_RESPONSE = "FROM_ORIGINAL_RESPONSE"
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
# Applied to the raw answer in addition to the batch citation normalisation, so
|
|
32
|
+
# citation formats outside the platform-resolved set can still be configured.
|
|
33
|
+
DEFAULT_REFERENCE_PATTERN = r"[\[<]?source[\s_]?(\d+)[>\]]?"
|
|
34
|
+
|
|
35
|
+
|
|
31
36
|
class HallucinationPromptsConfig(EvaluationMetricPromptsConfig):
|
|
32
37
|
system_prompt_template: PromptType = Field(default_factory=system_prompt_loader)
|
|
33
38
|
user_prompt_template: PromptType = Field(default_factory=user_prompt_loader)
|
|
@@ -37,7 +42,7 @@ class HallucinationConfig(EvaluationMetricConfig):
|
|
|
37
42
|
source_selection_mode: SkipJsonSchema[SourceSelectionMode] = Field(
|
|
38
43
|
default=SourceSelectionMode.FROM_ORIGINAL_RESPONSE
|
|
39
44
|
)
|
|
40
|
-
reference_pattern: SkipJsonSchema[str] = Field(default=
|
|
45
|
+
reference_pattern: SkipJsonSchema[str] = Field(default=DEFAULT_REFERENCE_PATTERN)
|
|
41
46
|
enabled: SkipJsonSchema[bool] = False
|
|
42
47
|
name: SkipJsonSchema[EvaluationMetricName] = EvaluationMetricName.HALLUCINATION
|
|
43
48
|
language_model: LMI = LanguageModelInfo.from_name(
|
|
@@ -5,6 +5,7 @@ from unique_toolkit._common.utils.jinja.render import render_template
|
|
|
5
5
|
from unique_toolkit.agentic.evaluation.config import EvaluationMetricConfig
|
|
6
6
|
from unique_toolkit.agentic.evaluation.exception import EvaluatorException
|
|
7
7
|
from unique_toolkit.agentic.evaluation.hallucination.constants import (
|
|
8
|
+
DEFAULT_REFERENCE_PATTERN,
|
|
8
9
|
SourceSelectionMode,
|
|
9
10
|
hallucination_required_input_fields,
|
|
10
11
|
)
|
|
@@ -16,6 +17,9 @@ from unique_toolkit.agentic.evaluation.schemas import (
|
|
|
16
17
|
)
|
|
17
18
|
from unique_toolkit.content import ContentReference
|
|
18
19
|
from unique_toolkit.content.schemas import ContentChunk
|
|
20
|
+
from unique_toolkit.experimental._internal.streaming.pattern_replacer import (
|
|
21
|
+
normalize_citations_to_brackets,
|
|
22
|
+
)
|
|
19
23
|
from unique_toolkit.language_model.builder import MessagesBuilder
|
|
20
24
|
from unique_toolkit.language_model.infos import ModelCapabilities
|
|
21
25
|
from unique_toolkit.language_model.invocation_stats import (
|
|
@@ -31,6 +35,8 @@ from unique_toolkit.language_model.service import LanguageModelService
|
|
|
31
35
|
|
|
32
36
|
_LOGGER = getLogger(__name__)
|
|
33
37
|
|
|
38
|
+
_NORMALIZED_CITATION_PATTERN = re.compile(r"\[(\d+)\]")
|
|
39
|
+
|
|
34
40
|
|
|
35
41
|
async def check_hallucination(
|
|
36
42
|
company_id: str,
|
|
@@ -255,7 +261,7 @@ def context_text_from_stream_response(
|
|
|
255
261
|
response: LanguageModelStreamResponse,
|
|
256
262
|
selected_chunks: list[ContentChunk],
|
|
257
263
|
source_selection_mode: SourceSelectionMode = SourceSelectionMode.FROM_ORIGINAL_RESPONSE,
|
|
258
|
-
reference_pattern: str =
|
|
264
|
+
reference_pattern: str = DEFAULT_REFERENCE_PATTERN,
|
|
259
265
|
) -> list[str]:
|
|
260
266
|
"""Extract context text from stream response based on selected chunks.
|
|
261
267
|
|
|
@@ -361,12 +367,12 @@ def _from_original_response_source_selection_mode(
|
|
|
361
367
|
selected_chunks: list[ContentChunk],
|
|
362
368
|
reference_pattern: str,
|
|
363
369
|
) -> list[ContentChunk]:
|
|
364
|
-
"""Extract
|
|
370
|
+
"""Extract chunks cited in the original text, as normalised citations or via ``reference_pattern``.
|
|
365
371
|
|
|
366
372
|
Args:
|
|
367
373
|
original_text: The original response text containing source references.
|
|
368
374
|
selected_chunks: List of content chunks to select from.
|
|
369
|
-
|
|
375
|
+
reference_pattern: Regex pattern for extracting source numbers.
|
|
370
376
|
|
|
371
377
|
Returns:
|
|
372
378
|
List of referenced content chunks.
|
|
@@ -374,11 +380,22 @@ def _from_original_response_source_selection_mode(
|
|
|
374
380
|
if original_text is None:
|
|
375
381
|
raise ValueError("original_text is required for FROM_ORIGINAL_RESPONSE mode")
|
|
376
382
|
_LOGGER.debug("Processing original text for source extraction")
|
|
377
|
-
|
|
383
|
+
normalized_text = normalize_citations_to_brackets(original_text)
|
|
384
|
+
source_number_matches = [
|
|
385
|
+
*_NORMALIZED_CITATION_PATTERN.findall(normalized_text),
|
|
386
|
+
*re.findall(reference_pattern, original_text),
|
|
387
|
+
]
|
|
378
388
|
|
|
379
389
|
# Remove duplicates and preserve order
|
|
380
390
|
source_numbers = list(dict.fromkeys(int(num) for num in source_number_matches))
|
|
381
391
|
|
|
392
|
+
if not source_numbers and selected_chunks:
|
|
393
|
+
_LOGGER.warning(
|
|
394
|
+
f"No source citations found (pattern {reference_pattern!r}) although "
|
|
395
|
+
f"{len(selected_chunks)} chunks are available; the hallucination "
|
|
396
|
+
"check will run without references."
|
|
397
|
+
)
|
|
398
|
+
|
|
382
399
|
# Add bounds checking
|
|
383
400
|
max_index = len(selected_chunks) - 1
|
|
384
401
|
valid_source_numbers = [idx for idx in source_numbers if 0 <= idx <= max_index]
|
|
@@ -205,7 +205,7 @@ def test_hallucination_config__has_default_regex_pattern__for_source_references(
|
|
|
205
205
|
config: HallucinationConfig = HallucinationConfig()
|
|
206
206
|
|
|
207
207
|
# Assert
|
|
208
|
-
assert config.reference_pattern == r"[\[<]?source(\d+)[>\]]?"
|
|
208
|
+
assert config.reference_pattern == r"[\[<]?source[\s_]?(\d+)[>\]]?"
|
|
209
209
|
|
|
210
210
|
|
|
211
211
|
@pytest.mark.ai
|
|
@@ -481,7 +481,7 @@ def test_hallucination_metric_default_config__has_expected_default_settings__con
|
|
|
481
481
|
# Act & Assert
|
|
482
482
|
assert config.name == EvaluationMetricName.HALLUCINATION
|
|
483
483
|
assert config.source_selection_mode == SourceSelectionMode.FROM_ORIGINAL_RESPONSE
|
|
484
|
-
assert config.reference_pattern == r"[\[<]?source(\d+)[>\]]?"
|
|
484
|
+
assert config.reference_pattern == r"[\[<]?source[\s_]?(\d+)[>\]]?"
|
|
485
485
|
|
|
486
486
|
|
|
487
487
|
@pytest.mark.ai
|
|
@@ -571,6 +571,124 @@ def test_from_original_response_source_selection_mode__returns_empty_list__when_
|
|
|
571
571
|
assert len(result) == 0
|
|
572
572
|
|
|
573
573
|
|
|
574
|
+
@pytest.mark.ai
|
|
575
|
+
@pytest.mark.parametrize(
|
|
576
|
+
"original_text",
|
|
577
|
+
[
|
|
578
|
+
"Claim one [source 0] and claim two [source 2].",
|
|
579
|
+
"Claim one [source_0] and claim two [source_2].",
|
|
580
|
+
"Claim one [source0] and claim two <source 2>.",
|
|
581
|
+
],
|
|
582
|
+
)
|
|
583
|
+
def test_from_original_response_source_selection_mode__matches_spaced_and_underscored_citations__with_default_pattern(
|
|
584
|
+
sample_chunks: List[ContentChunk],
|
|
585
|
+
original_text: str,
|
|
586
|
+
) -> None:
|
|
587
|
+
"""
|
|
588
|
+
Purpose: Verify the default pattern extracts citations written as [source N] or [source_N].
|
|
589
|
+
Why this matters: The chat backend resolves these forms into references, so the judge
|
|
590
|
+
must see the same chunks or it flags a sourced answer as high hallucination (UN-28753).
|
|
591
|
+
Setup summary: Default config pattern, text citing sources 0 and 2 in each form,
|
|
592
|
+
assert both chunks are returned in order.
|
|
593
|
+
"""
|
|
594
|
+
# Arrange
|
|
595
|
+
pattern: str = HallucinationConfig().reference_pattern
|
|
596
|
+
|
|
597
|
+
# Act
|
|
598
|
+
result: List[ContentChunk] = _from_original_response_source_selection_mode(
|
|
599
|
+
original_text, sample_chunks, pattern
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
# Assert
|
|
603
|
+
assert result == [sample_chunks[0], sample_chunks[2]]
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
@pytest.mark.ai
|
|
607
|
+
def test_from_original_response_source_selection_mode__logs_warning__when_chunks_exist_but_none_cited(
|
|
608
|
+
sample_chunks: List[ContentChunk],
|
|
609
|
+
caplog: pytest.LogCaptureFixture,
|
|
610
|
+
) -> None:
|
|
611
|
+
"""
|
|
612
|
+
Purpose: Verify a warning is logged when chunks are available but no citation matches.
|
|
613
|
+
Why this matters: An unmatched citation format silently sends the judge no references;
|
|
614
|
+
the warning makes that failure visible in logs.
|
|
615
|
+
Setup summary: Text with an unsupported citation form, assert empty result and warning.
|
|
616
|
+
"""
|
|
617
|
+
# Arrange
|
|
618
|
+
original_text: str = "Claim [ref 1]."
|
|
619
|
+
pattern: str = HallucinationConfig().reference_pattern
|
|
620
|
+
|
|
621
|
+
# Act
|
|
622
|
+
with caplog.at_level("WARNING"):
|
|
623
|
+
result: List[ContentChunk] = _from_original_response_source_selection_mode(
|
|
624
|
+
original_text, sample_chunks, pattern
|
|
625
|
+
)
|
|
626
|
+
|
|
627
|
+
# Assert
|
|
628
|
+
assert result == []
|
|
629
|
+
assert "No source citations found" in caplog.text
|
|
630
|
+
|
|
631
|
+
|
|
632
|
+
@pytest.mark.ai
|
|
633
|
+
@pytest.mark.parametrize(
|
|
634
|
+
"original_text",
|
|
635
|
+
[
|
|
636
|
+
"Claim one [Source 0] and claim two [SOURCE 2].",
|
|
637
|
+
"Claim one [<source 0>] and claim two [<source2>].",
|
|
638
|
+
"Claim one [0] and claim two [2].",
|
|
639
|
+
"Claims [source: 0, 2].",
|
|
640
|
+
"Claims [0, 2].",
|
|
641
|
+
"Claim one [**0**] and claim two [**2**].",
|
|
642
|
+
'Claim one source_number="0" and claim two source_number="2".',
|
|
643
|
+
"Claim one source n°0 and claim two source n°2.",
|
|
644
|
+
],
|
|
645
|
+
)
|
|
646
|
+
def test_from_original_response_source_selection_mode__matches_all_platform_normalized_citations(
|
|
647
|
+
sample_chunks: List[ContentChunk],
|
|
648
|
+
original_text: str,
|
|
649
|
+
) -> None:
|
|
650
|
+
"""
|
|
651
|
+
Purpose: Verify every citation format the chat backend turns into a reference is extracted.
|
|
652
|
+
Why this matters: Running the answer through BATCH_NORMALIZATION_PATTERNS keeps the judge's
|
|
653
|
+
context in line with the references shown in the UI (UN-28753).
|
|
654
|
+
Setup summary: Default config pattern, text citing sources 0 and 2 in each normalised form,
|
|
655
|
+
assert both chunks are returned in order.
|
|
656
|
+
"""
|
|
657
|
+
# Arrange
|
|
658
|
+
pattern: str = HallucinationConfig().reference_pattern
|
|
659
|
+
|
|
660
|
+
# Act
|
|
661
|
+
result: List[ContentChunk] = _from_original_response_source_selection_mode(
|
|
662
|
+
original_text, sample_chunks, pattern
|
|
663
|
+
)
|
|
664
|
+
|
|
665
|
+
# Assert
|
|
666
|
+
assert result == [sample_chunks[0], sample_chunks[2]]
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
@pytest.mark.ai
|
|
670
|
+
def test_from_original_response_source_selection_mode__matches_legacy_pattern__on_spaced_citations(
|
|
671
|
+
sample_chunks: List[ContentChunk],
|
|
672
|
+
) -> None:
|
|
673
|
+
"""
|
|
674
|
+
Purpose: Verify configs that still carry the pre-UN-28753 pattern also see [source N] citations.
|
|
675
|
+
Why this matters: reference_pattern can be persisted in space configs; normalisation must fix
|
|
676
|
+
the mismatch without requiring a config migration.
|
|
677
|
+
Setup summary: Legacy pattern without separator support, spaced citations, assert both found.
|
|
678
|
+
"""
|
|
679
|
+
# Arrange
|
|
680
|
+
original_text: str = "Claim one [source 0] and claim two [source 2]."
|
|
681
|
+
legacy_pattern: str = r"[\[<]?source(\d+)[>\]]?"
|
|
682
|
+
|
|
683
|
+
# Act
|
|
684
|
+
result: List[ContentChunk] = _from_original_response_source_selection_mode(
|
|
685
|
+
original_text, sample_chunks, legacy_pattern
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
# Assert
|
|
689
|
+
assert result == [sample_chunks[0], sample_chunks[2]]
|
|
690
|
+
|
|
691
|
+
|
|
574
692
|
@pytest.mark.ai
|
|
575
693
|
def test_from_original_response_source_selection_mode__works_with_custom_regex_pattern(
|
|
576
694
|
sample_chunks: List[ContentChunk],
|
|
@@ -49,7 +49,20 @@ which file failed and why, using the reason given below:
|
|
|
49
49
|
{% endif %}
|
|
50
50
|
""".strip()
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
# Shared by both default prompts. Assumes the hosted container ships reportlab,
|
|
53
|
+
# matplotlib's DejaVu fonts and pdfplumber (checked on one live container, 2026-11);
|
|
54
|
+
# if an image drops one, the model's PDF code fails rather than this config.
|
|
55
|
+
_PDF_FILE_RULES = """
|
|
56
|
+
PDF files: CRITICAL rules when you write a new text document as a PDF (report, summary, letter); text MUST wrap and stay on the page:
|
|
57
|
+
- Build it with reportlab Platypus: `SimpleDocTemplate(path, pagesize=A4)` with `Paragraph`, `Spacer`, `Table` and `ListFlowable`, so every line wraps inside the page margins.
|
|
58
|
+
- NEVER write its running text with `canvas.drawString`, canvas text objects or `Preformatted`: they do not wrap, so long lines run off the page and are cut off. (Canvas is fine for charts and for stamping, annotating or filling an existing PDF.)
|
|
59
|
+
- Turn Markdown into real formatting: headings into heading styles, `**x**` into `<b>x</b>`, links into `<a href="url">text</a>`, bullets into `ListFlowable(items, bulletType="bullet", start="•")` (`start="bullet"` prints the word "bullet"), tables into a `Table` of `Paragraph` cells whose `colWidths` sum to `doc.width - 12` (the frame's padding). Escape `&`, `<` and `>` in the text first, then add the tags.
|
|
60
|
+
- For Latin, Greek and Cyrillic text use a TrueType font, as built-in Helvetica draws many accented, Greek and Cyrillic letters as black boxes: register `DejaVuSans.ttf` and `DejaVuSans-Bold.ttf` from `Path(matplotlib.get_data_path()) / "fonts" / "ttf"` and call `registerFontFamily` so `<b>` works.
|
|
61
|
+
- Before referencing the PDF, check it in code: open it with `pdfplumber` and assert every word's `x1` is at most `page.width`; if not, fix the build and save it again.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT_BASE = (
|
|
65
|
+
"""
|
|
53
66
|
Use this tool to run python code, e.g to generate plots, process excel files, perform calculations, etc.
|
|
54
67
|
|
|
55
68
|
Instructions:
|
|
@@ -73,7 +86,9 @@ Always use a line break between the title and the markdown!
|
|
|
73
86
|
- YOU MUST use the syntax above to display images, otherwise the image will not be displayed in the chat.
|
|
74
87
|
- Only the following file types are allowed to be uploaded to the platform, anything else will FAIL: PDF, DOCX, XLSX, PPTX, CSV, HTML, MD, TXT, PNG, JPG, JPEG.
|
|
75
88
|
- You MUST always use this syntax, otherwise the files will not be displayed in the chat.
|
|
76
|
-
|
|
89
|
+
"""
|
|
90
|
+
+ _PDF_FILE_RULES
|
|
91
|
+
+ """
|
|
77
92
|
# Displaying Dataframes/Tables:
|
|
78
93
|
- Whenever asked to display a dataframe/table, it is CRITICAL to represent it faithfully as a markdown table in your response.
|
|
79
94
|
|
|
@@ -91,6 +106,7 @@ Handling User Queries:
|
|
|
91
106
|
- If a tool step fails, you must recover as much as possible.
|
|
92
107
|
- After exhausting all possible solutions without success, inform the user of what was tried and request clarification/help.
|
|
93
108
|
"""
|
|
109
|
+
)
|
|
94
110
|
|
|
95
111
|
DEFAULT_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT = (
|
|
96
112
|
_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT_BASE + _TOOL_DESCRIPTION_FILES_SUFFIX
|
|
@@ -107,7 +123,8 @@ DEFAULT_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT = (
|
|
|
107
123
|
# UN-19880: kaleido is not installed in the Azure OpenAI code interpreter environment,
|
|
108
124
|
# so plotly's fig.write_image() always fails. The "Visualization library choice" section
|
|
109
125
|
# steers the model to use matplotlib for PNG outputs and plotly only for HTML artifacts.
|
|
110
|
-
_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT_FENCE_BASE =
|
|
126
|
+
_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT_FENCE_BASE = (
|
|
127
|
+
"""
|
|
111
128
|
Use this tool to run python code, e.g to generate plots, process excel files, perform calculations, etc.
|
|
112
129
|
|
|
113
130
|
Instructions:
|
|
@@ -162,7 +179,9 @@ HTML files — CRITICAL rules:
|
|
|
162
179
|
- Apply clean, readable typography: prefer system fonts (`-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif`) and sufficient contrast (WCAG AA minimum).
|
|
163
180
|
- Use semantic HTML elements (`<table>` for tabular data, `<button>` for actions, `<h1>`–`<h6>` for headings, `alt` attributes on `<img>` tags). Avoid using `<div>` for everything.
|
|
164
181
|
- Do NOT use `window.parent`, `window.top`, or any attempt to access the parent frame.
|
|
165
|
-
|
|
182
|
+
"""
|
|
183
|
+
+ _PDF_FILE_RULES
|
|
184
|
+
+ """
|
|
166
185
|
|
|
167
186
|
# Displaying Dataframes/Tables:
|
|
168
187
|
- Whenever asked to display a dataframe/table, it is CRITICAL to represent it faithfully as a markdown table in your response.
|
|
@@ -183,6 +202,7 @@ Handling User Queries:
|
|
|
183
202
|
- If a tool step fails, you must recover as much as possible.
|
|
184
203
|
- After exhausting all possible solutions without success, inform the user of what was tried and request clarification/help.
|
|
185
204
|
"""
|
|
205
|
+
)
|
|
186
206
|
|
|
187
207
|
DEFAULT_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT_FENCE = (
|
|
188
208
|
_TOOL_DESCRIPTION_FOR_SYSTEM_PROMPT_FENCE_BASE + _TOOL_DESCRIPTION_FILES_SUFFIX
|
|
@@ -95,6 +95,14 @@ BATCH_NORMALIZATION_PATTERNS: list[NormalizationPattern] = [
|
|
|
95
95
|
"""Normalisation rules that convert model-emitted citation formats
|
|
96
96
|
to the canonical ``[N]`` bracket notation (for batch processing)."""
|
|
97
97
|
|
|
98
|
+
|
|
99
|
+
def normalize_citations_to_brackets(text: str) -> str:
|
|
100
|
+
"""Rewrite every citation format the platform resolves into canonical ``[N]``."""
|
|
101
|
+
for pattern, replacement in BATCH_NORMALIZATION_PATTERNS:
|
|
102
|
+
text = re.sub(pattern, replacement, text)
|
|
103
|
+
return text
|
|
104
|
+
|
|
105
|
+
|
|
98
106
|
NORMALIZATION_MAX_MATCH_LENGTH = 80
|
|
99
107
|
"""Upper bound on characters any single pattern can match. Sized for
|
|
100
108
|
multi-source patterns like ``[source: 1, 2, ..., 20]``."""
|
|
@@ -3,7 +3,7 @@ import re
|
|
|
3
3
|
from unique_toolkit.chat.schemas import ChatMessage
|
|
4
4
|
from unique_toolkit.content.schemas import ContentChunk, ContentReference
|
|
5
5
|
from unique_toolkit.experimental._internal.streaming.pattern_replacer import (
|
|
6
|
-
|
|
6
|
+
normalize_citations_to_brackets,
|
|
7
7
|
)
|
|
8
8
|
|
|
9
9
|
|
|
@@ -84,9 +84,7 @@ def _preprocess_message(text: str) -> str:
|
|
|
84
84
|
to ``<sup>N</sup>``. The streaming path uses ``NORMALIZATION_PATTERNS`` which
|
|
85
85
|
outputs ``<sup>N</sup>`` directly.
|
|
86
86
|
"""
|
|
87
|
-
|
|
88
|
-
text = re.sub(pattern, replacement, text)
|
|
89
|
-
return text
|
|
87
|
+
return normalize_citations_to_brackets(text)
|
|
90
88
|
|
|
91
89
|
|
|
92
90
|
def _limit_consecutive_source_references(text: str) -> str:
|
{unique_toolkit-2026.48.0.dev17.dist-info → unique_toolkit-2026.48.0.dev19.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: unique-toolkit
|
|
3
|
-
Version: 2026.48.0.
|
|
3
|
+
Version: 2026.48.0.dev19
|
|
4
4
|
Summary:
|
|
5
5
|
Author: Cedric Klinkert, Martin Fadler, Sadique Sheik, Fabian Schläpfer, Pascal Hauri, Ejiroghene Oki-Peter, Rami Azouz, Ricardo Visini, Sanzio Monti
|
|
6
6
|
Author-email: Cedric Klinkert <cedric.klinkert@unique.ch>, Martin Fadler <martin.fadler@unique.ch>, Sadique Sheik <sadique@unique.ch>, Fabian Schläpfer <fabian@unique.ch>, Pascal Hauri <pascal@unique.ch>, Ejiroghene Oki-Peter <oki-peter.ejiroghene@unique.ai>, Rami Azouz <rami.ext@unique.ch>, Ricardo Visini <ricardo.visini@unique.ch>, Sanzio Monti <sanzio.monti@unique.ai>
|
|
@@ -35,7 +35,7 @@ Requires-Dist: cachetools>=5.0,<6
|
|
|
35
35
|
Requires-Dist: rapidfuzz>=3.0,<4
|
|
36
36
|
Requires-Dist: pyyaml>=6.0.3
|
|
37
37
|
Requires-Dist: asyncpg>=0.30,<1 ; extra == 'activity-records'
|
|
38
|
-
Requires-Dist: unique-toolkit[monitoring]>=2026.48.0.
|
|
38
|
+
Requires-Dist: unique-toolkit[monitoring]>=2026.48.0.dev19,<2026.48.0rc0 ; extra == 'activity-records'
|
|
39
39
|
Requires-Dist: fastapi>=0.133.0,<1.0.0 ; extra == 'fastapi'
|
|
40
40
|
Requires-Dist: starlette>=1.3.1,<2.0.0 ; extra == 'fastapi'
|
|
41
41
|
Requires-Dist: uvicorn>=0.37.0,<0.38 ; extra == 'fastapi'
|
{unique_toolkit-2026.48.0.dev17.dist-info → unique_toolkit-2026.48.0.dev19.dist-info}/RECORD
RENAMED
|
@@ -97,21 +97,21 @@ unique_toolkit/agentic/evaluation/context_relevancy/schema.py,sha256=lZd0TPzH43i
|
|
|
97
97
|
unique_toolkit/agentic/evaluation/context_relevancy/service.py,sha256=RAmV21RXiyUd_kLQtBG7ZqaSa3iEJeQZQVcG95N6UOg,11866
|
|
98
98
|
unique_toolkit/agentic/evaluation/evaluation_manager.py,sha256=OIh1LhkKQFIpori06Ikaidc1HtIFItVxUsYp73XLCeg,8801
|
|
99
99
|
unique_toolkit/agentic/evaluation/exception.py,sha256=6DtYhsOdJ7WnbpjY45pb9m7VN4ZbRACsQ-VRLeHZXgs,911
|
|
100
|
-
unique_toolkit/agentic/evaluation/hallucination/constants.py,sha256=
|
|
100
|
+
unique_toolkit/agentic/evaluation/hallucination/constants.py,sha256=rQnXb70eEFRnjk_1xUZmgBZOHbc_RKF9mS9Ml49IW5w,3428
|
|
101
101
|
unique_toolkit/agentic/evaluation/hallucination/hallucination_evaluation.py,sha256=R_GKauBDj-u-taDGG1k6JULgEyFcOceaOqjTTO6fwZs,4730
|
|
102
102
|
unique_toolkit/agentic/evaluation/hallucination/prompts/__init__.py,sha256=4KFYMZsB3fJUKzoiUJE1npZ0gueWgvceB32EUrN-v7A,343
|
|
103
103
|
unique_toolkit/agentic/evaluation/hallucination/prompts/system_prompt.j2,sha256=sDUX6G645Ba40D_qKu4cUI8g-sJOfG8JpZreTNFgf7M,2616
|
|
104
104
|
unique_toolkit/agentic/evaluation/hallucination/prompts/user_prompt.j2,sha256=mD_qE9fOkyc1XXrebFt097ddx8bTlA6lbY04hKSQmWs,273
|
|
105
105
|
unique_toolkit/agentic/evaluation/hallucination/service.py,sha256=QSPsRxx2H-YpSR2Jn7zJKtwZfZ7elTPAFQiYvM3gYfs,2618
|
|
106
|
-
unique_toolkit/agentic/evaluation/hallucination/utils.py,sha256=
|
|
106
|
+
unique_toolkit/agentic/evaluation/hallucination/utils.py,sha256=pU40fkyMB4O9eO4ii_XjqEmXxA9E2Ni1sGKKxxW1A_U,16351
|
|
107
107
|
unique_toolkit/agentic/evaluation/output_parser.py,sha256=0FDo8YY_Dc4qlTNeYyQkznzIFj9aX9wMrLOTbhhTl6g,1418
|
|
108
108
|
unique_toolkit/agentic/evaluation/schemas.py,sha256=RT0O-AXSOf1zV3fDbUfn7V6bOIA01pkzui02Uad9E3Y,3815
|
|
109
109
|
unique_toolkit/agentic/evaluation/tests/fixtures.py,sha256=Q-ughTfDiAdsMKbBVGzFiBucFdAx-FXgJ9iqp5xMyPs,2801
|
|
110
110
|
unique_toolkit/agentic/evaluation/tests/test_config.py,sha256=p7xFQ7KE_yU8jGpqYA7ntAYe5Vln33wd6nwv3FM9XfI,8327
|
|
111
111
|
unique_toolkit/agentic/evaluation/tests/test_context_relevancy_service.py,sha256=-GRxH70vzvrZG6Hz0igH6i2CqM7Z9jjKt3396xWDh84,12011
|
|
112
|
-
unique_toolkit/agentic/evaluation/tests/test_hallucination_constants.py,sha256=
|
|
112
|
+
unique_toolkit/agentic/evaluation/tests/test_hallucination_constants.py,sha256=dD30f06SlCZdD-PvI89CVat_tCC2qHzAN9Ry3yGxKig,20490
|
|
113
113
|
unique_toolkit/agentic/evaluation/tests/test_hallucination_external_context.py,sha256=3JR9WfBWazX7a1h3uq77Q6kSKm8Mt-aAW8KUYxJUw14,4303
|
|
114
|
-
unique_toolkit/agentic/evaluation/tests/test_hallucination_utils.py,sha256=
|
|
114
|
+
unique_toolkit/agentic/evaluation/tests/test_hallucination_utils.py,sha256=YPpNc95UszRMquhmj7ZYwyiJRrcHeNEyIvnnXY9MYHE,45943
|
|
115
115
|
unique_toolkit/agentic/evaluation/tests/test_output_parser.py,sha256=KfltytmvqnPWLhmZpBXqcRmnlYorw_USwM5rkLVv8so,5179
|
|
116
116
|
unique_toolkit/agentic/evaluation/tests/test_prompt_loaders.py,sha256=zBREdlKf5tdDyB8XSaNgpQv3-tuZJoYteeJrp6WMWDM,11897
|
|
117
117
|
unique_toolkit/agentic/evaluation/utils.py,sha256=HmyPaDV8wdW-_gOjjW-wDaMKgdrsP5-SHP7OqTmGI_A,264
|
|
@@ -119,7 +119,7 @@ unique_toolkit/agentic/feature_flags/__init__.py,sha256=fBR9FaLrc9e8sdYDe1LwP9aN
|
|
|
119
119
|
unique_toolkit/agentic/feature_flags/feature_flags.py,sha256=3E24xKSlpmZmIgIyPrXT_P_6yG1zeODFVJdEgcY0uJA,7250
|
|
120
120
|
unique_toolkit/agentic/history_manager/context_overflow.py,sha256=N5g8bHUHcRz7gey3cCX-xwK7DJkp_O-3IthMnGsIvcE,9472
|
|
121
121
|
unique_toolkit/agentic/history_manager/history_construction_with_contents.py,sha256=cw7YpLMk3NKlNJ4k0Nv2bhMH15NEDYUUwvrloJrV38s,26096
|
|
122
|
-
unique_toolkit/agentic/history_manager/history_manager.py,sha256=
|
|
122
|
+
unique_toolkit/agentic/history_manager/history_manager.py,sha256=SUa6OnPD1LCHBYDzbapUbDfE-8KJCBwO9go7oYNuABU,19084
|
|
123
123
|
unique_toolkit/agentic/history_manager/loop_token_reducer.py,sha256=yLxBPF6gkzpBTL5aOzPgQ61bsZd2kOOxeNrGBEdWTEg,31350
|
|
124
124
|
unique_toolkit/agentic/history_manager/settings.py,sha256=Lrx3a8yXeU0MXrWlV6RZSHsgYWF9Zrs8LyR96OpqQ_k,1216
|
|
125
125
|
unique_toolkit/agentic/history_manager/utils.py,sha256=DiBip8xtah3I9-G-_Ul3OjlYKunrXR-5RJtzREHWV_0,6579
|
|
@@ -230,7 +230,7 @@ unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/gene
|
|
|
230
230
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/postprocessors/office_preview.py,sha256=2-u9NlNRyQ7PC5b6vW_5CypzVbfNUWRd9DAbCSKE4qk,5099
|
|
231
231
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/schemas.py,sha256=4JDJ2SuKTYcLFo_bYoDWKTgjlcO20mid203NVpJ1jm4,779
|
|
232
232
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/tool/__init__.py,sha256=r6yXmGTLJzXNq5laHOlre9veu--VbCQVlDRVm2QUGzI,326
|
|
233
|
-
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/tool/config.py,sha256=
|
|
233
|
+
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/tool/config.py,sha256=tlDT6iJUbZCLgWnDd8cxQT3iHbqELPUgrfdIqG9UYBw,21801
|
|
234
234
|
unique_toolkit/agentic/tools/openai_builtin/code_interpreter/tool/service.py,sha256=opbNxT-COtJcszlXL41AnAaHfUKfR7hQw6Us3QK2Cgk,3698
|
|
235
235
|
unique_toolkit/agentic/tools/openai_builtin/manager.py,sha256=nWgH38k5v-pi9DadmpHJxfHkJLuVei8YIbFiZo7XSZ0,4187
|
|
236
236
|
unique_toolkit/agentic/tools/run_context.py,sha256=lk9tS1wn97NcSByNZpJWunnnZTos9H2SsxUkKKAvW_A,783
|
|
@@ -309,7 +309,7 @@ unique_toolkit/experimental/__init__.py,sha256=fhSv-QhH0yxnnGqSwbFhX7Rp3TCG_zBph
|
|
|
309
309
|
unique_toolkit/experimental/_internal/__init__.py,sha256=wClblbvHTnOCjymmXVoAde1is3AF18iQ46lK6wKObr4,995
|
|
310
310
|
unique_toolkit/experimental/_internal/streaming/__init__.py,sha256=YExuxaOHB96xT1k0FsWiZEo6Ngiyv54GumhCAKW_3aA,942
|
|
311
311
|
unique_toolkit/experimental/_internal/streaming/common.py,sha256=AOvgFqywJcm2qBhz78Zyt4LZh8uI-X2dj0lsjaKCyZ8,8551
|
|
312
|
-
unique_toolkit/experimental/_internal/streaming/pattern_replacer.py,sha256=
|
|
312
|
+
unique_toolkit/experimental/_internal/streaming/pattern_replacer.py,sha256=RthtvrkYcuL3Fq4pXanzNJJRshnmxYneIq3yo80ZqfM,9194
|
|
313
313
|
unique_toolkit/experimental/components/__init__.py,sha256=rl-s8AnHZoLEOB8ei9jQgiRIndfMWrzWJm8gEMzNcS4,2029
|
|
314
314
|
unique_toolkit/experimental/components/_base.py,sha256=XZHKffTIy331ZQnsywl0m1XkJ4DCjHV2on5EBkaG-ik,4153
|
|
315
315
|
unique_toolkit/experimental/components/content_tree/__init__.py,sha256=zAMzctv__M5e4OppVD_neO471V4zKBeHcbVrixZciaM,1946
|
|
@@ -421,7 +421,7 @@ unique_toolkit/language_model/invocation_stats.py,sha256=CQbpUz394IsVd8eNTB1gPSM
|
|
|
421
421
|
unique_toolkit/language_model/model_costs.py,sha256=AVHAuMTzsglzusWsVF_xwBVEndST-TVCVi0H49OhdvE,7419
|
|
422
422
|
unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
|
|
423
423
|
unique_toolkit/language_model/provider_token_count.py,sha256=mS597Mvrc7EsAc9iJSmASIEwvETSPLtIEsWxusPrQVc,5337
|
|
424
|
-
unique_toolkit/language_model/reference.py,sha256=
|
|
424
|
+
unique_toolkit/language_model/reference.py,sha256=YcADLGMhgV5Hc9gKANjdICkfIMnQDssuN52OHlgNkuE,6908
|
|
425
425
|
unique_toolkit/language_model/schemas.py,sha256=o8zGkfoYayO1gL85G-ulV3Akp_BwjgEWGGUb89j1OgU,35440
|
|
426
426
|
unique_toolkit/language_model/service.py,sha256=lgpzWhqxLBOeFacCafQi4e7BqAxJbOlr8GnCYcKeTdM,13274
|
|
427
427
|
unique_toolkit/language_model/settings.py,sha256=Yj9zcIctL3WhxDR4v6VnliYmn3txq519MK8DoWFHuiQ,1542
|
|
@@ -447,6 +447,6 @@ unique_toolkit/short_term_memory/service.py,sha256=2JMBEBn6GoyK-a0xvdcWpPft-3C74
|
|
|
447
447
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
448
448
|
unique_toolkit/smart_rules/compile.py,sha256=vRe0aMJWuVIK-VsqomgxQImzke7MDmwgSxxJfYCa7zw,1386
|
|
449
449
|
unique_toolkit/test_utilities/events.py,sha256=FLrhMh0A_mQutAUjoD0FdMcVQ4Gq31r35OVGzRjvLro,6760
|
|
450
|
-
unique_toolkit-2026.48.0.
|
|
451
|
-
unique_toolkit-2026.48.0.
|
|
452
|
-
unique_toolkit-2026.48.0.
|
|
450
|
+
unique_toolkit-2026.48.0.dev19.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
451
|
+
unique_toolkit-2026.48.0.dev19.dist-info/METADATA,sha256=K9HofFJ6Uhb8lf7YRbj5JkCNetuJKr527tAPr7cSEiM,8021
|
|
452
|
+
unique_toolkit-2026.48.0.dev19.dist-info/RECORD,,
|
|
File without changes
|