-
Notifications
You must be signed in to change notification settings - Fork 772
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
Automate chat template JS dependency updates #5853
Conversation
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=943589&view=codecoverage-tab |
...xtensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/wwwroot/pdf_viewer.html
Outdated
Show resolved
Hide resolved
...Extensions.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/wwwroot/pdf_viewer.mjs
Outdated
Show resolved
Hide resolved
This is wonderful. I love it. Much better than having that massive dump of files we had before. Brilliant.
I definitely think that would that would be helpful, even more so than the JS files since the .NET deps are going to rev continually. Hopefully we could use an equivalent technique to what we do in dotnet/aspnetcore so we automatically use whatever version this host repo itself depends on, so the automatic dependency flow keeps things up-to-date for us: https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/GenerateContent.targets |
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=944582&view=codecoverage-tab |
73ad687
to
b93d183
Compare
...ons.AI.Templates/src/ChatWithCustomData/ChatWithCustomData.Web/wwwroot/pdf_viewer/viewer.mjs
Outdated
Show resolved
Hide resolved
…tWithCustomData/ChatWithCustomData.Web/wwwroot/pdf_viewer/viewer.mjs
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=946558&view=codecoverage-tab |
Automate chat template JS dependency updates
Following are the main changes in this PR:
package.json
to specify project template dependencies and how they should be copied into template contentcopyDependency.mjs
script that carries out the actual dependency copying.PDF viewer changes
The
pdfjs
dependency was trickier than the others, because its NPM package (pdfjs-dist
) does not include the built-in PDF viewer that was being utilized by the chat template. There are numerous issues in the pdf.js GitHub repo asking for the viewer to be included, but the maintainers have stated that they don't want people to use the PDF viewer "as-is" in actual code:Given this statement and the fact that it was intentionally made difficult to use the built-in PDF viewer, it's probably best to find an alternative.
Thankfully, it's pretty straightforward to recreate a super minimal PDF viewer using pdf.js directly. I've added two assets to the
wwwroot
folder in the template that define a custom viewer:pdf_viewer.html
pdf_viewer.js
These assets won't get updated automatically, but they probably won't need to be anyway unless there's a significant breaking change in pdf.js.
It's pretty minimal, but I don't think we need anything more advanced for a template:

One advantage to this is that we can significantly reduce the number of assets required for PDF viewing (all the images except for the loading icon can be removed).
In the future, we could even replace
pdf_viewer.html
with a Blazor component that displays the citation in a modal dialog. But I'm hoping we would address that in a follow-up.Future work
This PR does not add a CI pipeline to update template dependencies. It's still "manual" in that you have to clone the repo and run these two commands from the
src/ProjectTemplates
folder:However, this is how it works in the ASP.NET Core repo as well, and I'd imagine it saves about 90% of the effort required to update dependencies.
This PR also doesn't do anything to automate .NET dependency updates. If we think this would be helpful, I'll address it in a follow-up PR to keep this one focused.
Fixes https://github.com/dotnet/ai-private-planning/issues/276
Microsoft Reviewers: Open in CodeFlow