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

[Feature/agent_framework] Registers a single agent with multiple tools #198

Conversation

owaiskazi19
Copy link
Member

@owaiskazi19 owaiskazi19 commented Nov 26, 2023

Description

This PR has couple of new functionalities:

  1. ToolStep for registering a tool.
  2. RegisterAgentStep to register an agent.
  3. Handled parsing for Number types for WorkflowNode.
  4. Handled special case parsing for llm field
"llm": {
                        "model_id": "ldzS04kBxRPZ5cnWrqpd",
                        "parameters": {
                            "stop_when_no_tool_found": "true",
                            "max_iteration": "5"
                        }
                    }
  1. Fixes CI for feature branch after repo name change.
  2. Removed stale GetTask class.

TODO:

  1. Fetch a modelId from previous step and add it in the parameter field of ToolStep.
  2. This PR just creates a single agent. To create multiple agent and distinguish them, a nodeID should be passed with the <List<WorkflowData>> param in execute method and that nodeID can be used to store the response with the agent_id.
  3. For the steps we are storing the modelId in response, need to attach the nodeId to make that modelId unique in the map of WorkflowData.

Request:

{
    "name": "tool-register-agent",
    "description": "test case",
    "use_case": "REGISTER_AGENT",
    "version": {
        "template": "1.0.0",
        "compatibility": [
            "2.12.0",
            "3.0.0"
        ]
    },
    "workflows": {
        "provision": {
            "nodes": [
                {
                    "id": "workflow_step_1",
                    "type": "tool",
                    "user_inputs": {
                        "name": "MLModelTool",
                        "type": "MLModelTool",
                        "alias": "language_model_tool",
                        "description": "A general tool to answer any question. But it can't handle math problem",
                        "parameters": {
                            "model_id": "ldzS04kBxRPZ5cnWrqpd",
                            "prompt": "Answer the question as best you can.",
                            "response_filter": "choices[0].message.content"
                        }
                    }
                },
                {
                    "id": "workflow_step_2",
                    "type": "tool",
                    "user_inputs": {
                        "name": "MathTool",
                        "type": "MathTool",
                        "description": "A general tool to calculate any math problem. The action input must be valid math expression, like 2+3",
                        "parameters": {
                            "max_iteration": 5
                        }
                    }
                },
                {
                    "id": "workflow_step_3",
                    "type": "register_agent",
                    "previous_node_inputs": {
                        "workflow_step_1": "tools",
                        "workflow_step_2": "tools"
                    },
                    "user_inputs": {
                        "name": "Test_Agent_For_CoT",
                        "type": "cot",
                        "description": "this is a test agent",
                        "parameters": {"hello": "world"},
                        "llm": {
                            "model_id": "ldzS04kBxRPZ5cnWrqpd",
                            "parameters": {
                                "max_iteration": "5",
                                "stop_when_no_tool_found": "true"
                            }
                        },
                        "memory": {
                            "type": "conversation_buffer_window"
                        },
                        "app_type": "chatbot",
                        "created_time": 1689793598499,
                        "last_updated_time": 1689793598530
                    }
                }
            ],
            "edges": [
                {
                    "source": "workflow_step_1",
                    "dest": "workflow_step_3"
                },
                {
                    "source": "workflow_step_2",
                    "dest": "workflow_step_3"
                }
            ]
        }
    }
}

Response from the Logs:

