unique_toolkit 1.12.0__py3-none-any.whl → 1.13.0__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/evaluation_manager.py +9 -5
- unique_toolkit/agentic/evaluation/hallucination/hallucination_evaluation.py +9 -1
- unique_toolkit/content/functions.py +45 -1
- unique_toolkit/content/schemas.py +5 -0
- unique_toolkit/knowledge_base.py +127 -0
- {unique_toolkit-1.12.0.dist-info → unique_toolkit-1.13.0.dist-info}/METADATA +7 -1
- {unique_toolkit-1.12.0.dist-info → unique_toolkit-1.13.0.dist-info}/RECORD +9 -9
- {unique_toolkit-1.12.0.dist-info → unique_toolkit-1.13.0.dist-info}/LICENSE +0 -0
- {unique_toolkit-1.12.0.dist-info → unique_toolkit-1.13.0.dist-info}/WHEEL +0 -0
@@ -123,6 +123,15 @@ class EvaluationManager:
|
|
123
123
|
self._evaluation_passed = False
|
124
124
|
evaluation_results_unpacked.append(unpacked_evaluation_result)
|
125
125
|
|
126
|
+
for evaluation_name, evaluation_result in zip(
|
127
|
+
selected_evaluation_names, evaluation_results_unpacked
|
128
|
+
):
|
129
|
+
evaluation_instance = self.get_evaluation_by_name(evaluation_name)
|
130
|
+
if evaluation_instance:
|
131
|
+
await self._show_message_assessment(
|
132
|
+
evaluation_instance, evaluation_result, assistant_message_id
|
133
|
+
)
|
134
|
+
|
126
135
|
return evaluation_results_unpacked
|
127
136
|
|
128
137
|
async def execute_evaluation_call(
|
@@ -143,11 +152,6 @@ class EvaluationManager:
|
|
143
152
|
evaluation_metric_result: EvaluationMetricResult = (
|
144
153
|
await evaluation_instance.run(loop_response)
|
145
154
|
)
|
146
|
-
# show results to the user
|
147
|
-
await self._show_message_assessment(
|
148
|
-
evaluation_instance, evaluation_metric_result, assistant_message_id
|
149
|
-
)
|
150
|
-
|
151
155
|
return evaluation_metric_result
|
152
156
|
|
153
157
|
return EvaluationMetricResult(
|
@@ -78,11 +78,19 @@ class HallucinationEvaluation(Evaluation):
|
|
78
78
|
if not evaluation_result.error
|
79
79
|
else ChatMessageAssessmentStatus.ERROR
|
80
80
|
)
|
81
|
+
explanation = evaluation_result.reason
|
82
|
+
|
83
|
+
if status == ChatMessageAssessmentStatus.ERROR:
|
84
|
+
title = "Hallucination Check Error"
|
85
|
+
label = ChatMessageAssessmentLabel.RED
|
86
|
+
explanation = (
|
87
|
+
"An unrecoverable error occurred while evaluating the response."
|
88
|
+
)
|
81
89
|
|
82
90
|
return EvaluationAssessmentMessage(
|
83
91
|
status=status,
|
84
92
|
title=title,
|
85
|
-
explanation=
|
93
|
+
explanation=explanation,
|
86
94
|
label=label,
|
87
95
|
type=self.get_assessment_type(),
|
88
96
|
)
|
@@ -16,6 +16,7 @@ from unique_toolkit.content.schemas import (
|
|
16
16
|
ContentInfo,
|
17
17
|
ContentRerankerConfig,
|
18
18
|
ContentSearchType,
|
19
|
+
DeleteContentResponse,
|
19
20
|
FolderInfo,
|
20
21
|
PaginatedContentInfos,
|
21
22
|
)
|
@@ -585,6 +586,7 @@ def download_content(
|
|
585
586
|
def get_content_info(
|
586
587
|
user_id: str,
|
587
588
|
company_id: str,
|
589
|
+
*,
|
588
590
|
metadata_filter: dict[str, Any] | None = None,
|
589
591
|
skip: int | None = None,
|
590
592
|
take: int | None = None,
|
@@ -610,7 +612,7 @@ def get_content_info(
|
|
610
612
|
)
|
611
613
|
|
612
614
|
|
613
|
-
def get_folder_info(user_id: str, company_id: str, scope_id: str) -> FolderInfo:
|
615
|
+
def get_folder_info(user_id: str, company_id: str, *, scope_id: str) -> FolderInfo:
|
614
616
|
info = unique_sdk.Folder.get_info(
|
615
617
|
user_id=user_id, company_id=company_id, scopeId=scope_id
|
616
618
|
)
|
@@ -648,3 +650,45 @@ def update_content(
|
|
648
650
|
user_id=user_id, company_id=company_id, **update_params
|
649
651
|
)
|
650
652
|
return ContentInfo.model_validate(content_info, by_alias=True, by_name=True)
|
653
|
+
|
654
|
+
|
655
|
+
def delete_content(
|
656
|
+
user_id: str,
|
657
|
+
company_id: str,
|
658
|
+
*,
|
659
|
+
content_id: str | None = None,
|
660
|
+
file_path: str | None = None,
|
661
|
+
) -> DeleteContentResponse:
|
662
|
+
if content_id:
|
663
|
+
resp = unique_sdk.Content.delete(
|
664
|
+
user_id=user_id, company_id=company_id, contentId=content_id
|
665
|
+
)
|
666
|
+
elif file_path:
|
667
|
+
resp = unique_sdk.Content.delete(
|
668
|
+
user_id=user_id, company_id=company_id, filePath=file_path
|
669
|
+
)
|
670
|
+
else:
|
671
|
+
raise ValueError("content_id or file_path must be provided")
|
672
|
+
|
673
|
+
return DeleteContentResponse.model_validate(resp, by_alias=True, by_name=True)
|
674
|
+
|
675
|
+
|
676
|
+
async def delete_content_async(
|
677
|
+
user_id: str,
|
678
|
+
company_id: str,
|
679
|
+
*,
|
680
|
+
content_id: str | None = None,
|
681
|
+
file_path: str | None = None,
|
682
|
+
) -> DeleteContentResponse:
|
683
|
+
if content_id:
|
684
|
+
resp = await unique_sdk.Content.delete_async(
|
685
|
+
user_id=user_id, company_id=company_id, contentId=content_id
|
686
|
+
)
|
687
|
+
elif file_path:
|
688
|
+
resp = await unique_sdk.Content.delete_async(
|
689
|
+
user_id=user_id, company_id=company_id, filePath=file_path
|
690
|
+
)
|
691
|
+
else:
|
692
|
+
raise ValueError("content_id or file_path must be provided")
|
693
|
+
|
694
|
+
return DeleteContentResponse.model_validate(resp, by_alias=True, by_name=True)
|
unique_toolkit/knowledge_base.py
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import asyncio
|
1
2
|
import logging
|
2
3
|
from pathlib import Path
|
3
4
|
from typing import Any, overload
|
@@ -11,6 +12,8 @@ from unique_toolkit.content.constants import (
|
|
11
12
|
DEFAULT_SEARCH_LANGUAGE,
|
12
13
|
)
|
13
14
|
from unique_toolkit.content.functions import (
|
15
|
+
delete_content,
|
16
|
+
delete_content_async,
|
14
17
|
download_content_to_bytes,
|
15
18
|
download_content_to_file_by_id,
|
16
19
|
get_content_info,
|
@@ -29,6 +32,7 @@ from unique_toolkit.content.schemas import (
|
|
29
32
|
ContentInfo,
|
30
33
|
ContentRerankerConfig,
|
31
34
|
ContentSearchType,
|
35
|
+
DeleteContentResponse,
|
32
36
|
FolderInfo,
|
33
37
|
PaginatedContentInfos,
|
34
38
|
)
|
@@ -585,6 +589,129 @@ class KnowledgeBaseService:
|
|
585
589
|
|
586
590
|
return self._resolve_visible_file_tree(content_infos=info.content_infos)
|
587
591
|
|
592
|
+
@overload
|
593
|
+
def delete_content(
|
594
|
+
self,
|
595
|
+
*,
|
596
|
+
content_id: str,
|
597
|
+
) -> DeleteContentResponse: ...
|
598
|
+
|
599
|
+
"""Delete content by id"""
|
600
|
+
|
601
|
+
@overload
|
602
|
+
def delete_content(
|
603
|
+
self,
|
604
|
+
*,
|
605
|
+
file_path: str,
|
606
|
+
) -> DeleteContentResponse: ...
|
607
|
+
|
608
|
+
"""Delete all content matching the file path"""
|
609
|
+
|
610
|
+
def delete_content(
|
611
|
+
self,
|
612
|
+
*,
|
613
|
+
content_id: str | None = None,
|
614
|
+
file_path: str | None = None,
|
615
|
+
metadata_filter: dict[str, Any] | None = None,
|
616
|
+
) -> DeleteContentResponse:
|
617
|
+
"""Delete content by id, file path or metadata filter"""
|
618
|
+
if metadata_filter:
|
619
|
+
infos = self.get_paginated_content_infos(
|
620
|
+
metadata_filter=metadata_filter,
|
621
|
+
)
|
622
|
+
for info in infos.content_infos:
|
623
|
+
delete_content(
|
624
|
+
user_id=self._user_id,
|
625
|
+
company_id=self._company_id,
|
626
|
+
content_id=info.id,
|
627
|
+
)
|
628
|
+
|
629
|
+
return delete_content(
|
630
|
+
user_id=self._user_id,
|
631
|
+
company_id=self._company_id,
|
632
|
+
content_id=content_id,
|
633
|
+
file_path=file_path,
|
634
|
+
)
|
635
|
+
|
636
|
+
def delete_contents(
|
637
|
+
self,
|
638
|
+
*,
|
639
|
+
metadata_filter: dict[str, Any],
|
640
|
+
) -> list[DeleteContentResponse]:
|
641
|
+
"""Delete all content matching the metadata filter"""
|
642
|
+
resp: list[DeleteContentResponse] = []
|
643
|
+
|
644
|
+
if metadata_filter:
|
645
|
+
infos = self.get_paginated_content_infos(
|
646
|
+
metadata_filter=metadata_filter,
|
647
|
+
)
|
648
|
+
|
649
|
+
for info in infos.content_infos:
|
650
|
+
resp.append(
|
651
|
+
delete_content(
|
652
|
+
user_id=self._user_id,
|
653
|
+
company_id=self._company_id,
|
654
|
+
content_id=info.id,
|
655
|
+
)
|
656
|
+
)
|
657
|
+
|
658
|
+
return resp
|
659
|
+
|
660
|
+
@overload
|
661
|
+
async def delete_content_async(
|
662
|
+
self,
|
663
|
+
*,
|
664
|
+
content_id: str,
|
665
|
+
) -> DeleteContentResponse: ...
|
666
|
+
|
667
|
+
@overload
|
668
|
+
async def delete_content_async(
|
669
|
+
self,
|
670
|
+
*,
|
671
|
+
file_path: str,
|
672
|
+
) -> DeleteContentResponse: ...
|
673
|
+
|
674
|
+
async def delete_content_async(
|
675
|
+
self,
|
676
|
+
*,
|
677
|
+
content_id: str | None = None,
|
678
|
+
file_path: str | None = None,
|
679
|
+
) -> DeleteContentResponse:
|
680
|
+
return await delete_content_async(
|
681
|
+
user_id=self._user_id,
|
682
|
+
company_id=self._company_id,
|
683
|
+
content_id=content_id,
|
684
|
+
file_path=file_path,
|
685
|
+
)
|
686
|
+
|
687
|
+
async def delete_contents_async(
|
688
|
+
self,
|
689
|
+
*,
|
690
|
+
metadata_filter: dict[str, Any],
|
691
|
+
) -> list[DeleteContentResponse]:
|
692
|
+
"""Delete all content matching the metadata filter"""
|
693
|
+
if not metadata_filter:
|
694
|
+
return []
|
695
|
+
|
696
|
+
infos = self.get_paginated_content_infos(
|
697
|
+
metadata_filter=metadata_filter,
|
698
|
+
)
|
699
|
+
|
700
|
+
# Create all delete tasks without awaiting them
|
701
|
+
delete_tasks = [
|
702
|
+
delete_content_async(
|
703
|
+
user_id=self._user_id,
|
704
|
+
company_id=self._company_id,
|
705
|
+
content_id=info.id,
|
706
|
+
)
|
707
|
+
for info in infos.content_infos
|
708
|
+
]
|
709
|
+
|
710
|
+
# Await all delete operations concurrently
|
711
|
+
resp = await asyncio.gather(*delete_tasks)
|
712
|
+
|
713
|
+
return list(resp)
|
714
|
+
|
588
715
|
|
589
716
|
if __name__ == "__main__":
|
590
717
|
kb_service = KnowledgeBaseService.from_settings()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: unique_toolkit
|
3
|
-
Version: 1.
|
3
|
+
Version: 1.13.0
|
4
4
|
Summary:
|
5
5
|
License: Proprietary
|
6
6
|
Author: Cedric Klinkert
|
@@ -118,6 +118,12 @@ All notable changes to this project will be documented in this file.
|
|
118
118
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
119
119
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
120
120
|
|
121
|
+
## [1.13.0] - 2025-10-07
|
122
|
+
- Delete contents with knowledge base service
|
123
|
+
|
124
|
+
## [1.12.1] - 2025-10-07
|
125
|
+
- Fix bug where failed evaluations did not show an error to the user.
|
126
|
+
|
121
127
|
## [1.12.0] - 2026-10-07
|
122
128
|
- Add the `OpenAIUserMessageBuilder` for complex user messages with images
|
123
129
|
- More examples with documents/images on the chat
|
@@ -31,10 +31,10 @@ unique_toolkit/agentic/evaluation/config.py,sha256=Fer-y1aP8kmnPWXQydh12i9f_XU7K
|
|
31
31
|
unique_toolkit/agentic/evaluation/context_relevancy/prompts.py,sha256=EdHFUOB581yVxcOL8482KUv_LzaRjuiem71EF8udYMc,1331
|
32
32
|
unique_toolkit/agentic/evaluation/context_relevancy/schema.py,sha256=lZd0TPzH43ifgWWGg3WO6b1AQX8aK2R9y51yH0d1DHM,2919
|
33
33
|
unique_toolkit/agentic/evaluation/context_relevancy/service.py,sha256=fkPGq4Nnn5las1waYDICqHl6xC-rR5iOpT24YifGO20,9654
|
34
|
-
unique_toolkit/agentic/evaluation/evaluation_manager.py,sha256=
|
34
|
+
unique_toolkit/agentic/evaluation/evaluation_manager.py,sha256=IPx4BVUgkjFOP1BGLi0BlB6UujpXlZ0KGuSXDRemQhY,8143
|
35
35
|
unique_toolkit/agentic/evaluation/exception.py,sha256=7lcVbCyoN4Md1chNJDFxpUYyWbVrcr9dcc3TxWykJTc,115
|
36
36
|
unique_toolkit/agentic/evaluation/hallucination/constants.py,sha256=0HyvI5zu7JmjHLe9lKJSeAWMvfQfpmR6MLHJ4HPX1hc,2063
|
37
|
-
unique_toolkit/agentic/evaluation/hallucination/hallucination_evaluation.py,sha256=
|
37
|
+
unique_toolkit/agentic/evaluation/hallucination/hallucination_evaluation.py,sha256=yMcfA7iMNXkneNrFxJuoDIoB37mK8IRXEKnPsK_UDOk,3454
|
38
38
|
unique_toolkit/agentic/evaluation/hallucination/prompts.py,sha256=O3Hi_rOzZlujvnO2wn2jhoPmrYLjzVtRWwxn5Q81m9Y,3405
|
39
39
|
unique_toolkit/agentic/evaluation/hallucination/service.py,sha256=Ut-f768HY4E9zEhfMoKYnGTFRZVkxWGiSTGOpgfZWYM,2447
|
40
40
|
unique_toolkit/agentic/evaluation/hallucination/utils.py,sha256=QLsYvgAyQ5XnKEzn7ko7bXfzePD4De99TWnMKglMpds,8178
|
@@ -112,8 +112,8 @@ unique_toolkit/chat/state.py,sha256=Cjgwv_2vhDFbV69xxsn7SefhaoIAEqLx3ferdVFCnOg,
|
|
112
112
|
unique_toolkit/chat/utils.py,sha256=ihm-wQykBWhB4liR3LnwPVPt_qGW6ETq21Mw4HY0THE,854
|
113
113
|
unique_toolkit/content/__init__.py,sha256=EdJg_A_7loEtCQf4cah3QARQreJx6pdz89Rm96YbMVg,940
|
114
114
|
unique_toolkit/content/constants.py,sha256=1iy4Y67xobl5VTnJB6SxSyuoBWbdLl9244xfVMUZi5o,60
|
115
|
-
unique_toolkit/content/functions.py,sha256=
|
116
|
-
unique_toolkit/content/schemas.py,sha256=
|
115
|
+
unique_toolkit/content/functions.py,sha256=TWwXGHZ8AeBC7UbRVjKXjHC7PmlghPtPNQvw7fOj1tY,22403
|
116
|
+
unique_toolkit/content/schemas.py,sha256=pBm1XHSgATdVe9PWUcEetRux9W6oRQ91oFl-kHofDh0,5665
|
117
117
|
unique_toolkit/content/service.py,sha256=i7wN_wYjF8NBZHBcpcA5XRlMRGntuw3mlVoudAoGQRk,23293
|
118
118
|
unique_toolkit/content/smart_rules.py,sha256=z2gHToPrdyj3HqO8Uu-JE5G2ClvJPuhR2XERmmkgoug,9668
|
119
119
|
unique_toolkit/content/utils.py,sha256=qNVmHTuETaPNGqheg7TbgPr1_1jbNHDc09N5RrmUIyo,7901
|
@@ -130,7 +130,7 @@ unique_toolkit/framework_utilities/openai/__init__.py,sha256=CrHYoC7lv2pBscitLer
|
|
130
130
|
unique_toolkit/framework_utilities/openai/client.py,sha256=ct1cqPcIK1wPl11G9sJV39ZnLJwKr2kDUDSra0FjvtM,2007
|
131
131
|
unique_toolkit/framework_utilities/openai/message_builder.py,sha256=RT1pZjxH42TFZlAxQ5zlqdKPvHKVTjc5t3JDUy58I7Q,6887
|
132
132
|
unique_toolkit/framework_utilities/utils.py,sha256=JK7g2yMfEx3eMprug26769xqNpS5WJcizf8n2zWMBng,789
|
133
|
-
unique_toolkit/knowledge_base.py,sha256=
|
133
|
+
unique_toolkit/knowledge_base.py,sha256=SdkMM8aiPeksYLjlNiqD6JgJWM5H-rpaoce-Igp0mYo,23566
|
134
134
|
unique_toolkit/language_model/__init__.py,sha256=lRQyLlbwHbNFf4-0foBU13UGb09lwEeodbVsfsSgaCk,1971
|
135
135
|
unique_toolkit/language_model/builder.py,sha256=4OKfwJfj3TrgO1ezc_ewIue6W7BCQ2ZYQXUckWVPPTA,3369
|
136
136
|
unique_toolkit/language_model/constants.py,sha256=B-topqW0r83dkC_25DeQfnPk3n53qzIHUCBS7YJ0-1U,119
|
@@ -149,7 +149,7 @@ unique_toolkit/short_term_memory/schemas.py,sha256=OhfcXyF6ACdwIXW45sKzjtZX_gkcJ
|
|
149
149
|
unique_toolkit/short_term_memory/service.py,sha256=5PeVBu1ZCAfyDb2HLVvlmqSbyzBBuE9sI2o9Aajqjxg,8884
|
150
150
|
unique_toolkit/smart_rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
151
151
|
unique_toolkit/smart_rules/compile.py,sha256=Ozhh70qCn2yOzRWr9d8WmJeTo7AQurwd3tStgBMPFLA,1246
|
152
|
-
unique_toolkit-1.
|
153
|
-
unique_toolkit-1.
|
154
|
-
unique_toolkit-1.
|
155
|
-
unique_toolkit-1.
|
152
|
+
unique_toolkit-1.13.0.dist-info/LICENSE,sha256=GlN8wHNdh53xwOPg44URnwag6TEolCjoq3YD_KrWgss,193
|
153
|
+
unique_toolkit-1.13.0.dist-info/METADATA,sha256=wQc8-zijmHKsEz9v1ECKbKDJo_i7JMSWrSeppYE79CY,36164
|
154
|
+
unique_toolkit-1.13.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
155
|
+
unique_toolkit-1.13.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|