Build a JavaScript AI Agent With LangGraph.js and MongoDB

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ธ.ค. 2024

ความคิดเห็น • 35

  • @MongoDB
    @MongoDB  3 หลายเดือนก่อน +4

    ✅ Written tutorial → mdb.link/article-qXDrWKVSx1w
    ✅ Create your free Atlas cluster → mdb.link/free-qXDrWKVSx1w
    ✅ Get help on our Community Forums → mdb.link/forums-qXDrWKVSx1w

    • @robrita
      @robrita 3 หลายเดือนก่อน

      quick question please.. once I created a vector index, what happen to new data coming in to the DB, will it get indexed as well?

    • @야햐-l9b
      @야햐-l9b หลายเดือนก่อน

      I want to get the current state without invoking the agent. I need to retrieve the chat history so I can display it on the UI, allowing the user to continue the conversation. However, I haven’t found a way to access the messages from the current state.
      Here’s how I’m doing it right now:
      '''
      async getChats(userId: string): Promise {
      const agentFinalState = await this.agent.invoke(
      { messages: [new SystemMessage('get-chats-of-the-user-from-memory')] },
      { configurable: { thread_id: userId }, recursionLimit: 10 },
      );
      return agentFinalState.messages
      .filter(
      (message: BaseMessage) =>
      message &&
      message.content &&
      !(message instanceof SystemMessage) &&
      !(message instanceof ToolMessage),
      )
      .map((message: BaseMessage) => ({
      type: message instanceof HumanMessage ? 'human' : 'ai',
      message: message.content,
      }));
      }
      '''
      Currently, I send a system message, and in the callModel function, if this message is detected, the model doesn’t proceed with a response.
      callModel:
      '''
      if (
      state.messages[state.messages.length - 1].content ===
      'get-chats-of-the-user-from-memory'
      ) {
      return;
      }
      '''
      This approach isn’t ideal, as it introduces other issues.
      we wanna add pagination as well

  • @ofofononoumoren
    @ofofononoumoren 5 วันที่ผ่านมา +1

    Very very great tutorial.

    • @MongoDB
      @MongoDB  2 วันที่ผ่านมา

      Thank you!

  • @bidokris
    @bidokris 3 หลายเดือนก่อน +4

    Awesome tutorial, easy to set up and follow along

    • @MongoDB
      @MongoDB  3 หลายเดือนก่อน

      Thanks so much!

  • @leonardowildt2613
    @leonardowildt2613 2 หลายเดือนก่อน +1

    Great video! Thank you!

    • @MongoDB
      @MongoDB  2 หลายเดือนก่อน

      You are welcome!

    • @leonardowildt2613
      @leonardowildt2613 2 หลายเดือนก่อน

      with all due respect has anyone told you that you look like a techie Tom Segura

  • @RomanH91
    @RomanH91 6 วันที่ผ่านมา +1

    Tokens increase when a dialog is long. How can I optimize it? Thank you for your answer!

    • @MongoDB
      @MongoDB  6 วันที่ผ่านมา

      Great question! Here are some things you could look into when handling memory in long conversations:
      - Only get the last N turns of the conversation
      - Store and retrieve conversation summaries instead of the full thread
      - Retrieve specific turns of the conversation using semantic search or a custom scoring mechanism
      - Apply prompt compression

  • @IkraamDev
    @IkraamDev 3 หลายเดือนก่อน +1

    I remember watching Jesse’s videos in early 2020 when I was learning to code.

    • @MongoDB
      @MongoDB  3 หลายเดือนก่อน +1

      Thank you! - Jesse 💪

  • @jaggyjut
    @jaggyjut 2 หลายเดือนก่อน +1

    Would have been great if there was a front end app as well. Great tutorial. Thank you

    • @codeSTACKr
      @codeSTACKr 2 หลายเดือนก่อน +1

      I debated that. I just wanted to focus on the tech and not distract from it. Which frontend tech would you have used? I'll be building more things like this and will include one in a future video.

    • @jaggyjut
      @jaggyjut 2 หลายเดือนก่อน

      ​@@codeSTACKrstreamlit or nextjs using cursor AI

  • @RomanH91
    @RomanH91 15 วันที่ผ่านมา

    I couldn't find info about formattedPrompt in the console.log. Where can I check if formattedPrompt works? I want to see the `time` and `tool_names`
    Thank you for the tutorial!

    • @MongoDB
      @MongoDB  13 วันที่ผ่านมา

      Thanks! It uses prompt templates. More info can be found here: js.langchain.com/docs/concepts/prompt_templates

  • @WongYamPan
    @WongYamPan 3 หลายเดือนก่อน +1

    This is good stuff. Unfortunately, I am familiar with mongoose.js and not Zod. Can the same result be achieve with mongoose.js instead of Zod? If the answer is yes, any video tutorials?

    • @MongoDB
      @MongoDB  3 หลายเดือนก่อน +2

      The answer is yes! And we are working on more examples to share very soon for both Mongoose and Prisma!

    • @WongYamPan
      @WongYamPan 3 หลายเดือนก่อน

      @@MongoDB Thank you! It will also be interesting to have a code-along that shows how we can clone/convert an existing Mongo Atlas database into a RAG and process it with two or three custom nodes/edges.

  • @RomanH91
    @RomanH91 15 วันที่ผ่านมา

    What is the difference between new MongoDBSaver() and new MemorySaver()? Besides refreshing the page, the conversation still remains

    • @MongoDB
      @MongoDB  13 วันที่ผ่านมา +1

      One saves to the MongoDB database and the other saves to the server memory. If the server reboots you will loose everything saved to memory.

  • @piyush_kashyap23
    @piyush_kashyap23 3 หลายเดือนก่อน +1

    What are recursion limit?

    • @MongoDB
      @MongoDB  3 หลายเดือนก่อน

      You can set the recursion limit as needed. It's up to your use case.

  • @pubsub8143
    @pubsub8143 3 หลายเดือนก่อน +2

    @MongoDb, This video is really very helpful for me. Thank you so much for this tutorial. I am currently implementing something using LangGraph and MongoDB. I cloned the repository and ran it locally. In the Agents.ts file, I replaced Anthropic with OpenAI:
    const model = new ChatOpenAI({
    modelName: "gpt-4o-mini",
    temperature: 0,
    }).bindTools(tools);
    I was able to start the server and ask queries. However, it's not invoking the employeeLookupTool, and I'm not sure what I'm missing. Please help.
    Also, I have the knowledge base vectors in another collection. I wanted to create a new agent for the knowledge base and will try to implement it.

    • @pubsub8143
      @pubsub8143 3 หลายเดือนก่อน

      It worked, after I change from modelName: "gpt-4o-mini", to modelName: "gpt-4o", maybe mini doesn't support bindtools I guess,
      I want to get all the raw user query and AI response from the mongodb based on threadid, can you please help with the mongo query for that? Thanks in advance.

    • @MongoDB
      @MongoDB  3 หลายเดือนก่อน

      Glad you got it working. You can alter the thread route to return any info you'd like in the response.

  • @itl4755
    @itl4755 14 วันที่ผ่านมา +1

    is anybody else's mind blow..

    • @MongoDB
      @MongoDB  13 วันที่ผ่านมา

      yep!!

  • @karannesh7700
    @karannesh7700 24 วันที่ผ่านมา

    Really nice video, but please avoid this blinking cursor .. its distracting... :( thanks

    • @MongoDB
      @MongoDB  16 วันที่ผ่านมา

      you either love it or hate it 😅