A FastAPI + vanilla JS chat app fronting an Anthropic Claude agent for order status, returns, and policy questions. Architecture: - agent.py: system prompt, runtime reminder injection, output validation, agentic tool-use loop with prompt caching on the system prompt block - tools.py: four tools (lookup_order, check_return_eligibility, initiate_return, lookup_policy) with per-session SessionGuardState enforcing protocol ordering on the tool side - mock_data.py: orders, return policy, and FAQ entries used as the single source of truth by both the prompt and the tools - server.py: FastAPI app exposing /api/chat, /health, and the static UI - static/: vanilla HTML/CSS/JS chat UI, no build step - tests/: 30 tests covering tool-side enforcement, the privacy boundary, output validation, and the agent loop with a mocked Anthropic client - deploy/: systemd unit and nginx site config for production
162 lines
2.9 KiB
CSS
162 lines
2.9 KiB
CSS
:root {
|
|
--bg: #f5f3ee;
|
|
--panel: #ffffff;
|
|
--ink: #1a1a1a;
|
|
--ink-muted: #6b6b6b;
|
|
--accent: #2e5b8a;
|
|
--accent-ink: #ffffff;
|
|
--bubble-user: #2e5b8a;
|
|
--bubble-user-ink: #ffffff;
|
|
--bubble-assistant: #ececec;
|
|
--bubble-assistant-ink: #1a1a1a;
|
|
--border: #e2ddd2;
|
|
}
|
|
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
html, body {
|
|
margin: 0;
|
|
padding: 0;
|
|
height: 100%;
|
|
background: var(--bg);
|
|
color: var(--ink);
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
font-size: 16px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.chat {
|
|
display: flex;
|
|
flex-direction: column;
|
|
max-width: 720px;
|
|
margin: 0 auto;
|
|
height: 100vh;
|
|
background: var(--panel);
|
|
border-left: 1px solid var(--border);
|
|
border-right: 1px solid var(--border);
|
|
}
|
|
|
|
.chat__header {
|
|
padding: 18px 24px;
|
|
border-bottom: 1px solid var(--border);
|
|
background: var(--panel);
|
|
}
|
|
|
|
.chat__header h1 {
|
|
margin: 0;
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
letter-spacing: -0.01em;
|
|
}
|
|
|
|
.chat__subtitle {
|
|
margin: 4px 0 0;
|
|
font-size: 13px;
|
|
color: var(--ink-muted);
|
|
}
|
|
|
|
.chat__messages {
|
|
flex: 1;
|
|
overflow-y: auto;
|
|
padding: 20px 24px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
|
|
.message {
|
|
max-width: 78%;
|
|
padding: 10px 14px;
|
|
border-radius: 16px;
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
font-size: 15px;
|
|
}
|
|
|
|
.message--user {
|
|
align-self: flex-end;
|
|
background: var(--bubble-user);
|
|
color: var(--bubble-user-ink);
|
|
border-bottom-right-radius: 4px;
|
|
}
|
|
|
|
.message--assistant {
|
|
align-self: flex-start;
|
|
background: var(--bubble-assistant);
|
|
color: var(--bubble-assistant-ink);
|
|
border-bottom-left-radius: 4px;
|
|
}
|
|
|
|
.message--typing {
|
|
display: inline-flex;
|
|
gap: 4px;
|
|
align-items: center;
|
|
}
|
|
|
|
.message--typing span {
|
|
width: 6px;
|
|
height: 6px;
|
|
background: var(--ink-muted);
|
|
border-radius: 50%;
|
|
opacity: 0.4;
|
|
animation: typing 1.2s infinite ease-in-out;
|
|
}
|
|
|
|
.message--typing span:nth-child(2) { animation-delay: 0.15s; }
|
|
.message--typing span:nth-child(3) { animation-delay: 0.3s; }
|
|
|
|
@keyframes typing {
|
|
0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
|
|
40% { opacity: 1; transform: translateY(-2px); }
|
|
}
|
|
|
|
.chat__composer {
|
|
display: flex;
|
|
gap: 10px;
|
|
padding: 14px 16px;
|
|
border-top: 1px solid var(--border);
|
|
background: var(--panel);
|
|
}
|
|
|
|
.chat__input {
|
|
flex: 1;
|
|
padding: 11px 14px;
|
|
font-size: 15px;
|
|
border: 1px solid var(--border);
|
|
border-radius: 22px;
|
|
outline: none;
|
|
background: var(--panel);
|
|
color: var(--ink);
|
|
}
|
|
|
|
.chat__input:focus {
|
|
border-color: var(--accent);
|
|
}
|
|
|
|
.chat__send {
|
|
padding: 11px 22px;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
color: var(--accent-ink);
|
|
background: var(--accent);
|
|
border: none;
|
|
border-radius: 22px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.chat__send:disabled {
|
|
opacity: 0.5;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
@media (max-width: 720px) {
|
|
.chat {
|
|
border: none;
|
|
}
|
|
.message {
|
|
max-width: 88%;
|
|
}
|
|
}
|