<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bradley Clemson on Medium]]></title>
        <description><![CDATA[Stories by Bradley Clemson on Medium]]></description>
        <link>https://medium.com/@bradclemson?source=rss-9b66da66d8c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tCSlckfEp9332BIkkZv8Gw.jpeg</url>
            <title>Stories by Bradley Clemson on Medium</title>
            <link>https://medium.com/@bradclemson?source=rss-9b66da66d8c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 12:34:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bradclemson/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building The Situation Room: An Honest, Live Monitor of NATO’s Eastern Flank]]></title>
            <link>https://medium.com/@bradclemson/building-the-situation-room-an-honest-live-monitor-of-natos-eastern-flank-351585442d8b?source=rss-9b66da66d8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/351585442d8b</guid>
            <category><![CDATA[nato]]></category>
            <category><![CDATA[russia]]></category>
            <category><![CDATA[ukraine]]></category>
            <dc:creator><![CDATA[Bradley Clemson]]></dc:creator>
            <pubDate>Thu, 05 Nov 2026 15:30:01 GMT</pubDate>
            <atom:updated>2026-11-05T15:30:01.446Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Grounding an AI brief in real reporting, curating open-source map layers by hand, and what to do when the data you want isn’t licensed.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HPtZ1dEINZKMgPTECOdt7w.png" /></figure><h3>Why build it?</h3><p>I’ve followed developments across NATO’s eastern flank for some time, particularly the growing intersection of conventional military activity, cyber operations and hybrid warfare. But keeping track of what’s happening is surprisingly fragmented. You might read about GPS interference over the Baltic, an undersea cable incident in the North Sea and a military exercise near Kaliningrad, all in separate reports, without an easy way to understand how they fit together geographically.</p><p>I wanted to bring those pieces into one place. Not another news aggregator, but a geographic intelligence dashboard that connects reporting with the locations and infrastructure it describes. The aim was to experiment with how modern web technologies and AI could make open-source intelligence more accessible, while being honest about what the underlying data can and cannot tell us.</p><p>The Situation Room is a single page that answers one question: <em>what is happening along NATO’s eastern flank right now, and where?</em> It combines three things:</p><ul><li><strong>An AI intelligence brief</strong> at the top, summarising current developments in three or four sentences.</li><li><strong>An interactive map</strong> with toggleable layers: NATO bases, Russian military sites, critical undersea cables, and areas of persistent GPS jamming.</li><li><strong>A live news feed and timeline</strong> underneath, so every claim on the page can be traced back to a source.</li></ul><p>It’s built with Astro and React islands, MapLibre GL for the map, Netlify Functions for the server side, Groq for model inference and the Guardian Open Platform for news.</p><p>The interesting problems weren’t the map or the UI. They were about <strong>trust</strong>: how do you put AI-generated analysis next to a map of military sites without misleading anyone?</p><h3>1. The AI brief: from “confident fiction” to grounded summary</h3><h3>The first version had a quiet problem</h3><p>The original brief was a single prompt: <em>“You are an intelligence analyst… provide a concise briefing on the current situation along NATO’s eastern flank.”</em> The only live input was today’s date.</p><p>It read well. That was the problem. A model given only a date writes from its training data, so the “current situation” it describes could be months out of date — or simply invented — and it reads exactly as confidently either way. For a page whose whole purpose is current awareness, that’s the worst kind of failure: invisible.</p><h3>Grounding it in real reporting</h3><p>The fix was to stop asking the model what it <em>knows</em> and start asking it to <em>summarise what it’s given</em>:</p><ol><li>A Netlify Function fetches the 20 most recent eastern-flank articles from the Guardian API — headline plus standfirst, with inline HTML stripped.</li><li>They’re passed to the model as a numbered list of reports.</li><li>The prompt is strict: use <strong>only</strong> these reports, leave out any topic they don’t cover, and cite supporting reports inline as [3] or [2][5].</li></ol><p>The function constructs the numbered report list using the following TypeScript:</p><pre>const reports = articles<br>  .map((a, i) =&gt; `[${i + 1}] ${a.date.slice(0, 10)} — ${a.title}${a.trailText ? `: ${a.trailText}` : &quot;&quot;}`)<br>  .join(&quot;\n&quot;);</pre><p>The function then parses which numbers the model actually cited and returns only those sources. On the page, citations render as small links, and a collapsible “Based on N Guardian reports · generated 14:00 UTC” list sits under the brief. Every sentence can be checked in one click.</p><p>Two smaller decisions mattered as much as the prompt:</p><ul><li><strong>Fail closed.</strong> If the news fetch fails, the brief says it’s unavailable rather than letting the model write from memory. A missing brief is better than a fabricated one.</li><li><strong>Don’t cache failures.</strong> Successful briefs are cached for an hour; failures are sent with Cache-Control: no-store, so one bad request doesn&#39;t stick for an hour at the CDN.</li></ul><h3>A lesson in silent failure</h3><p>Months after launch, the brief started showing <em>“Intelligence brief temporarily unavailable”</em> — with an HTTP 200. The function was catching the upstream error and returning a friendly fallback, which meant nothing looked broken in the network tab.</p><p>The cause: the model it used (llama-3.3-70b-versatile) had been retired by Groq in August 2026. The replacement, openai/gpt-oss-120b, is a reasoning model, which introduced a subtler trap: <strong>reasoning tokens count against the completion limit</strong>. The old max_tokens: 450 would have let the model spend its whole budget thinking and return nothing. Setting reasoning_effort: &quot;low&quot; and max_completion_tokens: 1500 fixed it.</p><p>Takeaways I’d apply to any LLM feature:</p><ul><li>Pin model IDs, and put their retirement dates somewhere you’ll see them.</li><li>A graceful fallback still needs an alert. Log the upstream status and body, and watch for the fallback rate.</li><li>When swapping to a reasoning model, re-check every token limit.</li></ul><h3>Before and after</h3><p>The whole change comes down to what the model is given. The original prompt asked for analysis and supplied nothing to analyse but the date:</p><blockquote><em>Provide a concise intelligence-style briefing (3–4 complete sentences) focused specifically on the current situation along NATO’s eastern flank.</em></blockquote><blockquote><em>Date context: Thu, 05 Nov 2026 13:36:00 GMT</em></blockquote><p>The grounded prompt hands over the evidence and constrains the model to it:</p><blockquote><em>Using ONLY the numbered reports below, write a concise intelligence-style briefing.</em></blockquote><blockquote><em>Rules:</em></blockquote><blockquote>Do not state any fact that is not supported by the reports. If a topic is not covered, leave it out.</blockquote><blockquote>Cite supporting reports inline with their numbers in square brackets, e.g. [3] or [2][5].</blockquote><blockquote><em>Reports:</em></blockquote><blockquote><em>[1] 2026–11–05 — Bomb threats disrupt at least 15 flights across Europe, renewing hybrid warfare fears: …</em></blockquote><blockquote><em>[2] 2026–11–04 — Zelenskyy says 40 now confirmed dead after ‘insane’ Russian attack on school: …</em></blockquote><p>The result: every sentence carries citations, and the reports behind them are one click away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ntl8KkhGzHCHW78nGSC8lw.png" /><figcaption><strong>The grounded brief, with inline citations after each claim</strong></figcaption></figure><p>Expanding the source list shows exactly which reports the brief drew on — here, 7 of the 20 it was given — so a reader can verify any claim before trusting it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0eYAqahwAtmSPpw8W5kbBA.png" /><figcaption><strong>The brief’s source list expanded, showing the seven cited Guardian reports with dates</strong></figcaption></figure><h3>2. The map: curated layers you can actually trust</h3><h3>Why curated data, not a live feed</h3><p>There is no single open, licensed, reliable feed of “military sites” or “critical cables”. So every layer is a <strong>hand-curated, typed dataset</strong> in the repo — a deliberate trade-off: less “live”, but every point is something I can source and explain.</p><p>The map currently contains:</p><p>LayerCountWhat it showsNATO bases104Command HQs, air, naval and land bases, missile-defence sitesRussian military sites60Districts, fleets, Kaliningrad, strategic and nuclear sites, bases abroadUndersea cables22Data and power links, with damage incidents highlightedGPS jamming zones10Areas of repeatedly reported interference</p><p>Each record is typed (MilitaryBase, UnderseaCable, GpsJammingZone) with a name, coordinates, operator and a one-line description. Entries whose status is uncertain say so in their description — Syria after December 2024, reported nuclear storage in Belarus — rather than presenting a guess as fact.</p><h3>Undersea cables: the hybrid-threat story</h3><p>The cables layer is where the map earns its place on a hybrid-threat dashboard. Baltic cables cut in 2023–25 (C-Lion1, BCS East-West Interlink, Estlink 2 and others) get a red glow; clicking a cable shows its route, operator and incident history.</p><p>Two small MapLibre techniques made it usable:</p><ul><li><strong>An invisible hit layer.</strong> A 2px line is almost impossible to click, so each cable has a transparent 12px-wide twin that receives the clicks.</li><li><strong>Click priority.</strong> Layers stack jamming → cables → bases → tension zones. Each handler checks queryRenderedFeatures for anything above it before opening its own popup, so a base sitting on a cable opens the base.</li></ul><h3>Making 190+ points readable</h3><p>With every layer on, the map shows nearly 200 points. Three features keep it legible:</p><ul><li><strong>Type filters</strong> — chips for HQ, Air, Naval, Land, Missile defence and Nuclear, applied across both base layers with live counts.</li><li><strong>Labels on zoom</strong> — site names appear from zoom 5.5, using the basemap’s own fonts, and MapLibre drops overlapping labels automatically.</li><li><strong>A collapsible legend</strong> that shows how many layers are on when collapsed.</li></ul><h3>Shareable views</h3><p>Every toggle, filter and the map position live in the URL:</p><p>/situation-room?layers=russia,jamming&amp;types=strategic&amp;view=20.50,54.70,6.0</p><p>That link opens on Kaliningrad with only nuclear-capable Russian sites and jamming zones visible. Two details made this robust:</p><ul><li><strong>Read the URL after mount, not during render.</strong> The page is server-rendered, so reading window.location in the initial render would produce different HTML on the server and client — a React hydration mismatch.</li><li><strong>Validate everything.</strong> Unknown layer names are ignored, an out-of-range view falls back to the default, and a types value with no recognisable entries is ignored rather than hiding every base.</li></ul><h3>3. GPS jamming: when the data exists but you can’t use it</h3><p>GPS interference over the Baltic, Kaliningrad, Finland and the Black Sea is one of the clearest everyday signals of hybrid activity. Finnair suspended flights to Tartu in spring 2024 because interference made approaches unsafe. It was the layer I most wanted.</p><p>The obvious source is <a href="https://gpsjam.org/">GPSJam</a>, which maps interference daily from aircraft navigation-accuracy reports. But:</p><ul><li><strong>GPSJam</strong> publishes no licence, terms of use, download or API.</li><li>Its upstream sources are <strong>ADS-B Exchange</strong>, whose data access is commercial, and <strong>airplanes.live</strong>, whose API asks you to email a description of your project before use.</li></ul><p>So the data exists, it’s public to look at, and there’s still no clear permission to reuse it. Scraping it, or embedding someone else’s map without permission, wasn’t an option I was comfortable with.</p><h3>The honest alternative</h3><p>Instead, the layer shows <strong>ten curated zones</strong> — circles drawn from a centre and radius — around areas where aviation regulators and public reporting repeatedly document interference: Kaliningrad, the Gulf of Finland, Pskov, Karelia, Kola/Finnmark, the Belarus border, Moscow, the Ukraine front line, the Black Sea and the Eastern Mediterranean. Shading reflects how persistent the reported interference is.</p><p>The most important design decision was the wording. Every zone popup and the legend say plainly that this is an <strong>approximate area of repeatedly reported interference, not a live measurement</strong>, and link to GPSJam for live data. A layer that overstates its precision would undermine trust in every other layer on the page.</p><p>If API access is approved later, a scheduled function could replace the circles with measured data without changing the UI.</p><h3>4. Smaller lessons worth sharing</h3><ul><li><strong>Escape third-party text, even in “just a popup”.</strong> MapLibre’s setHTML takes raw HTML, and the news popups inserted article titles straight into it. A malicious headline could have injected script. A ten-line escapeHtml helper and an http(s)-only URL check closed it.</li><li><strong>Hydration mismatches hide in clocks.</strong> The world clock rendered the time on the server and again in the browser a moment later — never equal. Rendering a fixed placeholder until mount fixed it.</li><li><strong>Tear down map instances.</strong> Without a cleanup in the init effect, hot reload kept the old map and silently skipped new layers. map.remove() on unmount fixed that and made development honest.</li></ul><h3>What’s next</h3><p>There are three areas I’d like to take further.</p><ul><li><strong>An event-driven timeline.</strong> Annotate the map with significant historical incidents, particularly undersea cable damage, GPS interference and other reported hybrid-threat activity. This would help distinguish isolated events from longer-running patterns.</li><li><strong>Geographical news intelligence.</strong> Go beyond a chronological news feed by identifying references to locations and infrastructure already represented on the map. An article mentioning a cable incident in the Baltic should be discoverable alongside that cable, rather than buried in a general feed.</li><li><strong>Better data coverage.</strong> Continue expanding and validating the curated datasets, while exploring whether additional providers can offer licensed, reliable access to live GPS interference data.</li></ul><p>The longer-term ambition is to move from a dashboard that brings information together towards one that helps people understand relationships between events, infrastructure and geography, without presenting inference as established fact.</p><p>The Situation Room is an ongoing experiment in building useful intelligence tools with open data, modern web technologies and AI.</p><p>The biggest lesson so far is that building an intelligence dashboard isn’t particularly difficult. Building one that people can actually trust is considerably harder.</p><p><strong>Explore The Situation Room:</strong> <a href="https://bradleyclemson.com/situation-room">https://bradleyclemson.com/situation-room</a></p><p>I’d be interested to hear from anyone working in OSINT, defence technology or geospatial intelligence who has thoughts on how it could be improved.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=351585442d8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From SQL to Smart Assistant: Connecting Databases to AI with MCP]]></title>
            <link>https://medium.com/@bradclemson/from-sql-to-smart-assistant-connecting-databases-to-ai-with-mcp-fbf79f752189?source=rss-9b66da66d8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbf79f752189</guid>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[anthropic-claude]]></category>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Bradley Clemson]]></dc:creator>
            <pubDate>Thu, 21 Aug 2025 13:20:21 GMT</pubDate>
            <atom:updated>2025-08-21T13:20:21.217Z</atom:updated>
            <content:encoded><![CDATA[<p>See how the Model Context Protocol lets AI go beyond chat and actually use your data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*UT7J5sTa0YVff8arv3UDsw.png" /></figure><p>Artificial intelligence assistants are becoming more powerful every day, but one of the biggest challenges is connecting them to real-world data and tools in a safe, structured way. That’s where the <strong>Model Context Protocol (MCP)</strong> comes in.</p><p>MCP is an emerging open standard that allows AI models to interact with external tools, APIs, and data sources through a consistent interface. Instead of hardcoding integrations or relying on brittle hacks, MCP provides a clear framework for exposing tools to AI in a way that is both <strong>flexible</strong> and <strong>secure</strong>. This means developers can create assistants that don’t just generate text, but can also fetch data, call services, and perform useful actions.</p><p>In this article, I will walk you through a practical example of MCP in action: building a simple <strong>employee assistant</strong> connected to a PostgreSQL database. We’ll set up an MCP server that exposes employee data (like birthdays and work anniversaries), then connect it to a client, and finally enhance it with an AI model so you can ask natural questions like <em>“Who has a birthday today?”</em> or <em>“Show me everyone who started in 2020.”</em></p><p>By the end, you’ll have a working MCP-powered AI assistant and a deeper understanding of how MCP bridges the gap between <strong>AI reasoning</strong> and <strong>real-world execution</strong>.</p><h3>What is MCP?</h3><p>When we think about AI assistants, we often picture a model like ChatGPT or Claude generating natural-language answers. But if you’ve ever asked an assistant to <em>do something real</em> — like check a database, call an API, or look up internal company data — you’ll know that large language models (LLMs) can’t natively perform those actions.</p><p>That’s the problem the <strong>Model Context Protocol (MCP)</strong> is designed to solve.</p><p>At its core, MCP is an <strong>open standard</strong> that defines how AI models can talk to external tools in a structured and predictable way. Instead of hardcoding integrations for each model or API, MCP provides a <strong>common interface</strong>. This makes it possible to connect any model that speaks MCP to any tool that exposes an MCP server — safely, flexibly, and without reinventing the wheel.</p><p>Think of it as the “language” that lets your AI assistant say:</p><ul><li>“Hey server, do you have any tools I can use?”</li><li>“Here’s a user query — which tool should I call?”</li><li>“Run this tool and return the results.”</li></ul><p><strong>The key building blocks of MCP are:</strong></p><ul><li><strong>Server</strong> → Exposes tools to be used. For example, a server might provide access to a database query function, an email-sending API, or a file system.</li><li><strong>Client</strong> → Connects to the server and acts as the middleman. It lists tools, sends requests, and retrieves results.</li><li><strong>Model</strong> → The reasoning engine (Claude, GPT, etc.) that interprets user queries and decides when and how to use tools.</li></ul><p>By separating these roles, MCP creates a clean abstraction layer: the model doesn’t need to know how a tool is implemented, only how to call it. This makes it easier to build assistants that are <strong>portable, extensible, and secure</strong>.</p><p>In short:</p><blockquote><strong>MCP bridges the gap between AI reasoning and real-world execution.</strong></blockquote><p>In the rest of this article, we’ll see how this works in practice by building a simple employee assistant that uses MCP to query a PostgreSQL database.</p><h3>Designing the Employee Assistant</h3><p>Now that we understand the <strong>why</strong> behind MCP, let’s bring it down to earth with a simple but practical use case: an <strong>employee assistant</strong>.</p><p>Imagine you’re part of an HR team. You want a lightweight AI assistant that can answer questions about employees, such as:</p><ul><li><em>“Who has a birthday today?”</em></li><li><em>“Which employees are celebrating a work anniversary this month?”</em></li><li><em>“Show me everyone who started after 2018.”</em></li><li><em>“List employees living on Main Street.”</em></li></ul><p>This information already exists in your company’s database — but without MCP, your AI assistant has no safe way of accessing it. That’s where our MCP-powered solution comes in.</p><h4><strong>The Employee Table</strong></h4><p>We’ll keep things simple with a single PostgreSQL table called employee that contains four fields:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*4v6t0nlQj3FD3HlZ8uUZVQ.png" /><figcaption>Employee table</figcaption></figure><p>This schema gives us enough data to answer common HR-related queries without making things too complex.</p><h4><strong>How MCP Fits In</strong></h4><p>Here’s the architecture we’ll build:</p><p><strong>1.MCP Server (employee_server.py)</strong></p><ul><li>Exposes tools for querying the employee table</li><li>Examples: “employees with a birthday today” or “employees with an anniversary today”</li><li>Runs locally on localhost:8080</li></ul><p><strong>2.MCP Client (client.py)</strong></p><ul><li>Connects to the server</li><li>Lets a user run one of the tools by typing in a query</li><li>Prints the results</li></ul><p><strong>3.AI-Powered Client (client_ai.py)</strong></p><ul><li>Uses an AI model (Claude) to interpret free-form questions</li><li>Claude decides which tool to call and formats the result naturally</li><li>Lets the assistant feel more conversational and intelligent</li></ul><p>By the end, you’ll be able to type something like:<br><em> \nWho has a birthday today?\n</em><br> and the assistant will call the correct MCP tool, fetch results from Postgres, and give you an answer in plain English.</p><h3>Building the MCP Server</h3><p>The first piece of our application is the <strong>MCP server</strong>. This is the component that exposes access to our employee database in a structured way so that clients (and AI models) can query it.</p><p>We’ll use <strong>FastMCP</strong>, a lightweight Python framework for building MCP servers. It makes it easy to define “tools” — functions that the model (or user) can call to retrieve data.</p><h4>The Code: employee_server.py</h4><p>Here’s the server implementation:</p><pre>from fastmcp import FastMCP<br>from datetime import date<br>import psycopg2<br>import os<br><br>server = FastMCP(&quot;employee-server&quot;)<br><br># Postgres connection settings<br>DB_NAME = os.getenv(&quot;DB_NAME&quot;, &quot;employees_db&quot;)<br>DB_USER = os.getenv(&quot;DB_USER&quot;, &quot;postgres&quot;)<br>DB_PASSWORD = os.getenv(&quot;DB_PASSWORD&quot;, &quot;password&quot;)<br>DB_HOST = os.getenv(&quot;DB_HOST&quot;, &quot;localhost&quot;)<br>DB_PORT = os.getenv(&quot;DB_PORT&quot;, &quot;5432&quot;)<br><br>def get_connection():<br>    return psycopg2.connect(<br>        dbname=DB_NAME,<br>        user=DB_USER,<br>        password=DB_PASSWORD,<br>        host=DB_HOST,<br>        port=DB_PORT<br>    )<br><br>@server.tool()<br>def query_employee_data(where_clause: str = None) -&gt; list[dict]:<br>    &quot;&quot;&quot;<br>    Run a general query on the employee table.<br>    Args:<br>        where_clause: SQL WHERE condition (without the &#39;WHERE&#39; keyword).<br>                      Example: &quot;EXTRACT(YEAR FROM start_date) &gt; 2020&quot;<br>    &quot;&quot;&quot;<br>    conn = get_connection()<br>    cur = conn.cursor()<br>    base_query = &quot;SELECT name, date_of_birth, address, start_date FROM employee&quot;<br>    sql = f&quot;{base_query} WHERE {where_clause}&quot; if where_clause else base_query<br>    try:<br>        cur.execute(sql)<br>        rows = cur.fetchall()<br>        results = [{&quot;name&quot;: r[0], &quot;dob&quot;: r[1].isoformat(), &quot;address&quot;: r[2], &quot;start_date&quot;: r[3].isoformat()} for r in rows]<br>    except Exception as e:<br>        results = {&quot;error&quot;: str(e)}<br>    cur.close()<br>    conn.close()<br>    return results<br><br>if __name__ == &quot;__main__&quot;:<br>    server.run(host=&quot;127.0.0.1&quot;, port=8080)</pre><h4>How it works</h4><ul><li>Each function decorated with @server.tool() becomes available as an MCP tool.</li><li>query_employee_data provides <strong>flexibility</strong>, letting users filter employees with custom conditions (like a SQL WHERE clause).</li><li>Finally, server.run(port=8080) starts the MCP server on localhost:8080.</li></ul><p>At this point, we have a working MCP server that exposes our employee database. In the next step, we’ll build a <strong>client</strong> to connect to this server and actually run these tools.</p><h3>Creating a Basic MCP Client</h3><p>With our server up and running, the next step is to build a <strong>client</strong>. The client acts as the “middleman” between the user and the MCP server. It connects to the server, lists the available tools, and lets us call them with user input.</p><p>This step doesn’t involve AI yet — it’s about proving that our server works and that we can interact with it from a separate process.</p><h4>The Code: client.py</h4><pre>import asyncio<br>from mcp.client.session import ClientSession<br>from mcp.client.stdio import stdio_client<br>from mcp.client.stdio_server_parameters import StdioServerParameters<br>import re<br>from datetime import date<br><br>def generate_where_clause(query: str) -&gt; str:<br>    &quot;&quot;&quot;<br>    Convert natural language query to SQL WHERE clause.<br>    Very basic mapping for demonstration.<br>    &quot;&quot;&quot;<br>    query = query.lower()<br>    today = date.today()<br><br>    # Birthday today<br>    if &quot;birthday&quot; in query:<br>        return f&quot;EXTRACT(MONTH FROM date_of_birth) = {today.month} AND EXTRACT(DAY FROM date_of_birth) = {today.day}&quot;<br><br>    # Anniversary today<br>    if &quot;anniversary&quot; in query or &quot;work anniversary&quot; in query or &quot;started&quot; in query:<br>        return f&quot;EXTRACT(MONTH FROM start_date) = {today.month} AND EXTRACT(DAY FROM start_date) = {today.day}&quot;<br><br>    # Employees who started after a certain year<br>    match = re.search(r&quot;started after (\\d{4})&quot;, query)<br>    if match:<br>        year = match.group(1)<br>        return f&quot;EXTRACT(YEAR FROM start_date) &gt; {year}&quot;<br><br>    # Employees who live on a certain street<br>    match = re.search(r&quot;live on (.+)&quot;, query)<br>    if match:<br>        street = match.group(1)<br>        return f&quot;address LIKE &#39;%{street}%&#39;&quot;<br><br>    return None<br><br>async def run():<br>    server_params = StdioServerParameters(<br>        command=&quot;python&quot;,<br>        args=[&quot;employee_server.py&quot;],<br>        env=None<br>    )<br><br>    async with stdio_client(server_params) as (read, write):<br>        session = ClientSession(read, write)<br>        await session.initialize()<br>        tools = await session.list_tools()<br>        print(&quot;Available tools:&quot;, tools)<br><br>        # Prompt user for query<br>        user_query = input(&quot;\nAsk about employees (free text): &quot;)<br>        <br>        # Convert query to SQL WHERE clause<br>        where_clause = generate_where_clause(user_query)<br><br>        if where_clause is None:<br>            print(&quot;Sorry, could not understand the query.&quot;)<br>            return<br><br>        # Call general query tool<br>        result = await session.call_tool(&quot;query_employee_data&quot;, {&quot;where_clause&quot;: where_clause})<br>        print(&quot;\nResults:&quot;)<br>        print(result)<br><br>if __name__ == &quot;__main__&quot;:<br>    asyncio.run(run())</pre><h4><strong>How It Works</strong></h4><p><strong>1.Server Parameters</strong></p><ul><li>command=&quot;python”→ runs Python as the executable.</li><li>args=[&quot;employee_server.py&quot;] → launches our server script.</li></ul><p><strong>2.Connecting with stdio_client</strong></p><p>Starts the server as a subprocess and sets up communication over standard I/O.</p><p><strong>3.ClientSession</strong></p><p>Handles the actual session with the server. We call initialize() to establish the connection.</p><p><strong>4.Tool Listing</strong></p><p>list_tools() confirms what’s available (useful for debugging).</p><p><strong>5.Handling User Input</strong></p><p>User enters <strong>natural language</strong> query generate_where_clause() converts the query to a <strong>SQL WHERE clause</strong>. The client then calls query_employee_data with the clause.</p><p><strong>6.Result: </strong>Whatever the tool returns is printed in the console.</p><p>At this stage, we can query the server — but our logic is brittle. The client only recognises a few keywords, and users need to know SQL syntax for flexible queries. That’s not very user-friendly.</p><p>In the next section, we’ll solve this problem by bringing in <strong>Claude</strong> as the AI brain. The model will interpret natural language questions and decide which MCP tool to call — making our assistant much smarter.</p><h3>Adding AI (Claude)</h3><p>Our MCP client works — but it’s still rigid. Right now, users need to either type exact keywords (“birthday”, “anniversary”) or write raw SQL conditions. That’s not very user-friendly.</p><p>This is where the <strong>AI model</strong> comes in. By integrating <strong>Claude</strong> (Anthropic’s powerful LLM), we can make our assistant <strong>conversational</strong>. Instead of hardcoding keyword matches, we’ll let Claude interpret the user’s intent and decide which MCP tool to call.</p><h4>The Code: client_ai.py</h4><pre>import asyncio<br>from mcp.client.session import ClientSession<br>from mcp.client.stdio import stdio_client<br>from mcp.client.stdio import StdioServerParameters<br>from anthropic import Anthropic<br>import os<br><br># Load Anthropic API key<br>ANTHROPIC_API_KEY = os.getenv(&quot;ANTHROPIC_API_KEY&quot;)<br><br># Initialize Claude client<br>anthropic = Anthropic(api_key=ANTHROPIC_API_KEY)<br><br># Server parameters<br>server_params = StdioServerParameters(<br>    command=&quot;python&quot;,<br>    args=[&quot;employee_server.py&quot;],<br>    env=None<br>)<br><br>async def run():<br>    # Start server and create stdio connection<br>    async with stdio_client(server_params) as (read, write):<br>        session = ClientSession(read, write)<br>        await session.initialize()<br>        <br>        # List tools (for Claude context)<br>        tools = await session.list_tools()<br>        print(&quot;Available tools:&quot;, tools)<br>        <br>        # Get user input<br>        user_input = input(&quot;Ask about employees: &quot;)<br>        <br>        # Send query to Claude<br>        response = anthropic.messages.create(<br>            model=&quot;claude-3-opus-20240229&quot;,<br>            max_tokens=500,<br>            tools=tools,  # Give Claude access to MCP tools<br>            messages=[<br>                {&quot;role&quot;: &quot;user&quot;, &quot;content&quot;: user_input}<br>            ]<br>        )<br>        <br>        # Check if Claude wants to call a tool<br>        for content in response.content:<br>            if content.type == &quot;tool_use&quot;:<br>                tool_name = content.name<br>                tool_args = content.input or {}<br>                print(f&quot;Claude wants to use tool: {tool_name} with args {tool_args}&quot;)<br>                <br>                # Call tool via MCP<br>                tool_result = await session.call_tool(tool_name, arguments=tool_args)<br>                <br>                # Send result back to Claude<br>                follow_up = anthropic.messages.create(<br>                    model=&quot;claude-3-opus-20240229&quot;,<br>                    max_tokens=500,<br>                    messages=[<br>                        {&quot;role&quot;: &quot;assistant&quot;, &quot;content&quot;: content},<br>                        {&quot;role&quot;: &quot;tool_result&quot;, &quot;content&quot;: str(tool_result)}<br>                    ]<br>                )<br>                <br>                print(&quot;Assistant:&quot;, follow_up.content[0].text)<br>                break<br>        else:<br>            # If no tool needed, just print Claude’s response<br>            print(&quot;Assistant:&quot;, response.content[0].text)<br><br>if __name__ == &quot;__main__&quot;:<br>    asyncio.run(run())</pre><h4><strong>How It Works</strong></h4><p><strong>1.Claude Gets the Tools</strong></p><p>We pass the server’s tool definitions (list_tools()) into Claude’s context. Claude now knows which functions are available and how to call them.</p><p><strong>2.Natural Language Query</strong></p><p>The user types something like: Who started working here in 2020? Claude interprets the intent.</p><p><strong>3.Tool Decision</strong></p><p>If Claude decides a tool is needed, it emits a tool_use response with the tool name and arguments. Example: {“name”: “query_employee_data”, “input”: {“condition”: “start_date BETWEEN ‘2020–01–01’ AND ‘2020–12–31’”}}</p><p><strong>4.MCP Execution</strong></p><p>The client runs the tool on the server and gets the results from the database.</p><p><strong>5.Claude Follow-Up</strong></p><p>We send the tool results back to Claude. Claude then generates a natural-language summary, e.g.: “In 2020, Alice Johnson and Bob Smith joined the company.”</p><h4><strong>The Result</strong></h4><p>With this setup, you can ask your assistant in plain English — no keywords, no SQL — and Claude will:</p><ul><li>Parse your intent,</li><li>Call the right MCP tool,</li><li>Interpret the results,</li><li>And give you a natural answer.</li></ul><p>This is the real power of <strong>MCP + AI</strong>: bridging structured data access with conversational intelligence.</p><h3>Running the Application</h3><p>Now that we’ve built all the pieces — the <strong>MCP server</strong>, the <strong>basic client</strong>, and the <strong>AI-powered client</strong> — let’s put everything together.</p><p>Here’s how you can run the application step by step:</p><h4><strong>1.Set up the Database</strong></h4><p>First, make sure you have <strong>PostgreSQL</strong> installed and running.</p><p>Create a new database and an employee table:</p><pre>CREATE DATABASE employees_db;<br><br>\c employees_db;<br><br>CREATE TABLE employee (<br>    id SERIAL PRIMARY KEY,<br>    name VARCHAR(100),<br>    date_of_birth DATE,<br>    address TEXT,<br>    start_date DATE<br>);<br><br>-- Insert some test data<br>INSERT INTO employee (name, date_of_birth, address, start_date)<br>VALUES <br>(&#39;Alice Johnson&#39;, &#39;1990-08-19&#39;, &#39;123 Main St&#39;, &#39;2020-01-15&#39;),<br>(&#39;Bob Smith&#39;, &#39;1985-08-19&#39;, &#39;456 Oak Ave&#39;, &#39;2015-08-19&#39;),<br>(&#39;Charlie Davis&#39;, &#39;1992-05-01&#39;, &#39;789 Pine Rd&#39;, &#39;2022-08-19&#39;);</pre><h4><strong>2.Configure Environment Variables</strong></h4><p>Set your database connection and Anthropic API key in your shell (or .env file):</p><pre>export DB_NAME=employees_db<br>export DB_USER=postgres<br>export DB_PASSWORD=your_password<br>export DB_HOST=localhost<br>export DB_PORT=5432<br>export ANTHROPIC_API_KEY=your_api_key_here</pre><h4><strong>3.Install Dependencies</strong></h4><p>Install Python dependencies: pip install fastmcp mcp psycopg2-binary anthropic</p><h4>4.Run the MCP Server</h4><p>Start the MCP server: python employee_server.py</p><p>It will start listening on localhost:8080</p><h4>5.Run the Basic Client</h4><p>In a separate terminal, run: python client.py</p><p>Example queries:</p><ul><li>birthday today → Lists employees whose birthday is today.</li><li>anniversary today → Lists employees whose work anniversary is today.</li><li>start_date &gt; ‘2020–01–01’ → Flexible condition.</li></ul><h4>6.Run the AI Client</h4><p>Now, for the <strong>conversational experience</strong>: python client_ai.py</p><p>Example queries you can ask:</p><ul><li><em>“Whose birthday is today?”</em></li><li><em>“List employees who joined in 2020.”</em></li><li><em>“Who lives on Main Street?”</em></li></ul><p>Claude will decide which MCP tool to use, fetch the results, and respond in natural language.</p><h4><strong>That’s It!</strong></h4><p>You now have:</p><ul><li>An <strong>MCP server</strong> exposing employee data.</li><li>A <strong>basic client</strong> that connects directly.</li><li>An <strong>AI client</strong> that uses Claude to translate natural queries into structured MCP tool calls.</li></ul><p>This architecture is a great template for integrating MCP with <strong>any structured system</strong> (databases, APIs, business tools) while keeping the <strong>AI assistant smart and user-friendly</strong>.</p><h3>Conclusion</h3><p>The <strong>Model Context Protocol (MCP)</strong> is more than just a technical curiosity — it’s a powerful new way to connect AI models with the real world. Instead of treating assistants as “black boxes” that only generate text, MCP gives them a structured, reliable interface to call external tools, query databases, and perform useful actions.</p><p>In this walkthrough, we:</p><ul><li>Built an <strong>MCP server</strong> that exposes employee data from a PostgreSQL database.</li><li>Created a <strong>basic client</strong> that interacts with the server tools directly.</li><li>Enhanced it with <strong>Claude</strong>, turning the assistant into a conversational interface that understands natural language and decides which tool to use.</li></ul><p>The result is an AI assistant that feels intuitive to use — you can just ask <em>“Who has a birthday today?”</em> and get a clear, accurate answer, powered by your database and structured through MCP.</p><p>This is just the beginning. With MCP, you can:</p><ul><li>Connect to other data sources and APIs.</li><li>Expose multiple tools in a single server.</li><li>Build assistants tailored to specific business domains.</li><li>Keep control over what the AI can (and cannot) access.</li></ul><p>As AI becomes more embedded in workflows, MCP provides the <strong>bridge</strong> between <strong>reasoning</strong> and <strong>execution</strong>. Whether you’re managing employees, handling customer data, or orchestrating business processes, MCP opens the door to assistants that are not just chatty — but genuinely useful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbf79f752189" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Generative AI Application with Spring AI]]></title>
            <link>https://medium.com/version-1/building-a-generative-ai-application-with-spring-ai-dce717e38526?source=rss-9b66da66d8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/dce717e38526</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-ai]]></category>
            <dc:creator><![CDATA[Bradley Clemson]]></dc:creator>
            <pubDate>Fri, 12 Jan 2024 11:12:05 GMT</pubDate>
            <atom:updated>2024-09-23T08:11:03.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PpTu8T99XeZnsR1Ypo32bg.jpeg" /></figure><p>In this tutorial, we will explore the practical application of generative AI in a Spring Boot application with Spring AI.</p><blockquote><a href="https://www.version1.com/application-modernisation-integration/ai-powered-code-analysis-and-documentation-decipher/">AI-powered code analysis and documentation — Decipher | Version 1</a></blockquote><p>Put simply, Spring AI provides abstractions that streamline the development of AI applications. These abstractions have various implementations and enable developers to customise artificial intelligence functionality without unnecessary complexity.</p><p>From the AiClient to EmbeddingClient and Vector Database implementation, the Spring AI API is a comprehensive toolkit for crafting AI applications. Gracefully, as tasks for the API become more intricate, Spring AI integrates with other projects in the Spring Ecosystem, such as Spring Integration, Spring Batch, and Spring Data.</p><blockquote>The <a href="https://docs.spring.io/spring-ai/reference/index.html">Spring AI Documentation</a> covers the most recent releases, updates to the Spring AI project, and delivers in-depth insights into fundamental AI concepts such as models, prompts, and beyond.</blockquote><p>One of the features introduced by Spring AI is the AiClient interface. It acts as a uniform interface for interacting with various AI Models, including implementations for OpenAI and Azure OpenAI. The interface manages the complexity of request preparation and response parsing, offering a direct and simplified API interaction. <strong>Let’s demonstrate how this streamlines adding generative AI to our application…</strong></p><h3>Dependencies required in pom.xml</h3><p>To use Spring AI, define the following repository.</p><pre> &lt;repositories&gt;<br>  &lt;repository&gt;<br>   &lt;id&gt;spring-snapshots&lt;/id&gt;<br>   &lt;name&gt;Spring Snapshots&lt;/name&gt;<br>   &lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt;<br>   &lt;releases&gt;<br>    &lt;enabled&gt;false&lt;/enabled&gt;<br>   &lt;/releases&gt;<br>  &lt;/repository&gt;<br> &lt;/repositories&gt;</pre><p>When implementing OpenAI (what we will use in this tutorial), you can specify the following dependency:</p><pre>  &lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.experimental.ai&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-ai-openai-spring-boot-starter&lt;/artifactId&gt;<br>   &lt;version&gt;0.2.0-SNAPSHOT&lt;/version&gt;<br>  &lt;/dependency&gt;</pre><p>To implement Azure OpenAI instead of OpenAI, you can use the following dependency:</p><pre>&lt;dependency&gt;<br>   &lt;groupId&gt;org.springframework.experimental.ai&lt;/groupId&gt;<br>   &lt;artifactId&gt;spring-ai-azure-openai-spring-boot-starter&lt;/artifactId&gt;<br>   &lt;version&gt;0.2.0-SNAPSHOT&lt;/version&gt;<br>&lt;/dependency&gt;</pre><h3>Create OpenAI API Key</h3><p>To initiate a connection with OpenAI and make use of its models, it is essential to sign up and obtain an OpenAI API key <a href="https://platform.openai.com/account/api-keys">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-VaCgvmxPyqSZJCjSme7iQ.jpeg" /></figure><h3>Add API Key and OpenAI Image Generator URL in application. properties file:</h3><pre>spring.ai.openai.apikey=REPLACE_WITH_YOUR_API_KEY<br>spring.ai.openai.imageUrl=https://api.openai.com/v1/images/generations</pre><h3>Project Structure :</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*ivCfjWiWbOC3JpbxW6YJBA.jpeg" /></figure><h3>Create SpringAIService under services package:</h3><pre>@Service<br>public class SpringAIService {<br><br>    @Autowired<br>    AiClient aiClient;<br><br>    @Value(&quot;${spring.ai.openai.apikey}&quot;)<br>    private String apiKey;<br><br>    @Value(&quot;${spring.ai.openai.imageUrl}&quot;)<br>    private String openAIImageUrl;<br><br><br>    public String getJoke(String topic){<br>        PromptTemplate promptTemplate = new PromptTemplate(&quot;&quot;&quot;<br>                Crafting a compilation of programming jokes for my website. Would you like me to create a joke about {topic}?<br>                &quot;&quot;&quot;);<br>        promptTemplate.add(&quot;topic&quot;, topic);<br>        return this.aiClient.generate(promptTemplate.create()).getGeneration().getText();<br>    }<br><br>    public String getBook(String category, String year) {<br>        PromptTemplate promptTemplate = new PromptTemplate(&quot;&quot;&quot;<br>                I would like to research some books. Please give me a book about {category} in {year} to get started?<br>                But pick the best best you can think of. I&#39;m a book critic. Ratings are great help.<br>                And who wrote it? And who help it? Can you give me a short plot summary and also it&#39;s name?<br>                But don&#39;t give me too much information. I don&#39;t want any spoilers.<br>                And please give me these details in the following JSON format: category, year, bookName, author, review, smallSummary.<br>                &quot;&quot;&quot;);<br>        Map.of(&quot;category&quot;, category, &quot;year&quot;, year).forEach(promptTemplate::add);<br>        AiResponse generate = this.aiClient.generate(promptTemplate.create());<br>        return generate.getGeneration().getText();<br>    }<br><br><br>    public InputStreamResource getImage(@RequestParam(name = &quot;topic&quot;) String topic) throws URISyntaxException {<br>        PromptTemplate promptTemplate = new PromptTemplate(&quot;&quot;&quot;<br>                 I am really bored from online memes. Can you create me a prompt about {topic}.<br>                 Elevate the given topic. Make it sophisticated.<br>                 Make a resolution of 256x256, but ensure that it is presented in json.<br>                 I want only one image creation. Give me as JSON format: prompt, n, size.<br>                &quot;&quot;&quot;);<br>        promptTemplate.add(&quot;topic&quot;, topic);<br>        String imagePrompt = this.aiClient.generate(promptTemplate.create()).getGeneration().getText();<br><br>        RestTemplate restTemplate = new RestTemplate();<br>        HttpHeaders headers = new HttpHeaders();<br>        headers.add(&quot;Authorization&quot;, &quot;Bearer &quot; + apiKey);<br>        headers.add(&quot;Content-Type&quot;, &quot;application/json&quot;);<br>        HttpEntity&lt;String&gt; httpEntity = new HttpEntity&lt;&gt;(imagePrompt,headers);<br><br>        String imageUrl = restTemplate.exchange(openAIImageUrl, HttpMethod.POST, httpEntity, GeneratedImage.class)<br>                .getBody().getData().get(0).getUrl();<br>        byte[] imageBytes = restTemplate.getForObject(new URI(imageUrl), byte[].class);<br>        assert imageBytes != null;<br>        return new InputStreamResource(new java.io.ByteArrayInputStream(imageBytes));<br>    }<br><br><br><br><br>}</pre><p><strong>There are three methods —</strong></p><p>1.getJoke takes a topic as a parameter and returns a joke based on the topic.</p><p>2.getBook takes category and year as parameters, returning an appropriate book recommendation.</p><p>3.getImagetakes a topic as a parameter and requests an image related to that topic.</p><p><strong>Let’s unpack how the methods work…</strong></p><p>Dependency Injection: At the top level, using the @Autowired annotation, the class injects an instance of the AiClient interface that communicates with the OpenAI service.</p><p>Prompt: A key component for prompt templating in Spring AI is the PromptTemplate class. The class is designed to facilitate the creation of structured prompts that are then sent to the AI model for processing. Using the method Prompt create() we generate a predefined prompt in each of our our three methods.</p><p>Response: The AiResponse class holds the OpenAI AI Model’s output. The AiResponse class can also carry a map of key-value pairs providing metadata about the AI Model’s response.</p><p>Generation: Finally, the Generation class contains a String that represents the output text and a map that provides metadata about the response. In the case of our getImage method, the resulting image URL is obtained. The image is then fetched from the URL and converted into an InputStreamResource for further processing.</p><h3>Create GeneratedImage entity under models package:</h3><pre>public class GeneratedImage {<br>    private List&lt;ImageUrl&gt; data;<br><br>    public List&lt;ImageUrl&gt; getData() {<br>        return data;<br>    }<br><br>    public void setData(List&lt;ImageUrl&gt; data) {<br>        this.data = data;<br>    }<br><br>    public static class ImageUrl {<br>        private String url;<br><br>        public String getUrl() {<br>            return url;<br>        }<br><br>        public void setUrl(String url) {<br>            this.url = url;<br>        }<br>    }<br>}</pre><h3>Create SpringAIController under controllers package:</h3><pre>@RestController<br>@RequestMapping(&quot;/api/v1&quot;)<br>public class SpringAIController {<br><br>    @Autowired<br>    SpringAIService aiService;<br><br>    @GetMapping(&quot;/joke&quot;)<br>    public String getJoke(@RequestParam String topic) {<br>        return aiService.getJoke(topic);<br>    }<br><br>    @GetMapping(&quot;/book&quot;)<br>    public String getBook(@RequestParam(name = &quot;category&quot;) String category, @RequestParam(name = &quot;year&quot;) String year) {<br>        return aiService.getBook(category, year);<br>    }<br><br>    @GetMapping(value = &quot;/image&quot;, produces = &quot;image/jpeg&quot;)<br>    public ResponseEntity&lt;InputStreamResource&gt; getImage(@RequestParam(name = &quot;topic&quot;) String topic) throws URISyntaxException {<br>        return ResponseEntity.ok().body(aiService.getImage(topic));<br>    }<br>}</pre><p><strong>There are three endpoints in the controller class</strong></p><ol><li><strong>/api/v1/joke : </strong>It will tell a joke based on the topic you provide.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySVjdwQ9hniCbYWCXlzjtw.jpeg" /></figure><p><strong>2. /api/v1/book :</strong> It will give you details of a book recommendation based on the category and year you provide.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9J7bYz8P8eFTLGVfN4Q6A.jpeg" /></figure><p><strong>3. /api/v1/image :</strong> It will generate an image for you related to your description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F26QGaG9LbE_qlM87r7e-Q.jpeg" /></figure><p>Spring AI is magnificent. Hopefully, this tutorial has shown how it makes simple work of integrating a Spring application with AI. It is safe to say, that if you’re a developer who is familiar with Spring, and want to build generative AI in your applications, then Spring AI is indispensable.</p><h4>About the author</h4><p>Bradley Clemson is a Java Developer here at <a href="https://www.version1.com/">Version 1</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dce717e38526" width="1" height="1" alt=""><hr><p><a href="https://medium.com/version-1/building-a-generative-ai-application-with-spring-ai-dce717e38526">Building a Generative AI Application with Spring AI</a> was originally published in <a href="https://medium.com/version-1">Version 1</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Evolution of AI: Unleashing Prediction and Imagination]]></title>
            <link>https://medium.com/version-1/the-evolution-of-ai-unleashing-prediction-and-imagination-26a3321a07cc?source=rss-9b66da66d8c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/26a3321a07cc</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Bradley Clemson]]></dc:creator>
            <pubDate>Mon, 04 Sep 2023 16:51:07 GMT</pubDate>
            <atom:updated>2023-09-04T16:51:07.665Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ixJ8q58tDtikp-yfkOfD7g.jpeg" /></figure><h3><strong>What is Artificial Intelligence?</strong></h3><p>In short, it is the science of teaching machines to learn. Rather than handcrafting a set of rules (“if this, then do that”), we want to get an AI system to learn a representation of what is useful or productive in some environment itself.</p><h3><strong>What is a Large Language Model?</strong></h3><p>It is a category of AI, specifically a vast deep learning network which has been training on many billions of words on the open internet. A prominent application of such models is sentence completion, wherein you provide an initial input, and the model predicts the most likely succeeding word or sequence. It is the dominant approach which has taken over in the last 3–4 years or so, with the GPT series by OpenAI and Google’s Bard being prime examples which all harness large language models or various flavours of the same infrastructure.</p><h3><strong>The Next Wave</strong></h3><p>AI technologies have the potential to take real-world actions. The previous wave of AI primarily centred around classification. Over the past 10–15 years, the focus has been on deep learning systems mastering the art of object and image recognition, audio transcription, and language comprehension. This process fundamentally revolves around classification, organisation, and structuring — creating meaningful categories.</p><p>Now, armed with the proficiency to classify effectively, these AI models can advance beyond and into the realm of prediction. Prediction is a prerequisite to taking actions, as before doing something in the world you imagine, you simulate, you plan. For instance, before going to the train station you lay out the route in your mind and make predictions on what the weather is going to be like, is the route going to be busy and are you going to get there in time?</p><p>This sequence of activities underpins human creativity, allowing us to envisage a whole range of possible outcomes. This capability to imagine these scenarios and subsequently select a course of action, ultimately enabling us to engage with and influence our environment — that is intelligence in action.</p><p>Now experts are trying to infuse this intelligence into algorithmic constructs and if this becomes accessible to many people it will bring in the <strong>MOST</strong> <strong>productive period in human history</strong>. It would enable everybody to take actions and intervene in the world in very new and novel ways. Especially in terms of creativity and invention, with millions of individuals capable of creating new innovations.</p><p>But of course, the flipside is, if you design those systems to have certain capabilities like autonomy or the ability to self-modify goals and act independently of human beings, that’s when they could potentially be very harmful or dangerous.</p><blockquote><a href="https://www.safe.ai/statement-on-ai-risk">“Mitigating the risk of extinction from AI should be a global priority alongside other societal-scale risks such as pandemics and nuclear war.”</a> <br>— Centre for AI Safety</blockquote><h3>Containment</h3><p>If you don’t start from a position of fear, then you probably aren’t paying attention. We find ourselves at the mercy of relentless exponential technological advancements. As technologies become more useful, they also become easier to make, more user-friendly, and cheaper to use, causing them to spread far and wide. This is extremely true in the context of software, which is unburdened by the traditional constraints of the physical world. Software can be easily moved around on the web; it is an idea, so it spreads even faster than a physical invention like a motorcar. If everything defaults to getting cheaper and easier, then we must contend with power in using AI to take actions in the world, being very widely available to many, many people.</p><p>Our intuitive understanding must keep pace with the rapid technological progress, and AI companies should willingly commit to subjecting their work to independent audits and sharing best practices. The <a href="https://www.europarl.europa.eu/news/en/headlines/society/20230601STO93804/eu-ai-act-first-regulation-on-artificial-intelligence">European Union’s AI Act</a> seems to be moving in the right direction. Their approach mandates AI developers to proactively assess the potential risks of their applications. If these risks surpass a certain threshold, developers must disclose the data upon which their AI systems were trained and how these models operate.</p><p>From a personal standpoint, it is imperative that we all embrace the idea of AI and its capabilities. The belief that AI is too complex to understand is nonsense, as AI is entirely accessible. Countless online videos offer a comprehensive understanding of AI systems within just a few hours of viewing. We should all strive to gain proficiency in AI because it is fundamental to its containment. To be effective stewards, we must grasp the fundamentals of what we are dealing with.</p><p>Artificial Intelligence, in all its forms, is a tool and one that will have countless applications tomorrow and in the future. If you want to find out more about what AI can do for you and your business, contact <a href="http://www.version1.com/">Version 1</a> today.</p><p><strong>Bradley Clemson is a Java Developer at Version 1.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26a3321a07cc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/version-1/the-evolution-of-ai-unleashing-prediction-and-imagination-26a3321a07cc">The Evolution of AI: Unleashing Prediction and Imagination</a> was originally published in <a href="https://medium.com/version-1">Version 1</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>