deepset-mcp 0.0.6__py3-none-any.whl → 0.0.7__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.
- deepset_mcp/__init__.py +3 -4
- deepset_mcp/api/__init__.py +3 -0
- deepset_mcp/api/client.py +126 -107
- deepset_mcp/api/custom_components/__init__.py +3 -0
- deepset_mcp/api/custom_components/models.py +7 -8
- deepset_mcp/api/custom_components/protocols.py +4 -3
- deepset_mcp/api/custom_components/resource.py +39 -13
- deepset_mcp/api/haystack_service/__init__.py +3 -0
- deepset_mcp/api/haystack_service/protocols.py +21 -0
- deepset_mcp/api/haystack_service/resource.py +46 -0
- deepset_mcp/api/indexes/__init__.py +3 -0
- deepset_mcp/api/indexes/models.py +23 -11
- deepset_mcp/api/indexes/protocols.py +13 -4
- deepset_mcp/api/indexes/resource.py +86 -22
- deepset_mcp/api/integrations/__init__.py +4 -0
- deepset_mcp/api/integrations/models.py +4 -13
- deepset_mcp/api/integrations/protocols.py +3 -3
- deepset_mcp/api/integrations/resource.py +5 -5
- deepset_mcp/api/pipeline/__init__.py +1 -15
- deepset_mcp/api/pipeline/models.py +66 -28
- deepset_mcp/api/pipeline/protocols.py +6 -10
- deepset_mcp/api/pipeline/resource.py +101 -58
- deepset_mcp/api/pipeline_template/__init__.py +3 -0
- deepset_mcp/api/pipeline_template/models.py +12 -23
- deepset_mcp/api/pipeline_template/protocols.py +11 -5
- deepset_mcp/api/pipeline_template/resource.py +51 -39
- deepset_mcp/api/protocols.py +13 -11
- deepset_mcp/api/secrets/__init__.py +3 -0
- deepset_mcp/api/secrets/models.py +2 -8
- deepset_mcp/api/secrets/protocols.py +4 -3
- deepset_mcp/api/secrets/resource.py +32 -7
- deepset_mcp/api/shared_models.py +111 -1
- deepset_mcp/api/transport.py +30 -58
- deepset_mcp/api/user/__init__.py +3 -0
- deepset_mcp/api/workspace/__init__.py +1 -3
- deepset_mcp/api/workspace/models.py +4 -8
- deepset_mcp/api/workspace/protocols.py +3 -3
- deepset_mcp/api/workspace/resource.py +5 -9
- deepset_mcp/main.py +5 -20
- deepset_mcp/mcp/__init__.py +10 -0
- deepset_mcp/{server.py → mcp/server.py} +8 -18
- deepset_mcp/{store.py → mcp/store.py} +3 -3
- deepset_mcp/{tool_factory.py → mcp/tool_factory.py} +20 -37
- deepset_mcp/mcp/tool_models.py +57 -0
- deepset_mcp/{tool_registry.py → mcp/tool_registry.py} +16 -6
- deepset_mcp/{tools/tokonomics → tokonomics}/__init__.py +3 -1
- deepset_mcp/{tools/tokonomics → tokonomics}/decorators.py +2 -2
- deepset_mcp/{tools/tokonomics → tokonomics}/explorer.py +1 -1
- deepset_mcp/tools/__init__.py +58 -0
- deepset_mcp/tools/custom_components.py +7 -4
- deepset_mcp/tools/haystack_service.py +64 -22
- deepset_mcp/tools/haystack_service_models.py +40 -0
- deepset_mcp/tools/indexes.py +131 -32
- deepset_mcp/tools/object_store.py +1 -1
- deepset_mcp/tools/pipeline.py +40 -10
- deepset_mcp/tools/pipeline_template.py +35 -18
- deepset_mcp/tools/secrets.py +29 -13
- deepset_mcp/tools/workspace.py +2 -2
- deepset_mcp-0.0.7.dist-info/METADATA +100 -0
- deepset_mcp-0.0.7.dist-info/RECORD +74 -0
- deepset_mcp/api/README.md +0 -536
- deepset_mcp/api/pipeline/log_level.py +0 -13
- deepset_mcp/tool_models.py +0 -42
- deepset_mcp-0.0.6.dist-info/METADATA +0 -807
- deepset_mcp-0.0.6.dist-info/RECORD +0 -75
- /deepset_mcp/{tools/tokonomics → tokonomics}/object_store.py +0 -0
- {deepset_mcp-0.0.6.dist-info → deepset_mcp-0.0.7.dist-info}/WHEEL +0 -0
- {deepset_mcp-0.0.6.dist-info → deepset_mcp-0.0.7.dist-info}/entry_points.txt +0 -0
- {deepset_mcp-0.0.6.dist-info → deepset_mcp-0.0.7.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2025-present deepset GmbH <info@deepset.ai>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from enum import StrEnum
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MemoryType(StrEnum):
|
|
11
|
+
"""Configuration for how memory is provided to tools."""
|
|
12
|
+
|
|
13
|
+
EXPLORABLE = "explorable"
|
|
14
|
+
"""The tool's output is stored in the object store and nested properties can be explored through using the object
|
|
15
|
+
store tools.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
REFERENCEABLE = "referenceable"
|
|
19
|
+
"""The tool can be called by referencing an object or object-property that was stored in the object store."""
|
|
20
|
+
|
|
21
|
+
EXPLORABLE_AND_REFERENCEABLE = "explorable_and_referenceable"
|
|
22
|
+
"""The tool's output is stored in the object store and it can be called by reference."""
|
|
23
|
+
|
|
24
|
+
NO_MEMORY = "no_memory"
|
|
25
|
+
"""The tool returns all outputs as is. It does not interact with the object store."""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass
|
|
29
|
+
class ToolConfig:
|
|
30
|
+
"""Configuration for tool registration.
|
|
31
|
+
|
|
32
|
+
It allows users to define what arguments should be passed to the tool at registration time. These arguments will not
|
|
33
|
+
be provided by the LLM as the tool will receive them programmatically through partial application.
|
|
34
|
+
|
|
35
|
+
The configuration also determines if a tool should store outputs in the object store.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
needs_client: bool = False
|
|
39
|
+
"""If the tool should receive a configured instance of the 'AsyncDeepsetClient' at tool-registration time."""
|
|
40
|
+
|
|
41
|
+
needs_workspace: bool = False
|
|
42
|
+
"""If the tool should receive a static deepset workspace at tool-registration time."""
|
|
43
|
+
|
|
44
|
+
memory_type: MemoryType = MemoryType.NO_MEMORY
|
|
45
|
+
"""The type of memory this tool should use."""
|
|
46
|
+
|
|
47
|
+
custom_args: dict[str, Any] = field(default_factory=dict)
|
|
48
|
+
"""Any other arguments that should be passed to the tool at registration time instead of being passed by the LLM."""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass
|
|
52
|
+
class DeepsetDocsConfig:
|
|
53
|
+
"""Configuration for deepset documentation search tool."""
|
|
54
|
+
|
|
55
|
+
pipeline_name: str
|
|
56
|
+
api_key: str
|
|
57
|
+
workspace_name: str
|
|
@@ -8,7 +8,7 @@ from typing import Any
|
|
|
8
8
|
from deepset_mcp.api.client import AsyncDeepsetClient
|
|
9
9
|
from deepset_mcp.config import DEFAULT_CLIENT_HEADER, DOCS_SEARCH_TOOL_NAME
|
|
10
10
|
from deepset_mcp.initialize_embedding_model import get_initialized_model
|
|
11
|
-
from deepset_mcp.tool_models import DeepsetDocsConfig, MemoryType, ToolConfig
|
|
11
|
+
from deepset_mcp.mcp.tool_models import DeepsetDocsConfig, MemoryType, ToolConfig
|
|
12
12
|
from deepset_mcp.tools.custom_components import (
|
|
13
13
|
get_latest_custom_component_installation_logs as get_latest_custom_component_installation_logs_tool,
|
|
14
14
|
list_custom_component_installations as list_custom_component_installations_tool,
|
|
@@ -18,6 +18,7 @@ from deepset_mcp.tools.haystack_service import (
|
|
|
18
18
|
get_component_definition as get_component_definition_tool,
|
|
19
19
|
get_custom_components as get_custom_components_tool,
|
|
20
20
|
list_component_families as list_component_families_tool,
|
|
21
|
+
run_component as run_component_tool,
|
|
21
22
|
search_component_definition as search_component_definition_tool,
|
|
22
23
|
)
|
|
23
24
|
from deepset_mcp.tools.indexes import (
|
|
@@ -26,6 +27,7 @@ from deepset_mcp.tools.indexes import (
|
|
|
26
27
|
get_index as get_index_tool,
|
|
27
28
|
list_indexes as list_indexes_tool,
|
|
28
29
|
update_index as update_index_tool,
|
|
30
|
+
validate_index as validate_index_tool,
|
|
29
31
|
)
|
|
30
32
|
from deepset_mcp.tools.object_store import create_get_from_object_store, create_get_slice_from_object_store
|
|
31
33
|
from deepset_mcp.tools.pipeline import (
|
|
@@ -88,7 +90,7 @@ TOOL_REGISTRY: dict[str, tuple[Callable[..., Any], ToolConfig]] = {
|
|
|
88
90
|
ToolConfig(
|
|
89
91
|
needs_client=True,
|
|
90
92
|
needs_workspace=True,
|
|
91
|
-
memory_type=MemoryType.
|
|
93
|
+
memory_type=MemoryType.EXPLORABLE_AND_REFERENCEABLE,
|
|
92
94
|
custom_args={"skip_validation_errors": True},
|
|
93
95
|
),
|
|
94
96
|
),
|
|
@@ -97,7 +99,7 @@ TOOL_REGISTRY: dict[str, tuple[Callable[..., Any], ToolConfig]] = {
|
|
|
97
99
|
ToolConfig(
|
|
98
100
|
needs_client=True,
|
|
99
101
|
needs_workspace=True,
|
|
100
|
-
memory_type=MemoryType.
|
|
102
|
+
memory_type=MemoryType.EXPLORABLE_AND_REFERENCEABLE,
|
|
101
103
|
custom_args={"skip_validation_errors": True},
|
|
102
104
|
),
|
|
103
105
|
),
|
|
@@ -116,7 +118,7 @@ TOOL_REGISTRY: dict[str, tuple[Callable[..., Any], ToolConfig]] = {
|
|
|
116
118
|
),
|
|
117
119
|
"validate_pipeline": (
|
|
118
120
|
validate_pipeline_tool,
|
|
119
|
-
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.
|
|
121
|
+
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.EXPLORABLE_AND_REFERENCEABLE),
|
|
120
122
|
),
|
|
121
123
|
"get_pipeline_logs": (
|
|
122
124
|
get_pipeline_logs_tool,
|
|
@@ -136,16 +138,20 @@ TOOL_REGISTRY: dict[str, tuple[Callable[..., Any], ToolConfig]] = {
|
|
|
136
138
|
),
|
|
137
139
|
"create_index": (
|
|
138
140
|
create_index_tool,
|
|
139
|
-
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.
|
|
141
|
+
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.EXPLORABLE_AND_REFERENCEABLE),
|
|
140
142
|
),
|
|
141
143
|
"update_index": (
|
|
142
144
|
update_index_tool,
|
|
143
|
-
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.
|
|
145
|
+
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.EXPLORABLE_AND_REFERENCEABLE),
|
|
144
146
|
),
|
|
145
147
|
"deploy_index": (
|
|
146
148
|
deploy_index_tool,
|
|
147
149
|
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.EXPLORABLE),
|
|
148
150
|
),
|
|
151
|
+
"validate_index": (
|
|
152
|
+
validate_index_tool,
|
|
153
|
+
ToolConfig(needs_client=True, needs_workspace=True, memory_type=MemoryType.EXPLORABLE_AND_REFERENCEABLE),
|
|
154
|
+
),
|
|
149
155
|
"list_templates": (
|
|
150
156
|
list_pipeline_templates_tool,
|
|
151
157
|
ToolConfig(
|
|
@@ -195,6 +201,10 @@ TOOL_REGISTRY: dict[str, tuple[Callable[..., Any], ToolConfig]] = {
|
|
|
195
201
|
get_custom_components_tool,
|
|
196
202
|
ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE),
|
|
197
203
|
),
|
|
204
|
+
"run_component": (
|
|
205
|
+
run_component_tool,
|
|
206
|
+
ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE_AND_REFERENCEABLE),
|
|
207
|
+
),
|
|
198
208
|
"list_secrets": (list_secrets_tool, ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE)),
|
|
199
209
|
"get_secret": (get_secret_tool, ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE)),
|
|
200
210
|
"list_workspaces": (list_workspaces_tool, ToolConfig(needs_client=True, memory_type=MemoryType.EXPLORABLE)),
|
|
@@ -4,12 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
from .decorators import explorable, explorable_and_referenceable, referenceable
|
|
6
6
|
from .explorer import RichExplorer
|
|
7
|
-
from .object_store import InMemoryBackend, ObjectStore
|
|
7
|
+
from .object_store import InMemoryBackend, ObjectStore, ObjectStoreBackend, RedisBackend
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
10
|
# Core classes
|
|
11
11
|
"InMemoryBackend",
|
|
12
|
+
"RedisBackend",
|
|
12
13
|
"ObjectStore",
|
|
14
|
+
"ObjectStoreBackend",
|
|
13
15
|
"RichExplorer",
|
|
14
16
|
# Decorators
|
|
15
17
|
"explorable",
|
|
@@ -19,8 +19,8 @@ from typing import Any, TypeVar, Union, get_args, get_origin
|
|
|
19
19
|
|
|
20
20
|
from glom import GlomError, glom
|
|
21
21
|
|
|
22
|
-
from deepset_mcp.
|
|
23
|
-
from deepset_mcp.
|
|
22
|
+
from deepset_mcp.tokonomics.explorer import RichExplorer
|
|
23
|
+
from deepset_mcp.tokonomics.object_store import ObjectStore
|
|
24
24
|
|
|
25
25
|
F = TypeVar("F", bound=Callable[..., Any])
|
|
26
26
|
|
|
@@ -18,7 +18,7 @@ from glom import GlomError, Path, T, glom
|
|
|
18
18
|
from rich.console import Console
|
|
19
19
|
from rich.pretty import Pretty
|
|
20
20
|
|
|
21
|
-
from deepset_mcp.
|
|
21
|
+
from deepset_mcp.tokonomics.object_store import ObjectStore
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
class RichExplorer:
|
deepset_mcp/tools/__init__.py
CHANGED
|
@@ -2,3 +2,61 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
+
from .custom_components import get_latest_custom_component_installation_logs, list_custom_component_installations
|
|
6
|
+
from .doc_search import search_docs
|
|
7
|
+
from .haystack_service import (
|
|
8
|
+
get_component_definition,
|
|
9
|
+
get_custom_components,
|
|
10
|
+
list_component_families,
|
|
11
|
+
run_component,
|
|
12
|
+
search_component_definition,
|
|
13
|
+
)
|
|
14
|
+
from .indexes import create_index, deploy_index, get_index, list_indexes, update_index, validate_index
|
|
15
|
+
from .object_store import create_get_from_object_store, create_get_slice_from_object_store
|
|
16
|
+
from .pipeline import (
|
|
17
|
+
create_pipeline,
|
|
18
|
+
deploy_pipeline,
|
|
19
|
+
get_pipeline,
|
|
20
|
+
get_pipeline_logs,
|
|
21
|
+
list_pipelines,
|
|
22
|
+
search_pipeline,
|
|
23
|
+
update_pipeline,
|
|
24
|
+
validate_pipeline,
|
|
25
|
+
)
|
|
26
|
+
from .pipeline_template import get_template, list_templates, search_templates
|
|
27
|
+
from .secrets import get_secret, list_secrets
|
|
28
|
+
from .workspace import get_workspace, list_workspaces
|
|
29
|
+
|
|
30
|
+
__all__ = [
|
|
31
|
+
"list_custom_component_installations",
|
|
32
|
+
"get_latest_custom_component_installation_logs",
|
|
33
|
+
"search_docs",
|
|
34
|
+
"run_component",
|
|
35
|
+
"get_custom_components",
|
|
36
|
+
"get_component_definition",
|
|
37
|
+
"search_component_definition",
|
|
38
|
+
"list_component_families",
|
|
39
|
+
"list_indexes",
|
|
40
|
+
"deploy_index",
|
|
41
|
+
"update_index",
|
|
42
|
+
"create_index",
|
|
43
|
+
"get_index",
|
|
44
|
+
"validate_index",
|
|
45
|
+
"create_get_from_object_store",
|
|
46
|
+
"create_get_slice_from_object_store",
|
|
47
|
+
"list_pipelines",
|
|
48
|
+
"get_pipeline",
|
|
49
|
+
"get_pipeline_logs",
|
|
50
|
+
"deploy_pipeline",
|
|
51
|
+
"search_pipeline",
|
|
52
|
+
"create_pipeline",
|
|
53
|
+
"update_pipeline",
|
|
54
|
+
"validate_pipeline",
|
|
55
|
+
"list_templates",
|
|
56
|
+
"get_template",
|
|
57
|
+
"search_templates",
|
|
58
|
+
"get_secret",
|
|
59
|
+
"list_secrets",
|
|
60
|
+
"list_workspaces",
|
|
61
|
+
"get_workspace",
|
|
62
|
+
]
|
|
@@ -2,17 +2,20 @@
|
|
|
2
2
|
#
|
|
3
3
|
# SPDX-License-Identifier: Apache-2.0
|
|
4
4
|
|
|
5
|
-
from deepset_mcp.api.custom_components.models import
|
|
5
|
+
from deepset_mcp.api.custom_components.models import CustomComponentInstallation
|
|
6
6
|
from deepset_mcp.api.protocols import AsyncClientProtocol
|
|
7
|
+
from deepset_mcp.api.shared_models import PaginatedResponse
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
async def list_custom_component_installations(
|
|
10
|
-
*, client: AsyncClientProtocol, workspace: str
|
|
11
|
-
) ->
|
|
11
|
+
*, client: AsyncClientProtocol, workspace: str, limit: int = 20, after: str | None = None
|
|
12
|
+
) -> PaginatedResponse[CustomComponentInstallation] | str:
|
|
12
13
|
"""List custom component installations.
|
|
13
14
|
|
|
14
15
|
:param client: The API client to use.
|
|
15
16
|
:param workspace: The workspace to operate in.
|
|
17
|
+
:param limit: Maximum number of installations to return per page.
|
|
18
|
+
:param after: The cursor to fetch the next page of results.
|
|
16
19
|
|
|
17
20
|
:returns: Custom component installations or error message.
|
|
18
21
|
"""
|
|
@@ -20,7 +23,7 @@ async def list_custom_component_installations(
|
|
|
20
23
|
users = client.users()
|
|
21
24
|
|
|
22
25
|
try:
|
|
23
|
-
installations = await custom_components.list_installations()
|
|
26
|
+
installations = await custom_components.list_installations(limit=limit, after=after)
|
|
24
27
|
except Exception as e:
|
|
25
28
|
return f"Failed to retrieve custom component installations: {e}"
|
|
26
29
|
|
|
@@ -27,11 +27,9 @@ from deepset_mcp.tools.model_protocol import ModelProtocol
|
|
|
27
27
|
def extract_component_texts(*, component_def: dict[str, Any]) -> tuple[str, str]:
|
|
28
28
|
"""Extracts the component name and description for embedding.
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
component_def: The component definition
|
|
30
|
+
:param component_def: The component definition
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
A tuple containing the component name and description
|
|
32
|
+
:returns: A tuple containing the component name and description
|
|
35
33
|
"""
|
|
36
34
|
component_type = component_def["properties"]["type"]["const"]
|
|
37
35
|
name = component_def.get("title", "")
|
|
@@ -39,6 +37,18 @@ def extract_component_texts(*, component_def: dict[str, Any]) -> tuple[str, str]
|
|
|
39
37
|
return component_type, f"{name} {description}"
|
|
40
38
|
|
|
41
39
|
|
|
40
|
+
def _format_type(type_: str | list[str]) -> str:
|
|
41
|
+
"""Formats the component type as a single string.
|
|
42
|
+
|
|
43
|
+
:param type_: The component type
|
|
44
|
+
:return: The component type formatted as a single string
|
|
45
|
+
"""
|
|
46
|
+
if isinstance(type_, str):
|
|
47
|
+
return type_
|
|
48
|
+
|
|
49
|
+
return " | ".join(type_)
|
|
50
|
+
|
|
51
|
+
|
|
42
52
|
async def _build_component_definition(
|
|
43
53
|
*, component_def: dict[str, Any], component_type: str, haystack_service: Any, schema: dict[str, Any] | None = None
|
|
44
54
|
) -> ComponentDefinition | str:
|
|
@@ -79,7 +89,7 @@ async def _build_component_definition(
|
|
|
79
89
|
name=prop_name,
|
|
80
90
|
annotation=prop_info.get("_annotation", prop_info.get("type", "Unknown")),
|
|
81
91
|
description=prop_info.get("description", "No description available."),
|
|
82
|
-
type=prop_info.get("type", "Unknown"),
|
|
92
|
+
type=_format_type(prop_info.get("type", "Unknown")),
|
|
83
93
|
required=prop_name in input_required,
|
|
84
94
|
)
|
|
85
95
|
for prop_name, prop_info in input_props.items()
|
|
@@ -158,13 +168,11 @@ async def _build_component_definition(
|
|
|
158
168
|
async def get_component_definition(*, client: AsyncClientProtocol, component_type: str) -> ComponentDefinition | str:
|
|
159
169
|
"""Returns the definition of a specific Haystack component.
|
|
160
170
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
(e.g. haystack.components.routers.conditional_router.ConditionalRouter)
|
|
171
|
+
:param client: The API client to use
|
|
172
|
+
:param component_type: Fully qualified component type
|
|
173
|
+
(e.g. haystack.components.routers.conditional_router.ConditionalRouter)
|
|
165
174
|
|
|
166
|
-
|
|
167
|
-
ComponentDefinition model or error message string
|
|
175
|
+
:returns: ComponentDefinition model or error message string
|
|
168
176
|
"""
|
|
169
177
|
haystack_service = client.haystack_service()
|
|
170
178
|
|
|
@@ -195,14 +203,12 @@ async def search_component_definition(
|
|
|
195
203
|
) -> ComponentSearchResults | str:
|
|
196
204
|
"""Searches for components based on name or description using semantic similarity.
|
|
197
205
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
top_k: Maximum number of results to return (default: 5)
|
|
206
|
+
:param client: The API client to use
|
|
207
|
+
:param query: The search query
|
|
208
|
+
:param model: The model to use for computing embeddings
|
|
209
|
+
:param top_k: Maximum number of results to return (default: 5)
|
|
203
210
|
|
|
204
|
-
|
|
205
|
-
ComponentSearchResults model or error message string
|
|
211
|
+
:returns: ComponentSearchResults model or error message string
|
|
206
212
|
"""
|
|
207
213
|
haystack_service = client.haystack_service()
|
|
208
214
|
|
|
@@ -261,11 +267,9 @@ async def search_component_definition(
|
|
|
261
267
|
async def list_component_families(*, client: AsyncClientProtocol) -> ComponentFamilyList | str:
|
|
262
268
|
"""Lists all Haystack component families that are available on deepset.
|
|
263
269
|
|
|
264
|
-
|
|
265
|
-
client: The API client to use
|
|
270
|
+
:param client: The API client to use
|
|
266
271
|
|
|
267
|
-
|
|
268
|
-
ComponentFamilyList model or error message string
|
|
272
|
+
:returns: ComponentFamilyList model or error message string
|
|
269
273
|
"""
|
|
270
274
|
haystack_service = client.haystack_service()
|
|
271
275
|
|
|
@@ -360,3 +364,41 @@ async def get_custom_components(*, client: AsyncClientProtocol) -> ComponentDefi
|
|
|
360
364
|
component_definitions = [comp for comp in results if comp is not None]
|
|
361
365
|
|
|
362
366
|
return ComponentDefinitionList(components=component_definitions, total_count=len(component_definitions))
|
|
367
|
+
|
|
368
|
+
|
|
369
|
+
async def run_component(
|
|
370
|
+
*,
|
|
371
|
+
client: AsyncClientProtocol,
|
|
372
|
+
component_type: str,
|
|
373
|
+
init_params: dict[str, Any] | None = None,
|
|
374
|
+
input_data: dict[str, Any] | None = None,
|
|
375
|
+
input_types: dict[str, str] | None = None,
|
|
376
|
+
) -> dict[str, Any] | str:
|
|
377
|
+
"""Run a Haystack component with the given parameters.
|
|
378
|
+
|
|
379
|
+
This tool allows you to execute a Haystack component by providing its type
|
|
380
|
+
and initialization parameters, then passing input data to get results.
|
|
381
|
+
Use this to test components and see how they would work in your pipeline.
|
|
382
|
+
|
|
383
|
+
:param client: The API client to use
|
|
384
|
+
:param component_type: The type of component to run
|
|
385
|
+
(e.g., "haystack.components.builders.prompt_builder.PromptBuilder")
|
|
386
|
+
:param init_params: Initialization parameters for the component
|
|
387
|
+
:param input_data: Input data for the component
|
|
388
|
+
:param input_types: Optional type information for inputs (inferred if not provided). For custom types use the full
|
|
389
|
+
import path (e.g. haystack.dataclasses.document.Document for Document)
|
|
390
|
+
|
|
391
|
+
:returns: Dictionary containing the component's outputs or error message string
|
|
392
|
+
"""
|
|
393
|
+
haystack_service = client.haystack_service()
|
|
394
|
+
|
|
395
|
+
try:
|
|
396
|
+
result = await haystack_service.run_component(
|
|
397
|
+
component_type=component_type,
|
|
398
|
+
init_params=init_params,
|
|
399
|
+
input_data=input_data,
|
|
400
|
+
input_types=input_types,
|
|
401
|
+
)
|
|
402
|
+
return result
|
|
403
|
+
except Exception as e:
|
|
404
|
+
return f"Failed to run component: {str(e)}"
|
|
@@ -15,87 +15,127 @@ class ComponentInitParameter(BaseModel):
|
|
|
15
15
|
"""Represents an initialization parameter for a Haystack component."""
|
|
16
16
|
|
|
17
17
|
name: str
|
|
18
|
+
"Name of the initialization parameter"
|
|
18
19
|
annotation: str
|
|
20
|
+
"Type annotation string for the parameter"
|
|
19
21
|
description: str
|
|
22
|
+
"Human-readable description of the parameter"
|
|
20
23
|
default: Any | None = None
|
|
24
|
+
"Default value for the parameter, if any"
|
|
21
25
|
required: bool = False
|
|
26
|
+
"Whether this parameter is required for component initialization"
|
|
22
27
|
|
|
23
28
|
|
|
24
29
|
class ComponentIOProperty(BaseModel):
|
|
25
30
|
"""Represents an input/output property schema."""
|
|
26
31
|
|
|
27
32
|
name: str
|
|
33
|
+
"Name of the input/output property"
|
|
28
34
|
annotation: str
|
|
35
|
+
"Type annotation string for the property"
|
|
29
36
|
description: str
|
|
37
|
+
"Human-readable description of the property"
|
|
30
38
|
type: str
|
|
39
|
+
"Type classification of the property"
|
|
31
40
|
required: bool = False
|
|
41
|
+
"Whether this property is required"
|
|
32
42
|
|
|
33
43
|
|
|
34
44
|
class ComponentIODefinition(BaseModel):
|
|
35
45
|
"""Represents a definition referenced in I/O schema."""
|
|
36
46
|
|
|
37
47
|
name: str
|
|
48
|
+
"Name of the I/O definition"
|
|
38
49
|
type: str
|
|
50
|
+
"Type classification of the definition"
|
|
39
51
|
properties: dict[str, ComponentIOProperty]
|
|
52
|
+
"Dictionary of properties within this definition"
|
|
40
53
|
required: list[str]
|
|
54
|
+
"List of required property names"
|
|
41
55
|
|
|
42
56
|
|
|
43
57
|
class ComponentIOSchema(BaseModel):
|
|
44
58
|
"""Represents the input/output schema for a component."""
|
|
45
59
|
|
|
46
60
|
properties: dict[str, ComponentIOProperty]
|
|
61
|
+
"Dictionary of input/output properties"
|
|
47
62
|
required: list[str]
|
|
63
|
+
"List of required property names"
|
|
48
64
|
definitions: dict[str, ComponentIODefinition] = Field(default_factory=dict)
|
|
65
|
+
"Dictionary of type definitions referenced by properties"
|
|
49
66
|
|
|
50
67
|
|
|
51
68
|
class ComponentDefinition(BaseModel):
|
|
52
69
|
"""Represents a complete Haystack component definition."""
|
|
53
70
|
|
|
54
71
|
component_type: str
|
|
72
|
+
"Fully qualified class name of the component"
|
|
55
73
|
title: str
|
|
74
|
+
"Human-readable title of the component"
|
|
56
75
|
description: str
|
|
76
|
+
"Detailed description of the component's functionality"
|
|
57
77
|
family: str
|
|
78
|
+
"Component family name (e.g., 'retrievers', 'generators')"
|
|
58
79
|
family_description: str
|
|
80
|
+
"Description of the component family"
|
|
59
81
|
init_parameters: list[ComponentInitParameter] = Field(default_factory=list)
|
|
82
|
+
"List of parameters required for component initialization"
|
|
60
83
|
input_schema: ComponentIOSchema | None = None
|
|
84
|
+
"Schema defining the component's input requirements"
|
|
61
85
|
output_schema: ComponentIOSchema | None = None
|
|
86
|
+
"Schema defining the component's output format"
|
|
62
87
|
error_message: str | None = None
|
|
88
|
+
"Error message if component definition failed to load"
|
|
63
89
|
is_custom: bool = False
|
|
90
|
+
"Whether this is a custom user-defined component"
|
|
64
91
|
package_version: str | None = None
|
|
92
|
+
"Version of the package containing this component"
|
|
65
93
|
dynamic_params: bool = False
|
|
94
|
+
"Whether the component accepts dynamic parameters"
|
|
66
95
|
|
|
67
96
|
|
|
68
97
|
class ComponentSearchResult(BaseModel):
|
|
69
98
|
"""Represents a search result for a component."""
|
|
70
99
|
|
|
71
100
|
component: ComponentDefinition
|
|
101
|
+
"Component definition that matched the search criteria"
|
|
72
102
|
similarity_score: float
|
|
103
|
+
"Relevance score indicating how well the component matches the search"
|
|
73
104
|
|
|
74
105
|
|
|
75
106
|
class ComponentSearchResults(BaseModel):
|
|
76
107
|
"""Response model for component search results."""
|
|
77
108
|
|
|
78
109
|
results: list[ComponentSearchResult]
|
|
110
|
+
"List of components matching the search criteria"
|
|
79
111
|
query: str
|
|
112
|
+
"Original search query string"
|
|
80
113
|
total_found: int
|
|
114
|
+
"Total number of components found matching the search criteria"
|
|
81
115
|
|
|
82
116
|
|
|
83
117
|
class ComponentFamily(BaseModel):
|
|
84
118
|
"""Represents a Haystack component family."""
|
|
85
119
|
|
|
86
120
|
name: str
|
|
121
|
+
"Name of the component family"
|
|
87
122
|
description: str
|
|
123
|
+
"Description of the component family and its purpose"
|
|
88
124
|
|
|
89
125
|
|
|
90
126
|
class ComponentFamilyList(BaseModel):
|
|
91
127
|
"""Response model for listing component families."""
|
|
92
128
|
|
|
93
129
|
families: list[ComponentFamily]
|
|
130
|
+
"List of available component families"
|
|
94
131
|
total_count: int
|
|
132
|
+
"Total number of component families available"
|
|
95
133
|
|
|
96
134
|
|
|
97
135
|
class ComponentDefinitionList(BaseModel):
|
|
98
136
|
"""Response model for listing component definitions."""
|
|
99
137
|
|
|
100
138
|
components: list[ComponentDefinition]
|
|
139
|
+
"List of component definitions"
|
|
101
140
|
total_count: int
|
|
141
|
+
"Total number of components available"
|