Bladeren bron

修改app包名路径,对接电视语音

wjg 1 jaar geleden
bovenliggende
commit
6edd762ec8

+ 2 - 2
app/build.gradle.kts

@@ -3,11 +3,11 @@ plugins {
 }
 
 android {
-    namespace = "com.ch.jedge.demo.glm"
+    namespace = "com.ch.jedge.llm.filter.glm"
     compileSdk = 33
 
     defaultConfig {
-        applicationId = "com.ch.jedge.demo.glm"
+        applicationId = "com.ch.jedge.llm.filter.glm"
         minSdk = 24
         targetSdk = 33
         versionCode = 1

+ 1 - 1
app/src/main/assets/cfg/dataset/smarthome/sh_cmd_list.json

@@ -2,7 +2,7 @@
   {"key": "turnOn", "disc": "打开或开启一个设备"},
   {"key": "turnOff", "disc": "关闭设备"},
   {"key": "setBrightness", "disc": "调整灯光亮度,需要额外参数,参数关键字:set_value,参数值:亮度值整数值,亮度值范围是:0-65535,最低亮度为655,变化幅度为6553"},
-  {"key": "setLightTemperature", "disc": "设备色温调整为冷光或暖光,需要额外参数,参数关键字:set_value,参数值:灯光温度取值整数值,灯光温度值范围是:2700-6500,2700为暖光,6500为冷光,变化幅度为1000"},
+  {"key": "setColorTemperature", "disc": "设备色温调整为冷光或暖光,需要额外参数,参数关键字:set_value,参数值:灯光温度取值整数值,灯光温度值范围是:2700-6500,2700为暖光,6500为冷光,变化幅度为1000"},
   {"key": "setLighterMode", "disc": "调整灯光模式:日光模式,彩光模式,流光模式,需要额外参数,参数关键字:set_value,参数值:模式取值整数值,模式值取值:流光=9,彩光=8,日光=6"},
   {"key": "setFlowMode", "disc": "流光模式下、调整流光速度,需要额外参数,参数关键字:flow_speed,参数值:流光速度整数值,流光速度取值为0-100"},
   {"key": "setColorMode", "disc": "设备颜色调整为红色,橙色,黄色,绿色,青色,蓝色,紫色,需要额外参数,参数关键字:hue,参数值:颜色对应的hue整数值,红色:0,橙色:5439,黄色:10944,绿色:21823,青色:32768,蓝色:43712,紫色:54591"},

+ 1 - 1
app/src/main/assets/cfg/jbot.json

@@ -5,6 +5,6 @@
     "host4": "localhost",
     "host": "127.0.0.1",
     "port": 8877,
-    "name": "jbot!"
+    "name": "jbot"
   }
 }

+ 1 - 1
app/src/main/assets/cfg/jsmart.json

@@ -6,6 +6,6 @@
     "host4": "localhost",
     "host": "127.0.0.1",
     "port": 8877,
-    "name": "jsm"
+    "name": "jsmart"
   }
 }

+ 1 - 1
app/src/main/assets/cfg/llm.json

@@ -5,6 +5,6 @@
     "host4": "localhost",
     "host": "127.0.0.1",
     "port": 8877,
-    "name": "llm!"
+    "name": "llm"
   }
 }

+ 1 - 1
app/src/main/cpp/mgs-driver.cpp

@@ -8,7 +8,7 @@
 #define LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) // 定义LOGD类型
 
 extern "C" JNIEXPORT void JNICALL
