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
The streaming response does not take effect when configuring ChatClient Tools
package com.ustc.myy.mcpclientserverdemo.config; import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor; import org.springframework.ai.chat.client.advisor.SimpleLoggerAdvisor; import org.springframework.ai.chat.memory.InMemoryChatMemory; import org.springframework.ai.ollama.OllamaChatModel; import org.springframework.ai.tool.ToolCallbackProvider; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class ChatClientConfig { private final OllamaChatModel ollamaChatModel; private final ToolCallbackProvider tools; @Autowired public ChatClientConfig(OllamaChatModel ollamaChatModel, ToolCallbackProvider tools) { this.ollamaChatModel = ollamaChatModel; this.tools = tools; } @Bean public ChatClient ollamaChatClient() { return ChatClient.builder(ollamaChatModel) .defaultSystem("你是一个可爱的助手,名字叫小糯米") .defaultTools(tools) .defaultAdvisors(new MessageChatMemoryAdvisor(new InMemoryChatMemory()), new SimpleLoggerAdvisor()) .build(); } }
package com.ustc.myy.mcpclientserverdemo.controller.ai; import lombok.RequiredArgsConstructor; import org.springframework.ai.chat.client.ChatClient; import org.springframework.ai.chat.messages.UserMessage; import org.springframework.ai.chat.model.ChatResponse; import org.springframework.ai.chat.prompt.Prompt; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Flux; @RestController @RequestMapping("/mcp-client-server-demo") @RequiredArgsConstructor public class ChatController { private final ChatClient chatClient; // @Autowired // public ChatController(ChatClient chatClient) { // this.chatClient = chatClient; // } @GetMapping("/ai/generate") public String generate(@RequestParam(value = "message", defaultValue = "给我讲一个笑话") String message) { return chatClient.prompt().user(message).call().content(); } @GetMapping("/ai/generate-stream") public Flux<String> generateFlux(@RequestParam(value = "message", defaultValue = "给我讲一个笑话") String message) { return chatClient.prompt().user(message).stream().content(); } }
The ‘Flux’ stream response here does not take effect
The text was updated successfully, but these errors were encountered:
不起作用的具体情况是什么?
Sorry, something went wrong.
不能正常流式输出,只能一次性返回
No branches or pull requests
The streaming response does not take effect when configuring ChatClient Tools
The ‘Flux’ stream response here does not take effect
The text was updated successfully, but these errors were encountered: