* update version
Browse files* introduce new configs
- output.py +3 -0
- prompt.py +28 -0
- prompt_text.txt +13 -13
- requirements.txt +1 -1
output.py
CHANGED
@@ -66,11 +66,13 @@ def init_settings() -> (List, Dict):
|
|
66 |
|
67 |
st_bs_match_type = st.selectbox("Match type", ["str", "word"])
|
68 |
st_bs_case_sensitive = st.checkbox("Case sensitive", value=False)
|
|
|
69 |
|
70 |
settings["BanSubstrings"] = {
|
71 |
"substrings": st_bs_substrings,
|
72 |
"match_type": st_bs_match_type,
|
73 |
"case_sensitive": st_bs_case_sensitive,
|
|
|
74 |
}
|
75 |
|
76 |
if "BanTopics" in st_enabled_scanners:
|
@@ -309,6 +311,7 @@ def get_scanner(scanner_name: str, vault: Vault, settings: Dict):
|
|
309 |
substrings=settings["substrings"],
|
310 |
match_type=settings["match_type"],
|
311 |
case_sensitive=settings["case_sensitive"],
|
|
|
312 |
)
|
313 |
|
314 |
if scanner_name == "BanTopics":
|
|
|
66 |
|
67 |
st_bs_match_type = st.selectbox("Match type", ["str", "word"])
|
68 |
st_bs_case_sensitive = st.checkbox("Case sensitive", value=False)
|
69 |
+
st_bs_redact = st.checkbox("Redact", value=False)
|
70 |
|
71 |
settings["BanSubstrings"] = {
|
72 |
"substrings": st_bs_substrings,
|
73 |
"match_type": st_bs_match_type,
|
74 |
"case_sensitive": st_bs_case_sensitive,
|
75 |
+
"redact": st_bs_redact,
|
76 |
}
|
77 |
|
78 |
if "BanTopics" in st_enabled_scanners:
|
|
|
311 |
substrings=settings["substrings"],
|
312 |
match_type=settings["match_type"],
|
313 |
case_sensitive=settings["case_sensitive"],
|
314 |
+
redact=settings["redact"],
|
315 |
)
|
316 |
|
317 |
if scanner_name == "BanTopics":
|
prompt.py
CHANGED
@@ -10,6 +10,7 @@ from llm_guard.input_scanners import (
|
|
10 |
BanTopics,
|
11 |
Code,
|
12 |
PromptInjection,
|
|
|
13 |
Secrets,
|
14 |
Sentiment,
|
15 |
TokenLimit,
|
@@ -28,6 +29,7 @@ def init_settings() -> (List, Dict):
|
|
28 |
"BanTopics",
|
29 |
"Code",
|
30 |
"PromptInjection",
|
|
|
31 |
"Secrets",
|
32 |
"Sentiment",
|
33 |
"TokenLimit",
|
@@ -110,11 +112,13 @@ def init_settings() -> (List, Dict):
|
|
110 |
|
111 |
st_bs_match_type = st.selectbox("Match type", ["str", "word"])
|
112 |
st_bs_case_sensitive = st.checkbox("Case sensitive", value=False)
|
|
|
113 |
|
114 |
settings["BanSubstrings"] = {
|
115 |
"substrings": st_bs_substrings,
|
116 |
"match_type": st_bs_match_type,
|
117 |
"case_sensitive": st_bs_case_sensitive,
|
|
|
118 |
}
|
119 |
|
120 |
if "BanTopics" in st_enabled_scanners:
|
@@ -187,6 +191,26 @@ def init_settings() -> (List, Dict):
|
|
187 |
"threshold": st_pi_threshold,
|
188 |
}
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
if "Secrets" in st_enabled_scanners:
|
191 |
st_sec_expander = st.sidebar.expander(
|
192 |
"Secrets",
|
@@ -284,6 +308,7 @@ def get_scanner(scanner_name: str, vault: Vault, settings: Dict):
|
|
284 |
substrings=settings["substrings"],
|
285 |
match_type=settings["match_type"],
|
286 |
case_sensitive=settings["case_sensitive"],
|
|
|
287 |
)
|
288 |
|
289 |
if scanner_name == "BanTopics":
|
@@ -304,6 +329,9 @@ def get_scanner(scanner_name: str, vault: Vault, settings: Dict):
|
|
304 |
if scanner_name == "PromptInjection":
|
305 |
return PromptInjection(threshold=settings["threshold"])
|
306 |
|
|
|
|
|
|
|
307 |
if scanner_name == "Secrets":
|
308 |
return Secrets(redact_mode=settings["redact_mode"])
|
309 |
|
|
|
10 |
BanTopics,
|
11 |
Code,
|
12 |
PromptInjection,
|
13 |
+
PromptInjectionV2,
|
14 |
Secrets,
|
15 |
Sentiment,
|
16 |
TokenLimit,
|
|
|
29 |
"BanTopics",
|
30 |
"Code",
|
31 |
"PromptInjection",
|
32 |
+
"PromptInjectionV2",
|
33 |
"Secrets",
|
34 |
"Sentiment",
|
35 |
"TokenLimit",
|
|
|
112 |
|
113 |
st_bs_match_type = st.selectbox("Match type", ["str", "word"])
|
114 |
st_bs_case_sensitive = st.checkbox("Case sensitive", value=False)
|
115 |
+
st_bs_redact = st.checkbox("Redact", value=False)
|
116 |
|
117 |
settings["BanSubstrings"] = {
|
118 |
"substrings": st_bs_substrings,
|
119 |
"match_type": st_bs_match_type,
|
120 |
"case_sensitive": st_bs_case_sensitive,
|
121 |
+
"redact": st_bs_redact,
|
122 |
}
|
123 |
|
124 |
if "BanTopics" in st_enabled_scanners:
|
|
|
191 |
"threshold": st_pi_threshold,
|
192 |
}
|
193 |
|
194 |
+
if "PromptInjectionV2" in st_enabled_scanners:
|
195 |
+
st_piv2_expander = st.sidebar.expander(
|
196 |
+
"Prompt Injection V2",
|
197 |
+
expanded=False,
|
198 |
+
)
|
199 |
+
|
200 |
+
with st_piv2_expander:
|
201 |
+
st_piv2_threshold = st.slider(
|
202 |
+
label="Threshold",
|
203 |
+
value=0.5,
|
204 |
+
min_value=0.0,
|
205 |
+
max_value=1.0,
|
206 |
+
step=0.05,
|
207 |
+
key="prompt_injection_v2_threshold",
|
208 |
+
)
|
209 |
+
|
210 |
+
settings["PromptInjectionV2"] = {
|
211 |
+
"threshold": st_piv2_threshold,
|
212 |
+
}
|
213 |
+
|
214 |
if "Secrets" in st_enabled_scanners:
|
215 |
st_sec_expander = st.sidebar.expander(
|
216 |
"Secrets",
|
|
|
308 |
substrings=settings["substrings"],
|
309 |
match_type=settings["match_type"],
|
310 |
case_sensitive=settings["case_sensitive"],
|
311 |
+
redact=settings["redact"],
|
312 |
)
|
313 |
|
314 |
if scanner_name == "BanTopics":
|
|
|
329 |
if scanner_name == "PromptInjection":
|
330 |
return PromptInjection(threshold=settings["threshold"])
|
331 |
|
332 |
+
if scanner_name == "PromptInjectionV2":
|
333 |
+
return PromptInjectionV2(threshold=settings["threshold"])
|
334 |
+
|
335 |
if scanner_name == "Secrets":
|
336 |
return Secrets(redact_mode=settings["redact_mode"])
|
337 |
|
prompt_text.txt
CHANGED
@@ -1,15 +1,15 @@
|
|
1 |
-
Given the personal profile of Johnathan Edward Doe:
|
2 |
|
3 |
-
|
4 |
-
Date of Birth: April 12, 1990
|
5 |
-
Address: 123 Elm Street, Springfield, IL, 62701
|
6 |
-
Email: [email protected]
|
7 |
-
Phone Number: (123) 456-7890
|
8 |
-
Educational Background:
|
9 |
-
Springfield High School, Graduated in 2008
|
10 |
-
Springfield University, B.Sc. Computer Science, Graduated in 2012
|
11 |
-
Employment:
|
12 |
-
ABC Tech Solutions, Software Engineer, 2012-2015
|
13 |
-
XYZ Global Systems, Senior Software Developer, 2015-2021
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Given the personal profile of Johnathan Edward Doe, please summarize the following resume:
|
2 |
|
3 |
+
Profile:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
- Full Name: Johnathan Edward Doe
|
6 |
+
- Date of Birth: April 12, 1990
|
7 |
+
- Address: 123 Elm Street, Springfield, IL, 62701
|
8 |
+
- Email: [email protected]
|
9 |
+
- Phone Number: (123) 456-7890
|
10 |
+
- Educational Background:
|
11 |
+
- Springfield High School, Graduated in 2008
|
12 |
+
- Springfield University, B.Sc. Computer Science, Graduated in 2012
|
13 |
+
- Employment:
|
14 |
+
- ABC Tech Solutions, Software Engineer, 2012-2015
|
15 |
+
- XYZ Global Systems, Senior Software Developer, 2015-2021
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
llm-guard==0.2.
|
2 |
pandas==2.1.0
|
3 |
streamlit==1.26.0
|
4 |
streamlit-tags==1.2.8
|
|
|
1 |
+
llm-guard==0.2.4
|
2 |
pandas==2.1.0
|
3 |
streamlit==1.26.0
|
4 |
streamlit-tags==1.2.8
|