[2023-11-26T10:19:25,300][INFO ][o.o.c.s.ClusterSettings  ] [ip-172-31-56-214] updating [plugins.flow_framework.enabled] from [false] to [true]
[2023-11-26T10:19:27,560][INFO ][o.o.f.t.CreateWorkflowTransportAction] [ip-172-31-56-214] create state workflow doc
[2023-11-26T10:19:33,327][INFO ][o.o.m.c.MLSyncUpCron     ] [ip-172-31-56-214] ML configuration already initialized, no action needed
[2023-11-26T10:19:33,427][INFO ][o.o.f.t.ProvisionWorkflowTransportAction] [ip-172-31-56-214] Queueing process [workflow_step_1]. Can start immediately!
[2023-11-26T10:19:33,427][INFO ][o.o.f.t.ProvisionWorkflowTransportAction] [ip-172-31-56-214] Queueing process [workflow_step_2]. Can start immediately!
[2023-11-26T10:19:33,427][INFO ][o.o.f.w.ProcessNode      ] [ip-172-31-56-214] Starting workflow_step_1.
[2023-11-26T10:19:33,428][INFO ][o.o.f.t.ProvisionWorkflowTransportAction] [ip-172-31-56-214] Queueing process [workflow_step_3]. Must wait for [workflow_step_1, workflow_step_2] to complete first.
[2023-11-26T10:19:33,428][INFO ][o.o.f.w.ProcessNode      ] [ip-172-31-56-214] Starting workflow_step_2.
[2023-11-26T10:19:33,429][INFO ][o.o.f.w.ProcessNode      ] [ip-172-31-56-214] Finished workflow_step_2.
[2023-11-26T10:19:33,429][INFO ][o.o.f.w.ProcessNode      ] [ip-172-31-56-214] Finished workflow_step_1.
[2023-11-26T10:19:33,429][INFO ][o.o.f.w.ProcessNode      ] [ip-172-31-56-214] Starting workflow_step_3.
[2023-11-26T10:19:33,447][INFO ][o.o.f.w.RegisterAgentStep] [ip-172-31-56-214] Remote Agent registration successful
[2023-11-26T10:19:33,448][INFO ][o.o.f.w.ProcessNode      ] [ip-172-31-56-214] Finished workflow_step_3.
[2023-11-26T10:19:33,448][INFO ][o.o.f.t.ProvisionWorkflowTransportAction] [ip-172-31-56-214] Provisioning completed successuflly for workflow CQIkC4wBYEMl9cSlJcWP
[2023-11-26T10:19:33,453][INFO ][o.o.f.t.ProvisionWorkflowTransportAction] [ip-172-31-56-214] updated workflow CQIkC4wBYEMl9cSlJcWP state to PROVISIONING

Issues Resolved

Fixes #196
Part of #194

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.

@owaiskazi19 owaiskazi19 changed the title [Feature/agent_framework_dev] Register a single agent with multiple tools [Feature/agent_framework] Register a single agent with multiple tools Nov 26, 2023
@owaiskazi19 owaiskazi19 changed the title [Feature/agent_framework] Register a single agent with multiple tools [Feature/agent_framework] Registers a single agent with multiple tools Nov 26, 2023
Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

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

First pass

@owaiskazi19 owaiskazi19 force-pushed the register-agent branch 2 times, most recently from 18e331e to 952e825 Compare November 30, 2023 02:01
@owaiskazi19 owaiskazi19 marked this pull request as ready for review November 30, 2023 02:05
@joshpalis
Copy link
Member

@owaiskazi19 Regarding the workflow_step_3 user inputs, why is there a separate parameters field outside of the llm field. I do not see this anywhere in the chain of thought agent documentation

"user_inputs": {
                        "name": "Test_Agent_For_CoT",
                        "type": "cot",
                        "description": "this is a test agent",
                        "parameters": {"hello": "world"},
                        "llm": {
                            "model_id": "ldzS04kBxRPZ5cnWrqpd",
                            "parameters": {
                                "max_iteration": "5",
                                "stop_when_no_tool_found": "true"
                            }
                        },
                        "memory": {
                            "type": "conversation_buffer_window"
                        },
                        "app_type": "chatbot",
                        "created_time": 1689793598499,
                        "last_updated_time": 1689793598530
                    }

@owaiskazi19
Copy link
Member Author

owaiskazi19 commented Nov 30, 2023

@owaiskazi19 Regarding the workflow_step_3 user inputs, why is there a separate parameters field outside of the llm field. I do not see this anywhere in the chain of thought agent documentation

@joshpalis That's how it's here. These params are of the agent and params under llm are model related params.

Copy link
Member

@joshpalis joshpalis left a comment

Choose a reason for hiding this comment

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

Overall looks good to me, just a question

