unknown
2025-03-11 d5d68339c89b1cbbd9423521bb029b6ad718facd
Merge remote-tracking branch 'origin/appendix' into appendix

# Conflicts:
# JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/control/SMTJavaAIControl.java
# JAVA/SMTAIServer/src/main/resources/requestmap/java_ai.json
已修改2个文件
55 ■■■■ 文件已修改
JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/control/SMTJavaAIControl.java 41 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JAVA/SMTAIServer/src/main/resources/requestmap/java_ai.json 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
JAVA/SMTAIServer/src/main/java/com/smtaiserver/smtaiserver/control/SMTJavaAIControl.java
@@ -1307,20 +1307,20 @@
        
        return tranReq.returnJson(jsonWr);
    }
    public ModelAndView callLLM(SMTAIServerRequest tranReq) throws Exception
    public ModelAndView callLLM(SMTAIServerRequest tranReq) throws Exception
    {
        String llmId = tranReq.convParamToString("llm_id", false);
        Json jsonSystems = tranReq.convParamToJson("system_json", false);
        String question = tranReq.convParamToString("question", true);
        boolean answerIsJson = tranReq.convParamToBoolean("answer_is_json", true);
        SMTJsonWriter jsonWr = tranReq.newReturnJsonWriter(true, null, null);
        SMTLLMConnect conn = SMTAIServerApp.getApp().allocLLMConnect(llmId);
        List<String> listSystem = new ArrayList<>();
        if(jsonSystems != null)
        {
            for(Json jsonSystem : jsonSystems.asJsonList())
@@ -1328,7 +1328,7 @@
                listSystem.add(jsonSystem.asString());
            }
        }
        String answer = conn.callWithMessage(listSystem, question, tranReq);
        if(answerIsJson)
        {
@@ -1368,4 +1368,31 @@
            throw new Exception("Error processing file download: " + e.getMessage());
        }
    }
    public void downloadFileByFileId(SMTAIServerRequest tranReq, HttpServletResponse response) throws Exception {
        String fileId = tranReq.convParamToString("file_id", true);  // 获取请求中的file_id
        SMTDatabase db = SMTAIServerApp.getApp().allocDatabase();
        try {
            // 查询指定file_id的文件记录
            DBRecords dbRecords = db.querySQL("SELECT * FROM ai_times.chat_history_attach WHERE attach_id=?", new Object[]{fileId});
            if (dbRecords.getRecords().isEmpty()) {
                throw new Exception("文件不存在");
            }
            // 获取文件信息
            DBRecord fileRecord = dbRecords.getRecords().get(0);
            String attachTitle = fileRecord.getString("attach_title");  // 获取文件标题
            String attachBytes = fileRecord.getString("attach_bytes");
            byte[] bytes = attachBytes.getBytes();
            // 设置响应头和文件名
            String fileName = attachTitle != null ? attachTitle : "downloaded_file";
            response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
            response.setContentType("application/octet-stream");
            response.getOutputStream().write(bytes);
            response.getOutputStream().flush();
        } catch (Exception e) {
            throw new Exception("Error processing file download: " + e.getMessage());
        }
    }
}
JAVA/SMTAIServer/src/main/resources/requestmap/java_ai.json
@@ -358,7 +358,7 @@
            }
        ]
    },
    "llm/call_llm":{"map":{"class":"#SMTJavaAIControl", "method":"callLLM"}, "no_shrio":true,
            "swaggers":[
            {    "tags" : ["大模型操作"],
@@ -368,6 +368,18 @@
                    {"name":"system_json", "title":"提示json数组 [‘问题1’,‘问题2’...] ", "required":false},
                    {"name":"question", "title":"用户问题", "required":true},
                    {"name":"answer_is_json", "title":"回答问题格式是否是json", "required":true}
                    {"name":"quota_keys", "title":"query_attach_metric_names返回前端的json", "required":true},
                    {"name":"limit", "title":"查询页数,默认100", "required":false}
                ]
            }
        ]
    },
    "file/download_file":{"map":{"class":"#SMTJavaAIControl", "method":"downloadFileByFileId"},
        "swaggers":[
            {    "tags" : ["文件下载"],
                "title" : "文件下载",
                "parameters" : [
                    {"name":"file_id", "title":"文件id", "required":true}
                ]
            }
        ]