Author: admin

  • Day 92 – OpenAI API Structured Outputs

    For me Structured Outputs are essential when talking to an LLM. In most cases, an application needs to use data in a certain way so you want OpenAI to send back data in a specific structure, rather than having to format yourself.

    Structured Outputs (SOs) ensure an OpenAI response is structured in the way you would like.

    Prior to SOs you would use a specific prompt to get the response in the right structure.

    Parsing a Rental Property Webpage

    Let’s set a schema that will take a blurb from a Cottage Rental website and output an object …

    import { NextResponse } from 'next/server';
    import OpenAI from 'openai';
    import { zodTextFormat } from "openai/helpers/zod";
    import { z } from "zod";
    
    export async function POST(request) {
      try {
        const client = new OpenAI({
          apiKey: process.env.OPENAI_API_KEY,
          organization: process.env.OPENAI_ORG_ID,
        });
    
        const requestData = await request.json();
        const { model, input } = requestData;
    
        const PropertyListing = z.object({
          cottageName: z.string(),
          numberOfGuests: z.number(),
          numberOfBedrooms: z.number(),
          numberOfBathrooms: z.number(),
          allowsPets: z.boolean(),
          keyFeatures: z.array(z.string()),
          marketingCopy: z.string()
        });
    
        const response = await client.responses.parse({
          model: model || "gpt-4o-2024-08-06",
          input: input,
          text: {
            format: zodTextFormat(PropertyListing, "property"),
          },
        });
    
        return NextResponse.json({ 
          success: true, 
          event: response.output_parsed 
        });
      } catch (error) {
        console.error('OpenAI API Error:', error);
        return NextResponse.json(
          { success: false, error: error.message },
          { status: 500 }
        );
      }
    } 

    I can call this API crudely with something like:

        try {
          const response = await fetch('/api/openai/parse-cottage', {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json',
            },
            body: JSON.stringify({
              model: "gpt-4o-2024-08-06",
              input: [
                { role: "system", content: "Extract the cottage information." },
                {
                  role: "user",
                  content: `webpage html here`
                },
              ],
            }),
          });
    
          const data = await response.json();
          
          if (!data.success) {
            throw new Error(data.error || 'Failed to parse cottage');
          }
          
          setEvent(data.event);
        } catch (err) {
          console.error('Error parsing event:', err);
          setError(err.message || 'Failed to parse cottage');
        } finally {
          setLoading(false);
        }
      };

    The response I get is

    {
      "cottageName": "Point Break",
      "numberOfGuests": 8,
      "numberOfBedrooms": 4,
      "numberOfBathrooms": 3,
      "allowsPets": true,
      "keyFeatures": [
        "Beachside location",
        "Contemporary interiors",
        "Part of The Dunes development",
        "Traffic-free location",
        "Open plan living",
        "Floor to ceiling windows",
        "Balcony with ocean views"
      ],
      "marketingCopy": "A beautifully finished beachside house over three floors with contemporary interiors to the highest standard. Part of The Dunes development located directly in front of the beach. Tucked away in an almost traffic-free location. Open plan living, dining and kitchen space on the 2nd floor, taking advantage of the breath-taking views over the golden sand dunes, beach and Atlantic Ocean. The spacious living area comprises of two large sofas, TV, DVD player, coffee table, floor to ceiling windows, patio doors opening onto the balcony."
    }

    So, what that’s done is convert some HTML into a JSON object that summarises the HTML. Useful!

  • The end of software engineering

    AI has fundamentally changed developers jobs. This is a really good conversation about how good AI is at building software. The reality is software engineering teams can be way smaller.

    This excerpt is AI generated

    Think of today’s AI coding agents as the “combine harvester” of software: what once took whole armies of engineers hand-tilling every line of code can now be done in minutes by supercharged bots, letting founders and small teams build, ship and iterate faster than ever.

    Suddenly, building an app no longer means wrangling legacy stacks for months—tools like Claude Code, Cursor and Windsurf let you dream up features, prompt them into existence, then sip your coffee while the AI auto-writes the boilerplate and infrastructure. It’s not about replacing creativity, it’s about amplifying it: with lower costs and higher velocity, you can focus on obsessing over real human problems (the skill that will always outlive any algorithm).

    The upshot? In five years, “software engineer” will mean someone who knows how to choreograph AI agents, not who types every function by hand. So don’t wait for the bots to leave you behind—embrace these tools now, level up your agency, and join the next wave of founders riding this revolution. (Fun fact: when Rome outsourced too much to mercenaries, it crumbled—so always keep core skills sharp!)

  • Days 85 – 91 – Dropped into a part-time shit storm and extracting myself from it.

    Days 85 – 91 – Dropped into a part-time shit storm and extracting myself from it.

    100 days ago I decided to focus on becoming an AI startup. I gave myself a time limit (five months left) to demonstrate to myself that I could get something up and running.

    I was getting somewhat anxious about having no income coming in, so six weeks ago I took on a part-time freelance project for a company that was switching their booking system.

    I had planned for a nice ongoing earner with 1.5 days a week worth of work. Giving me plenty of time to focus on AI stuff.

    What actually happened, was I got dropped into a shitstorm.

    That said, I got them launched, and have backed out now. I won’t go into details to spare them the blushes, but did think I would write some generics about IT project management.

    Why IT projects go bad, and what to do when they do.

    Software projects can essentially have infinite scope. There is always something that can be tweaked or added. Add business management to the mix and they will demand a long list of features …

    1 – You didn’t clearly agree scope with all stakeholders at the beginning, and get them to sign off on it.

    All parties have a responsibility to be as clear as possible what the project is going to do. With money changing hands it’s absolutely essential.

    If you are just prototyping, it’s slightly different.

    You would rarely start builders on a home project without seeing some form of work blueprint.

    In my early career, I ignored scope and most of the time I got away with it. But as soon as it’s something more complex, it became essential.

    The work spec is essential because:

    • You can protect yourself when the customer asks for more than they are paying for. As soon as the customer says, ‘well I thought I was getting X, I really need X’ … you can direct them back to the initial agreement. ALWAYS build what was initially agreed, release that, and then build the new feature afterwards.
    • If done correctly, the work spec will force the thinking in the development team of HOW they are going to implement it, broadly speaking, and so the system architecture begins to form.
    • New management or developers don’t know where they are without the work specification.
    • Leads to increased probability that the cost is accurate
    • The customer is forced to think what they actually want

    Don’t mistake flowcharts for a specification. Documenting scope is a skill. Flowcharts are an essential part of the spec, but they still don’t describe what is being built.

    2 – The initial scope was wildly excessive, or the customer adds ongoing scope throughout the project (and you let them)

    Since software scope can be infinite, it’s easy for a customer to say they want everything. Writing a work spec helps against this, but if you don’t really think about the potential detail involved you’ll get the cost wrong.

    In most cases, a good developer should identify the handful of functions that actually represent the core USP of the system.

    If you are building a new product from scratch, always identify the very core of what you are trying to do and focus on that. Get those shipped and out there, and begin testing from there.

    If you are halfway through a project, the BIGGEST problem I’ve always found is that management will add onto the scope rather than goto launch. They will insist feature A needs to get done with some essential feature. This becomes a habit and the product NEVER gets launched.

    I worked on a project for two years and toward the end, management kept asking for more features … AND I LET THEM (at price)… I was naive … and eventually upper-upper management came into the project, the manager demanding the new features said ‘they haven’t finished’ … upper management got cold feet and pulled the project. We were so close to releasing a product that was perfectly timed to do well in the real world. Yet, it failed to launch because scope kept getting added.

    3 – The developer never documented the system

    This is a big one. Doesn’t seem it at the start, but eventually you need to bring other developers in… do you really want to explain repeatedly how the system works?

    Documentation should be as concise as possible. You will get egos in the team who think they demonstrate their intelligence by producing a 100 page spec that no-one is ever going to have the time to read.

    Documentation isn’t the initial project scope. A lot of programmers say that the code should explain itself. It’s correct, but also misses the point. Large codebases should be described (AI can help a huge amount now) … there’s always things that fellow developers need to know.

    4 – You are building on a system that is shit

    This is something that isn’t easily fixed. When you are working on a system that hasn’t been thought through properly; and just been cobbled together over the years… it really does become a major problem. Developers don’t want to work on it, they get stressed and they will mimic the state of the codebase by taking further shortcuts. And the problem compounds itself.

    5 – You are under-resourced

    There’s no way around it. If you don’t have the money to build your system then you will suffer. And if you are a technical founder, if you don’t have the time … then you are not going to get there either.

    You avoid this by:

    • Being very clear about what you want and don’t want
    • Your scope is realistic
    • Your work brief has identified how much it will REALISTICALLY cost by working out how to do it

    If you are deep into a project and money has run out… it’s generally because you’ve messed up further down the line. The main thing you can do is give equity away to a decent developer and ask them to work at minimum wage for a while on it, to bring it up to the correct level.

    Or, you just take out another credit card, but you get very clear about what you are doing or not doing.

    6 – Poor communication (too little or too much)

    The main problem with this last freelance project was that the two developers weren’t successfully communicating via emails. They were working, effectively, in different timezones … when I came in, I was able to bridge that gap and in just a few calls I had resolved blockages that had been around for quite a while.

    Emails are not the best form of communication. You really need to have developers talking to one another and sharing screens so they can properly explain their problems.

    So that was under communication which was the problem.

    Then you can get the over communication, where you get dumped with a ton of stuff that doesn’t matter … often information that should really be in a Google Doc that can be referenced. If you add to the mental overhead of a developer, the developer will have a drop in productivity. So often you just need to keep the technician focused and protected from the business decisions going on around them.

  • Days 79 – 84 Sugar!

    Am approaching launch on a web project that’s been a bit of a distraction to the AI efforts; but things are moving forward slowly.

    The truth is, I’ve been tired for the last month or so. I’ve really upped my output. But I’ve come up against my own energy levels. I’ve known for a while that I’ve needed to look at my diet and have made some good inroads in it.

    Last winter I removed caffeine from my life. No coffee, no tea. Five years ago I stopped drinking alcohol.

    Almost all major changes in life come about through fundamental paradigm changes.

    The past week my paradigm change has been around sugar. What’s this got to do with building an AI startup? To simplify the answer I would say it’s about energy. I’ve noticed how tired I’ve been getting – mostly mentally – over last month.

    This led me to point of realisation where I actually genuinely want to change what I eat. When you hit your 40s, your body starts slowing down if you haven’t looked after it.

    What is sugar?

    Coming from the sugar cane plant … the plant is then refined – stripped of all original fibre, minerals and vitamins – leaving a white crystalline structure that is very sweet and most importantly, soluble – which means it can be added to almost anything.

    Our bodies love the taste of sugar

    In some grand form of intelligent design, nature made fruits that are good for us, taste good. Natural sugar. So we like the taste.

    Big food industries realised they can hijack our natural taste for good natural sugar… with refined sugar … which became the trojan horse that allows it into our life.

    When you eat it, what happens?

    So, you get a high, followed by a low. You ingest something which has zero nutritional value and it completely disrupts your sugar levels. It’s high carb level means you probably won’t burn it off and it just gets stored as fat.

    … and that just leads to diabetes, heart disease and in general a life of lower vitality.

    The crazy thing that I’ve realised in the last week is how much bad sugar is in everything I’ve been eating my entire life. It’s not just the junk food; it’s any processed food, bread, rice, wheat, pastries … literally everything.

    Triggers

    It’s really useful to know what triggers cause you to reach for any sugary stuff:

    • boredom
    • sadness
    • stress
    • routine
    • reward

    The brainwashing

    What I’ve learnt this week, which seems obvious now, is that

    • anything with bad sugar in, is pretty much tainted with poison.
    • most of the food i’ve been eating, isn’t even food

    So, it’s no wonder that my body has started to ache and slow down; I am just eating actual food. It’s a wonder my body has managed to last this long. But it’s time to sort it out.

    So … a sandwich.

    Popular snack right? Often pushed as a lunch for busy people. Throw a bit of meat in there and a salad and you get a nice sandwich. But the bread isn’t really food. What sort of nutrition do you actually think the bread has? It has sugar in it, so it’s somewhat poisonous.

    Most will totally disagree. I would try to justify the bread. But anything with sugar in, by it’s very nature is going to damaging to your system. IT’S NOT FOOD!

    Absence of willpower

    There is a well known method of removing addictions that relies on changing perception rather than using willpower to stay away from the thing that is damaging you.

    I am talking about the unnatural sugar – the refined sugar that is present in everything. It messes seriously with your body to the point that it is responsible for killing millions of people every year. It is one of the things that we don’t talk about as a society, probably because most of us are unaware.

    We think we get pleasure from some foods mainly because of the high that we get immediately from foods with sugar in. So it fools us.

    It’s exactly the same as other addictions:

    Caffeine

    The main lie about caffeine is that it gives you energy and that it’s non-addictive. Caffeine has zero nutrients in it, and stresses your body out to produce an anxiety that feels like energy but actually frazzles you.

    Alcohol

    Alcohol is lied about too. The wonderful social aspect of alcohol is is a lie – it takes the credit for the endorphins that get released when humans socialise. But alcohol is an empty, meaningless liquid that has zero benefits.

    So what’s the lie about sugar:

    • We generally don’t consider it addictive
    • We know it’s ‘bad’, but we don’t realise HOW bad
    • We accept it’s added to foods, but don’t really pay attention
    • We accept it’s added for taste
    • The pleasure that we supposedly get from anything sugary is false – it’s just the food industry hijacks your natural taste buds for foods that are actually good for you
      • Also it raises sugar levels and gives you a brief high and then a crash …
    • We dont realise we develop a tolerance for it

    The big thing with sugar is that it creates its own demand. It leaves that anxiety that only it can fill. But the only solution is to remove that ongoing source.

    Enough for now.

  • Day 77 & 78

    As I continue to use AI in my work I increasingly know my world has changed fundamentally.

    Today I had to come up with a quick way of holding booking information, and be able to export it to CSV.

    Fairly standard stuff but in an unstructured codebase i.e. vanilla no framework, it’s a bit of a pain with what I have to work around.

    So I manage to get the data into the database fairly simply.

    Well, what about just a UI so that the customer can quickly look at whats going on in that DB rather than download it manually and open the flatfile.

    So I ask Cursor to help me out.

    Within a few minutes it’s made a UI that did the job, with a CSV export to boot.

    I will say that at one point it did some very stupid things in the code which I had to go and tell it ‘bad, please fix’ … but it quickly remedies.

    The more I use Cursor the more I realise that it is GREAT … BUT you need to know what you are doing so you can spot things. Potentially when I experiment with MCP it would have tested this itself, worked it out and remedied. But i’m not at that stage yet.

    It’s obvious that AI mimics intelligence really well, but the current LM stuff really doesn’t *think* at all; but sort of spoofs thinking. At any rate, if you are mid to senior developer it’s a phenomenal tool that you can make some really impressive stuff with.

    I have no idea really how this technology actually manages to do what it does. From the most vague prompt it can pretty much ‘understand’ my meaning, and give me what i’m looking for.

    We are the last generation to know what life was like before language models! Something to ponder on!

  • Day 76 – Recent Progress

    Last six weeks I’ve been working on some client work. It’s so difficult to do this and still have enough time to focus on your own stuff at the same time.

  • Day 75 -Emails With AI

    The system I’ve designed is capable of indexing and tagging emails. Just need to build the module that grabs them via IMAP. But emails really annoy me. They are incredibly unstructured and they allow anyone from ‘the internet’ to take up my time often with completely unstructured, poor quality information delivery.

    I’ve said quite a few times that language models are really primed for abstracting information away from people; and providing it to them in a much more synthesised fashion. As the amount of information increases exponentially, and the more busy you get the more shit you need to deal with.

    Hence, language models having excellent potential for emails. Not necessarily writing emails. I’ve sent a few emails that have been completely AI driven, and I always felt a bit sick afterwards. It just feels completely non genuine especially when they to people I know. But the idea of having an assistant that tracks incoming information, assessing and categorising them according to your training, this is a nice idea.

    Obviously already done and out there as a service; but the market will be extensive since everyone will have their own VA eventually.

  • Day 72 -74 Of Building An AI Startup

    A lot of my time and mental energy recently has been taken up with some paid work. But during that time I’ve made a lot of use of Cursor, now my goto IDE. It definitely makes me more capable and when I get stuck it can spot obvious mistakes which happen to the best of us.

    Overall, things are going well.

    My energy, attitude and work rate compared to day 0 are way better. I’ve had a few blips for sure.

    Building a team

    I was reading this week that the most effective companies are going to be small teams of senior experienced / C-Suite level thinkers and doers; working together toward building something.

    Employing people in the UK is incredibly expensive. I have no idea what junior level people are going to do anymore. The ones that work hard and compete, will do fine as always; but there will be a huge drop off of demand.

    Building an automated company

    The tools are now here to automate actions that are regularly taken in a company. It might be just the signing up of a customer to various systems, that are manually done. It might only save a few minutes but it means someone doesn’t need to context switch. So it’s not just the time saved, it’s also the mental energy saved.

  • Day 71 – Sora !

    For today thought I would just add my first Sora video.

  • Day 70 – AI makes you a 10x more useful programmer.

    Day 70 – AI makes you a 10x more useful programmer.

    Today was a breakthrough day.

    I needed to collect some data from two sources and cross-link them.

    I was able to use Claude 3.7 to generate several python scripts that used Playwright to crawl a site, intercept a script call and grab a particular value from it, and insert it somewhere else.

    Claude was able to generate the python scripts for me.

    I wouldn’t be able to do this without spending a long, long time learning python and how to use some of the libraries.

    So, another win for “AI”.