LangChain Agents - Joining Tools and Chains with Decisions

Sdílet
Vložit
  • čas přidán 13. 03. 2023
  • Colab code Notebook: drp.li/FmrPY
    In this we look at LangChain Agents and how they enable you to use multiple Tools and Chains in a LLM app, by allowing your LLM to decide on the next input tool to use based on the user's input.
    My Links:
    Twitter - / sam_witteveen
    Linkedin - / samwitteveen
    Github:
    github.com/samwit/langchain-t...
    github.com/samwit/llm-tutorials
    #LangChain #BuildingAppswithLLMs
  • Věda a technologie

Komentáře • 105

  • @macbros5681
    @macbros5681 Před rokem +12

    No bullshit here straight to the point, clearly the goal is to improve viewers understanding of the subject first, really like your brand

  • @AP-hv5dh
    @AP-hv5dh Před rokem

    Outstanding Sam! Please keep them coming! 🎉

  • @catyung1094
    @catyung1094 Před rokem +1

    Love your LangChain series , Sam 💪💪💪

  • @dingruiwang3003
    @dingruiwang3003 Před 10 měsíci

    Thanks for the great help regarding the clarification of the Langchain concepts!

  • @K.F-R
    @K.F-R Před rokem

    Very helpful. Good deep dives on this topic are still rare. Thanks.

  • @jsonbourne8122
    @jsonbourne8122 Před 10 měsíci

    Great tutorial ! I can finally make sense of Tools.

  • @micbab-vg2mu
    @micbab-vg2mu Před rokem +1

    Another great video!!!Thank you.

  • @RapidExplainer
    @RapidExplainer Před rokem

    Just wowed at your tutorial. Thank you!

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

    Thanks for this very useful and descriptive video. I will start learning Lang chain

  • @luiztauffer8513
    @luiztauffer8513 Před rokem +12

    thanks for your LangChain playlist, it's definitely one of the best resources out there!
    Would be awesome to have your review on custom tools and agents, I find it to be the trickiest part in LangChain but also it's greatest potential

    • @samwitteveenai
      @samwitteveenai  Před rokem +1

      Glad you liked it. Yes I will don more with the Agents going forward and also plan to show making custom tools etc.

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

      @@samwitteveenai Great to know! How's these related video going?

  • @outofbounds9479
    @outofbounds9479 Před 13 dny

    Pretty amazing great work sam😊

  • @ObservingBeauty
    @ObservingBeauty Před rokem +1

    Truly helpful. Many thanks

  • @nishantshrivastava3031
    @nishantshrivastava3031 Před rokem +1

    Excellent stuff!

  • @niklase5901
    @niklase5901 Před rokem +1

    Great stuff, i really appreciate it!

  • @rajivraghu9857
    @rajivraghu9857 Před rokem +1

    Great stuff !!

  • @sprour
    @sprour Před rokem

    This is just mind blowing

  • @thecutestcat897
    @thecutestcat897 Před rokem

    thanks, this helps me a lot!

  • @vincentyang8393
    @vincentyang8393 Před rokem

    Hi Sam, great work! Very helpful for me. I am curious about how folks think about the potential of LangChain!

  • @OmarASultan
    @OmarASultan Před rokem +2

    Would be great if we can have a video on the Custom Agents
    Thank you so much for your videos, they are absolutely brilliant, really helped me

  • @sbacon92
    @sbacon92 Před 8 měsíci

    excellent.
    you should have a master class.

    • @samwitteveenai
      @samwitteveenai  Před 8 měsíci

      Yeah I am thinking of launching something like that. what would you like to see in it?

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

    Hi Sam great content. I am trying to figure out how I can build an agent that can answer questions from a) a repository of unstructured sources b) 5 to 10 SQL tables.

  • @iks_666
    @iks_666 Před 4 měsíci

    Great vids, all of'em. How did you implement the "terminal" tool tho?

  • @constantinebimplis
    @constantinebimplis Před rokem +1

    Amazing video! Finally I was able to understand and utilize agents. Thank you.
    I'm always experimenting in using opensource models along with openai. The terminal and search agent examples you discussed with the video fail with "ValueError: Could not parse LLM output:" when tried with huggingface models. A google search revealed that models used with these agents must follow the "conversational-react-description" template. Any ideas on which models would follow this template and would allow us to use openai alternatives? Thank you

    • @samwitteveenai
      @samwitteveenai  Před rokem +2

      Let me look into this. I think Cohere and Anthropic models should be ok. You could also finetune a model for this. I have some more vids on Agents planned so I will add this into the mix.

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

    Very very helpful video, thank you! I have to create a chatbot that knows only my documents informations. If the question isnt about docs content it must answer "i dont know" or something else, and it does not search answers on internet. Is there a way to create a search tool only about my docs folder? And then, for questions that arent about the context, should do i create another tool?

  • @vanheerdena
    @vanheerdena Před rokem +9

    That was extremely helpful. Could you cover custom agents? I need a way of using the response to make a decision. For example. In a multi-user chat log, if the question is directed at the chatbot respond else do nothing. Another example is an interviewer agent that has to either decide to probe for more information or go to the next question. Could you give any guidance on these kind of forking chain or custom agent type scenarios?

    • @samwitteveenai
      @samwitteveenai  Před rokem +5

      Will certainly make more vids around the Agents stuff. First will probably be explaining the paper behind it and then how you can manipulate the prompts. The idea of multi user would depend on a few things. Eg. does it know who is talking? eg. user1: blah blah, User2: blah blah etc

    • @vanheerdena
      @vanheerdena Před rokem +3

      @@samwitteveenai that would be awesome, your videos are really helpful! I think the general use case I need help with is calling a chain, getting a response, and then having some decision point that calls different chains depending on the outcome of chain 1. For the multi-user, yes I would know who the message is from. If user 1 said "does anyone know who the president of the USA is?" VS "chatbot, do you know who the president is" VS "user 2 do you know...". Chain 1 would need to work out an answer could be given to statement 1 and 3, but not say anything for 2. It's not the specific use case but more how to chain prompts where decisions from one prompt need to influence which of a range of secondary prompts should be called. It's quite possible this is easy to do and I'm just not fully understanding langchain yet😊

    • @sanjaythorat
      @sanjaythorat Před 8 měsíci

      Really helpful video. Thank you!

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

    How can you add custom tools with the specfied tool like serp, wiki, terminal and such and how can you alter the prompt template

  • @venkat1195
    @venkat1195 Před rokem +1

    legendddddddd

  • @Jay-Dub-Ay
    @Jay-Dub-Ay Před 8 měsíci

    It looks like you’ve strayed away from titling videos in this playlist with “Langchain Basics Tutorial #N”
    Is this a conversational buffer memory issue? 😂 but thank you for these videos! I’m really learning a lot 🙏❤️

  • @LucaMainieri68
    @LucaMainieri68 Před rokem +1

    Thank you for your amazing video and all work you do. I was wondering how to use langchain to perform data analysis on one or more datasets. Let's say I have leads, sell and orders dataset. Can I use langchain to perform some analysis, such as ask which customers placed the last order? How were sales last month?

    • @samwitteveenai
      @samwitteveenai  Před rokem

      Yes you could write your own chain to do various tasks like info extraction. You could also combine it with a database to answer more traditional database questions like how were sales last month etc.

  • @stanTrX
    @stanTrX Před měsícem

    Thanks. I will try it asap. How is it possible to end the conversation when it says "Finished Chain" i want to input user to Enter new prompt at this stage

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

    Great tutorial, thank you, Sam!
    The agent executor prompt can become quiet long. Is this being sent to the openai llm and costs tokens, or is it parsed by the agent? how does it work and how does it add to the economics?

    • @yans34
      @yans34 Před 8 měsíci

      Great question! I am also curious about this.

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

    Hi. Thanks for the tutorial. Can you please help me to understand what LangChain component should I use? I need to ask a user 2 follow up questions when user asks "How to pay less taxes?" and then prompt a model the initial user question with the additional information from the answers. I can't find an example of how to use Agents for this task. Thanks. Or maybe I should use Human as a tool from Agents integrations. But I do not understand how to force to ask particular questions when particular input received.

  • @christopheprotat
    @christopheprotat Před rokem +1

    Hey Sam. First. As usual thanks for the amazing content you gently share to the community. We learn a lot here. I have a question maybe you answered already. I am struggling using agents as you did but changing GPT to a smaller model like MPT-7B. That fails into error

    • @christopheprotat
      @christopheprotat Před rokem

      Forget my question. I think the model does not have capability to reason that far to handle the prompts and self reflection attached. Anyway. Still very powerful combined to openAI indeed

    • @samwitteveenai
      @samwitteveenai  Před rokem +1

      I am working on some things for testing open LLMs on reasoning and tasks like this and may also release a model for it.

    • @christopheprotat
      @christopheprotat Před rokem

      @@samwitteveenai that is great! Eager to see the result of your exploration. If we can help you in any manner, feel free.

  • @Ryan-yj4sd
    @Ryan-yj4sd Před rokem

    How do you give an initial goal to a langchain agent? It's fine to connect it to various tools, but I'd like to give it an initial goal/task. Any idea?

  • @user-su1iz6lm4p
    @user-su1iz6lm4p Před rokem

    Hey, I have a question:
    I built an Agent which I want to host via Gradio. It works and prints out the right result. Also on my machine I see the agent executor chain. How can I also print out the agent executor chain (in the machine and in Gradio). I mean If you can tell me how to print it in the machine, I can find a way to print it in gradio!

  • @ratral
    @ratral Před rokem

    @Sam, thanks for your great videos and the Colab Notebook code.
    Question: Is it possible to create an agent with a function in Python?
    For example:
    def area(diameter):
    return 3.14 * (diameter/2)**2
    Of course, I want to use more complex functions with more variables.
    Thanks

    • @samwitteveenai
      @samwitteveenai  Před rokem +1

      you want to call the function from a LLM tool or have the model output a python function. Check out the video about PAL chain that is creating the a python function from the LLM.

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

    Hi, when the agent decide to switch to another tool? Is there any score threshold as a reference

  • @AIforFun-jb9ph
    @AIforFun-jb9ph Před měsícem

    Very good , can we get this same into langserve to serve as an api

  • @ButilkaRomm
    @ButilkaRomm Před 2 měsíci

    Does this example use only one LLM - OpenAI? What Zero-shot-react-description does? It generates the template and then it calls OpenAI recursively by incorporating each response until the answer is found. Is that correct?

  • @RishabhGoyal
    @RishabhGoyal Před rokem

    Is there a way we can combine the RetrievalQAchain and Tools using Agents

  • @kevinyang2076
    @kevinyang2076 Před rokem

    Hi Sam, I tried your colab notebook example using the same OpenAI initialization (temp=0) and the exactly same tool/prompt/agent construction, however, when the query is not requiring to use one of the two tools like agent.run("Hi How are you today?"), the model seems to be confused and trapped in infinite loop, how can I solve this?
    this is the output:
    Entering new AgentExecutor chain...
    This is not a question that can be answered with a search or a calculator.
    Action: None
    Action Input: None
    Observation: None is not a valid tool, try another one.
    Thought: I need to answer this question with a response.
    Action: None
    Action Input: None
    Observation: None is not a valid tool, try another one.
    Thought: I need to answer this question with a response... and it keep repeats.

  • @kenchang3456
    @kenchang3456 Před rokem +1

    Indeed, you series is outstanding and is helping me build by POC. Did you ever get around to doing a video on zero-shot-react-description? I think that would help me progress on my form filling POC. Thank you very much for sharing.

    • @samwitteveenai
      @samwitteveenai  Před rokem +3

      No I have been wanting to make a ReACT video. I do show the Zero Shot ReACT in some other vids but need to make a ReAACT vid to explain it as it really is magic. Will try to get it out this week.

  • @shaunpx1
    @shaunpx1 Před 8 měsíci

    great video, do you have any videos that explain how to use agents and handle the output in Django and fast API for realmworld applicarions? I have found an overload of information and lots of issues getting the output using chat react models also how to pass prompt templates to an agent ?

    • @samwitteveenai
      @samwitteveenai  Před 8 měsíci +1

      I find the best way to handle prompts is to overload them if you need to change them. most the time though you can just pass variables into the prompts when you call them. getting output should be fine as strings if you want json back etc, then you can use a custom output parser etc. I have a number of vids showing those things.

  • @user-hs7kq7vd9l
    @user-hs7kq7vd9l Před rokem

    Hi Sam, Thanks for this video. Can we use langchain tools with Wizardllm or any other llm model without needing an openai key? because that would be great

    • @samwitteveenai
      @samwitteveenai  Před rokem

      I showed this in one of the vids last week. I will show some more non Open AI options in another video soon.

  • @qojte
    @qojte Před 8 měsíci

    howd you get the sick documentation background

  • @MomoCoder
    @MomoCoder Před rokem

    Hi thanks for the video, I am getting error: ValueError: Got error from SerpAPI: Invalid API key. -- I have the API key set to env and -- if I use GoogleSearch(search_params) it is working fine. Thanks in advance.

  • @seanng1809
    @seanng1809 Před 3 měsíci

    Can we have the agent run a mandatory tool and decide on some others tools ?

  • @EmilRock88
    @EmilRock88 Před rokem

    Minute 2:44, taking about zero-shot-react-etc.. you talk about a previous video and papaer. Could you point me out what is this paper name ?

  • @kajalmishra3225
    @kajalmishra3225 Před měsícem

    How can one return source_documents while working with agents having multiple tools?

  • @MrJvr80
    @MrJvr80 Před rokem

    Hi, this material is great.
    I have a follow up question- would you know how can I set up an agent to ask follow up questions as it needs the answers from the user to decide how to best proceed?
    For example: The user may ask a chatbot a question that can be theoretically answered by running a query in a SQL database, that the agent can access.
    However, dependent on the nature of the question, I would like to have the agent ask pre-programmed follow up questions, so that the agent use that extra information to run a more precise query.
    Any thoughts or pointers would be much appreciated.
    Thanks.

    • @MindsMusing
      @MindsMusing Před 10 měsíci +1

      @ MrJvr80 did you find the solution for that ? if yes, then can you please share it,

    • @alperenyuksel7184
      @alperenyuksel7184 Před 2 měsíci

      @@MindsMusing did you find the solution for that ? if yes, then can you please share it,

    • @MindsMusing
      @MindsMusing Před 2 měsíci

      @@alperenyuksel7184 I didn't not find the solution

  • @user-is6pg3ei9q
    @user-is6pg3ei9q Před 8 měsíci +1

    Hi Sam, Can we add chat memory buffer to agent for chat continuation?

  • @sysadmin9396
    @sysadmin9396 Před rokem

    In regards to using agents and tools:
    Is there a way to just use the llm for the initial prompt and then if the llm can’t answer it reverts to tools? I keep running into the issue where the agent decides to use a search tool rather than just use open ai’s llm (gpt-3.5) to try to answer the initial question.

    • @samwitteveenai
      @samwitteveenai  Před rokem

      You can get around this my changing the prompt and the tool description so that it only uses the search as a last resort etc. You will need to experiment with the prompt etc.

  • @kevinehsani3358
    @kevinehsani3358 Před rokem +1

    Than you for the video, it seems that we need to use template "agent.agent.llm_chain.prompt.template" as I tried to run without it and it could not answer "how are you today" and kept looping. I thought it could try to figure this out without a template. This is the message it kept outputting
    "Action Input: None
    Observation: None is not a valid tool, try another one.
    Thought: I need to answer this question with a response."

  • @kennt7575
    @kennt7575 Před rokem +1

    I have a question: in some cases, I have my own data stored in SQLite. Assuming that I want the agent to access my SQLite database to query data, how can I do that?

    • @samwitteveenai
      @samwitteveenai  Před rokem

      There is an Agent in LangChain that can do SQL queries. That should work.

    • @kennt7575
      @kennt7575 Před rokem

      @@samwitteveenai thanks, following your instruction, I tried to make a function.
      def query(input=""):
      sqlite_db_path = 'data/San_Francisco_Trees.db'
      db = SQLDatabase.from_uri(f"sqlite:///{sqlite_db_path}")
      db_chain = SQLDatabaseChain(llm=llm, database=db, verbose=True)
      result = db_chain.run(input)
      return result

  • @Phobos221B
    @Phobos221B Před rokem

    How to extract the Agent Executor chain thought processes and pass it to a FastAPI call?

    • @samwitteveenai
      @samwitteveenai  Před rokem +1

      Take a look at the custom agent /tools vids and ReACT

  • @sysadmin9396
    @sysadmin9396 Před rokem

    How can I get it to use the open ai llm first before trying the tools?

    • @samwitteveenai
      @samwitteveenai  Před rokem

      you could make a normal LLM chain and put that in a combined chain.

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

    @Sam Witteveen Hello Sam, Can we change the prompt associated with agents? If yes then let me know how to do that.

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

      Yes totally I go through that in a number of the early videos.

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

      @@samwitteveenai I am checking out your video's

  • @bartsekura
    @bartsekura Před rokem

    What's the paper about getting LLMS to take actions and generate steps?

    • @samwitteveenai
      @samwitteveenai  Před rokem +1

      The main one is the ReAct paper - arxiv.org/pdf/2210.03629.pdf I plan to make a vid on this and some similar research.

    • @bartsekura
      @bartsekura Před rokem

      @@samwitteveenai cheers!

  • @ferroumsamir6531
    @ferroumsamir6531 Před 2 měsíci

    My problem is: how do i combine Agents and sequentialchains. i have been looking on the internet, but nothing .

    • @samwitteveenai
      @samwitteveenai  Před měsícem

      This video is pretty old. The best way to do this now is to use LangChain Expression Language. I plan to make a new series with a lot of these changes soon. I already have one video about LCEL up

  • @brianrowe1152
    @brianrowe1152 Před rokem

    How do you make an vectorDb a tool so it can be in the tool list?

  • @avkashav
    @avkashav Před 8 měsíci

    Your voice is similar to Stewie Griffin from The Family Guy :D :P

  • @souvickdas5564
    @souvickdas5564 Před rokem

    How can we write the web crawled information in a file using this agent and tool? Please help

    • @samwitteveenai
      @samwitteveenai  Před rokem

      there is a write file tool, check that out.

    • @souvickdas5564
      @souvickdas5564 Před rokem

      @@samwitteveenai but I can't use the writefile tool in zeroshot react agents Or chat agents. Could you please help which agent can support write file tool. And I want the total crawled information not the summary or any specific short answer.

  • @wanted707
    @wanted707 Před 3 měsíci

    Хай, нужна помощь ( на Термуксе через Кали Линукс, ЛЛ АГЕНТ ВЫДАЁТ ОШИБКУ ПРИ ПОДКЛЮЧЕНИЕ К ИСКУСВСТУННЕМУ ИНТЕЛЛЕКТА)... КАК....? КАК РЕШИТ ЗАДАЧУ ?

  • @gameb30232
    @gameb30232 Před rokem

    how do i setup search engine api key?

    • @samwitteveenai
      @samwitteveenai  Před rokem

      Langchain docs should have a link to that from memory.

  • @user-wr4yl7tx3w
    @user-wr4yl7tx3w Před rokem

    Seems to be similar to HuggingGPT.

  • @user-wm2pb3hi7p
    @user-wm2pb3hi7p Před měsícem

    where you are joining tools and chains in this video??
    where you are using chains?
    you are just using agent with different tools.
    why are you even put the description like this?

  • @attilavass6935
    @attilavass6935 Před rokem

    I found that such questions like "How old is the current President?", the result got back is wrong, based on it calculates current day as Jun x 2021.
    Weird, because if I asked "what is the date today?", I got the correct answer. Google's search (tool: "google-search") was used.