Spring AI Custom CallAdvisor & StreamAdvisor Example
Spring AI CallAdvisor and StreamAdvisor provide hooks to wrap around LLM invocations, both for synchronous and streaming scenarios.
Spring AI CallAdvisor and StreamAdvisor provide hooks to wrap around LLM invocations, both for synchronous and streaming scenarios.
The error “java.lang.IllegalArgumentException: Failed to create folder” in Selenide typically happens when Selenide tries to save screenshots, page sources, or logs, but it cannot create the required directories due to permission issues or incorrect paths.
In-browser UI testing of Angular applications poses several challenges such as asynchronous operations and unpredictable loading screens with spinners or dimmers.
Selenide has an implicit capability to wait for the loading screen to disappear.
When InnoDB tables become corrupted, the InnoDB storage engine typically crashes the MySQL server to prevent further damage. In such situations, you can use the innodb_force_recovery option to force the server to start despite the corruption. However, you may face a situation where the innodb_force_recovery fails to start the server. …
The jpackage is a command-line tool introduced in Java 14 and helps create native installable packages (.exe, .msi, .dmg, .pkg, .deb, .rpm) for Windows, macOS, and Linux. Jpackage bundles Java applications along with a Java runtime (JRE) image, ensuring that end users do not need to install Java separately.
Database integrity refers to the accuracy, consistency, and reliability of the data stored within a database. It ensures that data remains uncorrupted, and adheres to defined rules. In SQL databases, integrity is supported through constraints like primary keys, foreign keys, unique constraints, and check constraints, alongside physical and logical data …
In TypeScript, an array of objects is a collection of items where each item is an object. Arrays of objects are commonly used to organize complex data structures, such as user information, products, or any other entity, into manageable collections.
In TypeScript, an array of vectors is a collection of vectors, where each vector can represent an array of numbers or custom objects. This multi-dimensional array structure is handy in scenarios such as mathematical computations, graphics programming, or handling grouped data in a type-safe and organized manner.
OpenHTMLToPDF library generates PDF from HTML and CSS content taken from templates such as HTML file, Freemarker and Thymeleaf templates.
Since version 3.4, Spring Boot will provide native support for structured logging in the most common and popular formats, such as JSON and XML.
Creating REST APIs is a better approach for building one-time token-based authentication combined with Jwt tokens in Spring Security.
Python provides several ways to read a text file and process its lines sequentially or randomly. The correct method to use depends on the size of the file (large or small) and the ease of desired syntax. In this Python tutorial, we will discuss different approaches based on their clean …
In Hibernate, an orphan entity refers to a child entity that has been disassociated from its parent. If these orphan entities are not explicitly removed, they remain in the database and result in unwanted data. The orphanRemoval = true attribute on the mapping annotation on parent entity automatically removes the …
One of the most essential concepts in Hibernate is working with parent-child entity relationships, where a parent entity contains references to one or more child entities. To ensure that we are saving/updating the child entities (along with the parent entity), we depend on the correct usage of annotations like @OneToOne, …
This short Logback tutorial lists examples for configuring logback.xml to log messages to both the console and/or file appenders. 1. Logback Dependencies To include Logback, include the latest version of logback-classic dependency, which transitively includes all the necessary dependencies, including SLF4J. Spring Boot comes with SLF4J and Logback as the …
The Hibernate Search module works as a bridge between Hibernate ORM and full-text search engines such as Lucene or Elasticsearch. While performing a search, it enables us to work with JPA entities, and in the background, it transparently works with Lucene to provide a consistent experience. This Hibernate search guide …
1. Problem When writing tests that depend on H2 database in a Spring boot application, we may encounter the CommandAcceptanceException: Error executing DDL. The root cause exception will be org.h2.jdbc.JdbcSQLSyntaxErrorException in the logs. The exception stack trace will look something like this: If you are trying to run unit tests …
Learn to configure log4j2.yaml file to output the log statements to the console, rolling files, etc. Also, learn to configure log4j2 appenders, levels, and patterns.
Learn to make HTTP GET requests (sync and async) using Spring Boot WebClient, pass URI and query params, handle responses, and handle errors.
As a best practice in Java, POJO classes or Data objects always declare the fields private and expose their access through the getter methods. On rare occasions, we may encounter situations when the member fields are private, and the class does not provide the public accessor methods. For example, the …
In Spring Security, a One-Time Token (OTT) is a server-side generated string that can be used only once for user login authentication purpose.
Learn to configure Postgres PgVectorStore to store the vectors generated with OpenAI and Ollama embedding models in a Spring AI project.
Learn to build a fully-functional chatbot application (with UI) with RAG (Retrieval-Augmented Generation) capabilities using Spring AI and Spring Web.
In Spring AI, function calling is the ability for the model to request one or more function calls to be made on its behalf by the ChatBot application.
Learn to download, install, and run an LLM model using Ollama. Also learn to configure Spring AI Ollama module to access the model’s chat API.
Inspired by LangChain4j and LlamaIndex, Spring AI project aims to streamline the development and integration of AI capabilities into existing or new Spring applications.
LLMs are quite good at producing the source code when they are provided enough context information and asked very clear questions. The same is true for generating SQL queries when they are provided the table/column information through DDL statements, and clear instructions of output format of the generated SQL statements. …
For creating an ETL pipeline for Spring AI data ingestion microservice, Spring cloud functions are an excellent choice for serverless providers.
The ETL pipeline ingest raw data sources (text, JSON/XML, audio, video, etc.) to a structured vector store for similarity searches using Spring AI.
In Spring AI, the role of a vector database is to store vector embeddings and facilitate similarity searches for these embeddings. Learn with examples.
In Spring AI Vector Embedding tutorial, learn what is a vector or embedding, how it helps in semantic searches, and how to generate embeddings using OpenAI.
Spring AI currently supports only OpenAI’s whisper model for speech transcription to JSON or TEXT files using OpenAiAudioTranscriptionModel class.
In Spring AI, SpeechModel and StreamingSpeechModel interfaces allow to interact with Text-to-Speech APIs of supported LLMs such as tts-1 by OpenAI.
In Spring AI PromptTemplate example, learn different message roles and how they are used to create prompts and send them to the AI models.
Learn to create an immutable or unmodifiable Map using the factory methods added in Java 9 and other versions (Java 8 to Java 21) with examples.
In Java, we can serialize an object to String in different ways such as converting to byte[] and thenBase64 encoded string, XML or JSON. Learn with examples.
Learn to read or write the records in a JSON file using Spring Batch JsonItemReader and JsonFileItemWriter implementations.
Learn to read and write XML files using StaxEventItemReader and StaxEventItemWriter classes in a Spring Batch application.
Learn to read all the rows from an Excel (.xls or .xlsx) file using Spring Batch and save them in a database in a Spring Boot application.
In LangChain4j, the AiServices helps in working with strongly typed objects and tasks such as extracting and parsing the structured output in JSON or XML format.
Added in Java 21, the Executors.newVirtualThreadPerTaskExecutor() method returns an Executor that creates a new virtual thread for each task submitted to it.
This Spring Boot tutorial aims at Langchain4j Chat APIs to get started with and run a few examples to give you a high-level understanding.
In Lucene, ByteBuffersDirectory is for pure in-memory access for demos, and MMapDirectory uses memory-mapped files stored in the filesystem.
Spring AI provides 3 inbuilt classes MapOutputConverter, ListOutputConverter, and BeanOutputConverter to help prompt in communicating expected response structures.
This Spring tutorial discusses the basics of Spring AI APIs for image generation using OpenAI’s DALL-E and Stability AI with examples.
This Spring AI tutorial discusses its core terminology and examples to interact with OpenAI’s chat and image generation APIs using simple text prompts.
Learn to write SQL queries with ‘LIKE’ keyword in a Spring Boot JPA application and execute with JdbcClient, JdbcTemplate or JpaRepository template methods.
Learn to create a REST API controller using @RestController in a Spring Boot application, and add method validation, error handling and unit tests.
Learn to Spring Data JPA module and work with JpaRepository interface for performing the CRUD operations in underlying databases in a Spring Boot application.
When rebuilding a Java or Spring application, after upgrading Java 21, you may face the issue “NoSuchFieldError: Class JCTree$JCImport does not have member field”.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.