haystack-vaultak 0.1.0__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.
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: haystack-vaultak
3
+ Version: 0.1.0
4
+ Summary: Vaultak runtime security components for Haystack pipelines
5
+ License: MIT
6
+ Project-URL: Homepage, https://vaultak.com
7
+ Project-URL: Documentation, https://docs.vaultak.com
8
+ Project-URL: Repository, https://github.com/samueloladji-beep/haystack-vaultak
9
+ Keywords: haystack,vaultak,security,ai-agents,runtime-security,pii
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Security
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: haystack-ai>=2.0.0
18
+ Requires-Dist: vaultak>=0.1.0
19
+
20
+ # haystack-vaultak
21
+
22
+ Vaultak runtime security components for [Haystack](https://haystack.deepset.ai) pipelines.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install haystack-vaultak
28
+ ```
29
+
30
+ ## Components
31
+
32
+ - **VaultakSecurityChecker** — Risk-scores every query before it enters your pipeline. Blocks high-risk inputs.
33
+ - **VaultakPIIMasker** — Masks PII in LLM replies before they reach users.
34
+
35
+ ## Quick start
36
+
37
+ ```python
38
+ from haystack import Pipeline
39
+ from haystack.components.generators.chat import OpenAIChatGenerator
40
+ from haystack_vaultak import VaultakSecurityChecker, VaultakPIIMasker
41
+ import os
42
+
43
+ pipeline = Pipeline()
44
+ pipeline.add_component("security", VaultakSecurityChecker(api_key=os.environ["VAULTAK_API_KEY"]))
45
+ pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini"))
46
+ pipeline.add_component("pii_masker", VaultakPIIMasker(api_key=os.environ["VAULTAK_API_KEY"]))
47
+
48
+ pipeline.connect("security.query", "llm.query")
49
+ pipeline.connect("llm.replies", "pii_masker.replies")
50
+
51
+ result = pipeline.run({"security": {"query": "What is the capital of France?"}})
52
+ print(result["pii_masker"]["replies"][0].text)
53
+ ```
54
+
55
+ ## License
56
+
57
+ MIT
@@ -0,0 +1,38 @@
1
+ # haystack-vaultak
2
+
3
+ Vaultak runtime security components for [Haystack](https://haystack.deepset.ai) pipelines.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install haystack-vaultak
9
+ ```
10
+
11
+ ## Components
12
+
13
+ - **VaultakSecurityChecker** — Risk-scores every query before it enters your pipeline. Blocks high-risk inputs.
14
+ - **VaultakPIIMasker** — Masks PII in LLM replies before they reach users.
15
+
16
+ ## Quick start
17
+
18
+ ```python
19
+ from haystack import Pipeline
20
+ from haystack.components.generators.chat import OpenAIChatGenerator
21
+ from haystack_vaultak import VaultakSecurityChecker, VaultakPIIMasker
22
+ import os
23
+
24
+ pipeline = Pipeline()
25
+ pipeline.add_component("security", VaultakSecurityChecker(api_key=os.environ["VAULTAK_API_KEY"]))
26
+ pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini"))
27
+ pipeline.add_component("pii_masker", VaultakPIIMasker(api_key=os.environ["VAULTAK_API_KEY"]))
28
+
29
+ pipeline.connect("security.query", "llm.query")
30
+ pipeline.connect("llm.replies", "pii_masker.replies")
31
+
32
+ result = pipeline.run({"security": {"query": "What is the capital of France?"}})
33
+ print(result["pii_masker"]["replies"][0].text)
34
+ ```
35
+
36
+ ## License
37
+
38
+ MIT
@@ -0,0 +1,4 @@
1
+ from .components import VaultakSecurityChecker, VaultakPIIMasker
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["VaultakSecurityChecker", "VaultakPIIMasker"]
@@ -0,0 +1,162 @@
1
+ """
2
+ Vaultak runtime security components for Haystack pipelines.
3
+ """
4
+ import os
5
+ from typing import Optional
6
+
7
+ from haystack import component, default_from_dict, default_to_dict
8
+ from haystack.dataclasses import ChatMessage
9
+
10
+
11
+ @component
12
+ class VaultakSecurityChecker:
13
+ """
14
+ Haystack component that risk-scores every query before it enters your pipeline.
15
+
16
+ Insert before your retriever or LLM. Queries whose risk score meets or exceeds
17
+ the threshold raise a RuntimeError so the pipeline halts cleanly.
18
+
19
+ Usage:
20
+ from haystack_vaultak import VaultakSecurityChecker
21
+
22
+ checker = VaultakSecurityChecker(api_key="vtk_...", threshold=7.0)
23
+ pipeline.add_component("security", checker)
24
+ pipeline.connect("security.query", "retriever.query")
25
+ """
26
+
27
+ def __init__(
28
+ self,
29
+ api_key: Optional[str] = None,
30
+ agent_name: str = "haystack-pipeline",
31
+ threshold: float = 7.0,
32
+ verbose: bool = False,
33
+ ):
34
+ from vaultak import Vaultak
35
+ self.api_key = api_key or os.environ.get("VAULTAK_API_KEY", "")
36
+ self.agent_name = agent_name
37
+ self.threshold = threshold
38
+ self.verbose = verbose
39
+ self._vt = Vaultak(api_key=self.api_key, agent_name=agent_name)
40
+
41
+ @component.output_types(query=str)
42
+ def run(self, query: str) -> dict:
43
+ """
44
+ Risk-score the query. Passes it through if safe; raises RuntimeError if blocked.
45
+
46
+ Args:
47
+ query: The user query to screen.
48
+
49
+ Returns:
50
+ dict with key 'query' containing the original query if it passes.
51
+
52
+ Raises:
53
+ RuntimeError: If the risk score meets or exceeds the threshold.
54
+ """
55
+ try:
56
+ result = self._vt.check(
57
+ action_type="query",
58
+ resource=query[:200],
59
+ agent_id=self.agent_name,
60
+ )
61
+ score = result.get("score", 0)
62
+ if self.verbose:
63
+ print(f"[Vaultak] Query risk score: {score}/100")
64
+
65
+ if score >= self.threshold * 10: # Convert 0-10 to 0-100
66
+ raise RuntimeError(
67
+ f"[Vaultak] Query blocked — risk score {score}/100 meets or exceeds "
68
+ f"threshold {self.threshold * 10}/100. Review at app.vaultak.com"
69
+ )
70
+ except RuntimeError:
71
+ raise
72
+ except Exception as e:
73
+ if self.verbose:
74
+ print(f"[Vaultak] Security check failed (non-blocking): {e}")
75
+
76
+ self._vt.log_action(
77
+ action_type="query",
78
+ resource=query[:200],
79
+ agent_id=self.agent_name,
80
+ )
81
+ return {"query": query}
82
+
83
+ def to_dict(self) -> dict:
84
+ return default_to_dict(
85
+ self,
86
+ agent_name=self.agent_name,
87
+ threshold=self.threshold,
88
+ verbose=self.verbose,
89
+ )
90
+
91
+ @classmethod
92
+ def from_dict(cls, data: dict):
93
+ return default_from_dict(cls, data)
94
+
95
+
96
+ @component
97
+ class VaultakPIIMasker:
98
+ """
99
+ Haystack component that masks PII in LLM replies before they reach users.
100
+
101
+ Insert after your LLM generator. Scans every reply and replaces PII
102
+ with safe placeholders.
103
+
104
+ Usage:
105
+ from haystack_vaultak import VaultakPIIMasker
106
+
107
+ masker = VaultakPIIMasker(api_key="vtk_...")
108
+ pipeline.add_component("pii_masker", masker)
109
+ pipeline.connect("llm.replies", "pii_masker.replies")
110
+ """
111
+
112
+ def __init__(
113
+ self,
114
+ api_key: Optional[str] = None,
115
+ agent_name: str = "haystack-pipeline",
116
+ verbose: bool = False,
117
+ ):
118
+ from vaultak import Vaultak
119
+ self.api_key = api_key or os.environ.get("VAULTAK_API_KEY", "")
120
+ self.agent_name = agent_name
121
+ self.verbose = verbose
122
+ self._vt = Vaultak(api_key=self.api_key, agent_name=agent_name)
123
+
124
+ @component.output_types(replies=list)
125
+ def run(self, replies: list) -> dict:
126
+ """
127
+ Mask PII in a list of ChatMessage replies.
128
+
129
+ Args:
130
+ replies: List of ChatMessage objects from the LLM.
131
+
132
+ Returns:
133
+ dict with key 'replies' containing the masked messages.
134
+ """
135
+ masked_replies = []
136
+ for reply in replies:
137
+ try:
138
+ if hasattr(reply, 'text') and reply.text:
139
+ masked_text = self._vt.mask_pii(reply.text)
140
+ if self.verbose and masked_text != reply.text:
141
+ print(f"[Vaultak] PII masked in reply")
142
+ masked_replies.append(
143
+ ChatMessage.from_assistant(masked_text)
144
+ )
145
+ else:
146
+ masked_replies.append(reply)
147
+ except Exception as e:
148
+ if self.verbose:
149
+ print(f"[Vaultak] PII masking failed (non-blocking): {e}")
150
+ masked_replies.append(reply)
151
+ return {"replies": masked_replies}
152
+
153
+ def to_dict(self) -> dict:
154
+ return default_to_dict(
155
+ self,
156
+ agent_name=self.agent_name,
157
+ verbose=self.verbose,
158
+ )
159
+
160
+ @classmethod
161
+ def from_dict(cls, data: dict):
162
+ return default_from_dict(cls, data)
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: haystack-vaultak
3
+ Version: 0.1.0
4
+ Summary: Vaultak runtime security components for Haystack pipelines
5
+ License: MIT
6
+ Project-URL: Homepage, https://vaultak.com
7
+ Project-URL: Documentation, https://docs.vaultak.com
8
+ Project-URL: Repository, https://github.com/samueloladji-beep/haystack-vaultak
9
+ Keywords: haystack,vaultak,security,ai-agents,runtime-security,pii
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Security
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: haystack-ai>=2.0.0
18
+ Requires-Dist: vaultak>=0.1.0
19
+
20
+ # haystack-vaultak
21
+
22
+ Vaultak runtime security components for [Haystack](https://haystack.deepset.ai) pipelines.
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install haystack-vaultak
28
+ ```
29
+
30
+ ## Components
31
+
32
+ - **VaultakSecurityChecker** — Risk-scores every query before it enters your pipeline. Blocks high-risk inputs.
33
+ - **VaultakPIIMasker** — Masks PII in LLM replies before they reach users.
34
+
35
+ ## Quick start
36
+
37
+ ```python
38
+ from haystack import Pipeline
39
+ from haystack.components.generators.chat import OpenAIChatGenerator
40
+ from haystack_vaultak import VaultakSecurityChecker, VaultakPIIMasker
41
+ import os
42
+
43
+ pipeline = Pipeline()
44
+ pipeline.add_component("security", VaultakSecurityChecker(api_key=os.environ["VAULTAK_API_KEY"]))
45
+ pipeline.add_component("llm", OpenAIChatGenerator(model="gpt-4o-mini"))
46
+ pipeline.add_component("pii_masker", VaultakPIIMasker(api_key=os.environ["VAULTAK_API_KEY"]))
47
+
48
+ pipeline.connect("security.query", "llm.query")
49
+ pipeline.connect("llm.replies", "pii_masker.replies")
50
+
51
+ result = pipeline.run({"security": {"query": "What is the capital of France?"}})
52
+ print(result["pii_masker"]["replies"][0].text)
53
+ ```
54
+
55
+ ## License
56
+
57
+ MIT
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ haystack_vaultak/__init__.py
4
+ haystack_vaultak/components.py
5
+ haystack_vaultak.egg-info/PKG-INFO
6
+ haystack_vaultak.egg-info/SOURCES.txt
7
+ haystack_vaultak.egg-info/dependency_links.txt
8
+ haystack_vaultak.egg-info/requires.txt
9
+ haystack_vaultak.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ haystack-ai>=2.0.0
2
+ vaultak>=0.1.0
@@ -0,0 +1 @@
1
+ haystack_vaultak
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "haystack-vaultak"
7
+ version = "0.1.0"
8
+ description = "Vaultak runtime security components for Haystack pipelines"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.8"
12
+ keywords = ["haystack", "vaultak", "security", "ai-agents", "runtime-security", "pii"]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Developers",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Programming Language :: Python :: 3",
18
+ "Topic :: Security",
19
+ ]
20
+ dependencies = [
21
+ "haystack-ai>=2.0.0",
22
+ "vaultak>=0.1.0",
23
+ ]
24
+
25
+ [project.urls]
26
+ Homepage = "https://vaultak.com"
27
+ Documentation = "https://docs.vaultak.com"
28
+ Repository = "https://github.com/samueloladji-beep/haystack-vaultak"
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["."]
32
+ include = ["haystack_vaultak*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+