Skip to content
/ ai-jvm Public

Notebooks, Spring AI and LangChain4J examples

Notifications You must be signed in to change notification settings

upeter/ai-jvm

Repository files navigation

Sources Conference Talk: From 0 to H-AI-ro: fast track to AI for Kotlin developers.

Preparations

  • Install the Kotlin Notebooks plugin in IntelliJ
  • You need an OpenAI API key in your environment: OPENAI_API_KEY=<your-key>

LangChain4J with Spring Boot in module: /langchain4j

Run LangChain4J sample application

Play with Embeddings and Similarity

Data Ingestion

LangChain4J with ktor in module: /langchain4j-ktor

Run LangChain4J-ktor sample application

SpringAI in module: /spring-ai

Run SpringAI sample application

  • Provide the OpenAI key OPENAI_API_KEY in the environment
  • Start docker-compose: docker-compose up
  • Run application: SpringAIDemoApplication.kt
    • The first time it takes a while since the vector db is ingested using the spring-ai way
  • Run Samples in the notebook: spring-ai-demo.ipynb

Run KMP chat / audio client

  • Run KMP Chat Client main in Main.kt in the chatclient-kmp module

  • Chat Feature:

  • Voice Feature:

Kotlin MCP server + integration with Claude Desktop: /kotlin-mcp-server

  • MCP Server that exposes:

    • prompt: similar to system prompt in Spring-AI but tailored for MCP capabilities (resources and tools)
    • resource: the menu as MCP resource
    • tools: tools to classify, find dishes via vector search and ordering dish, all forwarding to the Spring-AI rest endpoints
  • Build the MCP Server with: ./gradlew jar

  • Open the Claude Desktop application -> Settings -> Developer and press Edit Config to locate the claude_desktop_config.json file.

  • Add the following configuration in claude_desktop_config.json:

    {
     "mcpServers": {
        "mcp-italian-delaight": {
         "command": "java",
         "args": ["-jar", "<project-path>/kotlin-mcp-server/build/libs/mcp-kt-jar-0.1.0.jar"]
        }
      } 
    }
    
    
    
  • Restart Claude Desktop and manually select the italian-meal-agent prompt that the MCP server exposes:

  • Now you can order your favorite dish. Buon Appetito 🍕🇮🇹🍝!

About

Notebooks, Spring AI and LangChain4J examples

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published