# LangChain for Java: Supercharge your Java application with the power of LLMs
## Project goals
The goal of this project is to simplify the integration of AI/LLM capabilities into your Java application.
This can be achieved thanks to:
- **A simple and coherent layer of abstractions**, designed to ensure that your code does not depend on concrete implementations such as LLM providers, embedding store providers, etc. This allows for easy swapping of components.
- **Numerous implementations of the above-mentioned abstractions**, providing you with a variety of LLMs and embedding stores to choose from.
- **Range of in-demand features on top of LLMs, such as:**
- The capability to **ingest your own data** (documentation, codebase, etc.), allowing the LLM to act and respond based on your data.
- **Autonomous agents** for delegating tasks (defined on the fly) to the LLM, which will strive to complete them.
- **Prompt templates** to help you achieve the highest possible quality of LLM responses.
- **Memory** to provide context to the LLM for your current and past conversations.
- **Structured outputs** for receiving responses from the LLM with a desired structure as Java POJOs.
- **"AI Services"** for declaratively defining complex AI behavior behind a simple API.
- **Chains** to reduce the need for extensive boilerplate code in common use-cases.
- **Auto-moderation** to ensure that all inputs and outputs to/from the LLM are not harmful.
## Code examples
Please see examples of how LangChain4j can be used in `langchain4j-examples` repo:
- [Examples in plain Java](https://github.com/langchain4j/langchain4j-examples/tree/main/other-examples/src/main/java)
- [Example with Spring Boot](https://github.com/langchain4j/langchain4j-examples/blob/main/spring-boot-example/src/test/java/dev/example/CustomerSupportApplicationTest.java)
## News
29 September:
- Updates to models API: return `Response<T>` instead of `T`. `Response<T>` contains token usage and finish reason.
- All model and embedding store integrations now live in their own modules
- Integration with [Vespa](https://vespa.ai/) by [@Heezer](https://github.com/Heezer)
- Integration with [Elasticsearch](https://www.elastic.co/) by [@Martin7-1](https://github.com/Martin7-1)
- Integration with [Redis](https://redis.io/) by [@Martin7-1](https://github.com/Martin7-1)
- Integration with [Milvus](https://milvus.io/) by [@IuriiKoval](https://github.com/IuriiKoval)
- Integration with [Astra DB](https://www.datastax.com/products/datastax-astra) and [Cassandra](https://cassandra.apache.org/) by [@clun](https://github.com/clun)
- Added support for overlap in document splitters
- Some bugfixes and smaller improvements
29 August:
- Offline [text classification with embeddings](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/embedding/classification/EmbeddingModelTextClassifierExample.java)
- Integration with [Google Vertex AI](https://cloud.google.com/vertex-ai) by [@kuraleta](https://github.com/kuraleta)
- Reworked [document splitters](https://github.com/langchain4j/langchain4j/blob/main/langchain4j/src/main/java/dev/langchain4j/data/document/splitter/DocumentSplitters.java)
- In-memory embedding store can now be easily persisted
- [And more](https://github.com/langchain4j/langchain4j/releases/tag/0.22.0)
19 August:
- Integration with [Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/overview) by [@kuraleta](https://github.com/kuraleta)
- Integration with Qwen models (DashScope) by [@jiangsier-xyz](https://github.com/jiangsier-xyz)
- [Integration with Chroma](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/embedding/store/ChromaEmbeddingStoreExample.java) by [@kuraleta](https://github.com/kuraleta)
- [Support for persistent ChatMemory](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/ServiceWithPersistentMemoryForEachUserExample.java)
10 August:
- [Integration with Weaviate](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/embedding/store/WeaviateEmbeddingStoreExample.java) by [@Heezer](https://github.com/Heezer)
- [Support for DOC, XLS and PPT document types](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/DocumentLoaderExamples.java) by [@oognuyh](https://github.com/oognuyh)
- [Separate chat memory for each user](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/ServiceWithMemoryForEachUserExample.java)
- [Custom in-process embedding models](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/embedding/model/InProcessEmbeddingModelExamples.java)
- Added lots of Javadoc
- [And more](https://github.com/langchain4j/langchain4j/releases/tag/0.19.0)
26 July:
- We've added integration with [LocalAI](https://localai.io/). Now, you can use LLMs hosted locally!
- Added support for [response streaming in AI Services](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/ServiceWithStreamingExample.java).
21 July:
- Now, you can do [text embedding inside your JVM](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/embedding/model/InProcessEmbeddingModelExamples.java).
17 July:
- You can now try out OpenAI's `gpt-3.5-turbo` and `text-embedding-ada-002` models with LangChain4j for free, without needing an OpenAI account and keys! Simply use the API key "demo".
15 July:
- Added EmbeddingStoreIngestor
- Redesigned document loaders (see FileSystemDocumentLoader)
- Simplified ConversationalRetrievalChain
- Renamed DocumentSegment into TextSegment
- Added output parsers for numeric types
- Added @UserName for AI Services
- Fixed [23](https://github.com/langchain4j/langchain4j/issues/23) and [24](https://github.com/langchain4j/langchain4j/issues/24)
11 July:
- Added ["Dynamic Tools"](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/ServiceWithDynamicToolsExample.java):
Now, the LLM can generate code for tasks that require precise calculations, such as math and string manipulation. This will be dynamically executed in a style akin to GPT-4's code interpreter!
We use [Judge0, hosted by Rapid API](https://rapidapi.com/judge0-official/api/judge0-ce/pricing), for code execution. You can subscribe and receive 50 free executions per day.
5 July:
- Now you can [add your custom knowledge base to "AI Services"](https://github.com/langchain4j/langchain4j-examples/blob/main/spring-boot-example/src/test/java/dev/example/CustomerSupportApplicationTest.java).
Relevant information will be automatically retrieved and injected into the prompt. This way, the LLM will have a
context of your data and will answer based on it!
- The current date and time can now be automatically injected into the prompt using
special `{{current_date}}`, `{{current_time}}` and `{{current_date_time}}` placeholders.
3 July:
- Added support for Spring Boot 3
2 July:
- [Added Spring Boot Starter](https://github.com/langchain4j/langchain4j-examples/blob/main/spring-boot-example/src/test/java/dev/example/CustomerSupportApplicationTest.java)
- Added support for HuggingFace models
1 July:
- [Added "Tools"](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/ServiceWithToolsExample.java) (support for OpenAI functions)
## Highlights
You can declaratively define concise "AI Services" that are powered by LLMs:
```java
interface Assistant {
String chat(String userMessage);
}
Assistant assistant = AiServices.create(Assistant.class, model);
String answer = assistant.chat("Hello");
System.out.println(answer);
// Hello! How can I assist you today?
```
You can use LLM as a classifier:
```java
enum Sentiment {
POSITIVE, NEUTRAL, NEGATIVE
}
in
没有合适的资源?快使用搜索试试~ 我知道了~
LangChain开源大型语言模型(LLM)框架
共328个文件
java:283个
xml:19个
txt:3个
需积分: 1 14 下载量 186 浏览量
2023-11-09
14:29:27
上传
评论 2
收藏 524KB ZIP 举报
温馨提示
LangChain是由Harrison Chase开发的一个框架,迎合了大型语言模型(LLM)的需求。在OpenAI的GPT-3取得巨大成功后,它的受欢迎程度激增,可以说,GPT-3.5和GPT-4更是如此。2022年10月底推出的LangChain利用了这些进展,提供了一个专门用于创建依赖LLM的生产级应用程序的平台,而不仅仅是实验性的。 LangChain的关键理念是将不同的部件连接或 "链条 "在一起,形成复杂的应用。这些链子可以使用许多模块的碎片,如各种提示的模板(如聊天回复、ELI5等)、与不同LLM模型的连接(如GPT-3、BLOOM等)、代理(使用LLM来决定做什么--我们今天晚些时候将讨论gpt-engineer项目在这个类别中的情况)以及记忆(短期和长期)。所有这些都是以标准应用框架的形式提供的。 langchain4j/langchain4j则是langchain的一个Java封装器--一个类固醇。整个项目已经在引导用户,并专注于清楚地展示使用的可能性(在项目中你会发现一个带有例子的目录),并且创造者宣布进一步的发展。
资源推荐
资源详情
资源评论
收起资源包目录
LangChain开源大型语言模型(LLM)框架 (328个子文件)
test-file.banana 29B
opennlp-en-ud-ewt-sentence-1.0-1.9.3.bin 20KB
mvnw.cmd 7KB
test-file.doc 22KB
test-file.docx 12KB
spring.factories 107B
.gitattributes 43B
.gitignore 427B
org.springframework.boot.autoconfigure.AutoConfiguration.imports 44B
AiServicesIT.java 28KB
AiServices.java 27KB
DocumentByParagraphSplitterTest.java 21KB
LangChain4jAutoConfiguration.java 13KB
ElasticsearchEmbeddingStore.java 13KB
MilvusEmbeddingStoreTest.java 11KB
EmbeddingModelTextClassifierTest.java 11KB
VespaEmbeddingStore.java 11KB
MilvusEmbeddingStore.java 11KB
RedisEmbeddingStore.java 11KB
AzureOpenAiStreamingChatModel.java 11KB
InMemoryEmbeddingStoreTest.java 11KB
RedisEmbeddingStoreTest.java 10KB
ElasticsearchEmbeddingStoreTest.java 10KB
ChromaEmbeddingStoreTest.java 9KB
AzureOpenAiChatModel.java 9KB
PineconeEmbeddingStore.java 9KB
ToolExecutorTest.java 9KB
WeaviateEmbeddingStoreTest.java 8KB
PineconeEmbeddingStoreTest.java 8KB
WeaviateEmbeddingStore.java 8KB
VertexAiChatModel.java 8KB
StreamingAiServicesIT.java 8KB
DocumentBySentenceSplitterTest.java 8KB
AzureOpenAiEmbeddingModel.java 7KB
ChromaEmbeddingStore.java 7KB
AzureOpenAiStreamingLanguageModel.java 7KB
EmbeddingModelTextClassifier.java 7KB
AzureOpenAiLanguageModel.java 7KB
CassandraEmbeddingStoreSupport.java 7KB
ServiceOutputParser.java 7KB
OpenAiStreamingChatModel.java 7KB
OpenAiTokenizer.java 6KB
InMemoryEmbeddingStore.java 6KB
TokenWindowChatMemoryTest.java 6KB
VespaQueryClient.java 6KB
VextexAiLanguageModel.java 6KB
VertexAiEmbeddingModel.java 6KB
TokenWindowChatMemory.java 6KB
HierarchicalDocumentSplitter.java 6KB
QwenEmbeddingModel.java 6KB
SampleDocumentLoaderAndRagWithAstraTest.java 6KB
ToolExecutor.java 6KB
OpenAiTokenizerTest.java 6KB
InternalOpenAiHelper.java 5KB
OpenAiChatModel.java 5KB
CollectionOperationsExecutor.java 5KB
HuggingFaceChatModel.java 5KB
OpenAiStreamingChatModelIT.java 5KB
MessageWindowChatMemoryTest.java 5KB
FileSystemDocumentLoaderTest.java 5KB
LocalAiStreamingChatModel.java 5KB
MessageWindowChatMemory.java 5KB
HtmlTextExtractor.java 5KB
CassandraEmbeddingStore.java 5KB
FileSystemDocumentLoader.java 5KB
QwenChatModel.java 5KB
Parameters.java 4KB
EmbeddingStoreIngestor.java 4KB
HuggingFaceLanguageModel.java 4KB
QwenStreamingChatModel.java 4KB
CassandraChatMemoryStore.java 4KB
OpenAiModerationModel.java 4KB
Mapper.java 4KB
OpenAiStreamingLanguageModel.java 4KB
AiServiceStreamingResponseHandler.java 4KB
OpenAiStreamingResponseBuilder.java 4KB
QwenLanguageModel.java 4KB
OpenAiEmbeddingModel.java 4KB
LocalAiChatModel.java 4KB
HtmlTextExtractorTest.java 4KB
QwenStreamingLanguageModel.java 4KB
CassandraEmbeddingConfigurationTest.java 4KB
DocumentByRegexSplitter.java 4KB
OpenAiLanguageModel.java 4KB
ToolSpecification.java 4KB
DocumentBySentenceSplitter.java 4KB
AstraDbEmbeddingConfigurationTest.java 4KB
TestUtils.java 4KB
EmbeddingStore.java 4KB
DocumentByRegexSplitterTest.java 3KB
ChromaClient.java 3KB
ChatMessageSerializerTest.java 3KB
EmbeddingStoreIngestorTest.java 3KB
QwenEmbeddingModelIT.java 3KB
HuggingFaceClient.java 3KB
ChatLanguageModel.java 3KB
LocalAiStreamingLanguageModel.java 3KB
AiServiceTokenStream.java 3KB
ToolSpecifications.java 3KB
JsonTest.java 3KB
共 328 条
- 1
- 2
- 3
- 4
资源评论
技术探秘者
- 粉丝: 1121
- 资源: 48
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 【java毕业设计】考研资讯平台源码(springboot+vue+mysql+说明文档+LW).zip
- 【java毕业设计】就业信息管理系统源码(springboot+vue+mysql+说明文档+LW).zip
- mongo-shake-v2.6.5 Linux版本
- 数据集-目标检测系列- 小猪 检测数据集 pig >> DataBall
- python与mysql基础.txt
- 【java毕业设计】旧物置换网站源码(springboot+vue+mysql+说明文档+LW).zip
- python与mysql基础.txt
- python与mysql基础.txt
- maven上传工具,仅限windows环境
- 【java毕业设计】酒店管理系统源码(springboot+vue+mysql+说明文档+LW).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功