Commit 2f2ad90
authored
Add SLM Engine support function calling (#1582)
This pull request introduces significant enhancements to the SLM Engine,
focusing on adding function-calling support and improving the build
process for ONNX Runtime-GenAI. The most notable changes include the
implementation of function-calling capabilities, updates to the build
scripts to handle fallback modes, and the addition of new structures and
methods to support function tools in the C++ codebase.
### Function-Calling Support:
* Added a new section in `README.md` to document function-calling
capabilities, including key features, an example request, and structured
JSON output for function calls (`examples/slm_engine/README.md`).
* Introduced new structs (`FunctionParameter`, `FunctionTool`,
`FunctionCallOptions`, `FunctionCall`, and `FunctionCallResult`) to
represent function tools, parameters, and results in the SLM Engine
(`examples/slm_engine/src/cpp/slm_engine.h`).
* Added methods to parse tools from JSON, format input with tools,
create grammar for function calling, and handle function call results
(`examples/slm_engine/src/cpp/slm_engine.h`).
* Updated `InputDecoder` to handle tools and added a new `TOOL` role to
support function-calling scenarios
(`examples/slm_engine/src/cpp/input_decoder.cpp`,
`examples/slm_engine/src/cpp/input_decoder.h`).
### Build Process Improvements:
* Enhanced the build process for ONNX Runtime-GenAI to support guidance
mode for function calling and added a fallback mechanism if guidance
mode fails (`examples/slm_engine/build_scripts/build_deps.py`).
* Updated build scripts to include descriptive logging for
function-calling support
(`examples/slm_engine/build_scripts/build_deps.py`).
### Server Capabilities Update:
* Modified the SLM server to include "function_calling" as a capability
in its response, reflecting the new feature
(`examples/slm_engine/src/cpp/slm_server.cpp`).
These changes collectively enhance the SLM Engine's functionality,
making it more adaptable for use cases requiring intelligent function
invocation and robust build processes.1 parent 7adf3b7 commit 2f2ad90
File tree
13 files changed
+1552
-81
lines changed- examples/slm_engine
- build_scripts
- src
- cpp
- test
13 files changed
+1552
-81
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
323 | 401 | | |
324 | 402 | | |
325 | 403 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
215 | 216 | | |
216 | 217 | | |
217 | 218 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
333 | | - | |
| 334 | + | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| |||
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
343 | 348 | | |
344 | 349 | | |
345 | 350 | | |
| |||
368 | 373 | | |
369 | 374 | | |
370 | 375 | | |
371 | | - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
372 | 390 | | |
373 | 391 | | |
374 | 392 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| |||
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
71 | 82 | | |
72 | 83 | | |
73 | 84 | | |
| |||
89 | 100 | | |
90 | 101 | | |
91 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
92 | 106 | | |
93 | 107 | | |
94 | 108 | | |
| |||
0 commit comments