Skip to content

Commit eb1bd34

Browse files
committed
init library with message compression
surface first function: the ability to drop messages above a configured token limit
1 parent 95a528a commit eb1bd34

Some content is hidden

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

52 files changed

+1732
-8754
lines changed

.github/workflows/publish.yml

Lines changed: 43 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,54 @@
1-
name: Create and Publish Release
1+
name: Publish Python Package
22

33
on:
4-
push:
5-
tags:
6-
- 'v*' # Trigger on version tags
7-
branches-ignore:
8-
- '**' # Ignore branch pushes, only trigger on tags
4+
release:
5+
types: [created]
96

10-
jobs:
11-
publish-pypi:
12-
environment:
13-
name: pypi
14-
runs-on: ubuntu-latest
15-
permissions:
16-
contents: write
17-
packages: write
18-
id-token: write
7+
permissions:
8+
contents: read
199

20-
steps:
21-
- name: Publish to PyPI
22-
env:
23-
TWINE_USERNAME: __token__
24-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
25-
run: |
26-
pip install --user uv
27-
uv venv
28-
source .venv/bin/activate
29-
uv pip install build
30-
python -m build
31-
uv pip install twine
32-
twine upload dist/*
33-
34-
create-github-release:
35-
environment:
36-
name: pypi
37-
needs: [publish-pypi]
10+
jobs:
11+
test:
3812
runs-on: ubuntu-latest
13+
environment: test
14+
env:
15+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
16+
strategy:
17+
matrix:
18+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
3919
steps:
40-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v5
4123
with:
42-
fetch-depth: 0
43-
44-
- name: Create GitHub Release
45-
uses: actions/create-release@v1
46-
with:
47-
tag_name: ${{ github.ref }}
48-
release_name: Release ${{ github.ref }}
49-
draft: false
50-
prerelease: false
51-
body_path: CHANGELOG.md
52-
env:
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54-
update-stable-and-deploy-branch:
55-
environment:
56-
name: pypi
57-
needs: [create-github-release]
24+
python-version: ${{ matrix.python-version }}
25+
cache: pip
26+
cache-dependency-path: pyproject.toml
27+
- name: Install dependencies
28+
run: |
29+
pip install -e '.[dev]'
30+
- name: Run tests
31+
run: |
32+
python -m pytest
33+
deploy:
5834
runs-on: ubuntu-latest
35+
needs: [test]
36+
environment: release
37+
permissions:
38+
id-token: write
5939
steps:
60-
- uses: actions/checkout@v3
40+
- uses: actions/checkout@v4
41+
- name: Set up Python
42+
uses: actions/setup-python@v5
6143
with:
62-
fetch-depth: 0
63-
- name: Update stable branch
44+
python-version: "3.13"
45+
cache: pip
46+
cache-dependency-path: pyproject.toml
47+
- name: Install dependencies
6448
run: |
65-
git config --global user.name 'GitHub Actions'
66-
git config --global user.email 'actions@github.com'
67-
git checkout stable || git checkout -b stable
68-
git reset --hard ${GITHUB_REF}
69-
git push -f origin stable
70-
git checkout deploy || git checkout -b deploy
71-
git reset --hard ${GITHUB_REF}
72-
git push -f origin deploy
49+
pip install setuptools wheel build
50+
- name: Build
51+
run: |
52+
python -m build
53+
- name: Publish
54+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/test.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Test
2+
3+
on: [push, pull_request]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
environment: test
12+
env:
13+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
14+
strategy:
15+
matrix:
16+
python-version: ["3.10", "3.11", "3.12", "3.13"]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
cache: pip
24+
cache-dependency-path: pyproject.toml
25+
- name: Install dependencies
26+
run: |
27+
pip install -e '.[dev]'
28+
- name: Run tests
29+
run: |
30+
python -m pytest

0 commit comments

Comments
 (0)