Share
Embed
ChatGPTの新機能「Function Calling」をPostmanで使ってみる
6月13日にOpenAIが発表したChatGPT APIの新機能「Function Calling」を、Postmanを使って試してみました。ChatGPTの新機能と、Postmanの基本的な使い方の流れの両方を掴んでいただくことができます。Postman Tokyo Meetup 2023.7での発表資料です。
草薙昭彦
July 04, 2023
Transcript
30 slides
-
All rights reserved by Postman Inc ChatGPT の新機能 「Function Calling」を
Postman で使ってみる 草薙 昭彦 テクノロジーエバンジェリスト #PostmanMeetup -
Function Calling プログラム Open AI Function 1 Function 2 Function
3 1 2 3 4 5 サービス 利用者 Chat Completions API @postman_japan -
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" } -
リクエスト @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"] } } ] } -
レスポンス @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" } ], ... } -
リクエスト @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"] } } ] } -
レスポンス @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" } ], ... } -
リクエスト @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"] } } ] } -
レスポンス @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" } ], ... } -
リクエスト @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"] } } ] } -
レスポンス @postman_japan { "id": "chatcmpl-7RMx7CDcxQnqkKHHND2lvUr9iAVaA", ... "choices": [ { "index":
0, "message": { "role": "assistant", "content": "横浜の天気は晴れで、気温は 22℃です。" }, "finish_reason": "stop" } ], ... } -
ダウンロードして無料でスタート! https://www.postman.com/downloads/ デスクトップアプリ • Windows • Mac • Linux Web
アプリ • アカウント登録で同 じ機能をブラウザで も利用できる @postman_japan