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

Add more information in log to help troubleshooting. #1847

Closed
wants to merge 6 commits into from

Conversation

xluo-aws
Copy link
Member

@xluo-aws xluo-aws commented Jan 9, 2024

Description

[Describe what this change achieves]

Issues Resolved

[List any issues this PR will resolve]

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

log.info("Fetching tool for type: " + toolType);

if (toolFactories.get(toolType) == null) {
log.error(toolType + " can't be found, please use ListTool API to check if it's deployed.");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need suggestions how we should exit gracefully if the tool suggested by LLM is not available.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjunkumargiri do you have any suggestion here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjunkumargiri, please take a look at here, it's important one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to logging, agent should respond back to LLM that the suggested tool is not available and to either use a different tool from the available list of tool or to generate response from the available data.

@jngz-es please let me know if you have any concerns.

@@ -149,7 +149,7 @@ public static String extractModelResponseJson(String text) {
if (matcher.find()) {
return matcher.group(1);
} else {
throw new IllegalArgumentException("Model output is invalid");
throw new IllegalArgumentException("Model output is invalid:" + text);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about: throw new IllegalArgumentException("Invalid model output: '" + text + "' does not meet the required criteria.");

@@ -145,7 +145,7 @@ public void run(MLAgent mlAgent, Map<String, String> params, ActionListener<Obje

runAgent(mlAgent, params, listener, memory, memory.getConversationId());
}, e -> {
log.error("Failed to get chat history", e);
log.error("Failed to runAgent " + mlAgent.getName(), e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run agent?

log.info("Fetching tool for type: " + toolType);

if (toolFactories.get(toolType) == null) {
log.error(toolType + " can't be found, please use ListTool API to check if it's deployed.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arjunkumargiri do you have any suggestion here?

Copy link
Collaborator

@sam-herman sam-herman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use of {} placeholder pattern is the standard in Java to avoid unnecessary String concatenation.

@@ -145,7 +145,7 @@ public void run(MLAgent mlAgent, Map<String, String> params, ActionListener<Obje

runAgent(mlAgent, params, listener, memory, memory.getConversationId());
}, e -> {
log.error("Failed to get chat history", e);
log.error("Failed to run agent " + mlAgent.getName(), e);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proper use of log facility needs to use placeholders pattern instead of concatenation or manual interpolation: log.error("Failed to run agent: {} ", mlAgent.getName(), e)

log.info("Fetching tool for type: " + toolSpec.getType());
Tool tool = toolFactories.get(toolSpec.getType()).create(executeParams);
String toolType = toolSpec.getType();
log.info("Fetching tool for type: " + toolType);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here. Please use pattern instead of manual concatenation of text in log message:
log.info("Fetching tool for type: {}", toolType);

log.info("Fetching tool for type: " + toolType);

if (toolFactories.get(toolType) == null) {
log.error(toolType + " can't be found, please use ListTool API to check if it's deployed.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, Please use pattern instead of manual concatenation of text in log message:
log.error("{} can't be found, please use ListTool API to check if it's deployed.", toolType);

@b4sjoo
Copy link
Collaborator

b4sjoo commented Jan 12, 2024

@xluo-aws Hi can you rebase with the main branch first and make the CI pass before we merge?

@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 16, 2024 03:44 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 16, 2024 03:44 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 16, 2024 03:44 — with GitHub Actions Inactive
@xluo-aws xluo-aws had a problem deploying to ml-commons-cicd-env January 16, 2024 03:44 — with GitHub Actions Failure
@xluo-aws
Copy link
Member Author

@xluo-aws Hi can you rebase with the main branch first and make the CI pass before we merge?

Waiting for instruction on one of the exceptional case handling.

Copy link
Collaborator

@sam-herman sam-herman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xluo-aws can you please address my comments regarding proper usage of Log4J facility with place holders? I would like to see these comments addressed before this PR gets merged.

For reference in case the earlier comments weren't clear this is what I am talking about:
https://stackoverflow.com/questions/30975026/log4j-implicit-string-formatting

@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:02 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:02 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:02 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:02 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:02 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:02 — with GitHub Actions Inactive
Copy link

codecov bot commented Jan 24, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.92%. Comparing base (d0895bb) to head (d766e0b).
Report is 348 commits behind head on main.

Files with missing lines Patch % Lines
.../ml/engine/algorithms/agent/MLChatAgentRunner.java 66.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1847      +/-   ##
============================================
- Coverage     82.94%   82.92%   -0.03%     
+ Complexity     5414     5412       -2     
============================================
  Files           521      521              
  Lines         21709    21712       +3     
  Branches       2213     2214       +1     
============================================
- Hits          18007    18005       -2     
- Misses         2807     2811       +4     
- Partials        895      896       +1     
Flag Coverage Δ
ml-commons 82.92% <71.42%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:29 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:29 — with GitHub Actions Inactive
@xluo-aws xluo-aws temporarily deployed to ml-commons-cicd-env January 24, 2024 03:29 — with GitHub Actions Inactive
@dhrubo-os
Copy link
Collaborator

@xluo-aws are you working on this issue?

@mingshl mingshl closed this Jan 10, 2025
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.

6 participants