Тёмный
No video :(

Streaming for LangChain Agents + FastAPI 

James Briggs
Подписаться 67 тыс.
Просмотров 31 тыс.
50% 1

Опубликовано:

 

28 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 65   
@llaaoopp
@llaaoopp 11 месяцев назад
Wanted to get to this for quite a while but it was never a priority. Love that I am now able to simply follow your advice instead of going through this all on my own! Thanks for the great videos, they are an incredible resource!
@jamesbriggs
@jamesbriggs 11 месяцев назад
haha glad to hear, it can be a little fiddly to get right
@3stdv93
@3stdv93 11 месяцев назад
I'm searching for this for a along time. Thank you! ❤
@Brkcln
@Brkcln 10 месяцев назад
These recommendations were really helpful! I'm excited to watch all the series you shared. Thanks a lot for sharing them with us
@zacboyles1396
@zacboyles1396 11 месяцев назад
Over the weekend I was working on this exact problem. I couldn’t say which part I was missing, probably different parts at different times. What I can say is how epic it was to start the day with this video, thank you 🙏 legend! … I don’t suppose you feel like taking a crack at autogen next 😅 In any case thanks again!
@jamesbriggs
@jamesbriggs 11 месяцев назад
autogen is interesting, so maybe haha - glad this video helped :)
@tonymizunhi
@tonymizunhi 6 месяцев назад
great tutorial, super useful. thanks for sharing!
@sanchaythalnerkar9736
@sanchaythalnerkar9736 11 месяцев назад
That is so great , now I can integrate my agent into the chatbot
@domineia
@domineia 2 месяца назад
Really helpful content, thank you for sharing it.
@Hyferionx
@Hyferionx 10 месяцев назад
Great video! Do you know why this doesn't work with a GET request? If I send a GET request instead of a Post (of course I adapted the API) it loads the whole message first and then sends it to the client instead of doing it async.
@brandonreid797
@brandonreid797 11 месяцев назад
Thanks for the awesome walk through! Have you had a chance to test this flow with OpenAI Function Calls? I have a similar implementation for streaming, but once the LLM triggers an OpenAI Function Call, it fails to stream - It seems like the iterator just doesn't return any tokens.
@jamesbriggs
@jamesbriggs 11 месяцев назад
I haven't yet but will try it out
@brandonhresko6844
@brandonhresko6844 10 месяцев назад
having the same issue, have you solved it?
@henkhbit5748
@henkhbit5748 11 месяцев назад
Excellent video about streaming👏👏 extending with voice streaming if a complete sentence is streamed would be cool…
@jamesbriggs
@jamesbriggs 11 месяцев назад
that would be incredibly cool - will try it out
@tichon007
@tichon007 5 месяцев назад
Really useful. You win a subscriber 😅
@coreymiller6581
@coreymiller6581 4 месяца назад
Why is it you can create a fairly simple generator to the frontend using the LLM, but when you add an agent, it becomes so needlessly cumbersome? Anyway, amazing job with the tutorial!!! You're a Godsend.
@rithickguru1561
@rithickguru1561 11 месяцев назад
Really Useful content!!!
@ABHISHEKSHARMA-fo4tf
@ABHISHEKSHARMA-fo4tf 11 месяцев назад
This is amazing video where we can get lot of information . Can you make a video on how we connect streaming with llmchain and memory and show the streaming in webpage or html or streamlit?
@JohanFire
@JohanFire 3 месяца назад
Great video! How could I do this but with ConversationalRetrievalChain to mantain memory & vectordb ?
@eduai-1
@eduai-1 6 месяцев назад
hey, when I use tool, the streaming stops. When no tool is used, streaming occurs as expected but when a tool is called, the final response after taking observation into consideration doesnt comes in aiter() function
@sowmyancs
@sowmyancs 9 месяцев назад
Great content. It works with Agent, in my case I need to use AgentExecutor instead of Agent, agent_executor = AgentExecutor(agent=agent_chain, memory=memory, verbose=True, tools=tool_list,return_intermediate_steps=False) Look like AgentExecutor is not streaming with LCEL. Any ideas?
@abdullahhashmi654
@abdullahhashmi654 7 месяцев назад
I have the same issue. I have a few tools, and an Agent executor which handles all the calls. I am using a SQL database tool, and even though the tool itself is giving me streamed results, the final answer is not streamed. Any idea how to tackle this?
@oliver1231033
@oliver1231033 6 месяцев назад
@@abdullahhashmi654 I got the exact same issue
@mahdifalek252
@mahdifalek252 3 месяца назад
any updates ?? if u find a solution how with agent executor ??
@hamzakivideo
@hamzakivideo 11 месяцев назад
I see what you did there 😂 awesome stuff
@maxlgemeinderat9202
@maxlgemeinderat9202 7 месяцев назад
Would be nice if you could do another example on Streaming with FastAPI, Langchain and a local model, for example when building a Rag app
@digitalchild
@digitalchild 7 месяцев назад
Looks like since the last langchain update all the current calls are deprecated. Do you have any details on how to update the code to work with all the changes?
@AnubhavGoel-cj3fq
@AnubhavGoel-cj3fq 5 месяцев назад
great video! but whenever i try to run uvicorn main:app --reload in the terminal, i get this error: TypeError: multiple bases have instance lay-out conflict
@peterc.2301
@peterc.2301 11 месяцев назад
Excellent video as always! Do you have any idea about how to use the "Professor Synapse" prompt with langchain?🙂
@schOOlsin
@schOOlsin 9 месяцев назад
It seems there's some kind of issue when trying to perform the get_stream("Hi there") the second time. The first time i receive correctly: { "action": "Final Answer", "action_input": "Hello! How can I assist you today?" } the second time i just receive: Hello! How can I assist you today? and that generates an exception
@kamalkamals
@kamalkamals 8 месяцев назад
Good example but the result still very summarised specially when using search engine like serper, so the question here how can control size of response text, because there are same cases need response contain more of details.
@ersaaatmeh9273
@ersaaatmeh9273 5 месяцев назад
Hi James, could I ask you how I can do the same step if I try LLM from Hugging Face?
@caizenz
@caizenz 10 месяцев назад
intresting , do you know what other llms or platforms that supports streaming ? like from replicate or clarifai ?
@ngontinhhaymely
@ngontinhhaymely 10 месяцев назад
how to set a timeout for the agent, agent sometimes forgets the prompt and stuck there with streaming.
@fredrik-ekelund
@fredrik-ekelund 11 месяцев назад
👍👍👍 Thanks!!
@shivarajgudaganatti8573
@shivarajgudaganatti8573 8 месяцев назад
How can i get to extract only the LLM Langchain thoughts and stream those.
@qochpeter9836
@qochpeter9836 11 месяцев назад
Thank you very much James for this tutorial! The FastAPI template works perpectly without adding tools. When I add LLMMathChain tool to the agent, the application starts normally but it just stucks at the step "Entering new LLMMathChain chain..." I have only access to AzureOpenAI. I wonder if it is an AzureOpenAI problem or it is a general problem. Have you tried to add tools for the Agent in the FastAPI code and did it work? I also tested with Zero-shot agent, the result is the same. > Entering new AgentExecutor chain... ```json { "action": "Calculator", "action_input": "50 * 48" } ``` > Entering new LLMMathChain chain... Many thanks in advance!
@jamesbriggs
@jamesbriggs 11 месяцев назад
No it’s just a case of modifying the async iteration logic to handle how you should deal with tools (if-else statements to handle when to stream and when not to) - there may be some other LLM math specific behaviour that I haven’t come across though as I have not used that specific tool with this
@CintraAI
@CintraAI 10 месяцев назад
@@jamesbriggs Ya, most tools should have an _arun method that works with the acall agent function. if it cant run async, you'll have to modify _arun to just return self._run, and it should work. This means you won't be able to stream the result of that tool right away, but you can stream the resulting response from the AI
@shaunpx1
@shaunpx1 11 месяцев назад
So I got a question, do we need to specify an input and output parser using and agent for the APIs I'm trying to wire one up to Django rest api and get constant errors saying LLM output can't parse but yet works perfect in Colan? plus is there a difference. betwee other agents and using initialize_agent its hard to get a clear answer answer on the data structures and usage of agent methods in langchain or just a something that is clear and not all over the the place info overload with their docs? thanks, Awesome content by the way. Do you have any other videos clarifying agents?
@jamesbriggs
@jamesbriggs 11 месяцев назад
If not using streaming you can use the standard output parser classes in LangChain, with streaming you should try and parse live, which is harder but typically doable unless the model really messes up I have a YT course on LangChain, chapters 7-9 focus on agents :) ru-vid.com/group/PLIUOU7oqGTLieV9uTIFMm6_4PXg-hlN6F
@shaunpx1
@shaunpx1 10 месяцев назад
Awesome this worked thank you so much!!@@jamesbriggs
@sabalmalhan5447
@sabalmalhan5447 11 месяцев назад
Question - I followed along and ensured the code matches, however I am unable to emulate this streaming behavior when calling the "get_stream" function. It seems to still wait for the chain to complete gathering the text and then printing it all at once. Any pointers on what might have gone wrong?
@jamesbriggs
@jamesbriggs 11 месяцев назад
maybe you're missing an async function somewhere?
@zacboyles1396
@zacboyles1396 11 месяцев назад
Make sure websockets are installed.
@zacboyles1396
@zacboyles1396 11 месяцев назад
Or the uvicorn standard extras: “uvicorn[standard]”
@zacboyles1396
@zacboyles1396 11 месяцев назад
I pulled up the sample to check and ran into the issue too. In my working code, the equivalent to the demo `AsyncCallbackHandler`, I’m overriding `__init__` and calling `super().__init__()`. Changing that got it working for me. I bet if you’d used the built-in handler and switched to custom without full shutdown, you wouldn’t catch the issue.
@sabalmalhan5447
@sabalmalhan5447 10 месяцев назад
Hmm thanks for the idea@@zacboyles1396 , however it still doesn't seem to work for me - I did confirm websockets and the uvicorn extras as also installed. The standard handler does seem to work better (although not perfect as seen in the video)
@cihangirkoroglu
@cihangirkoroglu 6 месяцев назад
Thank you.. great video.. so how can I implement this streaming to a text to speech app... like pyttsx3...
@setop123
@setop123 6 месяцев назад
Langchain make me regret even using a framework for my LLMs...it's awful.
@jamesbriggs
@jamesbriggs 6 месяцев назад
they do have new streaming API - apparently better, will look into it soon
@ABHISHEKSHARMA-fo4tf
@ABHISHEKSHARMA-fo4tf 11 месяцев назад
the streaming is print in terminal , how we can streaming do with show in the webpage ?
@jamesbriggs
@jamesbriggs 11 месяцев назад
check out the final part of the video, I show how to stream from fastapi - that is how you'd do it
@ABHISHEKSHARMA-fo4tf
@ABHISHEKSHARMA-fo4tf 11 месяцев назад
@@jamesbriggs can I used conversational chain and memory with chain predict and show like streaming?
@muazashraf409
@muazashraf409 9 месяцев назад
I am using flask and html. I add this callback and get the streaming response in terminal but not frontend. I also use websocket, SSE client but not succeed.
@izarniz
@izarniz 13 дней назад
How did you fix that issue?
@vaibhavsaxena6482
@vaibhavsaxena6482 11 месяцев назад
How can we stream LLAMA on gradio?
@saibhaskerraju2513
@saibhaskerraju2513 4 месяца назад
please update your notebook. langchain code changed. kindly update
@engineeredmind
@engineeredmind 9 месяцев назад
Langchain really needs to get it together with the streaming structure. This is terrible.
@coreymiller6581
@coreymiller6581 4 месяца назад
Seriously.
@gabrielvinicius6766
@gabrielvinicius6766 10 месяцев назад
Anyone can streaming with any opensource model?
@romeogomez9948
@romeogomez9948 10 месяцев назад
I need that but with pinecone
@Viellmo
@Viellmo 10 месяцев назад
I have a question -> What encoding should I use to encode Polish characters, because line.decode("utf-8") returns errors for Polsih letters. I tried other encodings but its, not working. Any ideas @jamesbriggs ?
Далее
LangChain Multi-Query Retriever for RAG
18:46
Просмотров 27 тыс.
LangGraph 101: it's better than LangChain
32:26
Просмотров 68 тыс.
Reforged | Update 0.30.0 Trailer | Standoff 2
02:05
Просмотров 770 тыс.
Semantic Chunking for RAG
29:56
Просмотров 22 тыс.
DataStreaming with LangChain & FastAPI
8:51
Просмотров 17 тыс.
RAG But Better: Rerankers with Cohere AI
23:43
Просмотров 58 тыс.
OpenAI Embeddings and Vector Databases Crash Course
18:41
GPTs vs Assistants API - which one is best for you?
13:09