-
Notifications
You must be signed in to change notification settings - Fork 33
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
Support pass prompt to CreateAlertTool #452
Support pass prompt to CreateAlertTool #452
Conversation
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
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.
Approved. Can @zane-neo review?
public enum ModelType { | ||
CLAUDE, | ||
OPENAI; | ||
|
||
public static ModelType from(String value) { | ||
if (value.isEmpty()) { | ||
return ModelType.CLAUDE; | ||
} | ||
try { | ||
return ModelType.valueOf(value.toUpperCase(Locale.ROOT)); | ||
} catch (Exception e) { | ||
log.error("Wrong Model type, should be CLAUDE or OPENAI"); | ||
return ModelType.CLAUDE; | ||
} | ||
} | ||
} |
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.
Wait a bit. The code is the same as the ModelType in PPL tool. Can you extract it outside the function for code reusage?
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.
They are not exactly the same, this tool doesn't support FINETUNE
model. If we want to reuse this method, we'd better refactor it as well and I think it should also applies to other tools like CreateAnomalyDetectorTool
.
So I don't think it's a blocker for this PR, we can do such refactor work in a separate PR.
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.
I see. Then the code is good.
); | ||
modelType = String.valueOf(ModelType.from(modelType)); | ||
if (prompt.isEmpty()) { | ||
if (!promptDict.containsKey(modelType)) { |
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.
The model type is enumerated, do we need to judge whether promptDict contains the model type?
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 is the right line for identify whether promptDict contains that model. It will throw exception if not having.
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 PR looks good to me. Pinging @xinyual to review again.
#457 @qianheng-aws This PR gets merged. Please update accordingly. |
Should this PR be the same as that change? I think there is no difference functionally. We already support empty model_type and return a default one. |
Well. I mean you can make the following code snippet public. Then, both CreateAlertTool and CreateAnomalyDetectorTool can import it.
|
I think that change should be made in the PR for refactoring code reuse. There is no help make it public for now. |
@qianheng-aws Seems CI/CD fails. Can you fix this? |
@qianheng-aws Spotless apply plz. |
Signed-off-by: Heng Qian <qianheng@amazon.com>
Signed-off-by: Heng Qian <qianheng@amazon.com>
Only 1 flakey test failure, which is unrelated as well: 71 tests completed, 1 failed
|
Pinging @xinyual to review this PR. |
@xinyual Plz attach backport-2.x label to this PR. |
* Support pass prompt to CreateAlertTool Signed-off-by: Heng Qian <qianheng@amazon.com> * Use Claude as ModelType if passed-in modelType is empty Signed-off-by: Heng Qian <qianheng@amazon.com> * Fix UT Signed-off-by: Heng Qian <qianheng@amazon.com> * Fix spotlessApply Signed-off-by: Heng Qian <qianheng@amazon.com> * Fix spotlessApply Signed-off-by: Heng Qian <qianheng@amazon.com> --------- Signed-off-by: Heng Qian <qianheng@amazon.com> Co-authored-by: zane-neo <zaniu@amazon.com> (cherry picked from commit a95cfae) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Support pass prompt to CreateAlertTool * Use Claude as ModelType if passed-in modelType is empty * Fix UT * Fix spotlessApply * Fix spotlessApply --------- (cherry picked from commit a95cfae) Signed-off-by: Heng Qian <qianheng@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: zane-neo <zaniu@amazon.com>
Description
This PR enhance the CreateAlertTool with 2 features:
Related Issues
Resolves #447
Check List
--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.