← Back to context Comment by psadri 21 hours ago Could you share some samples / pointers on how you do this? 1 comment psadri Reply tlarkworthy 14 hours ago Yeah, this upsert_cell tool does ithttps://observablehq.com/@tomlarkworthy/forking-agent#upsert...format: { type: "grammar", syntax: "regex", definition: cellsRegex },Where cellRegex iscellsRegex = { const CELL_OPEN = String.raw`<cell>\s`; const INPUTS_BLOCK = String.raw`<inputs>.*<\/inputs>\s*`; const CODE_BLOCK = String.raw`<code><!\[CDATA\[[\s\S]*\]\]>\s*<\/code>\s*`; const CELL_CLOSE = String.raw`<\/cell>`; return "^(" + CELL_OPEN + INPUTS_BLOCK + CODE_BLOCK + CELL_CLOSE + ")*$"; }And the extraction logic is here https://observablehq.com/@tomlarkworthy/robocoop-2#processfunction process(content) { const doc = domParser.parseFromString( "<response>" + content + "</response>", "text/xml" ); const cells = [...doc.querySelectorAll("cell")]; return cells.map((cell) => { const inputsContent = cell.querySelector("inputs")?.textContent || ""; return { inputs: inputsContent.length > 0 ? inputsContent.split(",").map((s) => s.trim()) : [], code: (cell.querySelector("code")?.textContent || "").trim() }; }); }BTW that agent is under development and not actually that good at programming. Its parent https://observablehq.com/@tomlarkworthy/robocoop-2 is actually very good at notebook programming
tlarkworthy 14 hours ago Yeah, this upsert_cell tool does ithttps://observablehq.com/@tomlarkworthy/forking-agent#upsert...format: { type: "grammar", syntax: "regex", definition: cellsRegex },Where cellRegex iscellsRegex = { const CELL_OPEN = String.raw`<cell>\s`; const INPUTS_BLOCK = String.raw`<inputs>.*<\/inputs>\s*`; const CODE_BLOCK = String.raw`<code><!\[CDATA\[[\s\S]*\]\]>\s*<\/code>\s*`; const CELL_CLOSE = String.raw`<\/cell>`; return "^(" + CELL_OPEN + INPUTS_BLOCK + CODE_BLOCK + CELL_CLOSE + ")*$"; }And the extraction logic is here https://observablehq.com/@tomlarkworthy/robocoop-2#processfunction process(content) { const doc = domParser.parseFromString( "<response>" + content + "</response>", "text/xml" ); const cells = [...doc.querySelectorAll("cell")]; return cells.map((cell) => { const inputsContent = cell.querySelector("inputs")?.textContent || ""; return { inputs: inputsContent.length > 0 ? inputsContent.split(",").map((s) => s.trim()) : [], code: (cell.querySelector("code")?.textContent || "").trim() }; }); }BTW that agent is under development and not actually that good at programming. Its parent https://observablehq.com/@tomlarkworthy/robocoop-2 is actually very good at notebook programming
Yeah, this upsert_cell tool does it
https://observablehq.com/@tomlarkworthy/forking-agent#upsert...
format: { type: "grammar", syntax: "regex", definition: cellsRegex },
Where cellRegex is
cellsRegex = { const CELL_OPEN = String.raw`<cell>\s`;
}
And the extraction logic is here https://observablehq.com/@tomlarkworthy/robocoop-2#process
function process(content) { const doc = domParser.parseFromString( "<response>" + content + "</response>", "text/xml" ); const cells = [...doc.querySelectorAll("cell")]; return cells.map((cell) => { const inputsContent = cell.querySelector("inputs")?.textContent || ""; return { inputs: inputsContent.length > 0 ? inputsContent.split(",").map((s) => s.trim()) : [], code: (cell.querySelector("code")?.textContent || "").trim() }; }); }
BTW that agent is under development and not actually that good at programming. Its parent https://observablehq.com/@tomlarkworthy/robocoop-2 is actually very good at notebook programming