qiyu-lu opened a new issue, #4108:
URL: https://github.com/apache/rocketmq-dashboard/issues/4108

   ## 问题
   
   AI 助手使用 HTTP 引擎接收 OpenAI-compatible SSE 响应时,如果模型把空格、换行或缩进单独放在一个 
`choices[0].delta.content` 片段中,后端会丢弃该片段,导致单词粘连、Markdown 
换行和代码缩进丢失。同样的内容是否出错取决于上游如何分片。
   
   ## 环境与复现
   
   - 分支:`rocketmq-studio`,基线提交:`d6dee7d7ccfcf4886f02466ec51452a6928b2cc8`。
   - 后端 Java 21;AI 设置中启用 HTTP 引擎,配置可用的 OpenAI-compatible API 地址、模型及所需凭据。
   
   1. 在 AI 助手中要求模型输出包含空行、列表或缩进代码块的 Markdown。
   2. 当上游返回独立的纯空白 content 片段时,页面输出会缺失对应的空白。真实模型的分片方式不固定,因此不是每次请求都会触发。
   3. 可在 `OpenAiCompatibleLlmClient.emitStreamEvent` 的 content 判断处设置条件断点 `token 
!= null && !token.isEmpty() && token.isBlank()`,观察片段没有传递给下游。
   
   不依赖真实模型的最小示例:依次用 SSE `data:` 事件发送以下 content 片段(例如空格事件为 `data: 
{"choices":[{"delta":{"content":" "}}]}`),最后发送 `[DONE]`:
   
   ```json
   ["hello", " ", "world", "\n", "    ", "next"]
   ```
   
   预期拼接结果为 `"hello world\n    next"`,实际为 `"helloworldnext"`。
   
   ## 原因与预期行为
   
   `OpenAiCompatibleLlmClient.emitStreamEvent` 使用 
`StringUtils.hasText(token)`,错误地过滤了合法的纯空白 
content。`OpenAiCompatibleLlmGateway.emitEnhanceChunk` 也使用相同判断,提示词增强预览存在同类问题。
   
   应保留所有非空 content/chunk,包括空格、LF、CRLF、Tab、连续空格和空行;仍然忽略 null、空字符串和没有 content 
的元数据事件,并保持 `[DONE]` 与错误事件行为不变。
   
   计划用一个小范围 PR 修复这两处判断,并增加客户端 SSE 与增强预览回归测试。
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to