forked from opensearch-project/ml-commons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstract tool support to create ML agent tools
Signed-off-by: Arjun kumar Giri <arjung@amazon.com>
- Loading branch information
1 parent
2b04af5
commit 27af0c7
Showing
7 changed files
with
92 additions
and
163 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
ml-algorithms/src/main/java/org/opensearch/ml/engine/tools/AbstractTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.opensearch.ml.engine.tools; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.opensearch.ml.common.spi.tools.Parser; | ||
import org.opensearch.ml.common.spi.tools.Tool; | ||
|
||
import java.util.Map; | ||
|
||
public abstract class AbstractTool implements Tool { | ||
|
||
/** | ||
* Name of the tool to be used in prompt. | ||
*/ | ||
@Setter | ||
@Getter | ||
private String name; | ||
|
||
/** | ||
* Default description of the tool. This description will be used by LLM to select next tool to execute. | ||
*/ | ||
@Getter | ||
@Setter | ||
private String description; | ||
|
||
/** | ||
* Tool type mapping to the corresponding run function. Tool type will be used by agent framework to identify the tool. | ||
*/ | ||
@Getter | ||
private String type; | ||
|
||
/** | ||
* Current tool version. | ||
*/ | ||
@Getter | ||
protected String version; | ||
|
||
/** | ||
* Parser used to read tool input. | ||
*/ | ||
@Setter | ||
protected Parser inputParser; | ||
|
||
/** | ||
* Parser used to write tool output. | ||
*/ | ||
@Setter | ||
protected Parser outputParser; | ||
|
||
/** | ||
* Default tool constructor. | ||
* | ||
* @param type | ||
* @param name | ||
* @param description | ||
*/ | ||
protected AbstractTool(String type, String name, String description) { | ||
this.type = type; | ||
this.name = name; | ||
this.description = description; | ||
} | ||
|
||
protected AbstractTool(String type, String description) { | ||
this(type, type, description); | ||
} | ||
|
||
/** | ||
* Validate tool input and check if request could be processed by the tool. | ||
* | ||
* @param parameters | ||
* @return | ||
*/ | ||
@Override | ||
public abstract boolean validate(Map<String, String> parameters); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.