iT邦幫忙

2024 iThome 鐵人賽

DAY 28
0

7-3 新增動作 add action (function calling )

https://ithelp.ithome.com.tw/upload/images/20240811/20046160MzmMO0vi9y.png

建置 My GPT 個人覺得建立新動作是一個很棒的功能,在 GPTs Store 有很多GPT是藉由 action 和其所開發的服務做串結來完成的,例如一些第三方簡報、繪圖、音樂、訂房網站,幾乎是無限可能。

實作範例

  1. 選 配置
  2. 選 建立新動作 add action
  3. 以範例作為示範

https://ithelp.ithome.com.tw/upload/images/20240801/20046160qaVTCamErD.png

  1. 選 寵物商店
  2. 會 匯入 範例的 json 檔

https://ithelp.ithome.com.tw/upload/images/20240801/20046160t9MUBDEsRT.png

  1. 可以點測試
  2. 這時 GPT 會問你 允許 連 外網 嗎

https://ithelp.ithome.com.tw/upload/images/20240801/20046160hJ0TgYplPo.png

  1. 點 允許 就會去連了
  2. 但因為 "url": "https://weather.example.com" 網址不對

https://ithelp.ithome.com.tw/upload/images/20240801/20046160vgqk9GXbUW.png

  1. 就會產生錯誤訊息

實作氣象局opendata

  1. 註冊 拿 key https://opendata.cwa.gov.tw/user/authkey
  2. 參考這個 https://opendata.cwa.gov.tw/dist/opendata-swagger.html
  3. 以預報網址為例

https://ithelp.ithome.com.tw/upload/images/20240801/20046160E4BJnxQftn.png

  1. 不會寫 openapi 檔 沒關係 , 直接將網址喂給 ActionsGPT
    https://ithelp.ithome.com.tw/upload/images/20240801/20046160D323ArrUxt.png
    https://ithelp.ithome.com.tw/upload/images/20240801/20046160ElQ8mLLwYf.png

  2. 有了 yaml 檔後,貼回去 結構描述

https://ithelp.ithome.com.tw/upload/images/20240801/20046160SUPyDTIcXp.png

這裡要注意,雖然 GPT 有給 驗證 的 設定,但因為 氣象局直接將 api key 明碼丟在 網址裡(氣象局叔叔有練過,小朋友不要學),所以 paths 裡,只好將 Authorization=CWA-698D79B5-A104-419E-8FED-xxx 貼上去。

  1. 點 測試

https://ithelp.ithome.com.tw/upload/images/20240801/20046160KSoLWuOycB.png

  1. 設定 Instruction 的 prompt : use getWeatherData to get weather information 才能讓 GPT 記得使用 getWeatherData 這個 action 去呼叫天氣

https://ithelp.ithome.com.tw/upload/images/20240801/20046160yiNVBJQMnl.png

  1. prompt : 天氣如何
    https://ithelp.ithome.com.tw/upload/images/20240801/20046160Hie6Y4IGOe.png

9 .用中文問會用中文回答

關於我

我是 Wolke。我是一名專業程式開發者,專長是開發 AI 和程式解決方案。

我投入了不少時間在專業發展上。我是多本書的作者,其中包括《LINE聊天機器人+AI+雲端+開源+程式:輕鬆入門到完整學習》《ChatGPT來襲,未來人人都需具備的運算思維!應用詠唱工程來釋放程式生產力—程式學習/開發篇》。也有出版線上課程,我熱衷於分享我的經驗和技術,幫助其他開發者更好地利用 AI 工具。

也在許多知名大學、論壇、社團擔任講者,如果貴方有需要也歡迎與我聯繫。
2023年 講座 紀錄

最後這篇文章若有切合你的需求,敬請訂閱按讚分享


上一篇
7-2 GPTs 基本實作
下一篇
7-4 驗證 api key 以 LINE notify 服務 為例
系列文
運用生成式 AI 服務 所提供的API 實做應用開發(以Gemini及ChatGPT為例)29
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言