czat: karta pytającego przy pytaniach w pierwszej osobie (domyślnie wyłączona)

„Co mam na głowie?”, „moje terminy”: gdy pytanie nie wskazuje nikogo ani niczego, a mówi
w pierwszej osobie liczby pojedynczej, czat bierze kartę osoby tego, kto pyta. W małej
kancelarii admin to zwykle właściciel albo menedżer, który sam pracuje i pyta o siebie.
„Mamy” (kancelaria) i „mi” nie włączają karty. Nagłówek karty mówi, że to osoba pytająca.

Za przełącznikiem chat.ja === true do czasu pomiaru (testy/czat-graf/RUNDA3.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016uwxqFLC3q51VqQzdfk12g
(cherry picked from commit e35722a7d8)
This commit is contained in:
tobayah
2026-11-12 20:39:44 +01:00
parent d5023ca0fe
commit da5b3c99e2
+16 -7
View File
@@ -2615,8 +2615,12 @@ function chatGraphAsk(ids, index) {
mentioned: cands.map(anchor).filter(Boolean), why: 'niejednoznaczna nazwa', ambiguous: ids, order: cands.map((e) => e.id) };
}
// The asker speaking of themselves: "co mam na głowie", "moje terminy". Singular only: "mamy" is the firm.
const CHAT_SELF = /(?<!\p{L})(?:m[oó]j|moj(?:a|e|ą|ego|ej|emu|ich|im|imi)|mnie|mną|mam|prowadz[eę]|odpowiadam)(?!\p{L})/iu;
// The plan of a turn: a card of which entity, a card of one record's links, a question back, or nothing (`why`).
function chatGraphTurn({ question, index, named = [], resolved = [], back = [], pin = null }) {
// `ja`: a question in the first person that names nobody gets the asker's own card (testy/czat-graf/RUNDA3.md).
function chatGraphTurn({ question, index, named = [], resolved = [], back = [], pin = null, ja = false }) {
const g = index.graph;
if (!g) return null;
// `pin`: the candidate the asker picked by its place in the code's own question back ("ta druga").
@@ -2642,7 +2646,12 @@ function chatGraphTurn({ question, index, named = [], resolved = [], back = [],
if (blocking.length) {
return blocking.length === 1 && other.length === 1 && !ents.length && chatLinkable(blocking[0].key, g) ? { link: blocking[0].key } : { why: 'jednoskokowe' };
}
if (!root) return { why: found ? 'brak encji' : 'nic w pytaniu' };
if (!root) {
// A small firm's owner or manager is often the administrator and does the work too; they ask about themselves.
const me = ja && !picked.length && CHAT_SELF.test(question) && g.ent.get('osoba:' + index.user);
if (me && me.recs.size) return { root: me.id, kind: 'osoba', hit: 'pelne', ja: true };
return { why: found ? 'brak encji' : 'nic w pytaniu' };
}
const e = g.ent.get(root);
// A root from a named record is a full hit; from the text, as sure as the words that found it.
const hit = picked.map(entOf).includes(root) ? 'pelne' : found.hit;
@@ -2778,7 +2787,7 @@ function chatCardLines(e, index, today, kind) {
// The card of an entity as one source: {rec, lead, members, names, table}. `rec` is built per turn and stays out
// of index.records, so search weights, the no-access refusal and chatNamed never see it; it has no `labels`.
function chatCard(entId, index, today, { table = false } = {}) {
function chatCard(entId, index, today, { table = false, ja = false } = {}) {
const g = index.graph;
const e = g.ent.get(entId);
const names = g.names;
@@ -2795,7 +2804,7 @@ function chatCard(entId, index, today, { table = false } = {}) {
head = `Karta sprawy ${m.reference} „${m.name}”: klient ${m.client_name}, status ${m.status}, prowadzi ${names[m.responsible_lawyer_id] || 'nieznany'}. ${made} Rekordy połączył kod po numerze sprawy, polach przypisania i pełnej nazwie, nie po podobieństwie słów.`;
} else {
title = 'Karta osoby z zespołu: ' + e.name;
head = `Karta osoby z zespołu: ${e.name}. ${made} Rekordy połączył kod po polach przypisania (prowadzi sprawę, odpowiada za termin, autor wersji, właściciel zlecenia), nie po nazwisku.`;
head = `Karta osoby z zespołu: ${e.name}${ja ? ' (to osoba, która pyta)' : ''}. ${made} Rekordy połączył kod po polach przypisania (prowadzi sprawę, odpowiada za termin, autor wersji, właściciel zlecenia), nie po nazwisku.`;
}
const lines = [chatNoBrackets(head), chatNoBrackets(`Razem: ${parts.total.join(', ')}.`), ...parts.lines];
if (e.type === 'sprawa') {
@@ -3585,7 +3594,7 @@ const CHAT_ADVICE = /naj(?:ważn|piln|pierw)|priorytet|co\s+(?:\p{L}+\s+){0,3}?(
async function chatTurn({ model, question, turns, index, answer = { role: 'assistant', content: '', status: '', refs: [], trace: [] }, onUpdate = () => {},
// Default 'osoba' after round 2 (testy/czat-graf/RUNDA2.md): the team member's card helped both Qwen and Bielik;
// the full map (true) cost Qwen its "nie ma" answers twice. false switches the map off entirely.
graf = chat.graf ?? 'osoba' }) {
graf = chat.graf ?? 'osoba', ja = chat.ja === true }) {
const done = (content, extra = {}) => Object.assign(answer, { content, status: '', ...extra });
try {
// "Umowa o dzieło" in a question about the law is not a question about Compass's contracts.
@@ -3649,7 +3658,7 @@ async function chatTurn({ model, question, turns, index, answer = { role: 'assis
let topic = [];
// Computed on both arms: on A it only records whether B would have had a card (coverage without extra turns).
let gt = null;
try { gt = index.graph && chatGraphTurn({ question, index, named, resolved, back, pin }); } catch (ex) { console.warn('chat map off:', ex); }
try { gt = index.graph && chatGraphTurn({ question, index, named, resolved, back, pin, ja: ja && !!graf }); } catch (ex) { console.warn('chat map off:', ex); }
// 'osoba': only a team member's card (testy/czat-graf/RUNDA2.md); firms, matters, one record and the question back stay as A.
if (graf === 'osoba' && gt && gt.kind !== 'osoba') gt = { why: 'tylko osoba' };
// "Wypowiedzenie umowy z Velmora Pompy" names a client, so it is a data question, not one for Insider. A name
@@ -3663,7 +3672,7 @@ async function chatTurn({ model, question, turns, index, answer = { role: 'assis
// A card only for a data question: a cited article stays Insider's. A fault in building it leaves the turn as A.
let card = null;
try {
card = !usable || route !== 'data' ? null : gt.root ? chatCard(gt.root, index, today, { table: graf === 'tabela' })
card = !usable || route !== 'data' ? null : gt.root ? chatCard(gt.root, index, today, { table: graf === 'tabela', ja: !!gt.ja })
: gt.link ? chatLinkCard(gt.link, index, today) : null;
} catch (ex) { console.warn('chat map off:', ex); card = null; }
// Set here, so turns that end early (done) carry it too; the harness reads it from every answer.