Skip to content

[WIP] Proof of Concept integration with LangChain4j #102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

glaforge
Copy link

[DON'T MERGE]

This is a proof of concept of an integration with LangChain4j, to show that it's possible to open up ADK to all the models supported by the LangChain4j framework.

@cornellgit
Copy link
Collaborator

This is awesome, created a contrib/ folder, we can put it there first then gradually iterate.

@glaforge
Copy link
Author

@cornellgit Good idea, my contribution will make more sense in a contrib folder! 😉

@glaforge
Copy link
Author

@cornellgit Moved my WIP experiment in the new contrib directory.
Haven't touched yet the implementation itself, there's still a fair bit of work to cover most tools for examples.
Once/if we want to release the contribution, we'll have to review the pom.xml to ensure this can be pushed to Maven Central at some point.

contrib/pom.xml Outdated
<packaging>jar</packaging>
<name>Agent Development Kit - Contributions</name>
<url>https://github.com/google/adk-java</url>
<licenses>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeing this here makes me think that we should have a root parent POM to define everything that's not specific to core or dev or contrib. I can propose a PR for that, if there is agreement that this would make sense?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert in Maven, but I definitely agree we need to make the build a little more modular to avoid repeating things, and more clearly separating the different artifacts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #155! Let's wait for that to get reviewed & merged, and then take this from there?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Indeed, we'll have to get it reviewed & merged.
It would be easier if we could work on the same PR.
Or maybe I can cherry pick the changes in your PR... hmm...

@@ -0,0 +1,324 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that we would want this to be contrib/langchain4j, not just contrib/ ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely a good point.
I'll make that change now, but I'd be happy if you could look into the Maven parent pom.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the directory change

LlmAgent agent = LlmAgent.builder()
.name("science-app")
.description("Science teacher agent")
.model(new LangChain4j(claudeModel, CLAUDE_3_7_SONNET_20250219))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.model(new LangChain4j(claudeModel, CLAUDE_3_7_SONNET_20250219))
.model(new LangChain4j(claudeModel))

BaseAgent agent = LlmAgent.builder()
.name("friendly-weather-app")
.description("Friend agent that knows about the weather")
.model(new LangChain4j(claudeModel, CLAUDE_3_7_SONNET_20250219))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.model(new LangChain4j(claudeModel, CLAUDE_3_7_SONNET_20250219))
.model(new LangChain4j(claudeModel))

BaseAgent agent = LlmAgent.builder()
.name("friendly-weather-app")
.description("Friend agent that knows about the weather")
.model(new LangChain4j(gptModel, "gpt-3.5-turbo"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.model(new LangChain4j(gptModel, "gpt-3.5-turbo"))
.model(new LangChain4j(gptModel))

@@ -63,6 +63,7 @@
<java-websocket.version>1.6.0</java-websocket.version>
<jackson.version>2.19.0</jackson.version>
<okhttp.version>4.12.0</okhttp.version>
<langchain4j.version>1.0.1</langchain4j.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't go here... witht the contrib/langchain4j "module" it (now) belongs in that POM, agreed?

Maybe it's easier to wait for #155, first; up to you.

@BeforeAll
public static void setUp() {
assertNotNull(System.getenv("ANTHROPIC_API_KEY"));
assertNotNull(System.getenv("GOOGLE_API_KEY"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assertNotNull(System.getenv("GOOGLE_API_KEY"));
assertNotNull(System.getenv("GOOGLE_API_KEY"));
assertNotNull(System.getenv("OPENAI_API_KEY"));

public static final String GPT_4_O_MINI = "gpt-4o-mini";

@BeforeAll
public static void setUp() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this to pass on CI, we'll need to put someone's x3 API keys as secrets into the configuration of this repo.

That's going to be fun to sort out... 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants