Skip to content

Latest commit

 

History

History
117 lines (79 loc) · 5.38 KB

README.md

File metadata and controls

117 lines (79 loc) · 5.38 KB

Kotlin AI Examples

Kotlin AI Examples is a repository showcasing various AI frameworks integrated into Kotlin-based projects.
Here you’ll find ready-to-use examples for Spring AI, LangChain4j, as well as interactive Kotlin notebooks.


Contents

Kotlin Projects Kotlin Notebooks 🚀 Getting Started ⚙ Prerequisites

Kotlin Projects (/projects)

This section contains complete Kotlin projects demonstrating AI integrations.

Spring AI Examples (/projects/spring-ai)

  • helloworld: Basic example of using Spring AI
  • spring-ai-examples: A comprehensive set of Spring AI feature demonstrations and examples
  • playground-flight-booking: An AI-powered flight booking system demo using multiple providers (OpenAI, VertexAI Gemini, Azure OpenAI, Groq, Anthropic Claude)
  • spring-ai-mcp-server-example: spring mcp server sample
  • springAI-demo: a Spring Boot application with Spring AI and Kotlin that loads Kotlin standard library documents into a Qdrant vector store, implements endpoints for similarity search and a RAG-powered chat interface, and integrates an LLM for detailed, document-driven answers.

LangChain4j Examples (/projects/langchain4j)

MCP Examples (/projects/mcp)

  • mcp-demo: this tutorial briefly describes the process of creating an MCP server in Kotlin to work with stock data from FMP, connecting it to Claude for Desktop, and developing a custom client based on OpenAI using Compose.

Kotlin Notebooks (/notebooks)

A collection of interactive Jupyter notebooks in Kotlin, organized by project.

Spring AI Kotlin Notebooks (/notebooks/spring-ai)

LangChain4j Kotlin Notebooks (/notebooks/langchain4j)

  • LangChain4j_Overview.ipynb: overview of LangChain4j with Kotlin, demonstrating how to work with chat models, manage prompts, streaming, and produce structured responses.
  • SummarizingDocuments.ipynb: demonstrates how to split large text documents into smaller chunks, summarize each chunk with an AI model, and then merge the summaries into a concise final result.

Agents ReaCtor (ARC) Kotlin Notebooks (/notebooks/arc)

  • WeatherAgent.ipynb: demonstrates creating an agent that retrieves real-time weather data for a specified location via WeatherAPI
  • SummarizerAgent.ipynb: demonstrates creating an agent that summarizes web pages (e.g., blog posts) by processing HTML and generating concise summaries

KInference Kotlin Notebooks (/notebooks/kInference)

  • KIClassification.ipynb: how to set up a classification environment using the KIEngine framework, manage cached data files, and perform inference on input data.
  • KIGPT2.ipynb: how to configure and run a GPT-2 model with KIEngine, handling tokenization, caching, and text generation.
  • ORTClassification.ipynb: how to perform classification using ORT-based inference, handling data loading, caching, and model execution steps.
  • ORTGPT2.ipynb: how to run GPT-2 inference using the ORT engine, handling tokenization, caching, and generation of text outputs.

xef.ai Kotlin Notebooks (/notebooks/xefAI)


Getting Started

Each project in the projects directory has its own README with detailed instructions on how to run and use the examples.


Prerequisites

  • Java 17+
  • Kotlin
  • Appropriate AI provider API keys (see each project’s README for more details)

Note
Make sure you have the necessary access credentials for your chosen AI service (OpenAI, Azure, VertexAI, etc.) and the required dependencies in your build scripts (Gradle/Maven).

⭐ If you enjoy this repository, please give it a star!


License

This project is licensed under the Apache License 2.0.