Commit eacea93
committed
fix: improve LLM provider integration and debug logging
This commit addresses critical issues with Gemini and OpenAI provide integrations and enhances debug logging across all LLM adapters.
Changes:
- Reroute Gemini to standalone HTTP client bypassing rig.rs due to
deserialization issues with current Gemini API
- Add generationConfig.responseMimeType to Gemini requests to enforce
JSON responses
- Switch OpenAI from json_schema to json_object response format for
better compatibility with GPT-5 reasoning models
- Add flexible regex patterns INSTR_IGNORE and PROMPT_LEAK to
rules/patterns.json to catch attack variations
- Enhance debug logging: always log raw LLM responses when --debug flag
is enabled (not only on errors)
- Add debug logging to Gemini standalone client
- Remove unused verdict_json_schema function from rig adapter
- Update README.md with detailed provider integration pitfalls
Fixes:
- Gemini "missing field generationConfig" deserialization errors
- OpenAI GPT-5 returning only reasoning traces with no content
- Detection rules missing "ignore your previous instructions" variations
- Debug logging only showing errors instead of all raw responses1 parent fa42884 commit eacea93
File tree
5 files changed
+75
-61
lines changed- crates/llm-guard-core/src/llm
- rules
5 files changed
+75
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
536 | | - | |
537 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
538 | 539 | | |
539 | 540 | | |
540 | 541 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
| |||
106 | 110 | | |
107 | 111 | | |
108 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
109 | 122 | | |
110 | 123 | | |
111 | 124 | | |
| |||
114 | 127 | | |
115 | 128 | | |
116 | 129 | | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
117 | 135 | | |
118 | 136 | | |
119 | 137 | | |
| |||
135 | 153 | | |
136 | 154 | | |
137 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
138 | 160 | | |
139 | 161 | | |
140 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
141 | 172 | | |
142 | 173 | | |
143 | 174 | | |
| |||
152 | 183 | | |
153 | 184 | | |
154 | 185 | | |
155 | | - | |
| 186 | + | |
156 | 187 | | |
157 | 188 | | |
158 | 189 | | |
159 | 190 | | |
160 | | - | |
| 191 | + | |
161 | 192 | | |
162 | 193 | | |
163 | 194 | | |
164 | 195 | | |
165 | | - | |
| 196 | + | |
166 | 197 | | |
167 | 198 | | |
168 | 199 | | |
169 | 200 | | |
170 | | - | |
| 201 | + | |
171 | 202 | | |
172 | 203 | | |
173 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 104 | + | |
| 105 | + | |
127 | 106 | | |
128 | 107 | | |
129 | 108 | | |
| |||
217 | 196 | | |
218 | 197 | | |
219 | 198 | | |
| 199 | + | |
| 200 | + | |
220 | 201 | | |
221 | 202 | | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 203 | + | |
228 | 204 | | |
229 | 205 | | |
230 | 206 | | |
| 207 | + | |
| 208 | + | |
231 | 209 | | |
232 | 210 | | |
233 | 211 | | |
| |||
255 | 233 | | |
256 | 234 | | |
257 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
258 | 239 | | |
259 | 240 | | |
260 | 241 | | |
| |||
270 | 251 | | |
271 | 252 | | |
272 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
273 | 260 | | |
274 | | - | |
275 | 261 | | |
276 | 262 | | |
277 | 263 | | |
| |||
282 | 268 | | |
283 | 269 | | |
284 | 270 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
| 271 | + | |
290 | 272 | | |
291 | 273 | | |
292 | 274 | | |
| |||
362 | 344 | | |
363 | 345 | | |
364 | 346 | | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | 347 | | |
382 | 348 | | |
383 | 349 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
14 | 26 | | |
15 | 27 | | |
0 commit comments