Skip to content

chore!: Update finish reason in output of HuggingFaceAPIChatGenerator to match between stream and non-stream modes #9686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 11, 2025

Conversation

sjrl
Copy link
Contributor

@sjrl sjrl commented Aug 6, 2025

Related Issues

Proposed Changes:

In this previous PR, we introduced a finish_reason field to StreamingChunk. When used with the HuggingFaceAPIChatGenerator, this new field was included in the meta of the returned ChatMessage. However, the update only applied when streaming was enabled. If streaming was disabled, the old finish_reason was still returned. This PR fixes that by ensuring the updated finish_reason is used even when streaming is off.

How did you test it?

  • Updated unit tests

Notes for the reviewer

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added unit tests and updated the docstrings
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test: and added ! in case the PR includes breaking changes.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

@coveralls
Copy link
Collaborator

coveralls commented Aug 6, 2025

Pull Request Test Coverage Report for Build 16878499788

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 38 unchanged lines in 6 files lost coverage.
  • Overall coverage increased (+0.01%) to 91.969%

Files with Coverage Reduction New Missed Lines %
components/embedders/sentence_transformers_document_embedder.py 2 96.97%
dataclasses/chat_message.py 2 99.32%
utils/jinja2_chat_extension.py 2 98.13%
components/embedders/hugging_face_api_document_embedder.py 3 96.52%
components/generators/chat/hugging_face_api.py 9 95.41%
components/embedders/openai_document_embedder.py 20 67.72%
Totals Coverage Status
Change from base Build 16832785234: 0.01%
Covered Lines: 12838
Relevant Lines: 13959

💛 - Coveralls

@sjrl sjrl changed the title fix: Update finish reason in output of HuggingFaceAPIChatGenerator to match between stream and non-stream modes chore!: Update finish reason in output of HuggingFaceAPIChatGenerator to match between stream and non-stream modes Aug 11, 2025
@sjrl sjrl marked this pull request as ready for review August 11, 2025 07:39
@sjrl sjrl requested a review from a team as a code owner August 11, 2025 07:39
@sjrl sjrl requested review from Amnah199 and removed request for a team August 11, 2025 07:39
…2a079733e8.yaml

Co-authored-by: Amna Mubashar <amnahkhan.ak@gmail.com>
@github-actions github-actions bot added the type:documentation Improvements on the docs label Aug 11, 2025
Copy link
Contributor

@Amnah199 Amnah199 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG!

@sjrl sjrl merged commit af9aac2 into main Aug 11, 2025
21 checks passed
@sjrl sjrl deleted the update-finish-reason-hf-api-chat-gen branch August 11, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update finish_reason values in HuggingFaceAPIChatGenerator
3 participants