LangChain is AMAZING | Quick Python Tutorial

LangChain is a great Python library for creating applications that communicate with Large Language Model (LLM) APIs. In this tutorial, I’ll show you how it works and also discuss its design
👷 Join the FREE Code Diagnosis Workshop to help you review code more effectively using my 3-Factor Diagnosis Framework: www.arjancodes.com/diagnosis
💻 ArjanCodes Blog: www.arjancodes.com/blog
🐱💻 Git repository: git.arjan.codes/2023/langchain
✍🏻 Take a quiz on this topic: www.learntail.com/quiz/cancrx
🎓 Courses:
The Software Designer Mindset: www.arjancodes.com/mindset
The Software Architect Mindset: Pre-register now! www.arjancodes.com/architect
Next Level Python: Become a Python Expert: www.arjancodes.com/next-level...
The 30-Day Design Challenge: www.arjancodes.com/30ddc
🛒 GEAR & RECOMMENDED BOOKS: kit.co/arjancodes.
👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!
Social channels:
💬 Discord: discord.arjan.codes
🐦Twitter: / arjancodes
🌍LinkedIn: / arjancodes
🕵Facebook: / arjancodes
📱Instagram: / arjancodes
♪ Tiktok: / arjancodes
👀 Code reviewers:
- Yoriz
- Ryan Laursen
- Dale Hagglund
🎥 Video edited by Mark Bacskai: / bacskaimark
🔖 Chapters:
0:00 Intro
0:42 LangChain Tutorial
12:23 LangChain’s design
15:58 Final Thoughts
#arjancodes #softwaredesign #python
DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!

