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
Semantic Kernel を使って ChatGPT Plugins をアプリに組み込んでみよう
Search
Kazuki
June 01, 2023
Technology
970
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Semantic Kernel を使って ChatGPT Plugins をアプリに組み込んでみよう
以下のイベントの発表資料です。
https://dotnet-communities.connpass.com/event/277869/
Kazuki
June 01, 2023
More Decks by Kazuki
See All by Kazuki
GitHub Copilot CLI の 個人的な好きなところ
okazuki
1
700
.NET ユーザーにやさしい GitHub Copilot の使い方
okazuki
0
650
Durable Task Extension for Microsoft Agent Framework はいいぞ
okazuki
2
450
正式リリースされた Semantic Kernel の Agent Framework 全部紹介!
okazuki
1
3.3k
.NET のUnified AI Building Blocks 入門...!
okazuki
0
380
Semantic Kernel の Agent 機能試してみた!
okazuki
1
1.2k
.NET Aspire を始めよう
okazuki
0
570
空のプロジェクトから始める Blazor
okazuki
1
760
.NET Aspire を使おう!
okazuki
0
450
Other Decks in Technology
See All in Technology
2026-09-10 【Snowflake World Tour Tokyo 2026】dbt Core と Snowflake で実現する多層的なデータガバナンス / Multi-Layered Data Governance Powered by dbt Core and Snowflake
civitaspo
0
230
プロダクトエンジニアに必要な「いい感じ」に作る能力 〜たくさん作れる時代に、どこまで作るかの決め方〜
jnishime_dresscode
2
1.4k
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
210
KPIだけでは評価できないプロダクトが考えるべき Evalsという第二の評価系 / Beyond KPIs: Evals as a Second Evaluation Framework for Products #PdEConf
aki_iinuma
4
3.8k
Bet AI Day 2026丨Production-Ready AI Agents — エンタープライズの実務を任せるための設計と運用
layerx
PRO
4
2.6k
Where Is JetBrains AI Heading- — Central CLI, Air Alpha, and the Agentic Development Stack
x5gtrn
PRO
0
150
AI時代におけるプロダクト横断勉強会の設計
zozotech
PRO
0
170
Driving AI Adoption Using In-House GPUs to Serve Qwen
po3rin
2
470
多層防御と最⼩権限で実現する、安全なAIエージェント設計パターン
lycorptech_jp
PRO
1
220
When Does a Local Qwen Start to Break
morshoto
0
190
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
250
日経電子版を支えていく Kasane Design System/fec_fukuoka
nikkei_engineer_recruiting
0
220
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
202
76k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.5k
エンジニアに許された特別な時間の終わり
watany
108
250k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
970
New Earth Scene 8
popppiees
3
2.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
We Have a Design System, Now What?
morganepeng
55
8.3k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
The Invisible Side of Design
smashingmag
301
52k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
490
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Transcript
Semantic Kernel を使って ChatGPT plugins を 自分のアプリに組み込む方法 日本マイクロソフト シニア クラウドソリューション
アーキテクト エンジニアリング 大田 一希
自己紹介 日本マイクロソフト クラウド ソリューション アーキテクト エンジニアリング 大田 一希 (Kazuki Ota)
好きな技術:C# (20 年以上ほぼ一筋)、Azure PaaS 系サービス 苦手な言語:変数に型のない言語全般 SNS や Blog: Twitter: @okazuki (https://twitter.com/okazuki) GitHub: @runceel (https://github.com/runceel) Zenn: https://zenn.dev/okazuki Qiita: https://qiita.com/okazuki Hatena: https://blog.okazuki.jp 趣味:プログラミング、ゲーム(スマブラ: 2495時間, モンハン 1785時間、ティアキン 80時間) 好きな食べ物:🍖🍣 出身地:広島
もくじ Semantic Kernel の全体像をざっくり Semantic Kernel で ChatGPT
Plugins を呼ぶ方法 まとめ
Semantic Kernel の全体像をざっくり
Semantic Kernel とは • 全体概要については以下の動画の 2:19:00 あたりから始まる、ちょまどさん の「Azure OpenAI Service
と OpenAI (本家) + Semantic Kernel (LLM 用 SDK) 入門セッション (C#)」見てください。 • JAZUG: Global Azure 2023 [Room C+D] https://www.youtube.com/watch?v=LQhihic-PCg
Semantic Kernel とは LLM を使うアプリを作る際に必要な機能の詰め合わせ ◼ コア機能 (a.k.a 分類に困った機能) •
プロンプト生成のためのテンプレート エンジン • 変数の埋め込み、関数の呼び出し結果の埋め込みが可能 • プラグイン機能 (少し前まで Skill という名前でした) • 組み込みのプラグイン (MSGraph、Bing、OpenAPI、etc...) • 自作のプロンプトや C# の関数で作るプラグイン • 関数のオーケストレーション機能 ◼ Connectors • 外部サービスとの接続機能 ◼ Memories • データの永続化・検索機能 ◼ Planner • やりたいことを達成するための関数を自動で選んでくれる機能
Semantic Kernel 全体像 Kernel KernelBuilder Plugin 関数 関数 関数 関数
Plugin 関数 関数 関数 関数 自作Plugin 関数 関数 関数 関数 Memories Azure Cognitive Search、Sqlite、 Qdrant、PostgreSQL、Pinecone、 CosmosDB、etc 外部サービス 組み込みPlugin テキスト、ドキュメント、MS Graph API、 OpenAPI、ChatGPT Plugins、etc Connector 生成 データ保存先 使うものを登録 AI サービス テキスト、チャット、画像 Embedding Azure OpenAI Service OpenAI Others... Plugins 使用するAIサービス 使う 使う セットアップが終わった Kernel に対して 以下のようなことが出来る • 実行したい関数を選んで実行 • 実行したい複数の関数をつなげて実行 • AI サービスを直接呼び出す • Memory にデータを登録 • Memory からデータを取得
Semantic Kernel 全体像 Kernel KernelBuilder Plugin 関数 関数 関数 関数
Plugin 関数 関数 関数 関数 自作Plugin 関数 関数 関数 関数 Memory Azure Cognitive Search、Sqlite、 Qdrant、PostgreSQL、Pinecone、 CosmosDB、etc Planner Plan 外部サービス 組み込みPlugin テキスト、ドキュメント、MS Graph API、 OpenAPI、ChatGPT Plugins、etc Connector 生成 データ保存先 使うものを登録 Pluginの 関数一覧から 最適なものを AIを使って選択 AI サービス テキスト、チャット、画像 Embedding Azure OpenAI Service OpenAI Others... 作成 Plan 達成に 必要な関数を参照 Plugins 使用するAIサービス 使う 使う
Semantic Kernel 全体像 Kernel KernelBuilder Plugin 関数 関数 関数 関数
Plugin 関数 関数 関数 関数 自作Plugin 関数 関数 関数 関数 Memory Azure Cognitive Search、Sqlite、 Qdrant、PostgreSQL、Pinecone、 CosmosDB、etc Planner Plan 外部サービス 組み込みPlugin テキスト、ドキュメント、MS Graph API、 OpenAPI、ChatGPT Plugins、etc Connector 生成 データ保存先 使うものを登録 Pluginの 関数一覧から 最適なものを AIを使って選択 AI サービス テキスト、チャット、画像 Embedding Azure OpenAI Service OpenAI Others... 作成 Plan 達成に 必要な関数を参照 Plugins 使用するAIサービス 使う 使う 今日やりたいことが 組み込みである!
作ってみました 自作 TODO ChatGPT Plugins を組み込んだアプリのデモ runceel/ChatGPTPlugins-SemanticKernel (github.com)
頑張った点 ChatGPT Plugins を作る 参考: Introduction - OpenAI
API 作った Plugin の説明文を丁寧に記載する 正しい Plugin が選択されるようにプロンプトを組み立てる 正しい回答が返ってくるようにプロンプトを組み立てる
ポイント1: ChatGPT Plugins のマニフェスト Description に使い方をきちんと書かないとダメ openapi: 3.0.1 info: title:
TodoPlugin version: '1.0' servers: - url: https://localhost:7062 paths: /todos: get: tags: - TodoPlugin description: 全てのTODOを返します。 operationId: getTodos responses: '200': description: O { "schema_version": "v1", "name_for_human": "TODO リスト (no auth)", "name_for_model": "TODO list", "description_for_human": "TODOリストの表示と追加が出来ます。", "description_for_model": "TODOリストの管理が出来るプラグインです。TODOの一覧表示と追加が出来ます。", "auth": { "type": "none" }, "api": { "type": "openapi", "url": "https://localhost:7062/swagger/v1/swagger.yaml" }, "logo_url": "http://localhost:5003/logo.png", "contact_email": "
[email protected]
", "legal_info_url": "http://example.com/legal" } name_for_model と description_for_model を見て AI が使うプラグインを選ぶ
ポイント2: OpenAPI の定義 Description に使い方をきちんと書かないとダメ openapi: 3.0.1 info: title: TodoPlugin
version: '1.0' servers: - url: https://localhost:7062 paths: /todos: get: tags: - TodoPlugin description: 全てのTODOを返します。 operationId: getTodos responses: '200': description: O openapi: 3.0.1 info: title: TodoPlugin version: '1.0' servers: - url: https://localhost:7062 paths: /todos: get: tags: - TodoPlugin description: 全てのTODOを返します。 operationId: getTodos responses: '200': description: OK content: application/json: schema: type: array items: $ref: '#/components/schemas/TodoItem' post: tags: - TodoPlugin description: TODOを作成します。 operationId: createTodo requestBody: description: 'TODO Item. { "text": "Todo item title" }' content: application/json: schema: $ref: '#/components/schemas/TodoItem' required: true responses: '200': description: OK components: schemas: TodoItem: required: - Text type: object properties: text: minLength: 1 type: string description: TODO のタイトル additionalProperties: false description: TODO Item Description を見て AI が呼び出すべき 処理と渡すべきパラメーターを決める
Kernel への ChatGPT Plugins の読み込み IKernel の ImportChatGptPluginSkillFromUrlAsync メソッドで Kernel
に登録可能 await kernel.ImportChatGptPluginSkillFromUrlAsync( "Todos", new Uri("https://localhost:7062/.well-known/ai-plugin.json"), new HttpClient()); ai-plugins.json と OpenAPI の定義を読み込んで Semantic Kernel の Plugins として登録
プラグインを使ったチャットを成立させる処理の流れ 1. ユーザーの入力メッセージが何をしたいのか意図を確認する 2. 意図を元に適切なプラグインがあるか ActionPlanner を使って探す 3. 適切なプラグインがある場合は実行をする 4.
プラグインを実行した結果を含めたプロンプトを使って回答を生成
プラグインを使うためのフロー 1. ユーザーの入力メッセージが何をしたいのか意図を確認する プロンプト力が求められる…
プラグインを使うためのフロー 2. 意図を元に適切なプラグインがあるか ActionPlanner を使って探す 3. 適切なプラグインがある場合は実行をする 3 2
プラグインを使うためのフロー 4. プラグインを実行した結果を含めて回答を生成 プロンプト力が求められる… この部分で 2, 3 の処理を呼び出し結果を埋め込んでいる
苦労した点、もっと考えないといけない点 苦労した点 Planner が呼び出すべきプラグインを正しく選定出来るような文章を組むのが大変 Planner が内部で使用しているプロンプトが英語なので英語になりがち Planner
のプロンプトは差し替え可能なので日本語を使ってくれる Planner はプロンプト力があれば作れる もっと考えないといけない点 ChatGPT Plugins を呼ぶ場合はユーザーの明示的な同意が必要なようにするべき 呼ぶ前にユーザーがボタンを押すなどの明示的なアクションが必要 特に更新系の場合はユーザーの明示的なアクションがないと怖くて使えない Semantic Kernel の Copilot Chat というサンプル アプリは確認プロセスを実装しているので参考になる semantic-kernel/samples/apps/copilot-chat-app at main チャット履歴が長くなってくると思った通りに動かなくなりがち… 例: プラグインから取得した情報とチャットの履歴の間で矛盾が起きたら間違う可能性が上がる ユーザー認証はどうする?
まとめ 簡単な ChatGPT Plugins を作って Semantic Kernel で使ってみた
プロンプト力が無いと思った結果を出すのが大変… GPT 4 で試してみたい ある程度やることを絞らないと使い物になるものを作るのは難しそう… AI にユーザーがやりたいことを要約してもらってから処理をするのが良さそう 1 回のチャットのやり取りで N 回 AI に処理してもらう ユーザーが結構待たされることになるので UI での工夫が必要になりそう 「考え中…」の表示やストリーミングに対応して生成結果をパラパラと表示する Semantic Kernel の Copilot Chat サンプルが参考になる semantic-kernel/samples/apps/copilot-chat-app at main
参考: Copilot Chat の画面 a
© Copyright Microsoft Corporation. All rights reserved.