-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: prompt token may be None in streaming mode #3462
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
base: main
Are you sure you want to change the base?
fix: prompt token may be None in streaming mode #3462
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello @wsa-2002, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a specific runtime error encountered in the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
1676512 to
d2c4f48
Compare
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.
Code Review
This pull request effectively resolves a TypeError that occurred when prompt_token_count was None in streaming mode. The solution, which involves adding a None check before setting the span attribute, is correct and aligns with existing checks for other metadata fields. The addition of a new unit test, test_trace_call_llm_with_no_usage_metadata, is excellent as it specifically validates this fix, ensuring the code is more robust. The changes are well-contained and address the reported issue properly.
d2c4f48 to
5ea026e
Compare
|
Hi @wsa-2002 , Thanks for your contribution. |
5ea026e to
9751b33
Compare
|
Hi @ryanaiagent |
|
Hi @wsa-2002 ,Your PR has been received by the team and is currently under review. |
|
Hi @ankursharmas , can you please review this. |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
Problem:
When using adk in streaming mode,
usage_metadata.prompt_token_countmay beNonewhich will emit logInvalid type NoneType for attribute 'gen_ai.usage.input_tokens' value. Expected one of ['bool', 'str', 'bytes', 'int', 'float'] or a sequence of those typesSolution:
Skip setting span attribute if prompt token count is None
Unit Tests:
Please include a summary of passed
pytestresults.Checklist