Files
langchain4j-demo/quarkus-vs-spring-ai/README.md
T

41 lines
1.9 KiB
Markdown

# quarkus-vs-spring-ai
The same support assistant built twice: **Quarkus + Quarkus LangChain4j** and **Spring Boot + Spring AI**.
Companion to the ankurm.com post *Quarkus LangChain4j vs Spring AI: Same AI Service Built Twice*.
The assistant has a system prompt, one tool (`orderStatus`) and RAG over three policy files in `knowledge/`.
No API key is needed: both apps talk to `stub-llm`, a deterministic OpenAI-compatible stub (not a language model).
Timing numbers are therefore framework overhead only.
| Component | Version | Note |
|---|---|---|
| JDK | 25.0.5 (Temurin) | LTS; GraalVM for JDK 25.0.4 builds the native images |
| Quarkus | 3.40.1.1 | latest GA with a GA LangChain4j extension (Quarkus 4.0.1 is GA, its extension is 2.0.0.CR1) |
| Quarkus LangChain4j | 1.15.1 | brings LangChain4j 1.23.0 |
| Spring Boot | 4.2.0 | GA |
| Spring AI | 2.1.0 | GA |
## Run
```bash
export JAVA_HOME=/path/to/jdk-25
mvn install # builds both apps; the tests write output/11,12,21,22
scripts/start-stub.sh # stub LLM on :18089
java -Dquarkus.http.port=18080 -Dquarkus.langchain4j.openai.base-url=http://localhost:18089/v1 \
-jar quarkus-app/target/quarkus-app/quarkus-run.jar
curl 'localhost:18080/ask?q=Where+is+my+order+1001%3F'
```
`scripts/run-all.sh` regenerates all of `output/` (tests, wire capture, benchmarks; native step needs `GRAALVM_HOME`).
This module is a standalone Maven build: it is deliberately not part of the parent pom's `<modules>`.
## Layout
| Path | What |
|---|---|
| `quarkus-app/` | `SupportAssistant` (declarative AI service), `OrderTools`, `PolicyStore`, `PolicyRetrievalAugmentor` |
| `spring-ai-app/` | `AiConfig` (ChatClient, tools, `QuestionAnswerAdvisor`), `OrderTools`, `AskController` |
| `stub-llm/` | the OpenAI-compatible stub (chat completions and embeddings) |
| `scripts/` | `bench.py`, `wire.sh`, `run-all.sh` |
| `output/` | captured results the post quotes |