Это видео недоступно.
Сожалеем об этом.

Build an AI RAG Application with LangChain & Next.js

Поделиться
HTML-код
  • Опубликовано: 7 авг 2024
  • Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
    Learn how to build an AI RAG application with LangChain & Next.js. This tutorial introduces LangChain and shows how to use the framework to enhance your chatbots and build RAG (retrieval augmented generation) applications with Next.js.
    💖 Support me on Patreon ➜ / davegray
    ⭐ Become a full-stack web dev with Zero To Mastery Courses:
    - Complete Next.js Developer: bit.ly/CompNextJSDev
    - Advanced React: bit.ly/AdvReactDev
    - Junior to Senior Dev Roadmap: bit.ly/WebDevRoadmap-JrtoSr
    🚩 Subscribe ➜ bit.ly/3nGHmNn
    📬 Course Updates ➜ courses.davegray.codes/
    ❓ Questions - Please post them to my Discord ➜ / discord
    ☕ Buy Me A Coffee ➜ www.buymeacoffee.com/davegray
    🔗 Starter Source Code Example: github.com/gitdagray/nextjs-a...
    🔗 Completed Source Code Example: github.com/gitdagray/nextjs-r...
    🔗 My Next.js Videos: • Next.js Tutorials for ...
    👇 Follow Me On Social Media:
    GitHub: github.com/gitdagray
    Twitter: / yesdavidgray
    LinkedIn: / davidagray
    Build an AI RAG Application with LangChain & Next.js
    (00:00) Intro
    (00:12) Welcome
    (00:34) Lesson Goal
    (01:03) What is RAG?
    (02:17) What is LangChain?
    (03:39) Source Code
    (04:14) OpenAI API Key
    (05:04) Dependencies
    (06:35) Frontend Chat Component
    (07:24) Simple Chat Example
    (09:29) Ex. 1: LangChain Chat
    (14:51) Ex. 2: Chat with History
    (21:06) Ex. 3: Chat with Personality
    (22:37) Ex. 4a: RAG Pattern Chat with JSON Object
    (29:58) Ex. 4b: RAG Pattern Chat with JSON file
    (32:11) Wrap-up
    📚 Tutorial References:
    🔗 LangChain: js.langchain.com/docs/get_sta...
    🔗 Next.js: nextjs.org
    🔗 Vercel AI SDK: sdk.vercel.ai/docs
    🔗 OpenAI: openai.com/
    🔗 shadcn/ui: ui.shadcn.com/
    🔗 Next.js Light & Dark Modes: www.davegray.codes/posts/ligh...
    Was this tutorial about building a RAG application with LangChain & Next.js helpful? If so, please share. Let me know your thoughts in the comments.
    #rag #app #langchain

