Skip to content

Commit

Permalink
Added skeleton structure for docs (langchain4j#458)
Browse files Browse the repository at this point in the history
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
amithkoujalgi and Amith Koujalgi authored Jan 6, 2024
1 parent 2d82a49 commit a0c63b6
Show file tree
Hide file tree
Showing 44 changed files with 27,840 additions and 0 deletions.
20 changes: 20 additions & 0 deletions docs/.gitignore
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*
7 changes: 7 additions & 0 deletions docs/Makefile
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
37 changes: 37 additions & 0 deletions docs/README.md
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
```
3 changes: 3 additions & 0 deletions docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
9 changes: 9 additions & 0 deletions docs/blog/2023-01-01-welcome/index.md
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!
33 changes: 33 additions & 0 deletions docs/blog/2023-08-29-release-0.22.0.md
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)
11 changes: 11 additions & 0 deletions docs/blog/authors.yml
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
8 changes: 8 additions & 0 deletions docs/docs/code-examples/_category_.json
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"
}
}
26 changes: 26 additions & 0 deletions docs/docs/code-examples/hello-world.md
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?
}
}
```
32 changes: 32 additions & 0 deletions docs/docs/code-examples/plain-java.md
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?
}
}
```
49 changes: 49 additions & 0 deletions docs/docs/code-examples/sping-boot.md
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("==========================================================================================");
}
}
```
8 changes: 8 additions & 0 deletions docs/docs/documentation/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Documentation",
"position": 5,
"link": {
"type": "generated-index",
"description": "Documentation"
}
}
5 changes: 5 additions & 0 deletions docs/docs/documentation/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 1
---

# TBD
8 changes: 8 additions & 0 deletions docs/docs/getting-started/_category_.json
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"
}
}
48 changes: 48 additions & 0 deletions docs/docs/getting-started/hello-world.md
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).
35 changes: 35 additions & 0 deletions docs/docs/getting-started/setup.md
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

![Java](https://img.shields.io/badge/Java-8_+-blue.svg?style=for-the-badge&labelColor=gray)

Latest version of LangChain4j: ![Maven Central](https://img.shields.io/maven-central/v/dev.langchain4j/langchain4j?style=for-the-badge&labelColor=gray)

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}'
```
8 changes: 8 additions & 0 deletions docs/docs/integrations/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Integrations",
"position": 7,
"link": {
"type": "generated-index",
"description": "Integrations"
}
}
5 changes: 5 additions & 0 deletions docs/docs/integrations/code-execution-engines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 5
---

# Code Execution Engines
5 changes: 5 additions & 0 deletions docs/docs/integrations/document-loaders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 2
---

# Document Loaders
5 changes: 5 additions & 0 deletions docs/docs/integrations/embedding-models.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 4
---

# Embedding Models
5 changes: 5 additions & 0 deletions docs/docs/integrations/embedding-stores.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 3
---

# Embedding Stores
5 changes: 5 additions & 0 deletions docs/docs/integrations/frameworks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
sidebar_position: 6
---

# Frameworks
Loading

0 comments on commit a0c63b6

Please sign in to comment.