unique_toolkit 0.8.16__tar.gz → 0.8.17__tar.gz
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-0.8.16 → unique_toolkit-0.8.17}/CHANGELOG.md +3 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/PKG-INFO +4 -1
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/pyproject.toml +1 -1
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/token/token_counting.py +2 -3
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/validators.py +7 -0
- unique_toolkit-0.8.17/unique_toolkit/debug_info_manager/debug_info_manager.py +19 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/hallucination_evaluation.py +7 -8
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/history_manager/history_construction_with_contents.py +4 -4
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/history_manager/history_manager.py +48 -58
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/history_manager/loop_token_reducer.py +17 -17
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/postprocessor/postprocessor_manager.py +1 -2
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/factory.py +7 -2
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/tool.py +0 -2
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/tool_manager.py +0 -3
- unique_toolkit-0.8.16/unique_toolkit/tools/agent_chunks_handler.py +0 -62
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/LICENSE +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/README.md +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/_base_service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/_time_utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/default_language_model.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/exception.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/token/image_token_counting.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/validate_required_values.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/dev_util.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/init_logging.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/init_sdk.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/performance/async_tasks.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/performance/async_wrapper.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/unique_settings.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/verification.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/chat/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/chat/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/chat/functions.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/chat/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/chat/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/chat/state.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/chat/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/content/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/content/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/content/functions.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/content/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/content/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/content/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/embedding/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/embedding/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/embedding/functions.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/embedding/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/embedding/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/embedding/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/config.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/context_relevancy/prompts.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/context_relevancy/schema.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/context_relevancy/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/evaluation_manager.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/exception.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/prompts.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/output_parser.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/tests/test_context_relevancy_service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/tests/test_output_parser.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/config.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/context_relevancy/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/context_relevancy/prompts.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/context_relevancy/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/context_relevancy/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/exception.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/prompts.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/output_parser.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/framework_utilities/langchain/client.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/framework_utilities/langchain/history.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/framework_utilities/openai/client.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/framework_utilities/openai/message_builder.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/framework_utilities/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/history_manager/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/builder.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/functions.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/infos.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/prompt.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/reference.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/language_model/utils.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/protocols/support.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/reference_manager/reference_manager.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/constants.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/functions.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/persistent_short_term_memory_manager.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/service.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/smart_rules/__init__.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/smart_rules/compile.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/thinking_manager/thinking_manager.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/config.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/schemas.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/test/test_tool_progress_reporter.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/tool_progress_reporter.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/utils/execution/execution.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/utils/source_handling/schema.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/utils/source_handling/source_formatting.py +0 -0
- {unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/utils/source_handling/tests/test_source_formatting.py +0 -0
|
@@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.8.17] - 2025-08-22
|
|
9
|
+
- fixed circular dependencies in tools
|
|
10
|
+
|
|
8
11
|
## [0.8.16] - 2025-08-19
|
|
9
12
|
- moved Hallucination evaluator into toolkit
|
|
10
13
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unique_toolkit
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.17
|
|
4
4
|
Summary:
|
|
5
5
|
License: Proprietary
|
|
6
6
|
Author: Martin Fadler
|
|
@@ -114,6 +114,9 @@ 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.17] - 2025-08-22
|
|
118
|
+
- fixed circular dependencies in tools
|
|
119
|
+
|
|
117
120
|
## [0.8.16] - 2025-08-19
|
|
118
121
|
- moved Hallucination evaluator into toolkit
|
|
119
122
|
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/token/token_counting.py
RENAMED
|
@@ -5,15 +5,14 @@ import json
|
|
|
5
5
|
from typing import Any, Callable
|
|
6
6
|
|
|
7
7
|
from pydantic import BaseModel
|
|
8
|
+
from unique_toolkit._common.token.image_token_counting import calculate_image_tokens_from_base64
|
|
8
9
|
from unique_toolkit.language_model import (
|
|
9
10
|
LanguageModelMessage,
|
|
10
11
|
LanguageModelMessages,
|
|
11
12
|
LanguageModelName,
|
|
12
13
|
)
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
calculate_image_tokens_from_base64,
|
|
16
|
-
)
|
|
15
|
+
|
|
17
16
|
|
|
18
17
|
|
|
19
18
|
class SpecialToolCallingTokens(BaseModel):
|
|
@@ -28,6 +28,13 @@ LMI = Annotated[
|
|
|
28
28
|
),
|
|
29
29
|
]
|
|
30
30
|
|
|
31
|
+
def get_LMI_default_field(llm_name: LanguageModelName, **kwargs) -> Any:
|
|
32
|
+
return Field(
|
|
33
|
+
default=LanguageModelInfo.from_name(llm_name),
|
|
34
|
+
json_schema_extra={"default": llm_name},
|
|
35
|
+
**kwargs,
|
|
36
|
+
)
|
|
37
|
+
|
|
31
38
|
|
|
32
39
|
def serialize_lmi(model: LanguageModelInfo) -> str | LanguageModelInfo:
|
|
33
40
|
if model.provider == LanguageModelProvider.CUSTOM:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from unique_toolkit.content.schemas import ContentChunk, ContentReference
|
|
2
|
+
from unique_toolkit.tools.schemas import ToolCallResponse
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class DebugInfoManager:
|
|
6
|
+
def __init__(self):
|
|
7
|
+
self.debug_info = {"tools": []}
|
|
8
|
+
|
|
9
|
+
def extract_tool_debug_info(self, tool_call_responses: list[ToolCallResponse]):
|
|
10
|
+
for tool_call_response in tool_call_responses:
|
|
11
|
+
self.debug_info["tools"].append(
|
|
12
|
+
{"name": tool_call_response.name, "data": tool_call_response.debug_info}
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
def add(self, key, value):
|
|
16
|
+
self.debug_info = self.debug_info | {key: value}
|
|
17
|
+
|
|
18
|
+
def get(self):
|
|
19
|
+
return self.debug_info
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
from typing import Any
|
|
2
2
|
|
|
3
|
-
from unique_toolkit.
|
|
4
|
-
from unique_toolkit.
|
|
3
|
+
from unique_toolkit.app.schemas import ChatEvent
|
|
4
|
+
from unique_toolkit.chat.schemas import (
|
|
5
5
|
ChatMessageAssessmentLabel,
|
|
6
6
|
ChatMessageAssessmentStatus,
|
|
7
7
|
ChatMessageAssessmentType,
|
|
8
8
|
)
|
|
9
|
-
from unique_toolkit.
|
|
10
|
-
from unique_toolkit.
|
|
11
|
-
from unique_toolkit.
|
|
12
|
-
from unique_toolkit.unique_toolkit.evals.schemas import (
|
|
9
|
+
from unique_toolkit.evals.evaluation_manager import Evaluation
|
|
10
|
+
from unique_toolkit.evals.hallucination.utils import check_hallucination
|
|
11
|
+
from unique_toolkit.evals.schemas import (
|
|
13
12
|
EvaluationAssessmentMessage,
|
|
14
13
|
EvaluationMetricInput,
|
|
15
14
|
EvaluationMetricName,
|
|
16
15
|
EvaluationMetricResult,
|
|
17
16
|
)
|
|
18
|
-
from unique_toolkit.
|
|
17
|
+
from unique_toolkit.evals.hallucination.constants import (
|
|
19
18
|
HallucinationConfig,
|
|
20
19
|
)
|
|
21
|
-
from unique_toolkit.
|
|
20
|
+
from unique_toolkit.reference_manager.reference_manager import (
|
|
22
21
|
ReferenceManager,
|
|
23
22
|
)
|
|
24
23
|
|
|
@@ -9,10 +9,10 @@ import tiktoken
|
|
|
9
9
|
|
|
10
10
|
from pydantic import RootModel
|
|
11
11
|
|
|
12
|
-
from _common.token.token_counting import num_tokens_per_language_model_message
|
|
13
|
-
from chat.service import ChatService
|
|
14
|
-
from content.service import ContentService
|
|
15
|
-
from language_model.schemas import LanguageModelMessages
|
|
12
|
+
from unique_toolkit._common.token.token_counting import num_tokens_per_language_model_message
|
|
13
|
+
from unique_toolkit.chat.service import ChatService
|
|
14
|
+
from unique_toolkit.content.service import ContentService
|
|
15
|
+
from unique_toolkit.language_model.schemas import LanguageModelMessages
|
|
16
16
|
from unique_toolkit.app import ChatEventUserMessage
|
|
17
17
|
from unique_toolkit.chat.schemas import ChatMessage
|
|
18
18
|
from unique_toolkit.chat.schemas import ChatMessageRole as ChatRole
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/history_manager/history_manager.py
RENAMED
|
@@ -1,92 +1,84 @@
|
|
|
1
|
-
from datetime import datetime
|
|
2
1
|
from logging import Logger
|
|
3
2
|
from typing import Annotated, Awaitable, Callable
|
|
4
3
|
|
|
5
4
|
from pydantic import BaseModel, Field
|
|
6
5
|
|
|
7
|
-
import tiktoken
|
|
8
6
|
from unique_toolkit.app.schemas import ChatEvent
|
|
9
7
|
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
from unique_toolkit.chat.service import ChatService
|
|
13
|
-
from unique_toolkit.content.schemas import Content
|
|
14
|
-
from unique_toolkit.content.service import ContentService
|
|
15
|
-
from unique_toolkit.language_model.builder import MessagesBuilder
|
|
9
|
+
|
|
16
10
|
from unique_toolkit.language_model.schemas import (
|
|
17
11
|
LanguageModelAssistantMessage,
|
|
18
12
|
LanguageModelFunction,
|
|
19
|
-
LanguageModelMessage,
|
|
20
|
-
LanguageModelMessageRole,
|
|
13
|
+
LanguageModelMessage,
|
|
21
14
|
LanguageModelMessages,
|
|
22
|
-
|
|
23
|
-
LanguageModelToolMessage,
|
|
24
|
-
LanguageModelUserMessage,
|
|
15
|
+
LanguageModelToolMessage
|
|
25
16
|
)
|
|
26
17
|
|
|
27
18
|
from unique_toolkit.tools.schemas import ToolCallResponse
|
|
28
19
|
from unique_toolkit.history_manager.utils import transform_chunks_to_string
|
|
29
20
|
|
|
30
|
-
from _common.validators import LMI
|
|
31
|
-
from history_manager.loop_token_reducer import LoopTokenReducer
|
|
32
|
-
from
|
|
33
|
-
from
|
|
21
|
+
from unique_toolkit._common.validators import LMI
|
|
22
|
+
from unique_toolkit.history_manager.loop_token_reducer import LoopTokenReducer
|
|
23
|
+
from unique_toolkit.language_model.infos import LanguageModelInfo, LanguageModelName
|
|
24
|
+
from unique_toolkit.reference_manager.reference_manager import ReferenceManager
|
|
25
|
+
from unique_toolkit.tools.config import get_configuration_dict
|
|
34
26
|
|
|
35
27
|
DeactivatedNone = Annotated[
|
|
36
28
|
None,
|
|
37
29
|
Field(title="Deactivated", description="None"),
|
|
38
30
|
]
|
|
39
31
|
|
|
40
|
-
class
|
|
32
|
+
class UploadedContentConfig(BaseModel):
|
|
33
|
+
model_config = get_configuration_dict()
|
|
41
34
|
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
user_context_window_limit_warning: str = Field(
|
|
36
|
+
default="The uploaded content is too large to fit into the ai model. "
|
|
37
|
+
"Unique AI will search for relevant sections in the material and if needed combine the data with knowledge base content",
|
|
38
|
+
description="Message to show when using the Internal Search instead of upload and chat tool due to context window limit. Jinja template.",
|
|
39
|
+
)
|
|
40
|
+
percent_for_uploaded_content: float = Field(
|
|
41
|
+
default=0.6,
|
|
42
|
+
ge=0.0,
|
|
43
|
+
lt=1.0,
|
|
44
|
+
description="The fraction of the max input tokens that will be reserved for the uploaded content.",
|
|
45
|
+
)
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
default=0.6,
|
|
47
|
-
ge=0.0,
|
|
48
|
-
lt=1.0,
|
|
49
|
-
description="The fraction of the max input tokens that will be reserved for the history.",
|
|
50
|
-
)
|
|
47
|
+
class ExperimentalFeatures(BaseModel):
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
model_config = get_configuration_dict()
|
|
49
|
+
full_sources_serialize_dump: bool = Field(
|
|
50
|
+
default=False,
|
|
51
|
+
description="If True, the sources will be serialized in full, otherwise only the content will be serialized.",
|
|
52
|
+
)
|
|
57
53
|
|
|
58
|
-
user_context_window_limit_warning: str = Field(
|
|
59
|
-
default="The uploaded content is too large to fit into the ai model. "
|
|
60
|
-
"Unique AI will search for relevant sections in the material and if needed combine the data with knowledge base content",
|
|
61
|
-
description="Message to show when using the Internal Search instead of upload and chat tool due to context window limit. Jinja template.",
|
|
62
|
-
)
|
|
63
|
-
percent_for_uploaded_content: float = Field(
|
|
64
|
-
default=0.6,
|
|
65
|
-
ge=0.0,
|
|
66
|
-
lt=1.0,
|
|
67
|
-
description="The fraction of the max input tokens that will be reserved for the uploaded content.",
|
|
68
|
-
)
|
|
69
54
|
|
|
70
|
-
|
|
71
|
-
def __init__(self, full_sources_serialize_dump: bool = False):
|
|
72
|
-
self.full_sources_serialize_dump = full_sources_serialize_dump
|
|
55
|
+
class HistoryManagerConfig(BaseModel):
|
|
73
56
|
|
|
74
|
-
full_sources_serialize_dump: bool = Field(
|
|
75
|
-
default=False,
|
|
76
|
-
description="If True, the sources will be serialized in full, otherwise only the content will be serialized.",
|
|
77
|
-
)
|
|
78
57
|
|
|
79
58
|
experimental_features: ExperimentalFeatures = Field(
|
|
80
59
|
default=ExperimentalFeatures(),
|
|
81
60
|
description="Experimental features for the history manager.",
|
|
82
61
|
)
|
|
83
62
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
|
|
64
|
+
percent_of_max_tokens_for_history: float = Field(
|
|
65
|
+
default=0.2,
|
|
66
|
+
ge=0.0,
|
|
67
|
+
lt=1.0,
|
|
68
|
+
description="The fraction of the max input tokens that will be reserved for the history.",
|
|
88
69
|
)
|
|
89
70
|
|
|
71
|
+
language_model: LMI = LanguageModelInfo.from_name(
|
|
72
|
+
LanguageModelName.AZURE_GPT_4o_2024_1120
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
@property
|
|
76
|
+
def max_history_tokens(self) -> int:
|
|
77
|
+
return int(
|
|
78
|
+
self.language_model.token_limits.token_limit_input
|
|
79
|
+
* self.percent_of_max_tokens_for_history,
|
|
80
|
+
)
|
|
81
|
+
|
|
90
82
|
uploaded_content_config: (
|
|
91
83
|
Annotated[
|
|
92
84
|
UploadedContentConfig,
|
|
@@ -96,11 +88,6 @@ class HistoryManagerConfig(BaseModel):
|
|
|
96
88
|
) = UploadedContentConfig()
|
|
97
89
|
|
|
98
90
|
|
|
99
|
-
input_token_distribution: InputTokenDistributionConfig = Field(
|
|
100
|
-
default=InputTokenDistributionConfig(),
|
|
101
|
-
description="Configuration for the input token distribution.",
|
|
102
|
-
)
|
|
103
|
-
|
|
104
91
|
|
|
105
92
|
class HistoryManager:
|
|
106
93
|
"""
|
|
@@ -140,7 +127,8 @@ class HistoryManager:
|
|
|
140
127
|
self._token_reducer = LoopTokenReducer(
|
|
141
128
|
logger=self._logger,
|
|
142
129
|
event=event,
|
|
143
|
-
|
|
130
|
+
max_history_tokens=self._config.max_history_tokens,
|
|
131
|
+
has_uploaded_content_config=bool(self._config.uploaded_content_config),
|
|
144
132
|
language_model=self._language_model,
|
|
145
133
|
reference_manager=reference_manager,
|
|
146
134
|
)
|
|
@@ -220,6 +208,8 @@ class HistoryManager:
|
|
|
220
208
|
rendered_system_message_string: str,
|
|
221
209
|
remove_from_text: Callable[[str], Awaitable[str]]
|
|
222
210
|
) -> LanguageModelMessages:
|
|
211
|
+
self._logger.info("Getting history for model call -> ")
|
|
212
|
+
|
|
223
213
|
messages = await self._token_reducer.get_history_for_model_call(
|
|
224
214
|
original_user_message=original_user_message,
|
|
225
215
|
rendered_user_message_string=rendered_user_message_string,
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/history_manager/loop_token_reducer.py
RENAMED
|
@@ -5,16 +5,15 @@ from typing import Awaitable, Callable
|
|
|
5
5
|
|
|
6
6
|
from pydantic import BaseModel
|
|
7
7
|
import tiktoken
|
|
8
|
-
from _common.token.token_counting import num_token_for_language_model_messages
|
|
9
|
-
from _common.validators import LMI
|
|
10
|
-
from app.schemas import ChatEvent
|
|
11
|
-
from chat.service import ChatService
|
|
12
|
-
from content.schemas import ContentChunk
|
|
13
|
-
from content.service import ContentService
|
|
14
|
-
from history_manager.history_construction_with_contents import FileContentSerialization, get_full_history_with_contents
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from reference_manager.reference_manager import ReferenceManager
|
|
8
|
+
from unique_toolkit._common.token.token_counting import num_token_for_language_model_messages
|
|
9
|
+
from unique_toolkit._common.validators import LMI
|
|
10
|
+
from unique_toolkit.app.schemas import ChatEvent
|
|
11
|
+
from unique_toolkit.chat.service import ChatService
|
|
12
|
+
from unique_toolkit.content.schemas import ContentChunk
|
|
13
|
+
from unique_toolkit.content.service import ContentService
|
|
14
|
+
from unique_toolkit.history_manager.history_construction_with_contents import FileContentSerialization, get_full_history_with_contents
|
|
15
|
+
from unique_toolkit.language_model.schemas import LanguageModelAssistantMessage, LanguageModelMessage, LanguageModelMessageRole, LanguageModelMessages, LanguageModelSystemMessage, LanguageModelToolMessage, LanguageModelUserMessage
|
|
16
|
+
from unique_toolkit.reference_manager.reference_manager import ReferenceManager
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
class SourceReductionResult(BaseModel):
|
|
@@ -33,11 +32,14 @@ class LoopTokenReducer():
|
|
|
33
32
|
self,
|
|
34
33
|
logger: Logger,
|
|
35
34
|
event: ChatEvent,
|
|
36
|
-
|
|
35
|
+
max_history_tokens:int,
|
|
36
|
+
has_uploaded_content_config: bool,
|
|
37
37
|
reference_manager: ReferenceManager,
|
|
38
38
|
language_model: LMI
|
|
39
39
|
):
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
self._max_history_tokens = max_history_tokens
|
|
42
|
+
self._has_uploaded_content_config = has_uploaded_content_config
|
|
41
43
|
self._logger = logger
|
|
42
44
|
self._reference_manager = reference_manager
|
|
43
45
|
self._language_model = language_model
|
|
@@ -49,7 +51,7 @@ class LoopTokenReducer():
|
|
|
49
51
|
|
|
50
52
|
|
|
51
53
|
def _get_encoder(self, language_model: LMI) -> tiktoken.Encoding:
|
|
52
|
-
name = language_model.
|
|
54
|
+
name = language_model.encoder_name or "cl100k_base"
|
|
53
55
|
return tiktoken.get_encoding(name)
|
|
54
56
|
|
|
55
57
|
async def get_history_for_model_call( self,
|
|
@@ -203,7 +205,7 @@ class LoopTokenReducer():
|
|
|
203
205
|
content_service=self._content_service,
|
|
204
206
|
file_content_serialization_type=(
|
|
205
207
|
FileContentSerialization.NONE
|
|
206
|
-
if self.
|
|
208
|
+
if self._has_uploaded_content_config
|
|
207
209
|
else FileContentSerialization.FILE_NAME
|
|
208
210
|
),
|
|
209
211
|
)
|
|
@@ -212,9 +214,7 @@ class LoopTokenReducer():
|
|
|
212
214
|
|
|
213
215
|
limited_history_messages = self._limit_to_token_window(
|
|
214
216
|
full_history.root,
|
|
215
|
-
self.
|
|
216
|
-
self._language_model.token_limits.token_limit_input,
|
|
217
|
-
)
|
|
217
|
+
self._max_history_tokens
|
|
218
218
|
)
|
|
219
219
|
|
|
220
220
|
|
|
@@ -4,10 +4,9 @@ from logging import Logger
|
|
|
4
4
|
|
|
5
5
|
from unique_toolkit.chat.service import ChatService
|
|
6
6
|
from unique_toolkit.language_model.schemas import (
|
|
7
|
-
LanguageModelMessage,
|
|
8
7
|
LanguageModelStreamResponse,
|
|
9
8
|
)
|
|
10
|
-
from unique_toolkit.tools.utils.execution.execution import
|
|
9
|
+
from unique_toolkit.tools.utils.execution.execution import SafeTaskExecutor
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
class Postprocessor(ABC):
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
from typing import Callable
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
from unique_toolkit.tools.schemas import BaseToolConfig
|
|
3
|
+
|
|
5
4
|
from unique_toolkit.tools.tool import Tool
|
|
6
5
|
|
|
6
|
+
from unique_toolkit.tools.schemas import BaseToolConfig
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
7
10
|
if TYPE_CHECKING:
|
|
8
11
|
from unique_toolkit.tools.config import ToolBuildConfig
|
|
9
12
|
|
|
10
13
|
|
|
14
|
+
|
|
15
|
+
|
|
11
16
|
class ToolFactory:
|
|
12
17
|
tool_map: dict[str, type[Tool]] = {}
|
|
13
18
|
tool_config_map: dict[str, Callable] = {}
|
|
@@ -19,7 +19,6 @@ from unique_toolkit.language_model.service import LanguageModelService
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
from unique_toolkit.evals.schemas import EvaluationMetricName
|
|
22
|
-
from unique_toolkit.tools.agent_chunks_handler import AgentChunksHandler
|
|
23
22
|
from unique_toolkit.tools.config import ToolBuildConfig, ToolSelectionPolicy
|
|
24
23
|
from unique_toolkit.tools.schemas import BaseToolConfig, ToolCallResponse, ToolPrompts
|
|
25
24
|
from unique_toolkit.tools.tool_progress_reporter import ToolProgressReporter
|
|
@@ -81,7 +80,6 @@ class Tool(ABC, Generic[ConfigType]):
|
|
|
81
80
|
def get_tool_call_result_for_loop_history(
|
|
82
81
|
self,
|
|
83
82
|
tool_response: ToolCallResponse,
|
|
84
|
-
agent_chunks_handler: AgentChunksHandler,
|
|
85
83
|
) -> LanguageModelMessage:
|
|
86
84
|
raise NotImplementedError
|
|
87
85
|
|
|
@@ -35,9 +35,6 @@ class ToolManagerConfig(BaseModel):
|
|
|
35
35
|
description="Maximum number of tool calls that can be executed in one iteration.",
|
|
36
36
|
)
|
|
37
37
|
|
|
38
|
-
def __init__(self, tools: list[ToolBuildConfig], max_tool_calls: int = 10):
|
|
39
|
-
self.tools = tools
|
|
40
|
-
self.max_tool_calls = max_tool_calls
|
|
41
38
|
|
|
42
39
|
|
|
43
40
|
class ToolManager:
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
from unique_toolkit.content.schemas import ContentChunk, ContentReference
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class AgentChunksHandler:
|
|
5
|
-
def __init__(self):
|
|
6
|
-
self._tool_chunks = {}
|
|
7
|
-
self._chunks: list[ContentChunk] = []
|
|
8
|
-
self._references: list[list[ContentReference]] = []
|
|
9
|
-
|
|
10
|
-
@property
|
|
11
|
-
def chunks(self) -> list[ContentChunk]:
|
|
12
|
-
return self._chunks
|
|
13
|
-
|
|
14
|
-
@property
|
|
15
|
-
def tool_chunks(self) -> dict:
|
|
16
|
-
return self._tool_chunks
|
|
17
|
-
|
|
18
|
-
def extend(self, chunks: list[ContentChunk]):
|
|
19
|
-
self._chunks.extend(chunks)
|
|
20
|
-
|
|
21
|
-
def replace(self, chunks: list[ContentChunk]):
|
|
22
|
-
self._chunks = chunks
|
|
23
|
-
|
|
24
|
-
def add_references(
|
|
25
|
-
self,
|
|
26
|
-
references: list[ContentReference],
|
|
27
|
-
):
|
|
28
|
-
self._references.append(references)
|
|
29
|
-
|
|
30
|
-
@property
|
|
31
|
-
def all_references(
|
|
32
|
-
self,
|
|
33
|
-
) -> list[list[ContentReference]]:
|
|
34
|
-
return self._references
|
|
35
|
-
|
|
36
|
-
@property
|
|
37
|
-
def latest_references(
|
|
38
|
-
self,
|
|
39
|
-
) -> list[ContentReference]:
|
|
40
|
-
if not self._references:
|
|
41
|
-
return []
|
|
42
|
-
return self._references[-1]
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def latest_referenced_chunks(self) -> list[ContentChunk]:
|
|
46
|
-
if not self._references:
|
|
47
|
-
return []
|
|
48
|
-
return self._get_referenced_chunks_from_references(self._references[-1])
|
|
49
|
-
|
|
50
|
-
def _get_referenced_chunks_from_references(
|
|
51
|
-
self,
|
|
52
|
-
references: list[ContentReference],
|
|
53
|
-
) -> list[ContentChunk]:
|
|
54
|
-
"""
|
|
55
|
-
Get _referenced_chunks by matching sourceId from _references with merged id and chunk_id from _chunks.
|
|
56
|
-
"""
|
|
57
|
-
referenced_chunks: list[ContentChunk] = []
|
|
58
|
-
for ref in references:
|
|
59
|
-
for chunk in self._chunks:
|
|
60
|
-
if ref.source_id == str(chunk.id) + "_" + str(chunk.chunk_id):
|
|
61
|
-
referenced_chunks.append(chunk)
|
|
62
|
-
return referenced_chunks
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/default_language_model.py
RENAMED
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/token/image_token_counting.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/_common/validate_required_values.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/performance/async_tasks.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/app/performance/async_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/context_relevancy/prompts.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/context_relevancy/schema.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/context_relevancy/service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/constants.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/prompts.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/hallucination/service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evals/tests/test_output_parser.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/context_relevancy/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/constants.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/prompts.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/service.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/evaluators/hallucination/utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/framework_utilities/openai/client.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/__init__.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/constants.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/short_term_memory/functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/thinking_manager/thinking_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/tool_progress_reporter.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/utils/execution/execution.py
RENAMED
|
File without changes
|
{unique_toolkit-0.8.16 → unique_toolkit-0.8.17}/unique_toolkit/tools/utils/source_handling/schema.py
RENAMED
|
File without changes
|
|
File without changes
|