Copy link
Member

@amitgalitz amitgalitz left a comment

Choose a reason for hiding this comment

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

LGTM, as long as other comments are resolved

Copy link
Member

@joshpalis joshpalis left a comment

Choose a reason for hiding this comment

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

LGTM thanks Owais for addressing my comments

Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
@owaiskazi19 owaiskazi19 merged commit 10d0840 into opensearch-project:feature/agent_framework Nov 30, 2023
10 checks passed
dbwiddis pushed a commit to dbwiddis/flow-framework that referenced this pull request Dec 15, 2023
opensearch-project#198)

* Initial register agent workflow step

Signed-off-by: Owais Kazi <[email protected]>

* Added tools step

Signed-off-by: Owais Kazi <[email protected]>

* Fixed ClassCastException

Signed-off-by: Owais Kazi <[email protected]>

* Handled exception for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Added type Instant for WorklowNode Parser

Signed-off-by: Owais Kazi <[email protected]>

* Removed created and last updated time

Signed-off-by: Owais Kazi <[email protected]>

* Addressed parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing of Long values for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Handled nested object for llm key

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Another attempt to fix parsing error for llm

Signed-off-by: Owais Kazi <[email protected]>

* Another attemp to fix XContent

Signed-off-by: Owais Kazi <[email protected]>

* Fixed Parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Added tests for toolstep and javadocs

Signed-off-by: Owais Kazi <[email protected]>

* Undo CI changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Handled interface changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressed conflicts

Signed-off-by: Owais Kazi <[email protected]>

* Added TODO

Signed-off-by: Owais Kazi <[email protected]>

---------

Signed-off-by: Owais Kazi <[email protected]>
dbwiddis pushed a commit that referenced this pull request Dec 18, 2023
#198)

* Initial register agent workflow step

Signed-off-by: Owais Kazi <[email protected]>

* Added tools step

Signed-off-by: Owais Kazi <[email protected]>

* Fixed ClassCastException

Signed-off-by: Owais Kazi <[email protected]>

* Handled exception for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Added type Instant for WorklowNode Parser

Signed-off-by: Owais Kazi <[email protected]>

* Removed created and last updated time

Signed-off-by: Owais Kazi <[email protected]>

* Addressed parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing of Long values for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Handled nested object for llm key

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Another attempt to fix parsing error for llm

Signed-off-by: Owais Kazi <[email protected]>

* Another attemp to fix XContent

Signed-off-by: Owais Kazi <[email protected]>

* Fixed Parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Added tests for toolstep and javadocs

Signed-off-by: Owais Kazi <[email protected]>

* Undo CI changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Handled interface changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressed conflicts

Signed-off-by: Owais Kazi <[email protected]>

* Added TODO

Signed-off-by: Owais Kazi <[email protected]>

---------

Signed-off-by: Owais Kazi <[email protected]>
dbwiddis pushed a commit to dbwiddis/flow-framework that referenced this pull request Dec 18, 2023
opensearch-project#198)

* Initial register agent workflow step

Signed-off-by: Owais Kazi <[email protected]>

* Added tools step

Signed-off-by: Owais Kazi <[email protected]>

* Fixed ClassCastException

Signed-off-by: Owais Kazi <[email protected]>

* Handled exception for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Added type Instant for WorklowNode Parser

Signed-off-by: Owais Kazi <[email protected]>

* Removed created and last updated time

Signed-off-by: Owais Kazi <[email protected]>

* Addressed parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing of Long values for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Handled nested object for llm key

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Another attempt to fix parsing error for llm

Signed-off-by: Owais Kazi <[email protected]>

* Another attemp to fix XContent

Signed-off-by: Owais Kazi <[email protected]>

* Fixed Parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Added tests for toolstep and javadocs

Signed-off-by: Owais Kazi <[email protected]>

* Undo CI changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Handled interface changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressed conflicts

Signed-off-by: Owais Kazi <[email protected]>

* Added TODO

Signed-off-by: Owais Kazi <[email protected]>

---------

