Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
LLMを拡張機能に
Search
nikawa2161
June 17, 2025
17
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
28
Sagaパターン入門(続編)
nikawa2161
0
39
Sagaパターン入門
nikawa2161
0
48
沖縄観光とPostgreSQL排他制約の話
nikawa2161
0
36
20251209_プログラミング原則の学び
nikawa2161
0
29
自分のコードを数年ぶりに読んだら
nikawa2161
0
20
ユーザーインタビュー分析に参加して得られたことと気づき
nikawa2161
0
31
oEmbedとは?
nikawa2161
0
170
はじめまして、にかわです
nikawa2161
0
20
Featured
See All Featured
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
290
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
430
So, you think you're a good person
axbom
PRO
2
2.1k
Mobile First: as difficult as doing things right
swwweet
225
10k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1.1k
Documentation Writing (for coders)
carmenintech
77
5.4k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4.2k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.6k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
170
Statistics for Hackers
jakevdp
799
230k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
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 テンプレート