AI Wiki中文/EN

函数调用接口:格式正确的请求还不是被允许的动作

Function calling

构建一个 JSON-RPC 形式的分发器,把解析、模式校验、权限、确认和业务规则分开,并在响应丢失后不重复预订。

本页目录直觉理解数学与方法代码实现局限与误解实验与练习研究脉络

模型提出请求,程序做出决定

一个基于语言模型的商店助手被要求为顾客保留两本书。模型回复的不是一段话,而是一个结构化请求:调用预订库存的函数,附上商品编码和数量。必须有某个东西把这段文本变成真正的预订,而这个东西是普通软件。它要检查文本是否为合法 JSON、函数是否存在、参数形状是否正确、这个用户是否有权预订、用户是否同意了这个动作,以及商店是否真的有这本书。然后网络把回复弄丢了,客户端又问了一遍。

函数调用(function calling)是这样一种接口模式:开发者向模型描述函数,模型以机器可读的形式输出函数名和参数,由应用决定是否执行以及如何执行。OpenAI 2023 年 6 月的公告描述了这种分工:开发者用 JSON Schema 描述函数,经过微调、能判断何时需要函数的模型输出一个包含调用参数的 JSON 对象。该页把模型的输出描述为这个包含参数的 JSON 对象;它没有明确说由谁运行函数,但它建议在动作前加入确认步骤,这意味着由应用来执行。同一公告提醒,工具输出中的不可信数据可能指使模型执行非预期的动作,并建议在有现实影响的动作之前加入用户确认。函数调用一节

本文把模型当作不可信的请求来源,构建接收一侧。下面的请求是代替模型输出的合成字符串;不涉及模型、网络、付款或真实库存。

五道检查,五种不同的职责

一个请求应当依次通过一系列检查,每一道回答一个不同的问题:

execute(m,u)  ⟺  parse(m)⏟JSON∧shape(m)⏟protocol and schema∧allowed(u,m)⏟permission∧confirmed(u,m)⏟side effects∧feasible(m)⏟business state.\text{execute}(m,u)\iff \underbrace{\mathrm{parse}(m)}_{\text{JSON}}\wedge \underbrace{\mathrm{shape}(m)}_{\text{protocol and schema}}\wedge \underbrace{\mathrm{allowed}(u,m)}_{\text{permission}}\wedge \underbrace{\mathrm{confirmed}(u,m)}_{\text{side effects}}\wedge \underbrace{\mathrm{feasible}(m)}_{\text{business state}} .

这里 m 是消息,u 是主体(principal),即应用已经认证过的身份。主体来自应用,绝不能来自 m 内部的字段,因为模型或它读过的某份文档可以在 JSON 里写入任何身份。

消息信封。 JSON-RPC 2.0 是一个小型、与传输方式无关的远程过程调用协议,我们用它的规范作为信封。请求对象包含成员 jsonrpc,其值必须恰好是字符串 “2.0”;一个方法名;可选的 params,必须是数组或对象;以及 id,必须是字符串、数字或 null。没有 id 的请求是通知:服务器不得回复,因此客户端永远不知道它是否失败。第4–4.2节 响应要么带 result,要么带 error,二者不能同时出现,并带有与请求相同的 id;当 id 无法确定时,例如 JSON 无法解析,响应的 id 为 null。第5节 从 −32768 到 −32000 的错误码是保留的,其中定义了 −32700 解析错误、−32600 无效请求、−32601 方法不存在和 −32602 无效参数;此范围之外的错误码可供应用自定义。第5.1节

多个请求可以作为数组一起发送。服务器可以按任意顺序处理,也可以按任意顺序返回响应;客户端应按 id 匹配。批量中的通知不会得到响应,只含通知的批量什么也不返回。第6节 规范没有定义认证、授权、超时或重试;id 的作用是把响应与请求对应起来。第1与4节

