-
-
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.
configure tools using environment variables
- Loading branch information
1 parent
2f79905
commit 8efe803
Showing
10 changed files
with
175 additions
and
10 deletions.
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
...c/main/kotlin/io/github/alexcheng1982/agentappbuilder/core/tool/ToolExecutionException.kt
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,9 @@ | ||
package io.github.alexcheng1982.agentappbuilder.core.tool | ||
|
||
class ToolExecutionException( | ||
private val tool: AgentTool<*, *>, | ||
cause: Throwable? | ||
) : RuntimeException(cause) { | ||
override val message: String | ||
get() = "Execution error in tool ${tool.name()}" | ||
} |
45 changes: 45 additions & 0 deletions
45
...o/github/alexcheng1982/agentappbuilder/core/tool/EnvironmentVariableConfigProviderTest.kt
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,45 @@ | ||
package io.github.alexcheng1982.agentappbuilder.core.tool | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import uk.org.webcompere.systemstubs.SystemStubs.withEnvironmentVariable | ||
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension | ||
import kotlin.properties.Delegates | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNotNull | ||
|
||
@ExtendWith(SystemStubsExtension::class) | ||
class EnvironmentVariableConfigProviderTest { | ||
|
||
class TestConfig { | ||
lateinit var value: String | ||
var intValue by Delegates.notNull<Int>() | ||
var longValue by Delegates.notNull<Long>() | ||
var doubleValue by Delegates.notNull<Double>() | ||
var floatValue by Delegates.notNull<Float>() | ||
} | ||
|
||
class TestConfigProvider : | ||
EnvironmentVariableConfigProvider<TestConfig>( | ||
TestConfig::class.java, | ||
"testConfig_" | ||
) | ||
|
||
@Test | ||
fun testConfigProvider() { | ||
withEnvironmentVariable("testConfig_value", "hello") | ||
.and("testConfig_intValue", "100") | ||
.and("testConfig_longValue", "1000") | ||
.and("testConfig_doubleValue", "1.01") | ||
.and("testConfig_floatValue", "2.02") | ||
.execute { | ||
val config = TestConfigProvider().get() | ||
assertNotNull(config) | ||
assertEquals("hello", config.value) | ||
assertEquals(100, config.intValue) | ||
assertEquals(1000, config.longValue) | ||
assertEquals(1.01, config.doubleValue) | ||
assertEquals(2.02f, config.floatValue) | ||
} | ||
} | ||
} |
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
11 changes: 10 additions & 1 deletion
11
...ava/io/github/alexcheng1982/agentappbuilder/tool/writelocalfile/WriteLocalFileConfig.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 |
---|---|---|
@@ -1,5 +1,14 @@ | ||
package io.github.alexcheng1982.agentappbuilder.tool.writelocalfile; | ||
|
||
public record WriteLocalFileConfig(String basePath) { | ||
public class WriteLocalFileConfig { | ||
|
||
private String basePath; | ||
|
||
public String getBasePath() { | ||
return basePath; | ||
} | ||
|
||
public void setBasePath(String basePath) { | ||
this.basePath = basePath; | ||
} | ||
} |
3 changes: 2 additions & 1 deletion
3
...va/io/github/alexcheng1982/agentappbuilder/tool/writelocalfile/WriteLocalFileRequest.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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package io.github.alexcheng1982.agentappbuilder.tool.writelocalfile; | ||
|
||
public record WriteLocalFileRequest(String filename, String url, | ||
public record WriteLocalFileRequest(String filename, | ||
String url, | ||
String content) { | ||
|
||
} |
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
6 changes: 3 additions & 3 deletions
6
...o/github/alexcheng1982/agentappbuilder/tool/writelocalfile/WriteLocalFileToolFactory.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
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