haystack-experimental 0.15.2__py3-none-any.whl → 0.17.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.
- haystack_experimental/chat_message_stores/in_memory.py +3 -3
- haystack_experimental/chat_message_stores/types.py +2 -2
- haystack_experimental/components/agents/agent.py +264 -124
- haystack_experimental/components/agents/human_in_the_loop/dataclasses.py +6 -6
- haystack_experimental/components/agents/human_in_the_loop/errors.py +1 -5
- haystack_experimental/components/agents/human_in_the_loop/strategies.py +10 -10
- haystack_experimental/components/agents/human_in_the_loop/types.py +5 -5
- haystack_experimental/components/agents/human_in_the_loop/user_interfaces.py +2 -2
- haystack_experimental/components/generators/chat/openai.py +11 -11
- haystack_experimental/components/preprocessors/__init__.py +1 -3
- haystack_experimental/components/retrievers/chat_message_retriever.py +4 -4
- haystack_experimental/components/retrievers/types/protocol.py +3 -3
- haystack_experimental/components/summarizers/llm_summarizer.py +7 -7
- haystack_experimental/core/pipeline/breakpoint.py +6 -6
- haystack_experimental/dataclasses/breakpoints.py +2 -2
- haystack_experimental/memory_stores/__init__.py +7 -0
- haystack_experimental/memory_stores/mem0/__init__.py +16 -0
- haystack_experimental/memory_stores/mem0/memory_store.py +323 -0
- haystack_experimental/memory_stores/types/__init__.py +7 -0
- haystack_experimental/memory_stores/types/protocol.py +94 -0
- haystack_experimental/utils/hallucination_risk_calculator/dataclasses.py +9 -9
- haystack_experimental/utils/hallucination_risk_calculator/openai_planner.py +4 -4
- haystack_experimental/utils/hallucination_risk_calculator/skeletonization.py +5 -5
- {haystack_experimental-0.15.2.dist-info → haystack_experimental-0.17.0.dist-info}/METADATA +8 -11
- {haystack_experimental-0.15.2.dist-info → haystack_experimental-0.17.0.dist-info}/RECORD +28 -24
- haystack_experimental/components/preprocessors/embedding_based_document_splitter.py +0 -430
- {haystack_experimental-0.15.2.dist-info → haystack_experimental-0.17.0.dist-info}/WHEEL +0 -0
- {haystack_experimental-0.15.2.dist-info → haystack_experimental-0.17.0.dist-info}/licenses/LICENSE +0 -0
- {haystack_experimental-0.15.2.dist-info → haystack_experimental-0.17.0.dist-info}/licenses/LICENSE-MIT.txt +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
5
|
from dataclasses import asdict, dataclass
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
@dataclass
|
|
@@ -23,8 +23,8 @@ class ConfirmationUIResult:
|
|
|
23
23
|
"""
|
|
24
24
|
|
|
25
25
|
action: str # "confirm", "reject", "modify"
|
|
26
|
-
feedback:
|
|
27
|
-
new_tool_params:
|
|
26
|
+
feedback: str | None = None
|
|
27
|
+
new_tool_params: dict[str, Any] | None = None
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
@dataclass
|
|
@@ -49,9 +49,9 @@ class ToolExecutionDecision:
|
|
|
49
49
|
|
|
50
50
|
tool_name: str
|
|
51
51
|
execute: bool
|
|
52
|
-
tool_call_id:
|
|
53
|
-
feedback:
|
|
54
|
-
final_tool_params:
|
|
52
|
+
tool_call_id: str | None = None
|
|
53
|
+
feedback: str | None = None
|
|
54
|
+
final_tool_params: dict[str, Any] | None = None
|
|
55
55
|
|
|
56
56
|
def to_dict(self) -> dict[str, Any]:
|
|
57
57
|
"""
|
|
@@ -2,17 +2,13 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
from typing import Optional
|
|
6
|
-
|
|
7
5
|
|
|
8
6
|
class HITLBreakpointException(Exception):
|
|
9
7
|
"""
|
|
10
8
|
Exception raised when a tool execution is paused by a ConfirmationStrategy (e.g. BreakpointConfirmationStrategy).
|
|
11
9
|
"""
|
|
12
10
|
|
|
13
|
-
def __init__(
|
|
14
|
-
self, message: str, tool_name: str, snapshot_file_path: str, tool_call_id: Optional[str] = None
|
|
15
|
-
) -> None:
|
|
11
|
+
def __init__(self, message: str, tool_name: str, snapshot_file_path: str, tool_call_id: str | None = None) -> None:
|
|
16
12
|
"""
|
|
17
13
|
Initialize the HITLBreakpointException.
|
|
18
14
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
5
|
from dataclasses import replace
|
|
6
|
-
from typing import TYPE_CHECKING, Any
|
|
6
|
+
from typing import TYPE_CHECKING, Any
|
|
7
7
|
|
|
8
8
|
from haystack.components.agents.state import State
|
|
9
9
|
from haystack.components.tools.tool_invoker import ToolInvoker
|
|
@@ -52,8 +52,8 @@ class BlockingConfirmationStrategy:
|
|
|
52
52
|
tool_name: str,
|
|
53
53
|
tool_description: str,
|
|
54
54
|
tool_params: dict[str, Any],
|
|
55
|
-
tool_call_id:
|
|
56
|
-
confirmation_strategy_context:
|
|
55
|
+
tool_call_id: str | None = None,
|
|
56
|
+
confirmation_strategy_context: dict[str, Any] | None = None,
|
|
57
57
|
) -> ToolExecutionDecision:
|
|
58
58
|
"""
|
|
59
59
|
Run the human-in-the-loop strategy for a given tool and its parameters.
|
|
@@ -125,8 +125,8 @@ class BlockingConfirmationStrategy:
|
|
|
125
125
|
tool_name: str,
|
|
126
126
|
tool_description: str,
|
|
127
127
|
tool_params: dict[str, Any],
|
|
128
|
-
tool_call_id:
|
|
129
|
-
confirmation_strategy_context:
|
|
128
|
+
tool_call_id: str | None = None,
|
|
129
|
+
confirmation_strategy_context: dict[str, Any] | None = None,
|
|
130
130
|
) -> ToolExecutionDecision:
|
|
131
131
|
"""
|
|
132
132
|
Async version of run. Calls the sync run() method by default.
|
|
@@ -210,8 +210,8 @@ class BreakpointConfirmationStrategy:
|
|
|
210
210
|
tool_name: str,
|
|
211
211
|
tool_description: str,
|
|
212
212
|
tool_params: dict[str, Any],
|
|
213
|
-
tool_call_id:
|
|
214
|
-
confirmation_strategy_context:
|
|
213
|
+
tool_call_id: str | None = None,
|
|
214
|
+
confirmation_strategy_context: dict[str, Any] | None = None,
|
|
215
215
|
) -> ToolExecutionDecision:
|
|
216
216
|
"""
|
|
217
217
|
Run the breakpoint confirmation strategy for a given tool and its parameters.
|
|
@@ -248,8 +248,8 @@ class BreakpointConfirmationStrategy:
|
|
|
248
248
|
tool_name: str,
|
|
249
249
|
tool_description: str,
|
|
250
250
|
tool_params: dict[str, Any],
|
|
251
|
-
tool_call_id:
|
|
252
|
-
confirmation_strategy_context:
|
|
251
|
+
tool_call_id: str | None = None,
|
|
252
|
+
confirmation_strategy_context: dict[str, Any] | None = None,
|
|
253
253
|
) -> ToolExecutionDecision:
|
|
254
254
|
"""
|
|
255
255
|
Async version of run. Calls the sync run() method.
|
|
@@ -304,7 +304,7 @@ def _prepare_tool_args(
|
|
|
304
304
|
tool: Tool,
|
|
305
305
|
tool_call_arguments: dict[str, Any],
|
|
306
306
|
state: State,
|
|
307
|
-
streaming_callback:
|
|
307
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
308
308
|
enable_streaming_passthrough: bool = False,
|
|
309
309
|
) -> dict[str, Any]:
|
|
310
310
|
"""
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
from typing import Any,
|
|
5
|
+
from typing import Any, Protocol
|
|
6
6
|
|
|
7
7
|
from haystack.core.serialization import default_from_dict, default_to_dict
|
|
8
8
|
|
|
@@ -67,8 +67,8 @@ class ConfirmationStrategy(Protocol):
|
|
|
67
67
|
tool_name: str,
|
|
68
68
|
tool_description: str,
|
|
69
69
|
tool_params: dict[str, Any],
|
|
70
|
-
tool_call_id:
|
|
71
|
-
**kwargs:
|
|
70
|
+
tool_call_id: str | None = None,
|
|
71
|
+
**kwargs: dict[str, Any] | None,
|
|
72
72
|
) -> ToolExecutionDecision:
|
|
73
73
|
"""
|
|
74
74
|
Run the confirmation strategy for a given tool and its parameters.
|
|
@@ -92,8 +92,8 @@ class ConfirmationStrategy(Protocol):
|
|
|
92
92
|
tool_name: str,
|
|
93
93
|
tool_description: str,
|
|
94
94
|
tool_params: dict[str, Any],
|
|
95
|
-
tool_call_id:
|
|
96
|
-
**kwargs:
|
|
95
|
+
tool_call_id: str | None = None,
|
|
96
|
+
**kwargs: dict[str, Any] | None,
|
|
97
97
|
) -> ToolExecutionDecision:
|
|
98
98
|
"""
|
|
99
99
|
Async version of run. Run the confirmation strategy for a given tool and its parameters.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import json
|
|
6
6
|
from threading import Lock
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
from haystack.core.serialization import default_to_dict
|
|
10
10
|
from rich.console import Console
|
|
@@ -20,7 +20,7 @@ _ui_lock = Lock()
|
|
|
20
20
|
class RichConsoleUI(ConfirmationUI):
|
|
21
21
|
"""Rich console interface for user interaction."""
|
|
22
22
|
|
|
23
|
-
def __init__(self, console:
|
|
23
|
+
def __init__(self, console: Console | None = None):
|
|
24
24
|
self.console = console or Console()
|
|
25
25
|
|
|
26
26
|
def get_user_confirmation(
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
5
|
from dataclasses import replace
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any
|
|
7
7
|
|
|
8
8
|
from haystack import component
|
|
9
9
|
from haystack.components.generators.chat.openai import OpenAIChatGenerator as BaseOpenAIChatGenerator
|
|
@@ -56,12 +56,12 @@ class OpenAIChatGenerator(BaseOpenAIChatGenerator):
|
|
|
56
56
|
def run(
|
|
57
57
|
self,
|
|
58
58
|
messages: list[ChatMessage],
|
|
59
|
-
streaming_callback:
|
|
60
|
-
generation_kwargs:
|
|
59
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
60
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
61
61
|
*,
|
|
62
|
-
tools:
|
|
63
|
-
tools_strict:
|
|
64
|
-
hallucination_score_config:
|
|
62
|
+
tools: ToolsType | None = None,
|
|
63
|
+
tools_strict: bool | None = None,
|
|
64
|
+
hallucination_score_config: HallucinationScoreConfig | None = None,
|
|
65
65
|
) -> dict[str, list[ChatMessage]]:
|
|
66
66
|
"""
|
|
67
67
|
Invokes chat completion based on the provided messages and generation parameters.
|
|
@@ -123,12 +123,12 @@ class OpenAIChatGenerator(BaseOpenAIChatGenerator):
|
|
|
123
123
|
async def run_async(
|
|
124
124
|
self,
|
|
125
125
|
messages: list[ChatMessage],
|
|
126
|
-
streaming_callback:
|
|
127
|
-
generation_kwargs:
|
|
126
|
+
streaming_callback: StreamingCallbackT | None = None,
|
|
127
|
+
generation_kwargs: dict[str, Any] | None = None,
|
|
128
128
|
*,
|
|
129
|
-
tools:
|
|
130
|
-
tools_strict:
|
|
131
|
-
hallucination_score_config:
|
|
129
|
+
tools: ToolsType | None = None,
|
|
130
|
+
tools_strict: bool | None = None,
|
|
131
|
+
hallucination_score_config: HallucinationScoreConfig | None = None,
|
|
132
132
|
) -> dict[str, list[ChatMessage]]:
|
|
133
133
|
"""
|
|
134
134
|
Asynchronously invokes chat completion based on the provided messages and generation parameters.
|
|
@@ -8,13 +8,11 @@ from typing import TYPE_CHECKING
|
|
|
8
8
|
from lazy_imports import LazyImporter
|
|
9
9
|
|
|
10
10
|
_import_structure = {
|
|
11
|
-
"embedding_based_document_splitter": ["EmbeddingBasedDocumentSplitter"],
|
|
12
11
|
"md_header_level_inferrer": ["MarkdownHeaderLevelInferrer"],
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
if TYPE_CHECKING:
|
|
16
|
-
from .
|
|
17
|
-
from .md_header_level_inferrer import MarkdownHeaderLevelInferrer
|
|
15
|
+
from .md_header_level_inferrer import MarkdownHeaderLevelInferrer as MarkdownHeaderLevelInferrer
|
|
18
16
|
|
|
19
17
|
else:
|
|
20
18
|
sys.modules[__name__] = LazyImporter(name=__name__, module_file=__file__, import_structure=_import_structure)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
from haystack import DeserializationError, component, default_from_dict, default_to_dict, logging
|
|
8
8
|
from haystack.core.serialization import import_class_by_name
|
|
@@ -39,7 +39,7 @@ class ChatMessageRetriever:
|
|
|
39
39
|
```
|
|
40
40
|
"""
|
|
41
41
|
|
|
42
|
-
def __init__(self, chat_message_store: ChatMessageStore, last_k:
|
|
42
|
+
def __init__(self, chat_message_store: ChatMessageStore, last_k: int | None = 10):
|
|
43
43
|
"""
|
|
44
44
|
Create the ChatMessageRetriever component.
|
|
45
45
|
|
|
@@ -94,8 +94,8 @@ class ChatMessageRetriever:
|
|
|
94
94
|
self,
|
|
95
95
|
chat_history_id: str,
|
|
96
96
|
*,
|
|
97
|
-
last_k:
|
|
98
|
-
current_messages:
|
|
97
|
+
last_k: int | None = None,
|
|
98
|
+
current_messages: list[ChatMessage] | None = None,
|
|
99
99
|
) -> dict[str, list[ChatMessage]]:
|
|
100
100
|
"""
|
|
101
101
|
Run the ChatMessageRetriever
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
from typing import Any,
|
|
5
|
+
from typing import Any, Protocol
|
|
6
6
|
|
|
7
7
|
# Ellipsis are needed to define the Protocol but pylint complains. See https://github.com/pylint-dev/pylint/issues/9319.
|
|
8
8
|
# pylint: disable=unnecessary-ellipsis
|
|
@@ -16,7 +16,7 @@ class TextRetriever(Protocol):
|
|
|
16
16
|
store or other data source. They return a dictionary with a list of Document objects.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
|
-
def run(self, query: str, filters:
|
|
19
|
+
def run(self, query: str, filters: dict[str, Any] | None = None, top_k: int | None = None) -> dict[str, Any]:
|
|
20
20
|
"""
|
|
21
21
|
Retrieve documents that are relevant to the query.
|
|
22
22
|
|
|
@@ -42,7 +42,7 @@ class EmbeddingRetriever(Protocol):
|
|
|
42
42
|
"""
|
|
43
43
|
|
|
44
44
|
def run(
|
|
45
|
-
self, query_embedding: list[float], filters:
|
|
45
|
+
self, query_embedding: list[float], filters: dict[str, Any] | None = None, top_k: int | None = None
|
|
46
46
|
) -> dict[str, Any]:
|
|
47
47
|
"""
|
|
48
48
|
Retrieve documents that are relevant to the query.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
|
|
7
7
|
from haystack import Document, component, default_from_dict, default_to_dict, logging
|
|
8
8
|
from haystack.components.generators.chat.types import ChatGenerator
|
|
@@ -49,9 +49,9 @@ class LLMSummarizer:
|
|
|
49
49
|
def __init__( # pylint: disable=too-many-positional-arguments
|
|
50
50
|
self,
|
|
51
51
|
chat_generator: ChatGenerator,
|
|
52
|
-
system_prompt:
|
|
52
|
+
system_prompt: str | None = "Rewrite this text in summarized form.",
|
|
53
53
|
summary_detail: float = 0,
|
|
54
|
-
minimum_chunk_size:
|
|
54
|
+
minimum_chunk_size: int | None = 500,
|
|
55
55
|
chunk_delimiter: str = ".",
|
|
56
56
|
summarize_recursively: bool = False,
|
|
57
57
|
split_overlap: int = 0,
|
|
@@ -274,10 +274,10 @@ class LLMSummarizer:
|
|
|
274
274
|
self,
|
|
275
275
|
*,
|
|
276
276
|
documents: list[Document],
|
|
277
|
-
detail:
|
|
278
|
-
minimum_chunk_size:
|
|
279
|
-
summarize_recursively:
|
|
280
|
-
system_prompt:
|
|
277
|
+
detail: float | None = None,
|
|
278
|
+
minimum_chunk_size: int | None = None,
|
|
279
|
+
summarize_recursively: bool | None = None,
|
|
280
|
+
system_prompt: str | None = None,
|
|
281
281
|
) -> dict[str, list[Document]]:
|
|
282
282
|
"""
|
|
283
283
|
Run the summarizer on a list of documents.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
from dataclasses import replace
|
|
6
6
|
from datetime import datetime
|
|
7
|
-
from typing import TYPE_CHECKING, Any
|
|
7
|
+
from typing import TYPE_CHECKING, Any
|
|
8
8
|
|
|
9
9
|
from haystack import logging
|
|
10
10
|
from haystack.core.pipeline.utils import _deepcopy_with_exceptions
|
|
@@ -27,7 +27,7 @@ def _create_agent_snapshot(
|
|
|
27
27
|
component_visits: dict[str, int],
|
|
28
28
|
agent_breakpoint: AgentBreakpoint,
|
|
29
29
|
component_inputs: dict[str, Any],
|
|
30
|
-
tool_execution_decisions:
|
|
30
|
+
tool_execution_decisions: list["ToolExecutionDecision"] | None = None,
|
|
31
31
|
) -> AgentSnapshot:
|
|
32
32
|
"""
|
|
33
33
|
Create a snapshot of the agent's state.
|
|
@@ -59,10 +59,10 @@ def _create_agent_snapshot(
|
|
|
59
59
|
def _create_pipeline_snapshot_from_tool_invoker(
|
|
60
60
|
*,
|
|
61
61
|
execution_context: "_ExecutionContext",
|
|
62
|
-
tool_name:
|
|
63
|
-
agent_name:
|
|
64
|
-
break_point:
|
|
65
|
-
parent_snapshot:
|
|
62
|
+
tool_name: str | None = None,
|
|
63
|
+
agent_name: str | None = None,
|
|
64
|
+
break_point: AgentBreakpoint | None = None,
|
|
65
|
+
parent_snapshot: PipelineSnapshot | None = None,
|
|
66
66
|
) -> PipelineSnapshot:
|
|
67
67
|
"""
|
|
68
68
|
Create a pipeline snapshot when a tool invoker breakpoint is raised or an exception during execution occurs.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
from dataclasses import dataclass
|
|
6
6
|
from datetime import datetime
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
from haystack.dataclasses.breakpoints import AgentBreakpoint
|
|
10
10
|
from haystack.dataclasses.breakpoints import AgentSnapshot as HaystackAgentSnapshot
|
|
@@ -14,7 +14,7 @@ from haystack_experimental.components.agents.human_in_the_loop.dataclasses impor
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class AgentSnapshot(HaystackAgentSnapshot):
|
|
17
|
-
tool_execution_decisions:
|
|
17
|
+
tool_execution_decisions: list[ToolExecutionDecision] | None = None
|
|
18
18
|
|
|
19
19
|
def to_dict(self) -> dict[str, Any]:
|
|
20
20
|
"""
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
|
+
|
|
8
|
+
from lazy_imports import LazyImporter
|
|
9
|
+
|
|
10
|
+
_import_structure = {"memory_store": ["Mem0MemoryStore"]}
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from .memory_store import Mem0MemoryStore as Mem0MemoryStore
|
|
14
|
+
|
|
15
|
+
else:
|
|
16
|
+
sys.modules[__name__] = LazyImporter(name=__name__, module_file=__file__, import_structure=_import_structure)
|