Skip to content

Commit 116f49f

Browse files
committed
promptlayer v0.5.0
Signed-off-by: aritroCoder <ogcodinggod@gmail.com>
0 parents  commit 116f49f

39 files changed

Lines changed: 11027 additions & 0 deletions

.github/workflows/test.yml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches: ["*"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v2
18+
19+
- name: Set up Python
20+
run: uv python install 3.12
21+
22+
- name: Install dependencies
23+
run: uv pip install -e ".[dev,test]"
24+
25+
- name: Run black
26+
run: uv run black --check src/ tests/
27+
28+
- name: Run ruff
29+
run: uv run ruff check src/ tests/
30+
31+
- name: Run mypy
32+
run: uv run mypy src/
33+
34+
test:
35+
runs-on: ${{ matrix.os }}
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
os: [ubuntu-latest]
40+
python-version: ["3.9", "3.10", "3.11", "3.12"]
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Install uv
47+
uses: astral-sh/setup-uv@v2
48+
49+
- name: Set up Python ${{ matrix.python-version }}
50+
run: uv python install ${{ matrix.python-version }}
51+
52+
- name: Install dependencies
53+
run: uv pip install -e ".[test]"
54+
55+
- name: Run pytest
56+
run: uv run pytest tests/unit/ -v --cov --cov-report=xml --cov-report=term-missing
57+
58+
- name: Upload coverage to Codecov
59+
uses: codecov/codecov-action@v4
60+
if: matrix.python-version == '3.12'
61+
with:
62+
file: ./coverage.xml
63+
fail_ci_if_error: false
64+
continue-on-error: true
65+
66+
integration-tests:
67+
runs-on: ubuntu-latest
68+
# Don't block PRs if integration tests fail (API may be down, rate limits, etc.)
69+
continue-on-error: true
70+
71+
steps:
72+
- name: Checkout code
73+
uses: actions/checkout@v4
74+
75+
- name: Install uv
76+
uses: astral-sh/setup-uv@v2
77+
78+
- name: Set up Python
79+
run: uv python install 3.12
80+
81+
- name: Install dependencies
82+
run: uv pip install -e ".[test]"
83+
84+
- name: Run integration tests
85+
if: ${{ secrets.GROQ_API_KEY != '' }}
86+
env:
87+
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
88+
run: uv run pytest tests/integration/ -m integration -v
89+
90+
performance:
91+
runs-on: ubuntu-latest
92+
# Run on main branch commits and PRs
93+
if: github.event_name == 'push' || github.event_name == 'pull_request'
94+
95+
steps:
96+
- name: Checkout code
97+
uses: actions/checkout@v4
98+
with:
99+
# Fetch enough history to compare with previous commit
100+
fetch-depth: 2
101+
102+
- name: Install uv
103+
uses: astral-sh/setup-uv@v2
104+
105+
- name: Set up Python
106+
run: uv python install 3.12
107+
108+
- name: Install dependencies
109+
run: uv pip install -e ".[test]"
110+
111+
- name: Create benchmarks directory
112+
run: mkdir -p .benchmarks
113+
114+
- name: Run performance benchmarks
115+
run: |
116+
uv run pytest tests/performance/test_benchmarks.py \
117+
--benchmark-only \
118+
--benchmark-json=.benchmarks/current.json \
119+
--benchmark-columns=min,max,mean,stddev,median,ops \
120+
--benchmark-sort=name
121+
122+
- name: Download previous benchmark results
123+
uses: actions/cache@v4
124+
with:
125+
path: .benchmarks/baseline.json
126+
key: benchmark-baseline-${{ github.ref }}-${{ github.sha }}
127+
restore-keys: |
128+
benchmark-baseline-${{ github.ref }}-
129+
benchmark-baseline-refs/heads/main-
130+
131+
- name: Compare with baseline
132+
if: hashFiles('.benchmarks/baseline.json') != ''
133+
run: |
134+
uv run pytest tests/performance/test_benchmarks.py \
135+
--benchmark-only \
136+
--benchmark-compare=.benchmarks/baseline.json \
137+
--benchmark-compare-fail=mean:20% || true
138+
139+
- name: Store benchmark results as baseline
140+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
141+
run: |
142+
cp .benchmarks/current.json .benchmarks/baseline.json
143+
144+
- name: Upload benchmark results
145+
uses: actions/upload-artifact@v4
146+
with:
147+
name: benchmark-results
148+
path: .benchmarks/current.json
149+
retention-days: 90
150+
151+
- name: Comment PR with benchmark results
152+
if: github.event_name == 'pull_request'
153+
uses: actions/github-script@v7
154+
continue-on-error: true
155+
with:
156+
script: |
157+
const fs = require('fs');
158+
const results = JSON.parse(fs.readFileSync('.benchmarks/current.json', 'utf8'));
159+
160+
let comment = '## 📊 Performance Benchmark Results\n\n';
161+
comment += '| Benchmark | Mean | Ops/sec |\n';
162+
comment += '|-----------|------|----------|\n';
163+
164+
results.benchmarks.forEach(b => {
165+
const name = b.name.replace('test_benchmark_', '').replace('test_', '');
166+
const mean = (b.stats.mean * 1000000).toFixed(2); // Convert to µs
167+
const ops = (b.stats.ops / 1000).toFixed(2); // Convert to K ops/sec
168+
comment += `| ${name} | ${mean} µs | ${ops}K |\n`;
169+
});
170+
171+
comment += '\n*All benchmarks run with pytest-benchmark (100 iterations, 10 rounds)*';
172+
173+
github.rest.issues.createComment({
174+
issue_number: context.issue.number,
175+
owner: context.repo.owner,
176+
repo: context.repo.repo,
177+
body: comment
178+
});

.gitignore

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# BMAD Artifacts and AI-generated content
2+
.artifacts/
3+
.ai/
4+
5+
# Python
6+
__pycache__/
7+
.ruff_cache/
8+
*.py[cod]
9+
*$py.class
10+
*.so
11+
.Python
12+
build/
13+
develop-eggs/
14+
dist/
15+
downloads/
16+
eggs/
17+
.eggs/
18+
lib/
19+
lib64/
20+
parts/
21+
sdist/
22+
var/
23+
wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# Virtual environments
30+
.venv/
31+
venv/
32+
ENV/
33+
env/
34+
.virtualenv/
35+
36+
# Testing
37+
.pytest_cache/
38+
.coverage
39+
htmlcov/
40+
.tox/
41+
.hypothesis/
42+
.nox/
43+
.mypy_cache/
44+
45+
# IDEs and Editors
46+
.vscode/
47+
.idea/
48+
*.swp
49+
*.swo
50+
*~
51+
.project
52+
.pydevproject
53+
.settings/
54+
55+
# OS
56+
.DS_Store
57+
.DS_Store?
58+
._*
59+
.Spotlight-V100
60+
.Trashes
61+
ehthumbs.db
62+
Thumbs.db
63+
64+
# Documentation builds
65+
docs/_build/
66+
site/
67+
_site/
68+
69+
# Environment variables and secrets
70+
.env
71+
.env.local
72+
.env.*.local
73+
*.key
74+
*.pem
75+
76+
# Logs
77+
*.log
78+
*.tmp
79+
logs/
80+
81+
# Node modules (if using any JS tooling)
82+
node_modules/
83+
npm-debug.log*
84+
yarn-debug.log*
85+
yarn-error.log*
86+
87+
# Package lock files (optional - uncomment if you want to ignore)
88+
# uv.lock
89+
# package-lock.json
90+
91+
# Temporary files
92+
*.bak
93+
*.swp
94+
*.tmp
95+
temp/
96+
tmp/
97+
98+
uv.lock

.pre-commit-config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
11+
- repo: https://github.com/psf/black
12+
rev: 23.12.0
13+
hooks:
14+
- id: black
15+
language_version: python3.12
16+
17+
- repo: https://github.com/astral-sh/ruff-pre-commit
18+
rev: v0.1.9
19+
hooks:
20+
- id: ruff
21+
args: [--fix, --exit-non-zero-on-fix]
22+
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v1.8.0
25+
hooks:
26+
- id: mypy
27+
additional_dependencies: [pydantic>=2.5, httpx>=0.27.0, rich>=13.0.0, attrs>=23.0.0, types-click>=7.1.8]
28+
args: [--strict, --python-version=3.9]
29+
exclude: ^tests/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 PromptLayer Contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)