suerprisePlus
2024-10-18 1efa47bc58fe0673a231233f644d3a5f8277e42c
src/main/java/com/yb/controller/agentController.java
@@ -50,10 +50,12 @@
    public R getIntention(@RequestParam Map<String, String> allParams) throws Exception {
        System.out.println("rec getMessage:" + allParams);
        String msg = allParams.get("message");
        String sessionid = allParams.get("session_id");
        String libid = allParams.get("lib_id");
//       判断msg是否为空
        if (StringUtils.isEmpty(msg)) {
            String info = agentService.getAgentIntention(xzConfig.agentUrl, xzConfig.agentIntent, "''");
            String info = agentService.getAgentIntention(xzConfig.agentUrl, xzConfig.agentIntent, "''",sessionid,libid);
            JSONObject obj = JSONObject.parseObject(info);
            String cont = obj.getString("content");
            System.out.println("rec isEmpty:" + cont);
@@ -65,7 +67,8 @@
        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        if (isMap) {
            hashMap.put("type", "Map");
            String funcInfo = agentService.getAgentIntention(xzConfig.agentUrl, xzConfig.agentIntent, msg);
            hashMap.put("session_id", allParams.get("session_id"));
            String funcInfo = agentService.getAgentIntention(xzConfig.agentUrl, xzConfig.agentIntent, msg,sessionid,libid);
            JSONObject jsonObject = JSON.parseObject(funcInfo);
            String orderString = jsonObject.getString("order");
            if (orderString == null) {
@@ -76,13 +79,14 @@
                return R.error(erroContent);
            }
            String report =jsonObject.getString("report");
//          意图函数匹配
            HashMap<String, Object> mapObj = intentionService.getFunctionMatch(orderString, allParams);
            HashMap<String, Object> mapObj = intentionService.getFunctionMatch(orderString, allParams,report);
//            hashMap.put("place",place)
            String args = JSONObject.parseObject(orderString).getString("args");
            if(args!= null){
            if (args != null) {
                String place = JSONObject.parseObject(args).getString("place");
                mapObj.put("place",place);
                mapObj.put("place", place);
            }
            hashMap.put("content", mapObj);
            return R.ok(hashMap);
@@ -92,7 +96,7 @@
            String ragInfo1 = agentService.getAgentRag(xzConfig.agentUrl, xzConfig.agentRag, allParams.get("session_id"), allParams.get("lib_id"), msg);
            System.out.println("rec rag:" + ragInfo1);
            if (ragInfo1.equals("")) {
                String ragInfo = agentService.getAgentIntention(xzConfig.agentUrl, xzConfig.agentChat, msg);
                String ragInfo = agentService.getAgentIntention(xzConfig.agentUrl, xzConfig.agentChat, msg,sessionid,libid);
                JSONObject jsonObject = JSON.parseObject(ragInfo);
                String answer = jsonObject.getString("content");
                System.out.println("Answer: " + answer);
@@ -127,7 +131,7 @@
        formData.put("token", xzConfig.token);
        formData.put("dbid", xzConfig.dbid);
        String obj = entityHttpUtil.getPostMessage(xzConfig.permissionLayer, formData);
        System.out.println("layerList: " + obj);
//        System.out.println("layerList: " + obj);
        HashMap<String, Object> hashMap = new HashMap<String, Object>();
        String layers = JSON.parseObject(JSONObject.parseObject(obj).getString("data")).getString("layers");
        JSONArray dataArray = JSONArray.parseArray(layers);
@@ -160,7 +164,7 @@
        }
            System.out.println("layerList: " + list);
//            System.out.println("layerList: " + list);
        hashMap.put("data", list);
        return R.ok(hashMap);
    }