Пікірлер: 69

  • @ArjanCodes
    @ArjanCodes7 ай бұрын

    👷 Join the FREE Code Diagnosis Workshop to help you review code more effectively using my 3-Factor Diagnosis Framework: www.arjancodes.com/diagnosis

  • @NGrimthrie
    @NGrimthrie9 ай бұрын

    This is great. Would you consider doing a video on ways to extend the models beyond their training cutoff dates? Possibly using vector databases and LangChain's document parsers?

  • @tylerchism134

    @tylerchism134

    9 ай бұрын

    Yes! I second this request.

  • @munteanionut3993

    @munteanionut3993

    9 ай бұрын

    second it second, 2

  • @pypypy4228
    @pypypy4228Ай бұрын

    This is a paragon of explanation: succinct and to the point, gradually increasing the difficulty, with an apt digression into principles and design patterns. I would love to see YOUR tutorials about LCEL - langchain chain expression language. I don't grasp the concept of RunnablePassthrough and nobody seems to explain it the way you explain the Python magic. ❤

  • @paulomtts
    @paulomtts9 ай бұрын

    Very interesting. Thanks for the video!

  • @jumper0122
    @jumper01229 ай бұрын

    I must have missed that survey -- I would love to see more content about databases and best-practices with them. Like using SQLAlchemy efficiently and whatnot. I do a lot of web scraping and it was only this year that I graduated from heinously large JSON files to proper databases

  • @aungkyawkyaw9114
    @aungkyawkyaw91149 ай бұрын

    Do all the more on all topics please. Never stop.

  • @user-lo1ie3tz4b
    @user-lo1ie3tz4b9 ай бұрын

    can not wait for your long-chain tutorials.

  • @TacticalTruth
    @TacticalTruth9 ай бұрын

    Looks perfect for Data Cleaning and Record Linkage.

  • @melvingeorge2729
    @melvingeorge27299 ай бұрын

    wow! this is phenomenal :) thanks, Arjan! Also, which are the books in the shelf behind you?

  • @TNothingFree
    @TNothingFree9 ай бұрын

    Fantastic cover. A. it shows how complex it is, you need to understand the API correctly to make the maximum out of it. B. I just can imagine what it can do with many products, every app/web site can integrate such automatic tools which may generate ton of content. My favorite are infinite dungeon crawlers.

  • @MicheleHjorleifsson
    @MicheleHjorleifsson9 ай бұрын

    Please Please do one on embeddings :)

  • @drag0zu
    @drag0zu9 ай бұрын

    Great video, i would really like to see how a Database Content + Model can be integrated into an LLM application (can be also GPT4all i think), so users can then ask stuff about the DB content.

  • @animelover5093

    @animelover5093

    6 ай бұрын

    Been thinking about this as well recently 🤔

  • @jeffrey5602
    @jeffrey56029 ай бұрын

    I actually enjoy the original python content the most. Especially in this AI craze I try to avoid AI content from people who weren't doing AI content before all the hype, no fence. But your great python content is what I subscribed for :)

  • @TheVengeful0ne

    @TheVengeful0ne

    9 ай бұрын

    same. Unsubscribing for now. He has mentioned that he gets a lot more views from these type of videos so expect more from him. =/ Feels bad to see this kind of content from Arjan as someone who is working as a tech lead in the AI space. Stick to content you are great at please. Don't try to milk the hype and alienate your original subscribers by going into an area which you have superficial knowledge or a very narrow perspective/understanding about. Encouraging the use of a very opaque + opinionated framework that you have very little control over and has a very brittle foundation just doesn't work out well in production and is a bad idea.

  • @jeffrey5602

    @jeffrey5602

    9 ай бұрын

    @@TheVengeful0ne As a mid data scientist with a focus on NLP I could not agree more. I am watching the channel to get better at SWE. Also from what I have seen there have not been much useful applications for any of the "openai wrapper" and related tech. For most use cases I can see in my company it would be wasteful to actually use openai apis and using smaller HF models makes way more sense. Noone without an actual PyTorch/TF background should touch those use cases though.

  • @torstenschindler1965
    @torstenschindler19659 ай бұрын

    Hi Arjan, what’s your take on Max Woolf’s Blog: “The Problem with Langchain” ? Loading the environment variables via the os module is not necessary. It is done in the ChatOpenAI class anyhow.

  • @ivanherreros7773

    @ivanherreros7773

    9 ай бұрын

    Wow. I truly like Arjan's content, spirit, everything. But I have to admit that the post that you've linked here is (I am very sorry to say) of more value to me than the video itself. Indeed, it reflects my issues when I was trying to tweak a "RAG" demo in LangChain to my use case. Namely, asking myself, "what is all this complexity good for?". The post answers: for nothing, really. I think that the ones who enjoyed Software Engineering content in this channel will be more inclined to see what concepts are very useful in LangChain, and then reimplement them ourselves (or find a leaner framework- it must exist somewhere). So, Arjan, if you read this, please take it as constructive criticism. And I will of course stay subscribed :)

  • @default_youtube_profile
    @default_youtube_profile9 ай бұрын

    Hello Arjan, What keyboard are you using ?

  • @InglesConConfianza
    @InglesConConfianza9 ай бұрын

    Great tutorial!

  • @ArjanCodes

    @ArjanCodes

    9 ай бұрын

    Thank you!

  • @aniketgninawe4963
    @aniketgninawe49639 ай бұрын

    I am working with CSV data and using create_csv_agent, looks like its facing difficulty with complex queries, any solution? Thanks

  • @moondevonyt
    @moondevonyt9 ай бұрын

    mad props for diving deep into Langchain however, the real game changer for me would be direct integration with modern frameworks still, your explanations? on point always appreciate the effort you put in, but there's always room to elevate

  • @JohnWalz97

    @JohnWalz97

    9 ай бұрын

    What do you mean direct integration with modern frameworks?

  • @midprogramming

    @midprogramming

    9 ай бұрын

    I'm not too sure what he means either considering Jason Zhou and multiple researchers on Twitter already have integrated Langchain into real world products... @@JohnWalz97

  • @fuba44
    @fuba449 ай бұрын

    But can you run your own models? Like can I download the llama 2 from huggingface, and query it using langchain?

  • @jakecyr

    @jakecyr

    9 ай бұрын

    You can! You can extend the LLM class and add your own implementation for any custom model.

  • @PatrioticBastard
    @PatrioticBastard9 ай бұрын

    can you visualize your keystrokes so we know what shortcuts youre using?

  • @malgindesilva2758
    @malgindesilva27589 ай бұрын

    This is very simple yet informative into Ajan, love your videos

  • @adrianzuur5589
    @adrianzuur55899 ай бұрын

    One of the things about LangChain that irritates me is how when you use the ConversationChain class with memory to communicate with GPT>=3.5, it DOES NOT use the chat completion endpoint OpenAI has. Instead, it uses simple completion, formatting all of the messages in the history into a single string. I suppose this is because they want the ConversationChain to work with all sorts of LLMs, including those without a chat completion mode, but... it's not the behavior you would expect for GPT>=3.5.

  • @davidyoung623

    @davidyoung623

    9 ай бұрын

    That is how the regular API endpoint functions as well 🤔 You have to send prior messages as part of your API call, or the endpoint doesn't know about them either 🤷

  • @manomancan

    @manomancan

    9 ай бұрын

    I think it's a straight-up bug!

  • @nuurnwui
    @nuurnwui3 ай бұрын

    When this video came out, I didn’t understand it. Now I do, but to me it means Arjan wasn’t quite as good at explaining as usual. Please do more on Langchain or related technologies.

  • @adrianobleton
    @adrianobleton9 ай бұрын

    I actually have a lot of trouble following the langchain model. For example, it's not clear to me why you use a human prompt and a system prompt in the country example. Wouldn't the system prompt alone be sufficient? For my use cases, doing a thin wrapper around the chat gpt calls is sufficient. I do use the system prompt templates though for the initial context messages.

  • @berdgg

    @berdgg

    Ай бұрын

    Its so overly complicated. You initiate so many classes, call so many methods, and then realize at the end it just constructed a big string and called a simple API...

  • @frazuppi4897
    @frazuppi48979 ай бұрын

    langchain is actually (all love to the creator)a OOP hell and not really good

  • @Lanc840930

    @Lanc840930

    9 ай бұрын

    I agree

  • @oc3academy

    @oc3academy

    9 ай бұрын

    I couldn't igree more

  • @PmmSoares

    @PmmSoares

    9 ай бұрын

    Ya, is very confusing and documentation doesn't help. There's any alternative?

  • @judgelaloicmoi

    @judgelaloicmoi

    8 ай бұрын

    Llamaindex ?

  • @chriskeo392

    @chriskeo392

    8 ай бұрын

    Maybe too advanced for you?

  • @svaponi
    @svaponi2 ай бұрын

    Does anybody have the transcript of the code? git repo maybe?

  • @RedCloudServices
    @RedCloudServices8 ай бұрын

    Is it possible to chat with langchain documentation? How would you train an LLM using Langchain documentation?

  • @morrischoga1581

    @morrischoga1581

    7 ай бұрын

    Brain Usage : 100%

  • @Benemortasia666
    @Benemortasia6669 ай бұрын

    Goud

  • @pypro
    @pypro9 ай бұрын

    Dude you are amazing! thanks for the content, really good to get a "best practices" view on all of these topics! thanks so much, greetings from México! let me know when you come to the caribbean (mexican) I will buy you some drinks!!

  • @torbjrnwikestad28
    @torbjrnwikestad288 ай бұрын

    Discord invite didn't work.

  • @VolodymyrInTech
    @VolodymyrInTech9 ай бұрын

    💛💙👍

  • @thezachdrake
    @thezachdrake3 ай бұрын

    I didn't know John Greene knew how to code.

  • @pipi_delina
    @pipi_delina9 ай бұрын

    Can you explain llama

  • @BorrWick
    @BorrWick9 ай бұрын

    Langchain is so bad what are you saying 😅

  • @Ringoshiiro

    @Ringoshiiro

    9 ай бұрын

    Why is it bad?

  • @TheVengeful0ne

    @TheVengeful0ne

    9 ай бұрын

    yeah. A lot of people (myself included) have moved away from using it in production in our companies too because outside of its data/platform connectors it is just way too restrictive and has too many layers of unneeded abstractions for even very simple stuff. Pretty disappointing to see it being promoted here.. but hey as a content creator it makes sense to make content about the most popular thing out there. Like he mentioned in another comment here, he gets more viewers making these kinds of videos >.> ​ @Ringoshiiro you can easily find a lot of threads complaining about using it in prod on hackernews. There are also 2 very detailed articles from the Buzzfeed AI team diving into details of the problems langchain has

  • @Piipolinoo
    @Piipolinoo9 ай бұрын

    Please no more AI content :( the fucking space is flooded by it. it was nice having at least you talk about other stuff. please please please no more ai crap

  • @ArjanCodes

    @ArjanCodes

    9 ай бұрын

    It looks like the majority of viewers disagree with you. Whenever I cover AI on the channel, the views are higher than on my other videos. I do try to keep a balance between different types of content - the last video covering AI stuff was several weeks ago.

  • @Piipolinoo

    @Piipolinoo

    9 ай бұрын

    @@ArjanCodes haha I totally get it, i just wanted to be the loud minority ;) Keep up the good work!

  • @ArjanCodes

    @ArjanCodes

    9 ай бұрын

    No worries, and will do 😊

  • @Vanessa-vz5cw

    @Vanessa-vz5cw

    9 ай бұрын

    ​@@ArjanCodes One thing that I think would be super interesting to do that is still very related to AI but a little more general is a more general ML modelling tutorial or video that is slightly lower-level. One thing I'd love to see your take on is how to best structure code that uses mlflow (maybe fine do hugging face language model or something to still generate interest from the LLM crowd). I work in machine learning and mlflow is widely, but I have yet to see someone implement it while following the programming principals you explain so well on this channel. It seems to be often called out of no where during feature engineering, model training, etc. to log metadata, which makes it quite hard to test and also keep track of where it's being called and what it's logging.

  • @ermalai
    @ermalai3 ай бұрын

    I get Country is not a subclass of BaseModel, though I inherited frm BaseModel in the definition. why? raise validation_error pydantic.v1.error_wrappers.ValidationError: 1 validation error for PydanticOutputParser pydantic_object subclass of BaseModel expected (type=type_error.subclass; expected_class=BaseModel)

  • @edbeds

    @edbeds

    2 ай бұрын

    Me too, did you find a solution?

  • @ermalai
    @ermalai3 ай бұрын

    I even tried with your exact code, I still get the same error

  • @imaderraiss1609
    @imaderraiss16099 ай бұрын

    arjaound. god no.