Blossoming Intelligence: How to Run Spring AI Locally with Ollama
In this short article, we'll look at how easy it is to create a chat bot backend powered by Spring and Olama using the llama 3 model.
Sat, 11th May 2024
Read MoreReact 19: The long-expected features
React 19 introduces a number of new features that will undoubtedly make the life of react developers simpler. While the release is not yet stable, you can test out the new features using the canary version.
Wed, 17th April 2024
Read MoreIn certain scenarios, we need to retrieve large volumes of data, yet we often experience delays before the first pieces of the response are displayed. Fortunately, this is a well-known problem, and an effective solution exists.
This project is built using:
Simply, we need 1 million products (json objects) in the GET endpoint.
this is a simple SQL script to create and fill the products table:
Next the entity and JPA repository:
Nothing fancy for our traditional endpoint, a simple find all GET:
While using this endpoint, the client needs to wait before exploiting the first returned product, or even worse, the response size is too big to be handled properly:
Using StreamingResponseBody, we can stream our products one by one and save some time :)
You may already noticed that we loop over the products and write one by one to the output stream, this can be improved even more by streaming data end-2-end from the data source to the client; For that purpose solutions like Spring Webflux and JPA streams exist.
Stream<T>