【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文件

相关推荐
chuan.bai2 小时前
Java RAG 实战(第 11 篇):RAG 知识工作台网页
java·开发语言·人工智能
fthux5 小时前
招聘季实测:我用 TraeWork 搭了一套 AI 简历初筛系统
人工智能·ai编程·trae
SLD_Allen5 小时前
NVIDIA KAI Scheduler深度解析——Kubernetes原生AI调度器的架构、原理与实践
人工智能·架构·kubernetes
小玮看世界5 小时前
从“画图”到“Mermaid”:AI语义理解与架构绘制的演进之路
人工智能·深度学习·计算机视觉
小岐AI观6 小时前
智赋岐黄适合养生馆吗?
大数据·人工智能·物联网
YOLO数据集集合6 小时前
煤炭物料检测数据集:基于YOLO26的矿山传送带智能“哨兵”
人工智能·yolo·数据挖掘·煤炭·煤炭检测·矿山传送带·传送带异物
深小乐6 小时前
DeepSeek Harness 强是真的强,普通用户可以再等等
人工智能