-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
为什么不支持sse流式输出? #43
Comments
你鼠标往后拉拉,数据应该在一行里面吧。你可以使用getCurrStr,只打印当前content中的内容。 |
this.getCurrData() + '\n'即可 |
你也可以将返回对象修改为SseEmitter : @GetMapping("/chatStream2")
public SseEmitter getChatMessageStream(@RequestParam String question) {
SseEmitter emitter = new SseEmitter();
// 获取聊天服务
IChatService chatService = aiService.getChatService(PlatformType.DEEPSEEK);
// 创建请求参数
ChatCompletion chatCompletion = ChatCompletion.builder()
.model("deepseek-chat")
.message(ChatMessage.withUser(question))
.build();
Executors.newSingleThreadExecutor().submit(() -> {
try {
SseListener sseListener = new SseListener() {
@Override
protected void send() {
try {
emitter.send(this.getCurrData());
System.out.println(this.getCurrData()); // 打印当前发送的内容
} catch (IOException e) {
emitter.completeWithError(e);
}
}
};
// 发送流式数据
chatService.chatCompletionStream(chatCompletion, sseListener);
// 完成后关闭连接
emitter.complete();
} catch (Exception e) {
emitter.completeWithError(e);
}
});
return emitter;
} |
|
哦好了,我用key调了真实的DeepSeek可以,调用本地ollama部署的小的1.5b的版本就不行,不知道是为什么。。。 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The text was updated successfully, but these errors were encountered: