Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
LLMを拡張機能に
Search
nikawa2161
June 17, 2025
23
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
LLMを拡張機能に
nikawa2161
June 17, 2025
More Decks by nikawa2161
See All by nikawa2161
Node.js Subpath imports
nikawa2161
0
44
Sagaパターン入門(続編)
nikawa2161
0
52
Sagaパターン入門
nikawa2161
0
65
沖縄観光とPostgreSQL排他制約の話
nikawa2161
0
41
20251209_プログラミング原則の学び
nikawa2161
0
41
自分のコードを数年ぶりに読んだら
nikawa2161
0
26
ユーザーインタビュー分析に参加して得られたことと気づき
nikawa2161
0
44
oEmbedとは?
nikawa2161
0
250
はじめまして、にかわです
nikawa2161
0
29
Featured
See All Featured
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
300
Rails Girls Zürich Keynote
gr2m
96
14k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
520
Building an army of robots
kneath
307
47k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
Designing for Performance
lara
612
70k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Large-scale JavaScript Application Architecture
addyosmani
516
110k
Into the Great Unknown - MozCon
thekraken
41
2.8k
Building the Perfect Custom Keyboard
takai
2
900
Transcript
Chrome拡張機能にLLMを組み込む
・前回がVercel AIを使ってLLM作成 ・Chrome拡張として動かす
なぜChrome拡張機能なのか? ・手軽に使える ・ローカルでLLMを動かせばAPI料金かからない
Chrome 拡張機s H Manifes` H 定義や宣言を行4 H Service workerG H
ブラウザのイベントを処理できT H Content scriptG H DOM を利用で、変更を加えたりできT H Toolbar actio@ H 拡張機能ツールバーのアイコンをクリックした時に、処理を 実行できる
構2 ( サービスワーカー(バックエンド担当 ( LLM、イベンÉ ( サイドパネル(フロント担当 ( 画面サイドにチャット
None
用意するもの ! manifest.jso& ! background.j# ! index.html
manifest.json 1 2 3 4 5 6 7 8 9
10 11 12 13 { , , , [ , ], { }, { , } } "manifest_version" "name" "version" "permissions" "background" "service_worker" "side_panel" "default_path" : : : : : : : : 3 "LLM Assistant" "1.0" "sidePanel" "scripting" "background.js" "index.html"
background.js 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 21 const const async const await const return if model ({ baseURL , apiKey , }). ( ); (request Request) { { messages } request. (); result ({ model, system , messages, }); result. (); }; self. ( , (event ) { (event.request.url. ( )) { event. ( (event.request)); } }); = : : = : => = = : : any => createOpenAI chat handleChat json streamText toDataStreamResponse addEventListener endsWith respondWith handleChat 'https://models.github.ai/inference' 'api-key' 'openai/gpt-4.1' 'AIアシスタント' 'fetch' '/api/chat' // リクエストを横取り
index.html(react) 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 import from export default function const return div div div form input button button form div { useChat } ; () { { messages, input, handleInputChange, handleSubmit } ({ api , }); ( < > {messages. ((message) ( < key={message.id}> {message.role } {message.content} </ > ))} < onSubmit={handleSubmit}> < name="prompt" placeholder="質問を入力してください" value={input} onChange={handleInputChange} /> < type="submit">送信</ > </ > </ > ); } "@ai-sdk/react" "/api/chat" "user" "User: " "AI: " Chat useChat map = : => === ? :
拡張機能として読み込む
完成!
https://github.com/Jonghakseo/chrome-extension-boilerplate-react-vite テンプレート