How I Use OpenAI Assistants API To Control My Streamlit App

  Рет қаралды 9,298

Fanilo Andrianasolo

Fanilo Andrianasolo

Күн бұрын

Seen the OpenAI Dev Day Wanderlust Assistants API demo and wondering how to implement a similar web app in full Python? It's all thanks to the new Assistants API feature and its integrated Function Calling.
In this video, I prototype a Streamlit version of the app. Through this quick overview, you'll learn to:
- leverage Streamlit's Session State for a clean reactive app using an MVC-like pattern
- configure an OpenAI Assistant API 's Function calling feature to have OpenAI talk with your app by mapping user intent to predefined functions
- layout a chatbot and Plotly map through columns and configured by Streamlit secrets
At the end of this video, you will be able to interactively experiment with the new Assistants API through a Streamlit app and have natural language control the flow of your app.
00:00 Intro
00:45 Python App Skeleton
01:55 Configure GPT to generate code?
03:24 Everything in Session State
05:23 Session State is Everything
06:31 GPT-4 Controls Everything
08:28 The Last Stretch
10:21 Easy Peasy
📧 Want a free, slower paced live coding of this tutorial? Sign up to my email list to be alerted first, and keep up to date with the latest news, tutorials and resources about Streamlit & friends ➡ andfanilo-newsletter.streamli...
💰 Buy me a coffee to stay awake while editing www.buymeacoffee.com/andfanilo
🗣️ Find my socials on andfanilo.com
🔗 Links
- Source Code: github.com/andfanilo/social-m...
- How Language Model Hallucinations Can Snowball: arxiv.org/abs/2305.13534
- Someone did ask about open-sourcing the demo: community.openai.com/t/openai...
👉 My tools (Affiliate links to support me!)
- 📷 Main Camera - amzn.to/3QvTosB
- 📷 Main Lens - amzn.to/3svYCwq
- 🎙️ Microphone - amzn.to/47l5ewA
- 🎵 Music & Sound Effects - www.epidemicsound.com/referra...
- 📕 Streamlit Official Book - amzn.to/3QuRPwl
______
🪶 I tried my hand at motion graphics & design in this video, and I'm quite happy with the result, plus it was a lot of fun! I hope you liked the small animations too, let me know in the comments I want to keep improving this
⚠️ Disclaimer: I receive no compensation by any brand quoted in this video. Views are my own and do not represent my employer's.
Links included in this description might be affiliate links. If you purchase a product or service with the links that I provide I may receive a small commission. Thank you for supporting my channel so I can continue providing you with free content!
#streamlit #python #datascience #dataapps

