Building AI Agents in Pure Python - Beginner Course
ฝัง
- เผยแพร่เมื่อ 7 ก.พ. 2025
- Want to get started as a freelancer? Let me help: www.datalumina...
Additional Resources
📚 Just getting started? Learn the fundamentals of AI: www.skool.com/...
🚀 Already building AI apps? Get our production framework: launchpad.data...
💼 Need help with a project? Work with me: www.datalumina...
🔗 GitHub Repository
github.com/dav...
🔗 Other links
www.anthropic....
platform.opena...
🛠️ My VS Code / Cursor Setup
• The Ultimate VS Code S...
⏱️ Timestamps
2:45 Basic API Call
5:10 Structured Output
8:00 Using Tools
18:31 Memory and Retrieval
24:35 Building an AI Calendar Agent
34:59 Prompt Chaining
37:56 Routing Requests
41:57 Parallelization
46:18 Deploying Your AI Application
📌 Description
In this tutorial, we’ll cover everything you need to start building AI agents in pure Python. We’ll start with the essential building blocks and then dive into workflow patterns for more reliable systems. To follow along, basic Python skills are recommended, along with familiarity with the OpenAI SDK and an API key. I highly recommend cloning the GitHub repository so you can work through the code step by step. Watch me go through it first, then try it yourself to reinforce your understanding. I move quickly to cover a lot in 45 minutes, but you can always pause, rewind, or ask ChatGPT for help.
👋🏻 About Me
Hi! I'm Dave, AI Engineer and founder of Datalumina®. On this channel, I share practical tutorials that teach developers how to build production-ready AI systems that actually work in the real world. Beyond these tutorials, I also help people start successful freelancing careers. Check out the links above to learn more!
it's clear to see that you build real world production apps unlike most people making videos about hot tools out there. most of these tools don't work as expected, are very unstable to use in production and make things more complex than they need to be. congrats for your sensible approach
100%. Great to see in-depth quality videos like this! One downside of the "AI revolution" is all the "make money fast with AI" videos out there that LOOK professional, but lack any depth.
Appreciate it! 🙏🏻
@@daveebbelaar 100@ agree, that this channel is one of the few channels who actually make practical sense
You are one of a kind sir. It is rare when I am learning from someone and nearly everything explained "clicks" immediately. You got me up to speed so fast on building with AI. Thank you! I may actually buy your launchpad (which I've never done before haha)
What is your weather policy:
{"answer":"We do not have a weather policy as we are an e-commerce store and do not have control over external weather conditions. However, our delivery times may be affected by inclement weather or other external factors.","source":0}
Than you by the way for this great tutorial ! I learned so much from this
One of the best current communicators of AI content.
This is an awesome video. I've been learning to use pydanticAi, but I really appreciate you showing how to build agent workflows from scratch as it can be really useful to know. Would love to see more content like this as frameworks such as langchain and crewAi are so high-level, you don't know what's happening. Pure python or even pydanticAi is the way to go! ❤
This is the most comprehensive tutorial I found on llm agents. Thank you !
Looking forward to learn a lot from you.
Awesome, thank you!
Thank you so much, Dave! This video taught me all the essential concepts I needed to develop my application using LLMs. Your clear explanations and practical insights are incredibly valuable, and I'm sure you're helping far more people than you can imagine. Keep up the amazing work!
I envy the people who can watch this as they start building with LLMs. I've wasted so many hours using pre-made systems trying to figure out what's happening inside the box. This is the way to go.
Thanks for the video - at the moment I use pure Python as well - )
Totally, more control, more understanding
Same here!
Your videos are at next lvl, easy and simple to understand. Keep up the good work. Thank you for wonderful content.👍
Thank you for the videos! finding videos on AI systems/solutions that are actually useful and reliable is not easy. This is orders of magnitude better than 99% of videos I've watched on AI "agents".
Such a nice video! I totally agree with you every single week there is a new framework to build agent with IA and it's become very overwhelming sometimes. Thanks a lot for the clear explanation and for taking the time to make this long video. I watched entirely and followed your code locally as well :)
Yes! Thank you!
Brilliant way of explanation! Purified value, with no unnecessary complications.
Great!! Keep making videos like this ! I have always wondered how it works . You make it lot easier and clear path to study further . Thanks !!!
I like your approach. I tought the same as you and I fall into the trap of pydanthic ai (pydanthic made it so it should be “native”) but is still too young and now im sticking to native and close to original platform as possible. Thanks for the vids. Love youe content 🎉
I have a simple question, take for instance you built a multi tool agent, where human feedback is allowed, and of course has memory. How do you make the model not skip overlapping questions.
Example:
Human: I need to make some purchase
AI: what would you like to buy
Human: do you guys have any coupon
AI: yes we do, pls check this link
(Normally AI is supposed to revert back to unanswered question here, but my AI built using PydanticAI won’t do this, even with a reasoning model.)
Human: thank you
AI: you’re welcome, I’m here if you need any other thing.
really great content, as usual on your channel, thank you!
I appreciate that!
👏excellent like usual
Great tutorial, can’t wait to try. Thanks so much for your work, it helps me in mine.
great video need more like such video and deployment too
This is amazing. Thank you so much for sharing this knowledge. It helps tremendously.
Excellent video as always! What documentation would you suggest to understand how to do message and response handling for a local LLM package (like ollama) instead of the openai package?
Check this out: python.useinstructor.com/examples/ollama/
Superb as always. Hopefully we'll get to see you teach the orchestrator pattern as well. Thanks, Dave.
Thanks! You can check out the code in the repo. There's an example there. It's a little trickier. We don't really use it in our production applications yet.
Amazing video! Thanks for all the info you are putting out.
Super cool you explained the common patterns
Great video, extremely useful thank you. Would love more videos on pydantic
Awesome contribution 👍
As a student, i want to learn about the AI agents and where to apply them. Is there any way to test these API’s w free of cost ? I tried to do an API call and it just showed error - free credits already used up :/ This was the first API call and I was kinda excited to see the output. Is there anyway to use these API’s for free for a bit to test them out ? Great video btw 💯
Lovely video! Thank you so much for sharing :)
Super, voorbij de hype. Thanks Dave!
Great video thanks! How do you run your Python scripts on internet on the web?
People use tools like LangChain or Vercel AI SDK mainly because they can easily switch between different AI services. You usually only need to change one line to use a different service.
We use the Instructor Library for that. LiteLLM or PydanticAI are also good options for this. I didn't cover that in this video, but those are good to unify the API call.
What do you think about open operator
Is it considered as an AI agent or no?
Thanks a lot.
Great video, thanks a lot!
iyo, what are the downsides of platforms such as n8n?
takes way longer to create and debug all the nodes - ironically
@@alexanderderiy1182 got it!
It seems that it's made for shorter and personal workflows rather than running an agency based on it.
I think n8n is good for showing prototypes to less technical people before moving on to more solid solid solutions like the one offered here.
How reliable structured outputs are now?
I remember when I used to work with GPT 4, I had to give it a really good prompt, an example of generated JSON and then try-catch around parsing and have a retry mechanism if the output was not correct.
With Pydantic it's really reliable
@@daveebbelaar Thanks.
can you make tutorial on making ai voice assistant for customer cares and other stuff using python and chatgpt
Yes , it will be great if you can create a video for AI voice assistant
Hey Dave , really nice video! I was wondering if I could help you with more Quality Editing in your videos with good pricing & turnaround time and will also make a highly engaging Thumbnail which will help your video to reach a wider audience ! Lmk what you think ?
@dave I also noticed that tools never get included when I use response_format
example:
completion_2 = client.beta.chat.completions.parse(
model="gpt-4o",
messages=messages,
tools=tools,
response_format=KBResponse,
)
WehenI remove response_format tools get included. Maybe bug in open AI
How to provide a memory or context awareness to it?can you help us do that?
how env var are loading for you? for me I have to use dotenv like below
from dotenv import load_dotenv
load_dotenv(dotenv_path="./.env") # take environment variables from .env
@dave Great video. thank you for sharing. In your tools example I dont think we need to append message in the tool call loop:
for tool_call in completion.choices[0].message.tool_calls:
name = tool_call.function.name
args = json.loads(tool_call.function.arguments)
messages.append(completion.choices[0].message)
I believe it need to be outside the for loop?
But what about graph parallele execution without sequential execution.I meant what is your opinion about langgraph and graph state frameworks?
Hi!
following your example, I'm running at VSCode win10 the code line by line in the Interactive Window.
However, instead of seeing all the intermediate variable values like you do, I only see two lines: import os and ['Alice', 'Bob'].
I can't get it to show the results of the other lines without using print(). Any ideas what might be wrong?
isnt the sequential and router flow more like a ai powered pipeline ?
The data freelancing is not available in the Asia region, if its freelancing, may I join the North America community being physically present in Asia?
Awesome breakdown, Dave! 🔥 Love how you structured this for real-world AI builds. We’re working on LLMShotgun-an automation & prompting tool for devs-and would love to explore a collab. Think your audience would find it useful? Would be great to chat!
Is it me or this way of being "agentic" is mostly irrelevant/hype/cope? If I need to code 5000 functions and use an llm just to interface in natural language with the user to retrieve values of variables and build the entire logic myself, it's mostly the same old way of doing stuff... I need the llm to *write* the functions (and they will), else sure, I can make user experience a bit more pleasant in certain cases, but I might as well just build a workflow/use buttons and input trees, etc. the good "old" (current) way.
Yeah I will agree upon this , I feel we are not utilising Ai at its fullest with this. also we are limited with token window like one can’t afford this llm services into his workflows without spending huge money and more problem I see it’s over reliance on llm service providers it can became potential single point of failure if llm service goes down
@@AScientist-dr7lu + it opens all sorts of dead ends in the flowchart, while usually you'd validate user inputs and variables values.
The thing you get the power of language understanding, imagine how hard it would be to scrape a web page and write some code to make sense of it, discard irrelevant info and remain with the exact info you need from that page, but with context and a prompt that is like eating a cheese cake for an llm
@@Patrick-wn6uj all that stuff is already automated, nothing to do with "agentic" ai that many VCs and pumpers in the field are coping with.
Super cool video and very helpful. I can program (python, C, C++, etc) but I am not a developer. Working with an API is not a problem but I could not figure yet out how to program such an agent and run it locally on a LLM. Can any body help or know a youtube video about it?
"Let your hustle speak louder than your doubts."
who has a link to the antropic blog post
www.anthropic.com/research/building-effective-agents
Great video but No need to use openai when you have much cheaper and better models out there
not all Hearoes wear a cap