We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
使用的依赖ai4j-spring-boot-starter,版本1.2.1
配置如下 ai: ollama: api-host: http://localhost:11434/
ai: ollama: api-host: http://localhost:11434/
代码如下:
`@GetMapping(value = "/ai/chatstream")
public ResponseBodyEmitter generateStreamAsString2(@RequestParam(value = "message") String message) throws Exception { // 中文乱码问题 response.setCharacterEncoding("UTF-8"); // 构造请求参数 IChatService chatService = aiService.getChatService(PlatformType.OLLAMA); ChatCompletion chatCompletion = ChatCompletion.builder() .model("deepseek-r1:8b") .message(ChatMessage.withUser(message)) .build(); ResponseBodyEmitter emitter = new ResponseBodyEmitter(); Executors.newSingleThreadExecutor().submit(() -> { try { SseListener sseListener = new SseListener() { @Override protected void send() { try { emitter.send(this.getCurrStr()); System.out.println(this.getCurrStr()); // 打印当前发送的内容 } catch (IOException e) { emitter.completeWithError(e); } } }; // 发送流式数据 chatService.chatCompletionStream(chatCompletion, sseListener); // 完成后关闭连接 emitter.complete(); } catch (Exception e) { emitter.completeWithError(e); } }); return emitter; }`
The text was updated successfully, but these errors were encountered:
已修复,请进行测试
Sorry, something went wrong.
No branches or pull requests
使用的依赖ai4j-spring-boot-starter,版本1.2.1
配置如下
ai: ollama: api-host: http://localhost:11434/
代码如下:
The text was updated successfully, but these errors were encountered: