Skip to content

Commit d9062b7

Browse files
Latence AIcursoragent
andcommitted
Initial commit
Co-authored-by: Cursor <cursoragent@cursor.com>
0 parents  commit d9062b7

100 files changed

Lines changed: 21138 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Latence Python SDK Environment Variables
2+
# Copy to .env or export these in your shell
3+
4+
# API Key (required for all API calls)
5+
LATENCE_API_KEY=la_your_api_key_here
6+
7+
# Base URL (optional - defaults to production)
8+
# For staging/development:
9+
# LATENCE_BASE_URL=https://staging.api.latence.ai
10+
# For production (default):
11+
# LATENCE_BASE_URL=https://api.latence.ai
12+
13+
# Logging level (optional - defaults to WARNING)
14+
# Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
15+
# LATENCE_LOG_LEVEL=DEBUG

.github/workflows/publish.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
id-token: write # Required for trusted publishing
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.11'
20+
21+
- name: Install build dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install build
25+
26+
- name: Build package
27+
run: python -m build
28+
29+
- name: Publish to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Python 3.11
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.11"
19+
20+
- name: Install dependencies
21+
run: |
22+
python -m pip install --upgrade pip
23+
pip install -e ".[dev]"
24+
25+
- name: Check formatting
26+
run: ruff format --check src/latence tests/
27+
28+
- name: Run linter
29+
run: ruff check src/latence tests/
30+
31+
- name: Run type checking
32+
run: mypy src/latence
33+
34+
test:
35+
runs-on: ubuntu-latest
36+
strategy:
37+
matrix:
38+
python-version: ['3.9', '3.10', '3.11', '3.12']
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set up Python ${{ matrix.python-version }}
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: ${{ matrix.python-version }}
47+
48+
- name: Install dependencies
49+
run: |
50+
python -m pip install --upgrade pip
51+
pip install -e ".[dev]"
52+
53+
- name: Run tests with coverage
54+
run: pytest tests/ -v --cov=latence --cov-report=xml --cov-report=term-missing
55+
56+
- name: Upload coverage to Codecov
57+
if: matrix.python-version == '3.11'
58+
uses: codecov/codecov-action@v4
59+
with:
60+
file: ./coverage.xml
61+
fail_ci_if_error: false
62+
63+
integration:
64+
runs-on: ubuntu-latest
65+
# Only run on main branch pushes, not PRs (to avoid exposing staging keys)
66+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
67+
needs: [lint, test]
68+
steps:
69+
- uses: actions/checkout@v4
70+
71+
- name: Set up Python 3.11
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: "3.11"
75+
76+
- name: Install dependencies
77+
run: |
78+
python -m pip install --upgrade pip
79+
pip install -e ".[dev]"
80+
81+
- name: Run integration tests
82+
env:
83+
LATENCE_BASE_URL: ${{ secrets.STAGING_API_URL }}
84+
LATENCE_API_KEY: ${{ secrets.STAGING_API_KEY }}
85+
run: pytest tests/integration/ -v --tb=short
86+
continue-on-error: true

.gitignore

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.nox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*.cover
48+
*.py,cover
49+
.hypothesis/
50+
.pytest_cache/
51+
52+
# Translations
53+
*.mo
54+
*.pot
55+
56+
# Django stuff:
57+
*.log
58+
local_settings.py
59+
db.sqlite3
60+
db.sqlite3-journal
61+
62+
# Flask stuff:
63+
instance/
64+
.webassets-cache
65+
66+
# Scrapy stuff:
67+
.scrapy
68+
69+
# Sphinx documentation
70+
docs/_build/
71+
72+
# PyBuilder
73+
target/
74+
75+
# Jupyter Notebook
76+
.ipynb_checkpoints
77+
78+
# IPython
79+
profile_default/
80+
ipython_config.py
81+
82+
# pyenv
83+
.python-version
84+
85+
# pipenv
86+
Pipfile.lock
87+
88+
# PEP 582
89+
__pypackages__/
90+
91+
# Celery stuff
92+
celerybeat-schedule
93+
celerybeat.pid
94+
95+
# SageMath parsed files
96+
*.sage.py
97+
98+
# Environments
99+
.env
100+
.venv
101+
env/
102+
venv/
103+
ENV/
104+
env.bak/
105+
venv.bak/
106+
107+
# Spyder project settings
108+
.spyderproject
109+
.spyproject
110+
111+
# Rope project settings
112+
.ropeproject
113+
114+
# mkdocs documentation
115+
/site
116+
117+
# mypy
118+
.mypy_cache/
119+
.dmypy.json
120+
dmypy.json
121+
122+
# Pyre type checker
123+
.pyre/
124+
125+
# IDEs
126+
.vscode/
127+
.idea/
128+
*.swp
129+
*.swo
130+
*~
131+
132+
# OS
133+
.DS_Store
134+
Thumbs.db
135+
136+
# Project specific
137+
.dev.vars
138+
139+
# Notebooks: archived old notebooks and test data
140+
notebooks/_archive/
141+
notebooks/data/

.pre-commit-config.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Pre-commit hooks for latence-python
2+
# Install with: pre-commit install
3+
# Run manually: pre-commit run --all-files
4+
5+
repos:
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.5.0
8+
hooks:
9+
- id: trailing-whitespace
10+
- id: end-of-file-fixer
11+
- id: check-yaml
12+
- id: check-added-large-files
13+
args: ['--maxkb=500']
14+
- id: check-merge-conflict
15+
16+
- repo: https://github.com/astral-sh/ruff-pre-commit
17+
rev: v0.3.0
18+
hooks:
19+
# Run the formatter
20+
- id: ruff-format
21+
args: [--config, pyproject.toml]
22+
# Run the linter
23+
- id: ruff
24+
args: [--fix, --config, pyproject.toml]
25+
26+
- repo: local
27+
hooks:
28+
- id: mypy
29+
name: mypy
30+
entry: mypy src/latence --config-file pyproject.toml
31+
language: system
32+
types: [python]
33+
pass_filenames: false
34+
always_run: true

CONTRIBUTING.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Contributing to Latence Python SDK
2+
3+
Thank you for your interest in contributing to the Latence Python SDK!
4+
5+
## Development Setup
6+
7+
1. Clone the repository:
8+
```bash
9+
git clone https://github.com/latenceai/latence-python.git
10+
cd latence-python
11+
```
12+
13+
2. Create a virtual environment:
14+
```bash
15+
python -m venv venv
16+
source venv/bin/activate # On Windows: venv\Scripts\activate
17+
```
18+
19+
3. Install in development mode:
20+
```bash
21+
pip install -e ".[dev]"
22+
```
23+
24+
## Running Tests
25+
26+
```bash
27+
# Run all tests
28+
pytest tests/ -v
29+
30+
# Run with coverage
31+
pytest tests/ --cov=latence --cov-report=html
32+
33+
# Type checking
34+
mypy src/latence
35+
36+
# Linting
37+
ruff check src/latence
38+
```
39+
40+
## Code Style
41+
42+
- Follow PEP 8
43+
- Use type hints for all function signatures
44+
- Add docstrings for public APIs
45+
- Keep functions focused and modular
46+
47+
## Pull Request Process
48+
49+
1. Create a new branch for your feature/fix
50+
2. Make your changes with clear commit messages
51+
3. Add tests for new functionality
52+
4. Ensure all tests pass
53+
5. Update documentation if needed
54+
6. Submit a pull request
55+
56+
## Release Process
57+
58+
Releases are automated via GitHub Actions when a new release is published.
59+
60+
## Questions?
61+
62+
Open an issue or reach out to support@latence.ai

0 commit comments

Comments
 (0)