Tales from the jar side: "Hidden" JSON fields from AI services, Giazotto vs Albinoni vs Bach/Gounod, and the usual toots and skeets
My wife and I laugh at how competitive we are, but I laugh more. (rimshot/chuckle)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of February 16 - 23, 2025. This week I taught my Managing Your AI-Driven Manager course privately, I gave a similar talk at the Atlanta Java Users Group, as well as my regular courses at Trinity College (Hartford).
Accessing “Hidden” Values in AI Responses
I’m planning a video on this very niche topic, but it looks like I’m not going to complete it before this newsletter goes out, so let me describe it here. That will hopefully help me get my thoughts in order, and maybe help the tiny handful of you that might possibly encountere this problem.
If you want to access an AI tool programmatically, the first thing to realize is that they’re all REST-based web services. In other words, you send HTTP GET and POST requests to them, include JSON data when necessary, and process the HTTP responses, which also contain JSON data.
Over the past year or so, several conventions have emerged to make that process easier. One is that lots of services implement the OpenAI libraries in Python or JavaScript for their own service. That way you don’t have to handle the networking yourself, nor do you have to parse or generate JSON data manually.
Or, rather, you mostly don’t. The thing is, while the AI services claim they use the OpenAI API, they have a tendency to add to it.
For example, here’s the web page from Perplexity:
See how it actually says “OpenAI client-compatible” right up front? It’s true, and the request looks exactly like one for ChatGPT. The response, however, is a bit different:
See that highlighted tag in the response, called citations
? That’s unique to Perplexity. That’s one of its best features, actually, since it’s trying to tell you where it got its answers, and that’s a good thing.
The hot new DeepSeek model does the same thing. It says it’s OpenAI-compatible:
The thing is, if you use the reasoning model, the response adds a new property, called reasoning_content
:
That’s all fine, of course. If you’re writing code in JavaScript or Python, you can get back that JSON data and just drill down manually to get those additional fields.
It’s Java that provides a problem, especially when you use it with one of the major AI frameworks, LangChain4j or Spring AI. Both of those frameworks do a ton of work for you, and that includes handling the networking and mapping the JSON inputs and outputs to classes. That’s a great time saver. The frameworks also provide many additional features, like chat memory, function calling, and RAG support, all of which are really helpful.
What they don’t have, at least not at the moment, is an implementation of Perplexity or DeepSeek chat models that would include the additional output quantities. You can use the OpenAI chat model for both, and I do, but each ignores those extra fields because they don’t exist in the OpenAI API.
So what do you do? In the past I’ve remapped the input and output classes as necessary. That’s rather tedious, though. As it happens, there’s a much easier solution, based on two ideas:
Both frameworks already have a networking library built in. For LangChain4j, that’s the OkHttp library. For Spring AI, its their own
RestClient
class.Both also include JSON parsing and generating libraries. In fact, they both use the Jackson JSON API for that.
If you’re using one of the frameworks, you can take advantage of those libraries to make a manual network call and then extract the data you need. For example, here’s the networking call using OkHttp:
And here’s how you dig into the JSON data:
That’s basically all there is to it. It’s a bit more work than just using the framework directly, but you get what you need, and you can take the results and feed it back into the framework classes.
Anyway, I’ve got the code working and a rough script. I just need to record the video. Hopefully that will happen this week as I prepare for the Devnexus conference that follows.
The Tragedy of Remo Giazotto
Over the past few months I’ve spent a lot of time listening to classical music. I’m not sure what triggered that, other than a growing appreciation for the beauty of the music and the skills of the great masters. I’m at the stage in my life where I’m not concerned with the pretentiousness or perceived elitism of classical music — I just know what I like. I don’t care if I’m supposed to like it or not. I enjoy the music for its own sake, at least until I get tired of it.
To understand more about what I’m hearing, the Claude AI tool has proven to be a helpful companion. I’ve had many conversations with Claude about the history and background of various pieces, or what the composers were doing at the time, or why this piece is really well-known while that one is not. As long as I check any factual information before believing it too much, it’s nice to have a well-read (well-listened?) service I can talk to and ask whatever questions I like.
A few weeks ago I was listening to a playlist in the car when I saw a piece identified only as Adagio in G minor, without an identified composer or performer. That’s not all that surprising — the regular music services are terrible about classical music. They have no conception that you might care about the name of the work, as well as its composer, its year, the conductor if it’s being performed by an orchestra, and maybe more.
I asked Claude, and apparently I’d stumbled across one of the great mysteries in classical music.
First, here’s a good recording of the Adagio in G Minor, attributed (we’ll get to that) to Tomaso Albinoni:
Remo Giazotto, an Italian musicologist and Albinoni (1671 - 1751) scholar, claimed that he “reconstructed” the piece from a fragment of a manuscript by Albinoni that Giazotto discovered in the Dresden State Library that was bombed during World War II. Rediscovering lost baroque works was all the rage at the time, and this was a really good one. He published the work in 1958, and collected royalties on it for the rest of his life.
The problem is, no trace of that original fragment has ever been found, and no known inventory of the Dresden Library includes it. It’s also not typical of Albinoni’s style. The current thinking is that it was almost certainly composed by Giazotto, who attributed it to Albinoni at the time, and published it under his own name rather than Albinoni’s, and stuck with that claim for the rest of his life, though some people say he admitted privately to writing it himself.
The thing is, this piece is by far the most famous work from Albinoni ever, and he probably never wrote it. Admittedly, most of Albinoni’s work has been lost over the centuries, but he would still be an obscure baroque composer if not for this one piece. Then we have Giazotto, who was a musicologist of some note. He probably cranked out the ultimate classical One Hit Wonder, and never got credit for writing it.
The mystery is whether he composed or not. My question, though, is more about the “why” issue. Why produce such a masterpiece, but give away all the credit? Was he afraid no one would listen to his own music, despite its quality? Did he think using another composer’s name would lift it to enough fame that he would be respected more? Was he just after the royalties? After all, if Albinoni did write it, it would definitely be in the public domain by now, while a copyright of 1958 would still be running, depending on the country.
The thing is, there was a precedent he could have followed. Here is an absolutely gorgeous piece, entitled Ave Maria but with the composers listed as JS Bach and Gonoud:
Isn’t that wonderful? If you prefer violins to cellos, here’s a great alternative:
I wanted to know why it was listed as being written by two composers who lived over a century apart, so again I asked Claude about it. It turns out the piano piece is one I recognized: it’s Johann Sebastian Bach’s Prelude No. 1 in C Major (BWV 846) from The Well-Tempered Clavier, Book 1, published in 1722. Charles Gounod was a French Romantic composer, and in 1853 he heard Bach’s prelude and improvised a melody over it. Eventually it was arranged for voice and piano and someone added the Latin words to Ave Maria, and the rest is history.
The thing is, Gounod published the piece under both his and Bach’s names together. It’s really obvious who did which part when you think about it, and Gounod’s addition works so incredibly well it’s almost like he revealed a melody hiding in the original prelude. Though Gounod eventually became famous for his opera Faust, he’s probably more well-known today for this Ave Maria.
All this mean that Giazotto had a model to follow. All he had to do was to publish his Adagio under both names and he would have been fine. I mean, why not? He certainly did enough to warrant co-authorship. Would musicologists have harassed him more or less over which composer wrote which parts? I don’t know. I think you could make a case either way.
Honestly, though, I wonder about something else. As I’ve gotten older, I realize more and more how unreliable memory is, especially if you’ve told a particular story over and over. I remember Douglas Adams telling the story of how he came up with the idea for the Hitchhiker’s Guide to the Galaxy series of books, and admitting he was no longer sure what the true story was anymore.
Was that what happened to Giazotto? He was an Albinoni scholar, and did extensive research on his works. Did Giazotto have the main theme from the Adagio in his head one day and convince himself he’d seen a fragment of it in Albinoni’s works somewhere, but he could no longer find it?
I still think he should have included his own name, though. That would have removed some of the mystery, but also a lot of the ethical issues and credibility questions he faced the rest of his life.
Toots and Skeets
Stand back
They could have saved themselves a lot of trouble by cremating him.
They’re all good dogs
Opposable thumbs would probably help, but maybe not.
Too many examples to count
The examples just keep on coming, but don’t worry. I’m not getting into politics this week.
Software development jobs
This was originally going to be my big topic this week, but I ran out of room. Let’s just say the big changes have been due to:
Over-expansion during the pandemic.
Rising interest rates (from about 0.25 up to 5.5)
Generative AI
Teasing out the individual contributions is going to take some time, but we’ll see.
Here’s a direct link to the article if you’re interested.
Pride
Works for me.
It’s a trap!
Some people just want to see the world burn.
Perspective
Probably the new Captain America movie, from what I hear.
Sure, I’d believe it
Gotta be better than the truth.
On a similar note
Might want to think that one through.
Crafty
Again opposable thumbs, etc, but okay.
And finally:
He was a good kid
Definitely needs a rimshot.
Have a great week, everybody!
Last week:
Managing Your AI-Driven Manager, my talk at the Atlanta Java Users Group
Help Your Boss Help You, private class
My regular Trinity College schedule
This week:
My regular Trinity College schedule