mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 05:59:36 +08:00
Self-hostable PageIndex, a fileable question bank, and third-party plugins. - PageIndex: adds PageIndex OSS as its own knowledge-base type, bound to the base's local library and driven by the configured LLM rather than a PageIndex API key. Retrieval moves off the built-in MCP server (removed) onto a workflow-owned reading loop that walks the document tree. - Question bank: addEntryToCategory shipped in v1.3.6 and was never called from the frontend, so categories could be created but never filled. The quiz card now uses the shared CategoryMenu, the page is rebuilt around search / batch selection / an unfiled inbox, and a new question_bank tool lets the tutor file questions instead of misrouting them to write_note. - Plugins: deeptutor.plugins was imported behind a try/except but the module never existed — implemented, plus a deeptutor.loop_capabilities group so third-party packages can register chat-loop capabilities. Builtins win on name collisions; broken entry points are skipped. - Parsing: remote Apache Tika engine (TIKA_SERVER_URL), with no local package and no model download. - LightRAG: the three indexing knobs from #877 get inputs under their own Indexing divider; unsupported keywords are dropped with a warning. - Knowledge bases: uploads take a destination folder, same-named documents from different subtrees stop dropping one another, and linked folders keep their source-relative structure — closing #866. - Book: a learning-capture inbox with an explicit status lifecycle, and drift warnings scoped to the KB documents that actually changed. - Whisper: /whisper moves out of the primary nav into Learning Space → More Projects, credited to its contributor; the room needs its own capability package. The reusable half is CAPABILITY_COMPLETE forwarding of a capability-declared body and its declared extras. - README: a Collaborate badge beside the Docs badge, in all twelve languages. - Lint: nosec B608 on four false-positive question-bank queries (literal fragments only, every value bound), and three mypy fixes. Release notes: assets/releases/ver1-5-15.md
57 lines
1.6 KiB
TypeScript
57 lines
1.6 KiB
TypeScript
export type WhisperSeat = "visitor" | "trainee";
|
|
|
|
export type WhisperMessage = {
|
|
id: string;
|
|
role: "user" | "assistant" | "system";
|
|
text: string;
|
|
stage?: string;
|
|
source?: string;
|
|
localSeat?: WhisperSeat; // optimistic user bubble
|
|
};
|
|
|
|
export function parseRoomIdFromContent(text: string): string | null {
|
|
const m = /room_id=([A-Za-z0-9_-]+)/.exec(text || "");
|
|
return m ? m[1] : null;
|
|
}
|
|
|
|
export function filterMessagesForSeat(
|
|
messages: WhisperMessage[],
|
|
seat: WhisperSeat,
|
|
): WhisperMessage[] {
|
|
if (seat === "trainee") return messages;
|
|
return messages.filter((msg) => {
|
|
if (msg.stage === "whisper") return false;
|
|
if (msg.source === "whisper_trainee" && msg.stage === "debrief")
|
|
return false;
|
|
return true;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Detect visitor-facing crisis redirect copy from psych_academy/safety/redirect.py
|
|
* (_EN / _ZH). Match distinctive substrings from the real templates.
|
|
*/
|
|
export function looksLikeCrisisRedirect(text: string): boolean {
|
|
const t = (text || "").toLowerCase();
|
|
return (
|
|
t.includes("cannot provide crisis intervention") ||
|
|
t.includes("i am concerned you may be in danger") ||
|
|
t.includes("不能做危机干预") ||
|
|
t.includes("可能处于危险中") ||
|
|
// optional helpline_text appended by render_redirect
|
|
t.includes("转介") ||
|
|
t.includes("热线")
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Detect trainee-facing crisis summary from whisper_trainee._CRISIS_SUMMARY.
|
|
*/
|
|
export function looksLikeTraineeCrisisSummary(text: string): boolean {
|
|
const t = (text || "").toLowerCase();
|
|
return (
|
|
t.includes("closed for crisis referral") ||
|
|
t.includes("no further counseling or whispers")
|
|
);
|
|
}
|