Adding Information page
Browse files- app/templates/base.html +2 -2
- app/templates/home.html +165 -4
- app/ui.py +4 -0
app/templates/base.html
CHANGED
|
@@ -50,7 +50,7 @@
|
|
| 50 |
opacity: 0.6;
|
| 51 |
z-index: 0;
|
| 52 |
}
|
| 53 |
-
|
| 54 |
/* Code rain canvas (behind everything) */
|
| 55 |
#code-rain {
|
| 56 |
position: fixed;
|
|
@@ -155,7 +155,7 @@
|
|
| 155 |
<nav>
|
| 156 |
<a href="/chat">Chat</a>
|
| 157 |
<a href="/dev">Dev</a>
|
| 158 |
-
<a href="/
|
| 159 |
<a href="https://github.com/agent-matrix/matrix-ai" target="_blank" rel="noreferrer" title="Give me a star on GitHub!">GitHub</a>
|
| 160 |
|
| 161 |
</nav>
|
|
|
|
| 50 |
opacity: 0.6;
|
| 51 |
z-index: 0;
|
| 52 |
}
|
| 53 |
+
/* <a href="/docs" target="_blank" rel="noreferrer">API Docs</a> */
|
| 54 |
/* Code rain canvas (behind everything) */
|
| 55 |
#code-rain {
|
| 56 |
position: fixed;
|
|
|
|
| 155 |
<nav>
|
| 156 |
<a href="/chat">Chat</a>
|
| 157 |
<a href="/dev">Dev</a>
|
| 158 |
+
<a href="/home">Info</a>
|
| 159 |
<a href="https://github.com/agent-matrix/matrix-ai" target="_blank" rel="noreferrer" title="Give me a star on GitHub!">GitHub</a>
|
| 160 |
|
| 161 |
</nav>
|
app/templates/home.html
CHANGED
|
@@ -1,8 +1,169 @@
|
|
| 1 |
{% extends "base.html" %}
|
| 2 |
{% block body %}
|
| 3 |
-
<div class="card">
|
| 4 |
-
<
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
{% endblock %}
|
|
|
|
| 1 |
{% extends "base.html" %}
|
| 2 |
{% block body %}
|
| 3 |
+
<div class="card" style="padding:28px">
|
| 4 |
+
<div class="hero" style="display:grid; gap:14px;">
|
| 5 |
+
<div class="badge">Stage-1 • Observe + Assist</div>
|
| 6 |
+
<h1 style="margin:0">MATRIX-AI</h1>
|
| 7 |
+
<p class="lede">
|
| 8 |
+
The AI planning microservice for the Matrix EcoSystem. It generates
|
| 9 |
+
<strong>short, low-risk, auditable remediation plans</strong> for Matrix-Guardian
|
| 10 |
+
and offers a compact, RAG-assisted chat over Matrix docs.
|
| 11 |
+
</p>
|
| 12 |
+
|
| 13 |
+
<div class="cta">
|
| 14 |
+
<a class="btn" href="/chat">Open Chat</a>
|
| 15 |
+
<a class="btn ghost" href="/dev">Plan Playground</a>
|
| 16 |
+
<!-- Removed API Docs button; Home is now the docs landing -->
|
| 17 |
+
</div>
|
| 18 |
+
|
| 19 |
+
<div class="meta">
|
| 20 |
+
<span class="chip">Service: matrix-ai</span>
|
| 21 |
+
<span class="chip">Version: {{ request.app.version }}</span>
|
| 22 |
+
<span class="chip">API: /v1/plan · /v1/chat</span>
|
| 23 |
+
</div>
|
| 24 |
+
</div>
|
| 25 |
</div>
|
| 26 |
+
|
| 27 |
+
<div class="grid">
|
| 28 |
+
<div class="card feature">
|
| 29 |
+
<div class="icon">🛠️</div>
|
| 30 |
+
<h3>Plan Engine</h3>
|
| 31 |
+
<p>
|
| 32 |
+
Given a compact health context from <em>Matrix-Guardian</em>, matrix-ai produces
|
| 33 |
+
a JSON plan with bounded steps, a risk label, and a brief rationale. Strict schema,
|
| 34 |
+
PII redaction, short timeouts, and retries ensure safe operation.
|
| 35 |
+
</p>
|
| 36 |
+
<div class="list">
|
| 37 |
+
<div>• Strict JSON schema (plan_id, steps[], risk, explanation)</div>
|
| 38 |
+
<div>• Bounded tokens, low temperature</div>
|
| 39 |
+
<div>• Robust parsing + safe fallback</div>
|
| 40 |
+
</div>
|
| 41 |
+
</div>
|
| 42 |
+
|
| 43 |
+
<div class="card feature">
|
| 44 |
+
<div class="icon">📚</div>
|
| 45 |
+
<h3>RAG Assist</h3>
|
| 46 |
+
<p>
|
| 47 |
+
Lightweight retrieval over curated Matrix docs. We assemble a compact CONTEXT
|
| 48 |
+
and instruct the model to answer <em>only</em> from those facts (or say it doesn’t know).
|
| 49 |
+
</p>
|
| 50 |
+
<div class="list">
|
| 51 |
+
<div>• FAISS + embeddings (MiniLM)</div>
|
| 52 |
+
<div>• Optional re-ranking for accuracy</div>
|
| 53 |
+
<div>• Sources returned with answers</div>
|
| 54 |
+
</div>
|
| 55 |
+
</div>
|
| 56 |
+
|
| 57 |
+
<div class="card feature">
|
| 58 |
+
<div class="icon">🛡️</div>
|
| 59 |
+
<h3>Guardrails</h3>
|
| 60 |
+
<p>
|
| 61 |
+
Production-safe defaults: JSON logs, request IDs, in-memory rate-limit,
|
| 62 |
+
idempotent writes (where applicable), and ETag support for caches.
|
| 63 |
+
</p>
|
| 64 |
+
<div class="list">
|
| 65 |
+
<div>• PII redaction pre-inference</div>
|
| 66 |
+
<div>• 429 limits, 5xx propagation</div>
|
| 67 |
+
<div>• Trace-friendly logging</div>
|
| 68 |
+
</div>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
|
| 72 |
+
<div class="card arch">
|
| 73 |
+
<h3 style="margin-top:0">How it fits</h3>
|
| 74 |
+
<div class="diagram">
|
| 75 |
+
<div class="lane">
|
| 76 |
+
<div class="box svc">Matrix-Guardian</div>
|
| 77 |
+
<div class="arrow">/v1/plan</div>
|
| 78 |
+
<div class="box ai">matrix-ai</div>
|
| 79 |
+
<div class="arrow">HF Router</div>
|
| 80 |
+
<div class="box hf">Upstream LLM</div>
|
| 81 |
+
</div>
|
| 82 |
+
<div class="lane">
|
| 83 |
+
<div class="box user">Operators</div>
|
| 84 |
+
<div class="arrow">/v1/chat</div>
|
| 85 |
+
<div class="box ai">matrix-ai</div>
|
| 86 |
+
<div class="arrow">RAG</div>
|
| 87 |
+
<div class="box kb">KB (FAISS)</div>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
|
| 91 |
+
<div class="quick">
|
| 92 |
+
<details>
|
| 93 |
+
<summary>Endpoints</summary>
|
| 94 |
+
<pre><code>POST /v1/plan # JSON plan for Guardian (non-stream)
|
| 95 |
+
POST /v1/chat # Q&A over Matrix docs (RAG, stream or non-stream)
|
| 96 |
+
GET /healthz # Liveness</code></pre>
|
| 97 |
+
</details>
|
| 98 |
+
<details>
|
| 99 |
+
<summary>Quick start (local)</summary>
|
| 100 |
+
<pre><code># 1) Export your token (or use Space Secret)
|
| 101 |
+
export HF_TOKEN="hf_xxx"
|
| 102 |
+
|
| 103 |
+
# 2) Run the service
|
| 104 |
+
uvicorn app.main:app --host 0.0.0.0 --port 7860
|
| 105 |
+
|
| 106 |
+
# 3) Try chat (non-stream)
|
| 107 |
+
curl -s -X POST localhost:7860/v1/chat \
|
| 108 |
+
-H 'content-type: application/json' \
|
| 109 |
+
-d '{"query":"What is MatrixHub?"}' | jq
|
| 110 |
+
|
| 111 |
+
# 4) Try plan
|
| 112 |
+
curl -s -X POST localhost:7860/v1/plan \
|
| 113 |
+
-H 'content-type: application/json' \
|
| 114 |
+
-d '{"mode":"plan","context":{"entity_uid":"matrix-ai"},"constraints":{"max_steps":3,"risk":"low"}}' | jq</code></pre>
|
| 115 |
+
</details>
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
|
| 119 |
+
<style>
|
| 120 |
+
.hero .badge{
|
| 121 |
+
display:inline-block; font-size:12px; letter-spacing:.06em;
|
| 122 |
+
color:#002f1b; background:linear-gradient(180deg,#00ff9c,#00c97e);
|
| 123 |
+
border-radius:999px; padding:6px 10px; font-weight:700;
|
| 124 |
+
box-shadow:0 6px 24px rgba(0,255,156,.25);
|
| 125 |
+
}
|
| 126 |
+
h1 { font-family:"Share Tech Mono", monospace; color:var(--matrix); letter-spacing:.03em; }
|
| 127 |
+
.lede { font-size:16px; opacity:.95; max-width:64ch; }
|
| 128 |
+
.cta { display:flex; gap:10px; margin-top:4px; flex-wrap:wrap; }
|
| 129 |
+
.btn {
|
| 130 |
+
display:inline-block; text-decoration:none; padding:10px 14px; border-radius:12px;
|
| 131 |
+
font-weight:700; font-family:"Share Tech Mono", monospace; letter-spacing:.03em;
|
| 132 |
+
background:linear-gradient(180deg,#00ff9c,#00c97e); color:#032215;
|
| 133 |
+
box-shadow:0 6px 20px rgba(0,255,156,.25);
|
| 134 |
+
}
|
| 135 |
+
.btn.ghost {
|
| 136 |
+
background:#0b1a12; color:var(--muted); border:1px solid var(--border);
|
| 137 |
+
box-shadow:none;
|
| 138 |
+
}
|
| 139 |
+
.btn:hover { filter:brightness(1.05); }
|
| 140 |
+
.meta { display:flex; gap:10px; flex-wrap:wrap; margin-top:6px; }
|
| 141 |
+
.chip {
|
| 142 |
+
font-size:12px; border:1px solid var(--border); border-radius:999px;
|
| 143 |
+
padding:4px 10px; background:#061006a6;
|
| 144 |
+
}
|
| 145 |
+
.grid {
|
| 146 |
+
margin:22px auto; display:grid; gap:16px;
|
| 147 |
+
grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
|
| 148 |
+
}
|
| 149 |
+
.feature .icon { font-size:22px; margin-bottom:4px; }
|
| 150 |
+
.feature .list { margin-top:6px; opacity:.9; font-size:14px; display:grid; gap:4px; }
|
| 151 |
+
.arch { margin-top:18px; }
|
| 152 |
+
.diagram { margin-top:8px; display:grid; gap:8px; }
|
| 153 |
+
.lane { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
|
| 154 |
+
.box {
|
| 155 |
+
padding:8px 10px; border-radius:10px; border:1px solid var(--border);
|
| 156 |
+
background:#020a04; font-family:"Share Tech Mono", monospace; font-size:13px;
|
| 157 |
+
}
|
| 158 |
+
.svc { box-shadow:0 0 0 1px rgba(0,255,156,.08); }
|
| 159 |
+
.ai { box-shadow:0 0 0 1px rgba(0,255,156,.12); }
|
| 160 |
+
.hf { box-shadow:0 0 0 1px rgba(0,255,156,.08); }
|
| 161 |
+
.user{ box-shadow:0 0 0 1px rgba(0,255,156,.08); }
|
| 162 |
+
.kb { box-shadow:0 0 0 1px rgba(0,255,156,.08); }
|
| 163 |
+
.arrow { opacity:.7; font-family:"Share Tech Mono", monospace; }
|
| 164 |
+
.quick { margin-top:8px; display:grid; gap:8px; }
|
| 165 |
+
details { border:1px solid var(--border); border-radius:12px; padding:8px 10px; background:#06100680; }
|
| 166 |
+
details summary { cursor:pointer; user-select:none; color:var(--muted); }
|
| 167 |
+
pre { margin:8px 0 0; }
|
| 168 |
+
</style>
|
| 169 |
{% endblock %}
|
app/ui.py
CHANGED
|
@@ -15,6 +15,10 @@ async def home_redirect():
|
|
| 15 |
# Default to the Chat page
|
| 16 |
return RedirectResponse(url="/chat", status_code=302)
|
| 17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
@router.get("/chat", response_class=HTMLResponse)
|
| 19 |
async def chat_get(request: Request):
|
| 20 |
return templates.TemplateResponse("chat.html", {"request": request, "answer": None})
|
|
|
|
| 15 |
# Default to the Chat page
|
| 16 |
return RedirectResponse(url="/chat", status_code=302)
|
| 17 |
|
| 18 |
+
@router.get("/home", response_class=HTMLResponse, include_in_schema=False)
|
| 19 |
+
async def home_alias(request: Request):
|
| 20 |
+
return templates.TemplateResponse("home.html", {"request": request})
|
| 21 |
+
|
| 22 |
@router.get("/chat", response_class=HTMLResponse)
|
| 23 |
async def chat_get(request: Request):
|
| 24 |
return templates.TemplateResponse("chat.html", {"request": request, "answer": None})
|