Browse Source

上传代码补充

weicu
liwei1dao 1 year ago
parent
commit
e83dcfb63f
  1. 84
      lib/modules/agent/views/message_bubble.dart
  2. 19
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt

84
lib/modules/agent/views/message_bubble.dart

@ -56,34 +56,33 @@ class MessageBubble extends GetView<AgentController> {
crossAxisAlignment: crossAxisAlignment:
isUser ? CrossAxisAlignment.end : CrossAxisAlignment.start, isUser ? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: [ children: [
Container( Stack(
padding: (hasImage && message == '[图片]') children: [
? EdgeInsets.zero Container(
: const EdgeInsets.all(12), padding: (hasImage && message == '[图片]')
decoration: BoxDecoration( ? EdgeInsets.zero
color: _getBubbleColor(context), : const EdgeInsets.all(12),
borderRadius: BorderRadius.only( decoration: BoxDecoration(
topLeft: isUser color: _getBubbleColor(context),
? const Radius.circular(18) borderRadius: BorderRadius.only(
: const Radius.circular(4), topLeft: isUser
topRight: isUser ? const Radius.circular(18)
? const Radius.circular(4) : const Radius.circular(4),
: const Radius.circular(18), topRight: isUser
bottomLeft: const Radius.circular(18), ? const Radius.circular(4)
bottomRight: const Radius.circular(18), : const Radius.circular(18),
), bottomLeft: const Radius.circular(18),
boxShadow: [ bottomRight: const Radius.circular(18),
BoxShadow( ),
color: Colors.black.withOpacity(0.05), boxShadow: [
blurRadius: 2, BoxShadow(
offset: const Offset(0, 1), color: Colors.black.withOpacity(0.05),
blurRadius: 2,
offset: const Offset(0, 1),
),
],
), ),
], child: Padding(
),
child: Stack(
children: [
// 主要消息内容
Padding(
padding: (!isUser && padding: (!isUser &&
functionCalls != null && functionCalls != null &&
functionCalls!.isNotEmpty) functionCalls!.isNotEmpty)
@ -91,14 +90,15 @@ class MessageBubble extends GetView<AgentController> {
: EdgeInsets.zero, : EdgeInsets.zero,
child: _buildMessageContent(context), child: _buildMessageContent(context),
), ),
//工具调用流程显示(仅在AI消息且有functionCalls时显示) ),
if (!isUser && //工具调用流程显示(仅在AI消息且有functionCalls时显示)
functionCalls != null && if (!isUser &&
functionCalls!.isNotEmpty) functionCalls != null &&
_buildFunctionCallsWidget(context), functionCalls!.isNotEmpty)
], _buildFunctionCallsWidget(context),
), ],
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
// 识别中的消息不显示时间 // 识别中的消息不显示时间
if (!isRecognizing) if (!isRecognizing)
@ -621,12 +621,17 @@ class MessageBubble extends GetView<AgentController> {
); );
}, },
child: Container( child: Container(
height: 20, // 增加固定高度,给字体更多空间 height: 30, // 增加固定高度,给字体更多空间
padding: EdgeInsets.all(8),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[800]?.withOpacity(0.8) ? const Color.fromARGB(255, 71, 68, 68)
?.withOpacity(0.8)
: Colors.grey[100]?.withOpacity(0.9), : Colors.grey[100]?.withOpacity(0.9),
borderRadius: BorderRadius.circular(6), borderRadius: const BorderRadius.only(
topLeft: Radius.circular(6),
topRight: Radius.circular(6),
),
border: Border.all( border: Border.all(
color: Theme.of(context).brightness == Brightness.dark color: Theme.of(context).brightness == Brightness.dark
? Colors.white.withOpacity(0.1) ? Colors.white.withOpacity(0.1)
@ -682,7 +687,10 @@ class MessageBubble extends GetView<AgentController> {
color: Theme.of(context).brightness == Brightness.dark color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[900]?.withOpacity(0.95) // 深色模式下使用深灰色背景 ? Colors.grey[900]?.withOpacity(0.95) // 深色模式下使用深灰色背景
: Colors.white.withOpacity(0.95), // 浅色模式下使用白色背景 : Colors.white.withOpacity(0.95), // 浅色模式下使用白色背景
borderRadius: BorderRadius.circular(4), // 减小圆角 borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(6),
bottomRight: Radius.circular(6),
),
border: Border.all( border: Border.all(
color: Theme.of(context).brightness == Brightness.dark color: Theme.of(context).brightness == Brightness.dark
? Colors.white.withOpacity(0.2) ? Colors.white.withOpacity(0.2)

19
local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt

@ -209,11 +209,12 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
try { try {
azureAsrHelper.setupEventListeners(object : azureAsrHelper.setupEventListeners(object :
AzureAsrHelper.ContinuousRecognizeCallback { AzureAsrHelper.ContinuousRecognizeCallback {
override fun onResult(text: String, detectedLanguage: String) { override fun onResult(sessionid:String,text: String, detectedLanguage: String) {
sendAsrEvent( sendAsrEvent(
mapOf( mapOf(
"type" to "result", "type" to "result",
"sessionid" to sessionid,
"text" to text, "text" to text,
"detectedLanguage" to detectedLanguage "detectedLanguage" to detectedLanguage
) )
@ -222,6 +223,7 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
} }
override fun onRecognizing( override fun onRecognizing(
sessionid:String,
recognizing: String, recognizing: String,
detectedLanguage: String detectedLanguage: String
) { ) {
@ -229,26 +231,28 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
sendAsrEvent( sendAsrEvent(
mapOf( mapOf(
"type" to "recognizing", "type" to "recognizing",
"sessionid" to sessionid,
"text" to recognizing, "text" to recognizing,
"detectedLanguage" to detectedLanguage "detectedLanguage" to detectedLanguage
) )
) )
} }
override fun onSessionStarted() { override fun onSessionStarted(sessionid:String) {
sendAsrEvent(mapOf("type" to "sessionStarted")) sendAsrEvent(mapOf("type" to "sessionStarted","sessionid" to sessionid,))
} }
override fun onSessionStopped() { override fun onSessionStopped(sessionid:String) {
sendAsrEvent(mapOf("type" to "sessionStopped")) sendAsrEvent(mapOf("type" to "sessionStopped","sessionid" to sessionid,))
} }
override fun onCanceled(reason: String, errorDetails: String) { override fun onCanceled(sessionid:String,reason: String, errorDetails: String) {
sendAsrEvent( sendAsrEvent(
mapOf( mapOf(
"type" to "canceled", "type" to "canceled",
"sessionid" to sessionid,
"reason" to reason, "reason" to reason,
"errorDetails" to errorDetails "errorDetails" to errorDetails
) )
@ -257,10 +261,11 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
} }
override fun onError(code: Int, error: String) { override fun onError(sessionid:String,code: Int, error: String) {
sendAsrEvent( sendAsrEvent(
mapOf( mapOf(
"type" to "error", "type" to "error",
"sessionid" to sessionid,
"code" to code, "code" to code,
"message" to error "message" to error
) )

Loading…
Cancel
Save