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

Support regenerate for execute API #1709

Conversation

Hailong-am
Copy link
Contributor

@Hailong-am Hailong-am commented Nov 29, 2023

Description

Support regenerate on existing interaction, regenerate_interaction_id and memory_id must be provide for regenerate case.

POST http://localhost:9200/_plugins/_ml/agents/MBWOSIwBAnQBpyKtmAkn/_execute
{
  "parameters": {
    "memory_id": "A5CgV4wBiufF8-BkxC0r",
    "regenerate_interaction_id": "BJCgV4wBiufF8-BkxC2b",
    "verbose": false
  }
}

Response

{
    "inference_results": [
        {
            "output": [
                {
                    "name": "response",
                    "dataAsMap": {
                        "response": "Your OpenSearch cluster contains many security audit log indices from late 2023, with most replicas in a yellow status. The cluster and index storage sizes and document counts appear normal.",
                        "additional_info": {}
                    }
                },
                {
                    "name": "QuestionSuggestor",
                    "result": "[\"What are some ways I can analyze these security audit logs further?\",\"Can you help me understand why the replicas are in yellow status?\"]"
                }
            ]
        }
    ]
}

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.

Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 57 lines in your changes are missing coverage. Please review.

Comparison is base (9155655) 69.78% compared to head (5c19d90) 69.56%.

Files Patch % Lines
...g/opensearch/ml/engine/memory/MLMemoryManager.java 0.00% 35 Missing ⚠️
...ch/ml/engine/algorithms/agent/MLAgentExecutor.java 53.84% 16 Missing and 2 partials ⚠️
.../ml/engine/algorithms/agent/MLChatAgentRunner.java 69.23% 4 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                        @@
##             feature/agent_framework_dev    #1709      +/-   ##
=================================================================
- Coverage                          69.78%   69.56%   -0.23%     
- Complexity                          2660     2667       +7     
=================================================================
  Files                                244      244              
  Lines                              12977    13036      +59     
  Branches                            1305     1309       +4     
=================================================================
+ Hits                                9056     9068      +12     
- Misses                              3303     3347      +44     
- Partials                             618      621       +3     
Flag Coverage Δ
ml-commons 69.56% <34.48%> (-0.23%) ⬇️

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.

Comment on lines 111 to 118
// for regenerate, original interaction id must provide
String regenerateInteractionId = params.get(REGENERATE_INTERACTION_ID);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can interaction regeneration logic be handled in MLAgenExecutor instead of Chat agent? In future there could be new agent types and we should not re-implement regeneration logic in each agent type

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arjunkumargiri Instead of put logic in MLAgenExecutor, we can have a base class for all kinds of agent runner, put common logic in that class would make more sense.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@arjunkumargiri Since the root interaction been moved to MLAgentRunner,regenerate is coupled with root interaction, move the logic to that class also.

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

Add includeToolputInAgentResponse flag

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

Apply spotless

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

address review comments

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

address review comments

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]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env December 18, 2023 07:23 — with GitHub Actions Inactive
@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env December 18, 2023 07:23 — with GitHub Actions Inactive
@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env December 18, 2023 07:23 — with GitHub Actions Inactive
@Hailong-am Hailong-am temporarily deployed to ml-commons-cicd-env December 18, 2023 07:23 — with GitHub Actions Inactive
String appType = mlAgent.getAppType();
String question = inputDataSet.getParameters().get(QUESTION);

if (memoryId == null && regenerateInteractionId != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if both are null? Do we still want to continue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if regenerateInteractionId is null, it's a normal flow, memory will automatically create if needed

dhrubo-os
dhrubo-os previously approved these changes Dec 19, 2023
@Hailong-am Hailong-am changed the base branch from feature/agent_framework_dev to main December 27, 2023 06:45
@Hailong-am Hailong-am dismissed dhrubo-os’s stale review December 27, 2023 06:45

The base branch was changed.

@Hailong-am Hailong-am changed the base branch from main to feature/agent_framework_dev December 27, 2023 06:47
@Hailong-am
Copy link
Contributor Author

done in #1816

@Hailong-am Hailong-am closed this Jan 2, 2024
@Hailong-am Hailong-am deleted the regenerate branch January 11, 2024 07:58
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.

5 participants