Skip to content

It's the Java implementation of LangChain, for building applications with LLMs through composability.

License

Notifications You must be signed in to change notification settings

tckb/langchain-java

Repository files navigation

🦜️ LangChain Java

⚡ Building applications with LLMs through composability ⚡

What is this?

This is the Java language implementation of LangChain.

Large language models (LLMs) are emerging as a transformative technology, enabling developers to build applications that they previously could not. But using these LLMs in isolation is often not enough to create a truly powerful app - the real power comes when you can combine them with other sources of computation or knowledge.

This library is aimed at assisting in the development of those types of applications.

Looking for the Python version? Check out LangChain.

Examples

Here's a simple example of using langchain-java to interact with OpenAI:

@Test
void testOpenAiCall() {
   OpenAI openAI = OpenAI.builder()
           .proxy(ProxyUtils.http("127.0.0.1", 1087))
           .maxTokens(10)
           .build()
           .init();

   assertThat(openAI.call("Say foo:")).isEqualTo("\n\nFoo!");
}

Run Test from Source

Prerequisites for building:

  • Git
  • Java 17 or later
  • Unix-like environment (we use Linux, Mac OS X)
  • Maven (we recommend version 3.8.6 and require at least 3.5.4)
git clone https://github.com/HamaWhiteGG/langchain-java.git
cd langchain-java

# Set the environment variable OPENAI_API_KEY, using the command 'export OPENAI_API_KEY=xxx'

# export JAVA_HOME=JDK17_INSTALL_HOME && mvn clean test
mvn clean test

Support

Don’t hesitate to ask!

Open an issue if you find a bug in Flink.

Fork and Contribute

This is an active open-source project. We are always open to people who want to use the system or contribute to it.

Contact me if you are looking for implementation tasks that fit your skills.

About

It's the Java implementation of LangChain, for building applications with LLMs through composability.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%