Skip to content

Commit 0fdbc2e

Browse files
chore(examples): migrate AI examples from pip to uv with locked versions (#471)
* chore(examples): migrate AI examples from pip to uv with locked versions Replace requirements.txt with pyproject.toml + uv.lock for all AI provider examples, pinning dependencies to latest versions for reproducible installs. Update READMEs to use uv sync / uv run. * chore(examples): add uv installation hint to READMEs
1 parent 795ee41 commit 0fdbc2e

29 files changed

Lines changed: 10393 additions & 52 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ build/
99
.vscode/
1010
env/
1111
venv/
12+
.venv/
1213
flake8.out
1314
pylint.out
1415
posthog-analytics

examples/example-ai-anthropic/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ Track Anthropic Claude API calls with PostHog.
55
## Setup
66

77
```bash
8-
pip install -r requirements.txt
98
cp .env.example .env
109
# Fill in your API keys in .env
10+
# Install uv if you haven't already: https://docs.astral.sh/uv/getting-started/installation/
11+
uv sync
1112
```
1213

1314
## Examples
@@ -20,7 +21,7 @@ cp .env.example .env
2021

2122
```bash
2223
source .env
23-
python chat.py
24-
python streaming.py
25-
python extended_thinking.py
24+
uv run python chat.py
25+
uv run python streaming.py
26+
uv run python extended_thinking.py
2627
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[project]
2+
name = "example-ai-anthropic"
3+
version = "0.1.0"
4+
requires-python = ">=3.10"
5+
dependencies = [
6+
"posthog==7.9.12",
7+
"anthropic==0.86.0",
8+
]

examples/example-ai-anthropic/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/example-ai-anthropic/uv.lock

Lines changed: 581 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/example-ai-gemini/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ Track Google Gemini API calls with PostHog.
55
## Setup
66

77
```bash
8-
pip install -r requirements.txt
98
cp .env.example .env
109
# Fill in your API keys in .env
10+
# Install uv if you haven't already: https://docs.astral.sh/uv/getting-started/installation/
11+
uv sync
1112
```
1213

1314
## Examples
@@ -20,7 +21,7 @@ cp .env.example .env
2021

2122
```bash
2223
source .env
23-
python chat.py
24-
python streaming.py
25-
python image_generation.py
24+
uv run python chat.py
25+
uv run python streaming.py
26+
uv run python image_generation.py
2627
```
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[project]
2+
name = "example-ai-gemini"
3+
version = "0.1.0"
4+
requires-python = ">=3.10"
5+
dependencies = [
6+
"posthog==7.9.12",
7+
"google-genai==1.68.0",
8+
]

examples/example-ai-gemini/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

examples/example-ai-gemini/uv.lock

Lines changed: 744 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/example-ai-langchain/README.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@ Track LangChain LLM calls with PostHog.
55
## Setup
66

77
```bash
8-
pip install -r requirements.txt
98
cp .env.example .env
109
# Fill in your API keys in .env
11-
```
12-
13-
For the OTEL example, also install:
14-
15-
```bash
16-
pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
10+
# Install uv if you haven't already: https://docs.astral.sh/uv/getting-started/installation/
11+
uv sync
1712
```
1813

1914
## Examples
@@ -25,6 +20,6 @@ pip install opentelemetry-sdk opentelemetry-exporter-otlp-proto-http
2520

2621
```bash
2722
source .env
28-
python callback_handler.py
29-
python otel.py
23+
uv run python callback_handler.py
24+
uv run python otel.py
3025
```

0 commit comments

Comments
 (0)