haystack-experimental 0.14.0__py3-none-any.whl → 0.14.1__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/components/agents/agent.py +6 -7
- haystack_experimental/components/generators/chat/openai.py +8 -10
- haystack_experimental/core/pipeline/breakpoint.py +0 -55
- {haystack_experimental-0.14.0.dist-info → haystack_experimental-0.14.1.dist-info}/METADATA +3 -3
- {haystack_experimental-0.14.0.dist-info → haystack_experimental-0.14.1.dist-info}/RECORD +8 -8
- {haystack_experimental-0.14.0.dist-info → haystack_experimental-0.14.1.dist-info}/WHEEL +0 -0
- {haystack_experimental-0.14.0.dist-info → haystack_experimental-0.14.1.dist-info}/licenses/LICENSE +0 -0
- {haystack_experimental-0.14.0.dist-info → haystack_experimental-0.14.1.dist-info}/licenses/LICENSE-MIT.txt +0 -0
|
@@ -20,7 +20,6 @@ import haystack_experimental.core.pipeline.breakpoint as exp_breakpoint
|
|
|
20
20
|
|
|
21
21
|
hs_breakpoint._create_agent_snapshot = exp_breakpoint._create_agent_snapshot
|
|
22
22
|
hs_breakpoint._create_pipeline_snapshot_from_tool_invoker = exp_breakpoint._create_pipeline_snapshot_from_tool_invoker # type: ignore[assignment]
|
|
23
|
-
hs_breakpoint._trigger_tool_invoker_breakpoint = exp_breakpoint._trigger_tool_invoker_breakpoint
|
|
24
23
|
|
|
25
24
|
from haystack import logging
|
|
26
25
|
from haystack.components.agents.agent import Agent as HaystackAgent
|
|
@@ -39,7 +38,7 @@ from haystack.core.serialization import default_from_dict, import_class_by_name
|
|
|
39
38
|
from haystack.dataclasses import ChatMessage
|
|
40
39
|
from haystack.dataclasses.breakpoints import AgentBreakpoint, ToolBreakpoint
|
|
41
40
|
from haystack.dataclasses.streaming_chunk import StreamingCallbackT
|
|
42
|
-
from haystack.tools import
|
|
41
|
+
from haystack.tools import ToolsType, deserialize_tools_or_toolset_inplace
|
|
43
42
|
from haystack.utils.callable_serialization import deserialize_callable
|
|
44
43
|
from haystack.utils.deserialization import deserialize_chatgenerator_inplace
|
|
45
44
|
|
|
@@ -122,7 +121,7 @@ class Agent(HaystackAgent):
|
|
|
122
121
|
self,
|
|
123
122
|
*,
|
|
124
123
|
chat_generator: ChatGenerator,
|
|
125
|
-
tools: Optional[
|
|
124
|
+
tools: Optional[ToolsType] = None,
|
|
126
125
|
system_prompt: Optional[str] = None,
|
|
127
126
|
exit_conditions: Optional[list[str]] = None,
|
|
128
127
|
state_schema: Optional[dict[str, Any]] = None,
|
|
@@ -172,7 +171,7 @@ class Agent(HaystackAgent):
|
|
|
172
171
|
requires_async: bool,
|
|
173
172
|
*,
|
|
174
173
|
system_prompt: Optional[str] = None,
|
|
175
|
-
tools: Optional[Union[
|
|
174
|
+
tools: Optional[Union[ToolsType, list[str]]] = None,
|
|
176
175
|
**kwargs: dict[str, Any],
|
|
177
176
|
) -> _ExecutionContext:
|
|
178
177
|
"""
|
|
@@ -213,7 +212,7 @@ class Agent(HaystackAgent):
|
|
|
213
212
|
streaming_callback: Optional[StreamingCallbackT],
|
|
214
213
|
requires_async: bool,
|
|
215
214
|
*,
|
|
216
|
-
tools: Optional[Union[
|
|
215
|
+
tools: Optional[Union[ToolsType, list[str]]] = None,
|
|
217
216
|
) -> _ExecutionContext:
|
|
218
217
|
"""
|
|
219
218
|
Initialize execution context from an AgentSnapshot.
|
|
@@ -251,7 +250,7 @@ class Agent(HaystackAgent):
|
|
|
251
250
|
break_point: Optional[AgentBreakpoint] = None,
|
|
252
251
|
snapshot: Optional[AgentSnapshot] = None, # type: ignore[override]
|
|
253
252
|
system_prompt: Optional[str] = None,
|
|
254
|
-
tools: Optional[Union[
|
|
253
|
+
tools: Optional[Union[ToolsType, list[str]]] = None,
|
|
255
254
|
**kwargs: Any,
|
|
256
255
|
) -> dict[str, Any]:
|
|
257
256
|
"""
|
|
@@ -435,7 +434,7 @@ class Agent(HaystackAgent):
|
|
|
435
434
|
break_point: Optional[AgentBreakpoint] = None,
|
|
436
435
|
snapshot: Optional[AgentSnapshot] = None, # type: ignore[override]
|
|
437
436
|
system_prompt: Optional[str] = None,
|
|
438
|
-
tools: Optional[Union[
|
|
437
|
+
tools: Optional[Union[ToolsType, list[str]]] = None,
|
|
439
438
|
**kwargs: Any,
|
|
440
439
|
) -> dict[str, Any]:
|
|
441
440
|
"""
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
5
|
from dataclasses import replace
|
|
6
|
-
from typing import Any, Optional
|
|
6
|
+
from typing import Any, Optional
|
|
7
7
|
|
|
8
8
|
from haystack import component
|
|
9
9
|
from haystack.components.generators.chat.openai import OpenAIChatGenerator as BaseOpenAIChatGenerator
|
|
10
10
|
from haystack.dataclasses import ChatMessage, StreamingCallbackT
|
|
11
|
-
from haystack.tools import
|
|
11
|
+
from haystack.tools import ToolsType
|
|
12
12
|
|
|
13
13
|
from haystack_experimental.utils.hallucination_risk_calculator.dataclasses import HallucinationScoreConfig
|
|
14
14
|
from haystack_experimental.utils.hallucination_risk_calculator.openai_planner import calculate_hallucination_metrics
|
|
@@ -59,7 +59,7 @@ class OpenAIChatGenerator(BaseOpenAIChatGenerator):
|
|
|
59
59
|
streaming_callback: Optional[StreamingCallbackT] = None,
|
|
60
60
|
generation_kwargs: Optional[dict[str, Any]] = None,
|
|
61
61
|
*,
|
|
62
|
-
tools: Optional[
|
|
62
|
+
tools: Optional[ToolsType] = None,
|
|
63
63
|
tools_strict: Optional[bool] = None,
|
|
64
64
|
hallucination_score_config: Optional[HallucinationScoreConfig] = None,
|
|
65
65
|
) -> dict[str, list[ChatMessage]]:
|
|
@@ -75,9 +75,8 @@ class OpenAIChatGenerator(BaseOpenAIChatGenerator):
|
|
|
75
75
|
override the parameters passed during component initialization.
|
|
76
76
|
For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
|
|
77
77
|
:param tools:
|
|
78
|
-
A list of
|
|
79
|
-
`tools` parameter
|
|
80
|
-
`Tool` objects or a `Toolset` instance.
|
|
78
|
+
A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
|
|
79
|
+
If set, it will override the `tools` parameter provided during initialization.
|
|
81
80
|
:param tools_strict:
|
|
82
81
|
Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
|
|
83
82
|
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
|
|
@@ -127,7 +126,7 @@ class OpenAIChatGenerator(BaseOpenAIChatGenerator):
|
|
|
127
126
|
streaming_callback: Optional[StreamingCallbackT] = None,
|
|
128
127
|
generation_kwargs: Optional[dict[str, Any]] = None,
|
|
129
128
|
*,
|
|
130
|
-
tools: Optional[
|
|
129
|
+
tools: Optional[ToolsType] = None,
|
|
131
130
|
tools_strict: Optional[bool] = None,
|
|
132
131
|
hallucination_score_config: Optional[HallucinationScoreConfig] = None,
|
|
133
132
|
) -> dict[str, list[ChatMessage]]:
|
|
@@ -147,9 +146,8 @@ class OpenAIChatGenerator(BaseOpenAIChatGenerator):
|
|
|
147
146
|
override the parameters passed during component initialization.
|
|
148
147
|
For details on OpenAI API parameters, see [OpenAI documentation](https://platform.openai.com/docs/api-reference/chat/create).
|
|
149
148
|
:param tools:
|
|
150
|
-
A list of
|
|
151
|
-
`tools` parameter
|
|
152
|
-
`Tool` objects or a `Toolset` instance.
|
|
149
|
+
A list of Tool and/or Toolset objects, or a single Toolset for which the model can prepare calls.
|
|
150
|
+
If set, it will override the `tools` parameter provided during initialization.
|
|
153
151
|
:param tools_strict:
|
|
154
152
|
Whether to enable strict schema adherence for tool calls. If set to `True`, the model will follow exactly
|
|
155
153
|
the schema provided in the `parameters` field of the tool definition, but this may increase latency.
|
|
@@ -8,9 +8,6 @@ from datetime import datetime
|
|
|
8
8
|
from typing import TYPE_CHECKING, Any, Optional
|
|
9
9
|
|
|
10
10
|
from haystack import logging
|
|
11
|
-
from haystack.core.errors import BreakpointException
|
|
12
|
-
from haystack.core.pipeline.breakpoint import _save_pipeline_snapshot
|
|
13
|
-
from haystack.dataclasses import ChatMessage
|
|
14
11
|
from haystack.dataclasses.breakpoints import AgentBreakpoint, PipelineSnapshot, PipelineState, ToolBreakpoint
|
|
15
12
|
from haystack.utils.base_serialization import _serialize_value_with_schema
|
|
16
13
|
from haystack.utils.misc import _get_output_dir
|
|
@@ -120,55 +117,3 @@ def _create_pipeline_snapshot_from_tool_invoker(
|
|
|
120
117
|
final_snapshot = replace(parent_snapshot, agent_snapshot=agent_snapshot)
|
|
121
118
|
|
|
122
119
|
return final_snapshot
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
def _trigger_tool_invoker_breakpoint(*, llm_messages: list[ChatMessage], pipeline_snapshot: PipelineSnapshot) -> None:
|
|
126
|
-
"""
|
|
127
|
-
Check if a tool call breakpoint should be triggered before executing the tool invoker.
|
|
128
|
-
|
|
129
|
-
NOTE: Only difference to Haystack's native implementation is that it includes the fix from
|
|
130
|
-
PR https://github.com/deepset-ai/haystack/pull/9853 where we make sure to check all tool calls in a chat message
|
|
131
|
-
when checking if a BreakpointException should be made.
|
|
132
|
-
|
|
133
|
-
:param llm_messages: List of ChatMessage objects containing potential tool calls.
|
|
134
|
-
:param pipeline_snapshot: PipelineSnapshot object containing the state of the pipeline and Agent snapshot.
|
|
135
|
-
:raises BreakpointException: If the breakpoint is triggered, indicating a breakpoint has been reached for a tool
|
|
136
|
-
call.
|
|
137
|
-
"""
|
|
138
|
-
if not pipeline_snapshot.agent_snapshot:
|
|
139
|
-
raise ValueError("PipelineSnapshot must contain an AgentSnapshot to trigger a tool call breakpoint.")
|
|
140
|
-
|
|
141
|
-
if not isinstance(pipeline_snapshot.agent_snapshot.break_point.break_point, ToolBreakpoint):
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
tool_breakpoint = pipeline_snapshot.agent_snapshot.break_point.break_point
|
|
145
|
-
|
|
146
|
-
# Check if we should break for this specific tool or all tools
|
|
147
|
-
if tool_breakpoint.tool_name is None:
|
|
148
|
-
# Break for any tool call
|
|
149
|
-
should_break = any(msg.tool_call for msg in llm_messages)
|
|
150
|
-
else:
|
|
151
|
-
# Break only for the specific tool
|
|
152
|
-
should_break = any(
|
|
153
|
-
tc.tool_name == tool_breakpoint.tool_name for msg in llm_messages for tc in msg.tool_calls or []
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
if not should_break:
|
|
157
|
-
return # No breakpoint triggered
|
|
158
|
-
|
|
159
|
-
_save_pipeline_snapshot(pipeline_snapshot=pipeline_snapshot)
|
|
160
|
-
|
|
161
|
-
msg = (
|
|
162
|
-
f"Breaking at {tool_breakpoint.component_name} visit count "
|
|
163
|
-
f"{pipeline_snapshot.agent_snapshot.component_visits[tool_breakpoint.component_name]}"
|
|
164
|
-
)
|
|
165
|
-
if tool_breakpoint.tool_name:
|
|
166
|
-
msg += f" for tool {tool_breakpoint.tool_name}"
|
|
167
|
-
logger.info(msg)
|
|
168
|
-
|
|
169
|
-
raise BreakpointException(
|
|
170
|
-
message=msg,
|
|
171
|
-
component=tool_breakpoint.component_name,
|
|
172
|
-
inputs=pipeline_snapshot.agent_snapshot.component_inputs,
|
|
173
|
-
results=pipeline_snapshot.agent_snapshot.component_inputs["tool_invoker"]["serialized_data"]["state"],
|
|
174
|
-
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: haystack-experimental
|
|
3
|
-
Version: 0.14.
|
|
3
|
+
Version: 0.14.1
|
|
4
4
|
Summary: Experimental components and features for the Haystack LLM framework.
|
|
5
5
|
Project-URL: CI: GitHub, https://github.com/deepset-ai/haystack-experimental/actions
|
|
6
6
|
Project-URL: GitHub: issues, https://github.com/deepset-ai/haystack-experimental/issues
|
|
@@ -107,9 +107,9 @@ that includes it. Once it reaches the end of its lifespan, the experiment will b
|
|
|
107
107
|
[20]: https://github.com/deepset-ai/haystack-experimental/blob/main/haystack_experimental/components/agents/human_in_the_loop/strategies.py
|
|
108
108
|
[21]: https://github.com/deepset-ai/haystack-experimental/blob/main/haystack_experimental/components/agents/human_in_the_loop/dataclasses.py
|
|
109
109
|
[22]: https://github.com/deepset-ai/haystack-experimental/blob/main/haystack_experimental/components/agents/human_in_the_loop/errors.py
|
|
110
|
-
[23]: https://github.com/deepset-ai/haystack-experimental/discussions/
|
|
110
|
+
[23]: https://github.com/deepset-ai/haystack-experimental/discussions/381
|
|
111
111
|
[24]: https://github.com/deepset-ai/haystack-experimental/blob/main/haystack_experimental/components/sumarizers/llm_summarizer.py
|
|
112
|
-
[25]: https://github.com/deepset-ai/haystack-experimental/discussions/
|
|
112
|
+
[25]: https://github.com/deepset-ai/haystack-experimental/discussions/382
|
|
113
113
|
|
|
114
114
|
### Adopted experiments
|
|
115
115
|
| Name | Type | Final release |
|
|
@@ -4,7 +4,7 @@ haystack_experimental/chat_message_stores/in_memory.py,sha256=nc_B_70KOvtgsul4QJ
|
|
|
4
4
|
haystack_experimental/chat_message_stores/types.py,sha256=QzjA5-A08PlMAy7MMLNNUpob8S60Ypec74gSbz_l49E,2101
|
|
5
5
|
haystack_experimental/components/__init__.py,sha256=eHD7xrty2PCky_gG3ty19rpM4WfV32TyytM7gJODwl4,110
|
|
6
6
|
haystack_experimental/components/agents/__init__.py,sha256=Sxu9LxPpQ5cljgoTgUeNC0GY8CwUdiSy1JWkd_-RRJ4,414
|
|
7
|
-
haystack_experimental/components/agents/agent.py,sha256=
|
|
7
|
+
haystack_experimental/components/agents/agent.py,sha256=jJ5baKFgT4PNuf2vu2dlm5AyJ9O7stlK94_1zk2u2OA,31814
|
|
8
8
|
haystack_experimental/components/agents/human_in_the_loop/__init__.py,sha256=xLr1G9pNWMmCpKN9mbv6yqeFfwMcbZyaVfCkzlwMxhY,1674
|
|
9
9
|
haystack_experimental/components/agents/human_in_the_loop/breakpoint.py,sha256=GhNdGdFNDnwSiTukD4WVp6-1YgGjq5oqCEcGMC2dcog,2902
|
|
10
10
|
haystack_experimental/components/agents/human_in_the_loop/dataclasses.py,sha256=OakB0PXBSG0LbQixcuo-d7IC-A3_k6qi80pB8hwY23o,2563
|
|
@@ -18,7 +18,7 @@ haystack_experimental/components/embedders/types/__init__.py,sha256=HGR8aavwIEx7
|
|
|
18
18
|
haystack_experimental/components/embedders/types/protocol.py,sha256=EEVtggoYWZL6zF-vbasJollCxLbheMYIISAh7hJ8LkA,1038
|
|
19
19
|
haystack_experimental/components/generators/__init__.py,sha256=eHD7xrty2PCky_gG3ty19rpM4WfV32TyytM7gJODwl4,110
|
|
20
20
|
haystack_experimental/components/generators/chat/__init__.py,sha256=LEKI1mMtltVbSiU40QgBfnWC-z3_660TWuV-cVHhdTw,465
|
|
21
|
-
haystack_experimental/components/generators/chat/openai.py,sha256=
|
|
21
|
+
haystack_experimental/components/generators/chat/openai.py,sha256=gX6UI4yfY0pzKhWErquvPF_gV-3Ut0y6wSJytAD07Jk,9855
|
|
22
22
|
haystack_experimental/components/preprocessors/__init__.py,sha256=x3fM1lpGzYjWB3hpdbDWxXr_rYASb2e9yX0PgYG84rA,518
|
|
23
23
|
haystack_experimental/components/preprocessors/embedding_based_document_splitter.py,sha256=VyQ--gaMsWid-IRBVXi5YPJpwbFlaK-2mRFvRF8MSBQ,17616
|
|
24
24
|
haystack_experimental/components/preprocessors/md_header_level_inferrer.py,sha256=1Tn-H4Gvg2yYSUc54cPWKTCK78KXet5u32_1S8PM3NU,5643
|
|
@@ -36,7 +36,7 @@ haystack_experimental/components/writers/__init__.py,sha256=iMdeAaZozza8E6dQ4Lc2
|
|
|
36
36
|
haystack_experimental/components/writers/chat_message_writer.py,sha256=iu8gmvmRXlqd9S2-9B8p-7C0Y5GTuOI1AqcVKAkrzDc,3502
|
|
37
37
|
haystack_experimental/core/__init__.py,sha256=eHD7xrty2PCky_gG3ty19rpM4WfV32TyytM7gJODwl4,110
|
|
38
38
|
haystack_experimental/core/pipeline/__init__.py,sha256=eHD7xrty2PCky_gG3ty19rpM4WfV32TyytM7gJODwl4,110
|
|
39
|
-
haystack_experimental/core/pipeline/breakpoint.py,sha256=
|
|
39
|
+
haystack_experimental/core/pipeline/breakpoint.py,sha256=JtwQP8OF5Sdqo0abPRgs1K3SqBkUXhZ53PkeagcK2ZE,5134
|
|
40
40
|
haystack_experimental/dataclasses/__init__.py,sha256=eHD7xrty2PCky_gG3ty19rpM4WfV32TyytM7gJODwl4,110
|
|
41
41
|
haystack_experimental/dataclasses/breakpoints.py,sha256=f0kxYXJRHzk6jAW5Na51MZfUuRIlulhN4oTrGWTpSFE,2095
|
|
42
42
|
haystack_experimental/super_components/__init__.py,sha256=eHD7xrty2PCky_gG3ty19rpM4WfV32TyytM7gJODwl4,110
|
|
@@ -48,8 +48,8 @@ haystack_experimental/utils/hallucination_risk_calculator/core_math.py,sha256=8X
|
|
|
48
48
|
haystack_experimental/utils/hallucination_risk_calculator/dataclasses.py,sha256=3vk9jsbW-7C9n408Qe730qgdXxIOzsTigf4TMLpryvI,2318
|
|
49
49
|
haystack_experimental/utils/hallucination_risk_calculator/openai_planner.py,sha256=-yVQsGzM5rXsAVwolE6sp5W6q1yDw66SiIUuUbPk1ng,11413
|
|
50
50
|
haystack_experimental/utils/hallucination_risk_calculator/skeletonization.py,sha256=qNdBUoFiBjQsI3ovrhd4RyTFmIbv51Goai1Z_l9lG28,5488
|
|
51
|
-
haystack_experimental-0.14.
|
|
52
|
-
haystack_experimental-0.14.
|
|
53
|
-
haystack_experimental-0.14.
|
|
54
|
-
haystack_experimental-0.14.
|
|
55
|
-
haystack_experimental-0.14.
|
|
51
|
+
haystack_experimental-0.14.1.dist-info/METADATA,sha256=A1DesX7H05AtVp4S8PD99UIfyFy3cQB_y1a4Oho9Nmc,18566
|
|
52
|
+
haystack_experimental-0.14.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
53
|
+
haystack_experimental-0.14.1.dist-info/licenses/LICENSE,sha256=93_5nS97uHxptHvK9E8BZgKxLGeIS-rBWT2swIv-X5Y,11368
|
|
54
|
+
haystack_experimental-0.14.1.dist-info/licenses/LICENSE-MIT.txt,sha256=knmLkIKj_6tTrTSVRg9Tq88Kww4UCPLt2I1RGXJv9sQ,1037
|
|
55
|
+
haystack_experimental-0.14.1.dist-info/RECORD,,
|
|
File without changes
|
{haystack_experimental-0.14.0.dist-info → haystack_experimental-0.14.1.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|