Langchain and Pinecone with Node.js: A Quick Start Tutorial

Sdílet
Vložit
  • čas přidán 25. 08. 2024
  • #Langchain #Pinecone #Nodejs #Openai #javascript
    Dive into the world of Langchain and Pinecone, two innovative tools powered by OpenAI, within the versatile Node.js environment. This crash course will guide you through the basics and up to more complex applications. Whether you're a novice developer or looking to expand your toolkit, this comprehensive guide will help you grasp these cutting-edge technologies quickly and effectively. Get ready to explore the potentials of AI and machine learning in programming with Langchain and Pinecone.
    Github Link: github.com/dev...

Komentáře • 111

  • @DevelopersDigest
    @DevelopersDigest  Před 11 měsíci

    Building A Chatbot with Langchain and Upstash Redis in Next js
    czcams.com/video/gpXXIvfSCto/video.html

  • @naderdabit
    @naderdabit Před rokem +9

    You do an excellent job as an educator, you cover so much so clearly and quickly. thank you.

  • @waleedatif5018
    @waleedatif5018 Před 4 měsíci +3

    calm voice, straight to the point
    subscribed in the first minute❤❤

  • @tobiasmele
    @tobiasmele Před rokem +2

    Enjoyed this thoroughly because I'm a newcomer to code and want to take this model apply to certain things like industry specifications for Quality Engineers in Aerospace asking their chatbots about material specifications or generating purchase orders etc...endless workflow improvements on the horizon!

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      I love this thought! Hope some of my videos can help you on your journey, let me know if you have any questions I can help with

  • @holdinvestors6935
    @holdinvestors6935 Před rokem +1

    thanks for providing a useful lesson. it will be great to update by pinecone for the "langchain/vectorstores" has been deprecated.

  • @a999haa
    @a999haa Před rokem +2

    This is an amazing video! The content is really really helpful for someone looking for a js based solution amidst all the python ones. Again, appreciate it.

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Thank you for the kind words. I am stoked you found it helpful!

  • @wndGGaRkGBKpXvM6NWHGOeMJv

    I appreciate the nonsense free example - exactly what I needed!

  • @SLTRM
    @SLTRM Před rokem +1

    Thanks so much!!! Very illustrative video. Please go ahead with more videos for nodejs and js.

    • @DevelopersDigest
      @DevelopersDigest  Před rokem +1

      Thanks SLTRM! I really appreciate it, more to come soon… stay tuned!

    • @SLTRM
      @SLTRM Před rokem

      @@DevelopersDigest typescript is supported by langchain?

  • @hmtbt4122
    @hmtbt4122 Před rokem +2

    Thanks sir, this is much needed one

  • @user-un9vz4mi3i
    @user-un9vz4mi3i Před rokem +1

    Awesome tutorial, could imagine these video are part of a course.

  • @shinchima
    @shinchima Před 9 měsíci +1

    That was a clear explanation, thanks for uploading! peace.

  • @johannschuster7530
    @johannschuster7530 Před rokem +1

    Awesome intro tut. Thank you

  • @ortoapp
    @ortoapp Před rokem +1

    Super super useful, thank you! Great job explaining it too.

  • @the-web-scraping-guy
    @the-web-scraping-guy Před 11 měsíci +1

    Super helpful! Thank you!

  • @andrewlewin6525
    @andrewlewin6525 Před rokem +1

    Very useful, I can put this to practical use very quickly 😊

  • @stonedizzleful
    @stonedizzleful Před rokem +1

    You're videos are really good man. Thank you!

    • @DevelopersDigest
      @DevelopersDigest  Před rokem +1

      I appreciate you saying that Liam! Thank you for watching!

    • @stonedizzleful
      @stonedizzleful Před rokem

      @@DevelopersDigest No worries dude. It's great to see some node js content out there for langchain. I've been struggling to find anything quality and your stuff is right up there with super clear explanations.

  • @inkweonkim6299
    @inkweonkim6299 Před rokem +2

    This was the best class I've ever taken. I got a lot out of it. Thank you.
    I do have one question.
    If I wanted to add a CheerioWebBaseLoader() in the following code, how would I modify it?
    async readFiles() {
    const loader = new DirectoryLoader(this.dataPath, {
    '.txt': (path) => new TextLoader(path),
    '.pdf': (path) => new PDFLoader(path),
    });
    const docs = await loader.load();
    return docs;
    }

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Thank you 🙏 I will be releasing more Langchain content where I cover web loaders and I will make sure to include Cheerio.
      The one thing with Cheerio or Puppeteer is that loader will be specific to the website you are trying to scrape or crawl and it will be based on the selectors on the page you need. Those will vary from website to website that you will need to use. Stay tuned if you are interested if you are interested!

  • @raphauy
    @raphauy Před rokem +1

    Very helpful, thanks for sharing

  • @lyndonsimpson1056
    @lyndonsimpson1056 Před rokem +2

    thank you, i was looking for a nodeJs tutorial, i am having some trouble when embeding - it is receiving an empty object or unexpected format, i think my initial docs in the publis directory aren't formated well.

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Okay, I’m sorry to hear that. We’re you able to resolve the issue?

    • @lyndonsimpson1056
      @lyndonsimpson1056 Před rokem

      @@DevelopersDigest yes! Thank you, was able to make the pinecone method work as well as the hsnlib method. I started on small txt files but i'm wondering how well these methods will perform on very large sets of txt(like thousands of pages, have you had some test runs with very big files ?

  • @WebDevCody
    @WebDevCody Před rokem +1

    Is this Be A Better Dev’s alternative channel?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Hi Cody 👋 this is my only CZcams channel 🙂

    • @WebDevCody
      @WebDevCody Před rokem +1

      @@DevelopersDigest go listen to “Be A Better Dev”, you sound just like him, good video though!

    • @DevelopersDigest
      @DevelopersDigest  Před rokem +1

      I’ll go have a listen and thank you 🙏 that means a lot coming you! Cheers

  • @stermi
    @stermi Před rokem +1

    Why are you concatenating all the docs before passing them to the LLM? Could you please explain the reason behind that decision instead of passing them directly to GTP? By doing this, as far as I understand, you are losing all the metadata attached to the doc.

  • @mikerobin8410
    @mikerobin8410 Před rokem +1

    Thanks for this video, I implemented this in a project but the cost to the OPENAI API is really high

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Make sure to set up conditions to not re embed data each time if you are loading up a lot of document! Should also be able to with a bit of work be able to be tweaked to work with some other models!

    • @mikerobin8410
      @mikerobin8410 Před rokem

      @@DevelopersDigest I did set up conditions...the issue is that i live in a thrid world country so the cost of 3.5 dollars on average per day here is still quite high...I can send you the Github link you see if some optimazations are required

  • @TechWithAbee
    @TechWithAbee Před 16 dny +1

    man, tysm!

  • @LearnWithBahman
    @LearnWithBahman Před rokem +1

    what if we only have one documents (2000pages doc) and we do not want to change our document each time ? I think you check if the document is new or not and if it is not new it will not do pinecone and embedding , am I right ?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem +1

      You could do something like that potentially by checking for and adding a namespace.
      docs.pinecone.io/docs/namespaces
      A way to do this could be if you made your namespace your document name and then prior to the embedding process query for whether that namespace exists, if it does, just go straight to querying. Would just need a few tweaks to accomplish what you are asking

  • @omangramoswaane2211
    @omangramoswaane2211 Před rokem +2

    Perfect job sir. Just one question. Where did you config the Openai_key?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      OPENAI_API_KEY=your key in a .env.
      Make sure dotenv is installed. Cheers!

  • @mathurji4542
    @mathurji4542 Před 5 měsíci

    the video is awesome can you tell me how can add the prompt in the above while query from the pincone and also want to add the histroy of chat in that prompt how can do that can you give me some guidance about this.
    its very helpfull for me i am stuck with this problem

  • @effodero
    @effodero Před rokem +1

    Firstly, thank you for great content, delivered in very succinct and easy to digest way.
    I was wondering if you looked at ways of updating documents in existing index as well as updating existing index with additional documents? From what I'm seeing at the moment it seems that the index might need to be recreated each time. I did find some information on using other vector storage solutions with suggestions of removing existing documents from the index first, and then adding the updated docs. Is this something you looked at?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Thank you, I know exactly what you mean. I haven’t been thinking on how to cover this and implement. With pinecone knowing which group of vectors to target. My thought would be to store the ids that correlate with each document and then when you update the new document you look to those stored ids and perform your delete operation. I might try and make a video out of this idea. Thank you for pointing this out, it’s a really good area to cover I think. You should not have to rebuild the index each time.

  • @raphauy
    @raphauy Před rokem +1

    Thaynk you!!! Suscribed 🙂

  • @user-wi4gp9kq2x
    @user-wi4gp9kq2x Před rokem +1

    Hello!Can you help me with my code, where I using your code.I have error:Error starting the bot: Error: OpenAI or Azure OpenAI API key not found.I dont know where i should to use that AI api key.

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      You must get the OpenAI api key from their website, make sure you have a .env in your project, make sure to have installed dotenv. And that you have the correct variable name between what’s in your .env and your js. Hope that helps, cheers!

  • @JohnyIIOh
    @JohnyIIOh Před rokem +1

    Nice, I prefer python, but I'm not a coder heavy person. Gpt4 will need to explain me a lot of the code

  • @SetsunaKiryuKengan
    @SetsunaKiryuKengan Před 9 měsíci

    But where did you pass the OPEN AI KEY ?

  • @vishalsaberwal
    @vishalsaberwal Před rokem +1

    Awesome tutorial. When changing the vector dimension to 512, why do I get error "[Error: PineconeClient: Error calling upsert: Error: Vector dimension 1536 does not match the dimension of the index 512]"?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      If you made a vector you want to use in the pinecone GUI and set it to 512 you would have to make sure to set it up with 1536 for OpenAI, alternatively make sure the embeddings model you are using matches that which you set within pinecone. Cheers!

  • @mohamed.hesham
    @mohamed.hesham Před 7 měsíci

    [Error: PineconeClient: Error calling upsert: Error: PineconeClient: Error calling upsertRaw: FetchError: The request failed and the interceptors did not return an alternative response]
    please help

  • @rayyanhassan7560
    @rayyanhassan7560 Před rokem +1

    will this work on pdf and csv files as well ? I have tried but i keep getting stuck in the update pinecone for loop

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      You might need to make some tweaks on normalizing the data. I have not dug into csvs too much yet. I might dive into this in a future video on some approaches to handle csvs where the responses from the vector db can be used in a meaningful way.
      My intuition on this is maybe for the csvs upload, upload the header for each column in each set of rows that are uploaded but with that said there might be a better way, I just have to dig in more

  • @EthanTuttle
    @EthanTuttle Před rokem +1

    I get a Maximum call stack size exceeded when trying to load a large amount of html data. Is there a good way to incrementally load documents and update the vector store without exceeding this size?

  • @Marcelo-qc8lt
    @Marcelo-qc8lt Před 9 měsíci

    Great video!
    I'm sorry but I wanted to ask you a question. I'm building a small project for a client, but I'm having problems with "3-queryPineconeAndQueryGPT.js". On local it works fine but on Railway (where I deployed for testing), it doesn't return the "result.text".
    I went through console.log() and I see that even concatenatedPageContent works fine, the problem seems to happen in :
    const result = await chain.call({
    input_documents: [new Document({ pageContent: concatenatedPageContent })],
    question: question,
    });
    I don't know if the problem is in the call to the chain or where it creates a new document.
    If you have any idea what's going on I'd appreciate it!

  • @Chama.A.I.
    @Chama.A.I. Před 7 měsíci +1

    Error:
    C:\Users\User\Desktop\Get-Started-With-Langchain-and-Pinecone-in-Node.js-main
    ode_modules\@pinecone-database\pinecone\dist\index.js:102
    case 5: return [2 /*return*/, Promise.reject(new Error("PineconeClient: Error calling ".concat(func.name.replace("bound ", ""), ": ").concat(error)))]; ^
    [Error: PineconeClient: Error calling listIndexes: FetchError: The request failed and the interceptors did not return an alternative response]
    Can You help me, please?

    • @DevelopersDigest
      @DevelopersDigest  Před 6 měsíci

      Make sure all the api keys are configured and the versions match what were used in the example. That would be my first recommendatikn

  • @itsjinhk
    @itsjinhk Před rokem +1

    Can you help me please? I have error when running the command:
    Created with client:
    triggerUncaughtException(err, true /* fromPromise */);
    ^
    [PineconeError: PineconeClient: Error calling query: PineconeError: PineconeClient: Error calling queryRaw: no healthy upstream]

    • @DevelopersDigest
      @DevelopersDigest  Před rokem +1

      This could be a pinecone specific issue, you can check status.pinecone.io/ if there are issues if you or others run into this. If you try and exit out and run it again after a period of time does this error persist?

    • @itsjinhk
      @itsjinhk Před rokem

      @@DevelopersDigest Thank you for your reply, when I try to run it again it doesn't give the error anymore.

  • @ivanivanivanivan1592
    @ivanivanivanivan1592 Před rokem +1

    Thank you. Don't you know how to make it remember chat history?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      That would be an easy swap in langchain if you are looking to do that!

    • @ivanivanivanivan1592
      @ivanivanivanivan1592 Před rokem +1

      @@DevelopersDigest yes i do. Also I'm interested in some way to put a "in your role as a..." system prompt to this model to make it answer me in the way I need and maybe format its answer as JSON for example

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      @@ivanivanivanivan1592 I have a lot more Langchain content coming. Next one will show how to build out a full stack chat app leveraging Upstash Redis to store and organize conversations if that is something you are interested in. Additionally for reliably returning JSON. There is a really handy trick to get a JSON response by leveraging OpenAI function calling. Check this out it might help! Finally, I have a video on langchain output parsers which may help if using models outside of OpenAI GPT models. Cheers! twitter.com/jaredpalmer/status/1673056725446844417

    • @ivanivanivanivan1592
      @ivanivanivanivan1592 Před 11 měsíci

      @@DevelopersDigest thank you! this link is
      exactly what i need right now! 🤩

  • @LearnWithBahman
    @LearnWithBahman Před rokem +1

    So this code is safe for not leaking api key , we need to add frontend to it?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem +1

      If you take the necessarily precautions such as not pushing your environment variables to GitHub and have them secured in your production you should be good to go. In terms of front end you will have to incorporate it and add in a way to interact with the backend such as express.js if you’d like to turn this into a full stack app. Cheers!

  • @surajkhan5834
    @surajkhan5834 Před rokem +1

    Bro i achived by convert csv into txt file and use your code to question it's works, now i want to create a chat history how can i achive that and
    i can see the create_pandas_dataframe_agent in python can answer the question in only three line code below
    df = pd.read_csv('data.csv', encoding='ISO-8859-1')
    agent = create_pandas_dataframe_agent(OpenAI(temperature=0), df, verbose=True)
    result=agent.run(question)
    using this vector pinecone we use OpenAI Embeddings API and OpenAI model to generate an answer
    which one is better and less cost?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Great! All the costs are listed on OpenAI’s website. Embedding apis are considerably cheaper than LLMs. I have some more content and a recent video on Huggingface if you are exploring open source alternatives

    • @surajkhan5834
      @surajkhan5834 Před rokem

      @@DevelopersDigest sure i am also looking for that please make sure to use csv file 😅

  • @surajkhan5834
    @surajkhan5834 Před rokem +1

    Thank you so much for making this. I tried this today but I checked with a CSV file that contains 100 rows
    So I use CSVLoader form langchain i just console the docs, it created multiple object for each row😢
    So I can't use that in updatePinecone.js
    Please give me solution..

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      You may need adjust a little bit, first a function just to normalize the data you want to embed. Then you could create a vector based on each row and embed those one by one, just make sure what you pass in the embedding function is normalized to be a string. Then you could send the metadata with an id of each row with the data each contains. There are a handful of approaches here, that’s the first that came to mind!

    • @surajkhan5834
      @surajkhan5834 Před rokem

      @@DevelopersDigest embed each row? so call OpenAIEmbeddings for 100 times it will cost me more please guide me if i am worng or please you can add some more minutes in video to explain this please..

  • @Venkatesh-vm4ll
    @Venkatesh-vm4ll Před rokem +1

    for every file we need to create new index?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      No, you only need to create the index once and can upsert subsequent documents as you need from there.

    • @Venkatesh-vm4ll
      @Venkatesh-vm4ll Před rokem

      @@DevelopersDigest there will no override will occur?

  • @daniellasek1123
    @daniellasek1123 Před rokem +1

    What VSCode theme is that?

  • @rahulspoudel
    @rahulspoudel Před 11 měsíci +1

    GG ♥🙏👏

  • @RaheelAshrafAli
    @RaheelAshrafAli Před 11 měsíci

    Openai is charging me $0.06 per answer. Is there any way to reduce this cost?

    • @RaheelAshrafAli
      @RaheelAshrafAli Před 11 měsíci +1

      To create embeddings it uses text-embeddings-ada model which is consuming 13 tokens only for each call that is fine but to get the answer it uses davinci model which is consuming 2813 tokens to each. Is there any way I can avoid the use of davinci model to get the answer? Thanks in advance

    • @DevelopersDigest
      @DevelopersDigest  Před 11 měsíci

      A few things you can do. First use got-3.5 turbo. That should lower considerably. Next if you wanted you could limit the size of the embeddings before adding them to pinecone. You could also shrink the topK results if you want to bring it down further. Changing to 3.5 turbo should be a fraction of a penny for that amount of tokens

    • @RaheelAshrafAli
      @RaheelAshrafAli Před 11 měsíci

      @@DevelopersDigest Thanks for your response. I have changed the model to gpt-3.5 turbo. It has resolved the issue

  • @brawndojo
    @brawndojo Před rokem +1

    Beautiful, thanks. Plans for a Python version by chance?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      I don't currently have one planned, right now I have a handful more Node.js + Langchain videos coming down the pike for upcoming videos I will be coding out and recording over the next several weeks. With that said, I won't rule it out if there is enough interest!

    • @brawndojo
      @brawndojo Před rokem

      @@DevelopersDigest sounds great to me, I prefer the JS route myself, just giving a ChatGPT workshop next week, python is a bit more default. Happy to watch any and all content you produce, it is stellar.

  • @INKWEON7269
    @INKWEON7269 Před rokem +2

    Thanks for the great course.
    Can I use OpenAIChat instead of OpenAI to get answers inside a PDF document? If so, how can I modify it?

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      Yes, absolutely

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      I have a number of langchain videos planned over the next month. I will be covering some chat options in upcoming videos. Stay tuned

  • @minhcdao
    @minhcdao Před 7 měsíci

    I got this error 'The model `text-davinci-003` has been deprecated. I replaced it with text-embedding-ada-002. I got this response:
    {
    res: {
    text: 'This (a,chain,a,1, 1,Chainl( 1,1,1,1)aL2d,aand,and,1,Chain,1,1,1l,1,Chainand,1 l1l2a,chain,1,chainin,1,1and,1n1c1 ( 1,1,1,1l1,1 1and 1 1 1
    ' +
    . ..
    }
    }
    Any idea?

  • @johnnylyimo
    @johnnylyimo Před rokem

    Good tutorial, i did create and update all went successfully, the last querying i got an error, TypeError: text.replaceAll is not a function
    at OpenAIEmbeddings.embedQuery (webpack-internal:///(sc_server)/./node_modules/langchain/dist/embeddings/openai.js:128:46)
    The code brought an error: let queryResponse = await index.query({vector:queryEmbeddings}) Please help me fix this error

  • @PiyushJaiswal-bu8qp
    @PiyushJaiswal-bu8qp Před rokem +1

    When I am trying to embedDocument it throws an error Request failed with status code 429 and sometime
    const subPrompts = (0, chunk_js_1.chunkArray)(this.stripNewLines ? texts.map((t) => t.replaceAll("
    ", " ")) : texts, this.batchSize);
    ^
    TypeError: t.replaceAll is not a function

    • @DevelopersDigest
      @DevelopersDigest  Před rokem

      I would first check your version of node and make sure you have an up to date version. You can do so by adding node -v in your terminal. I believe it was node version 15 or 16 when replaceAll was added into the engine :)

    • @PiyushJaiswal-bu8qp
      @PiyushJaiswal-bu8qp Před rokem

      @@DevelopersDigest I am using node version 19