Stream LLMs with LangChain + Streamlit | Tutorial

  Рет қаралды 16,282

Alejandro AO - Software & Ai

Alejandro AO - Software & Ai

Күн бұрын

This video shows how to build a real-time chat application that enhances user experience by streaming responses from language models (LLMs) as they are generated. This video is perfect for both beginners and seasoned developers interested in integrating the power of language models into chat applications using Streamlit and Lang Chain.
Useful links:
📌 Article with code: alejandro-ao.com/how-to-use-s...
💬 Join the Discord Help Server: link.alejandro-ao.com/HrFKZn
❤️ Buy me a coffee... or a beer (thanks): link.alejandro-ao.com/l83gNq
✉️ Get the Newsletter: link.alejandro-ao.com/AIIguB
🚀 What You Will Learn:
How to set up your development environment for working with Streamlit and Lang Chain.
Step-by-step guidance on building a chat interface that streams language model responses in real-time.
Implementing the chat history feature to make your chatbot smarter and more contextual.
Tips and tricks for optimizing the performance of your chat application.
Integrating OpenAI models with Lang Chain for dynamic conversation generation.
💻 Technologies Covered:
Streamlit: For creating the front-end of the chat application.
Lang Chain: To interact with language models and handle real-time streaming of responses.
OpenAI Models: Leveraging powerful AI models for generating conversational responses.
🔧 Prerequisites:
Basic understanding of Python programming.
Familiarity with chatbot concepts and language models is helpful but not required.
👨‍💻 For Whom:
This tutorial is designed for software developers, data scientists, and tech enthusiasts interested in building real-time chat applications, integrating language models, or exploring new ways to enhance user engagement through streaming technologies.
🔗 Join Our Community:
Don't forget to subscribe to our channel for more tutorials on the latest software technologies. Join our Discord server to stay updated and connect with a community of like-minded individuals.
👉 Watch, Learn, and Code Along as we build a real-time chat application from scratch, showcasing the practical implementation of streaming responses for a seamless user experience. Whether you're building for fun or looking to integrate chat functionalities into your projects, this tutorial has you covered.
Timestamps:
0:00 Intro
0:46 What we will build
1:51 Project Setup
4:07 Create Chat UI
9:51 Chat Functionality
14:40 Add Streaming to App
17:28 Conclusion
#Streamlit #LangChain #RealTimeChat #LanguageModels #OpenAI #SoftwareDevelopment #Tutorial