Signed-off-by: Owais Kazi <[email protected]>
dbwiddis pushed a commit that referenced this pull request Dec 18, 2023
#198)

* Initial register agent workflow step

Signed-off-by: Owais Kazi <[email protected]>

* Added tools step

Signed-off-by: Owais Kazi <[email protected]>

* Fixed ClassCastException

Signed-off-by: Owais Kazi <[email protected]>

* Handled exception for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Added type Instant for WorklowNode Parser

Signed-off-by: Owais Kazi <[email protected]>

* Removed created and last updated time

Signed-off-by: Owais Kazi <[email protected]>

* Addressed parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing of Long values for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Handled nested object for llm key

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Another attempt to fix parsing error for llm

Signed-off-by: Owais Kazi <[email protected]>

* Another attemp to fix XContent

Signed-off-by: Owais Kazi <[email protected]>

* Fixed Parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Added tests for toolstep and javadocs

Signed-off-by: Owais Kazi <[email protected]>

* Undo CI changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Handled interface changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressed conflicts

Signed-off-by: Owais Kazi <[email protected]>

* Added TODO

Signed-off-by: Owais Kazi <[email protected]>

---------

Signed-off-by: Owais Kazi <[email protected]>
dbwiddis pushed a commit to dbwiddis/flow-framework that referenced this pull request Dec 18, 2023
opensearch-project#198)

* Initial register agent workflow step

Signed-off-by: Owais Kazi <[email protected]>

* Added tools step

Signed-off-by: Owais Kazi <[email protected]>

* Fixed ClassCastException

Signed-off-by: Owais Kazi <[email protected]>

* Handled exception for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Added type Instant for WorklowNode Parser

Signed-off-by: Owais Kazi <[email protected]>

* Removed created and last updated time

Signed-off-by: Owais Kazi <[email protected]>

* Addressed parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing of Long values for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Handled nested object for llm key

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Another attempt to fix parsing error for llm

Signed-off-by: Owais Kazi <[email protected]>

* Another attemp to fix XContent

Signed-off-by: Owais Kazi <[email protected]>

* Fixed Parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Added tests for toolstep and javadocs

Signed-off-by: Owais Kazi <[email protected]>

* Undo CI changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Handled interface changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressed conflicts

Signed-off-by: Owais Kazi <[email protected]>

* Added TODO

Signed-off-by: Owais Kazi <[email protected]>

---------

Signed-off-by: Owais Kazi <[email protected]>
dbwiddis pushed a commit to dbwiddis/flow-framework that referenced this pull request Dec 18, 2023
opensearch-project#198)

* Initial register agent workflow step

Signed-off-by: Owais Kazi <[email protected]>

* Added tools step

Signed-off-by: Owais Kazi <[email protected]>

* Fixed ClassCastException

Signed-off-by: Owais Kazi <[email protected]>

* Handled exception for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Added type Instant for WorklowNode Parser

Signed-off-by: Owais Kazi <[email protected]>

* Removed created and last updated time

Signed-off-by: Owais Kazi <[email protected]>

* Addressed parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing of Long values for Instant

Signed-off-by: Owais Kazi <[email protected]>

* Handled nested object for llm key

Signed-off-by: Owais Kazi <[email protected]>

* Handled parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Another attempt to fix parsing error for llm

Signed-off-by: Owais Kazi <[email protected]>

* Another attemp to fix XContent

Signed-off-by: Owais Kazi <[email protected]>

* Fixed Parsing error

Signed-off-by: Owais Kazi <[email protected]>

* Added tests for toolstep and javadocs

Signed-off-by: Owais Kazi <[email protected]>

* Undo CI changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Addressing PR comments

Signed-off-by: Owais Kazi <[email protected]>

* Handled interface changes

Signed-off-by: Owais Kazi <[email protected]>

* Addressed conflicts

Signed-off-by: Owais Kazi <[email protected]>

* Added TODO

Signed-off-by: Owais Kazi <[email protected]>

---------

Signed-off-by: Owais Kazi <[email protected]>
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.

4 participants