-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
jetty/src/test/java/org/bsc/langgraph4j/AgentExecutorStreamingServer.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,2 @@ | ||
package org.bsc.langgraph4j;public class AgentExecutorStreamingServer { | ||
} |
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,54 @@ | ||
package dev.langchain4j; | ||
|
||
|
||
import java.io.FileReader; | ||
import java.io.Reader; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
|
||
import static java.util.Optional.ofNullable; | ||
|
||
public interface DotEnvConfig { | ||
|
||
static void load() { | ||
|
||
// Search for .env file | ||
Path path = Paths.get(".").toAbsolutePath(); | ||
|
||
Path filePath = Paths.get( path.toString(), ".env"); | ||
|
||
for( int i=0; !filePath.toFile().exists(); ++i ) { | ||
path = path.getParent(); | ||
|
||
filePath = Paths.get(path.toString(), ".env"); | ||
|
||
if (i == 3) { | ||
throw new RuntimeException("no .env file found!"); | ||
} | ||
} | ||
|
||
// load .env contents in System.properties | ||
try { | ||
final java.util.Properties properties = new java.util.Properties(); | ||
|
||
try( Reader r = new FileReader(filePath.toFile())) { | ||
properties.load(r); | ||
} | ||
System.getProperties().putAll(properties); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
|
||
static Optional<String> valueOf(String key ) { | ||
String value = System.getenv(key); | ||
if (value == null) { | ||
value = System.getProperty(key); | ||
} | ||
return ofNullable(value); | ||
} | ||
|
||
|
||
} |
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,23 @@ | ||
package dev.langchain4j.agentexecutor; | ||
|
||
import dev.langchain4j.agent.tool.P; | ||
import dev.langchain4j.agent.tool.Tool; | ||
|
||
import java.util.Optional; | ||
|
||
import static java.lang.String.format; | ||
|
||
public class TestTool { | ||
private String lastResult; | ||
|
||
Optional<String> lastResult() { | ||
return Optional.ofNullable(lastResult); | ||
} | ||
|
||
@Tool("tool for test AI agent executor") | ||
String execTest(@P("test message") String message) { | ||
|
||
lastResult = format( "test tool executed: %s", message); | ||
return lastResult; | ||
} | ||
} |