-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Add completion start time timestamp to relevant generators #8728
Open
vblagoje
wants to merge
6
commits into
main
Choose a base branch
from
add_completion_start_time
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github-actions
bot
added
topic:tests
type:documentation
Improvements on the docs
labels
Jan 16, 2025
Pull Request Test Coverage Report for Build 12810835892Details
💛 - Coveralls |
vblagoje
requested review from
dfokina and
anakin87
and removed request for
a team
January 16, 2025 12:50
vblagoje
changed the title
feat: Add completion start time timestamp to relevant chat generators
feat: Add completion start time timestamp to relevant generators
Jan 16, 2025
anakin87
reviewed
Jan 16, 2025
Comment on lines
+278
to
+285
meta = { | ||
"finish_reason": finish_reason if finish_reason else None, | ||
"received_at": datetime.now().isoformat(), | ||
} | ||
chunks_meta.append(meta) | ||
|
||
if first_chunk_time is None: | ||
first_chunk_time = meta["received_at"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
meta = { | |
"finish_reason": finish_reason if finish_reason else None, | |
"received_at": datetime.now().isoformat(), | |
} | |
chunks_meta.append(meta) | |
if first_chunk_time is None: | |
first_chunk_time = meta["received_at"] | |
meta = {} | |
if finish_reason: | |
meta["finish_reason"] = finish_reason | |
if first_chunk_time is None: | |
first_chunk_time = datetime.now().isoformat() |
Do you see any problems with this simpler approach?
Comment on lines
+228
to
+236
chunk_metadata = { | ||
**asdict(token), | ||
**(asdict(chunk.details) if chunk.details else {}), | ||
"received_at": datetime.now().isoformat(), | ||
} | ||
|
||
if first_chunk_time is None: | ||
first_chunk_time = chunk_metadata["received_at"] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above - could we simplify it?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why:
Enhances Langfuse integration to track the time-to-first-token (TTFT) in streaming responses. The new entry in chat message metadata
completion_start_time
enables TTFT tracking in Langfuse. We'll separately update all other relevant generators in https://github.com/deepset-ai/haystack-core-integrations/What:
completion_start_time
metadata in theHugging Face API
andOpenAI
chat and non-chat generators to record the TTFT.completion_start_time
and its format correctness.How can it be used:
This change allows developers to track the exact start time of streaming completions, aiding in performance diagnostics
How did you test it:
Included updated unit tests for both
Hugging Face API
andOpenAI
chat and non-chat generators to ensure the presence and correct ISO format ofcompletion_start_time
metadata. These tests verify that the timestamps are recorded and formatted correctly during streaming responses.Notes for the reviewer:
Ensure close attention to the new metadata handling and its correctness across different components. Testing has validated the format, but real integration checks are recommended for full assurance.