|
|
|
@ -572,7 +572,7 @@ object AgentService : CoroutineScope { |
|
|
|
/** |
|
|
|
* 停止AI流输出 |
|
|
|
*/ |
|
|
|
private fun stopAiStream() { |
|
|
|
fun stopAiStream() { |
|
|
|
if (isAiStreaming) { |
|
|
|
try { |
|
|
|
// 先更新状态,避免回调时的状态不一致 |
|
|
|
@ -581,7 +581,8 @@ object AgentService : CoroutineScope { |
|
|
|
// 取消当前AI生成任务 |
|
|
|
currentAiJob?.cancel() |
|
|
|
currentAiJob = null |
|
|
|
|
|
|
|
currsessionId = "" //取消会话 |
|
|
|
|
|
|
|
// 通知ChatAPI服务终止当前流式请求 |
|
|
|
chatApiService.cancelCurrentStream() |
|
|
|
|
|
|
|
@ -757,9 +758,6 @@ object AgentService : CoroutineScope { |
|
|
|
responseBuilder.append(token) |
|
|
|
if (speakResponse && broadcast) { |
|
|
|
ttsService?.speakStream(token) |
|
|
|
if (token.length > 0) { |
|
|
|
audioPlayer?.stopAudio() |
|
|
|
} |
|
|
|
} |
|
|
|
if (broadcast) { |
|
|
|
// 发送流式回复token |
|
|
|
@ -775,6 +773,7 @@ object AgentService : CoroutineScope { |
|
|
|
// 视情况决定是否朗读回复 |
|
|
|
if (speakResponse && broadcast && sessionid == currsessionId){ |
|
|
|
ttsService?.flushStream() |
|
|
|
audioPlayer?.stopAudio() |
|
|
|
} |
|
|
|
val response = responseBuilder.toString() |
|
|
|
// 发送完整回复,包含是否有图片的标记 |
|
|
|
|