Skip to content

Commit b60f8a4

Browse files
authored
feat: chatbot slowness scenario, some local fixes (#18)
fix: reverting frontend APM frontend changes for now adding PR template adding PR template fixing synthetic pr template patch
1 parent 9bffe56 commit b60f8a4

File tree

6 files changed

+342
-16
lines changed

6 files changed

+342
-16
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
🚀 Pull Request
2+
========================
3+
4+
🎯 PR Type
5+
----------
6+
- [ ] **Feature:** Adds new functionality or user-facing change.
7+
- [ ] **Bug Fix:** Solves a defect or incorrect behavior.
8+
- [ ] **Refactor:** Improves code structure/readability without changing external behavior.
9+
- [ ] **Documentation:** Updates to README, Wiki, or internal docs.
10+
- [ ] **Chore:** Non-code changes (e.g., CI configuration, dependency bumps).
11+
12+
1\. Issue Tracking & Reference
13+
------------------------------
14+
- **Ticket Number(s):** [e.g., JIRA-123, GH-456]
15+
- **Ticket Link(s):** [Insert direct URL to the issue/ticket here]
16+
17+
2\. Summary of Changes
18+
----------------------
19+
Briefly describe the purpose of this PR. What is the overall goal it achieves?
20+
- **Expected Outcome:** [What should the user or system see after this PR is merged and deployed? (e.g., "New pricing page goes live," "Latency decreases by 100ms," "Bug X is resolved.")]
21+
22+
### Detailed Change Log & Justification
23+
List each significant change made in this PR. For each, provide a brief justification explaining *why* the change was necessary (e.g., to fix a bug, meet a requirement, or improve performance).
24+
- **Change 1:** [Description of the change, e.g., "Updated `UserController.js` to handle null user inputs."]
25+
- **Justification:** [e.g., "This prevents a server crash when a user submits an empty form."]
26+
- **Change 2:** [Description of the change]
27+
- **Justification:** [Explanation of why this change was made]
28+
29+
3\. Testing
30+
-----------
31+
Describe how you tested this PR. The quality of testing directly impacts the speed of review and deployment.
32+
33+
### Testing Strategy
34+
- **Environment Used:** (e.g., Local, Sandbox, Staging)
35+
- **Production Safety Assessment:** [Why do you believe this change is safe to deploy to production? (e.g., "Covered by comprehensive unit and integration tests," "It's an idempotent, non-breaking change," "Only touches static asset files.")]
36+
- **What areas were NOT tested and why?** (e.g., "Did not test old IE browsers as they are deprecated.")
37+
38+
### Coverage Details
39+
40+
| Scenario | Details | Results |
41+
| ------------- | -------------------------------------------------------------------------- | --------------------------------- |
42+
| Happy Path | [List sequential steps for the primary intended use case.] | [Add notes on outcome of testing] |
43+
| Edge Case 1 | [Test boundaries: null values, zero, max limits, concurrent actions, etc.] | [Add notes on outcome of testing] |
44+
| Edge Case ... | [Test boundaries: null values, zero, max limits, concurrent actions, etc.] | [Add notes on outcome of testing] |
45+
46+
4\. Evidence
47+
------------
48+
Provide evidence of successful testing.
49+
- **Screenshots/Gifs:** [Paste image links or attach screenshots here]
50+
- **Console/Log Output Snippets:** [Paste relevant logs or links to log files]
51+
- **Test Report Links:** [Link to test runs, etc.]
52+
53+
_Testing and evidence are **REQUIRED** before requesting review!_
54+
55+
5\. Review and Merge Checklist
56+
------------------------------
57+
Confirm the following prerequisites have been met by checking the boxes:
58+
- [ ] All blocking review comments from the latest round are **resolved**.
59+
- [ ] This branch has been rebased against the `main` branch and all **merge conflicts are resolved**.
60+
- [ ] The code includes sufficient comments, particularly in complex or non-obvious areas.
61+
- [ ] The code adheres to project **coding standards** (linting, style guides, best practices).
62+
- [ ] Relevant documentation and runbooks have been updated, if necessary.
63+
- [ ] My changes generate no new warnings or errors.
64+
- [ ] My commits are squashed into a single, descriptive commit.

chatbot_service/chatbot_service.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import logging
33
import json
4+
import ssl
45
from contextlib import asynccontextmanager
56
from typing import Optional
67
from typing import Any
@@ -52,7 +53,17 @@ class HealthResponse(BaseModel):
5253

5354
# https://mcp.deepwiki.com/sse
5455

55-
mcp_client = Client(server_config)
56+
# Create SSL context that doesn't verify certificates (for self-signed certs)
57+
ssl_context = ssl.create_default_context()
58+
ssl_context.check_hostname = False
59+
ssl_context.verify_mode = ssl.CERT_NONE
60+
61+
try:
62+
mcp_client = Client(server_config, ssl_context=ssl_context)
63+
except TypeError:
64+
# If Client doesn't accept ssl_context parameter, try without it
65+
logger.warning("Client does not support ssl_context parameter, proceeding without SSL verification override")
66+
mcp_client = Client(server_config)
5667

5768
async def get_tools() -> list[Tool]:
5869
"""

frontend_service/app/routes/support.tsx

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,45 @@ export default function SupportPage() {
3232

3333
useEffect(scrollToBottom, [messages, isBotTyping]);
3434

35+
// Demo scenario: Blocking synchronous Fibonacci calculation
36+
const calculateFibonacci = (n: number): number => {
37+
if (n <= 1) return n;
38+
return calculateFibonacci(n - 1) + calculateFibonacci(n - 2);
39+
};
40+
3541
const handleSend = async () => {
3642
if (!inputMessage.trim()) return;
3743

3844
const userMessageText = inputMessage.trim();
45+
46+
// Demo scenario
47+
// Check for spending analysis triggers
48+
// This will match variations like:
49+
// - "analyze my spending"
50+
// - "Analyze my spending."
51+
// - "analyse my spending"
52+
// - "spending analysis"
53+
// - "check my spending"
54+
const spendingAnalysisTriggers = [
55+
/analyz[e]?\s+my\s+spending/i,
56+
/analys[e]?\s+spending/i,
57+
/spending\s+analys[ie]s/i,
58+
/check\s+my\s+spending/i
59+
];
60+
61+
const isSpendingAnalysis = spendingAnalysisTriggers.some(
62+
pattern => pattern.test(userMessageText)
63+
);
64+
65+
if (isSpendingAnalysis) {
66+
// Demo scenario: Simulates heavy computation on main thread
67+
// This blocks the UI from updating before the user sees their message
68+
console.warn('[DEMO] Running blocking Fibonacci calculation for spending analysis...');
69+
const startTime = performance.now();
70+
const result = calculateFibonacci(42); // ~3-5 seconds on average CPU
71+
const endTime = performance.now();
72+
console.warn(`[DEMO] Blocking calculation complete: fib(42) = ${result}, took ${(endTime - startTime).toFixed(0)}ms`);
73+
}
3974
const newUserMessage: ChatMessage = {
4075
id: Date.now(),
4176
text: userMessageText,
@@ -44,7 +79,7 @@ export default function SupportPage() {
4479
};
4580

4681
// 1. Add user message and clear input
47-
setMessages((prev) => [...prev, newUserMessage]);
82+
setMessages((prev: ChatMessage[]) => [...prev, newUserMessage]);
4883
setInputMessage('');
4984
setIsBotTyping(true);
5085

@@ -75,23 +110,23 @@ export default function SupportPage() {
75110
timestamp: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
76111
};
77112

78-
setMessages((prev) => [...prev, newBotMessage]);
113+
setMessages((prev: ChatMessage[]) => [...prev, newBotMessage]);
79114

80-
} catch (error) {
115+
} catch (error: unknown) {
81116
console.error("Chatbot API call failed:", error);
82117
const errorMessage: ChatMessage = {
83118
id: Date.now() + 1,
84-
text: `Sorry, I couldn't connect to the support service. Please ensure the chatbot service is running. Error: ${error.message}`,
119+
text: `Sorry, I couldn't connect to the support service. Please ensure the chatbot service is running. Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
85120
sender: 'bot',
86121
timestamp: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
87122
};
88-
setMessages((prev) => [...prev, errorMessage]);
123+
setMessages((prev: ChatMessage[]) => [...prev, errorMessage]);
89124
} finally {
90125
setIsBotTyping(false);
91126
}
92127
};
93128

94-
const handleKeyPress = (e: React.KeyboardEvent) => {
129+
const handleKeyPress = (e: any) => {
95130
if (e.key === 'Enter' && !e.shiftKey) {
96131
e.preventDefault();
97132
handleSend();
@@ -163,7 +198,7 @@ export default function SupportPage() {
163198
flexDirection: 'column'
164199
}}
165200
>
166-
{messages.map((message) => (
201+
{messages.map((message: ChatMessage) => (
167202
<MessageBubble key={message.id} message={message} />
168203
))}
169204

@@ -192,7 +227,7 @@ export default function SupportPage() {
192227
autoFocus
193228
size="small"
194229
value={inputMessage}
195-
onChange={(e) => setInputMessage(e.target.value)}
230+
onChange={(e: any) => setInputMessage(e.target.value)}
196231
onKeyPress={handleKeyPress}
197232
disabled={isBotTyping}
198233
/>

frontend_service/vite.config.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import tailwindcss from "@tailwindcss/vite";
33
import { defineConfig } from "vite";
44
import tsconfigPaths from "vite-tsconfig-paths";
55

6-
export default defineConfig({
6+
export default defineConfig(({ mode }: { mode: string }) => ({
77
plugins: [tailwindcss(), reactRouter({
88
// FIX: Add historyApiFallback to ensure deep links (like /dashboard) fall back to index.html
99
historyApiFallback: {
@@ -18,5 +18,19 @@ export default defineConfig({
1818
clientPort: 3000
1919
},
2020
allowedHosts: ['relibank.westus2.cloudapp.azure.com'],
21+
// Only use proxy in development mode (local machine)
22+
// In production, the ingress handles routing to backend services
23+
...(mode === 'development' && {
24+
proxy: {
25+
'/chatbot-service': {
26+
target: 'http://chatbot-service:5003',
27+
changeOrigin: true
28+
},
29+
'/bill-pay-service': {
30+
target: 'http://bill-pay-service:5000',
31+
changeOrigin: true
32+
}
33+
}
34+
})
2135
},
22-
});
36+
}));

k8s/base/databases/mssql-deployment.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ spec:
3838
name: database-credentials
3939
key: MSSQL_SA_PASSWORD
4040
- name: MSSQL_MEMORY_LIMIT_MB
41-
value: "3072"
41+
value: "1024"
4242
- name: MSSQL_PID
4343
value: "Developer"
4444
resources:
4545
requests:
46-
memory: "4Gi"
47-
cpu: "2000m"
46+
memory: "1Gi"
47+
cpu: "500m"
4848
limits:
49-
memory: "4Gi"
50-
cpu: "2000m"
49+
memory: "2Gi"
50+
cpu: "1000m"
5151
volumeMounts:
5252
- name: mssql
5353
mountPath: "/var/opt/mssql"

0 commit comments

Comments
 (0)