This is a port of https://github.com/langchain4j/langchain4j-examples to Kotlin.
The primary reason of this port is to learn Kotlin language and langchain4j library.
The repository uses devcontainer to setup the development environment.
So far I have used vscode with devcontainer extension to setup the development environment and the experience has not been optimal w.r.t kotlin extension support.
The repository uses gradle and has multiple subprojects.
Most examples are using OPENAI_API_KEY
. Make sure it is present in your environment variable.
./gradlew :<project_name>:run -PmainClass=<name_of_main_class>
# example
./gradlew :tutorials:run -PmainClass=_00_HelloWorld
./gradlew --console plain :rag-examples:run -PmainClass=_2_QueryCompression
# for examples that require arguments
./gradlew :<project_name>:run -PmainClass=<name_of_main_class> --args="<arguments>"
# example
./gradlew :tutorials:run -PmainClass=_03_PromptTemplate --args="simple"
- Simplest chat query
- Play with chat model parameters
- Generate an image using DALL-E
- Simple & Structured Prompt templating
- How to stream response
- Chat context memory
- How to use examples in context (Few Shot)
- Hello AiServices
- [AiService] Using SystemMessage in interface
- [AiService] Using SystemMessage & UserMessage in interface
- [AiService] StructuredOutput - A simple example
- [AiService] StructuredOutput - A bit more
- [AiService] StructuredOutput - More types
- [AiService] Include ChatMemory
- [AiService] Include ChatMemory for every user