This commit is contained in:
luke 2025-06-23 16:16:53 +08:00
parent 45537ab339
commit 73ebf1fb66
3 changed files with 11 additions and 1 deletions

View File

@ -64,7 +64,10 @@ public class AnythingLLMServiceImpl implements LLMService {
String line;
while ((line = reader.readLine()) != null) {
writer.writeLine(line); // 已是 SSE 格式
if (line.startsWith("data:")) {
line = line.substring(5).trim();
}
writer.writeJsonLine(line);
}
}
}

View File

@ -19,4 +19,9 @@ public class SseOutputAdapter implements WriterAdapter {
emitter.send(SseEmitter.event().data(line));
}
}
@Override
public void writeJsonLine(String json) throws IOException {
emitter.send(SseEmitter.event().data(json));
}
}

View File

@ -4,5 +4,7 @@ import java.io.IOException;
public interface WriterAdapter {
void writeLine(String line) throws IOException;
void writeJsonLine(String line) throws IOException ;
}