opt
This commit is contained in:
parent
45537ab339
commit
73ebf1fb66
@ -64,7 +64,10 @@ public class AnythingLLMServiceImpl implements LLMService {
|
|||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
writer.writeLine(line); // 已是 SSE 格式
|
if (line.startsWith("data:")) {
|
||||||
|
line = line.substring(5).trim();
|
||||||
|
}
|
||||||
|
writer.writeJsonLine(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,4 +19,9 @@ public class SseOutputAdapter implements WriterAdapter {
|
|||||||
emitter.send(SseEmitter.event().data(line));
|
emitter.send(SseEmitter.event().data(line));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeJsonLine(String json) throws IOException {
|
||||||
|
emitter.send(SseEmitter.event().data(json));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,5 +4,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
public interface WriterAdapter {
|
public interface WriterAdapter {
|
||||||
void writeLine(String line) throws IOException;
|
void writeLine(String line) throws IOException;
|
||||||
|
|
||||||
|
void writeJsonLine(String line) throws IOException ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user