The Definitive Guide to Tool Support in LangChain4J
HTML-код
- Опубликовано: 30 июл 2024
- LangChain4J lets you add classes and methods that an AI model can invoke automatically. That allows you to supply functions that do well what the AI model does badly.
Note that the first example (called Math demo) comes from the LangChain4j examples project,
github.com/langchain4j/langch.... See the ServiceWithToolsExample for details. I originally mentioned that in the video but accidentally cut that part. Also, the PersonExtractor class is based on a different example from that same set, but with the new DateTimeExtractor tool added.
Tales from the jar side:
▶️ Newsletter: kenkousen.substack.com
▶️ RUclips channel: www.youtube.com/@talesfromthe...
▶️ Home page: 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.
▶️ Tella.tv: tella.tv/?via=tftjs
Tella is a great screen capture program. Very simple to use, but very powerful. :)
▶️ Descript: 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 RUclips Shorts.
▶️ TubeBuddy: www.tubebuddy.com/pricing?a=t...
This is about the best tool around for giving you statistics on RUclips videos.
▶️ CleanShot: 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: www.manning.com/?...
This is where my first book, "Making Java Groovy", was published, but you can use the link for any Manning books
00:00 - Welcome to Tales from the jar side!
01:23 - Math demo
01:56 - Function calling docs
08:32 - A Person extractor
15:27 - Exchange Rate Calculations
17:15 - Accessing OpenExchangeRates
18:32 - Map JSON to Java records
21:49 - OpenExchangeRates test
22:37 - Comparing MacBook Air prices
25:44 - Conclusions Наука
Nice intro to what LangChain4j is capable of doing.
Thanks :)
Fantastic! a question related to Data ingestion, do you have something or a link that is talking about ingesting and manipulating tabular data from csv, excel or that type of sources?
Great show, Ken! How did you get the DEBUG: lines to print?
Thanks! I have a file called logback.xml in my src/main/resources directory, and in that file the level of "root" is set to "debug". That's mostly useful when you turn on logging in a chat model, but here it turned out to be convenient anyway.
Clearly I need to add my repo to GitHub, which I'll do after I've cleaned up a few things. Thanks for commenting!
Does langchain4j handles token limit for model if function call responds tokens > limit ?
I don't think it does anything other than whatever the underlying AI tool does. Most of them don't handle that well either. But token limits keep going up and up, so maybe that won't be a serious problem for you
Can you please create a vedio about how to use function in langchain4j usimg gpt4
"Tool support" and "function calling" are two terms that mean the same thing. Check the OpenAI docs and you'll see them used interchangeably. I'm LangChain4j, you use the @Tool annotation to indicate which "function" (i.e., method) inside a class you want the AI to call. In other words, you already found the right video :-)
does it work with demo api key provided by langchain4j?
It should, but I have my own key so I didn't try their demo key. Good luck!
@@talesfromthejarside I have been trying out with demo key. It works except that it doesn't execute any of the tools. If you could confirm, it would be really helpful.
That's very strange. I'll see what I can do. You should be aware, however, that LangChain4j has a Discord server at discord.com/invite/JzTFvyjG6R . I'm somebody there will know the answer right away
good
Thanks 😊