There’s no need to wait for the Spring AI project to mature before accessing OpenAI services like ChatGPT in Spring. We can use the existing features like HTTP exchange interfaces, included JSON parsing, auto wiring, and more to connect a Spring app to Chat.
00:00 - Welcome to Spring + Chat
00:36 - OpenAI Chat API
01:28 - Pricing
02:51 - Mapping JSON request to Java records
03:55 - Java records for the Chat request
04:37 - Mapping the Chat response
06:47 - Spring HTTP Exchange Interface
09:36 - Java records for input/output
10:48 - Add Post Method to Interface
12:06 - Test the Chat
14:14 - Add a default method to the interface
15:13 - Test using default method
15:58 - Add a Service
16:44 - Cache the list of models
19:34 - Test the Service
20:35 - Sort the Model ids
21:41 - Other possible improvements
Tales from the jar side:
▶️ Newsletter: https://kenkousen.substack.com
▶️ YouTube channel: https://www.youtube.com/@talesfromthe...
▶️ Home page: http://www.kousenit.com
Welcome to Tales from the jar side! New newsletter every Sunday, new newsletter video every Monday, and additional technical videos (Java, Gradle, JUnit, Spring, and lots more) every week.
Affiliate links:
These are products I use on a regular basis. If you click on them, your price doesn't change, but I may receive a small referral fee. Feel free to try them out.
▶️ Descript: https://www.descript.com/?lmref=HHcVuA
This is a great program for transcribing videos and letting you edit them by editing the transcript. It also has several AI features like Studio Sound, Background Removal, Eye Tracking, Autodub, and more. I use it especially for YouTube Shorts.
▶️ TubeBuddy: https://www.tubebuddy.com/pricing?a=t...
This is about the best tool around for giving you statistics on YouTube videos.
▶️ CleanShot: https://cleanshot.sjv.io/Tftjs
I use this as my primary way of making screenshots. You can save them locally or to the cloud, crop and do other edits, add backgrounds, and more.
▶️ Manning Publications: https://www.manning.com/?utm_source=m...
This is where my first book, "Making Java Groovy", was published, but you can use the link for any Manning books