Пікірлер: 84
@gabrieljauregui654
@gabrieljauregui654 3 ай бұрын
Great tutorial to keep us practicing both LangChain and Streamlit! Greetings from Argentina 😊😊
@alejandro_ao
@alejandro_ao 3 ай бұрын
greetings!
@ronikh4n
@ronikh4n 2 ай бұрын
Fantastic walkthrough! I was wondering if you could create a tutorial on how to build a custom Knowledge Retrieval service using Langchain. The idea behind this service is to allow users (multi tenancy) to chat with their uploaded documents in different formats like PDF, CSV, and Text, while ensuring that the data remains accessible only to the user/owner who uploaded the file.
@chibuzoemelike6403
@chibuzoemelike6403 3 ай бұрын
This is very helpful, will be great to see something on Langraph and Agents. Thank you for all your support
@alejandro_ao
@alejandro_ao Ай бұрын
i have been planing to bring langgraph for a while. so many things to cover. i have started covering agents a bit more, though!
@duanxn
@duanxn 2 ай бұрын
great tutorial, step by step and crystal clear
@alejandro_ao
@alejandro_ao 2 ай бұрын
it's my pleasure :)
@ralphanthony5198
@ralphanthony5198 3 ай бұрын
Great content, amigo! Awesome work!
@alejandro_ao
@alejandro_ao 3 ай бұрын
Thanks amigo!
@edsonrodas3954
@edsonrodas3954 2 ай бұрын
I'm recently learning python and for me this is amazing. You make it look so easy, thanks for share your knowledge
@alejandro_ao
@alejandro_ao 2 ай бұрын
this is beautiful to hear. thank you 😊 keep it up, you're on the right path!
@jamessebastian8912
@jamessebastian8912 3 ай бұрын
Thanks! Great Tutorial.
@alejandro_ao
@alejandro_ao 2 ай бұрын
hey thanks for the tip
@zeelthumar
@zeelthumar 3 ай бұрын
That write_stream function is cool.. thanks for sharing this buddy.
@alejandro_ao
@alejandro_ao 2 ай бұрын
i know, they released it a few days ago. those guys at Streamlit are building super cool things
@ayoolaadedeji9353
@ayoolaadedeji9353 2 ай бұрын
I can't get the write_stream attribute to be recognised :/@@alejandro_ao
@hakikitosunpasa335
@hakikitosunpasa335 3 ай бұрын
Amazing tutorial, I wonder how to use LCEL with RAG and streaming output in conversational setting...
@Reality_Check_1984
@Reality_Check_1984 Ай бұрын
This is an amazing video. Extremely helpful. How would you go about sequential chains with this? I have been picking up errors and not sure where to read into this more.
@julienduchesneau9747
@julienduchesneau9747 Ай бұрын
yeah good video thank you, I will try to had a sidebar to ajust temp and token lenght with previous videos and see how it goes.
@cindywu3265
@cindywu3265 2 ай бұрын
Very clear and great content to follow along! I am able to build a chat app with multiple pdfs with ConversationalRetrievalChain, but not sure how to implement streaming with that. Hope I will see one soon!
@alejandro_ao
@alejandro_ao 2 ай бұрын
hey there. yeah, you can totally implement streaming with conversational retrieval chain. but you would probably need to use the latest version of it. i think that the class-based chains (like the one you mentioned) are not compatible with LCEL but I am not certain. try creating your chain like this: python.langchain.com/docs/expression_language/cookbook/retrieval
@cindywu3265
@cindywu3265 2 ай бұрын
@@alejandro_ao Awesome, thank you Alejandro! Look forward to your next video
@mikachiche
@mikachiche 2 ай бұрын
Thanks you very useful tuto, you should explain a little more what and why you're doing something
@cristianaguilar4253
@cristianaguilar4253 3 ай бұрын
nice. gracias alejandro
@alejandro_ao
@alejandro_ao 2 ай бұрын
un placer, cristian :)
@chikosan99
@chikosan99 Ай бұрын
Thanks a lot !! great
@alejandro_ao
@alejandro_ao Ай бұрын
Glad you liked it!
@amorotto
@amorotto 3 ай бұрын
Great video! would be great to create a similar one for conversational agents with tools using LCEL as well!
@alejandro_ao
@alejandro_ao 3 ай бұрын
i'm working on something like that :)
@geekyprogrammer4831
@geekyprogrammer4831 3 ай бұрын
Thank you so much ❤❤
@alejandro_ao
@alejandro_ao 3 ай бұрын
it's my pleasure!
@user-yh1qt9tf4u
@user-yh1qt9tf4u Ай бұрын
I like your so helpful videos so much. Recently, with the help of your videos, I created a customized Rag chatbot with nice avatars and customized HTML. So with the langchain chat message function and the chat history. Text streaming using chat message instead simple langchain message as add on is not possible, is it?
@dhmkkk
@dhmkkk 2 ай бұрын
is there any way to incorporate streamlit button inputs and llm to answer from that like i ask give menu options and it shows options as buttons and when i click one the llm knows what i selected
@ramkipalle6612
@ramkipalle6612 3 ай бұрын
How can we do the streaming if the backend chain logic is exposed as REST API? In this example, both backend and frontend logic is there in the same file.
@ajay.kartheek
@ajay.kartheek 3 ай бұрын
Great Tutorials...... Can you tell me what I need to know to build an RAG application like webpage query bot without using streamlit (python based web developemnt will be very useful for me)... I am trying to build an project for my Placement drives. Plz help me through this!! Thank you!!
@AageSundvor
@AageSundvor 24 күн бұрын
Is it possible to add tools to this chatbot or must an agent be used? Maybe you could show how the best way to add search tool for the bot?
@AIdevel
@AIdevel 3 ай бұрын
Thanks for this great video I wonder how to integrate the streaming method in my RAG application, how to stream the response in RAG based app that uses Qdrant database would you explain it for me ❤❤
@fatiga2426
@fatiga2426 18 күн бұрын
Great video! I was wondering, why is it necessary to use a Str output parser? Why not getting the content string from de answer directly? Thanks!
@alejandro_ao
@alejandro_ao 17 күн бұрын
hey! you can do that too. that was mostly to show how to use the output parsers. but usually you would use the output parser within a chain rather than at the end. inside a chain, if your next step in the chain requires a string input, using an output parser will make sure that it works regardless of what the intermediate step returns 👍
@anuvratshukla7061
@anuvratshukla7061 2 ай бұрын
How can we do the same streaming with Mixtral LLM? I'm using Mixtral (huggining face inferecing) + Langchain + Streamlit. LLM is used as pandas agent and I want to stream the response.
@jamessebastian8912
@jamessebastian8912 3 ай бұрын
Thanks!
@alejandro_ao
@alejandro_ao 2 ай бұрын
*thanks to you!*
@softwareideology2033
@softwareideology2033 2 ай бұрын
Hi ! I impressed with your chat with MySQL solution Can you make a video about chat with api which has swagger docs ?
@ersaaatmeh9273
@ersaaatmeh9273 2 ай бұрын
Hi , could I ask you how I can do the same step if I try LLM from Hugging Face?
@srikanthverpula6271
@srikanthverpula6271 2 ай бұрын
its good but if possible can you work on function calling (Realtime API multiple) in conversational way?
@limjuroy7078
@limjuroy7078 2 ай бұрын
After watching this video, I am thinking of updating the code for your Multiple PDF Chat Tutorial that I have followed fw months ago. I am considering replacing the existing ConversationalRetrievalChain and BufferMemory with LCEL as demonstrated in the video.
@alejandro_ao
@alejandro_ao 2 ай бұрын
yes! i really need to update that video. the core remains relevant, but the code might need some brushing up
@limjuroy7078
@limjuroy7078 2 ай бұрын
@@alejandro_ao Hope you will do that and come out with a video asap.
@Emmanuel-xe5bc
@Emmanuel-xe5bc 29 күн бұрын
great job. I hope i can use part of your code for school assignments?
@alejandro_ao
@alejandro_ao 26 күн бұрын
absolutely! and tell your friends about the channel in case they want to learn more about LLM apps :)
@sebastianalza4595
@sebastianalza4595 Ай бұрын
what a voice men
@alejandro_ao
@alejandro_ao Ай бұрын
do not smoke
@sebastianalza4595
@sebastianalza4595 Ай бұрын
@@alejandro_aohahahahahhaah
@mirzatouqirbaig3920
@mirzatouqirbaig3920 3 ай бұрын
Great video. Can you make a video on LangGraph?
@alejandro_ao
@alejandro_ao 3 ай бұрын
hey there, sure! coming soon!
@jamalnuh8565
@jamalnuh8565 3 ай бұрын
We I reimplement your code I got errors I wonder, I almost clone three of your repo and fails although I try to use free API such as hugging face
@ScottSummerill
@ScottSummerill 3 ай бұрын
Just stumbled across your channel. Looks pretty decent. Curious what the AO means.
@alejandro_ao
@alejandro_ao 3 ай бұрын
thanks! welcome to the community :) AO is just my initials btw
@tojitojira858
@tojitojira858 2 ай бұрын
Thank, how should be process to add this functionality on your example "chat wit a website" ?
@alejandro_ao
@alejandro_ao 2 ай бұрын
hey there! all you got to do is use `stream` instead of `invoke` and yield the results using `st.write_stream`. did you manage to make it work?
@tojitojira858
@tojitojira858 2 ай бұрын
@@alejandro_ao I applied the changes mentioned in your video, but I didn't manage to get the same result as you.
@tojitojira858
@tojitojira858 2 ай бұрын
@@alejandro_ao the message is displayed but a very long json variable
@shobhitagnihotri416
@shobhitagnihotri416 3 ай бұрын
How can we generate an assistant that can provide code after uploading documentation of frame work . Please make something related to this . Thank in advance
@alejandro_ao
@alejandro_ao 3 ай бұрын
that's a bit more tricky since we usually need a lot of context to write good code. gemini 1.5 is capable of doing this afaik. i'll make some videos about this!
@hakeemowais9845
@hakeemowais9845 3 ай бұрын
Can you please make a chatbot on an open source model. And Great Tutorial as always 🎉
@alejandro_ao
@alejandro_ao 2 ай бұрын
hey there! sure, i will be including more open source models in the demos fron now on :)
@geekyprogrammer4831
@geekyprogrammer4831 2 ай бұрын
Can you create a tutorial on Langgraph?
@abhijitubale
@abhijitubale 2 ай бұрын
Hey Alejandro, Please do let us know which code completion extension/plugin are you using…it seems really “ahead” of you in the video…
@abhijitubale
@abhijitubale 2 ай бұрын
Does anyone know ??
@alejandro_ao
@alejandro_ao 2 ай бұрын
hey there! i am using github copilot. it's great :)
@parmoksha
@parmoksha 2 ай бұрын
This site can’t be reached . Blog giving error
@AIdevel
@AIdevel 3 ай бұрын
This is really excellent video It’s exactly what I have been looking for Would you please tell me how to use it with RAG applications please make video about that because it’s a game changer in python chat bots 🤖 I tried but failed I need your assistance 😊
@alejandro_ao
@alejandro_ao 3 ай бұрын
hey there! glad to hear this! sure thing. i have been covering RAG quite a bit. even though i have much more content about this coming :) - my most recent video about it is this one, which shows how to do RAG on a web page's contents: kzbin.info/www/bejne/mKbTqWNuj8yGfMksi=A8fPDeepjKuPe2oP - this one is a more detailed and is about PDF files, but with a slightly older version of langchain: kzbin.info/www/bejne/monbgmOCh5Jmfsksi=FnULh8P7fn4Iq7df
@AIdevel
@AIdevel 3 ай бұрын
@@alejandro_ao Off course I am keen follower of yours I’ve seen them but I mean how to integrate the message streaming with RAG app ? In the retrieval chain ? and how exactly to achieve it ?
@alejandro_ao
@alejandro_ao 3 ай бұрын
@@AIdevel oh alright! i will incorporate streaming next time i make a RAG app! 🤓 thanks for following the channel!
@PapaioannouOrama
@PapaioannouOrama Ай бұрын
@@alejandro_ao pretty sure retriever objects don't support streaming, I know it's possible to have some elements in your chain that don't support streaming though
@jamalnuh8565
@jamalnuh8565 3 ай бұрын
Can u use not openAI API s
@alejandro_ao
@alejandro_ao 2 ай бұрын
sure thing :)
@parkeatshark4364
@parkeatshark4364 2 ай бұрын
Could it possible to do this with free account of openai
@alejandro_ao
@alejandro_ao 2 ай бұрын
hey there, if you don't want to use openai, you can always use a free model. Groq has a free API (for now) and they allow you to try out Mistral, Gema and Llama2 for free. check them out and the just implement them like this: python.langchain.com/docs/integrations/chat/groq (it should be about a couple lines of code!)
@parkeatshark4364
@parkeatshark4364 2 ай бұрын
Thanks you, I will try this one btw your content is very helpful and easily understood@@alejandro_ao
@Shakti18348
@Shakti18348 3 ай бұрын
How to stream responses of the previous chatbot you made where you used create_retrieval_chain I'm getting an error: return conversational_rag_chain.stream({ TypeError: 'generator' object is not subscriptable
@ErwinWientjes
@ErwinWientjes 2 ай бұрын
where has your site gone
@alejandro_ao
@alejandro_ao 2 ай бұрын
hey can you please check again? i think the dns is taking too long to propagate :S
Tutorial | Chat with any Website using Python and Langchain (LATEST VERSION)
1:21:13
Alejandro AO - Software & Ai
Рет қаралды 54 М.
Chat with MySQL Database with Python | LangChain Tutorial
37:11
Alejandro AO - Software & Ai
Рет қаралды 29 М.
Sigma Girl Education #sigma #viral #comedy
00:16
CRAZY GREAPA
Рет қаралды 75 МЛН
Be kind🤝
00:22
ISSEI / いっせい
Рет қаралды 19 МЛН
Super sport🤯
00:15
Lexa_Merin
Рет қаралды 20 МЛН
What is LangChain?
8:08
IBM Technology
Рет қаралды 130 М.
Create a RAG Chain using LangChain 0.1 (New version)
52:10
Alejandro AO - Software & Ai
Рет қаралды 21 М.
5 Things I Wish I Knew Before Learning Streamlit
21:34
Fanilo Andrianasolo
Рет қаралды 18 М.
Generating Plotly Charts in Streamlit
16:39
The Analytics Professor
Рет қаралды 1,9 М.
5 New AI Tools You Should Try
9:18
Skill Leap AI
Рет қаралды 8 М.
15 crazy new JS framework features you don’t know yet
6:11
Fireship
Рет қаралды 406 М.
Chat with MySQL Database using GPT-4 and Mistral AI | Python GUI App
1:01:00
Alejandro AO - Software & Ai
Рет қаралды 17 М.
Streaming for LangChain Agents + FastAPI
27:42
James Briggs
Рет қаралды 28 М.
LangChain Explained in 13 Minutes | QuickStart Tutorial for Beginners
12:44