Skip to content

Commit

Permalink
Docu: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
LangChain4j committed Feb 2, 2024
1 parent b86f319 commit f17f834
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 62 deletions.
56 changes: 16 additions & 40 deletions docs/docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,66 +33,42 @@ To add langchain4j to your java project, add the following dependency:
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j</artifactId>
<version>{your-version}</version> <!-- Specify your version here -->
<version>0.26.1</version>
</dependency>
```

- For Gradle project `build.gradle`

```groovy
implementation 'dev.langchain4j:langchain4j:{your-version}'
implementation 'dev.langchain4j:langchain4j:0.26.1'
```



## Write a Hello World program

The easiest way to get started is with the OpenAI API integration.
The easiest way to get started is with the OpenAI integration.

Next to your java classes, create a class ```ApiKeys``` where you expose you OpenAI API key:
First, import your OpenAI API key.
It's recommended to store your API keys in environment variables to reduce the risk of exposing them publicly.
```java
public class ApiKeys {
public static final String OPENAI_API_KEY = System.getenv("your key goes here");
}
String apiKey = System.getenv("OPENAI_API_KEY");
```

:::note
If you don't have a key for OpenAI API, you can temporarily use "demo" as a key to try out langchain4j
:::

Once you've set the key up, create this Java class and run it:

If you don't have your own OpenAI API key, don't worry.
You can temporarily use `demo` key, which we provide for free for demonstration purposes:
```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(ApiKeys.OPENAI_API_KEY);

// Start interacting
String answer = model.generate("Hello world!");

System.out.println(answer); // Hello! How can I assist you today?
}
}
String apiKey = "demo";
```

Alternatively, specify your OpenAI API key as the environment variable `OPENAI_API_KEY`.

```shell
export OPENAI_API_KEY=sk-<the-rest-of-your-key>
:::
Once you've set up the key, let's create an instance of an `OpenAiChatModel`:
```java
OpenAiChatModel model = OpenAiChatModel.withApiKey(apiKey);
```

and load it into your java class as follows

No, it is time to chat!
```java
String key = System.getenv("OPENAI_API_KEY");
String answer = model.generate("Say 'Hello World'");
System.out.println(answer);
```

Find step-by-step tutorials with more complex examples [here](/docs/category/tutorials).
Expand Down
10 changes: 10 additions & 0 deletions docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ LangChain4j features a modular design, comprising:
- A wide array of `langchain4j-xyz` modules, each providing integration with various LLM providers and embedding stores into LangChain4j.
You can use the `langchain4j-xyz` modules independently. For additional features, simply import the main `langchain4j` dependency.

### 2 levels of abstraction
LangChain4j operates on two levels of abstraction:
- Low level. At this level, you have the most freedom and access to all the low-level components such as
`ChatLanguageModel`, `UserMessage`, `AiMessage`, `EmbeddingStore`, `Embedding`, etc.
These are the "primitives" of your LLM-powered application.
You have complete control over how to combine them, but you will need to write more code in the imperative style.
- High level. At this level, you interact with LLMs using high-level APIs like `AiServices` and `Chain`s,
which hides all the complexity and boilerplate from you.
You still have the flexibility to adjust and fine-tune the behavior, but it is done more in a declarative manner.

[![](/img/langchain4j-components.png)](/docs/intro)

### Tutorials (User Guide)
Expand Down
18 changes: 1 addition & 17 deletions docs/docs/latest-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,4 @@ sidebar_position: 20
---

# Latest Release Notes


LangChain4j 0.25.0 is out!

- Azure OpenAI:
- Using official Azure SDK by [@jdubois](https://github.com/jdubois)
- Image generation with DALL·E by [@jdubois](https://github.com/jdubois)
- OpenAI:
- [Image generation with DALL·E](https://github.com/langchain4j/langchain4j-examples/blob/main/open-ai-examples/src/main/java/OpenAiImageModelExamples.java) by [@Heezer](https://github.com/Heezer)
- Parallel function calling, json output, precise token estimation by [@langchain4j](https://github.com/langchain4j)
- [Integration with Google Gemini](https://github.com/langchain4j/langchain4j-examples/blob/main/vertex-ai-gemini-examples/src/main/java/VertexAiGeminiChatModelExamples.java) by [@kuraleta](https://github.com/kuraleta)
- Ollama:
- [Chat API](https://github.com/langchain4j/langchain4j-examples/tree/main/ollama-examples) by [@fintanmm](https://github.com/fintanmm)
- Json output and more parameters by [@langchain4j](https://github.com/langchain4j)
- [Integration with Neo4j](https://github.com/langchain4j/langchain4j-examples/blob/main/neo4j-example/src/main/java/Neo4jEmbeddingStoreExample.java) by [@vga91](https://github.com/vga91)
- Integration with ChatGLM by [@Martin7-1](https://github.com/Martin7-1)
- [And more](https://github.com/langchain4j/langchain4j/releases/tag/0.25.0)
Please find the latest release notes [here](https://github.com/langchain4j/langchain4j/releases).
10 changes: 5 additions & 5 deletions docs/src/components/HomepageFeatures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import styles from './styles.module.css';

const FeatureList = [
{
title: 'Easy interaction with LLMs and AI',
title: 'Easy interaction with LLMs and Vector Stores',
Svg: require('@site/static/img/llm-logos.svg').default,
description: (
<>
All major commercial and open source models are easily accessible via a streamlined <code>API</code>, allowing you to build Chatbots, Assistants, Data Classifiers, Autonomous Agents, ...
All major commercial and open-source LLMs and Vector Stores are easily accessible through a unified API, enabling you to build chatbots, assistants and more.
</>
),
},
Expand All @@ -17,16 +17,16 @@ const FeatureList = [
Svg: require('@site/static/img/framework-logos.svg').default,
description: (
<>
Smooth integration in your java applications thanks to Quarkus and Spring Boot integrations, converse with LLMs in POJOs and have the LLM call Java methods
Smooth integration into your Java applications is made possible thanks to Quarkus and Spring Boot integrations. There is two-way integration between LLMs and Java: you can call LLMs from Java and allow LLMs to call your Java code in return.
</>
),
},
{
title: 'Tools, AI Services, Chains, RAG',
title: 'AI Services, RAG, Tols, Chains',
Svg: require('@site/static/img/functionality-logos.svg').default,
description: (
<>
Provides an extensive toolbox of common AI LLM operations, made easy thanks to various layers of abstraction
Our extensive toolbox provides a wide range of tools for common LLM operations, from low-level prompt templating, memory management, and output parsing, to high-level patterns like Agents and RAG.
</>
),
}
Expand Down

0 comments on commit f17f834

Please sign in to comment.