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
| | |
| | |
|
| | | 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())
|
| | |
| | | listSystem.add(jsonSystem.asString());
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | String answer = conn.callWithMessage(listSystem, question, tranReq);
|
| | | if(answerIsJson)
|
| | | {
|
| | |
| | | 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());
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | ]
|
| | | },
|
| | | |
| | |
|
| | | "llm/call_llm":{"map":{"class":"#SMTJavaAIControl", "method":"callLLM"}, "no_shrio":true,
|
| | | "swaggers":[
|
| | | { "tags" : ["大模型操作"],
|
| | |
| | | {"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}
|
| | | ]
|
| | | }
|
| | | ]
|