Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'java-library'
id 'org.springframework.boot'
id 'com.google.cloud.tools.jib' version '3.5.3'
alias(libs.plugins.jib)
}

dependencies {
Expand All @@ -22,7 +22,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-restclient'
implementation 'org.springframework.boot:spring-boot-starter-webmvc'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'io.pebbletemplates:pebble-spring-boot-starter:4.1.1'
implementation(libs.pebble.spring.starter)

developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
Expand All @@ -34,8 +34,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-websocket-test'
testImplementation 'org.springframework.boot:spring-boot-testcontainers'
testImplementation 'org.testcontainers:testcontainers-junit-jupiter'

testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

bootRun {
Expand Down
11 changes: 5 additions & 6 deletions base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,22 @@ plugins {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.modulith:spring-modulith-starter-core'
implementation 'org.jobrunr:jobrunr-spring-boot-4-starter:8.5.1'
implementation(libs.jobrunr.spring.starter)
implementation 'org.apache.commons:commons-lang3'
implementation 'com.fasterxml.jackson.core:jackson-core'

// No idea?
runtimeOnly 'io.netty:netty-resolver-dns-native-macos:4.2.10.Final'
runtimeOnly(libs.netty.resolver.dns.native.macos)

implementation 'org.springframework.ai:spring-ai-client-chat'
implementation 'org.springframework.ai:spring-ai-starter-mcp-client'

implementation 'org.springaicommunity:spring-ai-agent-utils:0.6.0-SNAPSHOT'
implementation 'org.springaicommunity:tool-search-tool:2.0.1'
implementation 'org.springaicommunity:tool-searcher-lucene:2.0.1'
implementation(libs.spring.ai.agent.utils)
implementation(libs.spring.ai.tool.search)
implementation(libs.spring.ai.tool.search.lucene)

runtimeOnly 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.testcontainers:testcontainers-junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Scheduler;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.SequencedSet;
import java.util.*;

/**
* A copy of Springs MessageChatMemoryAdvisor that does not add duplicate messages from memory if they are contained in the chatClientRequest.prompt().getInstructions()
Expand All @@ -28,18 +25,14 @@ public final class MessageChatMemoryAdvisor implements BaseChatMemoryAdvisor {

private final ChatMemory chatMemory;

private final String defaultConversationId;

private final int order;

private final Scheduler scheduler;

private MessageChatMemoryAdvisor(ChatMemory chatMemory, String defaultConversationId, int order, Scheduler scheduler) {
private MessageChatMemoryAdvisor(ChatMemory chatMemory, int order, Scheduler scheduler) {
Assert.notNull(chatMemory, "chatMemory cannot be null");
Assert.hasText(defaultConversationId, "defaultConversationId cannot be null or empty");
Assert.notNull(scheduler, "scheduler cannot be null");
this.chatMemory = chatMemory;
this.defaultConversationId = defaultConversationId;
this.order = order;
this.scheduler = scheduler;
}
Expand All @@ -56,7 +49,7 @@ public Scheduler getScheduler() {

@Override
public ChatClientRequest before(ChatClientRequest chatClientRequest, AdvisorChain advisorChain) {
String conversationId = getConversationId(chatClientRequest.context(), this.defaultConversationId);
String conversationId = getConversationId(chatClientRequest.context());

List<Message> instructions = chatClientRequest.prompt().getInstructions();

Expand Down Expand Up @@ -96,7 +89,7 @@ public ChatClientResponse after(ChatClientResponse chatClientResponse, AdvisorCh
.map(g -> (Message) g.getOutput())
.toList();
}
this.chatMemory.add(this.getConversationId(chatClientResponse.context(), this.defaultConversationId),
this.chatMemory.add(this.getConversationId(chatClientResponse.context()),
assistantMessages);
return chatClientResponse;
}
Expand All @@ -122,8 +115,6 @@ public static Builder builder(ChatMemory chatMemory) {

public static final class Builder {

private String conversationId = ChatMemory.DEFAULT_CONVERSATION_ID;

private int order = Advisor.DEFAULT_CHAT_MEMORY_PRECEDENCE_ORDER;

private Scheduler scheduler = BaseAdvisor.DEFAULT_SCHEDULER;
Expand All @@ -134,17 +125,6 @@ private Builder(ChatMemory chatMemory) {
this.chatMemory = chatMemory;
}

/**
* Set the conversation id.
*
* @param conversationId the conversation id
* @return the builder
*/
public Builder conversationId(String conversationId) {
this.conversationId = conversationId;
return this;
}

/**
* Set the order.
*
Expand All @@ -167,7 +147,7 @@ public Builder scheduler(Scheduler scheduler) {
* @return the advisor
*/
public MessageChatMemoryAdvisor build() {
return new MessageChatMemoryAdvisor(this.chatMemory, this.conversationId, this.order, this.scheduler);
return new MessageChatMemoryAdvisor(this.chatMemory, this.order, this.scheduler);
}

}
Expand Down
22 changes: 7 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
id 'org.springframework.boot' version '4.0.3' apply false
id 'io.spring.dependency-management' version '1.1.7' apply false
alias(libs.plugins.spring.boot) apply false
}

description = 'JavaClaw'
Expand All @@ -22,22 +21,15 @@ allprojects {

// Explicitly configure only real projects
configure(subprojects.findAll { it.buildFile.exists() }) {
apply plugin: 'io.spring.dependency-management'
plugins.withType(JavaPlugin).configureEach {
dependencies {
implementation(platform(libs.bom.spring.boot))
implementation(platform(libs.bom.spring.ai))
implementation(platform(libs.bom.spring.modulith))

ext {
springAiVersion = '2.0.0-SNAPSHOT'
springModulithVersion = '2.0.3'
}

dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:4.0.3"
mavenBom "org.springframework.ai:spring-ai-bom:2.0.0-SNAPSHOT"
mavenBom "org.springframework.modulith:spring-modulith-bom:2.0.3"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
}

plugins.withType(JavaPlugin) {
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
Expand Down
31 changes: 31 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[versions]
spring-boot = "4.0.6"
tool-search = "2.1.0"
telegrambots = "9.5.0"
commonmark = "0.28.0"

[libraries]
bom-spring-boot = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "spring-boot" }
bom-spring-ai = { module = "org.springframework.ai:spring-ai-bom", version = "2.0.0-M6" }
bom-spring-modulith = { module = "org.springframework.modulith:spring-modulith-bom", version = "2.0.6" }

spring-ai-agent-utils = { module = "org.springaicommunity:spring-ai-agent-utils", version = "0.7.0" }
spring-ai-tool-search = { module = "org.springaicommunity:tool-search-tool", version.ref = "tool-search" }
spring-ai-tool-search-lucene = { module = "org.springaicommunity:tool-searcher-lucene", version.ref = "tool-search" }

netty-resolver-dns-native-macos = { module = "io.netty:netty-resolver-dns-native-macos", version = "4.2.12.Final" }
jobrunr-spring-starter = { module = "org.jobrunr:jobrunr-spring-boot-4-starter", version = "8.6.0"}
pebble-spring-starter = { module = "io.pebbletemplates:pebble-spring-boot-starter", version = "4.1.1" }
java-discord-api = { module = "net.dv8tion:JDA", version = "6.4.1" }
playwright = { module = "com.microsoft.playwright:playwright", version = "1.52.0" }
telegrambots-client = { module = "org.telegram:telegrambots-client", version.ref = "telegrambots" }
telegrambots-springboot-longpolling-starter = { module = "org.telegram:telegrambots-springboot-longpolling-starter", version.ref = "telegrambots" }
commonmark-java = { module = "org.commonmark:commonmark", version.ref = "commonmark" }
commonmark-ext-gfm-strikethrough = { module = "org.commonmark:commonmark-ext-gfm-strikethrough", version.ref = "commonmark" }

[bundles]


[plugins]
spring-boot = { id = "org.springframework.boot", version.ref = "spring-boot" }
jib = { id = "com.google.cloud.tools.jib", version = "3.5.3" }
3 changes: 1 addition & 2 deletions plugins/brave/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ plugins {
dependencies {
implementation project(':base')
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springaicommunity:spring-ai-agent-utils:0.6.0-SNAPSHOT'
implementation(libs.spring.ai.agent.utils)

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-restclient-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
3 changes: 1 addition & 2 deletions plugins/discord/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ plugins {
dependencies {
implementation project(':base')
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'net.dv8tion:JDA:6.1.1'
implementation(libs.java.discord.api)

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
3 changes: 1 addition & 2 deletions plugins/playwright/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ dependencies {
implementation project(':base')
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.ai:spring-ai-client-chat'
implementation 'com.microsoft.playwright:playwright:1.52.0'
implementation(libs.playwright)

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
10 changes: 4 additions & 6 deletions plugins/telegram/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ plugins {
dependencies {
implementation project(':base')
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.telegram:telegrambots-springboot-longpolling-starter:9.4.0'
implementation 'org.telegram:telegrambots-client:9.4.0'

implementation 'org.commonmark:commonmark:0.21.0'
implementation 'org.commonmark:commonmark-ext-gfm-strikethrough:0.21.0'
implementation(libs.telegrambots.client)
implementation(libs.telegrambots.springboot.longpolling.starter)
implementation(libs.commonmark.java)
implementation(libs.commonmark.ext.gfm.strikethrough)

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
1 change: 0 additions & 1 deletion providers/anthropic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ dependencies {
implementation 'org.springframework.ai:spring-ai-starter-model-anthropic'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public AnthropicChatModel anthropicChatModel(AnthropicConnectionProperties conne
}

private static AnthropicChatOptions getAnthropicChatOptions(AnthropicConnectionProperties connectionProperties, AnthropicChatProperties chatProperties) {
AnthropicChatOptions options = chatProperties.getOptions();
if (connectionProperties.getApiKey() != null) options.setApiKey(connectionProperties.getApiKey());
if (connectionProperties.getBaseUrl() != null) options.setBaseUrl(connectionProperties.getBaseUrl());
if (connectionProperties.getTimeout() != null) options.setTimeout(connectionProperties.getTimeout());
if (connectionProperties.getMaxRetries() != null) options.setMaxRetries(connectionProperties.getMaxRetries());
if (connectionProperties.getProxy() != null) options.setProxy(connectionProperties.getProxy());
if (!connectionProperties.getCustomHeaders().isEmpty()) options.setCustomHeaders(connectionProperties.getCustomHeaders());
return options;
AnthropicChatOptions.Builder options = chatProperties.toOptions().mutate();
if (connectionProperties.getApiKey() != null) options.apiKey(connectionProperties.getApiKey());
if (connectionProperties.getBaseUrl() != null) options.baseUrl(connectionProperties.getBaseUrl());
if (connectionProperties.getTimeout() != null) options.timeout(connectionProperties.getTimeout());
if (connectionProperties.getMaxRetries() != null) options.maxRetries(connectionProperties.getMaxRetries());
if (connectionProperties.getProxy() != null) options.proxy(connectionProperties.getProxy());
if (!connectionProperties.getCustomHeaders().isEmpty()) options.customHeaders(connectionProperties.getCustomHeaders());
return options.build();
}

private static AnthropicClient anthropicClient(AnthropicChatOptions options, AnthropicClaudeCodeBackend backend) {
Expand Down
1 change: 0 additions & 1 deletion providers/google/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ dependencies {
implementation 'org.springframework.ai:spring-ai-starter-model-google-genai'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
1 change: 0 additions & 1 deletion providers/ollama/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ dependencies {
implementation 'org.springframework.ai:spring-ai-starter-model-ollama'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
1 change: 0 additions & 1 deletion providers/openai/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ dependencies {
implementation 'org.springframework.ai:spring-ai-starter-model-openai'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
Loading