Add quarkus-vs-spring-ai module: the same support assistant (system prompt, tool, RAG) built with Quarkus LangChain4j and Spring AI against a stub OpenAI-compatible server, with wire-format capture, startup/memory benchmarks and a Quarkus native image
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b4XrpfdpsacrvqnrBM
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
f4f90b3b30
commit
5e5326c810
@@ -0,0 +1,4 @@
|
||||
question: Where is my order 1001?
|
||||
answer: STUB-ANSWER (from tool): Order 1001 is shipped on 2026-11-20, arriving in 2 days
|
||||
chat requests sent to the stub for this question: 2
|
||||
embedding requests for this question: 1
|
||||
@@ -0,0 +1,4 @@
|
||||
question: How many days do I have to return an item?
|
||||
answer: STUB-ANSWER (echo): How many days do I have to return an item? Answer using the following information: Returns policy: items can be returned within 30 days of delivery for a full refund. Items must be unused and in original packaging. Refunds are issued to the original payment method within 5 business days of the warehouse receiving the parcel.
|
||||
chat requests sent to the stub for this question: 1
|
||||
embedding requests for this question: 1
|
||||
@@ -0,0 +1,4 @@
|
||||
question: Where is my order 1001?
|
||||
answer: STUB-ANSWER (from tool): "Order 1001 is shipped on 2026-11-20, arriving in 2 days"
|
||||
chat requests sent to the stub for this question: 2
|
||||
embedding requests for this question: 2
|
||||
@@ -0,0 +1,4 @@
|
||||
question: How many days do I have to return an item?
|
||||
answer: STUB-ANSWER (echo): How many days do I have to return an item? Context information is below, surrounded by --------------------- --------------------- Returns policy: items can be returned within 30 days of delivery for a full refund. Items must be unused and in original packaging. Refunds are issued to the original payment method within 5 business days of the warehouse receiving the parcel. --------------------- Given the context and provided history information and not prior knowledge, reply to the user comment. If the answer is not in the context, inform the user that you can't answer the question.
|
||||
chat requests sent to the stub for this question: 1
|
||||
embedding requests for this question: 1
|
||||
@@ -0,0 +1,33 @@
|
||||
##### quarkus: 3 chat requests for 2 questions
|
||||
--- request 1: top-level keys = ['frequency_penalty', 'messages', 'model', 'presence_penalty', 'tools']
|
||||
[system] 'You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for or'
|
||||
[user] 'Where is my order 1001?'
|
||||
tools: [{"function": {"description": "Looks up the delivery status of a customer order by its order number", "name": "orderStatus", "parameters": {"properties": {"orderId": {"description": "the numeric order number, for example 1001", "type": "string"}}, "required": ["orderId"], "type": "object"}}, "type": "function"}]
|
||||
--- request 2: top-level keys = ['frequency_penalty', 'messages', 'model', 'presence_penalty', 'tools']
|
||||
[system] 'You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for or'
|
||||
[user] 'Where is my order 1001?'
|
||||
[assistant] 'None' tool_calls=[{"id": "call_stub_1", "type": "function", "function": {"name": "orderStatus", "arguments": "{\"orderId\":\"1001\"}"}}]
|
||||
[tool] 'Order 1001 is shipped on 2026-11-20, arriving in 2 days'
|
||||
tools: [{"function": {"description": "Looks up the delivery status of a customer order by its order number", "name": "orderStatus", "parameters": {"properties": {"orderId": {"description": "the numeric order number, for example 1001", "type": "string"}}, "required": ["orderId"], "type": "object"}}, "type": "function"}]
|
||||
--- request 3: top-level keys = ['frequency_penalty', 'messages', 'model', 'presence_penalty', 'tools']
|
||||
[system] 'You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for or'
|
||||
[user] 'How many days do I have to return an item?\n\nAnswer using the following information:\nReturns policy: items can '
|
||||
tools: [{"function": {"description": "Looks up the delivery status of a customer order by its order number", "name": "orderStatus", "parameters": {"properties": {"orderId": {"description": "the numeric order number, for example 1001", "type": "string"}}, "required": ["orderId"], "type": "object"}}, "type": "function"}]
|
||||
|
||||
##### spring: 3 chat requests for 2 questions
|
||||
--- request 1: top-level keys = ['messages', 'model', 'tools']
|
||||
[system] 'You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for or'
|
||||
[user] 'Where is my order 1001?\n\nContext information is below, surrounded by ---------------------\n\n------------------'
|
||||
tools: [{"function": {"description": "Looks up the delivery status of a customer order by its order number", "name": "orderStatus", "parameters": {"$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": false, "properties": {"orderId": {"description": "the numeric order number, for example 1001", "type": "string"}}, "required": ["orderId"], "type": "object"}, "strict": false}, "type": "function"}]
|
||||
--- request 2: top-level keys = ['messages', 'model', 'tools']
|
||||
[system] 'You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for or'
|
||||
[user] 'Where is my order 1001?\n\nContext information is below, surrounded by ---------------------\n\n------------------'
|
||||
[assistant] '' tool_calls=[{"id": "call_stub_1", "function": {"arguments": "{\"orderId\":\"1001\"}", "name": "orderStatus"}, "type": "function"}]
|
||||
[tool] '"Order 1001 is shipped on 2026-11-20, arriving in 2 days"'
|
||||
tools: [{"function": {"description": "Looks up the delivery status of a customer order by its order number", "name": "orderStatus", "parameters": {"$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": false, "properties": {"orderId": {"description": "the numeric order number, for example 1001", "type": "string"}}, "required": ["orderId"], "type": "object"}, "strict": false}, "type": "function"}]
|
||||
--- request 3: top-level keys = ['messages', 'model', 'tools']
|
||||
[system] 'You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for or'
|
||||
[user] 'How many days do I have to return an item?\n\nContext information is below, surrounded by ---------------------\n'
|
||||
tools: [{"function": {"description": "Looks up the delivery status of a customer order by its order number", "name": "orderStatus", "parameters": {"$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": false, "properties": {"orderId": {"description": "the numeric order number, for example 1001", "type": "string"}}, "required": ["orderId"], "type": "object"}, "strict": false}, "type": "function"}]
|
||||
|
||||
tool declaration identical: False
|
||||
@@ -0,0 +1,23 @@
|
||||
host: 2 cpus, load average at start 0.2 (other processes were running)
|
||||
|
||||
== quarkus-jvm (7 runs)
|
||||
metric run1 run2 run3 run4 run5 run6 run7 median
|
||||
t_port 2190 1594 1545 1386 1433 1454 1563 1545
|
||||
t_first 2600 1922 1851 1641 1695 1735 1907 1851
|
||||
cpu_first 3350 3030 2980 2720 2750 2860 3160 2980
|
||||
rss_first 146.3 147.4 145.4 143.8 133.6 140.9 145.9 145.4
|
||||
rss_after 172.4 173.5 168.2 174.1 170.1 172.5 169.5 172.4
|
||||
p50 13.3 10.0 11.2 11.8 11.1 10.8 10.7 11.1
|
||||
p95 28.2 23.2 24.3 23.7 23.9 18.2 21.7 23.7
|
||||
|
||||
== spring-jvm (7 runs)
|
||||
metric run1 run2 run3 run4 run5 run6 run7 median
|
||||
t_port 11053 4949 4816 4776 5049 4818 5345 4949
|
||||
t_first 12002 5635 5548 5598 6065 5656 6277 5656
|
||||
cpu_first 11770 10160 10280 10090 11150 10050 11490 10280
|
||||
rss_first 301.2 300.2 326.2 306.5 326.4 308.1 300.0 306.5
|
||||
rss_after 313.8 312.8 337.7 321.0 335.6 318.4 312.0 318.4
|
||||
p50 11.2 9.6 10.3 10.5 8.6 9.9 9.4 9.9
|
||||
p95 23.6 22.0 23.0 25.7 20.7 22.8 22.8 22.8
|
||||
|
||||
load average at end 2.2
|
||||
@@ -0,0 +1,13 @@
|
||||
host: 2 cpus, load average at start 0.2 (other processes were running)
|
||||
|
||||
== quarkus-native (7 runs)
|
||||
metric run1 run2 run3 run4 run5 run6 run7 median
|
||||
t_port 30 33 38 33 39 33 27 33
|
||||
t_first 58 42 51 44 52 42 36 44
|
||||
cpu_first 20 30 40 30 30 30 30 30
|
||||
rss_first 52.0 51.9 51.9 51.9 52.1 51.9 51.9 51.9
|
||||
rss_after 96.8 94.4 96.7 93.8 97.0 96.7 96.6 96.7
|
||||
p50 3.6 3.5 3.4 3.5 3.1 3.2 3.3 3.4
|
||||
p95 5.7 5.8 5.0 5.0 5.9 4.6 4.7 5.0
|
||||
|
||||
load average at end 0.3
|
||||
@@ -0,0 +1,7 @@
|
||||
Spring Boot 4.2.0 / Spring AI 2.1.0 native-image attempt (GraalVM for JDK 25.0.4, 2 CPUs, 8 GB host)
|
||||
command: mvn -Pnative -DskipTests native:compile
|
||||
Build resources:
|
||||
- 4.87GB of memory (75.6% of system memory, in container)
|
||||
- 2 thread(s) (100.0% of 2 available processor(s), determined at start)
|
||||
Terminating due to java.lang.OutOfMemoryError: Java heap space
|
||||
The Native Image build process ran out of memory.
|
||||
@@ -0,0 +1,7 @@
|
||||
Quarkus JVM (fast-jar) directory : 27964 KiB, 125 jars in lib/main
|
||||
Spring Boot executable jar : 135777615 bytes, 120 nested jars
|
||||
Quarkus native executable : 72223056 bytes
|
||||
Quarkus native build time : 6m 25s (native-image step, 2 CPUs; a first attempt on a busier host took 15m 40s)
|
||||
Largest Spring nested jar : openai-java-core-4.101.0.jar, 74924097 bytes
|
||||
Quarkus native, self-reported : quarkus-app 1.0.0 native (powered by Quarkus 3.40.1.1) started in 0.087s
|
||||
Quarkus dev mode, self-reported : quarkus-app 1.0.0 on JVM (powered by Quarkus 3.40.1.1) started in 4.303s. | Profile dev activated. Live Coding activated.
|
||||
@@ -0,0 +1,7 @@
|
||||
$ curl -s localhost:18080/q/dev-ui/quarkus-langchain4j-core-data.js # while running: mvn quarkus:dev
|
||||
// Generated by Quarkus during Build
|
||||
export const systemMessages = ["You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for order questions and the supplied policy text for policy questions."];
|
||||
export const toolProviders = [];
|
||||
export const aiservices = [{"clazz":"com.ankurm.qvs.SupportAssistant","tools":["com.ankurm.qvs.OrderTools"]}];
|
||||
export const tools = [{"className":"com.ankurm.qvs.OrderTools","name":"orderStatus","description":"Looks up the delivery status of a customer order by its order number"}];
|
||||
export const envVarMappings = {"OPENAI_API_KEY":"quarkus.langchain4j.openai.api-key"};
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"model" : "stub-chat",
|
||||
"messages" : [ {
|
||||
"role" : "system",
|
||||
"content" : "You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for order questions and the supplied policy text for policy questions."
|
||||
}, {
|
||||
"role" : "user",
|
||||
"content" : "Where is my order 1001?"
|
||||
} ],
|
||||
"presence_penalty" : 0.0,
|
||||
"frequency_penalty" : 0.0,
|
||||
"tools" : [ {
|
||||
"type" : "function",
|
||||
"function" : {
|
||||
"name" : "orderStatus",
|
||||
"description" : "Looks up the delivery status of a customer order by its order number",
|
||||
"parameters" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"orderId" : {
|
||||
"type" : "string",
|
||||
"description" : "the numeric order number, for example 1001"
|
||||
}
|
||||
},
|
||||
"required" : [ "orderId" ]
|
||||
}
|
||||
}
|
||||
} ]
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"model" : "stub-chat",
|
||||
"messages" : [ {
|
||||
"role" : "system",
|
||||
"content" : "You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for order questions and the supplied policy text for policy questions."
|
||||
}, {
|
||||
"role" : "user",
|
||||
"content" : "Where is my order 1001?"
|
||||
}, {
|
||||
"role" : "assistant",
|
||||
"tool_calls" : [ {
|
||||
"id" : "call_stub_1",
|
||||
"type" : "function",
|
||||
"function" : {
|
||||
"name" : "orderStatus",
|
||||
"arguments" : "{\"orderId\":\"1001\"}"
|
||||
}
|
||||
} ]
|
||||
}, {
|
||||
"role" : "tool",
|
||||
"tool_call_id" : "call_stub_1",
|
||||
"content" : "Order 1001 is shipped on 2026-11-20, arriving in 2 days"
|
||||
} ],
|
||||
"presence_penalty" : 0.0,
|
||||
"frequency_penalty" : 0.0,
|
||||
"tools" : [ {
|
||||
"type" : "function",
|
||||
"function" : {
|
||||
"name" : "orderStatus",
|
||||
"description" : "Looks up the delivery status of a customer order by its order number",
|
||||
"parameters" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"orderId" : {
|
||||
"type" : "string",
|
||||
"description" : "the numeric order number, for example 1001"
|
||||
}
|
||||
},
|
||||
"required" : [ "orderId" ]
|
||||
}
|
||||
}
|
||||
} ]
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"model" : "stub-chat",
|
||||
"messages" : [ {
|
||||
"role" : "system",
|
||||
"content" : "You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for order questions and the supplied policy text for policy questions."
|
||||
}, {
|
||||
"role" : "user",
|
||||
"content" : "How many days do I have to return an item?\n\nAnswer using the following information:\nReturns policy: items can be returned within 30 days of delivery for a full refund. Items must be unused and in original packaging. Refunds are issued to the original payment method within 5 business days of the warehouse receiving the parcel."
|
||||
} ],
|
||||
"presence_penalty" : 0.0,
|
||||
"frequency_penalty" : 0.0,
|
||||
"tools" : [ {
|
||||
"type" : "function",
|
||||
"function" : {
|
||||
"name" : "orderStatus",
|
||||
"description" : "Looks up the delivery status of a customer order by its order number",
|
||||
"parameters" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"orderId" : {
|
||||
"type" : "string",
|
||||
"description" : "the numeric order number, for example 1001"
|
||||
}
|
||||
},
|
||||
"required" : [ "orderId" ]
|
||||
}
|
||||
}
|
||||
} ]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"messages" : [ {
|
||||
"content" : "You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for order questions and the supplied policy text for policy questions.",
|
||||
"role" : "system"
|
||||
}, {
|
||||
"content" : "Where is my order 1001?\n\nContext information is below, surrounded by ---------------------\n\n---------------------\n---------------------\n\nGiven the context and provided history information and not prior knowledge,\nreply to the user comment. If the answer is not in the context, inform\nthe user that you can't answer the question.\n",
|
||||
"role" : "user"
|
||||
} ],
|
||||
"model" : "stub-chat",
|
||||
"tools" : [ {
|
||||
"function" : {
|
||||
"name" : "orderStatus",
|
||||
"description" : "Looks up the delivery status of a customer order by its order number",
|
||||
"parameters" : {
|
||||
"$schema" : "https://json-schema.org/draft/2020-12/schema",
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"orderId" : {
|
||||
"type" : "string",
|
||||
"description" : "the numeric order number, for example 1001"
|
||||
}
|
||||
},
|
||||
"required" : [ "orderId" ],
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"strict" : false
|
||||
},
|
||||
"type" : "function"
|
||||
} ]
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"messages" : [ {
|
||||
"content" : "You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for order questions and the supplied policy text for policy questions.",
|
||||
"role" : "system"
|
||||
}, {
|
||||
"content" : "Where is my order 1001?\n\nContext information is below, surrounded by ---------------------\n\n---------------------\n---------------------\n\nGiven the context and provided history information and not prior knowledge,\nreply to the user comment. If the answer is not in the context, inform\nthe user that you can't answer the question.\n",
|
||||
"role" : "user"
|
||||
}, {
|
||||
"role" : "assistant",
|
||||
"content" : "",
|
||||
"tool_calls" : [ {
|
||||
"id" : "call_stub_1",
|
||||
"function" : {
|
||||
"arguments" : "{\"orderId\":\"1001\"}",
|
||||
"name" : "orderStatus"
|
||||
},
|
||||
"type" : "function"
|
||||
} ]
|
||||
}, {
|
||||
"content" : "\"Order 1001 is shipped on 2026-11-20, arriving in 2 days\"",
|
||||
"role" : "tool",
|
||||
"tool_call_id" : "call_stub_1"
|
||||
} ],
|
||||
"model" : "stub-chat",
|
||||
"tools" : [ {
|
||||
"function" : {
|
||||
"name" : "orderStatus",
|
||||
"description" : "Looks up the delivery status of a customer order by its order number",
|
||||
"parameters" : {
|
||||
"$schema" : "https://json-schema.org/draft/2020-12/schema",
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"orderId" : {
|
||||
"type" : "string",
|
||||
"description" : "the numeric order number, for example 1001"
|
||||
}
|
||||
},
|
||||
"required" : [ "orderId" ],
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"strict" : false
|
||||
},
|
||||
"type" : "function"
|
||||
} ]
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"messages" : [ {
|
||||
"content" : "You are the support assistant of an online electronics shop. Answer in one sentence. Use the order tool for order questions and the supplied policy text for policy questions.",
|
||||
"role" : "system"
|
||||
}, {
|
||||
"content" : "How many days do I have to return an item?\n\nContext information is below, surrounded by ---------------------\n\n---------------------\nReturns policy: items can be returned within 30 days of delivery for a full refund. Items must be unused and in original packaging. Refunds are issued to the original payment method within 5 business days of the warehouse receiving the parcel.\n---------------------\n\nGiven the context and provided history information and not prior knowledge,\nreply to the user comment. If the answer is not in the context, inform\nthe user that you can't answer the question.\n",
|
||||
"role" : "user"
|
||||
} ],
|
||||
"model" : "stub-chat",
|
||||
"tools" : [ {
|
||||
"function" : {
|
||||
"name" : "orderStatus",
|
||||
"description" : "Looks up the delivery status of a customer order by its order number",
|
||||
"parameters" : {
|
||||
"$schema" : "https://json-schema.org/draft/2020-12/schema",
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"orderId" : {
|
||||
"type" : "string",
|
||||
"description" : "the numeric order number, for example 1001"
|
||||
}
|
||||
},
|
||||
"required" : [ "orderId" ],
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"strict" : false
|
||||
},
|
||||
"type" : "function"
|
||||
} ]
|
||||
}
|
||||
Reference in New Issue
Block a user