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.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
nikawa2161
June 05, 2025
9
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
llm.pdf
nikawa2161
June 05, 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
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
GraphQLとの向き合い方2022年版
quramy
50
15k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
1.8k
Believing is Seeing
oripsolob
1
190
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Odyssey Design
rkendrick25
PRO
2
750
A better future with KSS
kneath
240
18k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
410
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Are puppies a ranking factor?
jonoalderson
1
3.8k
Transcript
LLMをつくってみる
どうやって作る?
Vercel AI SDK https://ai-sdk.dev/
Vercel AI SDK https://ai-sdk.dev/docs/foundations/providers-and-models
Vercel AI SDK https://ai-sdk.dev/docs/foundations/streaming
3 データ出力を逐次的に、公立よく扱うためのデータ構 3 データ全体(ファイル一個)をそれより細かく分割された単位の連続した 流れを表現する ストリームとは
用意するもの E フロント(React' E ストリーミングで表& E バックエンド(Hono' E AI SDKでモデル選択
用意するもの E フロント(React' E ストリーミングで表& E バックエンド(Hono' E AI SDKでモデル選択
ライブラリ E ai-sdk/openaS E ai-sdk/reac` E aS E zor E aiの依存関係として必要
モデルの選択 1 2 3 4 5 6 7 8 9
import from const { createOpenAI } ; model ({ baseURL , apiKey process.env. , }). ( ); "@ai-sdk/openai" "https://models.github.ai/inference" "openai/gpt-4o-mini" = : : createOpenAI chat OPENAI_API_KEY
リクエスト 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 import from import from const async const await const return { createOpenAI } ; { streamText } ; model ({ baseURL , apiKey process.env. , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); result. (); }); "@ai-sdk/openai" "ai" "https://models.github.ai/inference" "openai/gpt-4o-mini" "/api/chat" "You are a helpful assistant." = : : => = = : createOpenAI chat post json streamText toDataStream OPENAI_API_KEY
リクエスト(Hono) 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 import from import from import from const async const await const return { createOpenAI } ; { stream } ; { streamText } ; model ({ baseURL , apiKey process.env. , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); c. ( , ); (c, (stream) stream. (result. ())); }); "@ai-sdk/openai" "hono/streaming" "ai" "https://models.github.ai/inference" "openai/gpt-4o-mini" "/api/chat" "You are a helpful assistant." "Content-Encoding" "Identity" = : : => = = : => createOpenAI chat post json streamText header stream pipe toDataStream OPENAI_API_KEY
表示側 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" "http://localhost:5173/api/chat" "user" "User: " "AI: " Chat useChat map = : => === ? :
紹介
LLMはローカルでも動かせる ・モデルをダウンロード ・サーバーを立ち上げる ・https://ollama.com/
モデル選択(OpenAi) 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 import from import from import from const async const await const return { createOpenAI } ; { stream } ; { streamText } ; model ({ baseURL , apiKey process.env. , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); c. ( , ); (c, (stream) stream. (result. ())); }); "@ai-sdk/openai" "hono/streaming" "ai" "https://models.github.ai/inference" "openai/gpt-4o-mini" "/api/chat" "You are a helpful assistant." "Content-Encoding" "Identity" = : : => = = : => createOpenAI chat post json streamText header stream pipe toDataStream OPENAI_API_KEY
モデル選択(ollama) 1 2 3 4 5 6 7 8 9
10 11 12 13 14 15 16 17 18 19 20 // import { createOpenAI } from "@ai-sdk/openai"; import from import from import from const async const await const return { createOllama } ; { stream } ; { streamText } ; model ({ baseURL , }). ( ); app. ( , (c) { { messages } c.req. (); result ({ model, system , messages, }); c. ( , ); (c, (stream) stream. (result. ())); }); "ollama-ai-provider" "hono/streaming" "ai" "http://localhost:11434/api" "phi3" "/api/chat" "You are a helpful assistant." "Content-Encoding" "Identity" = : => = = : => createOllama chat post json streamText header stream pipe toDataStream
Chrome拡張機能 ・ローカルで動くLLMならChrome拡張機能に組み込める