mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-03 06:42:27 +08:00
feat: improve diagram edit tracking and cache handling
- Track lastGeneratedXml to detect user modifications - Only send XML context when needed (saves tokens) - Fix cached response streaming to include tool output - Add debug logging for model messages and steps - Enable multi-step tool execution with maxSteps: 5
This commit is contained in:
@@ -190,9 +190,15 @@ export function replaceXMLParts(
|
||||
let result = formatXML(xmlContent);
|
||||
let lastProcessedIndex = 0;
|
||||
|
||||
console.log('[replaceXMLParts] Input XML length:', xmlContent.length);
|
||||
console.log('[replaceXMLParts] Formatted XML length:', result.length);
|
||||
console.log('[replaceXMLParts] Number of edits:', searchReplacePairs.length);
|
||||
|
||||
for (const { search, replace } of searchReplacePairs) {
|
||||
// Also format the search content for consistency
|
||||
const formattedSearch = formatXML(search);
|
||||
console.log('[replaceXMLParts] Search pattern (first 200):', search.substring(0, 200));
|
||||
console.log('[replaceXMLParts] Formatted search (first 200):', formattedSearch.substring(0, 200));
|
||||
const searchLines = formattedSearch.split('\n');
|
||||
|
||||
// Split into lines for exact line matching
|
||||
@@ -276,6 +282,9 @@ export function replaceXMLParts(
|
||||
}
|
||||
|
||||
if (!matchFound) {
|
||||
console.log('[replaceXMLParts] SEARCH FAILED!');
|
||||
console.log('[replaceXMLParts] Current XML content:\n', result);
|
||||
console.log('[replaceXMLParts] Search pattern:\n', formattedSearch);
|
||||
throw new Error(`Search pattern not found in the diagram. The pattern may not exist in the current structure.`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user