Skip to content

Commit

Permalink
Update haystack/components/generators/chat/hugging_face_api.py
Browse files Browse the repository at this point in the history
Co-authored-by: Stefano Fiorucci <[email protected]>
  • Loading branch information
vblagoje and anakin87 authored Jan 17, 2025
1 parent 8e02206 commit 833e019
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions haystack/components/generators/chat/hugging_face_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,14 +275,12 @@ def _run_streaming(self, messages: List[Dict[str, str]], generation_kwargs: Dict

finish_reason = choice.finish_reason

meta = {
"finish_reason": finish_reason if finish_reason else None,
"received_at": datetime.now().isoformat(),
}
chunks_meta.append(meta)
meta = {}
if finish_reason:
meta["finish_reason"] = finish_reason

if first_chunk_time is None:
first_chunk_time = meta["received_at"]
first_chunk_time = datetime.now().isoformat()

stream_chunk = StreamingChunk(text, meta)
self.streaming_callback(stream_chunk) # type: ignore # streaming_callback is not None (verified in the run method)
Expand Down

0 comments on commit 833e019

Please sign in to comment.