forked from langchain4j/langchain4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added skeleton structure for docs (langchain4j#458)
Hi @LizeRaes, In reference to [this](langchain4j#429 (reply in thread)), I've added the skeleton structure for documentation under the `docs` directory. I've also updated the `README.md` under the `docs` directory to help in setting up and running the docs. It's straightforward to set up and run the docs locally to get a feel for its appearance. I've also attached a few screenshots of the pages to get a quick look at the appearance. Please have a look and do let me know what you think. Thanks! **_Sample Images:_** - Docs: Home/Landing Page <img width="1792" alt="1" src="https://github.com/langchain4j/langchain4j/assets/1876165/c2ff1bf3-a412-4d86-be0d-9937936ec533"> - Docs: Inner Page Sample <img width="1792" alt="2" src="https://github.com/langchain4j/langchain4j/assets/1876165/9166df41-f16a-4bff-a3ca-145364be475c"> - Docs: Sample Blog <img width="1792" alt="3" src="https://github.com/langchain4j/langchain4j/assets/1876165/44dc1e7c-f669-4806-acfe-8fc2c3d2f59b"> Co-authored-by: Amith Koujalgi <[email protected]>
- Loading branch information
1 parent
2d82a49
commit a0c63b6
Showing
44 changed files
with
27,840 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
build: | ||
npm ci; \ | ||
npm run build | ||
|
||
dev: | ||
npm ci; \ | ||
npm run start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
## LangChain4j Documentation | ||
|
||
### Table of Contents | ||
|
||
- [Prerequisites](#prerequisites) | ||
- [Installation](#installation) | ||
|
||
This is built using [Docusaurus](https://docusaurus.io/), a modern static docs/website generator. | ||
|
||
### Prerequisites | ||
|
||
- [Node.JS](https://nodejs.org/en/download) (20+) | ||
|
||
### Installation | ||
|
||
This command installs all the Node dependencies. | ||
|
||
```bash | ||
npm ci | ||
``` | ||
|
||
### Build | ||
|
||
This command builds the deployable static artifacts (i.e., html, js, css, etc) under the `build` directory. This static content can then be deployed to `GitHub pages` or `Vercel`, etc. | ||
|
||
``` | ||
npm run build | ||
``` | ||
|
||
### Local Development | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without | ||
having to restart the server. | ||
|
||
``` | ||
npm run start | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
slug: welcome | ||
title: Welcome | ||
authors: [ lanchain4j ] | ||
tags: [ Java, AI, LLM, GenAI, GenerativeAI, LangChain4j, LangChain, OpenSource, Developers | ||
] | ||
--- | ||
|
||
Welcome to LangChain4j! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
slug: release-0.22.0 | ||
title: Release 0.22.0 | ||
authors: [ lanchain4j ] | ||
tags: [ Java, AI, LLM, GenAI, GenerativeAI, LangChain4j, LangChain, OpenSource, Developers | ||
] | ||
--- | ||
|
||
LangChain4j 0.22.0 is out! | ||
|
||
- Integration with [Google Vertex AI](https://cloud.google.com/vertex-ai) | ||
- Offline text classification with embeddings | ||
- Reworked document splitters | ||
- In-process embedding models can now embed longer texts | ||
- In-memory embedding store can now be easily persisted | ||
- And more: https://github.com/langchain4j/langchain4j/releases/tag/0.22.0 | ||
|
||
Now any text (e.g. document, message from a user, etc) can be classified completely offline and without any external | ||
calls. | ||
|
||
See example [here](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/embedding/classification/EmbeddingModelTextClassifierExample.java). | ||
|
||
You only need to specify some examples for each label/category and that's it! BTW, examples can be generated using | ||
LLMs ;) | ||
|
||
Benefits are: faster and cheaper usage of LLMs. | ||
|
||
There are lots of use cases: | ||
|
||
1. Labeling documents | ||
2. For chatbots: choosing appropriate (system) prompt depending on the user's message (e.g. is it a complaint? a | ||
greeting? regular question? etc) | ||
3. For chatbots/agents: choosing appropriate tools depending on a user's message (to save on tokens) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
amith: | ||
name: Amith Koujalgi | ||
title: Maintainer of Ollama4j | ||
url: https://github.com/amithkoujalgi | ||
image_url: https://github.com/amithkoujalgi.png | ||
|
||
lanchain4j: | ||
name: LangChain4j | ||
title: Author and Maintainer of LangChain4j | ||
url: https://github.com/langchain4j | ||
image_url: https://github.com/langchain4j.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Code Examples", | ||
"position": 6, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Code Examples" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Hello, World! | ||
|
||
[HelloWorld.java](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/HelloWorldExample.java) | ||
|
||
```java | ||
import dev.langchain4j.model.chat.ChatLanguageModel; | ||
import dev.langchain4j.model.openai.OpenAiChatModel; | ||
|
||
public class HelloWorldExample { | ||
|
||
public static void main(String[] args) { | ||
|
||
// Create an instance of a model | ||
ChatLanguageModel model = OpenAiChatModel.withApiKey(ApiKeys.OPENAI_API_KEY); | ||
|
||
// Start interacting | ||
String answer = model.generate("Hello world!"); | ||
|
||
System.out.println(answer); // Hello! How can I assist you today? | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Plain Java | ||
|
||
[Simple Service](https://github.com/langchain4j/langchain4j-examples/blob/main/other-examples/src/main/java/SimpleServiceExample.java) | ||
|
||
```java | ||
import dev.langchain4j.model.chat.ChatLanguageModel; | ||
import dev.langchain4j.model.openai.OpenAiChatModel; | ||
import dev.langchain4j.service.AiServices; | ||
|
||
public class SimpleServiceExample { | ||
|
||
interface Assistant { | ||
|
||
String chat(String message); | ||
} | ||
|
||
public static void main(String[] args) { | ||
|
||
ChatLanguageModel chatLanguageModel = OpenAiChatModel.withApiKey(ApiKeys.OPENAI_API_KEY); | ||
|
||
Assistant assistant = AiServices.create(Assistant.class, chatLanguageModel); | ||
|
||
String answer = assistant.chat("Hello"); | ||
|
||
System.out.println(answer); // Hello! How can I assist you today? | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Spring Boot | ||
|
||
[CustomerSupportApplicationTest.java](https://github.com/langchain4j/langchain4j-examples/blob/main/spring-boot-example/src/test/java/dev/example/CustomerSupportApplicationTest.java) | ||
|
||
```java | ||
package dev.example; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
@SpringBootTest | ||
class CustomerSupportApplicationTest { | ||
|
||
@Autowired | ||
CustomerSupportAgent agent; | ||
|
||
@Test | ||
void should_provide_booking_details_and_explain_why_cancellation_is_not_possible() { | ||
|
||
// Please define API keys in application.properties before running this test. | ||
// Tip: Use gpt-4 for this example, as gpt-3.5-turbo tends to hallucinate often and invent name and surname. | ||
|
||
interact(agent, "Hi, I forgot when my booking is."); | ||
interact(agent, "123-457"); | ||
interact(agent, "I'm sorry I'm so inattentive today. Klaus Heisler."); | ||
interact(agent, "My bad, it's 123-456"); | ||
|
||
// Here, information about the cancellation policy is automatically retrieved and injected into the prompt. | ||
// Although the LLM sometimes attempts to cancel the booking, it fails to do so and will explain | ||
// the reason why the booking cannot be cancelled, based on the injected cancellation policy. | ||
interact(agent, "My plans have changed, can I cancel my booking?"); | ||
} | ||
|
||
private static void interact(CustomerSupportAgent agent, String userMessage) { | ||
System.out.println("=========================================================================================="); | ||
System.out.println("[User]: " + userMessage); | ||
System.out.println("=========================================================================================="); | ||
String agentAnswer = agent.chat(userMessage); | ||
System.out.println("=========================================================================================="); | ||
System.out.println("[Agent]: " + agentAnswer); | ||
System.out.println("=========================================================================================="); | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Documentation", | ||
"position": 5, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Documentation" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# TBD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Getting Started", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Getting Started" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Write a Hello World program! | ||
|
||
:::note | ||
|
||
Before you proceed, make sure you have Java 8+ and Maven installed. Verify it by typing in these commands in your terminal: | ||
|
||
```shell | ||
java --version | ||
mvn --version | ||
``` | ||
|
||
::: | ||
|
||
Easiest way to get started is with OpenAI integration. So, you'll need to setup an OpenAI account. | ||
Then, specify your OpenAPI key as the environment variable `OPENAI_API_KEY`. | ||
|
||
```shell | ||
export OPENAI_API_KEY=sk-<the-rest-of-your-key> | ||
``` | ||
|
||
Once you've setup OpenAPI key, create this Java class and run it. | ||
|
||
```java | ||
import dev.langchain4j.data.message.AiMessage; | ||
import dev.langchain4j.model.chat.ChatLanguageModel; | ||
import dev.langchain4j.model.openai.OpenAiChatModel; | ||
|
||
public class HelloWorldExample { | ||
|
||
public static void main(String[] args) { | ||
|
||
// Create an instance of a model | ||
ChatLanguageModel model = OpenAiChatModel | ||
.withApiKey(System.getenv("OPENAI_API_KEY"); | ||
|
||
// Start interacting | ||
AiMessage answer = model.sendUserMessage("Hello world!"); | ||
|
||
System.out.println(answer.text()); // Hello! How can I assist you today? | ||
} | ||
} | ||
``` | ||
|
||
Find more examples [here](/docs/category/code-examples). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Setup | ||
|
||
### Table of Contents | ||
|
||
- [Requirements](#requirements) | ||
- [Installation](#installation) | ||
|
||
#### Requirements | ||
|
||
 | ||
|
||
Latest version of LangChain4j:  | ||
|
||
To install langchain4j to your project, add the following dependency to your `pom.xml` file. | ||
|
||
For Maven project: | ||
|
||
```xml | ||
|
||
<dependency> | ||
<groupId>dev.langchain4j</groupId> | ||
<artifactId>langchain4j</artifactId> | ||
<version>{your-version}</version> <!-- Specify your version here --> | ||
</dependency> | ||
``` | ||
|
||
For Gradle project: | ||
|
||
```groovy | ||
implementation 'dev.langchain4j:langchain4j:{your-version}' | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Integrations", | ||
"position": 7, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "Integrations" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
sidebar_position: 5 | ||
--- | ||
|
||
# Code Execution Engines |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
sidebar_position: 2 | ||
--- | ||
|
||
# Document Loaders |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
sidebar_position: 4 | ||
--- | ||
|
||
# Embedding Models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Embedding Stores |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
sidebar_position: 6 | ||
--- | ||
|
||
# Frameworks |
Oops, something went wrong.