Tales from the jar side: Perplexity citations, an Image carousel, Flying to Bluesky, Election thoughts, and the usual tweets, toots, and skeets
I couldn't figure out whether someone was waving at me, or the person behind me. In other news, I lost my job as a lifeguard. (rimshot)
Welcome, fellow jarheads, to Tales from the jar side, the Kousen IT newsletter, for the week of November 3 - 10, 2024. This week I taught my Spring AI course on the O’Reilly Learning Platform and my regular courses at Trinity College.
Perplexity Citations
I recently published a video talking about how Perplexity AI, the search engine aiming to replace Google (an ambitious goal if there ever was one), had as its best feature the fact that it cites its sources. When you ask a question, it crawls the web, summarizes the results, and adds footnotes for each statement.
Since then, both Google and OpenAI have released a similar capability, so we’ll see how it goes in the marketplace.
What’s interesting to me, however, is that this week Perplexity announced that those citations were going to be part of the programmatic interface:
As documentation, this would be described as “a little thin”. Seriously, it doesn’t even tell you how to access those citations, and the API documentation itself hasn’t yet been updated to include them.
The first step is to run a simple example in Python and print the entire response, so you can see what they have in mind.
This is the example Perplexity shows on their Getting Started page. When you run it, the response includes:
ChatCompletion(id='59ab9cdb-6380-4bb3-ae76-062ae2d7a5a0', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='Estimating the exact number of stars in the universe is a complex task due to the vastness and complexity of the cosmos. However, based on various astronomical observations and studies, here are some estimates:\n\n1. **Astronomical Estimates**: \n - The Sloan Digital Sky Survey estimated about 48 million stars in a third of the observable sky[1]...', ..., usage=CompletionUsage(completion_tokens=319, prompt_tokens=31, total_tokens=350), citations=['https://www.space.com/26078-how-many-stars-are-there.html', 'https://bigthink.com/starts-with-a-bang/overestimated-stars-in-universe/', 'https://www.esa.int/Science_Exploration/Space_Science/Herschel/How_many_stars_are_there_in_the_Universe', 'https://www.astronomy.com/science/astro-for-kids-how-many-stars-are-there-in-space/', 'https://skyandtelescope.org/astronomy-resources/how-many-stars-are-there/'])
If you look at the entries in bold, you’ll see that now the output JSON data includes a field called citations
, which is a sibling of content
and usage
. The citations field contains a list of string URLs to the different sources. The references to the citations are embedded as numbers inside the text.
That means if you want to code in Python, you just write something like:
That shows the answer, followed by a numbered list of references.
That’s all well and good, because Python has weak, dynamic typing. You don’t have to declare a variable before using it, and you don’t need to know its type until runtime. That’s fine if your entire system is written in Python, but that’s not the world I live in. While Python is pervasive in the AI community, it’s rare outside of that. Most real world systems run on Java or some .Net language. If I want to access AI tools from there, I’m going to have to do a bit more work.
In the video, I discuss how to map Java records to the input and output JSON structures, including the new citations list. Then I use Java’s own HTTP library (added in version 11) to transmit the requests and receive the responses, and I use Google’s Gson library to parse and generate JSON data. It all works, and was less work than that sounds, and it’s a useful technique to know.
Look for that video to come out this coming week.
An Image Carousel
I’m not good at JavaFX. I was pretty good with Java Swing, but that’s long been out of favor relative to JavaFX, and I like to at least try to use the recommended tool kits. My students in my AI Integration course at Trinity College (Hartford, CT) are preparing for the art show we’re having in a few weeks, so I tried to put together an app that displays images for them. The idea was to make a carousel that loads all the images from a specified directory and shows each one for three seconds before rotating to the next.
It started out pretty easy, but then I kept asking my AI tools for “improvements” and now it’s on the complicated side. At least it has some tests, though, and is not all merged into a single class.
The process also got me to work with both jlink and jpackage, which I never do, as a way to help the students run a JavaFX application on a variety of platforms. Right now the only reliable way to start it is with Gradle, but with jlink I can make a script that bundles in everything needed, and with jpackage I can even make an installer. I did that through a plugin inside Gradle. I never would have known about that without an AI’s help (specifically, the new Claude 3.5 Sonnet). That also forced me to use Java modules for the first time in years.
All in all, a learning experience, which is stored in this GitHub repository. The only restriction at the moment is that the program assumes that all the images are stored under the src/main/resources
directory and its descendants. I should probably make that an environment variable or something, but I haven’t gotten there yet. The program may also be the subject of a future video. We’ll see.
I was going to include a video here, but I think I’ll wait for next week.
The Shift to Bluesky
I think we’ve reached a tipping point on Twitter. Over the past week or so, I’ve noticed a flood of people leaving, and this time they’re headed to Bluesky in a big way. I’ve been over there for a while, but someone (I think it might have been Josh Long) must have pushed the idea and encouraged the creation of a Java developers starter pack as well. Starter packs are collections of accounts that you can browse, or just click once to subscribe to everyone.
I should note that I changed my account about a week ago. Bluesky has the ability to associate you with a domain rather than just a name followed by bsky.social, and I thought that might be fun. That means now my profile is at https://bsky.app/profile/kousenit.com, so I suppose that means my handle is actual @kousenit.com rather than @kenkousen, like it was before.
Anyway, feel free to join us. There are no ads, and plenty of available block lists. Any time you see a list, click on “Subscribe”, but then you have the option to “Block” instead of add them. For example, go to Comfortably Numb, click on the Lists tab, and pick one, like “Spambots and scammers” or “Arrogant jerks and lousy trolls” and block them all. Anybody can make a list like that, but this account has some really helpful sets of accounts to block.
These days I spend most of my social media time on Mastodon and Bluesky. Now that many of the tech people have come over, and many of the sports people I follow are doing the same, all I need is for the chess content to build up and I can abandon that awful bird site and leave it to its doom.
Thoughts About The Election
In last week’s newsletter I included an entire section where I claimed, “she’s got this,” meaning I trusted Kamala Harris to finish the election successfully. Obviously that didn’t go the way I expected, and since I expected the opposite, I feel obligated to say a few words about it. I promise I’ll keep this brief, but feel free to skip this section if you’re not ready to think about any of this yet.
I’ve been keeping close track of Presidential elections since 1976. I was aware of ones before that, but didn’t really take in what was going on, and the first one where I was eligible to vote was 1980, when Reagan beat Carter for his first term. I normally read multiple “insider” books written after the elections as well, and take an active interest in what the experts say.
Based on all that, I say this:
Kamala Harris ran the best campaign I’ve ever seen, rivaled only by Reagan’s Morning in America campaign in 1984 that won 49 states.
Donald Trump ran, by far, the worst campaign I’ve ever seen.
To put it more succinctly, she did everything right and he did everything wrong.
Seriously, her performances, from the convention to the choice of running mate to the massive rallies to the get-out-the-vote operation, were flawless. She raised over $1 billion and, by all estimates, spent it wisely and well. Trump, on the other hand, ran a lazy operation, full of sloppiness, alienated key constituencies within weeks of the election itself, and explicitly used racist, sexist, misogynist rhetoric all the time. He even held a Nazi rally in a state he had no chance of winning the last week of the campaign. It was an unmitigated disaster all around. I’ve never seen a performance gap anywhere near that big.
Somehow, none of it mattered, or at least it didn’t matter enough. In the end she lost every swing state, not by much, but by enough to be definitive. It’s truly over.
All I can conclude is that the voters who wanted him didn’t care about what he said or what he did. They drank the Kool-Aid, as the saying goes, and that was that. Now they get to find out how wrong they were, and the rest of us somehow have to live through it.
As for me, my world collapsed in the literal sense, meaning it contracted down to just me and the people I care about. Like everybody else, I just tried to get through the week, making sure not to make any life-changing decisions while I knew I wasn’t in the best frame of mind.
A couple days ago as I was driving home, I passed a pick-up truck on the highway that had a light-bar of flashing yellow lights and four (four!) flags all bearing the label “Trump won!” on them. That’s pretty rare here in Connecticut. My reaction was:
There’s no point running him off the road, because it’s too late. The election already happened.
I wanted to say to him, “Yes, Trump won. The real tragedy, though, is that you think that means you won, too.”
I’ll say this much. I’m not going to change who I am, who I care about, or what I say or do until I am physically forced to do so. I am most definitely not going the “preemptive obedience” route of so many company CEOs, fools that they are. I have nothing but contempt for Trump and the cast of clowns, low-lifes, and grifters surrounding him, and I’ll enjoy watching them fail again and again. I intend to resist, both actively and passively, any way I can, because screw that guy.
Heck, I’m in software. We know all about how to look like you’re productive while accomplishing nothing. These days all you have to do is let the AI tools generate all your code, leave out any test cases, and watch chaos ensue.
I will say I’m glad I was so upbeat and optimistic the week before the election. That felt really good. I seriously doubt I’ll feel that way about my country ever again.
Tweets, Toots, and Skeets
Gift ideas
I haven’t verified this, but it seems like a decent thought for the right person.
Only Hugh
Yes, you should have seen that coming. So should I, but somehow I didn’t.
Jessie
Seriously dated joke, but I laughed.
Gen X? Really?
I don’t know about the generation labels, but a good gag anyway.
Wicked Gladiator
I tried thinking of a good name for that combo, but Wicked Gladiator is fine as it is.
Powered sheep
That’s not the first gag that came to mind from that image, but it’s a good one.
Press conference
I wonder what Greg’s follow up question was.
Savings
That would do it.
Elegant solution
Worth a try.
And finally, a Star Trek joke:
Time
Have a great week (or at least a manageable one), everybody!
Last week:
Spring AI, on the O’Reilly Learning Platform
My regular Trinity College schedule.
This week:
Latest Features in Java, on the O’Reilly Learning Platform
My regular Trinity College schedule.