| | |
| | | db.beginTran();
|
| | | try
|
| | | {
|
| | | db.executeSQL("INSERT INTO sys_user_info(user_id, user_name, user_state_code)VALUES(?, ?, ?)", new Object[] {
|
| | | db.executeSQL("INSERT INTO sys_user_info(user_id, user_name, user_state_code, create_time)VALUES(?, ?, ?, ?)", new Object[] {
|
| | | userId,
|
| | | userName,
|
| | | "Y"
|
| | | "Y",
|
| | | new Date()
|
| | | });
|
| | |
|
| | | db.executeSQL("INSERT INTO sys_role_user(user_id, role_id)VALUES(?, ?)", new Object[] {
|
| | |
| | | return tranReq.returnJsonState(false, "登录失败", null);
|
| | |
|
| | | String userPass = recs.getRecord(0).getString("user_pass");
|
| | | if(!SMTStatic.isNullOrEmpty(userPass))
|
| | | //if(!SMTStatic.isNullOrEmpty(userPass))
|
| | | {
|
| | | if(!userPass.equals(password))
|
| | | if(!password.equals(userPass))
|
| | | return tranReq.returnJsonState(false, "登录失败", null);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | public class SMTJavaAIControl
|
| | | {
|
| | | private class SMTCallAgentArgStreamView implements View
|
| | | {
|
| | | private SMTAIServerRequest _tranReq;
|
| | | |
| | | public SMTCallAgentArgStreamView(SMTAIServerRequest tranReq)
|
| | | {
|
| | | _tranReq = tranReq;
|
| | | _tranReq.setChunkedMode(true);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void render(Map<String, ?> model, HttpServletRequest request, HttpServletResponse response) throws Exception |
| | | {
|
| | | String agentId = _tranReq.convParamToString("agent_id", true);
|
| | | Json jsonArgs = _tranReq.convParamToJson("call_args", true);
|
| | | |
| | | response.setCharacterEncoding("UTF-8");
|
| | | response.setContentType("text/plain;charset=UTF-8");
|
| | | response.setHeader("smtstream", "chunked");
|
| | | |
| | | try
|
| | | {
|
| | | SMTQwenAgent agent = SMTAIServerApp.getApp().getQwenAgentManager().getAgentById(agentId);
|
| | | if(agent == null)
|
| | | throw new Exception("can't find agent : " + agentId);
|
| | | SMTLLMConnect llm = SMTAIServerApp.getApp().allocLLMConnect(null);
|
| | | |
| | | if(!jsonArgs.has("question"))
|
| | | jsonArgs.set("question", "");
|
| | | |
| | | agent.callAgents("/", jsonArgs, llm, "", _tranReq);
|
| | | }
|
| | | catch(Exception ex)
|
| | | {
|
| | | _tranReq.traceLLMDebug("call chat stream excetion : \n" + SMTStatic.toString(ex));
|
| | | _tranReq.sendChunkedBlock("error", ex.getMessage());
|
| | | }
|
| | | _tranReq.sendChunkedBlock("finish", "");
|
| | | }
|
| | | }
|
| | | |
| | | private class SMTAgentStreamView implements View
|
| | | {
|
| | | private SMTAIServerRequest _tranReq;
|
| | |
| | | }
|
| | |
|
| | |
|
| | | public ModelAndView chatCallAgent(SMTAIServerRequest tranReq, HttpServletResponse response) throws Exception
|
| | | public ModelAndView chatCallAgent(SMTAIServerRequest tranReq) throws Exception
|
| | | {
|
| | | String agentId = tranReq.convParamToString("agent_id", true);
|
| | | Json jsonArgs = tranReq.convParamToJson("args", false);
|
| | |
| | | return tranReq.returnJson(jsonWr);
|
| | |
|
| | | }
|
| | | |
| | | public ModelAndView callAgentArgStream(SMTAIServerRequest tranReq) throws Exception
|
| | | {
|
| | | return new ModelAndView(new SMTCallAgentArgStreamView(tranReq));
|
| | | }
|
| | | }
|
| | |
| | | ]
|
| | | },
|
| | |
|
| | | "chat/call_agent_arg_stream":{"map":{"class":"#SMTJavaAIControl", "method":"callAgentArgStream"},
|
| | | "swaggers":[
|
| | | { "tags" : ["AI大模型对话"],
|
| | | "title" : "流式直接调用agent带参数",
|
| | | "parameters" : [
|
| | | {"name":"agent_id", "title":"要调用的agent id", "required":true},
|
| | | {"name":"call_args", "title":"调用时候的参数", "required":true}
|
| | | ]
|
| | | }
|
| | | ]
|
| | | },
|
| | | |
| | | "chat/share_chat_history":{"map":{"class":"#SMTJavaAIControl", "method":"shareChatHistory"},
|
| | | "swaggers":[
|
| | | { "tags" : ["AI操作"],
|