ブログに記事要約機能を実装した(Built-in AI on Chrome)
DRANK

このブログに記事の内容を短く要約する機能を実装した。ブラウザの組み込みAI機能を使っているので、2025年12月末の時点ではChromeでのみ動作する。組み込みAI APIChromeはブラウザに組み込まれたGemini Nanoモデルを呼び出すAPIを提供している。今回利用したのはSummerizer APIで、Chrome 138から安定版で提供されている。他にもいくつかのAPIがあり、まだOrigin Trial段階のものもある。Summarizer APIはその名の通り、テキストを与えたら要約してくれるAPIだ。いまのところ、window.Summarizerオブジェクトを通じてAPIを呼び出すようになっている。このブログでは記事にロケール(ja or en) があり、それぞれのロケールに合わせた言語で要約を出力するよう、次のような設定でSummarizerを呼び出している。export async function createSummarizer(locale: string): Promise<Summarizer> { if (typeof Summarizer === 'undefined') { throw new Error('Summarizer API is not available'); } const outputLanguage = locale === 'en' ? 'en' : 'ja'; const options: SummarizerCreateOptions = { type: 'tldr', format: 'markdown', length: 'med…

blog.lacolaco.net
Related Topics: AI Web Standards / Browsers Google Chrome