-Java_com_ch_jedge_demo_glm_service_MgsService_handleStartService (
+Java_com_ch_jedge_llm_filter_glm_service_MgsService_handleStartService (
         JNIEnv* env,
         jobject /* this */, jstring dir , jstring dir_cache) {
     const char* local_dir, *local_dir_cache;

+ 1 - 1
app/src/main/java/com/ch/jedge/jbot/JEJBotLLMConst.java

@@ -8,7 +8,7 @@ public class JEJBotLLMConst {
     public static final String sval_sub_dir_field_cfg = "cols";
 
     // public static final String sval_panel_class_base_path = (new File(ConfigUtil.class.getResource("/").getFile())).getPath();
-    public static final String sval_panel_class_base_path = "/storage/emulated/0/Android/data/com.ch.jedge.demo.glm/cache/";//"./";
+    public static final String sval_panel_class_base_path = "/storage/emulated/0/Android/data/com.ch.jedge.llm.filter.glm/cache/";//"./";
     public static final String sval_server_db_cfg_filename = FileUtils.contactPath(sval_panel_class_base_path, sval_sub_dir_cfg, "db.json");
 
     public static final String sval_milvus_col_def_filename = FileUtils.contactPath(sval_panel_class_base_path, sval_sub_dir_cfg,"_col_def.json");

+ 1 - 1
app/src/main/java/com/ch/jedge/jbot/intent/JedgeJBotCBService.java

@@ -39,7 +39,7 @@ public class JedgeJBotCBService extends JMgbusService {
             String host = msg.getString("host");
             int port = msg.getInteger("port");
             is_online_ = true;
-            watchMgbusEvent("online", "jbot!", qiData -> {
+            watchMgbusEvent("online", "jbot", qiData -> {
                 synchronized (quitCtrl) {
                     if (!is_active_) {
                         is_active_= true;

+ 8 - 13
app/src/main/java/com/ch/jedge/jbot/intent/bot/JBotAppClient.java

@@ -11,25 +11,20 @@ import static com.ch.jedge.jbot.JEJBotLLMConst.sval_default_llm_call_service;
 
 public class JBotAppClient extends JMgbusClient {
 
-    static private JBotAppClient jLlmBot;
-
     public JBotAppClient(String subnet, String mgc_name, int threadCount, boolean tryLocal) {
         super(subnet, mgc_name, threadCount, tryLocal);
     }
 
     public static JBotAppClient getInstance(String botName, Class<? extends JedgeJBotCBService> serviceCls) {
-        if(jLlmBot == null) {
-            jLlmBot = new JBotAppClient("#0", botName, 10, true);
-            try {
-                Constructor<? extends JedgeJBotCBService> constructor = serviceCls.getConstructor(JMgbusModual.class);
-                JedgeJBotCBService service = constructor.newInstance(jLlmBot);
-                jLlmBot.bindService(sval_default_llm_call_service, service);
-            }catch (Exception e) {
-                e.printStackTrace();
-                return null;
-            }
+        JBotAppClient jLlmBot = new JBotAppClient("#0", botName, 10, true);
+        try {
+            Constructor<? extends JedgeJBotCBService> constructor = serviceCls.getConstructor(JMgbusModual.class);
+            JedgeJBotCBService service = constructor.newInstance(jLlmBot);
+            jLlmBot.bindService(sval_default_llm_call_service, service);
+        }catch (Exception e) {
+            e.printStackTrace();
+            return null;
         }
         return jLlmBot;
     }
-
 }

+ 24 - 10
app/src/main/java/com/ch/jedge/demo/glm/MainActivity.java → app/src/main/java/com/ch/jedge/llm/filter/glm/MainActivity.java

@@ -1,4 +1,4 @@
-package com.ch.jedge.demo.glm;
+package com.ch.jedge.llm.filter.glm;
 
 import androidx.appcompat.app.AppCompatActivity;
 import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -13,14 +13,15 @@ import android.content.IntentFilter;
 import android.os.Bundle;
 import android.util.Log;
 
-import com.ch.jedge.demo.glm.asserts.QAssetsCopyer;
-import com.ch.jedge.demo.glm.service.BaseJedgeService;
-import com.ch.jedge.demo.glm.service.JBotService;
-import com.ch.jedge.demo.glm.service.JGlmService;
-import com.ch.jedge.demo.glm.service.MgsService;
-import com.ch.jedge.demo.glm.service.PanleAgentService;
-import com.ch.jedge.demo.glm.service.TVAgentService;
-import com.ch.jedge.demo.glm.service.TVMufisService;
+import com.ch.jedge.llm.filter.glm.asserts.QAssetsCopyer;
+import com.ch.jedge.llm.filter.glm.service.BaseJedgeService;
+import com.ch.jedge.llm.filter.glm.service.JBotService;
+import com.ch.jedge.llm.filter.glm.service.JGlmService;
+import com.ch.jedge.llm.filter.glm.service.MgsService;
+import com.ch.jedge.llm.filter.glm.service.PanleAgentService;
+import com.ch.jedge.llm.filter.glm.service.TVAgentService;
+import com.ch.jedge.llm.filter.glm.service.TVMufisService;
+import com.ch.jedge.tvmufis.JeageTVBridge;
 import com.changhong.qlib.util.file.FileUtils;
 
 import java.util.ArrayList;
@@ -35,6 +36,7 @@ public class MainActivity extends AppCompatActivity {
 
     //添加过滤器,用于过滤发送过来广播
     private IntentFilter filter = new IntentFilter("intent.jedge.glm.msg");
+    private IntentFilter asr_filter = new IntentFilter("com.ch.jedge.llm.filter.glm.asr");
 
     @SuppressLint("UnspecifiedRegisterReceiverFlag")
     @Override
@@ -70,7 +72,7 @@ public class MainActivity extends AppCompatActivity {
         BaseJedgeService.startJedgeService(this , dir, jedgeBasePath, "jsmart", PanleAgentService.class);
 
         //注册广播
-//        registerReceiver(new MsgReceiver(), filter);
+        registerReceiver(new AsrMsgReceiver(), asr_filter);
 //        LocalBroadcastManager.getInstance(this).registerReceiver(msgReceiver, filter);
     }
 
@@ -122,4 +124,16 @@ public class MainActivity extends AppCompatActivity {
             }
         }
     }
+
+    class AsrMsgReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context var1, Intent var2) {
+            String content = var2.getStringExtra("text");
+            if(content.isEmpty())
+                return;
+            Log.d("ASRTEXTFORGLM", content);
+            JeageTVBridge bridge = JeageTVBridge.getInstance();
+            bridge.senduserMsg(content);
+        }
+    }
 }

+ 1 - 1
app/src/main/java/com/ch/jedge/demo/glm/MsgAdapter.java → app/src/main/java/com/ch/jedge/llm/filter/glm/MsgAdapter.java

@@ -1,4 +1,4 @@
-package com.ch.jedge.demo.glm;
+package com.ch.jedge.llm.filter.glm;
 
 import android.view.LayoutInflater;
 import android.view.View;

+ 1 - 1
app/src/main/java/com/ch/jedge/demo/glm/MsgContent.java → app/src/main/java/com/ch/jedge/llm/filter/glm/MsgContent.java

@@ -1,4 +1,4 @@
-package com.ch.jedge.demo.glm;
+package com.ch.jedge.llm.filter.glm;
 
 public class MsgContent {
     public static final int TYPE_RECEIVED = 0;

+ 1 - 1
app/src/main/java/com/ch/jedge/demo/glm/asserts/QAssetsCopyer.java → app/src/main/java/com/ch/jedge/llm/filter/glm/asserts/QAssetsCopyer.java

@@ -1,4 +1,4 @@
-package com.ch.jedge.demo.glm.asserts;
+package com.ch.jedge.llm.filter.glm.asserts;
 
 import android.content.Context;
 import android.content.res.AssetManager;

+ 2 - 5
app/src/main/java/com/ch/jedge/demo/glm/service/BaseJedgeService.java → app/src/main/java/com/ch/jedge/llm/filter/glm/service/BaseJedgeService.java

@@ -1,4 +1,4 @@
-package com.ch.jedge.demo.glm.service;
+package com.ch.jedge.llm.filter.glm.service;
 
 import android.app.IntentService;
 import android.app.Notification;
@@ -9,10 +9,7 @@ import android.content.Intent;
 import android.os.Build;
 import android.util.Log;
 
-import com.ch.jedge.glm.JGlmJava;
-import com.ch.jedge.jbot.JBotJava;
-import com.changhong.qlib.util.StringUtils;
-import com.ch.jedge.demo.glm.R;
+import com.ch.jedge.llm.filter.glm.R;
 
 public abstract class BaseJedgeService extends IntentService {
     public static final String Service_Key_Mgs = "mgs";

+ 1 - 1
app/src/main/java/com/ch/jedge/demo/glm/service/JBotService.java → app/src/main/java/com/ch/jedge/llm/filter/glm/service/JBotService.java

@@ -1,4 +1,4 @@
-package com.ch.jedge.demo.glm.service;
+package com.ch.jedge.llm.filter.glm.service;
 
 import com.ch.jedge.jbot.JBotJava;
 

+ 1 - 1
app/src/main/java/com/ch/jedge/demo/glm/service/JGlmService.java → app/src/main/java/com/ch/jedge/llm/filter/glm/service/JGlmService.java

@@ -1,4 +1,4 @@
-package com.ch.jedge.demo.glm.service;
+package com.ch.jedge.llm.filter.glm.service;
 
 import com.ch.jedge.glm.JGlmJava;
 

+ 1 - 3
app/src/main/java/com/ch/jedge/demo/glm/service/MgsService.java → app/src/main/java/com/ch/jedge/llm/filter/glm/service/MgsService.java

@@ -1,6 +1,4 @@
-package com.ch.jedge.demo.glm.service;
-
-import com.ch.jedge.jbot.JBotJava;
+package com.ch.jedge.llm.filter.glm.service;
 
 public class MgsService extends BaseJedgeService {
 

+ 2 - 2
app/src/main/java/com/ch/jedge/demo/glm/service/PanleAgentService.java → app/src/main/java/com/ch/jedge/llm/filter/glm/service/PanleAgentService.java

@@ -1,7 +1,7 @@
-package com.ch.jedge.demo.glm.service;
+package com.ch.jedge.llm.filter.glm.service;
 
 import com.ch.jedge.bots.jsmart.JedgeSmartHomeBot;
-import com.ch.jedge.demo.glm.asserts.QAssetsCopyer;
+import com.ch.jedge.llm.filter.glm.asserts.QAssetsCopyer;
 
 public class PanleAgentService extends BaseJedgeService {
 

+ 2 - 2
app/src/main/java/com/ch/jedge/demo/glm/service/TVAgentService.java → app/src/main/java/com/ch/jedge/llm/filter/glm/service/TVAgentService.java

@@ -1,7 +1,7 @@
-package com.ch.jedge.demo.glm.service;
+package com.ch.jedge.llm.filter.glm.service;
 
 import com.ch.jedge.bots.tvass.JedgeTVAssistant;
-import com.ch.jedge.demo.glm.asserts.QAssetsCopyer;
+import com.ch.jedge.llm.filter.glm.asserts.QAssetsCopyer;
 
 public class TVAgentService extends BaseJedgeService {
 

+ 3 - 2
app/src/main/java/com/ch/jedge/demo/glm/service/TVMufisService.java → app/src/main/java/com/ch/jedge/llm/filter/glm/service/TVMufisService.java

@@ -1,11 +1,11 @@
-package com.ch.jedge.demo.glm.service;
+package com.ch.jedge.llm.filter.glm.service;
 
 import android.content.Intent;
 
 import androidx.localbroadcastmanager.content.LocalBroadcastManager;
 
-import com.ch.jedge.glm.JGlmJava;
 import com.ch.jedge.tvmufis.JeageTVBridge;
+
 import com.ch.jedge.tvmufis.TvMufis;
 
 public class TVMufisService extends BaseJedgeService {
@@ -33,4 +33,5 @@ public class TVMufisService extends BaseJedgeService {
 //         sendBroadcast(intent);
          LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
      }
+
 }

+ 22 - 2
app/src/main/java/com/ch/jedge/tvmufis/JeageTVBridge.java

@@ -1,7 +1,10 @@
 package com.ch.jedge.tvmufis;
 
-import com.ch.jedge.demo.glm.MsgContent;
-import com.ch.jedge.demo.glm.service.TVMufisService;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.ch.jedge.llm.filter.glm.service.TVMufisService;
+import com.changhong.qlib.QData;
+import com.changhong.qlib.intf.QIData;
 
 public class JeageTVBridge {
 
@@ -39,4 +42,21 @@ public class JeageTVBridge {
         }
     }
 
+    public void senduserMsg(String content) {
+        if(!"".equals(content)) {
+            QIData qiData = new QData();
+            qiData.putBoolean("stream", true);
+            qiData.putBoolean("k", true);
+            qiData.putString("text",content);
+//            qiData.putString("uri","/gpt/knTalk");
+            JedgeTvMufisClient client = JedgeTvMufisClient.getInstance();
+            client.postThread(new Runnable() {
+                @Override
+                public void run() {
+                    client.postMgbusMessage("jbot", "/gpt/knTalk", qiData.asJsonObject());
+                }
+            });
+        }
+    }
+
 }