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

Mock http server for LLM; Integration test for visualization tool #92

Merged
merged 5 commits into from
Jan 3, 2024

Conversation

Hailong-am
Copy link
Contributor

Description

  1. mock LLM
  2. integration test for visualization tool

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.

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Copy link

codecov bot commented Jan 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (34ae75f) 81.29% compared to head (0bb88eb) 83.68%.
Report is 4 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

return JsonParser.parseString(resp).getAsJsonObject().get("model_id").getAsString();
}

private String setupConversationalAgent(String modelId) throws IOException {
Copy link
Collaborator

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);

Copy link
Contributor Author

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: ")) {
Copy link
Collaborator

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?

Copy link
Contributor Author

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;
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, good suggestion.

Comment on lines 216 to 224
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();
Copy link
Collaborator

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?

Copy link
Contributor Author

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]>
@zane-neo zane-neo merged commit 4c76e4c into opensearch-project:main Jan 3, 2024
13 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 3, 2024
* 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>
xinyual pushed a commit that referenced this pull request Jan 4, 2024
… (#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>
yuye-aws pushed a commit to yuye-aws/skills that referenced this pull request Apr 26, 2024
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants