-
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
Add default prompt to ppl tool #125
Add default prompt to ppl tool #125
Conversation
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
@@ -373,4 +405,20 @@ private String parseOutput(String llmOutput, String indexName) { | |||
return ppl; | |||
} | |||
|
|||
private String loadDefaultPrompt(PPLModelType pplModelType) { |
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.
Now we read the resource every time when invoke creating PPLTool. It would be more efficient if we only read them once and store the prompts at static fields
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.
Already move it to static.
Signed-off-by: xinyual <[email protected]>
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #125 +/- ##
============================================
+ Coverage 80.82% 80.83% +0.01%
- Complexity 193 195 +2
============================================
Files 13 13
Lines 975 1002 +27
Branches 130 133 +3
============================================
+ Hits 788 810 +22
- Misses 137 141 +4
- Partials 50 51 +1 ☔ View full report in Codecov by Sentry. |
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
try { | ||
defaultPromptDict = loadDefaultPromptDict(); | ||
} catch (IOException e) { | ||
throw new RuntimeException("fail to load default prompt dict" + e.getMessage()); |
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.
Is it possible that this would break the plugin initialization process with this error thrown?
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.
You're right. Already change the logic to init the dict to an empty dict and log an error here.
this.contextPrompt = contextPrompt; | ||
this.pplModelType = PPLModelType.from(pplModelType); | ||
if (contextPrompt.isEmpty()) { | ||
this.contextPrompt = this.defaultPromptDict.getOrDefault(this.pplModelType.toString(), ""); |
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.
Is it possible this pplModelType.toString() produce NPE?
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.
Since we init the modeltype with the default value, the model type should be an object or throw an error. So it shouldn't be a NPE.
Signed-off-by: xinyual <[email protected]>
Signed-off-by: xinyual <[email protected]>
cd2717b
to
a8c673a
Compare
Signed-off-by: xinyual <[email protected]>
Force push since we decide not to add abstract prompt class this time. |
FINETUNE; | ||
|
||
public static PPLModelType from(String value) { | ||
if (value.isEmpty()) { |
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.
Is value possibly be null?
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.
No, when create ppltool object, we use (String) map.getOrDefault("model_type", "")
So model type string will have default value.
* add default prompt for ppl tool Signed-off-by: xinyual <[email protected]> * fix Upper problem Signed-off-by: xinyual <[email protected]> * change wrong information Signed-off-by: xinyual <[email protected]> * remove uesless log Signed-off-by: xinyual <[email protected]> * add corresponding UTs Signed-off-by: xinyual <[email protected]> * apply spotless Signed-off-by: xinyual <[email protected]> * use locale instead Signed-off-by: xinyual <[email protected]> * move dict to static Signed-off-by: xinyual <[email protected]> * move dict to static Signed-off-by: xinyual <[email protected]> * replace throw error with error log Signed-off-by: xinyual <[email protected]> * add default value for PPL model type Signed-off-by: xinyual <[email protected]> * apply spotless Signed-off-by: xinyual <[email protected]> --------- Signed-off-by: xinyual <[email protected]> (cherry picked from commit 7e4c8d5) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* add default prompt for ppl tool * fix Upper problem * change wrong information * remove uesless log * add corresponding UTs * apply spotless * use locale instead * move dict to static * move dict to static * replace throw error with error log * add default value for PPL model type * apply spotless --------- (cherry picked from commit 7e4c8d5) Signed-off-by: xinyual <[email protected]> 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>
…roject#129) * add default prompt for ppl tool * fix Upper problem * change wrong information * remove uesless log * add corresponding UTs * apply spotless * use locale instead * move dict to static * move dict to static * replace throw error with error log * add default value for PPL model type * apply spotless --------- (cherry picked from commit 7e4c8d5) Signed-off-by: xinyual <[email protected]> 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> Signed-off-by: yuye-aws <[email protected]>
Description
add default prompt to ppl tool
Issues Resolved
add default prompt to ppl tool. So customer don't need to add very low context prompt in their request body.
Check List
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.