Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Some fixes on model server #362

wants to merge 8 commits into from

Conversation

nehcgs
Copy link
Contributor

@nehcgs nehcgs commented Jan 8, 2025

  1. Improve logging
  2. Clean up code and fix tests
  3. A little bit refactor
  4. Add simple formatting support

@nehcgs nehcgs requested a review from adilhafeez January 8, 2025 23:02
Copy link
Contributor

@adilhafeez adilhafeez left a 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.

model_server/src/cli.py Show resolved Hide resolved
model_server/src/commons/utils.py Outdated Show resolved Hide resolved
model_server/src/commons/utils.py Show resolved Hide resolved
model_server/src/core/function_calling.py Outdated Show resolved Hide resolved
model_server/src/core/function_calling.py Show resolved Hide resolved
model_server/src/core/guardrails.py Outdated Show resolved Hide resolved
model_server/src/main.py Show resolved Hide resolved
model_server/src/main.py Outdated Show resolved Hide resolved
model_server/src/main.py Outdated Show resolved Hide resolved
model_server/src/main.py Outdated Show resolved Hide resolved
@nehcgs nehcgs requested a review from adilhafeez January 9, 2025 01:00
Copy link
Contributor

@adilhafeez adilhafeez left a 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.

model_server/src/commons/utils.py Outdated Show resolved Hide resolved
model_server/src/core/function_calling.py Outdated Show resolved Hide resolved
model_server/src/core/function_calling.py Outdated Show resolved Hide resolved
)
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)}")
Copy link
Contributor

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))}")

Copy link
Contributor Author

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.

@nehcgs nehcgs requested a review from adilhafeez January 9, 2025 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants