Commit 2df7a14
fix: ensure that stop token is not ignored if llm_params is None (#1529)
* Fix ignored stop token if llm_params is None
Signed-off-by: Rob Geada <[email protected]>
* fix(llm): pass stop tokens to ainvoke or invoke instead of bind
Commit 67de947 ("chore(types): Type-clean /actions") introduced a bug
where stop tokens were only passed to the LLM when llm_params was truthy. When
llm_params was None or empty,
stop tokens were completely ignored.
Fix: Restored the original pattern where stop is passed directly to
ainvoke() as a kwarg, and .bind() is only used for llm_params:
- stop is now passed to _invoke_with_string_prompt() and
_invoke_with_message_list()
- Those functions pass stop=stop to llm.ainvoke()
- .bind() is only called when llm_params is truthy (no stop in bind)
---------
Signed-off-by: Rob Geada <[email protected]>
Co-authored-by: Rob Geada <[email protected]>1 parent f716ee0 commit 2df7a14
File tree
4 files changed
+47
-12
lines changed- nemoguardrails/actions/llm
- tests
4 files changed
+47
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
168 | | - | |
169 | | - | |
| 167 | + | |
170 | 168 | | |
171 | 169 | | |
172 | | - | |
| 170 | + | |
173 | 171 | | |
174 | | - | |
| 172 | + | |
175 | 173 | | |
176 | 174 | | |
177 | 175 | | |
| |||
206 | 204 | | |
207 | 205 | | |
208 | 206 | | |
| 207 | + | |
209 | 208 | | |
210 | 209 | | |
211 | 210 | | |
212 | | - | |
| 211 | + | |
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
| |||
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
| 220 | + | |
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
| |||
197 | 196 | | |
198 | 197 | | |
199 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
200 | 219 | | |
201 | 220 | | |
202 | 221 | | |
| |||
392 | 411 | | |
393 | 412 | | |
394 | 413 | | |
395 | | - | |
| 414 | + | |
396 | 415 | | |
397 | 416 | | |
398 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
253 | 253 | | |
254 | 254 | | |
255 | 255 | | |
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
0 commit comments