-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Experimental LLM response optimization #14571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Add new integration that optimizes Astro sites for consumption by Large Language Models. Features: - Converts HTML responses to markdown when Accept: text/markdown header is present - Uses Turndown to strip unnecessary elements (nav, footer, scripts) - Outputs clean markdown with ATX-style headings and fenced code blocks - Includes comprehensive tests for markdown conversion functionality
…feature Move the LLM optimization functionality from @astrojs/llm integration into Astro core as an experimental feature. When `experimental.llm.optimizePageResponse` is enabled, pages automatically convert to Markdown format when clients send an `Accept: text/markdown` header. This enables better integration with LLM tools and applications that work better with structured Markdown content instead of HTML. - Add experimental LLM config flag to enable/disable optimization - Integrate optimization into render-context for both dev and prod - Add LLM optimization function using Turndown for HTML-to-Markdown conversion - Add comprehensive fixture tests for dev and production builds - Remove @astrojs/llm integration package
🦋 Changeset detectedLatest commit: c170c71 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
CodSpeed Performance ReportMerging #14571 will not alter performanceComparing Summary
|
I think this is useful, but I don't think this is the right approach. I think it would be better as an integration. Also, as I understand it, this won't work with prerendered pages, which means all Starlight sites, which I'd imagine is the most common use case for it. I think the approach that Netlify takes is better: they render a We talked about this feature, but specifically about Starlight. For that it might make sense to have it in core, as well as the "copy as markdown" button which it could work alongside. As a side issue, I don't think the naming makes sense. It should be about rendering markdown versions, not about LLMs. |
@ascorbic Yeah this is just an early prototype, hence being in draft. I plan on creating an RFC for this. What I actually want to do is deeper than just converting HTML to markdown, but rather a way to directly link pages to the content collection (and entry) it covers so we can directly serve that and not need to do the lossy reverse compilation. Something like this: ---
export const collection = "blog";
export const entry = "[slug]";
const entry = Astro.collectionEntry; // don't need to call getEntry
--- And yeah static builds are a must, that probably involves having astro produce |
I still think such features should be part of an integration. Astro can enable the integration with new features, but I think the end result should be provided by an integration. Looking forward to see the RFC |
Changes
Testing
Docs
tbd