llm-apps-java-spring-ai

ThomasVitaleApache-2.0活跃维护

基于 Spring AI 和 Spring Boot 的 Java 示例集,演示如何接入 OpenAI、Ollama 等模型,实现 RAG、向量嵌入等生成式 AI 应用。

Samples showing how to build Java applications powered by Generative AI and LLMs using Spring AI and Spring Boot.

暂无版本788star +1 / 7 天192fork同步于 2026-11-10 11:55 UTC

怎么上手

由 README 提炼,执行前请确认
需先安装 Java 25 与 Podman/Docker,再进入对应示例目录运行
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求;本地推理通过 Ollama 运行,需 Podman/Docker 启动相关容器。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用 Spring AI 和 Spring Boot 构建 Java 生成式 AI 应用的示例集合

基于 Spring AI 和 Spring Boot 的 Java 示例集,演示如何接入 OpenAI、Ollama 等模型,实现 RAG、向量嵌入等生成式 AI 应用。

核心能力

  • 覆盖聊天、RAG、语义搜索、结构化抽取等用例
  • 演示 Mistral AI、Ollama、OpenAI 多模型接入
  • 包含提示模板、结构化输出、工具调用、记忆等模式
  • 提供文档读取、切分与向量化入库示例
  • 含输入输出护栏与 LLM 可观测性示例

容易踩的坑

需要 Java 25,版本过低无法编译;多数示例依赖 Ollama 本地模型,需提前拉取模型;RAG 与语义搜索示例还需 PGVector 数据库容器。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    LLM and AI-Infused Applications with Java & Spring AI

    Samples showing how to build Java applications powered by Generative AI and Large Language Models (LLMs) using Spring AI.

    🛠️ Pre-Requisites

    • Java 25
    • Podman/Docker

    💡 Use Cases

    🧠 Models

    Chat Models

    Chat completion with LLMs via different model providers:

    Decision Models

    Typed probabilistic decisions with decision models via different model providers:

    Embedding Models

    Vector transformation (embeddings) with LLMs via different model providers:

    Image Models

    Image generation with LLMs via different model providers:

    Audio Models

    Speech generation with LLMs via different model providers:

    Speech transcription with LLMs via different model providers:

    Moderation Models

    Coming soon

    📐 Patterns

    Prompts, Messages, and Templates

    Prompting using simple text:

    Prompting using structured messages and roles:

    Prompting using templates:

    Structured Output

    Converting LLM output to structured JSON and Java objects:

    Multimodality

    Including various media in prompts with LLMs:

    Tool Calling

    Tool calling with LLMs via different model providers:

    Memory

    Using chat memory to preserve context in conversations with LLMs:

    Guardrails

    Guardrails for input and output with LLMs via different model providers:

    📥 Data Ingestion

    Document Readers

    Reading and vectorizing documents with LLMs via Ollama:

    Document Transformers

    Document transformation with LLMs via Ollama:

    • Metadata
      Enrich documents with keywords and summary metadata for enhanced retrieval.
    • Splitters
      Divide documents into chunks to fit the LLM context window.

    🔢 Vector Stores

    Coming soon

    🔄 Retrieval Augmented Generation (RAG)

    Question answering with documents using different RAG flows (with Ollama and PGVector):

    Sequential RAG

    Branching RAG

    Conditional RAG

    📊 Observability

    LLM Observability

    LLM Observability for different model providers:

    Vector Store Observability

    Vector Store Observability for different vector stores:

    ⚙️ Model Context Protocol

    Integrations with MCP Servers for providing contexts to LLMs.

    📋 Evaluation

    Coming soon

    🤖 Agents

    Coming soon

    📚 References and Additional Resources

    Conferences

    Videos

    Demos

    Workshops