unique_toolkit 0.8.14__py3-none-any.whl → 0.8.16__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. unique_toolkit/_common/default_language_model.py +6 -0
  2. unique_toolkit/_common/token/image_token_counting.py +67 -0
  3. unique_toolkit/_common/token/token_counting.py +196 -0
  4. unique_toolkit/evals/config.py +36 -0
  5. unique_toolkit/evals/context_relevancy/prompts.py +56 -0
  6. unique_toolkit/evals/context_relevancy/schema.py +88 -0
  7. unique_toolkit/evals/context_relevancy/service.py +241 -0
  8. unique_toolkit/evals/hallucination/constants.py +61 -0
  9. unique_toolkit/evals/hallucination/hallucination_evaluation.py +92 -0
  10. unique_toolkit/evals/hallucination/prompts.py +79 -0
  11. unique_toolkit/evals/hallucination/service.py +57 -0
  12. unique_toolkit/evals/hallucination/utils.py +213 -0
  13. unique_toolkit/evals/output_parser.py +48 -0
  14. unique_toolkit/evals/tests/test_context_relevancy_service.py +252 -0
  15. unique_toolkit/evals/tests/test_output_parser.py +80 -0
  16. unique_toolkit/history_manager/history_construction_with_contents.py +307 -0
  17. unique_toolkit/history_manager/history_manager.py +80 -111
  18. unique_toolkit/history_manager/loop_token_reducer.py +457 -0
  19. unique_toolkit/language_model/schemas.py +8 -0
  20. unique_toolkit/reference_manager/reference_manager.py +15 -2
  21. {unique_toolkit-0.8.14.dist-info → unique_toolkit-0.8.16.dist-info}/METADATA +7 -1
  22. {unique_toolkit-0.8.14.dist-info → unique_toolkit-0.8.16.dist-info}/RECORD +24 -7
  23. {unique_toolkit-0.8.14.dist-info → unique_toolkit-0.8.16.dist-info}/LICENSE +0 -0
  24. {unique_toolkit-0.8.14.dist-info → unique_toolkit-0.8.16.dist-info}/WHEEL +0 -0
@@ -129,6 +129,14 @@ class LanguageModelStreamResponse(BaseModel):
129
129
  message: LanguageModelStreamResponseMessage
130
130
  tool_calls: list[LanguageModelFunction] | None = None
131
131
 
132
+ def is_empty(self) -> bool:
133
+ """
134
+ Check if the stream response is empty.
135
+ An empty stream response has no text and no tool calls.
136
+ """
137
+ return not self.message.original_text and not self.tool_calls
138
+
139
+
132
140
  def to_openai_param(self) -> ChatCompletionAssistantMessageParam:
