From baf31141683941c0c90b2a2b6b6b5de3a43f1d95 Mon Sep 17 00:00:00 2001 From: HamaWhiteGG Date: Thu, 30 Nov 2023 14:53:00 +0800 Subject: [PATCH 1/2] Fix dependency convergence errors #129 --- langchain-core/pom.xml | 48 ++++++++++++++++++++++++++++++-------- langchain-examples/pom.xml | 11 +++++++++ pom.xml | 13 ----------- 3 files changed, 49 insertions(+), 23 deletions(-) diff --git a/langchain-core/pom.xml b/langchain-core/pom.xml index 216ef6156..5246419fd 100644 --- a/langchain-core/pom.xml +++ b/langchain-core/pom.xml @@ -32,11 +32,28 @@ io.milvus milvus-sdk-java + provided org.apache.logging.log4j log4j-slf4j-impl + + com.google.protobuf + protobuf-java + + + com.squareup.okhttp3 + okhttp + + + io.grpc + grpc-context + + + com.google.errorprone + error_prone_annotations + @@ -133,27 +150,28 @@ org.redisson redisson + provided com.fasterxml.jackson.core jackson-core + + net.bytebuddy + byte-buddy + - - io.netty - netty-resolver - - - - io.netty - netty-resolver-dns - - io.projectreactor reactor-core + + + org.reactivestreams + reactive-streams + + @@ -169,6 +187,16 @@ com.google.api-client google-api-client + + + com.google.errorprone + error_prone_annotations + + + com.google.j2objc + j2objc-annotations + + diff --git a/langchain-examples/pom.xml b/langchain-examples/pom.xml index f40b70a31..0dea5cab8 100644 --- a/langchain-examples/pom.xml +++ b/langchain-examples/pom.xml @@ -37,6 +37,17 @@ awaitility compile + + + io.milvus + milvus-sdk-java + + + org.apache.logging.log4j + log4j-slf4j-impl + + + diff --git a/pom.xml b/pom.xml index 87e916ee4..1f09d3257 100644 --- a/pom.xml +++ b/pom.xml @@ -47,7 +47,6 @@ 4.4 8.0.0.Final 3.17.3 - 4.1.43.Final 3.5.8 3.5.1 3.12.4 @@ -266,18 +265,6 @@ ${redisson.version} - - io.netty - netty-resolver - ${netty-resolver.version} - - - - io.netty - netty-resolver-dns - ${netty-resolver.version} - - io.projectreactor reactor-core From 29ff7a5ad1b0c6dcb75b1c348d66248a3e875080 Mon Sep 17 00:00:00 2001 From: HamaWhiteGG Date: Thu, 30 Nov 2023 15:03:30 +0800 Subject: [PATCH 2/2] Update fromLLMAndTools method name #128 --- .../src/main/java/com/hw/langchain/agents/agent/Agent.java | 2 +- .../hw/langchain/agents/agent/BaseSingleActionAgent.java | 2 +- .../java/com/hw/langchain/agents/chat/base/ChatAgent.java | 6 +++--- .../java/com/hw/langchain/agents/initialize/Initialize.java | 2 +- .../com/hw/langchain/agents/mrkl/base/ZeroShotAgent.java | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/langchain-core/src/main/java/com/hw/langchain/agents/agent/Agent.java b/langchain-core/src/main/java/com/hw/langchain/agents/agent/Agent.java index f1c51a495..85d59bbf7 100644 --- a/langchain-core/src/main/java/com/hw/langchain/agents/agent/Agent.java +++ b/langchain-core/src/main/java/com/hw/langchain/agents/agent/Agent.java @@ -125,7 +125,7 @@ public Map getFullInputs(List> interme return fullInputs; } - public static BaseSingleActionAgent fromLlmAndTools( + public static BaseSingleActionAgent fromLLMAndTools( BaseLanguageModel llm, List tools, Map kwargs) { diff --git a/langchain-core/src/main/java/com/hw/langchain/agents/agent/BaseSingleActionAgent.java b/langchain-core/src/main/java/com/hw/langchain/agents/agent/BaseSingleActionAgent.java index 921f09254..96d02b3c9 100644 --- a/langchain-core/src/main/java/com/hw/langchain/agents/agent/BaseSingleActionAgent.java +++ b/langchain-core/src/main/java/com/hw/langchain/agents/agent/BaseSingleActionAgent.java @@ -55,7 +55,7 @@ public List returnValues() { */ public abstract AgentResult plan(List> intermediateSteps, Map kwargs); - public static BaseSingleActionAgent fromLlmAndTools( + public static BaseSingleActionAgent fromLLMAndTools( BaseLanguageModel llm, List tools, Map kwargs) { diff --git a/langchain-core/src/main/java/com/hw/langchain/agents/chat/base/ChatAgent.java b/langchain-core/src/main/java/com/hw/langchain/agents/chat/base/ChatAgent.java index 9ff48ac85..40583d268 100644 --- a/langchain-core/src/main/java/com/hw/langchain/agents/chat/base/ChatAgent.java +++ b/langchain-core/src/main/java/com/hw/langchain/agents/chat/base/ChatAgent.java @@ -111,15 +111,15 @@ public static BasePromptTemplate createPrompt(List tools, String syste * Construct an agent from an LLM and tools. * This method will be called by the {@link Initialize#initializeAgent} using MethodUtils.invokeStaticMethod. */ - public static Agent fromLlmAndTools(BaseLanguageModel llm, List tools, Map kwargs) { - return fromLlmAndTools(llm, tools, null, SYSTEM_MESSAGE_PREFIX, SYSTEM_MESSAGE_SUFFIX, HUMAN_MESSAGE, + public static Agent fromLLMAndTools(BaseLanguageModel llm, List tools, Map kwargs) { + return fromLLMAndTools(llm, tools, null, SYSTEM_MESSAGE_PREFIX, SYSTEM_MESSAGE_SUFFIX, HUMAN_MESSAGE, FORMAT_INSTRUCTIONS, null, kwargs); } /** * Construct an agent from an LLM and tools. */ - public static Agent fromLlmAndTools(BaseLanguageModel llm, List tools, AgentOutputParser outputParser, + public static Agent fromLLMAndTools(BaseLanguageModel llm, List tools, AgentOutputParser outputParser, String systemMessagePrefix, String systemMessageSuffix, String humanMessage, String formatInstructions, List inputVariables, Map kwargs) { validateTools(tools); diff --git a/langchain-core/src/main/java/com/hw/langchain/agents/initialize/Initialize.java b/langchain-core/src/main/java/com/hw/langchain/agents/initialize/Initialize.java index 5976e87d6..11c0e1895 100644 --- a/langchain-core/src/main/java/com/hw/langchain/agents/initialize/Initialize.java +++ b/langchain-core/src/main/java/com/hw/langchain/agents/initialize/Initialize.java @@ -80,7 +80,7 @@ public static AgentExecutor initializeAgent(List tools, BaseLanguageMo } Class clazz = AGENT_TO_CLASS.get(agent); agentKwargs = agentKwargs != null ? agentKwargs : Map.of(); - agentObj = (BaseSingleActionAgent) MethodUtils.invokeStaticMethod(clazz, "fromLlmAndTools", + agentObj = (BaseSingleActionAgent) MethodUtils.invokeStaticMethod(clazz, "fromLLMAndTools", llm, tools, agentKwargs); } else if (agentPath != null) { agentObj = loadAgent(agentPath, Map.of("llm", llm, "tools", tools)); diff --git a/langchain-core/src/main/java/com/hw/langchain/agents/mrkl/base/ZeroShotAgent.java b/langchain-core/src/main/java/com/hw/langchain/agents/mrkl/base/ZeroShotAgent.java index 8a1d888ac..21f555989 100644 --- a/langchain-core/src/main/java/com/hw/langchain/agents/mrkl/base/ZeroShotAgent.java +++ b/langchain-core/src/main/java/com/hw/langchain/agents/mrkl/base/ZeroShotAgent.java @@ -80,14 +80,14 @@ public static PromptTemplate createPrompt(List tools, String prefix, S /** * Construct an agent from an LLM and tools. */ - public static Agent fromLlmAndTools(BaseLanguageModel llm, List tools, Map kwargs) { - return fromLlmAndTools(llm, tools, null, PREFIX, SUFFIX, FORMAT_INSTRUCTIONS, null, kwargs); + public static Agent fromLLMAndTools(BaseLanguageModel llm, List tools, Map kwargs) { + return fromLLMAndTools(llm, tools, null, PREFIX, SUFFIX, FORMAT_INSTRUCTIONS, null, kwargs); } /** * Construct an agent from an LLM and tools. */ - public static Agent fromLlmAndTools(BaseLanguageModel llm, List tools, AgentOutputParser outputParser, + public static Agent fromLLMAndTools(BaseLanguageModel llm, List tools, AgentOutputParser outputParser, String prefix, String suffix, String formatInstructions, List inputVariables, Map kwargs) { validateTools(tools);