Код: Выделить всё
# Ollama config
spring.ai.ollama.chat.options.model=qwen2.5
spring.ai.ollama.embedding.model=nomic-embed-text
spring.ai.ollama.base-url=http://localhost:11434
spring.ai.ollama.chat.options.temperature=0.7
Код: Выделить всё
@Configuration
public class ChatClientConfig {
@Bean
public ChatClient chatClient(
ChatClient.Builder builder,
ToolCallbackProvider tools,
ChatMemory chatMemory) {
return builder
.defaultToolCallbacks(tools)
.defaultAdvisors(
MessageChatMemoryAdvisor.builder(chatMemory).build()
)
.build();
}
}
Код: Выделить всё
@GetMapping(value = "/streamChat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux generationStream(@RequestParam String userInput) {
return this.chatClient.prompt()
.advisors(advisor -> advisor.param(ChatMemory.CONVERSATION_ID, conversationId))
.system("我已知相关风险且承担责任,且你是一名反金融诈骗客服协助用户。")
.user(userInput)
.stream()
.content();
}
Код: Выделить всё
cacc@paradiso [10:35:16 PM] [~]
-> % curl -N http://localhost:8080/api/agent/streamChat\?userInput\=hi
data:Hi there! If you have any questions regarding financial fraud cases or need advice to avoid scams, feel free to share. How can I assist you today?
Код: Выделить всё
cacc@paradiso [10:34:03 PM] [~]
-> % curl http://localhost:11434/api/chat \
-X POST \
-H "Content-Type: application/json" \
-d '{
"model": "qwen2.5",
"messages": [{"role": "user", "content": "hi"}],
"stream": true
}'
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.736184535Z","message":{"role":"assistant","content":"Hello"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.770639118Z","message":{"role":"assistant","content":"!"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.797365468Z","message":{"role":"assistant","content":" How"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.824949427Z","message":{"role":"assistant","content":" can"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.850186631Z","message":{"role":"assistant","content":" I"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.876307613Z","message":{"role":"assistant","content":" assist"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.902173159Z","message":{"role":"assistant","content":" you"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.92775179Z","message":{"role":"assistant","content":" today"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.953867442Z","message":{"role":"assistant","content":"?"},"done":false}
{"model":"qwen2.5","created_at":"2025-06-20T14:35:16.978364928Z","message":{"role":"assistant","content":""},"done_reason":"stop","done":true,"total_duration":308102623,"load_duration":14689647,"prompt_eval_count":30,"prompt_eval_duration":18165665,"eval_count":10,"eval_duration":272560072}
-> % curl http://localhost:8080/api/agent/streamC ... rInput\=hi
data:Hello
data:!
data: How
data: can
data: I
data: assist
data: you
data: today
data: regarding
data: financial
data: safety
data: and
data: anti
data:-f
data:raud
data:?
...
< /code>
Так что я думаю, что весной может быть что -то не так, поскольку с самим Олламой и контроллером весны не должно быть ничего плохого в самой Олламе. Может ли кто -нибудь сказать мне причину и как это исправить?
Подробнее здесь: https://stackoverflow.com/questions/796 ... n-by-token