Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Automate chat template JS dependency updates#5853

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SteveSandersonMS merged 7 commits intomainfrommbuck/automate-template-dep-updates
Feb 10, 2025

Conversation

@MackinnonBuck
Copy link
Member

@MackinnonBuckMackinnonBuck commentedFeb 7, 2025
edited by dotnet-policy-servicebot
Loading

Automate chat template JS dependency updates

Following are the main changes in this PR:

  1. Add apackage.json to specify project template dependencies and how they should be copied into template content
    • Note that this is only a development-time dependency and doesn't ship with the templates. That is, we're not adding back a dependency on NPM for the shipping templates.
  2. Add acopyDependency.mjs script that carries out the actual dependency copying.
    • It also updates the package version in the README file
  3. Reduce the number of assets required for PDF viewing (more info below).

PDF viewer changes

Thepdfjs dependency was trickier than the others, because its NPM package (pdfjs-dist) doesnot 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 havestated that they don't want people to use the PDF viewer "as-is" in actual code:

The viewer is built on the display layer and is the UI for the PDF viewer in Firefox and the other browser extensions within the project. It can be a good starting point for building your own viewer.However, we do ask if you plan to embed the viewer in your own site, that it not just be an unmodified version. Please re-skin it or build upon it.

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 thewwwroot 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:
pdf-viewer

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 replacepdf_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 thesrc/ProjectTemplates folder:

npm installnpm run copy-dependencies

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.

Fixeshttps://github.com/dotnet/ai-private-planning/issues/276

Microsoft Reviewers:Open in CodeFlow

@dotnet-comment-bot
Copy link
Collaborator

‼️Found issues‼️

ProjectCoverage TypeExpectedActual
Microsoft.Extensions.Caching.HybridLine8682.77 🔻
Microsoft.Extensions.AI.OllamaLine8078.25 🔻
Microsoft.Gen.MetadataExtractorLine9857.35 🔻
Microsoft.Gen.MetadataExtractorBranch9862.5 🔻

🎉Good job! The coverage increased 🎉
UpdateMinCodeCoverage in the project files.

ProjectExpectedActual
Microsoft.Extensions.AI.Abstractions8384
Microsoft.Extensions.AI8889
Microsoft.Extensions.AI.OpenAI7778

Full code coverage report:https://dev.azure.com/dnceng-public/public/_build/results?buildId=943589&view=codecoverage-tab

@SteveSandersonMS
Copy link
Member

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:

This is wonderful. I love it. Much better than having that massive dump of files we had before. Brilliant.

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.

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

MackinnonBuck reacted with thumbs up emoji

@dotnet-comment-bot
Copy link
Collaborator

‼️Found issues‼️

ProjectCoverage TypeExpectedActual
Microsoft.Extensions.AI.OllamaLine8078.11 🔻
Microsoft.Gen.MetadataExtractorLine9857.35 🔻
Microsoft.Gen.MetadataExtractorBranch9862.5 🔻

🎉Good job! The coverage increased 🎉
UpdateMinCodeCoverage in the project files.

ProjectExpectedActual
Microsoft.Extensions.Caching.Hybrid8687
Microsoft.Extensions.AI.AzureAIInference9192
Microsoft.Extensions.AI8889
Microsoft.Extensions.AI.Abstractions8385

Full code coverage report:https://dev.azure.com/dnceng-public/public/_build/results?buildId=944582&view=codecoverage-tab

@SteveSandersonMSSteveSandersonMSforce-pushed thembuck/automate-template-dep-updates branch from73ad687 tob93d183CompareFebruary 10, 2025 11:30
…tWithCustomData/ChatWithCustomData.Web/wwwroot/pdf_viewer/viewer.mjs
@SteveSandersonMSSteveSandersonMSenabled auto-merge (squash)February 10, 2025 11:33
@dotnet-comment-bot
Copy link
Collaborator

‼️Found issues‼️

ProjectCoverage TypeExpectedActual
Microsoft.Extensions.Caching.HybridLine8682.92 🔻
Microsoft.Extensions.AI.OllamaLine8078.11 🔻
Microsoft.Gen.MetadataExtractorLine9857.35 🔻
Microsoft.Gen.MetadataExtractorBranch9862.5 🔻

🎉Good job! The coverage increased 🎉
UpdateMinCodeCoverage in the project files.

ProjectExpectedActual
Microsoft.Extensions.AI.Abstractions8385
Microsoft.Extensions.AI.AzureAIInference9192
Microsoft.Extensions.AI8889

Full code coverage report:https://dev.azure.com/dnceng-public/public/_build/results?buildId=946558&view=codecoverage-tab

@SteveSandersonMSSteveSandersonMS merged commit66bc675 intomainFeb 10, 2025
6 checks passed
@SteveSandersonMSSteveSandersonMS deleted the mbuck/automate-template-dep-updates branchFebruary 10, 2025 12:14
@jeffhandleyjeffhandley added the area-ai-templatesMicrosoft.Extensions.AI.Templates labelMar 7, 2025
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 6, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@SteveSandersonMSSteveSandersonMSSteveSandersonMS approved these changes

Assignees

@MackinnonBuckMackinnonBuck

Labels

area-ai-templatesMicrosoft.Extensions.AI.Templates

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@MackinnonBuck@dotnet-comment-bot@SteveSandersonMS@jeffhandley

[8]ページ先頭

©2009-2025 Movatter.jp