From 64ffad1a52cb2aa74b477ae5430864fbda9b9b8d Mon Sep 17 00:00:00 2001 From: 1585346868 <1585346868@qq.com> Date: Sun, 28 Jun 2026 00:00:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20target/aliyun/ai.lua?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- target/aliyun/ai.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/target/aliyun/ai.lua b/target/aliyun/ai.lua index 76c95a8..3fa691c 100644 --- a/target/aliyun/ai.lua +++ b/target/aliyun/ai.lua @@ -5,12 +5,15 @@ local cjson = require("cjson") local M = {} local url = "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions" -M.ask = function(key,content,model) +M.ask = function(key,content,model,is_json) -- 构造 JSON 格式的请求数据 local payload = { model = model, - messages = content - } + messages = content, + } + if is_json ~= nil and is_json == true then + payload["response_format"] = {type = "json_object"} + end local response_body = {} local res, code, response_headers, status = http.request{