Posts

Java Virtual Thread are java lightweight threads : Threads ( JEP 444)

Java 21 Virtual Threads: A Practical Guide to Lightweight Concurrency One of the most important features introduced in Java 21 is Virtual Threads , delivered as a permanent feature through JEP 444 . Virtual threads make it easier to build highly concurrent applications by allowing developers to create and manage large numbers of threads with less overhead than traditional platform threads. They also let us continue writing straightforward, blocking-style Java code instead of requiring every application to adopt asynchronous programming. Let's explore platform threads, understand how virtual threads work, and see how to create them using Java 21. 1. Understanding Platform Threads Java has supported threads through the java.lang.Thread class since its early versions. A task can be defined using the Runnable interface and executed by a thread. For example: Runnable task = () -> { System.out.println(" Hello from a platform thread! "); }; Thread thread = new Thread...

LangGraph — Conditional Workflow with Decision Routing

Image
  LangState and StateGraph are different, but directly linked . This is actually one of the most important concepts in LangGraph. LangState                  StateGraph    │                                    │    │ defines                    │ uses    ▼                               ▼ "What data does          "How does the the workflow carry?"      workflow run?" class LangState ( TypedDict ):     messages : Annotated [ list , add_messages ] LangState = the data/state structure ,  "Every state in my graph has a messages field." StateGraph = the workflow that operates on that state builder = StateGraph ( LangState ) There is the...

Introduction to LangGraph: Building Stateful LLM Workflows with Nodes and Edges

  What is LangGraph? LangGraph is a framework for building stateful workflows and agents around LLMs . In a typical LLM application, we may need to perform several steps. For example, the LLM may receive a question, decide that it needs a tool, call the tool, receive the result, and then generate a final answer. LangGraph helps us represent this workflow as a graph . A LangGraph workflow mainly consists of: State — contains the information carried through the workflow. Nodes — perform individual tasks, such as calling an LLM or executing a tool. Edges — define how the workflow moves from one node to another. A simple workflow can therefore look like this: START ↓ LLM Node ↓ Tool Node ↓ END The state travels through these nodes as the workflow executes. For example, if our state contains a messages list, the LLM can add an AIMessage to it and a tool can add a ToolMessage . The state therefore keeps track of what has happened during the workflow. In simple terms: LangGraph...