LangChain Streaming - stream, astream, astream_events API & FastAPI Integration

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ก.ค. 2024
  • In this Video I will show you how to perform streaming with LangChain. I will also show you the astream_events API. At the end I gonna show you how you can integrate both approaches with FastAPI.
    Code: github.com/Coding-Crashkurse/...
    Timestamps:
    0:00 Introduction
    0:27 stream & astream
    2:00 astream_events API
    4:52 FastAPI Integration (StreamingResponse)
    7:42 Frontend Events
    9:16 astream_events with FastAPI
    #langchain #streaming #fastapi

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

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

    This is so good! Thank you so much.

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

    Wonderfully done

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

    Thanks a lot !! Love your stuff (:

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

    This is so cute

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

    spend so many hours on this couple of weeks ago until I got it running. I think this video will help a lot of people!
    One question to this: for the astream_events, can you also include the source documents "on_chat_model_end"? At the moment I have a second FastAPI endpoint which returns the source docs but I think it would be more efficient to include it at the end of a streaming response.

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

      When you know how to do it, its not that hard actually :)

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

      yes not that hard, you are right. I think there is a little mistake in the script.In "app_events.py" you are streaming the "model" and not the "retrieval_chain", or is this intended to be?

  • @SameerKhan-zi2ip
    @SameerKhan-zi2ip 2 หลายเดือนก่อน

    Can you tell me how to get data source as output? Like I want the document name and the text from document it referred to. I can't figure out how to access that.

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

    Great video! How could I do this but with ConversationalRetrievalChain to mantain memory & vectordb ?

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

      You can learn this in other videos from me, like the LCEL video, which is the basis for pretty much everything

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

    I think we can only use data streaming with openai? I wish you could do this on a local model like Llama2 without using openai.

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

      No, other models also offer streaming, not only openai. LLama3 SHOULD offer it, but I am not totally sure.

  • @riteshpanditi3635
    @riteshpanditi3635 25 วันที่ผ่านมา

    can you tell how to do streaming for a react agent with a vector db retriever tool and a internet tool

    • @codingcrashcourses8533
      @codingcrashcourses8533  25 วันที่ผ่านมา

      they all share the same interface, streaming works the same for all custom runnables

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

      ​@@codingcrashcourses8533 But I'm getting intermediate steps instead. Not getting a token by token answer like a runnable chain.

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

    How can we know if a model supports streaming or not?

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

    Hi, nice one, how can I stream using Flask not fast api? Can you please provide the code.

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

      flask.palletsprojects.com/en/2.1.x/patterns/streaming/

  • @SameerKhan-zi2ip
    @SameerKhan-zi2ip 2 หลายเดือนก่อน

    You made retriever_chain but never used it, also since it is never used how are we establishing connection between model and retriever then?

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

      Yes, i used the wrong variable in that project. Sorry

    • @SameerKhan-zi2ip
      @SameerKhan-zi2ip 2 หลายเดือนก่อน

      @@codingcrashcourses8533 no worries, good stuff man

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

    Full stack streaming- beautiful one suggestion mate give me a few seconds at the end so I can click like on my tv then you can suggest subscribe thank you!