Комментарии • 58

  • @youneverknow7096
    @youneverknow7096 3 месяца назад +8

    Please do more AI based projects Dave, love your work !

  • @HavoJavo
    @HavoJavo 2 месяца назад +4

    Thanks for this ! More LangChain please ! More people seem to be warming up to it recently and I bet it will be a good marketable skill to have in the near future if not already.

  • @Amy-gr3xc
    @Amy-gr3xc 3 месяца назад +2

    Thank you so much for this and the explanations. I'm surprised how fast the docs were out of date between the video and today. It was frustrating.

  • @namaefumei
    @namaefumei 2 месяца назад

    Soooo helpful and easy to understand. Made this with Vue and Nuxt and it worked nicely. Thanks a lot.

  • @user-cn5cl6un1q
    @user-cn5cl6un1q 3 месяца назад +2

    so great to see this type of topics from you. i learn next js from you now langchain 😊. this is such a huge topic with lang chain lang graph that make my day Dave. thank you so much

  • @mfarnell
    @mfarnell 2 дня назад

    simple, clear and very helpful tutorial, thanks :)

  • @bigj3508
    @bigj3508 15 дней назад

    This was really helpful thank you! Subscribed.

  • @omarelhassani8452
    @omarelhassani8452 3 месяца назад +5

    that's what am exactly looking for .. thank you so much Dave

  • @truth8690
    @truth8690 2 месяца назад

    super cool dave

  • @AIdevel
    @AIdevel Месяц назад +1

    it is an excellent app please make one in React RAG and RAG very much needed

  • @dheerajs2838
    @dheerajs2838 3 месяца назад +1

    fantastic video .. thanks ..

  • @aymenbachiri-yh2hd
    @aymenbachiri-yh2hd 3 месяца назад

    Awesome videos, thank you

  • @ahmad-murery
    @ahmad-murery 3 месяца назад +1

    Interesting, I started a simple app in the past to answer student questions based on provided PDF/Word/Text documents and then to say it out loud using a TTS API.
    I was very motivated until I realized that sometimes it's hard to get access to these things if you're located in the wonderland🤦‍♂🤔
    Thanks Dave!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 месяца назад +2

      You're welcome, Ahmad - I hope you find this one interesting!

    • @ahmad-murery
      @ahmad-murery 3 месяца назад +1

      @@DaveGrayTeachesCode Yes, it really is

  • @TomAsh519
    @TomAsh519 2 месяца назад +1

    awesome job! could you make now ex5 and load the states to a vector database? and later a file?

  • @fscubetech7219
    @fscubetech7219 3 месяца назад +1

    Best content.

  • @Dvir1225
    @Dvir1225 2 месяца назад +1

    Is there a way to implement custom logic so that the chain doesn't stop at the "?" itself, rather after it?
    Returning a question to the user without a question mark is rather meh 😅

  • @JomarAmomas
    @JomarAmomas 3 месяца назад

    Thanks for the video. Any plans in the future to create a DenoJS learning videos/course? More power to you.

  • @biniyamfikru4464
    @biniyamfikru4464 3 месяца назад

    Thank you, Dave. in an unrelated topics are there any workarounds to implement fullscreen on ios as fullscreen API is not working on iPhones

  • @en_kratia
    @en_kratia 3 месяца назад

    Hello Dave, do you know how to get "cookies" in server component and preserve SSG at the same time? Looks like method "getSession" in "next-auth" can do this, but i don't know how to replicate this. Thank you

  • @mutasimahmed8975
    @mutasimahmed8975 3 месяца назад +1

    More such apps with AI and next js please

  • @REINOSO195
    @REINOSO195 2 месяца назад +1

    Thanks for the video, i have a question, to adapt this project to use a free model in Hugging Face what should i consider to do this?
    I mean i dont have a credit card to use, so i would like to use a free alternative.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 месяца назад +1

      Look at the Vercel AI SDK docs. They do offer integrations with other models.

  • @sebastianeden
    @sebastianeden 2 месяца назад

    Thank you for great content! I implemented this to chat with a pdf document that is quite big (170 pages). I then reach the token limit of 60k tokens/minute (I generate about 70k-80k). Is there any workaround for this? I want to use the whole document as context to answer the question.

  • @namaefumei
    @namaefumei 2 месяца назад

    How does thos handle big data? Like say 5GBs lf data? Is it possible to do chunking? Even if it could handle, do we have to give it data every time we initiate a chat?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 месяца назад

      You would want that in a vector db. It will need data access to process each new addition to the chat.

  • @BIDSAH
    @BIDSAH Месяц назад

    Hi there this is really fabulous video please make another one with persistent databases like qdrant where the text is converted into text embeddings and retrieved thanks from Jeddah Saudi Arabia

  • @programmerpro-hs8ro
    @programmerpro-hs8ro 13 дней назад

    How much words I can send as json to AI model

  • @rezashah22
    @rezashah22 3 месяца назад

    Hi Dave, Can we use LangChain to conditionally load data, based on the first user question? For example, user asks I need to know about US States (load state data), or I need to know about cars (then load car data)

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 месяца назад

      Yes, there are many patterns. I was thinking about covering conditionals and database queries.

  • @nikoscuatro7251
    @nikoscuatro7251 3 месяца назад

    Is this going to work with books in pdf files? there is change to make the gpt keep memory of that topic?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  3 месяца назад +1

      Yes, if you look at the loaders in the docs, there is a PDF loader. In this example, the route handler loads the data. The chat history context is maintained.

    • @nikoscuatro7251
      @nikoscuatro7251 3 месяца назад

      @@DaveGrayTeachesCode I will come back to try it.Thanks!

  • @kumargupta7149
    @kumargupta7149 3 месяца назад

    On current trend ❤

  • @prashlovessamosa
    @prashlovessamosa 3 месяца назад

    Please use Cloudflare workers for the next project.

  • @StephenRayner
    @StephenRayner 2 месяца назад

    Update for new Vercel AI changes?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 месяца назад

      Might be worth another video.

    • @StephenRayner
      @StephenRayner 2 месяца назад

      ​@@DaveGrayTeachesCode If so, please please also add in a sprinkle of LangGraph. I'm running through your tutorial now with the newer approaches. The extra code for handling the stream can just be dropped works nicely without
      ```
      import { LangChainAdapter, type Message, StreamingTextResponse } from "ai";
      ...
      const prompt = PromptTemplate.fromTemplate(TEMPLATE);
      const chain = prompt.pipe(model.bind({ stop: ["?"] }));
      const stream = await chain.stream({
      chat_history: formattedPreviousMessages.join("
      "),
      input: message,
      });
      return new StreamingTextResponse(LangChainAdapter.toAIStream(stream));
      ```
      See docs for the LangChainAdapter

    • @StephenRayner
      @StephenRayner 2 месяца назад

      Also for the next video, here's an example. You can run through using LangGraph or just LangChain.
      1. User inputs text to translate.
      2. LLM translates it and saves the source / target translation in vector db (pgvector)
      3. User inputs SAME text to translate, RAG (or RAT translation) retrieve existing translations instead of always using the LLM.
      4. Agent prompt template is told to re-use existing translations if identical
      5. Since the translation is a vector, include the matching score too, and now tell the prompt to create a new translation if the score is .70 or higher.
      6. This above can all but done using LangChain, but you can use LangGraph and have it decide to do a google search if it doesn't have any translations. Then use those to make up a better informed one.
      7. You can also add in another workflow which has it reflect on the source text and the translation and if it still holds the original meaning e.t.c.

    • @StephenRayner
      @StephenRayner 2 месяца назад

      Oh! Streaming UI! Maybe have it show a user to collect a selection from the user. Like feedback on changing the translation. Like the translation I have is... and you can edit it and save it back.

    • @StephenRayner
      @StephenRayner Месяц назад

      @@DaveGrayTeachesCode LangChain channel release a decent video on generate UI which hit the spot nicely. LangGraph, TypeScript! AI SDK. Check it out if you didn’t see it yet.

  • @subhash5122
    @subhash5122 2 месяца назад +3

    this guy is married

  • @epic_c_lips
    @epic_c_lips 2 месяца назад

    Tech aside, please reveal your skincare routine.

  • @Neunzahn
    @Neunzahn 2 месяца назад

    I wish more tutorials would use free models like llama. Everyone is just using openAI.

  • @subhash5122
    @subhash5122 2 месяца назад +1

    bro help me to get married