GPTs(GPT Builder)のActions(外部API連携)を使ってみた。
参考URL
https://note.com/it_navi/n/nd3137259cd2c
ランダムな犬の写真URLを返してくれるAPI
https://dog.ceo/api/breeds/image/random
GPT Builderでconfigureの一番下にActions(外部API連携)があるので、URLを入力する
独自ChatGPTが、データ・ファイルをアップロードするだけで、簡単に完成。このブログの投稿データを読み込ませてみたら、結構ちゃんと回答してる。GTP Builderバンザイ!
問題は、レスポンスの値をJSONで定義するschemaで、ちょっとでも間違っていると動作しない!
urlの最後にスラッシュがあるのが駄目だったんだけど「通信エラー」と出るだけで、何が原因か分からなかった…。
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 |
{ "openapi": "3.1.0", "info": { "title": "Random Dog Image Fetcher", "version": "1.0.0", "description": "This API fetches a random dog image from Dog CEO's Dog API." }, "servers": [ { "url": "https://dog.ceo/api" } ], "paths": { "/breeds/image/random": { "get": { "summary": "Get a Random Dog Image", "operationId": "getRandomDogImage", "responses": { "200": { "description": "A random dog image URL", "content": {"application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "format": "url", "description": "URL of the dog image" }, "status": { "type": "string", "description": "Status of the API request" } } }} } } } } } } } |
外部API連携して、本日発売のコミックを聞いてみよう
楽天ブックスの最新コミックリスト
https://books.rakuten.co.jp/event/book/comic/calendar/js/booklist.json
以下のschemaで取得したら、ResponseTooLarge(デカすぎて無理)だと~!?
千冊以上あるから、しょうがないのか…。
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
{ "openapi": "3.1.0", "info": { "title": "Get Rakuten Books Comic Calendar Data", "description": "Retrieves comic book data from Rakuten Books comic calendar.", "version": "v1.0.0" }, "servers": [ { "url": "https://books.rakuten.co.jp/event/book/comic/calendar/js/" } ], "paths": { "/booklist.json": { "get": { "description": "Retrieve list of comic books", "operationId": "GetComicBookList", "responses": { "200": { "description": "A list of comic books", "content": {"application/json": { "schema": { "$ref": "#/components/schemas/ComicListResponse" }} } } } } } }, "components": { "schemas": { "ComicListResponse": { "type": "object", "properties": { "column": { "type": "array", "items": {"type": "string" } }, "list": { "type": "array", "items": {"$ref": "#/components/schemas/ComicData" } } } }, "ComicData": { "type": "array", "items": { "oneOf": [ {"type": "integer", "description": "id"}, {"type": "integer", "description": "url"}, {"type": "string", "description": "img"}, {"type": "integer", "description": "eisbn"}, {"type": "integer", "description": "date"}, {"type": "string", "description": "ttl"}, {"type": "string", "description": "ttl_kana"}, {"type": "string", "description": "athr"}, {"type": "integer", "description": "dprc"}, {"type": "integer", "description": "bprc"}, {"type": "string", "description": "ahid_id"}, {"type": "integer", "description": "jun_id"}, {"type": "integer", "description": "cpn_id"}, {"type": "integer", "description": "ser_id"}, {"type": "integer", "description": "lbl_id"}, {"type": "integer", "description": "s_rec"}, {"type": "integer", "description": "s_new"}, {"type": "integer", "description": "s_res"}, {"type": "integer", "description": "s_frc"}, {"type": "integer", "description": "f_adlt"}, {"type": "string", "description": "fc1_id"}, {"type": "integer", "description": "fc2_id"}, {"type": "integer", "description": "fc3_id"}, {"type": "integer", "description": "viewer_id"}, {"type": "string", "description": "viewer_url" } ] } } } } } |