Conversations page: pump, search, read the transcript; docs and the libredesk link
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3544f29d85
commit
45db86d1ff
8 files changed
+127
-16
No files matched your search
@@ -2,10 +2,10 @@
|
||||
|
||||
aimsight-app: the control station of the AIMsight diagnostic (`README.md`): the web app, and the launching of processes whose code lives elsewhere. A camera follows targets on a structure; the detectors read the displacement series of the stations and flag the moments when the curves must not be trusted (rain, fog, spider web, turbulence…) or a real movement. The architecture of the repositories: `docs/architecture.drawio`.
|
||||
|
||||
- **The processes**: the Analysis tab launches `agents:analyst` (plugin `agents/`) on a range, with `instructions/analyst.md` and `DETECTORS: no` (labels and report in `labeling/auto/analyses/<STATION>_<start>_<end>/`, submitted to `labeling/auto/<STATION>.jsonl`); "Optimize the detectors" launches `/optimize` in `optimizer/` on the analysis (its request in `app/server/analysis.py`, its summary in `optimizer/sessions/<analysis>_<time>/summary.md`), which commits the detectors in `detectors/` and the reading tools in `tools/`; the Support tab launches `agents:support` on a range with a question and `instructions/support.md` (its answer in `labeling/auto/support/<STATION>_<start>_<end>/answer.md`; it may launch the analyst itself; nothing submitted).
|
||||
- **The links** (ignored by git, one copy of each repository on the workstation): `data/`, `labeling/`, `detectors/`, `tools/`, `agents/`, `optimizer/`, `models/` (the pilot of learned detectors); each thing is committed in its own repository, never here. This repository carries no agent, no reading tool, no workflow.
|
||||
- **The processes**: the Analysis tab launches `agents:analyst` (plugin `agents/`) on a range, with `instructions/analyst.md` and `DETECTORS: no` (labels and report in `labeling/auto/analyses/<STATION>_<start>_<end>/`, submitted to `labeling/auto/<STATION>.jsonl`); "Optimize the detectors" launches `/optimize` in `optimizer/` on the analysis (its request in `app/server/analysis.py`, its summary in `optimizer/sessions/<analysis>_<time>/summary.md`), which commits the detectors in `detectors/` and the reading tools in `tools/`; the Support tab launches `agents:support` on a range with a question and `instructions/support.md` (its answer in `labeling/auto/support/<STATION>_<start>_<end>/answer.md`; it may launch the analyst itself; nothing submitted); the Conversations page launches `libredesk/conversations/pomper.sh` (read-only on LibreDesk, its key in `~/aimsight-libredesk/.env`), each conversation in `labeling/auto/conversations/<reference>/` (`transcript.md`, `messages.json`, `attachments/`).
|
||||
- **The links** (ignored by git, one copy of each repository on the workstation): `data/`, `labeling/`, `detectors/`, `tools/`, `agents/`, `optimizer/`, `models/` (the pilot of learned detectors), `libredesk/` (the LibreDesk conversations); each thing is committed in its own repository, never here. This repository carries no agent, no reading tool, no workflow.
|
||||
- **The truth**: the labels of `labeling/auto/`; the labeling knowledge is in `labeling/`.
|
||||
- **The contracts**: the app calls the methods of the other repositories and holds no domain logic: with the detectors, `detectors/CLAUDE.md` (`categories.window`, `bench/score.py`); with the labels, `labeling/CLAUDE.md` (`scripts/validate.py` `check`, `scripts/ids.py` `assign`, `scripts/client.py`); with the data, `~/aimsight-data` (`extraction/pumping.py`; the weather is pumped into `data/<STATION>/weather/`); with the agents, `agents/README.md` (the requests of the analyst and of the support); with Optimizer, `optimizer/README.md` (the request of `/optimize`). A renaming over there requires the change here. One reader of the measurements, `tools/scripts/data.py`, for the Data page, the tools and the detectors (benchmark and Optimizer included): a reading fix there changes the benchmark.
|
||||
- **The contracts**: the app calls the methods of the other repositories and holds no domain logic: with the detectors, `detectors/CLAUDE.md` (`categories.window`, `bench/score.py`); with the labels, `labeling/CLAUDE.md` (`scripts/validate.py` `check`, `scripts/ids.py` `assign`, `scripts/client.py`); with the data, `~/aimsight-data` (`extraction/pumping.py`; the weather is pumped into `data/<STATION>/weather/`); with the agents, `agents/README.md` (the requests of the analyst and of the support); with Optimizer, `optimizer/README.md` (the request of `/optimize`); with LibreDesk, `libredesk/conversations/pompage.py` (`start`, `running`, `log`). A renaming over there requires the change here. One reader of the measurements, `tools/scripts/data.py`, for the Data page, the tools and the detectors (benchmark and Optimizer included): a reading fix there changes the benchmark.
|
||||
- **The benchmark**: `python3 detectors/bench/regression.py --labels labeling/auto --data data` (~1 min); the score of a range: `python3 detectors/bench/score.py data/<STATION> --labels labeling/auto/<STATION>.jsonl --from YYYY-MM-DD --to YYYY-MM-DD` (`--to` excluded).
|
||||
- **The pumping**: in `~/aimsight-data` (`extraction/pump.sh`, VS Code tasks **pump**, **pump a range**), read-only on the platform; user guide `~/aimsight-data/extraction/README.md`. Claude may launch it on small ranges; a long range or a history, outside busy hours.
|
||||
- **Check a change of the app**: `.venv/bin/python app/server/check.py`, then `cd app/web && npm run build` and launch the server. The labels: `python3 labeling/validate.py`.
|
||||
|
||||
@@ -6,6 +6,8 @@ The control station of the AIMsight diagnostic: see, analyze, launch. The Data p
|
||||
- **"Optimize the detectors"**, on a finished analysis: `/optimize` in Optimizer, on the analysis: it improves the detectors on the range of the analysis, its labels as truth, without overfitting; then it brings the analyst's scripts into the reading harness (tools repository);
|
||||
- **"Ask the support"** (Support tab): the `support` of the agents repository, on a chosen range, with a question and the app's instructions (`instructions/support.md`): it answers as it judges best, itself or through the analyst it launches; its answer and its work in `labeling/auto/support/`, its analyst's labels submitted nowhere.
|
||||
|
||||
The **Conversations** page pumps the LibreDesk conversations (the thread, its images and attachments), read-only, through `~/aimsight-libredesk` (`conversations/`), into `labeling/auto/conversations/<reference>/`: for the support, and as training data. Nothing is ever written to LibreDesk.
|
||||
|
||||
The architecture of the repositories, one responsibility each: `docs/architecture.drawio`.
|
||||
|
||||
## The repository
|
||||
@@ -14,7 +16,7 @@ The architecture of the repositories, one responsibility each: `docs/architectur
|
||||
- `instructions/analyst.md`: what the app asks of the analyst (output folder, report, dialogue); `instructions/support.md`, of the support (how free it is, its answer, dialogue).
|
||||
- `docs/`: the architecture of the repositories, the plans.
|
||||
|
||||
And seven links, ignored by git, to the neighbouring repositories (a single copy of each on the workstation):
|
||||
And eight links, ignored by git, to the neighbouring repositories (a single copy of each on the workstation):
|
||||
|
||||
| Link | Repository | What the app does with it |
|
||||
|---|---|---|
|
||||
@@ -24,6 +26,7 @@ And seven links, ignored by git, to the neighbouring repositories (a single copy
|
||||
| `tools/` | `~/aimsight-tools` | reads the data through `tools/scripts/data.py`; the analyst uses it, the upgrader writes in it (Optimizer) |
|
||||
| `agents/` | `~/aimsight-agents` | the plugin of the agents (`--plugin-dir agents`, `--agent agents:analyst`) |
|
||||
| `optimizer/` | `~/aimsight-optimizer` | launches `/optimize` there; reads the summaries in `optimizer/sessions/` |
|
||||
| `libredesk/` | `~/aimsight-libredesk` | pumps the LibreDesk conversations (`conversations/pompage.py`, its key in its `.env`) into `labeling/auto/conversations/` |
|
||||
| `models/` | `~/aimsight-models` | nothing yet: the pilot of learned detectors (Visibility, Obstruction), measured with the benchmark |
|
||||
|
||||
Each thing is committed in its own repository: the labels in `~/aimsight-labeling`, the detectors in `~/aimsight-detectors` (the optimization session does it, without pushing), the tools in `~/aimsight-tools` (the same session, through the upgrader).
|
||||
@@ -33,6 +36,7 @@ Each thing is committed in its own repository: the labels in `~/aimsight-labelin
|
||||
```bash
|
||||
ln -s ~/aimsight-data/data data && ln -s ~/aimsight-labeling labeling && ln -s ~/aimsight-detectors detectors
|
||||
ln -s ~/aimsight-tools tools && ln -s ~/aimsight-agents agents && ln -s ~/aimsight-optimizer optimizer
|
||||
ln -s ~/aimsight-libredesk libredesk
|
||||
```
|
||||
|
||||
The VS Code task **Run app** creates `.venv` and builds the front end if they are missing, then launches the server. By hand:
|
||||
|
||||
+11
-2
@@ -1,6 +1,6 @@
|
||||
# The AIMsight web app
|
||||
|
||||
The tool of the manual diagnostic: two pages, **Data** and **Stations**.
|
||||
The tool of the manual diagnostic: three pages, **Data**, **Stations** and **Conversations**.
|
||||
|
||||
## The Data page
|
||||
|
||||
@@ -46,12 +46,21 @@ cd app/web && npm install && npm run build # once, and after each change of
|
||||
|
||||
The page opens on `http://127.0.0.1:8770`. Settings by variables: `AIMSIGHT_DATA` (data, default `data/`), `AIMSIGHT_LABELS` (labels, default `labeling/`), `AIMSIGHT_PORT` (8770). To work on the page: `npm run dev` in `app/web/` (http://localhost:5173), the Python server launched next to it.
|
||||
|
||||
## The Conversations page
|
||||
|
||||
The LibreDesk conversations (`helpdesk.sensima.ch`), every inbox and status, private notes included, pumped **read-only** by `~/aimsight-libredesk` (link `libredesk/`, `conversations/pomper.sh` through `conversations/pompage.py`; the app only calls it, the read key stays in that repository's `.env`) into `labeling/auto/conversations/<reference>/`: `conversation.json`, `messages.json`, `attachments/`, and `transcript.md`, the readable thread.
|
||||
|
||||
- **Pump**: without dates, what changed since the last complete pumping (`pumped.json`; the first time, the whole history, at a quiet hour); with dates, the conversations updated in that range (To excluded). One at a time; the end of `out/conversations.log` of that repository read every 2 s. The commit of `auto/conversations/` in `~/aimsight-labeling` is the user's.
|
||||
- **The list**: the pumped conversations, the most recent message first, searched on subject, contact and reference; a click shows the transcript.
|
||||
- **What a client wrote is never run**: the transcript is escaped before Markdown, served with `Content-Security-Policy: default-src 'none'; img-src 'self'` (no script, no remote image or tracking pixel) in a sandboxed frame; a plain image (png, jpg, gif, webp) shows inline, any other attachment (an `.svg`, an `.html`) is downloaded.
|
||||
|
||||
## The folders
|
||||
|
||||
- `server/server.py`: FastAPI; serves the built page and the API under `/api` (stations, images, curves, detectors, labels, analyses, support); answers only the pages of the workstation (local Host, declared JSON).
|
||||
- `server/server.py`: FastAPI; serves the built page and the API under `/api` (stations, images, curves, detectors, labels, analyses, support); answers only the pages of the workstation (local Host, declared JSON); the Conversations routes under `/api/conversations`.
|
||||
- `server/station.py`: the data of the Data page; read-only on `data/` (through `tools/scripts/data.py`), writes only in `labeling/{auto,manual}/`.
|
||||
- `server/analysis.py`: the Analysis tab; launches `claude` with the agent `agents:analyst` (Read, Write, Bash allowed without asking); and the optimization, `/optimize` in Optimizer (Read, Write, Edit, Bash, Agent).
|
||||
- `server/support.py`: the Support tab; launches `claude` with the agent `agents:support` (Read, Write, Edit, Bash, Glob, Grep allowed without asking), through `analysis.run`.
|
||||
- `server/conversations.py`: the Conversations page; calls `libredesk/conversations/pompage.py`, lists `labeling/auto/conversations/`, renders a transcript safely.
|
||||
- `server/check.py`: checks, without calling claude: `.venv/bin/python app/server/check.py`.
|
||||
- `web/`: React (Vite) and Mantine; `src/App.jsx` (header, sidebar, address), `src/pages/Data.jsx` (the page), `src/pages/Images.jsx` (the images, in Data), `src/common.jsx` (requests, selector), `src/main.jsx` (theme). Plotly, dressed in Mantine's colours, loads only with Data. `dist/` and `node_modules/` outside git.
|
||||
|
||||
|
||||
+4
-2
@@ -3,11 +3,12 @@ import {
|
||||
ActionIcon, AppShell, Burger, ColorSwatch, Group, Loader, NavLink, ScrollArea, Text, Tooltip, useComputedColorScheme, useMantineColorScheme,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure } from "@mantine/hooks";
|
||||
import { IconChartLine, IconCircleCheck, IconCircleDashed, IconFolder, IconMoon, IconSatellite, IconSun } from "@tabler/icons-react";
|
||||
import { IconChartLine, IconCircleCheck, IconCircleDashed, IconFolder, IconMessages, IconMoon, IconSatellite, IconSun } from "@tabler/icons-react";
|
||||
|
||||
const Data = lazy(() => import("./pages/Data.jsx")); // Plotly, loaded only here
|
||||
const Stations = lazy(() => import("./pages/Stations.jsx"));
|
||||
const PAGES = [["data", "Data", IconChartLine], ["stations", "Stations", IconSatellite]];
|
||||
const Conversations = lazy(() => import("./pages/Conversations.jsx"));
|
||||
const PAGES = [["data", "Data", IconChartLine], ["stations", "Stations", IconSatellite], ["conversations", "Conversations", IconMessages]];
|
||||
|
||||
// The address: #/<page>?station=…&start=…&end=…; reloading keeps the page and the selection, Back works; without dates, the
|
||||
// last 5 UTC days, today included (end excluded: tomorrow)
|
||||
@@ -142,6 +143,7 @@ export default function App() {
|
||||
<AppShell.Main bg="var(--mantine-color-default-hover)">
|
||||
<Suspense fallback={<Loader m="xl" />}>
|
||||
{page === "stations" ? <Stations selection={selection} />
|
||||
: page === "conversations" ? <Conversations />
|
||||
: <Data selection={selection} choose={choose} analysis={analysis} setAnalysis={setAnalysis}
|
||||
support={support} setSupport={setSupport} />}
|
||||
</Suspense>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Button, Card, Group, Select, TextInput } from "@mantine/core";
|
||||
import { notifications } from "@mantine/notifications";
|
||||
|
||||
@@ -34,3 +34,11 @@ export function Selector({ selection, choose }) {
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
// A markdown rendered by the server (report, summary, transcript), at the height of its content once its images are loaded;
|
||||
// sandboxed: no script runs in it
|
||||
export function Page({ title, src }) {
|
||||
const frame = useRef();
|
||||
const fit = () => { const b = frame.current?.contentDocument?.body; if (b) frame.current.style.height = `${b.scrollHeight + 20}px`; };
|
||||
return <iframe ref={frame} title={title} sandbox="allow-same-origin" onLoad={fit} style={{ border: 0, width: "100%", height: 400 }} src={src} />;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { Button, Card, Code, Group, ScrollArea, Stack, Table, Text, TextInput, Title, useComputedColorScheme } from "@mantine/core";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import { call, Page } from "../common.jsx";
|
||||
|
||||
const when = t => (t ? t.slice(0, 16).replace("T", " ") : "");
|
||||
|
||||
// The LibreDesk conversations, pumped read-only by ~/aimsight-libredesk into labeling/auto/conversations/: a pumping (a range
|
||||
// of updates, or without dates what changed since the last one), its log read every 2 s; the pumped conversations, searched
|
||||
// on subject, contact and reference; a click shows the transcript (images inline, the client's text never run)
|
||||
export default function Conversations() {
|
||||
const [range, setRange] = useState({ start: "", end: "" }), [state, setState] = useState(null);
|
||||
const [list, setList] = useState([]), [search, setSearch] = useState(""), [open, setOpen] = useState(null);
|
||||
const dark = useComputedColorScheme("light") === "dark", wasRunning = useRef(false);
|
||||
const read = () => call("/api/conversations").then(l => l && setList(l));
|
||||
useEffect(() => { read(); }, []);
|
||||
useEffect(() => {
|
||||
const poll = () => fetch("/api/conversations/pump").then(r => r.ok && r.json()).then(p => {
|
||||
if (!p) return;
|
||||
if (wasRunning.current && !p.running) read(); // a pumping ended: the list again
|
||||
wasRunning.current = p.running;
|
||||
setState(p);
|
||||
}).catch(() => {}); // silently: every 2 s
|
||||
poll();
|
||||
const timer = setInterval(poll, 2000);
|
||||
return () => clearInterval(timer);
|
||||
}, []);
|
||||
const pump = () => call("/api/conversations/pump", "POST", range).then(p => { if (p) { wasRunning.current = p.running; setState(p); } });
|
||||
const q = search.trim().toLowerCase();
|
||||
const shown = list.filter(c => !q || [c.subject, c.contact, c.reference].some(x => x.toLowerCase().includes(q)));
|
||||
return (
|
||||
<Stack gap="lg" maw={1200}>
|
||||
<div>
|
||||
<Title order={2}>Conversations</Title>
|
||||
<Text c="dimmed">The LibreDesk conversations, pumped read-only into labeling/auto/conversations/: the thread, its images and
|
||||
attachments, for the support and as training data.</Text>
|
||||
</div>
|
||||
<Card shadow="sm" withBorder>
|
||||
<Stack gap="md">
|
||||
<Group align="flex-end" gap="md">
|
||||
<TextInput label="Updated from (UTC)" type="date" value={range.start} onChange={e => setRange({ ...range, start: e.currentTarget.value })} />
|
||||
<TextInput label="To (excluded)" type="date" value={range.end} onChange={e => setRange({ ...range, end: e.currentTarget.value })} />
|
||||
<Button onClick={pump} loading={!!state?.running}>Pump</Button>
|
||||
</Group>
|
||||
<Text size="xs" c="dimmed">Without dates: what changed since the last pumping; the first time, the whole history (a quiet
|
||||
hour). The key stays in ~/aimsight-libredesk/.env; nothing is ever written to LibreDesk.</Text>
|
||||
{state?.log?.length > 0 && (
|
||||
<ScrollArea h={200} viewportRef={v => v && (v.scrollTop = v.scrollHeight)}>
|
||||
<Code block>{state.log.join("\n")}</Code>
|
||||
</ScrollArea>
|
||||
)}
|
||||
</Stack>
|
||||
</Card>
|
||||
<Card shadow="sm" withBorder>
|
||||
<Stack gap="md">
|
||||
<TextInput placeholder="Search: subject, contact, reference" leftSection={<IconSearch size={16} />} value={search}
|
||||
onChange={e => setSearch(e.currentTarget.value)} maw={400} />
|
||||
{list.length ? (
|
||||
<ScrollArea.Autosize mah={400}>
|
||||
<Table highlightOnHover verticalSpacing={4} stickyHeader>
|
||||
<Table.Thead><Table.Tr><Table.Th>Ref.</Table.Th><Table.Th>Subject</Table.Th><Table.Th>Contact</Table.Th>
|
||||
<Table.Th>Status</Table.Th><Table.Th>Last message (UTC)</Table.Th><Table.Th>Messages</Table.Th><Table.Th>Attachments</Table.Th></Table.Tr></Table.Thead>
|
||||
<Table.Tbody>
|
||||
{shown.map(c => (
|
||||
<Table.Tr key={c.reference} onClick={() => setOpen(c.reference)} style={{ cursor: "pointer" }}
|
||||
bg={open === c.reference ? "var(--mantine-primary-color-light)" : undefined}>
|
||||
<Table.Td ff="monospace">{c.reference}</Table.Td><Table.Td>{c.subject}</Table.Td><Table.Td>{c.contact}</Table.Td>
|
||||
<Table.Td>{c.status}</Table.Td><Table.Td ff="monospace">{when(c.last)}</Table.Td>
|
||||
<Table.Td>{c.messages}</Table.Td><Table.Td>{c.attachments}</Table.Td>
|
||||
</Table.Tr>
|
||||
))}
|
||||
</Table.Tbody>
|
||||
</Table>
|
||||
</ScrollArea.Autosize>
|
||||
) : <Text c="dimmed" size="sm">No conversation pumped yet.</Text>}
|
||||
</Stack>
|
||||
</Card>
|
||||
{open && (
|
||||
<Card shadow="sm" withBorder>
|
||||
<Page key={`${open}-${dark}`} title="Transcript" src={`/api/conversations/${encodeURIComponent(open)}/report.html?dark=${dark}`} />
|
||||
</Card>
|
||||
)}
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
useComputedColorScheme,
|
||||
} from "@mantine/core";
|
||||
import { IconPlus, IconX } from "@tabler/icons-react";
|
||||
import { call, Selector } from "../common.jsx";
|
||||
import { call, Page, Selector } from "../common.jsx";
|
||||
import { StationImages } from "./Images.jsx";
|
||||
|
||||
// Data, the curve viewer and the labelling: one plot at the start, others to add or remove,
|
||||
@@ -515,12 +515,6 @@ function Thread({ lines }) {
|
||||
);
|
||||
}
|
||||
|
||||
// A markdown rendered by the server (report, summary), at the height of its content once its images are loaded
|
||||
function Page({ title, src }) {
|
||||
const frame = useRef();
|
||||
const fit = () => { const b = frame.current?.contentDocument?.body; if (b) frame.current.style.height = `${b.scrollHeight + 20}px`; };
|
||||
return <iframe ref={frame} title={title} sandbox="allow-same-origin" onLoad={fit} style={{ border: 0, width: "100%", height: 400 }} src={src} />;
|
||||
}
|
||||
|
||||
const STATE_COLOR = { running: "blue", done: "teal", error: "red", interrupted: "orange" };
|
||||
|
||||
|
||||
@@ -113,6 +113,15 @@
|
||||
<mxPoint x="360" y="515" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="ld" value="<b style="font-size:14px">aimsight-libredesk</b><br><i>le support LibreDesk : brouillons de réponse, base de connaissances</i><br><font color="#2e7d32"><b>+</b></font> conversations/ : le pompage des conversations, en lecture seule (GET seulement)<br>• lit LibreDesk (helpdesk.sensima.ch) ; sa clé de lecture dans son .env" style="rounded=1;arcSize=4;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;fontSize=12;align=left;verticalAlign=top;spacingLeft=8;spacingRight=8;spacingTop=4;" vertex="1" parent="1">
|
||||
<mxGeometry x="1240" y="440" width="440" height="110" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dep-e13" value="lance le pompage des conversations" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=block;endFill=1;fontSize=11;labelBackgroundColor=#ffffff;" edge="1" parent="1" source="app" target="ld">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="dep-e14" value="écrit auto/conversations/" style="edgeStyle=orthogonalEdgeStyle;rounded=1;html=1;endArrow=block;endFill=1;fontSize=11;labelBackgroundColor=#ffffff;" edge="1" parent="1" source="ld" target="lab">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
|
||||
Reference in new issue
Block a user