-
Notifications
You must be signed in to change notification settings - Fork 30
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
Mock http server for LLM; Integration test for visualization tool #92
Conversation
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #92 +/- ##
============================================
+ Coverage 81.29% 83.68% +2.39%
- Complexity 152 187 +35
============================================
Files 12 13 +1
Lines 882 944 +62
Branches 115 128 +13
============================================
+ Hits 717 790 +73
Misses 106 106
+ Partials 59 48 -11 ☔ View full report in Codecov by Sentry. |
return JsonParser.parseString(resp).getAsJsonObject().get("model_id").getAsString(); | ||
} | ||
|
||
private String setupConversationalAgent(String modelId) throws IOException { |
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 think a flow agent is enough to cover tool IT test like
String agentId = createAgent(registerAgentRequestBody); |
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 are right, conversational agent is used to test mock LLM server. To run integration test for tools, flow agent is enough.
} | ||
|
||
String response(String prompt) { | ||
if (prompt.contains("TOOL RESPONSE: ")) { |
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.
Will this TOOL RESPONSE:
be used when writing actual ITs for a tool? If so, should we extract it to a common constant?
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.
That depends. For most tools that use flow agent to do integration test, they will not interact with LLM. This default implementation is used to test conversational agent flow with mock LLM server. Based on this assumption, we can leave it as is.
static class ToolInput { | ||
String question; | ||
String toolType; | ||
String toolInput; |
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.
Can we change toolType and toolInput to action and actionInput to be consistency?
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.
sure, good suggestion.
StringBuilder sb = new StringBuilder(); | ||
|
||
try (BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))) { | ||
String line; | ||
while ((line = br.readLine()) != null) { | ||
sb.append(line); | ||
} | ||
} | ||
return sb.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 to use third party method like IOUtils.toString()
to simplify this code block?
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.
done, update to OpenSearch built-in class instead org.opensearch.common.io.Streams.readAllLines(ins)
Signed-off-by: Hailong Cui <[email protected]>
* mock server and integTest for visualization Signed-off-by: Hailong Cui <[email protected]> * update rest status Signed-off-by: Hailong Cui <[email protected]> * add refresh Signed-off-by: Hailong Cui <[email protected]> * merge from main Signed-off-by: Hailong Cui <[email protected]> * rename variable name Signed-off-by: Hailong Cui <[email protected]> --------- Signed-off-by: Hailong Cui <[email protected]> (cherry picked from commit 4c76e4c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
… (#102) * mock server and integTest for visualization * update rest status * add refresh * merge from main * rename variable name --------- (cherry picked from commit 4c76e4c) Signed-off-by: Hailong Cui <[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>
…ensearch-project#92) (opensearch-project#102) * mock server and integTest for visualization * update rest status * add refresh * merge from main * rename variable name --------- (cherry picked from commit 4c76e4c) Signed-off-by: Hailong Cui <[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
Issues Resolved
[List any issues this PR will resolve]
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.