Commit 650f26b
feat: use reasoning field in StreamingChunk for Google GenAI (#2900)
* feat: use reasoning field in StreamingChunk for Google GenAI
Populate StreamingChunk.reasoning with ReasoningContent instead of
storing reasoning deltas as dicts in meta. Update aggregation to read
from chunk.reasoning instead of chunk.meta["reasoning_deltas"].
* refactor: move thought_signature_deltas from meta to ReasoningContent.extra
Store thought_signature_deltas in ReasoningContent.extra instead of
StreamingChunk.meta when reasoning content is present, grouping all
reasoning-related info into ReasoningContent. For text/tool-call chunks
(where StreamingChunk mutual exclusivity prevents setting both content
and reasoning), signatures remain in meta. The aggregation logic reads
from both sources. Consistent with the Anthropic approach in PR #2849.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* test: use real Google API objects in thought chunk test
Replace Mock objects with actual types.Part, types.Content,
types.Candidate and types.GenerateContentResponse in the
test_convert_google_chunk_to_streaming_chunk_with_thought test,
following the pattern established in the existing real_example test.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* refactor: always store thought_signature_deltas in meta
Thought signatures can appear in both reasoning and non-reasoning response
parts, so storing them consistently in meta is simpler than splitting
between ReasoningContent.extra and meta.
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent fe43eca commit 650f26b
2 files changed
Lines changed: 59 additions & 23 deletions
File tree
- integrations/google_genai
- src/haystack_integrations/components/generators/google_genai/chat
- tests
Lines changed: 16 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
| 558 | + | |
559 | 559 | | |
560 | 560 | | |
561 | 561 | | |
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
614 | 613 | | |
615 | 614 | | |
616 | 615 | | |
617 | 616 | | |
618 | 617 | | |
619 | | - | |
620 | 618 | | |
621 | 619 | | |
622 | 620 | | |
623 | 621 | | |
624 | 622 | | |
625 | 623 | | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
| 624 | + | |
| 625 | + | |
631 | 626 | | |
632 | 627 | | |
633 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
634 | 633 | | |
635 | | - | |
| 634 | + | |
636 | 635 | | |
637 | 636 | | |
638 | 637 | | |
639 | 638 | | |
640 | 639 | | |
641 | 640 | | |
| 641 | + | |
642 | 642 | | |
643 | 643 | | |
644 | 644 | | |
| |||
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
665 | | - | |
666 | | - | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
672 | 668 | | |
673 | 669 | | |
674 | 670 | | |
| |||
Lines changed: 43 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
492 | 535 | | |
493 | 536 | | |
494 | 537 | | |
| |||
515 | 558 | | |
516 | 559 | | |
517 | 560 | | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | 561 | | |
522 | 562 | | |
523 | 563 | | |
| |||
0 commit comments