-
Notifications
You must be signed in to change notification settings - Fork 56
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
Some fixes on model server #362
base: main
Are you sure you want to change the base?
Conversation
nehcgs
commented
Jan 8, 2025
- Improve logging
- Clean up code and fix tests
- A little bit refactor
- Add simple formatting support
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.
Shuguang - thanks for putting this PR together. I've some comments. Please let me know if you have any questions about them.
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.
Thanks for the update, left some comments around logging format. Please take a look at it and let me know if you have any questions.
) | ||
else: | ||
messages = self._process_messages( | ||
req.messages, req.tools, self.extra_instruction | ||
) | ||
|
||
handler_logs += f"\n - [request]: {json.dumps(messages)}" | ||
logger.info(f" - [request]: {json.dumps(messages)}") |
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.
json.dumps would dump tons of data to disk. Consider trimming it down for example you could do sth line this,
logger.info(f" - [request]: {json.dumps(messages)[:MAX_JSON_LEN]}")
Or better,
def trim_string(input_string, max_length=128):
if len(input_string) > max_length:
return input_string[:max_length] + "..."
return input_string
logger.info(f" - [request]: {trim_string(json.dumps(messages))}")
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.
All the data is necessary. Trimming it will have a negative impact on debugging. This is the input to the endpoint, and we should keep it.