From f17f8349ac3597f9804bfe835554e4e618b15fa8 Mon Sep 17 00:00:00 2001 From: LangChain4j Date: Fri, 2 Feb 2024 09:12:54 +0100 Subject: [PATCH] Docu: updates --- docs/docs/get-started.md | 56 ++++++------------- docs/docs/intro.md | 10 ++++ docs/docs/latest-release-notes.md | 18 +----- docs/src/components/HomepageFeatures/index.js | 10 ++-- 4 files changed, 32 insertions(+), 62 deletions(-) diff --git a/docs/docs/get-started.md b/docs/docs/get-started.md index 19c27b7fffb..b62eb70eaa6 100644 --- a/docs/docs/get-started.md +++ b/docs/docs/get-started.md @@ -33,66 +33,42 @@ To add langchain4j to your java project, add the following dependency: dev.langchain4j langchain4j - {your-version} + 0.26.1 ``` - 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- +::: +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). diff --git a/docs/docs/intro.md b/docs/docs/intro.md index 8129de4bfbd..56938320eac 100644 --- a/docs/docs/intro.md +++ b/docs/docs/intro.md @@ -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) diff --git a/docs/docs/latest-release-notes.md b/docs/docs/latest-release-notes.md index 906294caa93..deb1b216231 100644 --- a/docs/docs/latest-release-notes.md +++ b/docs/docs/latest-release-notes.md @@ -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). diff --git a/docs/src/components/HomepageFeatures/index.js b/docs/src/components/HomepageFeatures/index.js index 2e2f74fb983..63092dcb145 100644 --- a/docs/src/components/HomepageFeatures/index.js +++ b/docs/src/components/HomepageFeatures/index.js @@ -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 API, 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. ), }, @@ -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. ), }