Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions tutorials/tutorial_pydanticAI/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Exclude files from Docker build context. This prevents unnecessary files from
# being sent to Docker daemon, reducing build time and image size.

# Python artifacts
__pycache__/
*.pyc
*.pyo
*.pyd
*.egg-info/

# Virtual environments
venv/
.venv/
env/
.env
.envrc
client_venv.helpers/
ENV/

# Jupyter
.ipynb_checkpoints/
.jupyter/

# Build artifacts
build/
dist/
*.eggs/
.eggs/

# Cache and temporary files
*.log
*.tmp
*.cache
.pytest_cache/
.mypy_cache/
.coverage
htmlcov/

# Git and version control
.git/
.gitignore
.gitattributes
.github/

# Docker build scripts (not needed at runtime)
docker_build.sh
docker_push.sh
docker_clean.sh
docker_exec.sh
docker_cmd.sh
docker_bash.sh
docker_jupyter.sh
docker_name.sh
run_jupyter.sh
Dockerfile.*
.dockerignore

# Documentation
README.md
README.admin.md
docs/
*.md
CHANGELOG.md
LICENSE

# Configuration and secrets
.env.*
.env.local
.env.development
.env.production
.DS_Store
Thumbs.db

# Shell configuration
.bashrc
.bash_history
.zshrc

# Large data files (mount via volume instead)
data/
*.csv
*.pkl
*.h5
*.parquet
*.feather
*.arrow
*.npy
*.npz

# Generated images
*.png
*.jpg
*.jpeg
*.gif
*.svg
*.pdf

# Test files and examples
tests/
test_*
*_test.py
tutorials/
examples/

# IDE and editor files
.vscode/
.idea/
*.swp
*.swo
*~
.project
.pydevproject
.settings/
*.iml
.sublime-project
.sublime-workspace

# Node and frontend (if applicable)
node_modules/
npm-debug.log
yarn-error.log
.npm

# Requirements management
requirements.in
Pipfile
Pipfile.lock
poetry.lock
setup.py
setup.cfg

# CI/CD configuration
.gitlab-ci.yml
.travis.yml
Jenkinsfile
.circleci/

# Miscellaneous
*.bak
.venv.bak/
*.whl
*.tar.gz
*.zip
93 changes: 93 additions & 0 deletions tutorials/tutorial_pydanticAI/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# OS files
.DS_Store
Thumbs.db
desktop.ini

# Editor / IDE files
.vscode/
.idea/
*.swp
*.swo

# Environment variables
.env
.env.*
!.env.example

# Python
__pycache__/
*.py[cod]
*.pyo
*.pyd
.Python
venv/
env/
.venv/
ENV/
pip-wheel-metadata/
.pytest_cache/
.mypy_cache/
.ruff_cache/
.coverage
htmlcov/
dist/
build/
*.egg-info/

# Jupyter
.ipynb_checkpoints/

# Node / JavaScript
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
package-lock.json
yarn.lock
pnpm-lock.yaml

# Logs
*.log
logs/

# Build outputs
out/
target/
bin/
obj/

# Temporary files
tmp/
temp/
*.tmp
*.bak
*.old
tmp.pytest.log
tmp.system_output.txt
tmp.system_cmd.sh
.codex

# Data / local artifacts
data/
datasets/
artifacts/
outputs/
models/
checkpoints/

# Docker / local config
docker-compose.override.yml

# ML / experiment tracking
mlruns/
wandb/
lightning_logs/

# Secrets / credentials
*.pem
*.key
*.crt
credentials.json
token.json
secrets.json
28 changes: 28 additions & 0 deletions tutorials/tutorial_pydanticAI/Dockerfile.python_slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use Python 3.12 slim (already has Python and pip).
FROM python:3.12-slim

# Avoid interactive prompts during apt operations.
ENV DEBIAN_FRONTEND=noninteractive

# Install CA certificates (needed for HTTPS).
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Install project specific packages.
RUN mkdir -p /install
COPY requirements.txt /install/requirements.txt
RUN pip install --upgrade pip && \
pip install --no-cache-dir jupyterlab jupyterlab_vim jupytext -r /install/requirements.txt

# Config.
COPY etc_sudoers /install/
COPY etc_sudoers /etc/sudoers
COPY bashrc /root/.bashrc

# Report package versions.
COPY version.sh /install/
RUN /install/version.sh 2>&1 | tee version.log

# Jupyter.
EXPOSE 8888
122 changes: 54 additions & 68 deletions tutorials/tutorial_pydanticAI/README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,56 @@
<!-- toc -->

- [Project files](#project-files)
- [Setup and Dependencies](#setup-and-dependencies)
* [Building and Running the Docker Container](#building-and-running-the-docker-container)
+ [Environment Setup](#environment-setup)

<!-- tocstop -->

# Project files

This project contains the following files.

- `README.md`: This file
- `pydanticai.API.ipynb`: notebook describing core PydanticAI APIs
- `pydanticai.example.ipynb`: notebook with applied, end-to-end examples
- `requirements.txt`: Python dependencies used by this tutorial
- `example_dataset/`: supporting markdown files used in examples
- `api.md`
- `billing.md`
- `integrations.md`
- `limits.md`
- `overview.md`
- `security.md`
- `support.md`
- `troubleshooting.md`
- Docker/dev runtime files
- `Dockerfile`
- `docker_build.sh`
- `docker_bash.sh`
- `docker_jupyter.sh`
- `docker_exec.sh`
- `docker_cmd.sh`
- `docker_clean.sh`
- `docker_push.sh`
- `docker_name.sh`
- `version.sh`
- `run_jupyter.sh`
- `etc_sudoers`

# Setup and Dependencies

## Building and Running the Docker Container

- Go to the project directory:
```bash
> cd tutorials/tutorial_pydanticAI
```
- Build Docker image:
```bash
> ./docker_build.sh
```
- Run container shell:
```bash
> ./docker_bash.sh
```
- Launch Jupyter Notebook:
```bash
> ./docker_jupyter.sh
```

### Environment Setup

Set the `OPENAI_API_KEY` environment variable for API access:

```python
import os
os.environ["OPENAI_API_KEY"] = "<your_openai_api_key>"
# PydanticAI Tutorial

This folder contains the setup for running PydanticAI tutorials within a
containerized environment.

## Quick Start

From the root of the repository, change your directory to the PydanticAI
tutorial folder:

```bash
> cd tutorials/tutorial_pydanticAI
```

Once the location has been changed to the repo run the command to build the
image to run dockers:

```bash
> ./docker_build.sh
```

Once the docker has been built you can then go ahead and run the container and
launch jupyter notebook using the created image using the command:

```bash
> ./docker_jupyter.sh
```

Once the `./docker_jupyter.sh` script is running, work through the following
notebooks in order.

For more information on the Docker build system refer to [Project template
README](/class_project/project_template/README.md)

## Tutorial Notebooks

Work through the following notebooks in order:

- [`pydanticai.API.ipynb`](pydanticai.API.ipynb): Core PydanticAI fundamentals
- Understanding the PydanticAI framework architecture
- Working with PydanticAI classes and methods
- Building basic agent configurations
- Integration with language models

- [`pydanticai.example.ipynb`](pydanticai.example.ipynb): Real-world application
workflow
- End-to-end agentic application example
- Practical problem-solving with PydanticAI
- Advanced agent interactions and workflows
- Best practices and patterns

- [`pydanticai_API_utils.py`](pydanticai_API_utils.py): Utility functions
supporting the API tutorial notebook

- [`pydanticai_example_utils.py`](pydanticai_example_utils.py): Utility
functions supporting the example tutorial notebook
Loading