Skip to content

Commit

Permalink
refactor: upgrade to langchain4j 0.33.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Jul 29, 2024
1 parent 7082a1f commit afaf327
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public static ChromaStore of(String openApiKey) {
private final ChromaEmbeddingStore chroma = new ChromaEmbeddingStore(
"http://localhost:8000",
"rag-chroma",
Duration.ofMinutes(2) );
Duration.ofMinutes(2),
true,
true );
private final OpenAiEmbeddingModel embeddingModel;

private ChromaStore( String openApiKey ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ public void RetrievalGraderTest() {
ChromaEmbeddingStore chroma = new ChromaEmbeddingStore(
"http://localhost:8000",
"rag-chroma",
Duration.ofMinutes(2) );
Duration.ofMinutes(2),
true,
true);
OpenAiEmbeddingModel embeddingModel = OpenAiEmbeddingModel.builder()
.apiKey(openApiKey)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public void connect() throws Exception {
ChromaEmbeddingStore chroma = new ChromaEmbeddingStore(
"http://localhost:8000",
"rag-chroma",
Duration.ofMinutes(2) );
Duration.ofMinutes(2),
true,
true);

OpenAiEmbeddingModel embeddingModel = OpenAiEmbeddingModel.builder()
.apiKey(openApiKey)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package dev.langchain4j.agentexecutor;

import dev.langchain4j.agent.tool.DefaultToolExecutor;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolExecutor;
import dev.langchain4j.agent.tool.ToolSpecification;
import dev.langchain4j.service.tool.DefaultToolExecutor;
import dev.langchain4j.service.tool.ToolExecutor;
import lombok.NonNull;
import lombok.Value;
import lombok.experimental.Accessors;
Expand All @@ -18,7 +18,7 @@
@Value
@Accessors( fluent = true)
public class ToolInfo {
@NonNull ToolSpecification specification;
@NonNull ToolSpecification specification;
@NonNull ToolExecutor executor;

public static List<ToolInfo> of( Object ...objectsWithTools) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package dev.langchain4j.image_to_diagram;

import com.google.gson.Gson;
import dev.langchain4j.model.output.OutputParser;
import lombok.var;

import java.util.regex.Pattern;

public class DiagramOutputParser implements OutputParser<Diagram.Element> {
@Override
public class DiagramOutputParser {
public Diagram.Element parse(String s) {
// String pattern = "```json\n(.*?)\n```";
String pattern = "```json\n(.*?)\n```";
Expand All @@ -26,9 +24,4 @@ public Diagram.Element parse(String s) {
var gson = new Gson();
return gson.fromJson(matcher.group(1), Diagram.Element.class);
}

@Override
public String formatInstructions() {
return "extract json from markdown text";
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<langchai4j.version>0.31.0</langchai4j.version>
<langchai4j.version>0.33.0</langchai4j.version>
</properties>

<distributionManagement>
Expand Down

0 comments on commit afaf327

Please sign in to comment.