1.AI语音关于取消当前对话逻辑修改,添加AI回应类型枚举(后续会配合使用)
authorluozheng <1732036298@qq.com>
Wed, 28 Aug 2024 10:22:57 +0000 (18:22 +0800)
committerluozheng <1732036298@qq.com>
Wed, 28 Aug 2024 10:22:57 +0000 (18:22 +0800)
code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceView.cpp

index 3ab0a1e..87b1d09 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 15:14:43
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-21 11:34:53
+ * @LastEditTime: 2024-08-28 17:45:47
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/include/AiVoiceModel.h
  */
 #ifndef AI_VOICE_MODEL_H
@@ -27,6 +27,14 @@ namespace OHOS
     class AiVoiceModel
     {
     public:
+        enum aiResponseType :uint8_t {
+                AI_RECORDING_PARSING_ERROR = 0, //AI录音解析错误
+                AI_RECORDING_PARSING_CONTENT, //AI录音解析内容
+                AI_RESPONSE_CONTENT, //AI回应内容
+                AI_RESPONSE_ERROR,//AI 回应错误
+                AI_RESPONSE_END,//AI 回应结束
+        };
+
         static AiVoiceModel &GetInstance(void); // 获取单例实例
         bool ChangeToReturnResultTextView(void);
         bool ChangeToAIVoiceListeningView(bool value);
@@ -107,6 +115,7 @@ namespace OHOS
         bool entryTextViewState{false};                                      // 进入返回结果界面的标志
         std::map<int, std::pair<int, int>> selectAiModelToTextId;            // pair的参数类型<模型的textid,查询模型是否可用id>
         bool AiVoiceConnectStatus{false};                                    //与AI模型的连接状态
+        uint8_t AIResponseType;
     };
 
 }
index 9bcf224..c457ba9 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 15:14:50
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-21 11:35:44
+ * @LastEditTime: 2024-08-28 17:46:07
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoiceModel.cpp
  */
 #include "aivoice/include/AiVoiceModel.h"
@@ -450,6 +450,7 @@ namespace OHOS
     void AiVoiceModel::SetAiAnswerStrStr(std::string str, uint8_t type)
     {
         aiAnswerStr += str;
+        AIResponseType = type;
         SendMsgToUIService(UI_UPDATE_AI_ANSWER_STR, 0, nullptr, 0);
     }
 
index 6f09ea7..db8e848 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-06-20 15:11:17
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-15 18:53:14
+ * @LastEditTime: 2024-08-28 17:46:50
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/aivoice/src/AiVoicePresenter.cpp
  */
 #include "AppViewIDs.h"
@@ -430,6 +430,7 @@ namespace OHOS
         if (keyID == static_cast<uint16_t>(ZliteKeyCode::ZLITE_KEY_POWER) && keyState == 1 && uapi_get_screen_state() == 0)
         {
             NativeAbility::GetInstance().Back(TransitionType::TRANSITION_BACK_TO_HEXAGONS);
+            AiVoiceModel::GetInstance().CancelCurAIChat();
         }
         return true;
     }
index 46d504d..2343c9d 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: luozheng 1732036298@qq.com
  * @Date: 2024-05-07 11:25:58
  * @LastEditors: luozheng 1732036298@qq.com
- * @LastEditTime: 2024-08-21 11:43:04
+ * @LastEditTime: 2024-08-28 17:47:15
  * @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/AiVoice/src/AiVoiceView.cpp
  */
 #include "aivoice/include/AiVoicePresenter.h"
@@ -513,10 +513,7 @@ namespace OHOS
         {
             container_->Add(AiVoiceScrollView[thisView]);
         }
-        if (AiVoiceModel::GetInstance().GetAiVoiceConnectStatus())
-        {
-            AiVoiceModel::GetInstance().CancelCurAIChat();
-        }
+        AiVoiceModel::GetInstance().CancelCurAIChat();
         return true;
     }