Commit 6a6ea3f
committed
Fix duplication with OpenAI Assistants pre-configured tools
Assistants lets you configure an agent with function signatures it's implicitly aware of, rather than them needing to be provided per request. That, however, creates complication for callers, as if they provide that function in ChatTools.Options, it leads to the function's signature being sent as part of the request, and the duplication of it with the pre-configured function signature results in an error. It's possible to work around this, by simply not including that function in the request, but it's a natural thing for a developer to do, especially if they want the function to be automatically invoked when the model requests it. You can achieve that by putting the function into the FunctionInvocationChatClient's AdditionalTools, which exists for this kind of purpose, but that's harder to discover.
Rather than try something more complicated, this commit simply deduplicates all tools by putting them into a set, deduplicating any duplicates provided.1 parent 22cbbb7 commit 6a6ea3f
File tree
1 file changed
+29
-7
lines changed- src/Libraries/Microsoft.Extensions.AI.OpenAI
1 file changed
+29
-7
lines changedLines changed: 29 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
309 | 311 | | |
310 | 312 | | |
311 | 313 | | |
| |||
318 | 320 | | |
319 | 321 | | |
320 | 322 | | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
| 323 | + | |
325 | 324 | | |
326 | 325 | | |
327 | 326 | | |
| |||
330 | 329 | | |
331 | 330 | | |
332 | 331 | | |
333 | | - | |
| 332 | + | |
334 | 333 | | |
335 | 334 | | |
336 | 335 | | |
337 | 336 | | |
338 | | - | |
| 337 | + | |
339 | 338 | | |
340 | 339 | | |
341 | 340 | | |
| |||
358 | 357 | | |
359 | 358 | | |
360 | 359 | | |
361 | | - | |
| 360 | + | |
362 | 361 | | |
363 | 362 | | |
364 | 363 | | |
| |||
374 | 373 | | |
375 | 374 | | |
376 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
377 | 381 | | |
378 | 382 | | |
379 | 383 | | |
| |||
543 | 547 | | |
544 | 548 | | |
545 | 549 | | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
546 | 568 | | |
0 commit comments