Пікірлер: 44
@MMABeijing
@MMABeijing 5 ай бұрын
In my opinion you have the best resources on youtube, and your style is unparalleled. What a talent you are Sir
@andfanilo
@andfanilo 4 ай бұрын
Wow, thank you, I appreciate the support ☺️
@PaulBenthamcom
@PaulBenthamcom 7 ай бұрын
Your videos are real hidden gems, thanks for the explanations here 👍
@andfanilo
@andfanilo 7 ай бұрын
Thank you for the kind words 😌 hope to keep seeing you around!
@Hitchon
@Hitchon 6 ай бұрын
Wow really great job ! I love your editing & teaching style, made the tutorial fun to watch! Keep it up :)
@andfanilo
@andfanilo 6 ай бұрын
Oh, thank you very much for the supportive feedback ☺️ I'm taking a small break but I'll be back soon, so I hope to see you on the next one! Any subject in particular you wanted to see covered one day :) ?
@Hitchon
@Hitchon 6 ай бұрын
@@andfanilo I’m somewhat new to streamlit, something on session states would be really helpful
@tgauss
@tgauss 6 ай бұрын
I second this comment. Your style is fast, fun and informative! Appreciate your great content and sharing your expertise.
@kenchang3456
@kenchang3456 7 ай бұрын
Fascinating, thanks for the detail. And BTW, you hit the right amount of humor, I was smiling through most of the video 🙂
@andfanilo
@andfanilo 7 ай бұрын
Thank you for the support, greatly appreciated :) I had loads of fun doing this video, I'm happy I managed to pass a smile and some teachings at the same time!
@silkogelman
@silkogelman 7 ай бұрын
👏👏👏🤩 Great tutorial, thank you Fanilo! Time for some experimentation 🎉
@andfanilo
@andfanilo 7 ай бұрын
Ahah, I feel you always have so many AI platform experimentations running XD do you share them somewhere ?
@silkogelman
@silkogelman 7 ай бұрын
@@andfanilo most of them are proof of concepts and experiments, not sure if that code should see the light of day 😅 I like exploring AI ideas, but they are less than half of what I experiment with.
@matthewcover8748
@matthewcover8748 7 ай бұрын
stoked I stumbled upon your channel, Fanilo 🔥
@andfanilo
@andfanilo 7 ай бұрын
Happy to hear that! Thanks for the support and hope to keep seeing you here :)
7 ай бұрын
Amazing video as always, loved the animations too! which tool did you use to create them?
@andfanilo
@andfanilo 7 ай бұрын
Thanks for the support :) I've been learning a lot more After Effects recently, and it was a really fun process! I think I can definitely pass more complex boring information from those when I get the hang of it
@ibrahimsaidi7239
@ibrahimsaidi7239 6 ай бұрын
Awesome tutorial
@andfanilo
@andfanilo 6 ай бұрын
Thanks for watching :) hope to see you in the next one!
@samsquamsh78
@samsquamsh78 7 ай бұрын
I really like your videos, you always have good topics, creative solutions and add humor to them🙂 for me though (a beginner at python and coding in general), you move a bit too fast. It would be great to see a video where you go from start to finish, as you code live in a speed which is okay for less seasoned developers. but, I understand if that is not your target audience. keep it up!
@andfanilo
@andfanilo 7 ай бұрын
Hello! Thanks for the support and for sharing your thoughts in a positive way 🙂 I have thought about the pacing and difficulty of my videos a lot recently, as more and more beginners stumble on my videos as I grow. I hope I can inspire them to keep coding and improving until they're able to understand a more complex use case video of mine in one take, but I also totally understand it can be very frustrating for people who just want to code at a slower pace (actually even intermediate developers would need to pause at 2-3 points of this video and criticize how fast I am in some difficult parts and I would totally agree, I'm still improving my pacing skills ^^ ) It's not that I don't want to target beginners, it's rather I haven't found a format I'm comfortable with doing for beginners. There are 2 things that make me not do it right now: - I feel there is already a lot of "live coding beginner-friendly" KZbin videos out there, for example just typing "Assistants API", and you have 10-15 KZbinrs who break down code in a notebook slowly, and I don't really want to compete with them - Ok the real reason is, I myself never learn by live coding with a video tutorial. I prefer reading books and reimplementing with blog posts instead, and only watch project overview videos rather than live-coding sessions...so I don't record "live-coding" videos because I can't seem to learn and benefit from those. Maybe I could write small blog posts with my videos (like what I did for streamlit-components-tutorial.netlify.app/ ) so after watching the video to get a first grasp of what the project is about, you can live-code with the blog post at the pace you want by reading the blog post, would that sound like a good compromise? Or maybe I could...do live code sessions of my complex videis like this one but only accessible through a newsletter or for paying members of my KZbin community. For a financial incentive, I could force myself to do it. Anyway, that was a very unstructured brainstorming answer, I hope it makes sense 😆
@samsquamsh78
@samsquamsh78 6 ай бұрын
@@andfanilo many thanks and much appreciated. I understand the dilemma of pacing and target audience. We have all different ways of learning, and you should probably stick to your beliefs. I will continue watching even though I may not be able to keep the pace up, but i can take inspiration from it😊👍
@mikew2883
@mikew2883 7 ай бұрын
Good stuff! 👍
@andfanilo
@andfanilo 7 ай бұрын
Thanks for the support, hope to keep seeing you around :)
@mikew2883
@mikew2883 7 ай бұрын
Absolutely! Just stumbled across your channel and definitely a subscriber now! @@andfanilo
@andfanilo
@andfanilo 7 ай бұрын
...you're right I totally forgot about them I documented them in the README: github.com/andfanilo/social-media-tutorials/tree/master/20231116-st_assistants (there's also all the code for markers, especially at the plotly part)
@syenza
@syenza 7 ай бұрын
Great video, thanks. Do you take on private clients to assist with implementing the above and other projects?
@andfanilo
@andfanilo 7 ай бұрын
Hello, Currently not, as I'm juggling this channel with a fulltime job and being an university lecturer. I'm open to giving advice during 1 hour Zoom calls when I have some time but that's it for now. What are you trying to build? Have a nice day!
@emilbalis5010
@emilbalis5010 7 ай бұрын
Very good :)))
@andfanilo
@andfanilo 7 ай бұрын
Thanks for the support 😃 I hope you’ll keep watching what’s next!
@rockNbrain
@rockNbrain 7 ай бұрын
Fanilo is a real rockstar 🎸
@andfanilo
@andfanilo 7 ай бұрын
🎸 I need to do some live touring at conferences then, like real rockstars ahah, what's the conference/meetup near your location :p ? Thanks for the support ^^
@rockNbrain
@rockNbrain 7 ай бұрын
@@andfanilo Brazil, please come! Lmfao
@andfanilo
@andfanilo 7 ай бұрын
Keeping it in mind :)
@camino_interior
@camino_interior 6 ай бұрын
Thank you very much for your videos. They are very useful for my learning. I made an app in streamlit to manage a parking lot, without knowing that streamlit does not have any functionality to send a print with a form_submit_button. My app needs to print a ticket to give to the customer when they leave the car. Do you have any solution for that?
@andfanilo
@andfanilo 6 ай бұрын
Hello! Yeah Streamlit doesn't have any functionality about that, you'll probably need to bring custom Python code & library. Like, are you able to build your own small PDF from data in the Streamlit app with PyPDF2, export as PDF and have a user download it with st.download_button or send that PDF via email? Or send that PDF to a remote Cloud location and a Cloud service that reacts to any new file added there to print it physically? I don't know much about Cloud Printing services though... sorry for the very quick brainstorming, those were my immediate unfiltered first thoughts, hope it helps a little
@camino_interior
@camino_interior 6 ай бұрын
@@andfanilo Thank you very much for your reply. I'm trying with an api that connects to the printer locally. When I have the solution I will share it.
@camino_interior
@camino_interior 6 ай бұрын
@@andfanilo Would something work? import streamlit as st import serial # Create an instance of the serial.Serial object to communicate with the printer. ser = serial.Serial( port='/dev/ttyUSB0', # Port to which the printer is connected baudrate=9600, # Printer baud rate parity=serial.PARITY_NONE, # Printer parity stopbits=serial.STOPBITS_ONE, # Printer stop bits timeout=1 # Printer wait time (in seconds) ) # Write data to the printer. # Obtain the data you want to print from the Streamlit interface data = st.text_input('Data to print') # Encode the data into a byte string data_bytes = data.encode('utf-8') # Write the data to the printer ser.write(data_bytes) # Close the instance of the serial.Serial object when finished using it. ser.close()
@abdollahchelasi1477
@abdollahchelasi1477 7 ай бұрын
Please teach a streamlit project for hotel reservation
@andfanilo
@andfanilo 7 ай бұрын
Hello, what do you mean by "hotel reservation" ?
@abdulmanan8432
@abdulmanan8432 6 ай бұрын
to much overacting
@andfanilo
@andfanilo 6 ай бұрын
🕺 too bad, I guess my channel won't be for you then Have a nice day!
5 Things I Wish I Knew Before Learning Streamlit
21:34
Fanilo Andrianasolo
Рет қаралды 20 М.
The Noodle Picture Secret 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 30 МЛН
Final muy inesperado 🥹
00:48
Juan De Dios Pantoja
Рет қаралды 18 МЛН
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 3,6 МЛН
СНЕЖКИ ЛЕТОМ?? #shorts
00:30
Паша Осадчий
Рет қаралды 7 МЛН
How to Convert a Streamlit App to an .EXE Executable
8:20
Fanilo Andrianasolo
Рет қаралды 38 М.
EPIC Google Sheets to Interactive Dashboard in Python ft. Streamlit / CSS
27:41
Do NOT use Streamlit for PRODUCTION until you watch this!
6:33
Full Stack AI
Рет қаралды 2,6 М.
Teasing Streamlit’s Next Biggest Changes
9:45
Fanilo Andrianasolo
Рет қаралды 3,7 М.
RAG from the Ground Up with Python and Ollama
15:32
Decoder
Рет қаралды 24 М.
Integrating OpenAI Assistants with Websites using FlowiseAI
27:03
Leon van Zyl
Рет қаралды 24 М.
My Workflow for Building any Streamlit Dashboard Project
9:40
Fanilo Andrianasolo
Рет қаралды 68 М.
The Noodle Picture Secret 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 30 МЛН