52 条回复  ·  5708 次点击
young1 楼主 初学 2025-9-5 15:26:41
@734694671 还有就是引号问题,模型给的长文本里面包含了召回内容里面带有的引号,有的时候会无法转换,还有就是经纬度,已经限定了条件,但是模型后面输出的时候就会吧经纬度的'转成"
dddd1919 初学 2025-9-5 15:52:30
@young1 #28 如果是支持多轮会话的 AI ,可以在 catch 这一步启用新的会话只做 json 修正,减少大模型理解上下文的时间
glitter1105 初学 2025-9-5 15:58:21
我的处理方法是手动使用正则匹配提取。
matrix1010 小成 2025-9-5 16:23:49
https://www.fex.com/t/1152314
zxr615 初学 2025-9-5 16:59:17
用 tools,限制返回的 Json 结构,在请求中指定定义结构: ``` json { "tools": [ { "type": "function", "function": { "name": "generateContent", "parameters": { "type": "object", "properties": { "filed_1": { "type": "string", "description": "这是要返回的字段 1" }, "filed_2": { "type": "string", "description": "这是要返回的字段 2" } } }, "required": [ "filed_1", "filed_2" ] } } ], "tool_choice": { "type": "function", "function": { "name": "generateContent" } } } ```
quicksandznzn 初学 2025-9-5 17:15:36
json-repair 或者 json_schema 的方式
pathetique 小成 2025-9-5 18:32:34
structured output or function calling (openai)?
kabob 小成 2025-9-5 18:37:44
我这边换了 claude 模型后就解决了,或者 openai o 系列推理模型,总结就是换厉害的模型
donaldturinglee 小成 2025-9-5 18:41:53
我解析 json 用的 json_schema 格式,或者你 call 一个 tool ,让 tool 帮你完成 json 格式的转换
IceBay 初学 2025-9-5 18:57:50
https://github.com/mangiucugna/json_repair DEMO: https://mangiucugna.github.io/json_repair/ 可以用这个库进行修复
返回顶部