133
141
  return ChatCompletionAssistantMessageParam(
134
142
  role="assistant",
@@ -3,7 +3,7 @@ from unique_toolkit.tools.schemas import ToolCallResponse
3
3
 
4
4
 
5
5
  class tool_chunks:
6
- def __init__(self, name: str, chunks: list) -> None:
6
+ def __init__(self, name: str, chunks: list[ContentChunk]) -> None:
7
7
  self.name = name
8
8
  self.chunks = chunks
9
9
 
@@ -47,8 +47,21 @@ class ReferenceManager:
47
47
  def get_chunks(self) -> list[ContentChunk]:
48
48
  return self._chunks
49
49
 
50
- def get_tool_chunks(self) -> dict:
50
+ def get_tool_chunks(self) -> dict[str, tool_chunks]:
51
51
  return self._tool_chunks
52
+
53
+
54
+ def get_chunks_of_all_tools(self) -> list[list[ContentChunk]]:
55
+ return [tool_chunks.chunks for tool_chunks in self._tool_chunks.values()]
56
+
57
+ def get_chunks_of_tool(self, tool_call_id: str) -> list[ContentChunk]:
58
+ return self._tool_chunks.get(tool_call_id, tool_chunks("", [])).chunks
59
+
60
+
61
+ def replace_chunks_of_tool(self, tool_call_id: str,chunks: list[ContentChunk]) -> None:
62
+ if tool_call_id in self._tool_chunks:
63
+ self._tool_chunks[tool_call_id].chunks = chunks
64
+
52
65
 
53
66
  def replace(self, chunks: list[ContentChunk]):
54
67
  self._chunks = chunks
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: unique_toolkit
3
- Version: 0.8.14
3
+ Version: 0.8.16
4
4
  Summary:
5
5
  License: Proprietary
6
6
  Author: Martin Fadler
@@ -114,6 +114,12 @@ All notable changes to this project will be documented in this file.
114
114
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
115
115
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
116
116
 
117
+ ## [0.8.16] - 2025-08-19
118
+ - moved Hallucination evaluator into toolkit
119
+
120
+ ## [0.8.15] - 2025-08-19
121
+ - Added history loading from database for History Manager
122
+
117
123
  ## [0.8.14] - 2025-08-19
118
124
  - Including GPT-5 series deployed via LiteLLM into language model info
119
125
 
@@ -1,7 +1,10 @@
1
1
  unique_toolkit/__init__.py,sha256=waK7W0EK3v2RJ26hawccwVz1i3yHGvHIIu5qgGjEGHQ,583
2
2
  unique_toolkit/_common/_base_service.py,sha256=S8H0rAebx7GsOldA7xInLp3aQJt9yEPDQdsGSFRJsGg,276
3
3
  unique_toolkit/_common/_time_utils.py,sha256=ztmTovTvr-3w71Ns2VwXC65OKUUh-sQlzbHdKTQWm-w,135
4
+ unique_toolkit/_common/default_language_model.py,sha256=M6OiVfpi21CixfgYFigOcJGqG8r987f2rxHnn0NZ2dc,333
4
5
  unique_toolkit/_common/exception.py,sha256=caQIE1btsQnpKCHqL2cgWUSbHup06enQu_Pt7uGUTTE,727
6
+ unique_toolkit/_common/token/image_token_counting.py,sha256=VpFfZyY0GIH27q_Wy4YNjk2algqvbCtJyzuuROoFQPw,2189
7
+ unique_toolkit/_common/token/token_counting.py,sha256=l8tDo5EaD5FIlKz7Zd6CTNYwMhF-UZ2S3Hb-pU5z2UY,6281
5
8
  unique_toolkit/_common/validate_required_values.py,sha256=Y_M1ub9gIKP9qZ45F6Zq3ZHtuIqhmOjl8Z2Vd3avg8w,588
6
9
  unique_toolkit/_common/validators.py,sha256=uPGPkeygNi3KimWZxKOKYFxwpCxTkhhYBAn-b_5TS_M,2584
7
10
  unique_toolkit/app/__init__.py,sha256=ETxYDpEizg_PKmi4JPX_P76ySq-us-xypfAIdKQ1QZU,1284
@@ -32,9 +35,21 @@ unique_toolkit/embedding/functions.py,sha256=3qp-BfuMAbnp8YB04rh3xH8vsJuCBPizoy-
32
35
  unique_toolkit/embedding/schemas.py,sha256=1GvKCaSk4jixzVQ2PKq8yDqwGEVY_hWclYtoAr6CC2g,96
33
36
  unique_toolkit/embedding/service.py,sha256=2KjYlUKxeh-Je8S1mOPiQ735pqAmdbeztycVNJxcUXA,5039
34
37
  unique_toolkit/embedding/utils.py,sha256=v86lo__bCJbxZBQ3OcLu5SuwT6NbFfWlcq8iyk6BuzQ,279
38
+ unique_toolkit/evals/config.py,sha256=LtBcPVCNpyZ2fFAKjiT9dPGauDSH5f0d_Jt4KpuS5OM,954
39
+ unique_toolkit/evals/context_relevancy/prompts.py,sha256=EdHFUOB581yVxcOL8482KUv_LzaRjuiem71EF8udYMc,1331
40
+ unique_toolkit/evals/context_relevancy/schema.py,sha256=xJeAHUwTTc-a090HhRYiK8Mob5Vt350lNfItz6w6Cq8,2958
41
+ unique_toolkit/evals/context_relevancy/service.py,sha256=j7crX64kMEGTcbQoUwCeGCCVaGfoLvYHclXLVt-x3zA,8384
35
42
  unique_toolkit/evals/evaluation_manager.py,sha256=_4XF2JY8EZd8kRmaZzF1S5R0kNATKTzgpE0ZIQDqQLE,7711
36
43
  unique_toolkit/evals/exception.py,sha256=7lcVbCyoN4Md1chNJDFxpUYyWbVrcr9dcc3TxWykJTc,115
44
+ unique_toolkit/evals/hallucination/constants.py,sha256=-eA0e3QntllNJ1wLOx-zAnCUrvDT4pS5IRwmACoMICc,1998
45
+ unique_toolkit/evals/hallucination/hallucination_evaluation.py,sha256=LRbnXola7lP5rl2wmuLEmAcTbSuB4e8yZdEA5U3Ze1k,3271
46
+ unique_toolkit/evals/hallucination/prompts.py,sha256=O3Hi_rOzZlujvnO2wn2jhoPmrYLjzVtRWwxn5Q81m9Y,3405
47
+ unique_toolkit/evals/hallucination/service.py,sha256=VH0jhoIf5_8lwy3f7ODhgVU08LfsXs5uk8GOjCpPVkc,2409
48
+ unique_toolkit/evals/hallucination/utils.py,sha256=CytY60CBdhq7777YljO38ngK3RSMqA-5Xh5YfpJbsE8,8127
49
+ unique_toolkit/evals/output_parser.py,sha256=vYjnlm8upIH1eiqGlwGx8K-KSf6IALgFeGMn6eW_HFE,1379
37
50
  unique_toolkit/evals/schemas.py,sha256=VwxT_L_1Fima1RwGWajp1DIPy36-4n23_eCFkK3MjTM,3114
51
+ unique_toolkit/evals/tests/test_context_relevancy_service.py,sha256=1kpNw4eeGXGX9eBr6IGEp605M6BrnBHFWs4j1_s3_Mc,7898
52
+ unique_toolkit/evals/tests/test_output_parser.py,sha256=HwSqptYI_8BeQtwyrQwPLwX11ugC5tjxL1BrM0LdMVc,3018
38
53
  unique_toolkit/evaluators/__init__.py,sha256=3Rfpnowm7MUXHWmeU4UV4s_3Hk-sw3V20oBwQCYlejQ,50
39
54
  unique_toolkit/evaluators/config.py,sha256=_DIXToJ-hGNpDAdWa7Q6GMjAsxiC_DquLF-SS5s9rTE,717
40
55
  unique_toolkit/evaluators/constants.py,sha256=1oI93jsh0R_TjX_8OenliiiywVe3vTooSnaMqtq6R18,27
@@ -54,7 +69,9 @@ unique_toolkit/framework_utilities/langchain/history.py,sha256=R9RuCeSFNaUO3OZ0G
54
69
  unique_toolkit/framework_utilities/openai/client.py,sha256=IasxPXlVJHIsZdXHin7yq-5tO4RNLUu9cEuhrgb4ghE,1205
55
70
  unique_toolkit/framework_utilities/openai/message_builder.py,sha256=VU6mJm_upLcarJQKFft_t1RlLRncWDxDuLC5LIJ5lQQ,4339
56
71
  unique_toolkit/framework_utilities/utils.py,sha256=JK7g2yMfEx3eMprug26769xqNpS5WJcizf8n2zWMBng,789
57
- unique_toolkit/history_manager/history_manager.py,sha256=ScC9CrkJCNbxFbWqTO-vpPlCUAUADpJCX2AqUd4Ff04,10104
72
+ unique_toolkit/history_manager/history_construction_with_contents.py,sha256=xKUVnJ4ZJq4-nnO2_35dbDh9d-zfCJfRzuj7v9hXUdM,9049
73
+ unique_toolkit/history_manager/history_manager.py,sha256=eo89SVl2A4_n-DnqsgKe_rZ94Nb3YK4-hdJiAzvWOXM,8690
74
+ unique_toolkit/history_manager/loop_token_reducer.py,sha256=-7Ezk3OLUsrU0Jd9Qc73_PBJZIayz7bVE3awc-q6Se0,17624
58
75
  unique_toolkit/history_manager/utils.py,sha256=3GT53SfOQ7g-dN3PHFIPaAab74sUfV28hbUtGMdX-bY,5607
59
76
  unique_toolkit/language_model/__init__.py,sha256=lRQyLlbwHbNFf4-0foBU13UGb09lwEeodbVsfsSgaCk,1971
60
77
  unique_toolkit/language_model/builder.py,sha256=4OKfwJfj3TrgO1ezc_ewIue6W7BCQ2ZYQXUckWVPPTA,3369
@@ -63,12 +80,12 @@ unique_toolkit/language_model/functions.py,sha256=-nWgcscaZvEfuf2ftCQj8hyFY2RynP
63
80
  unique_toolkit/language_model/infos.py,sha256=MbuXYtyTLik-7KTKlyQCjW3uNRTT5ddTvbpSarFxzPk,45715
64
81
  unique_toolkit/language_model/prompt.py,sha256=JSawaLjQg3VR-E2fK8engFyJnNdk21zaO8pPIodzN4Q,3991
65
82
  unique_toolkit/language_model/reference.py,sha256=nkX2VFz-IrUz8yqyc3G5jUMNwrNpxITBrMEKkbqqYoI,8583
66
- unique_toolkit/language_model/schemas.py,sha256=p95cAwrYmEBupI8f7JZY17aJTKEHvtqF88hMIzS5r_k,16259
83
+ unique_toolkit/language_model/schemas.py,sha256=ix5tCLUnlpAgc-WzV_54O_QpVI-shXOIUJVYVBRagpo,16498
67
84
  unique_toolkit/language_model/service.py,sha256=N_I3VtK5B0G8s5c6TcBVWM7CcLGqakDhEdHQ_z-Hcok,11676
68
85
  unique_toolkit/language_model/utils.py,sha256=bPQ4l6_YO71w-zaIPanUUmtbXC1_hCvLK0tAFc3VCRc,1902
69
86
  unique_toolkit/postprocessor/postprocessor_manager.py,sha256=68TAcXMU_ohWOtzo91LntY950HV9I9gGU92-V0Mxmr8,4239
70
87
  unique_toolkit/protocols/support.py,sha256=V15WEIFKVMyF1QCnR8vIi4GrJy4dfTCB6d6JlqPZ58o,2341
71
- unique_toolkit/reference_manager/reference_manager.py,sha256=JofRoTcnB-Azj9X10kmhqqTUUyPp4GRRWBmaiybzaUo,3446
88
+ unique_toolkit/reference_manager/reference_manager.py,sha256=WIvZkRgQztkY0zNTM_KIPSqJFT22HIGNexJ4yG3aj5E,3993
72
89
  unique_toolkit/short_term_memory/__init__.py,sha256=2mI3AUrffgH7Yt-xS57EGqnHf7jnn6xquoKEhJqk3Wg,185
73
90
  unique_toolkit/short_term_memory/constants.py,sha256=698CL6-wjup2MvU19RxSmQk3gX7aqW_OOpZB7sbz_Xg,34
74
91
  unique_toolkit/short_term_memory/functions.py,sha256=3WiK-xatY5nh4Dr5zlDUye1k3E6kr41RiscwtTplw5k,4484
@@ -90,7 +107,7 @@ unique_toolkit/tools/utils/execution/execution.py,sha256=vjG2Y6awsGNtlvyQAGCTthQ
90
107
  unique_toolkit/tools/utils/source_handling/schema.py,sha256=pvNhtL2daDLpCVIQpfdn6R35GvKmITVLXjZNLAwpgUE,871
91
108
  unique_toolkit/tools/utils/source_handling/source_formatting.py,sha256=C7uayNbdkNVJdEARA5CENnHtNY1SU6etlaqbgHNyxaQ,9152
92
109
  unique_toolkit/tools/utils/source_handling/tests/test_source_formatting.py,sha256=zu3AJnYH9CMqZPrxKEH3IgI-fM3nlvIBuspJG6W6B18,6978
93
- unique_toolkit-0.8.14.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
94
- unique_toolkit-0.8.14.dist-info/METADATA,sha256=5QadKjdIsrfsgxMGglGAN_qfn916APhtTcQWRc9S52c,27642
95
- unique_toolkit-0.8.14.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
96
- unique_toolkit-0.8.14.dist-info/RECORD,,
110
+ unique_toolkit-0.8.16.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
111
+ unique_toolkit-0.8.16.dist-info/METADATA,sha256=6bFV_VufKObIx2_UsorEVa09gEFyY2UIvS9zvY-py4E,27797
112
+ unique_toolkit-0.8.16.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
113
+ unique_toolkit-0.8.16.dist-info/RECORD,,