Spaces:
Runtime error
Runtime error
Commit ·
23fadf4
1
Parent(s): da9821a
Change index page content
Browse files
.gitignore
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
target/
|
| 2 |
+
app.jar
|
| 3 |
+
*.class
|
| 4 |
+
*.log
|
| 5 |
+
.idea/
|
| 6 |
+
*.iml
|
| 7 |
+
.DS_Store
|
multi-agent-customer-ops
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Subproject commit fdd6160dc4584144ae59663e6fea22f909aad0ed
|
pom.xml
CHANGED
|
@@ -24,7 +24,7 @@
|
|
| 24 |
</dependency>
|
| 25 |
<dependency>
|
| 26 |
<groupId>org.springframework.ai</groupId>
|
| 27 |
-
<artifactId>spring-ai-
|
| 28 |
</dependency>
|
| 29 |
|
| 30 |
<!-- Local spring-agent-flow framework -->
|
|
|
|
| 24 |
</dependency>
|
| 25 |
<dependency>
|
| 26 |
<groupId>org.springframework.ai</groupId>
|
| 27 |
+
<artifactId>spring-ai-mistral-ai-spring-boot-starter</artifactId>
|
| 28 |
</dependency>
|
| 29 |
|
| 30 |
<!-- Local spring-agent-flow framework -->
|
src/main/java/com/demo/agentflow/controller/SupportController.java
CHANGED
|
@@ -11,12 +11,16 @@ import org.springframework.web.bind.annotation.*;
|
|
| 11 |
import reactor.core.publisher.Flux;
|
| 12 |
|
| 13 |
import java.util.Map;
|
|
|
|
| 14 |
|
| 15 |
@RestController
|
| 16 |
@RequestMapping("/api/support")
|
| 17 |
public class SupportController {
|
| 18 |
|
| 19 |
private final AgentGraph supportGraph;
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
public SupportController(AgentGraph supportGraph) {
|
| 22 |
this.supportGraph = supportGraph;
|
|
@@ -26,6 +30,11 @@ public class SupportController {
|
|
| 26 |
public Flux<String> processSupportTicket(@RequestBody Map<String, String> request) {
|
| 27 |
String message = request.getOrDefault("message", "");
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
AgentContext context = AgentContext.empty()
|
| 30 |
.withMessage(new UserMessage(message));
|
| 31 |
|
|
@@ -47,6 +56,10 @@ public class SupportController {
|
|
| 47 |
text, intent, sentiment, orderStatus, decision);
|
| 48 |
}
|
| 49 |
return "{\"type\":\"ping\"}";
|
| 50 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
}
|
| 52 |
}
|
|
|
|
| 11 |
import reactor.core.publisher.Flux;
|
| 12 |
|
| 13 |
import java.util.Map;
|
| 14 |
+
import java.util.concurrent.atomic.AtomicInteger;
|
| 15 |
|
| 16 |
@RestController
|
| 17 |
@RequestMapping("/api/support")
|
| 18 |
public class SupportController {
|
| 19 |
|
| 20 |
private final AgentGraph supportGraph;
|
| 21 |
+
// Limit to 5 concurrent users
|
| 22 |
+
private final AtomicInteger activeRequests = new AtomicInteger(0);
|
| 23 |
+
private static final int MAX_CONCURRENT_REQUESTS = 5;
|
| 24 |
|
| 25 |
public SupportController(AgentGraph supportGraph) {
|
| 26 |
this.supportGraph = supportGraph;
|
|
|
|
| 30 |
public Flux<String> processSupportTicket(@RequestBody Map<String, String> request) {
|
| 31 |
String message = request.getOrDefault("message", "");
|
| 32 |
|
| 33 |
+
if (activeRequests.incrementAndGet() > MAX_CONCURRENT_REQUESTS) {
|
| 34 |
+
activeRequests.decrementAndGet();
|
| 35 |
+
return Flux.just("{\"type\":\"error\", \"message\":\"The demo is currently overloaded (>5 concurrent users). Please try again later or run it locally with your own Mistral API Key!\"}");
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
AgentContext context = AgentContext.empty()
|
| 39 |
.withMessage(new UserMessage(message));
|
| 40 |
|
|
|
|
| 56 |
text, intent, sentiment, orderStatus, decision);
|
| 57 |
}
|
| 58 |
return "{\"type\":\"ping\"}";
|
| 59 |
+
})
|
| 60 |
+
.onErrorResume(e -> {
|
| 61 |
+
return Flux.just("{\"type\":\"error\", \"message\":\"API Provider Error: Quota exceeded or LLM service unavailable. Clone the repo to run with your own key!\"}");
|
| 62 |
+
})
|
| 63 |
+
.doFinally(signalType -> activeRequests.decrementAndGet());
|
| 64 |
}
|
| 65 |
}
|
src/main/resources/application.yml
CHANGED
|
@@ -2,11 +2,9 @@ spring:
|
|
| 2 |
application:
|
| 3 |
name: multi-agent-customer-ops
|
| 4 |
ai:
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
api-key: ${GROQ_API_KEY:gsk_placeholder}
|
| 8 |
-
base-url: https://api.groq.com/openai/v1
|
| 9 |
chat:
|
| 10 |
options:
|
| 11 |
-
model:
|
| 12 |
temperature: 0.1
|
|
|
|
| 2 |
application:
|
| 3 |
name: multi-agent-customer-ops
|
| 4 |
ai:
|
| 5 |
+
mistralai:
|
| 6 |
+
api-key: ${MISTRAL_API_KEY:placeholder}
|
|
|
|
|
|
|
| 7 |
chat:
|
| 8 |
options:
|
| 9 |
+
model: open-mistral-nemo
|
| 10 |
temperature: 0.1
|
src/main/resources/static/index.html
CHANGED
|
@@ -23,8 +23,12 @@
|
|
| 23 |
|
| 24 |
<div class="max-w-6xl mx-auto">
|
| 25 |
<header class="mb-8 text-center">
|
| 26 |
-
<h1 class="text-
|
| 27 |
-
<p class="text-gray-600
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
</header>
|
| 29 |
|
| 30 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
@@ -54,7 +58,7 @@
|
|
| 54 |
<h2 class="font-semibold text-lg border-b pb-2 mb-4">2. Agent Pipeline (Real-time)</h2>
|
| 55 |
|
| 56 |
<div class="mb-4">
|
| 57 |
-
<div class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1">
|
| 58 |
<div id="pipelineSteps" class="space-y-2 text-sm font-mono bg-gray-50 p-3 rounded border h-32 overflow-y-auto">
|
| 59 |
<div class="text-gray-400 italic">Awaiting execution...</div>
|
| 60 |
</div>
|
|
@@ -139,6 +143,13 @@
|
|
| 139 |
// Update State JSON
|
| 140 |
stateOutput.innerHTML = JSON.stringify(data.state, null, 2);
|
| 141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
}
|
| 144 |
}
|
|
|
|
| 23 |
|
| 24 |
<div class="max-w-6xl mx-auto">
|
| 25 |
<header class="mb-8 text-center">
|
| 26 |
+
<h1 class="text-4xl font-extrabold text-blue-900 mb-3 tracking-tight">Multi-Agent Customer Support Demo</h1>
|
| 27 |
+
<p class="text-lg text-gray-600 max-w-3xl mx-auto">
|
| 28 |
+
This application demonstrates AI-driven customer support automation. It was built using
|
| 29 |
+
<a href="https://github.com/datallmhub/spring-agent-flow" target="_blank" class="text-blue-600 hover:text-blue-800 font-semibold underline decoration-blue-300 underline-offset-2 transition-colors">spring-agent-flow</a>,
|
| 30 |
+
our open-source Java multi-agent orchestration framework for Spring Boot.
|
| 31 |
+
</p>
|
| 32 |
</header>
|
| 33 |
|
| 34 |
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
|
|
|
|
| 58 |
<h2 class="font-semibold text-lg border-b pb-2 mb-4">2. Agent Pipeline (Real-time)</h2>
|
| 59 |
|
| 60 |
<div class="mb-4">
|
| 61 |
+
<div class="text-xs font-semibold text-gray-500 uppercase tracking-wider mb-1">Live Agent Routing</div>
|
| 62 |
<div id="pipelineSteps" class="space-y-2 text-sm font-mono bg-gray-50 p-3 rounded border h-32 overflow-y-auto">
|
| 63 |
<div class="text-gray-400 italic">Awaiting execution...</div>
|
| 64 |
</div>
|
|
|
|
| 143 |
// Update State JSON
|
| 144 |
stateOutput.innerHTML = JSON.stringify(data.state, null, 2);
|
| 145 |
}
|
| 146 |
+
else if (data.type === 'error') {
|
| 147 |
+
pipeline.innerHTML += `<div class="text-red-600 font-bold mt-2">[ERROR] Execution failed</div>`;
|
| 148 |
+
finalOutput.innerHTML = `<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded relative" role="alert">
|
| 149 |
+
<strong class="font-bold">Oops! </strong>
|
| 150 |
+
<span class="block sm:inline">${data.message}</span>
|
| 151 |
+
</div>`;
|
| 152 |
+
}
|
| 153 |
}
|
| 154 |
}
|
| 155 |
}
|