Skip to main content

Posts

Spring AI: Hello Spring AI

What Is Spring AI? Creating the Project Configuring OpenAI Understanding ChatModel Understanding ChatClient Creating a ChatClient Basic Conversation with ChatClient Running the Application Summary AI has rapidly become a standard capability in modern applications. Whether you are building chatbots, intelligent business workflows, or AI powered assistants, Large Language Models (LLMs) can significantly enhance your applications. Until recently, Python has been the primary language for building AI applications. However, a new era has arrived for Java developers. With Spring AI, Java developers can now build AI powered applications using the familiar Spring programming model. What Is Spring AI? Building AI applications involves several challenges, such as interacting with AI providers, constructing prompts, managing conversations, parsing responses, and orchestrating AI workflows. Spring AI addresses these challenges by providing the familiar Spring programming model for AI...

Understanding LLM Applications with OpenAI Without Frameworks

Greetings! Calling an LLM Understanding Tokens and Next Token Prediction Controlling the Response with Inference Parameters Temperature Top P Maximum Output Tokens LLM Responses Are Not Guaranteed Facts Getting Structured Responses Messages and Roles Chat Conversations Conversation Memory Context Windows The LLM Does Not Know Our Data External Knowledge with RAG Accessing Live Data with Tools Combining Memory, RAG, and Tools Are We Building an Agent? Why Do We Need AI Frameworks? Summary Large Language Models (LLMs) have changed the way we build applications. Today, we can build chatbots, intelligent workflows, AI assistants, and even AI agents. There are many frameworks available to build LLM powered applications like Spring AI, Langchain. However, before jumping into a framework, it is important to understand what happens underneath. In this article, we will explore the main concepts behind LLM applications by directly interacting with OpenAI APIs. Calling an ...

Enrich Search Results with Personalized Sorting in Elasticsearch

Greetings! Personalization is a key e-commerce feature for enhancing user experience and driving sales. One aspect of this is improving search results through recommendations, helping to surface more buyable products for the customer. Business opportunities Boost sales by sorting search results based on customer recommendations. Technical opportunity A business opportunity often comes with fascinating technical challenges. While Elasticsearch makes sorting easier, this doesn’t seem like something we can achieve with standard sorting alone (but we can). Sort by script Elasticsearch offers multiple search options, including custom scripts that allow us to define our own sorting logic. "sort": { "_script": { "type": "number", "script": { "lang": "painless", "inline": "doc[ 'field_name' ].value * params.factor", "params": { "f...

Implementing Faceted Search and Dynamic Filtering in Elasticsearch

Greetings! Faceting is a widely used concept in search and data filtering across various technologies and domains. It is commonly applied in e-commerce, healthcare, travel, and many other fields to enhance user experience. Most databases support faceting (filtering) for this purpose. In this article, I will focus on developing a facet search using Elasticsearch with movie data. Elasticsearch Aggregation Elasticsearch offers a powerful aggregation feature that enables querying and analyzing data efficiently. With a single query, you can retrieve both filters and search results, allowing for complex analyses and meaningful insights. Terms Aggregation This is used to group documents based on unique values of a specified field. { "aggs": { "genres": { "terms": { "field": "genre", "size": 100 } } } } Range Aggregation This groups documents into predefined numerical or date ranges. It is usefu...