Slide 1

Slide 1 text

All rights reserved by Postman Inc ChatGPT の新機能 「Function Calling」を Postman で使ってみる 草薙 昭彦 テクノロジーエバンジェリスト #PostmanMeetup

Slide 2

Slide 2 text

テクノロジーエバンジェリスト Postman 株式会社 草薙 昭彦 @nagix @postman_japan

Slide 3

Slide 3 text

6/13 発表の ChatGPT の新機能「Function Calling」 https://openai.com/blog/function-calling-and-other-api-updates @postman_japan

Slide 4

Slide 4 text

ChatGPT Open AI 1 2 サービス 利用者 @postman_japan

Slide 5

Slide 5 text

Function Calling プログラム Open AI Function 1 Function 2 Function 3 1 2 3 4 5 サービス 利用者 Chat Completions API @postman_japan

Slide 6

Slide 6 text

これまでの ChatGPT の外部連携との違い 応答のブレの少なさ → 正確性の向上 @postman_japan

Slide 7

Slide 7 text

準備 @postman_japan

Slide 8

Slide 8 text

準備 ChatGPT API キーの取得 https://qiita.com/kotattsu3/items/b936a65d173a5d39dad0 @postman_japan Postman のインストール https://qiita.com/ponsuke0531/items/03483449ea0df505a540

Slide 9

Slide 9 text

Postman API ネットワーク @postman_japan

Slide 10

Slide 10 text

コレクションを自分のワークスペースにフォーク @postman_japan

Slide 11

Slide 11 text

Environment を作って API キーを設定 @postman_japan

Slide 12

Slide 12 text

OpenAI のサンプルを そのまま試してみる @postman_japan

Slide 13

Slide 13 text

Chat Completions API @postman_japan [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Who won the world series in 2020?"}, {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."}, {"role": "user", "content": "Where was it played?"} ] このような状況設定と一連の会話の流れを与えてやれば・・・ 空気を読んで回答を返してくれる { "content": "The 2020 World Series was played in Texas at Globe Life Field in Arlington.", "role": "assistant" }

Slide 14

Slide 14 text

Chat Completions API @postman_japan

Slide 15

Slide 15 text

リクエスト @postman_japan { "model": "gpt-3.5-turbo-0613", "messages": [ {"role": "user", "content": "What is the weather like in Boston?"} ], "functions": [ { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] } }, "required": ["location"] } } ] }

Slide 16

Slide 16 text

レスポンス @postman_japan { "id": "chatcmpl-7RMEfHarZvZ7DsTkhioDG6dPyJ4PE", ... "choices": [ { "index": 0, "message": { "role": "assistant", "content": null, "function_call": { "name": "get_current_weather", "arguments": "{\n \"location\": \"Boston, MA\"\n}" } }, "finish_reason": "function_call" } ], ... }

Slide 17

Slide 17 text

ここでお天気 Function を呼ぶ @postman_japan

Slide 18

Slide 18 text

リクエスト @postman_japan { "model": "gpt-3.5-turbo-0613", "messages": [ {"role": "user", "content": "What is the weather like in Boston?"}, {"role": "assistant", "content": null, "function_call": {"name": "get_current_weather", "arguments": "{ \"location\": \"Boston, MA\"}"}}, {"role": "function", "name": "get_current_weather", "content": "{\"temperature\": 22, \"unit\": \"celsius\", \"description\": \"Sunny\"}"} ], "functions": [ { "name": "get_current_weather", "description": "Get the current weather in a given location", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": ["celsius", "fahrenheit"] } }, "required": ["location"] } } ] }

Slide 19

Slide 19 text

レスポンス @postman_japan { "id": "chatcmpl-7RMZdrjDXaDny6pE5FfadTvrXd8DC", ... "choices": [ { "index": 0, "message": { "role": "assistant", "content": "The weather in Boston is currently sunny with a temperature of 22 degrees Celsius." }, "finish_reason": "stop" } ], ... }

Slide 20

Slide 20 text

OpenAI のサンプルの データを日本語にしたら 機能するのか? @postman_japan

Slide 21

Slide 21 text

リクエスト @postman_japan { "model": "gpt-3.5-turbo-0613", "messages": [ {"role": "user", "content": "横浜の天気はどんな感じ? "} ], "functions": [ { "name": "get_current_weather", "description": "与えられた場所の現在の天気を取得 ", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "県と市区町村。例: 愛知県名古屋市" }, "unit": { "type": "string", "enum": ["摂氏", "華氏"] } }, "required": ["location"] } } ] }

Slide 22

Slide 22 text

レスポンス @postman_japan { "id": "chatcmpl-7RMqnNiRPVVmoGI0K6EHxQ1BJq8yV", ... "choices": [ { "index": 0, "message": { "role": "assistant", "content": null, "function_call": { "name": "get_current_weather", "arguments": "{\n \"location\": \"神奈川県横浜市\"\n}" } }, "finish_reason": "function_call" } ], ... }

Slide 23

Slide 23 text

ここでお天気 Function を呼ぶ @postman_japan

Slide 24

Slide 24 text

リクエスト @postman_japan { "model": "gpt-3.5-turbo-0613", "messages": [ {"role": "user", "content": "横浜の天気はどんな感じ? "}, {"role": "assistant", "content": null, "function_call": {"name": "get_current_weather", "arguments": "{ \"location\": \"神奈川県横浜市\"}"}}, {"role": "function", "name": "get_current_weather", "content": "{\"temperature\": 22, \"unit\": \"摂氏\", \"description\": \"晴れ\"}"} ], "functions": [ { "name": "get_current_weather", "description": "与えられた場所の現在の天気を取得 ", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "県と市区町村。例: 愛知県名古屋市" }, "unit": { "type": "string", "enum": ["摂氏", "華氏"] } }, "required": ["location"] } } ] }

Slide 25

Slide 25 text

レスポンス @postman_japan { "id": "chatcmpl-7RMx7CDcxQnqkKHHND2lvUr9iAVaA", ... "choices": [ { "index": 0, "message": { "role": "assistant", "content": "横浜の天気は晴れで、気温は 22℃です。" }, "finish_reason": "stop" } ], ... }

Slide 26

Slide 26 text

おわりに @postman_japan

Slide 27

Slide 27 text

Software 1.0 + Software 2.0 レガシーなデータ資産が、この機能により AIの世界と結 びついて活用が進んでいくのでは、という期待 @postman_japan

Slide 28

Slide 28 text

API がサービスを繋ぐ APIの重要性が格段に大きくなる世界 @postman_japan AI(大規模言語モデル)

Slide 29

Slide 29 text

ダウンロードして無料でスタート! https://www.postman.com/downloads/ デスクトップアプリ ● Windows ● Mac ● Linux Web アプリ ● アカウント登録で同 じ機能をブラウザで も利用できる @postman_japan

Slide 30

Slide 30 text

ありがとうございました @postman_japan