-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Bugfix] input prompt was not logged #13936
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
[Bugfix] input prompt was not logged #13936
Conversation
Summary of ChangesHello @alphabetc1, 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 logging oversight where the actual text of input prompts was not being captured in logs under certain configurations, particularly when prompts were processed as token IDs. The changes ensure comprehensive logging of input prompts, improving debuggability and traceability for requests, and also refine the internal handling of prompt inputs to correctly determine batch sizes. 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
|
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 fixes a bug where the input prompt was not logged when using input_ids. The changes correctly add logic to decode and log the prompt text when necessary. Additionally, the change in io_struct.py to prioritize input_ids over text is a good improvement for consistency. I have one suggestion to make the logging check logic more concise.
| log_requests_level = getattr( | ||
| self.tokenizer_manager.server_args, "log_requests_level", 0 | ||
| ) | ||
| need_log_text = ( | ||
| getattr(self.tokenizer_manager.server_args, "log_requests", False) | ||
| and log_requests_level >= 2 | ||
| ) | ||
| if need_log_text: | ||
| prompt_kwargs["text"] = ( | ||
| processed_messages.prompt | ||
| or self.tokenizer_manager.tokenizer.decode( | ||
| processed_messages.prompt_ids | ||
| ) | ||
| ) |
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.
This logic for checking whether to log the prompt text can be made more concise. You can combine the getattr calls into a single if statement to improve readability and reduce the number of local variables.
server_args = self.tokenizer_manager.server_args
if (
getattr(server_args, "log_requests", False)
and getattr(server_args, "log_requests_level", 0) >= 2
):
prompt_kwargs["text"] = (
processed_messages.prompt
or self.tokenizer_manager.tokenizer.decode(
processed_messages.prompt_ids
)
)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.
D
d839826 to
16ae233
Compare
| ): | ||
| prompt_kwargs["text"] = ( | ||
| processed_messages.prompt | ||
| or self.tokenizer_manager.tokenizer.decode( |
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.
Do not do de-tokenization here.
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.
16ae233 to
ecb0955
Compare
| and obj.input_ids is not None | ||
| and self.tokenizer is not None | ||
| ): | ||
| decoded = self.tokenizer.decode(obj.input_ids, skip_special_tokens=False) |
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.
Add a #FIXME comment here, saying this can be moved elsewhere.
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.
D
…s-level was set to 2 or 3.
ecb0955 to
7cb0d64
Compare
|
/tag-and-rerun-ci |

Motivation
Input prompt was not logged when --log-requests was enabled and --log-requests-level was set to 2 or 3.
log was enabled:

while text is None:

after fix:

Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist