Summary
Hey folks,
I've started a discussion around efficient .docx file edition with AI agent at python-docx, which turned out to be very intesting, after some exploration on a side-project of mine fais, a CLI agent for administrative tasks.
To put it in a nutshell, I've got the feeling that document edition is far from being optimal in most agentic systems I try, even the bigger commercial tools.
I've experimented a search and replace with OpenWork, and faced similar limitations : it needs to generate Python code just to change a piece of text, struggles a bit in the way with global Python package install, iterates a lot... it works but it's not token efficient or very reliable.
I've experimented with a selector based alternative implementation that can guarantee zero alteration on the XML structure. Instead of having the agent to script an edit on-the-fly, or outputting some XML that may alter the document structure, I force it to use selectors for edits, just as you'd do in JavaScript code to edit some HTML for instance.
There are plenty edge cases and this work is experimental, but you'll find an implementation here (functions to compute the selectors with lxml + to run an update) and an improved design doc here.
If you think that could be helpful for OpenWork, I could push the project a bit further and make it a contribution.
Problem / goal
User wants to search and replace text in a docx document. The request might be trickier than a simple regex search and replace, such as : "Replace the placeholder for the participant name with 'Eric Burel'". The text might have some complex layouting and style that must be preserved, so the XML structure of the document should stay the same. This means that an agentic approach is legitimate despite the apparent simplicity of the goal.
User wants the operation to consume as few tokens as possible.
Primary user(s)
OpenCode primitive alignment
Would take the shape of new tools.
Alignment with VISION/PRINCIPLES/PRODUCT
Couldn't find these files yet sorry!
Testability
Can be unit tested as this is mostly tooling, and evaluated against simple .docx tasks.
Ready to build it yourself?
Yes
Additional context
No response
Summary
Hey folks,
I've started a discussion around efficient .docx file edition with AI agent at python-docx, which turned out to be very intesting, after some exploration on a side-project of mine fais, a CLI agent for administrative tasks.
To put it in a nutshell, I've got the feeling that document edition is far from being optimal in most agentic systems I try, even the bigger commercial tools.
I've experimented a search and replace with OpenWork, and faced similar limitations : it needs to generate Python code just to change a piece of text, struggles a bit in the way with global Python package install, iterates a lot... it works but it's not token efficient or very reliable.
I've experimented with a selector based alternative implementation that can guarantee zero alteration on the XML structure. Instead of having the agent to script an edit on-the-fly, or outputting some XML that may alter the document structure, I force it to use selectors for edits, just as you'd do in JavaScript code to edit some HTML for instance.
There are plenty edge cases and this work is experimental, but you'll find an implementation here (functions to compute the selectors with lxml + to run an update) and an improved design doc here.
If you think that could be helpful for OpenWork, I could push the project a bit further and make it a contribution.
Problem / goal
User wants to search and replace text in a docx document. The request might be trickier than a simple regex search and replace, such as : "Replace the placeholder for the participant name with 'Eric Burel'". The text might have some complex layouting and style that must be preserved, so the XML structure of the document should stay the same. This means that an agentic approach is legitimate despite the apparent simplicity of the goal.
User wants the operation to consume as few tokens as possible.
Primary user(s)
OpenCode primitive alignment
Would take the shape of new tools.
Alignment with VISION/PRINCIPLES/PRODUCT
Couldn't find these files yet sorry!
Testability
Can be unit tested as this is mostly tooling, and evaluated against simple .docx tasks.
Ready to build it yourself?
Yes
Additional context
No response