【AI】如何编写GPTs的Actions

这篇文章和上篇 利用GPTs的Actions 获取第三方数据有点类似, actions 都是基于三方接口去完成自己想要的功能,不同的是,上篇是在基于有 swagger json 或者 yaml 文档的情况下, 但是如果仅仅是一个 cURL 示例呢

js 复制代码
curl -X GET  \
  'https://eolink.o.apispace.com/456456/weather/v001/now?areacode=101010100&lonlat=116.407526,39.904030' \
  -H 'X-APISpace-Token:your key'

创建Actions

而在 GPTs Actions 创建的时候,Schema 要求的格式模板如下,json或者yaml文件都可以

json 复制代码
{
  "openapi": "3.1.0",
  "info": {
    "title": "Get weather data",
    "description": "Retrieves current weather data for a location.",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://weather.example.com"
    }
  ],
  "paths": {
    "/location": {
      "get": {
        "description": "Get temperature for a specific location",
        "operationId": "GetCurrentWeather",
        "parameters": [
          {
            "name": "location",
            "in": "query",
            "description": "The city and state to retrieve the weather for",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "deprecated": false
      }
    }
  },
  "components": {
    "schemas": {}
  }
}

我们需要将 cURL示例转换成Schmea要求的格式, 这个可以让gpt帮我们完成,当然也可以自己写代码去转换,

下面提供几个GPTs, 试了下,第二个效果最好,

OpenAPI Schmea GPTs

GPT Customizer,File Finder JSON Action Creator

ActionsGPT

请求的时候把请求响应体带上,保证schema的完整,我这里用的是第二个GPT Customizer,File Finder JSON Action Creator

在用其它的两个GPTs 转换的时候,发现碰到这个问题,个别单词转换错误, 对应是schemas,或者去掉 components

测试

小技巧

voxscript.awt.icu/swagger/v1/...

json后缀名改成yaml就可以直接改成yaml文件

相关推荐
KaneLogger3 小时前
【Agent】openclaw + opencode 打造助手 安装篇
人工智能·google·程序员
知识浅谈4 小时前
一步步带你把 OpenClaw 玩宕机(附云服务器避坑部署教程)
人工智能
冬奇Lab4 小时前
OpenClaw 深度解析(四):插件 SDK 与扩展开发机制
人工智能·开源·源码阅读
IT_陈寒5 小时前
SpringBoot实战:5个让你的API性能翻倍的隐藏技巧
前端·人工智能·后端
机器之心6 小时前
让AI自我进化?斯坦福华人博士答辩视频火了,庞若鸣参与评审
人工智能·openai
iceiceiceice6 小时前
iOS PDF阅读器段评实现:如何从 PDFSelection 精准还原一个自然段
前端·人工智能·ios
AI攻城狮7 小时前
RAG Chunking 为什么这么难?5 大挑战 + 最佳实践指南
人工智能·云原生·aigc
yiyu07167 小时前
3分钟搞懂深度学习AI:梯度下降:迷雾中的下山路
人工智能·深度学习
掘金安东尼7 小时前
玩转龙虾🦞,openclaw 核心命令行收藏(持续更新)v2026.3.2
人工智能