Pular para o conteúdo principal

Postagens

Connecting to MCP Servers using Java

You probably heard about Model Context Protocol (MCP) , which is basically a standard for connecting Tools to LLMs. It was released November 2024 and a few months later we have a good list of MCP Clients and MCP Servers .  Building MCP Server is easy with Quarkus and there are a few good servers available with one single jbang command. Check the Quarkiverse MCP Servers project! For the client I did find myself with some difficult finding a good lightweight open MCP Client. Don't get me wrong, I know there are good alternatives, but I only use ollama locally and I don't want to fell in the multiverse of LLM Clients to find one that fits my needs. I wanted to build my own MCP Client! In this post let's take a look at MCP Java SDK to build our own client. MCP Java SDK MCP provides a good modern Java SDK for building MCP applications. Quarkus and langchain4j are also a good alternative, but this time I needed something low level.  To get started with the MCP Java SDK you ...
Postagens recentes

LLM-Powered Java Development: Using Quarkus and Langchain4J to Run Python-Generated Code

Code on my github   You may have heard that Auto Regressive LLMs (Large Language Models) are not good with certain tasks, given wrong or inaccurate results. Classical examples is the prompt: count the number of r in word strawberry Asking local llama 3.2 to count the number of 'r' on word 'strawberry' and it wrongly says 2 Or which number is bigger: 9.11 or 9.9 Asking Llama 3.2 the prompt which number is bigger: 9.11 or 9.9 and it wrongly says that 9.11 is bigger Of course modern LLMs may be trained to target such cases and may get it right, but if you try similar prompts you may get inaccurate results or even make the LLM "think" that they should answer something else and change the answer to something wrong. But still, there are issues that LLMs simply can't solve due the tokenization process and the context lenght. This is discussed in depth in recent Andrej Karpathy video about LLMs: In this same video Karpathy suggests the use of code to solve such ...

The Bluesky REST API

 You may have heard that Twitter has been blocked in Brazil . It has been defying local authorities and justice blocked its access from Brazil. Have that said, most Brazilians migrated to Bluesky , the social network created by Twitter's founder. I moved to there as well (feel free to follow me , be aware I post a lot in Portuguese) and I am amazed with two things: * The REST API is well documented and easy to use; * Bluesky supports The AT Protocol , which seems to be great alternative of how we consume content from the internet (which is currently dominated by suspicious algorithms). In this post let's reach the API to query about Java and build a dashboard out of it.  The API Endpoint We will be using the  app.bsky.feed.searchPosts endpoint. It returns a JSON in the following format To query it we need an API Key, which can be acquired going to your Profile Settings -> App Passwords -> Create App Password  The API seems to enable CORS from any web app, hen...

Computer Vision with JavaFX and DJL

Computer Vision is not a new topic in Computer Science, but in the recent years it got a boost due the use of Neural Networks for classification, object detection, instance segmentation and pose prediction. We can make use of these algorithms in Java using a Deep Learning library, such as DL4J  as we already did in this blog with  handwritten digits recognition , and detecting objects in a JavaFX application . However, deep learning is popular mostly among Python developers (one reason is because Python easily wraps on top of native libraries, it will be easier in Java after Project Panama ), so we have much more pre-trained models for Tensorflow and Pytorch libraries. It is possible to import them, but it requires a bit more of work then simply reusing a pre-trained model. Fortunately there is a new library called Deep Java Library  which offers a good set of pre-trained models. It makes use of Jupyter , which makes easier to try the library APIs. Another DJL feature ...

Database Query Server using Quarkus

We are updating our application to Quarkus and I have this requirement of supporting datasouces that users of our application can create. This is already supported in Widlfly , but does not seem to be supported on Quarkus . Before implementing this in our system we created a PoC which we share in this post. The problem Agroal is the part of Quarkus responsible for DataSources and pool connections. It is easy to configure datasources in Quarkus, but some properties only works during development time, after the JAR for distribution is built then you can't change some properties. The solution is programatically create datasources  so the application is flexible in a way that we can add datasets using system properties. We also must make sure that all supported data base drivers are in the application so users just needs to setup properties and no other action is required. All drivers dependencies Datasource from property We can create datasources using a map of properties. The proper...

Creating Fat JARs for JavaFX Applications

A FAT JAR is a type of Java application distribution where a single JAR contains all other dependencies, so no additional file is required to run the JAR besides the Java Virtual Machine. For any Java maven based application, creating a FAR JAR could be solved by using Maven Shade Plugin . However, creating FAT Jars using JavaFX may be a challenge because JavaFX uses modules. Fortunately this subject was intensely discussed in the WEB, and a good explanation and a solution was provided by Jose Pereda in this StackOverflow response. In this post I want to briefly share the steps to make a FAT JAR and post an example on my github so I can point others to check the example. How to create a FAT JAR for a JavaFX application? 1- Create a main class that will run your application. This class must have the main method and call your actual application static launch method; 2- Add the Shade Plugin to your project. For those using Gradle notice that Jose Pereda also provided an answer about it i...

Using jbang for ETL Scripts

As a Java programmer I prefer to use good old Java to extract/transform/load data to make it usable in tools I work for data visualization. However, it is a burden having to use maven just to write a single Java file. Hopefully there's a new tool called jbang that makes it easier to do scripting in Java. More than simple scripts What is impressive about jbang is that you are not restricted to standard Java APIs in fact you can use any library you want coming from Maven! What you will miss is the burden of having to deal with pom.xml and maven builds. Dependencies are simply declared in the Java file itself using a " DEPS " comment, for example: //DEPS org.slf4j:slf4j-nop:1.7.25 Installation To install jbang you just have to check the best way for you in downloads page.  In my case I have sdkman, so it was just a matter of running: $ sdk install jbang Hello World The simplest hello world we can thing can run with jbang without any additional configuration, just install j...