Tales from the jar side: Spring AI, Streaming requests, Heaven Can Wait, the Great Unsubscribing, and the usual tweets and toots
Scientists are studying the effects of cannabis on sea birds. They've left no tern unstoned. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of June 30 - July 7, 2024. This week I taught week three of my Spring AI course on the O’Reilly Learning Platform.
Regular readers of, listeners to, and video viewers of this newsletter are affectionately known as jarheads, and are far more intelligent, sophisticated, and attractive than the average newsletter reader or listener or viewer. If you wish to become a jarhead, please subscribe using this button:
As a reminder, when this message is truncated in email, click on the title to open it in a browser tab formatted properly for both the web and mobile.
Spring AI
I taught my second course on Spring AI this week. I talked a lot about it in last week’s newsletter, trying to deal with the massive amount of changes that happened between 0.8 and 1.0.0-M1 (milestone 1). I put a lot of time into it, plus I had access to Craig Walls during my prep, and since he’s writing the Manning book called Spring AI in Action, that was quite helpful.
(His book’s website is basically a placeholder at the moment. You can’t buy the book yet. I can assure you, however, it’s on its way. )
I spent a fair amount of time after class cleaning up my Spring AI Examples repository on GitHub. I’m particularly happy with my example of function calling, which is quite similar to an example I created for LangChain4j. If you’re curious, take a look inside the functions
package under both src/main/java
and src/test/java
, especially the ExchangeRateFunctionTest
. The RAG example inside its corresponding package is also decent.
With all the prep, the class went fine, though I’m glad I spent the time. I don’t think the class would have worked out otherwise.
As an update, last week I mentioned that the Spring release calendar suggested that the final release of Spring AI 1.0.0 was going to happen on Tuesday, July 2. Yeah, no, that didn’t happen. The calendar has been updated, however. Now the Milestone 2 release (Spring AI 1.0.0-M2) is scheduled for July 23, and the 1.0.0 release is supposed to happen August 26.
Hey, it could happen. We’ll see.
Async Requests and Responses
Getting back to my own book, whose working title is Adding AI to Java, I’ve been working hard on rewriting the chapters and creating separate projects for each chapter and each AI client. The chat chapter now has separate projects for OpenAI, Mistral, and Claude, for example.
I also wound up adding an appendix. I got a question from one of the reviewers about setting environment variables, and while most developers know how to do that, it seemed like a good idea to add a couple of pages to be clear about the process on multiple different operating systems.
As for learning something new, I finally realized I’d been doing something wrong, or at least incomplete, all along. So far, I’d always modeled the chat request based on this example, shown in the OpenAI documentation:
There are some optional parameters, like temperature or max_tokens, that I included in my corresponding Java record.
What I missed is shown in the corresponding “Streaming” example:
See that extra parameter, called stream
? I totally missed that, and then couldn’t figure out why, when I tried to access an asynchronous result, it looked like I was only getting one request/response pair. Turns out I needed to set stream
to true
in order for it to operate a few tokens at a time, like you get from the web site.
Mistral has the same parameter, which isn’t surprising since Mistral uses OpenAI’s API overall. It turns out Claude has the exact same parameter as well. Google’s Gemini does things differently, because Google. They use an endpoint called streamGenerateContent
instead of just generateContent
, but otherwise it looks the same.
I spent way too much time on this, but I got examples working for both Claude and Ollama. I used the Ollama API because that one defaults to streaming, as odd as that is. I’ll probably add this info to the Ollama chapter, but we’ll see. I have a feeling that the streaming API might be the first section to get cut when the book starts getting long, which it’s already starting to do. I’m sure my editor will have something to say about that.
Heaven Can Wait
One of my all-time favorite movies is Heaven Can Wait, the Warren Beatty classic from 1977. It’s a fantastic romantic comedy with an incredible cast: Warren Beatty (who starred, co-wrote, co-directed, and produced), Julie Christie, Dyan Cannon, Charles Grodin, Buck Henry, and James Mason in a fantastic role as Mr. Jordan.
If you don’t know the movie, the basic idea is that Joe Pendleton is a backup quarterback for the Los Angeles Rams about to get his first start, when he’s involved in an auto accident and, supposedly, dies. It’s all a mistake, however, and he has to be returned to his life, but unfortunately his body has been cremated. Therefore, in order to come back, he has to take the body of another man who has died but whose death has not yet been discovered.
I don’t think that description remotely does the movie justice. It’s absolutely fantastic, and if life these days is causing you too much stress (and isn’t that everybody right now), go out of your way to see this movie and you’ll feel better. It’s currently available on both Amazon Prime and Paramount+, at least here in the US.
Why am I bringing up a movie that’s nearly 50 years old? First, I saw it again recently (for the first time in about 30 years) and it’s still awesome, and second, they mentioned a date in the movie that surprised me.
When Pendleton keeps insisting that he’s not supposed to be at the way station to his final destination (presumably heaven), Mr. Jordan decides to check. He has a great line about that, btw: “The likelihood of one person being right rises in direct proportion to the intensity with which others keep trying to prove him wrong.”
The response is: “Joe Pendleton, scheduled to arrive here at 10:17am, March 20, 2025.”
Whoa! That’s not even a year away. I’m sure when they made up that date it seemed forever in the future, and it certainly felt that way to me when I first saw it. Now it’s happening in about 8 1/2 months.
I don’t know how they do it, but some of the online people I follow manage to have live streams where they share watching a movie together. I have to figure out how they do that before next March, because we simply have to do a Tales from the jar side Live Stream to watch the movie together on March 20, 2025. That’s also about a week after my birthday, too.
I’ll let you know what I figure out, but don’t hesitate to watch the movie before then. Frankly, anything that gets you through the current chaos is to be encouraged.
There is one event in the movie that I view very differently now. (Warning: Spoiler alert for a really old movie.) Leo Farnsworth buys the Rams, leading to this dialog:
Former owner: He got my team. The SOB got my team.
Former owner’s friend: What kind of pressure did he bring, Milt?
Former owner: I asked for $67 million, and he said yes.
Friend: Ruthless bastard.
The Rams supposedly had a value of only $19 million (that’s million, with an “m”) at the time, so this provoked a crisis in the movie. But looking back today, this was the greatest business decision of Farnsworth’s career. According to the Forbes list of most valuable NFL teams, as of last August the Rams are worth just under $7 billion. Yeah, that’s billion with a “b”. Assuming that sale went through, it was one of the greatest bargains of all time.
(Other than maybe buying Apple in 1998 or NVidia at the start of the AI boom two years ago. But you get the idea.)
The Great Unsubscribing
Speaking of ways to try to make myself feel better, I realized I’ve been getting interrupted with depressing “breaking news” far too often. It was time to unsubscribe from as much as possible. Here was step one:
I’ve been cancelling newsletters and unsubscribing from marketing emails right and left ever since. NY Times was the biggest and the toughest — they do NOT make it easy to leave, but I’m really glad I did. I still have a couple other news publications that I’m seriously considering bailing on as well. We’ll see.
My phone and email are already much quieter, and I’m much relieved.
Tweets and Toots
Down Under
I have a few Australian friends (and friends who spent time there) I need to contact to verify this map, but it’s interesting.
How many lights?
I’d guess four or five. One of those, anyway.
Hungry, hungry hippos
I asked DALL-E 3 to generate an image of a hippo riding a bicycle in a triathlon:
Not sure what the colors are about or what the banner is supposed to say, but good enough, I guess.
Rule of 80
I think I’ve heard that before. Not a lot of data points, though, so it’s probably not surprising they line up somehow.
Capitalism Use Case
Sacrifice yourself for the economy? This week I started saying no. I still have a long way to go, however.
Communication
Does a bear hide in the woods?
Natural camouflage. For the longest time, I couldn’t find anything. Even now I’m not totally sure.
Have a great week, everybody!
Last week:
Spring AI, on the O’Reilly Learning Platform
This week:
Integrating AI in Java Projects, on the O’Reilly Learning Platform
Modern Java Functional Programming, an NFJS Virtual Workshop