Java 21 + Spring Boot 3.2 + Spring AI = Software Development Advice from Miyamoto Musashi

Sdílet
Vložit
  • čas přidán 21. 07. 2024
  • Hi and welcome to DevXplaining channel!
    Todays video is a nice tutorial on how to slam together three modern components: Java 21, Spring Boot 3.2, and Spring AI - the newcomer. I will start from scratch, put these together, and create a RESTful AI service that leverages OpenAI API to provide deep and meaningful advice for a software developer - from the late and great Miyamoto Musashi, a legendary swordsman and author of Book of Five Rings. The code will not go very deep, just assembling together a stack of some modern technologies. May or may not also contain a rant why Spring is still relevant :)
    I've done a few videos on all these topics before, but this one puts it all together, with the latest versions available right now. Of course there are number of ways we could continue from here, but adding a UI/integrating more services are topics for future videos. Let me know if there's something you'd like to see!
    As always, I appreciate any likes, comments, questions, or feedback on my videos, and naturally subscribe to my channel for more.
    Timecodes:
    0:00 - What we are going to do
    0:37 - Set up Java 21
    3:26 - Set up a Spring 3.2 project with a REST service
    15:00 - Set up Spring AI and create AI-enabled REST service
    29:02 - Prompt engineering to make it fun
    All the code shown here is in Github, available for you to explore:
    github.com/crystoll/musashi
    Links in video:
    - openjdk.org/projects/jdk/21/
    - sdkman.io/
    - start.spring.io/
    - spring.io/guides/gs/rest-service
    - docs.spring.io/spring-ai/refe...
    - openai.com/blog/openai-api

Komentáře • 7

  • @lahiruchethiyaJayasinghe
    @lahiruchethiyaJayasinghe Před 2 měsíci +1

    Hi How to read and save json document in vector db

    • @DevXplaining
      @DevXplaining  Před 2 měsíci

      Hmm, perhaps a topic for another video. Short answer is... depends.

  • @SuperVinayaka
    @SuperVinayaka Před 3 měsíci +1

    Great video. I had a question. lets say we are building a chatBot and we need to make sure that the bot answers questions that are available in a document as well as personalized questions for a specific customer [which can be retrieved using some API's that have been exposed]. How would you do it?

    • @DevXplaining
      @DevXplaining  Před 3 měsíci

      Hmm ,interesting question. If I got it right, some customers would get answers based on the document, but others would get answers based on some APIs?
      If so, in both cases you want to inject some context in system level instruction, either from vector database/document, or an API - so that part remains the same.
      So when you need to answer an API, you would call the API, get the context for the question, then include that in system direction. No need for vector database, as long as what the API returns a) has all the context info needed and b) is relevant and c) is not too massive to chat in the available tokens.
      So in both cases, grab the context information, feed in the system level instruction like in my code. Decide on top of that which context is used for which user.
      One thing I'm not doing in this video, is keeping a conversational memory: I'm just asking a question, and activating context + chatgpt to handle it, but then forgetting all the conversation. So with conversational memory, would need to be a bit more careful, because also the conversational context is typically injected into the calls. Also I think would have to be careful with size, of course depending on your model token limits. And you would need to keep the contexts separate so each user would see their own personal context only (instead of same shared one for everyone).
      I hope this helps and I got the question right!

  • @Chrisbees
    @Chrisbees Před 4 měsíci +1

    This is really cool. Thank you for making this video, now I have to look more into SpringAI. But what would you say about code safety when using AI, dont that have access to your code that shouldn't be public?

    • @DevXplaining
      @DevXplaining  Před 4 měsíci

      Yeah, it's a good question. AI takes many forms, so rule of thumb is: anything you would not like to/be permitted to publish on front page of a popular magazine tomorrow, you should not send to AI - unless you know how the data is handled, stored, etc. And additionally, is your input used to train the models (which could cause it to pop up as an answer for future users).
      So for example using ChatGPT like I do here, I'd limit it to general advice. But for example Github Copilot Enterprise is my tool for daily work, and there are some rules in place to stop my code from leaking. So either know how your AI handles input data, or be safe and just use it for general questions.
      But as always, keep your secrets secret! :)

    • @Chrisbees
      @Chrisbees Před 4 měsíci

      very
      insightful, Thank you@@DevXplaining