Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Update to new tool factory interface
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcheng1982 committed Oct 4, 2024
1 parent 219bd26 commit 310bfd6
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: "17"
java-version: "21"
distribution: "temurin"
cache: maven
- name: Build with Maven
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class JavaCodeExecutionConfig {

private String executable = "java";
private String executable;

private String workingDirectory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import org.slf4j.LoggerFactory

const val toolId = "executeJavaCode"

class JavaCodeExecutor(private val config: JavaCodeExecutionConfig) :
class JavaCodeExecutor(private val config: JavaCodeExecutionConfig?) :
NonSandboxedCodeExecutor() {
override fun executable(): String {
return config.executable
return config?.executable ?: "java"
}

override fun workingDirectory(): String? {
return config.workingDirectory
return config?.workingDirectory
}

override fun args(input: String): List<String> {
Expand All @@ -26,7 +26,7 @@ class JavaCodeExecutor(private val config: JavaCodeExecutionConfig) :
/**
* Tool to execute Java code
*/
class JavaCodeExecutionTool(config: JavaCodeExecutionConfig) :
class JavaCodeExecutionTool(config: JavaCodeExecutionConfig?) :
ConfigurableAgentTool<JavaCodeExecutionRequest, JavaCodeExecutionResponse, JavaCodeExecutionConfig> {

private val logger = LoggerFactory.getLogger(javaClass)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package io.github.llmagentbuilder.tool.javacodeexecution

import io.github.llmagentbuilder.core.tool.EnvironmentVariableConfigurableAgentToolFactory
import io.github.llmagentbuilder.core.tool.ConfigurableAgentToolFactory

class JavaCodeExecutionToolFactory :
EnvironmentVariableConfigurableAgentToolFactory<JavaCodeExecutionTool, JavaCodeExecutionConfig>(
JavaCodeExecutionConfig::class.java, "${toolId}_"
) {
override fun create(config: JavaCodeExecutionConfig): JavaCodeExecutionTool {
ConfigurableAgentToolFactory<JavaCodeExecutionConfig, JavaCodeExecutionTool> {
override fun create(config: JavaCodeExecutionConfig?): JavaCodeExecutionTool {
return JavaCodeExecutionTool(config)
}

override fun configName(): String {
override fun toolId(): String {
return toolId
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class PythonCodeExecutionConfig {

private String executable = "python";
private String executable;

private String workingDirectory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import org.slf4j.LoggerFactory

const val toolId = "executePythonCode"

class PythonCodeExecutor(private val config: PythonCodeExecutionConfig) :
class PythonCodeExecutor(private val config: PythonCodeExecutionConfig?) :
NonSandboxedCodeExecutor() {
override fun executable(): String {
return config.executable
return config?.executable ?: "python"
}

override fun workingDirectory(): String? {
return config.workingDirectory
return config?.workingDirectory
}

override fun args(input: String): List<String> {
Expand All @@ -26,7 +26,7 @@ class PythonCodeExecutor(private val config: PythonCodeExecutionConfig) :
/**
* Tool to execute Python code
*/
class PythonCodeExecutionTool(config: PythonCodeExecutionConfig) :
class PythonCodeExecutionTool(config: PythonCodeExecutionConfig?) :
ConfigurableAgentTool<PythonCodeExecutionRequest, PythonCodeExecutionResponse, PythonCodeExecutionConfig> {

private val logger = LoggerFactory.getLogger(javaClass)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package io.github.llmagentbuilder.tool.pythoncodeexecution

import io.github.llmagentbuilder.core.tool.EnvironmentVariableConfigurableAgentToolFactory
import io.github.llmagentbuilder.core.tool.ConfigurableAgentToolFactory

class PythonCodeExecutionToolFactory :
EnvironmentVariableConfigurableAgentToolFactory<PythonCodeExecutionTool, PythonCodeExecutionConfig>(
PythonCodeExecutionConfig::class.java, "${toolId}_"
) {
override fun create(config: PythonCodeExecutionConfig): PythonCodeExecutionTool {
ConfigurableAgentToolFactory<PythonCodeExecutionConfig, PythonCodeExecutionTool> {
override fun create(config: PythonCodeExecutionConfig?): PythonCodeExecutionTool {
return PythonCodeExecutionTool(config)
}

override fun configName(): String {
override fun toolId(): String {
return toolId
}
}

0 comments on commit 310bfd6

Please sign in to comment.