Skip to content

Commit

Permalink
feat(server-jetty): add adaptiveRAG test
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Jul 21, 2024
1 parent dd7be4e commit 050c628
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server-jetty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.bsc.langgraph4j</groupId>
<artifactId>langgraph4j-adaptive-rag</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -124,6 +131,15 @@
<mainClass>org.bsc.langgraph4j.AgentExecutorStreamingServer</mainClass>
</configuration>
</execution>
<execution>
<!-- exec:java@adaptiverag -->
<id>adaptiverag</id>
<goals><goal>java</goal></goals>
<configuration>
<classpathScope>test</classpathScope>
<mainClass>org.bsc.langgraph4j.AdaptiveRAGStreamingServer</mainClass>
</configuration>
</execution>
</executions>
<configuration>
</configuration>
Expand Down
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();

}

}

0 comments on commit 050c628

Please sign in to comment.