-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server-jetty): add adaptiveRAG test
- Loading branch information
1 parent
dd7be4e
commit 050c628
Showing
2 changed files
with
58 additions
and
0 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
42 changes: 42 additions & 0 deletions
42
server-jetty/src/test/java/org/bsc/langgraph4j/AdaptiveRAGStreamingServer.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,42 @@ | ||
package org.bsc.langgraph4j; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.PropertyAccessor; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import dev.langchain4j.adaptiverag.AdaptiveRag; | ||
import dev.langchain4j.agentexecutor.AgentExecutor; | ||
import dev.langchain4j.model.openai.OpenAiChatModel; | ||
|
||
import java.util.List; | ||
|
||
public class AdaptiveRAGStreamingServer { | ||
|
||
public static void main(String[] args) throws Exception { | ||
|
||
DotEnvConfig.load(); | ||
|
||
var openApiKey = DotEnvConfig.valueOf("OPENAI_API_KEY") | ||
.orElseThrow( () -> new IllegalArgumentException("no OPENAI API KEY provided!")); | ||
var tavilyApiKey = DotEnvConfig.valueOf("TAVILY_API_KEY") | ||
.orElseThrow( () -> new IllegalArgumentException("no TAVILY API KEY provided!")); | ||
|
||
var adaptiveRagTest = new AdaptiveRag( openApiKey, tavilyApiKey); | ||
|
||
var app = adaptiveRagTest.buildGraph(); | ||
|
||
// [Serializing with Jackson (JSON) - getting "No serializer found"?](https://stackoverflow.com/a/8395924/521197) | ||
// ObjectMapper objectMapper = new ObjectMapper(); | ||
// objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); | ||
|
||
var server = LangGraphStreamingServer.builder() | ||
.port(8080) | ||
//.objectMapper(objectMapper) | ||
.title("ADAPTIVE RAG EXECUTOR") | ||
.addInputStringArg("question") | ||
.build(app); | ||
|
||
server.start().join(); | ||
|
||
} | ||
|
||
} |