Speculations on supporting LLM automation within HTML markup as a first class citizen
As someone who's been fighting a one man war to make SSGs (static site generators) great again. For some time i’ve been working on a new static site generator based on compile time macro expansion and transformation of HTML ASTs.
You can find the project here, called WebCompiler.
There's some great ideas baked into that project already. Especially with regard to the <include> macro.
E.g.
<!-- pages/index.html -->
<include src="../common/main.html">
<h1>Hello World</h1>
</include>
<!-- common/main.html -->
<include src="header.html"></include>
<main>
<content></content>
</main>
<include src="footer.html"></include>But in this article I’d like to discuss something more speculative (that I have yet to implement in some working MVP).
What if we could embed LLM copywriting instructions directly into your HTML markup?
In IT, those who value their time generally prefer TUIs (plain text based user interfaces) over GUIs for a multitude of reasons. Just as a UNIX CLI guru can do otherwise tedious operations in seconds that may take admins hours to manually replicate via GUIs. Webmasters everywhere should prefer plain text formats / interfaces over the ilk of WYSIWYGs.
When it comes to site copy content in particular, research suggests that LLMs tend to be more persuasive than copywriters. But these tools stand apart from the end-work. What if we could instead bake copywriting automation directly into the markup itself as a true first class citizen?
My idea is simple.
Update my compiler with new macros specifically for automated copy content generation.
Starting with the provision element.
<provision src="content/homepage/hero.txt">
Hero blurb highlighting core value proposition for the business
</provision>Each provision element contains a short prompt text.
A guiding design principle is to avoid repetition. Context is very repetitive. Context also tends to be top-down. There is global context (e.g. business name), there is also page specific context (e.g. what if this page), section specific context and so on — I regard this as lexically scoped context based on the element block structure (I used to consider myself an amateur compiler engineer, preliminary support for this is already backed into my WebCompiler toolchain).
So I would add a context element, and an associated internal context stack.
Context example 1:
<context>
Write in a clear, energetic tone aimed at first-time homeowners.
</context>
<provision src="content/homepage/value-prop.txt">
Concise value proposition explaining why this service is trusted locally.
</provision>Context example 2:
<context>
Write in a warm, conversational tone suitable for local homeowners.
</context>
<provision src="content/homepage/hero.txt">
Hero blurb introducing the company and core value proposition.
</provision>Notice how each ‘provision’ element specifies an output file location. This will be automatically populated with the LLM output, then reused in subsequent compiler invocations so that LLM invitations are effectively idempotent under this design. There is also the added benefit that initial content can be quickly populated and then manually edited thereafter.
After the output is saved, provision elements with an existing output file will effectively function like an <include> element as documented here.
Alternatively I’ve thought about something akin to the following:
<section id="hero">
<h1 prompt="summarize purpose of business"/>
<p prompt="who is this for? what do they need?"/>
<image src="logo.jpg" alt="Brand Logo"/>
</section>Notice the ‘prompt‘ attributes. However there’s the idempotency question, another attribute may be needed. A dedicated macro element seems best.
What comes next is a little more complicated. I need a prompt templating system that can take the prompt text and the associated context stack, and transform that into the structure by which LLMs will evaluate.
Two years I started with this tool that allowed me to define prompt templates via a simple XML DSL.
Example:
<prompt name="question-1" model="gpt-3.5-turbo-0125" top-p="0.15">
<message role="system">
You are a helpful assistant.
</message>
<message role="user">
What is ChatGPT?
</message>
</prompt>
<prompt name="question-2" model="gpt-4-0125-preview" top-p="0.15" max-tokens="4000">
<message role="system">
You are a helpful assistant.
</message>
<message role="user">
What is heavier, a kilo of feathers or a pound of steel?
</message>
</prompt>I never mentioned this in the README but programmatic functionality is possible via the liquid preprocessor.
E.g. here is an example from an actual project:
<prompt name="process">
<message role="system">
{% if errors.size > 2 %}
You will fix all JSON syntax errors, JSON schema model validation errors, and then compile the corrected JSON dataset.
{% else %}
{{ system_message }}
{% endif %}
</message>
<message role="user">{{ instructions }}</message>
{% for error in errors %}
<message role="assistant">{{ error.response }}</message>
<message role="user">
{{ error.message }}
There is an issue with your compiled JSON object!
</message>
{% endfor %}
{% if errors.size > 0 %}
<message role="system">
Follow these instructions:
1. Take heed of the following schema:
{{json_schema}}
2. The task remains: populate the requested JSON object following the provided schema and then return the compiled data.
Hint: we do not want the schema but the data the schema represents.
</message>
{% endif %}
</prompt>I’ve since been working on a pure rewrite that you can find over here with some new ideas for defining multi-step LLM invocations.
For example:
<prompt name="question-1">
<msg role="system">
<p>You are a helpful assistant.</p>
</msg>
<msg role="user">
<p>What is heavier, a kilo of feathers or a pound of steel?</p>
</msg>
<breakpoint role="assistant"></breakpoint>
<msg role="user">
<p>Explain your reasoning.</p>
</msg>
<breakpoint role="assistant"></breakpoint>
<msg role="user">
<p>Would you like to revise your answer?</p>
</msg>
<breakpoint role="assistant"></breakpoint>
<msg role="user">
<p>Finally, after considering your thoughts, please state just the answer.</p>
</msg>
</prompt>Notice the ‘breakpoint‘ element. See the README showcase for a live demo output of the above instructions.
Overall, the idea is to build out a prompt templating system that WebCompiler can use for evaluating `<provision>` elements, and in a manner that supports a level of sophistication for optimal copy automation provisioning.
So that's about everything I have to say right now.
Overall, the intent is to support automated copywriting workflows as a first class citizen within the markup itself. Perhaps prompts could be reused across a multitude of clients, simply updating a few context specific details site wide per client.