Updated the Plugin-API version to 0.1.4.1
Fixed entryPoint in plugin.json added the getting of tools added tools: - TestTool: sends back "This is a test tool" - TestToolAdvance: sends a "pong" back with the content of the "ping"
This commit is contained in:
+2
-1
@@ -8,6 +8,7 @@ version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven {
|
||||
url = "https://git.server.4zellen.se/api/packages/neurodock/maven"
|
||||
name = "gitea"
|
||||
@@ -19,7 +20,7 @@ dependencies {
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
|
||||
|
||||
compileOnly("me.neurodock:Plugin-API:0.1.2")
|
||||
compileOnly("me.neurodock:Plugin-API:0.1.4.1")
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.neurodock.example.plugin;
|
||||
import me.neurodock.plugin.Plugin;
|
||||
import me.neurodock.plugin.PluginMetadata;
|
||||
import me.neurodock.plugin.annotations.PluginEntryPoint;
|
||||
import me.neurodock.plugin.tool.Tool;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@PluginEntryPoint
|
||||
@@ -21,4 +22,12 @@ public class TestPlugin extends Plugin {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tool[] getTools() {
|
||||
return new Tool[]{
|
||||
new TestTool(this),
|
||||
new TestToolAdvance(this)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package me.neurodock.example.plugin;
|
||||
|
||||
import me.neurodock.plugin.Plugin;
|
||||
import me.neurodock.plugin.exceptions.ToolRuntimeException;
|
||||
import me.neurodock.plugin.tool.Tool;
|
||||
import me.neurodock.plugin.tool.ToolArguments;
|
||||
import me.neurodock.plugin.tool.ToolParameters;
|
||||
import me.neurodock.plugin.tool.ToolResponse;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TestTool extends Tool {
|
||||
/**
|
||||
* A base contructor, as the {@link Plugin} is used within this class
|
||||
*
|
||||
* @param plugin The plugin that owns this tool
|
||||
*/
|
||||
public TestTool(Plugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String name() {
|
||||
return "test_tool";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ToolParameters parameters() {
|
||||
return ToolParameters.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolResponse callTool(ToolArguments arguments) throws ToolRuntimeException {
|
||||
return new ToolResponse(name(), "This is a test tool.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.neurodock.example.plugin;
|
||||
|
||||
import me.neurodock.plugin.Plugin;
|
||||
import me.neurodock.plugin.exceptions.ToolRuntimeException;
|
||||
import me.neurodock.plugin.tool.Tool;
|
||||
import me.neurodock.plugin.tool.ToolArguments;
|
||||
import me.neurodock.plugin.tool.ToolParameters;
|
||||
import me.neurodock.plugin.tool.ToolResponse;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TestToolAdvance extends Tool {
|
||||
public TestToolAdvance(Plugin plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String name() {
|
||||
return "ping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ToolParameters parameters() {
|
||||
return ToolParameters.builder()
|
||||
.addProperty("message", ToolParameters.ToolParametersBuilder.Type.STRING, "the message to ping with", true)
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ToolResponse callTool(ToolArguments toolArguments) throws ToolRuntimeException {
|
||||
if(!toolArguments.hasArgument("message")) throw new ToolRuntimeException(name(), "Missing message");
|
||||
return new ToolResponse(name(), "pong: "+toolArguments.getArgument("message"));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"entryPoint": "me.neurodock.example.plugin",
|
||||
"entryPoint": "me.neurodock.example.plugin.TestPlugin",
|
||||
"name": "test"
|
||||
}
|
||||
Reference in New Issue
Block a user