Hi everybody. I'm opening an issue here because I'm using reactor.core.publisher.Flux in my code and the package name brought me here. If I'm not mistaken, your software is used in Spring Boot to implement reactive programming.
I came to Flux<String> while reading "Spring AI in Action", that guided me through building my own AI chat bot with ollama. I decided to implement something I use often, i.e. translating text from one language to another.
My code is very simple:
@Service
class TranslationService(builder: ChatClient.Builder) {
private val chatClient: ChatClient = builder.build()
fun translateStream(message: String, from: String, to: String): Flux<String> {
return chatClient.prompt().system(getTemplate(from, to)).user(message).stream().content()
}
}
I have a REST controller that exposes this service. Then I built a frontend for this by creating a super simple HTML page with an input field and a submit button that uses an EventSource to query my endpoint. At this point I've spent hours trying to understand why my frontend was not receiving whitespaces. I tested my backend with curl and httpie, and they showed:
This is because the space after the colon is ignored if present.
I've suddenly realized that the problem was the missing space after the colon. There should be always one, and when a chunk starts with a space, there should be two. In my example, Spring Boot should return a double space and not one, i.e. data: frase.
I'm opening this issue to ask for guidance. Who should I forward this issue to? Is this project responsible for how Flux is emitting that data:?
My code is here. I'm not pointing you to any particular commit hash cause I'm overwriting the history to make it more readable. The commit should be named feat: chapter 2 though.
Hi everybody. I'm opening an issue here because I'm using
reactor.core.publisher.Flux
in my code and the package name brought me here. If I'm not mistaken, your software is used in Spring Boot to implement reactive programming.I came to
Flux<String>
while reading "Spring AI in Action", that guided me through building my own AI chat bot with ollama. I decided to implement something I use often, i.e. translating text from one language to another.My code is very simple:
I have a REST controller that exposes this service. Then I built a frontend for this by creating a super simple HTML page with an input field and a submit button that uses an
EventSource
to query my endpoint. At this point I've spent hours trying to understand why my frontend was not receiving whitespaces. I tested my backend with curl and httpie, and they showed:while my frontend was receiving (open Developer Tools, Network tab, click on the request, and then click on the "Response" or "Event Stream" tab):
After hours I stumbled upon 9.2.6 Interpreting an event stream where the last example ends with:
I've suddenly realized that the problem was the missing space after the colon. There should be always one, and when a chunk starts with a space, there should be two. In my example, Spring Boot should return a double space and not one, i.e.
data: frase
.I'm opening this issue to ask for guidance. Who should I forward this issue to? Is this project responsible for how
Flux
is emitting thatdata:
?My code is here. I'm not pointing you to any particular commit hash cause I'm overwriting the history to make it more readable. The commit should be named
feat: chapter 2
though.Thank you for your attention.