Skip to content

Commit 4d9e8ce

Browse files
authored
chore: build workflow
1 parent c258948 commit 4d9e8ce

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed

.github/workflows/build.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Build
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
secrets:
7+
OPENAI_API_KEY:
8+
required: true
9+
ANTHROPIC_API_KEY:
10+
required: true
11+
12+
jobs:
13+
build:
14+
name: Build & Test
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.x"
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install poetry
27+
poetry install
28+
29+
# Models should be stored using LFS or downloaded in the pipeline for tests to be run
30+
# - name: Run tests
31+
# run: |
32+
# poetry run pytest
33+
34+
- name: Build
35+
run: |
36+
pip install poetry
37+
poetry build
38+
39+
- uses: actions/upload-artifact@v4
40+
with:
41+
path: ./dist

.github/workflows/publish.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Publish to PyPI
2+
3+
env:
4+
PYPI_PACKAGE_NAME: langchain_llamacpp_chat_model
5+
on:
6+
release:
7+
types:
8+
- created
9+
10+
jobs:
11+
publish:
12+
name: Publish to PyPI
13+
runs-on: ubuntu-latest
14+
environment: release
15+
permissions:
16+
id-token: write
17+
contents: write
18+
steps:
19+
- name: Extract version from tag
20+
id: extract_version
21+
run: |
22+
TAG_NAME=${{ github.event.release.tag_name }}
23+
if [[ $TAG_NAME =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
24+
VERSION=${BASH_REMATCH[1]}
25+
echo "VERSION=$VERSION" >> $GITHUB_ENV
26+
else
27+
echo "The tag $TAG_NAME is not in the expected format 'v<MAJOR>.<MINOR>.<PATCH>'"
28+
exit 1
29+
fi
30+
31+
- uses: actions/checkout@v4
32+
with:
33+
ref: ${{ github.head_ref }}
34+
- name: Set up Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: "3.x"
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip
41+
pip install poetry
42+
poetry install
43+
44+
- name: Update version in pyproject.toml
45+
run: |
46+
poetry version ${{ env.VERSION }}
47+
48+
# Models should be stored using LFS or downloaded in the pipeline for tests to be run
49+
# - name: Run tests
50+
# run: |
51+
# poetry run pytest
52+
53+
- name: Build
54+
run: |
55+
poetry build
56+
57+
- uses: actions/upload-artifact@v4
58+
with:
59+
path: ./dist
60+
61+
- uses: stefanzweifel/git-auto-commit-action@v5
62+
with:
63+
commit_message: Bump version to ${{ env.VERSION }}
64+
branch: main
65+
66+
- name: Publish to PyPI
67+
uses: pypa/gh-action-pypi-publish@release/v1
68+
with:
69+
packages-dir: ./dist

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ __pycache__/
1111
*.pyi
1212
*.pyw
1313
*.pytest_cache
14+
15+
*.tar.gz
16+
*.whl

tests/test_functional/models_configuration.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
},
1717
]
1818

19+
n_gpu_layers = (
20+
0 # -1 to offload on GPU. Until GPU is supported on Github, must be run on CPU
21+
)
22+
1923

2024
def _model_local_path(model) -> str:
2125
return os.path.join(
@@ -30,7 +34,11 @@ def _create_models_settings():
3034
for model in models_to_test:
3135
local_path = _model_local_path(model)
3236
models.append(
33-
ModelSettings(model=local_path, model_alias=model["alias"], n_gpu_layers=-1)
37+
ModelSettings(
38+
model=local_path,
39+
model_alias=model["alias"],
40+
n_gpu_layers=n_gpu_layers,
41+
)
3442
)
3543

3644
return models
@@ -41,7 +49,7 @@ def create_llama(request) -> Llama:
4149

4250
return Llama(
4351
model_path=local_path,
44-
n_gpu_layers=-1,
52+
n_gpu_layers=n_gpu_layers,
4553
)
4654

4755

0 commit comments

Comments
 (0)