Commit fac2774
committed
fix(llm): Add async streaming support to ChatNVIDIA provider patch (#1504)
* feat(llm): Add async streaming support to ChatNVIDIA provider
Enables stream_async() to work with ChatNVIDIA/NIM models by
implementing async streaming decorator and _agenerate method. Prior to
this fix, stream_async() would fail with NIM engine configurations.
* fix: ensure stream_async background task completes before exit (#1508)
Wrap the returned iterator to await the background generation task in a
finally block, preventing "Task was destroyed but it is pending"
warning.
Add overloaded type signatures to provide accurate return types based on
the include_generation_metadata parameter.1 parent be88814 commit fac2774
File tree
3 files changed
+487
-7
lines changed- nemoguardrails
- llm/providers
- rails/llm
- tests/llm_providers
3 files changed
+487
-7
lines changedLines changed: 46 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
25 | | - | |
| 31 | + | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| |||
49 | 55 | | |
50 | 56 | | |
51 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
52 | 80 | | |
53 | 81 | | |
54 | 82 | | |
| |||
65 | 93 | | |
66 | 94 | | |
67 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
68 | 111 | | |
69 | 112 | | |
70 | 113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
1255 | 1257 | | |
1256 | 1258 | | |
1257 | 1259 | | |
| 1260 | + | |
1258 | 1261 | | |
1259 | 1262 | | |
1260 | 1263 | | |
1261 | 1264 | | |
1262 | 1265 | | |
1263 | 1266 | | |
1264 | | - | |
| 1267 | + | |
1265 | 1268 | | |
1266 | 1269 | | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
1267 | 1293 | | |
1268 | 1294 | | |
1269 | 1295 | | |
| |||
1328 | 1354 | | |
1329 | 1355 | | |
1330 | 1356 | | |
1331 | | - | |
1332 | | - | |
| 1357 | + | |
1333 | 1358 | | |
1334 | 1359 | | |
1335 | 1360 | | |
1336 | 1361 | | |
1337 | 1362 | | |
1338 | 1363 | | |
1339 | | - | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
1340 | 1375 | | |
1341 | 1376 | | |
1342 | 1377 | | |
| |||
0 commit comments