spring-projects / spring-projects/spring-ai
ollama+mcp不能流返回
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
1、配置文件
spring:
ai:
openai:
base-url: http://192.168.1.123:11434
chat:
options:
model: qwen2.5:7b-instruct-fp16
stream-usage: true
mcp:
client:
type: async
sse:
connections:
mcp-server-chart:
url: http://localhost:1122/
2、代码
@Primary
@Bean
public ChatClient chatClient(ChatClient.Builder builder, ChatMemory chatMemory, ToolCallbackProvider tools) {
return builder.defaultSystem("""
你是一个智能人工助手
""")
.defaultAdvisors(
MessageChatMemoryAdvisor.builder(chatMemory).build(),
new SimpleLoggerAdvisor(
ModelOptionsUtils::toJsonStringPrettyPrinter,
ModelOptionsUtils::toJsonStringPrettyPrinter,
0
)
)
.defaultToolCallbacks(tools)
.build();
}
如果注释调.defaultToolCallbacks(tools) 这个。 就可以流返回。 如果加上后。AI回复的结果就变成了一次全返回
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ChatClient bean in the issue, comparing the streaming behavior with and without .defaultToolCallbacks(tools). Reproduce the configuration using Ollama and the MCP SSE connection; done means AI responses remain incrementally streamed while MCP tools are enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100