Small Python projects that show what an AI app looks like inside. Each one is short, runs end to end, and maps to real Python topics you need to learn for AI.
This is the companion repo for the Python for AI video on the Data With Baraa YouTube channel.
| # | Project | What it does |
|---|---|---|
| 1 | First call | Send a prompt to the model, get a response back. The smallest possible AI app. |
| 2 | Chatbot with memory | A CLI chatbot that remembers the conversation until you type quit. |
| 3 | Structuring messy data | Turn messy customer reviews into clean structured JSON with Pydantic. |
| 4 | Ask your documents | A basic RAG setup using ChromaDB to answer questions about a folder of docs. |
| 5 | Agent with tools | The model decides which tools to call to answer a question. |
| 6 | Specialized model | Classify reviews using a small Hugging Face model that runs locally, no API key needed. |
You need Python 3.11 or newer.
-
Clone the repo:
git clone https://github.com/DataWithBaraa/python-ai-projects.git cd python-ai-projects -
Create a virtual environment and install the dependencies:
python -m venv .venv source .venv/bin/activateOn Windows use
.venv\Scripts\activateinstead.Then install:
pip install -r requirements.txt
-
Add your API key:
cp .env.example .env
Open
.envand paste your Anthropic key. You can get one at https://console.anthropic.com.Project 6 does not need any API key. It downloads a small model the first time you run it.
python src/01_first_call.pySwap the filename to run any of the others.
The default examples use Claude through the Anthropic SDK, but the same code works with OpenAI with small changes:
- Install the SDK:
pip install openai - Change the import:
from openai import OpenAI - Use the OpenAI client:
client = OpenAI()and callclient.chat.completions.create(...). - Put
OPENAI_API_KEY=...in your.envfile.
The flow is the same: send messages, get a response back. Pick whatever model fits your use case and budget.
src/the Python scripts, one per projectdata/sample data (messy reviews + a few docs for the RAG example)config.jsonmodel name and file paths.env.exampletemplate for your API key
- Channel: youtube.com/@DataWithBaraa
- Website: datawithbaraa.com
- Newsletter: blog.datawithbaraa.com
MIT. Use the code freely in your own projects.