参数模式。 JSON Schema 的 type 关键字接受六种 JSON 类型,外加 “integer”,后者定义为小数部分为零的任何数。Validation 6.1.1 核心规范补充说,其数据模型不区分整数和其他数,相等数字的不同书写形式不在 JSON Schema 的范围之内。Core 4.2.1 所以 2 和 2.0 是同一个实例,而且都是整数:

integer(v)  ⟺  v∈Number ∧ v−⌊v⌋=0.\mathrm{integer}(v)\iff v\in\mathrm{Number}\ \wedge\ v-\lfloor v\rfloor=0 .

有两个后果常让实现者出错。第一,在 Python 中 True 是 int 的实例,但在 JSON 中布尔值不是数,所以用 isinstance 写的校验器会接受 JSON Schema 本应拒绝的布尔数量。第二,仅靠模式检查拦不住未知字段。required 关键字只要求列出的名字存在,省略它等同于空列表。Validation 6.5.3 properties 关键字只校验同时出现在实例和关键字中的名字,而省略 additionalProperties 等同于空模式,接受任何东西。Core 10.3.2.1–10.3.2.3 因此像 admin: true 这样的参数会通过,除非模式把 additionalProperties 设为 false。minimum 和 maximum 给出的边界是闭区间。Validation 6.2.2 与 6.2.4 format 关键字默认只是注解;除非另行配置,实现必须让 format 断言保持关闭。Validation 7.2.1

核心规范还指出,一个对象中出现两个同名属性时,行为是未定义的。Core 4.2.1 我们在 CPython 3.12 下运行示例时观察到,不加钩子的标准 json.loads 会悄悄保留最后一个值(键 a 先给 1 再给 2 的对象解码后 a 等于 2),并且会接受非标准字面量 NaN;这是观察到的程序行为,不是所引规范中的结论。我们的分发器在解析阶段就拒绝这两种情况,避免同一个请求在日志层和执行层被理解成两种意思。

重试需要自己的键。 假设服务器已经预订了库存,随后响应丢失。客户端分不清丢的是请求还是响应,于是重试。如果每次尝试的响应在效果提交之后独立地以概率 ρ 丢失,那么直到收到响应为止的尝试次数服从几何分布:

E[attempts]=∑k≥1k ρk−1(1−ρ)=11−ρ.\mathbb E[\text{attempts}]=\sum_{k\ge 1}k\,\rho^{k-1}(1-\rho)=\frac{1}{1-\rho}.

没有去重时每次尝试都会预订,所以当 ρ = 0.2 时,每一次意图中的预订平均会产生 1.25 次预订。解决办法是应用层的幂等键(idempotency key)。服务器把键、参数指纹 h 和收据一起存下来:

f(k,θ)={stored receipt,(k,h(θ))∈D,error,(k,h′)∈D, h′≠h(θ),execute, then store (k,h(θ),receipt),otherwise.f(k,\theta)= \begin{cases} \text{stored receipt}, & (k,h(\theta))\in\mathcal D,\\ \text{error}, & (k,h')\in\mathcal D,\ h'\ne h(\theta),\\ \text{execute, then store }(k,h(\theta),\text{receipt}), & \text{otherwise}. \end{cases}

JSON-RPC 的 id 不是这个键。重试是一条新消息,可以带新的 id;而幂等键标识的是意图中的那次操作。反过来,两笔参数完全相同但确实不同的订单,需要不同的键。

一个因正确理由说“不”的分发器

程序在一个虚构库存(BOOK: 5,PEN: 8)上定义两个方法:inventory.get 读取库存;inventory.reserve 需要 sku、1 到 9 之间的 quantity 和一个幂等键。两个模式都把 additionalProperties 设为 false。校验器只实现它用到的关键字:type、properties、required、additionalProperties false、minimum 和 maximum。每道检查都映射到一个 JSON-RPC 错误码,或 1001 到 1005 的应用错误码。reader 角色只能调用 inventory.get;buyer 角色两者都能调用,而且 reserve 还需要应用提供的确认标志。

"""Original JSON-RPC-shaped tool dispatcher with fictional inventory; no model, network or real order."""
import copy
import hashlib
import json
import random

SCHEMAS = {
    'inventory.get': {'type': 'object', 'properties': {'sku': {'type': 'string'}},
                      'required': ['sku'], 'additionalProperties': False},
    'inventory.reserve': {'type': 'object',
                          'properties': {'sku': {'type': 'string'},
                                         'quantity': {'type': 'integer', 'minimum': 1, 'maximum': 9},
                                         'key': {'type': 'string'}},
                          'required': ['sku', 'quantity', 'key'], 'additionalProperties': False},
}
SIDE_EFFECTS = {'inventory.reserve'}
PERMISSIONS = {'reader': {'inventory.get'}, 'buyer': {'inventory.get', 'inventory.reserve'}}


def is_type(value, name):
    """JSON types; Python bool is excluded from numbers, and integer means zero fractional part."""
    number = isinstance(value, (int, float)) and not isinstance(value, bool)
    return {'object': isinstance(value, dict), 'string': isinstance(value, str),
            'number': number, 'integer': number and float(value).is_integer()}[name]


def check(value, schema, path='params'):
    """Subset only: type, properties, required, additionalProperties false, minimum, maximum."""
    if not is_type(value, schema['type']):
        return ['%s: expected %s' % (path, schema['type'])]
    errors = []
    if schema['type'] == 'object':
        for name in schema.get('required', []):
            if name not in value:
                errors.append('%s: missing %s' % (path, name))
        for name, child in value.items():
            if name in schema.get('properties', {}):
                errors += check(child, schema['properties'][name], path + '.' + name)
            elif schema.get('additionalProperties') is False:
                errors.append('%s: unexpected %s' % (path, name))
    if 'minimum' in schema and value < schema['minimum']:
        errors.append('%s: below minimum' % path)
    if 'maximum' in schema and value > schema['maximum']:
        errors.append('%s: above maximum' % path)
    return errors


def strict_pairs(pairs):
    seen = {}
    for name, value in pairs:
        if name in seen:
            raise ValueError('duplicate key')
        seen[name] = value
    return seen


def reject_constant(name):
    raise ValueError('non-JSON constant ' + name)


def error(ident, code, message):
    return {'jsonrpc': '2.0', 'error': {'code': code, 'message': message}, 'id': ident}


class Server:
    def __init__(self):
        self.stock, self.ledger, self.effects = {'BOOK': 5, 'PEN': 8}, {}, 0

    def handle_text(self, text, principal, confirmed=False):
        try:
            message = json.loads(text, object_pairs_hook=strict_pairs, parse_constant=reject_constant)
        except ValueError:
            return error(None, -32700, 'Parse error')
        if isinstance(message, list):
            if not message:
                return error(None, -32600, 'Invalid Request')
            replies = [self.handle(item, principal, confirmed) for item in message]
            return [reply for reply in replies if reply is not None] or None
        return self.handle(message, principal, confirmed)

    def handle(self, request, principal, confirmed):
        ident = request.get('id') if isinstance(request, dict) else None
        valid_id = 'id' not in request if isinstance(request, dict) else False
        valid_id = valid_id or ident is None or isinstance(ident, str) or is_type(ident, 'number')
        if (not isinstance(request, dict) or request.get('jsonrpc') != '2.0'
                or not isinstance(request.get('method'), str) or not valid_id
                or not isinstance(request.get('params', {}), (dict, list))):
            return error(ident if valid_id else None, -32600, 'Invalid Request')
        reply = self.dispatch(request, principal, confirmed)
        return None if 'id' not in request else dict(reply, jsonrpc='2.0', id=ident)

    def dispatch(self, request, principal, confirmed):
        method, params = request['method'], request.get('params', {})
        if method not in SCHEMAS:
            return {'error': {'code': -32601, 'message': 'Method not found'}}
        problems = check(params, SCHEMAS[method])
        if problems:
            return {'error': {'code': -32602, 'message': 'Invalid params', 'data': problems}}
        if method not in PERMISSIONS.get(principal, set()):
            return {'error': {'code': 1001, 'message': 'Permission denied'}}
        if method in SIDE_EFFECTS and not confirmed:
            return {'error': {'code': 1002, 'message': 'Confirmation required'}}
        if params['sku'] not in self.stock:
            return {'error': {'code': 1003, 'message': 'Unknown SKU'}}
        if method == 'inventory.get':
            return {'result': {'available': self.stock[params['sku']]}}
        quantity = int(params['quantity'])
        digest = hashlib.sha256(json.dumps([params['sku'], quantity], sort_keys=True).encode()).hexdigest()
        slot = (principal, params['key'])
        if slot in self.ledger:
            old, receipt = self.ledger[slot]
            if old != digest:
                return {'error': {'code': 1004, 'message': 'Key reused with different arguments'}}
            return {'result': dict(copy.deepcopy(receipt), replayed=True)}
        if quantity > self.stock[params['sku']]:
            return {'error': {'code': 1005, 'message': 'Insufficient stock'}}
        self.stock[params['sku']] -= quantity
        self.effects += 1
        receipt = {'reserved': quantity, 'remaining': self.stock[params['sku']], 'replayed': False}
        self.ledger[slot] = (digest, copy.deepcopy(receipt))
        return {'result': receipt}


def call(ident, method, **params):
    return json.dumps({'jsonrpc': '2.0', 'method': method, 'params': params, 'id': ident})


def code(reply):
    return reply['error']['code'] if 'error' in reply else 'ok'


def experiment():
    server, log = Server(), []
    # Synthetic stand-ins for model-proposed calls, including malformed ones.
    proposals = [
        ('truncated JSON', 'buyer', '{"jsonrpc": "2.0", "method": "inventory.get", "params": {"sku"', True),
        ('NaN literal', 'buyer', '{"jsonrpc":"2.0","method":"inventory.get","params":{"sku":NaN},"id":1}', True),
        ('duplicate key', 'buyer', '{"jsonrpc":"2.0","method":"inventory.get","params":{"sku":"BOOK","sku":"PEN"},"id":2}', True),
        ('invented method', 'buyer', call(3, 'inventory.delete', sku='BOOK'), True),
        ('boolean quantity', 'buyer', call(4, 'inventory.reserve', sku='BOOK', quantity=True, key='k0'), True),
        ('extra argument', 'buyer', call(5, 'inventory.reserve', sku='BOOK', quantity=1, key='k0', admin=True), True),
        ('reader may not reserve', 'reader', call(6, 'inventory.reserve', sku='BOOK', quantity=1, key='k0'), True),
        ('no user confirmation', 'buyer', call(7, 'inventory.reserve', sku='BOOK', quantity=1, key='k0'), False),
        ('unknown SKU', 'buyer', call(8, 'inventory.reserve', sku='CHAIR', quantity=1, key='k0'), True),
        ('quantity 2.0 is a JSON Schema integer', 'buyer', call(9, 'inventory.reserve', sku='PEN', quantity=2.0, key='k1'), True),
    ]
    for label, who, text, confirmed in proposals:
        log.append({'case': label, 'code': code(server.handle_text(text, who, confirmed))})
    first = call(10, 'inventory.reserve', sku='BOOK', quantity=2, key='k2')
    server.handle_text(first, 'buyer', True)  # Response deliberately discarded: simulated loss.
    log.append({'case': 'lost response after commit', 'stock': dict(server.stock), 'effects': server.effects})
    retry = server.handle_text(call(11, 'inventory.reserve', sku='BOOK', quantity=2, key='k2'), 'buyer', True)
    log.append({'case': 'retry with same key, new id', 'code': code(retry), 'result': retry['result'],
                'effects': server.effects})
    changed = server.handle_text(call(12, 'inventory.reserve', sku='BOOK', quantity=1, key='k2'), 'buyer', True)
    log.append({'case': 'same key, changed quantity', 'code': code(changed)})
    fresh = server.handle_text(call(13, 'inventory.reserve', sku='BOOK', quantity=2, key='k3'), 'buyer', True)
    log.append({'case': 'same arguments, new key', 'code': code(fresh), 'result': fresh['result']})
    batch = [json.loads(call('a', 'inventory.get', sku='BOOK')), json.loads(call('b', 'inventory.get', sku='PEN')),
             {'jsonrpc': '2.0', 'method': 'inventory.get', 'params': {'sku': 'PEN'}}, {'foo': 'bar'}]
    replies = server.handle_text(json.dumps(batch), 'reader')
    random.Random(1).shuffle(replies)
    by_id = {reply['id']: reply for reply in replies if reply['id'] is not None}
    return {'synthetic': True, 'log': log,
            'batch': {'sent': len(batch), 'replies': len(replies), 'arrival_order': [r['id'] for r in replies],
                      'matched': {k: by_id[k]['result'] for k in ('a', 'b')},
                      'uncorrelated_errors': sum(r['id'] is None for r in replies)},
            'final_stock': server.stock, 'successful_effects': server.effects, 'ledger_entries': len(server.ledger)}


if __name__ == '__main__':
    print(json.dumps(experiment(), indent=1))
合成请求结果
截断的 JSON−32700 解析错误,id 为 null
数值写成 NaN−32700
重复键 sku−32700
编造的方法 inventory.delete−32601 方法不存在
quantity 为 true−32602 无效参数
多出参数 admin−32602 无效参数
reader 调用 reserve1001 权限不足
buyer 未经确认就预订1002 需要确认
未知商品 CHAIR1003 未知商品
PEN 的 quantity 为 2.0接受;PEN 8 → 6

2.0 这一行是正确的 JSON Schema 行为,不是缺陷:这个数的小数部分为零,所以是整数实例。业务层在改动库存之前把它转换成整数 2。若某个更严格的接口想拒绝 2.0,必须在自己的文档里写明,因为标准模式校验不会这样做。

接着运行重试序列:

步骤结果BOOK效果数
预订 2 本 BOOK,键 k2,id 10;响应被丢弃已提交32
重试,同一键 k2,新 id 11重放收据:预订 2,剩余 332
同一键 k2,数量改为 1,id 121004 键被用于不同参数32
相同参数,新键 k3,id 13预订 2,剩余 113

效果计数器统计成功的预订:2.0 那一行的 PEN 预订,加上两次 BOOK 预订。最终状态为 BOOK 1、PEN 6,账本有三条记录,每个键一条。

最后,reader 发送一个含四个元素的批量:id 为 a 和 b 的两个请求、一个通知,以及一个缺少必需成员的对象。服务器返回三个响应。经过一次确定性打乱后,它们按 b、null、a 的顺序到达。按 id 匹配可以为 a 取回 BOOK 1、为 b 取回 PEN 6;id 为 null 的错误无法对应到任何请求,单独计数;通知没有产生响应。

这个分发器不保证什么

账本和库存存放在一个进程的内存中,提交是两次连续赋值,在本仿真里没有任何东西能打断它们。真实服务需要把库存变化和账本写入放进同一个持久事务,还要有键过期的策略。在并发情况下,除非“检查并插入”是原子的,两次同时到达的重试可能都查不到账本。这些都不是网络上的“恰好一次”投递;最多只是至少一次投递加上对效果的去重。

重放已存的收据会返回旧答案,包括当时的剩余库存。这正是幂等的含义,但也意味着重放的响应不是最新读数。需要当前库存的客户端必须调用 inventory.get。

模式校验和权限检查并不判断请求是否合理。模型完全可能产生一个格式合法、已授权、已确认、却订错商品的预订,原因可能是误解了用户,也可能是某个工具结果里夹带了指令。这里的确认标志是测试代码提供的布尔值;真实界面必须向用户准确展示将要发生的事,确认必须来自用户,而不是来自模型输出。

校验器只覆盖六个关键字。它不是 JSON Schema 实现,不处理引用、组合关键字、正则模式、format 或数组。生产系统应使用有人维护的校验器,同时仍然把权限、确认和业务各层分开。

找出应当拒绝它的那一层

  1. 一个请求是合法 JSON,也符合 reserve 的模式,但用户是 reader 角色。哪一层拒绝它?为什么主体不能取自请求中的某个字段?

    答案:权限层以错误码 1001 拒绝它。主体必须来自应用已认证的会话。如果它是 JSON 字段,模型,或通过工具结果注入到模型上下文中的文本,就可以直接写上 “buyer”。

  2. reserve 的模式省略了 additionalProperties。模型发送了 sku、quantity、key 和 admin: true。模式校验会通过吗?quantity: true 呢?quantity: 3.0 呢?

    答案:省略 additionalProperties 时,admin 不在 properties 覆盖范围内,而被省略的关键字等同于空模式,所以校验通过,admin 会悄悄到达处理函数,除非别的环节拒绝它。quantity: true 不通过,因为 JSON 布尔值不是数,尽管 Python 把 True 当作 int。quantity: 3.0 作为整数通过,因为它的小数部分为零。

  3. 预订提交后,响应以 0.25 的概率独立丢失,客户端一直重试到收到响应为止。没有幂等键时,每次意图中的预订平均会产生多少次预订?有幂等键时呢?

    答案:期望尝试次数 = 1/(1 − 0.25) = 4/3 ≈ 1.333,每次尝试都会提交,所以平均约 1.333 次预订。有幂等键时,第一次尝试提交,之后的尝试重放收据,所以恰好一次预订,前提是账本写入和库存变化一起提交。

  4. 一位同事建议用 JSON-RPC 的 id 充当幂等键,省掉一个字段;并把预订作为通知发送以节省带宽。这两个主意各有什么问题?

    答案:id 用来把一条消息与它的响应对应起来。客户端常常为每次重试生成新的 id,不同会话的 id 也可能冲突,所以 id 不能标识意图中的那次操作;重试时换了新 id 就会造成第二次预订。按规范通知不会得到响应,客户端无法知道预订是成功、未通过校验还是被拒绝,这对有现实影响的操作是不可接受的。

规范定下底线,而不是策略

2023 年的公告描述了许多读者最先接触到的模式:输入模式、输出参数、由应用执行(页面是暗示而非明说),并警告工具输出可能左右模型。函数调用一节 我们读了该页面的函数调用一节及其后的安全段落;同页上的模型名称、价格和弃用日期属于产品历史,不是本文主张的一部分。

JSON-RPC 2.0 我们完整读过,它定义了消息形状、错误码和批量对应,对安全和重试未作规定。规范 2020-12 版 JSON Schema 文档以 2022 年 6 月的互联网草案形式发布,定义了什么是合法实例;我们读了 type、enum、const、数值边界、required、实例数据模型、properties 与 additionalProperties 的章节,以及 format 要求的开头部分。Validation Core 谁可以做什么、何时必须由用户确认、重试如何避免重复效果,这些都是建立在其上的应用策略。

先判断,再看解释

一个预订请求的响应丢失,客户端用新的 JSON-RPC id 重试。怎样避免重复预订?

选择一个答案

学习目标

  • 把解析、协议与模式校验、权限、用户确认和业务规则分成不同层,并为每层映射错误码。
  • 用幂等键处理响应丢失后的重试,计算无去重时的期望重复效果,并按 id 关联乱序批量响应。

先修与延伸

查看知识关联图 →

参考文献

  1. Function calling and other API updates — OpenAI announcement
    Atty Eleti; Jeff Harris; Logan Kilpatrick · 2023
  2. JSON Schema Validation: A Vocabulary for Structural Validation of JSON — Draft 2020-12 (draft-bhutton-json-schema-validation-01)
    Austin Wright; Henry Andrews; Ben Hutton · 2022
  3. JSON Schema: A Media Type for Describing JSON Documents — Draft 2020-12 core (draft-bhutton-json-schema-01)
    Austin Wright; Henry Andrews; Ben Hutton; Greg Dennis · 2022
  4. JSON-RPC 2.0 Specification
    JSON-RPC Working Group · 2013

版本1 · 编写状态: 已完成记录中的技术复核

查看技术检查记录(AI)

Claude · 2026-12-02 · Independent AI check (Claude subagent, not the author); this is not a human or expert review. Ran example.py with CPython 3.12.4 and compared with example.stdout.txt (identical); confirmed both code blocks are byte-identical to example.py and that every result code, stock value, effect count and batch order in the tables matches. Ran json.loads directly to confirm the duplicate-key (last value kept) and NaN-accepted behaviour. Hand-checked 1/(1−0.2) = 1.25 and 1/(1−0.25) ≈ 1.333. Fetched the OpenAI 2023-06-13 announcement: it supports JSON Schema function descriptions, fine-tuning to detect when a function is needed, JSON-object argument output, and the tool-output injection warning with user confirmation advice, but it does not explicitly state who executes the function. Fetched JSON Schema Validation 2020-12 for 6.2.2, 6.2.4, 6.5.3 and 7.2.1 (format assertion disabled by default). Relied on the writer's locators for JSON Schema Core 4.2.1/10.3.2 and the JSON-RPC 2.0 sections, spot-checking them against known specification text rather than a fresh full read. Compared zh and en section by section.

  • 程序输出、代码块一致性与所有错误码、库存、批量顺序核对无误。
  • 重试期望 1.25 与 1.333 手算一致。
  • OpenAI 公告支持所引内容;“由应用执行”改为页面暗示而非明说。
  • JSON Schema 验证规范 6.2.2、6.2.4、6.5.3、7.2.1 与文中描述一致。

核对的来源位置:

  • Function calling and other API updates — OpenAI announcement · Official page dated2023-06-13. Read the HTML introduction list, the Function calling section (JSON Schema function descriptions, argument JSON output, three use cases, functions/function_call parameters) and the following safety paragraph on tool-output injection and user confirmation. Model names, prices, deprecations and the2023-07-20 update are not used as claims; not a current API tutorial.
  • JSON Schema Validation: A Vocabulary for Structural Validation of JSON — Draft 2020-12 (draft-bhutton-json-schema-validation-01) · Internet-Draft published2022-06-16. Read6.1.1 type (integer as zero fractional part), 6.1.2 enum, 6.1.3 const, 6.2.1–6.2.5 numeric bounds, 6.5.2, 6.5.3 required, start of6.5.4, and7.2/7.2.1 (format as annotation; assertion disabled by default). Other sections unread.
  • JSON Schema: A Media Type for Describing JSON Documents — Draft 2020-12 core (draft-bhutton-json-schema-01) · Internet-Draft published2022-06-16. Read4.2.1 instance data model (numbers do not distinguish integers, lexical forms of equal numbers out of scope, duplicate keys undefined, integer as a vocabulary notion) and10.3.2.1–10.3.2.3 (properties, patternProperties, additionalProperties; omission equals empty schema). Rest unread.
  • JSON-RPC 2.0 Specification · Page states origin2010-03-26 (based on2009-05-24) and update2013-01-04. Read Sections1–8 in full: request object, notifications receive no reply, parameter structures, result/error exclusivity and id, error object and reserved codes, batches in any order matched by id, all-notification batches return nothing, examples and extensions. No authentication, authorization, timeout or idempotent-retry rules are defined.

相关主题

没有匹配结果,试试英文名或缩写。

已显示 0 条结果

将整个查询放入双引号,可按短语匹配。