Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libxml2-dev libxslt-dev

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
Expand Down Expand Up @@ -55,3 +59,46 @@ jobs:

- name: Publish package
run: uv publish --trusted-publishing always

deploy-api:
runs-on: ubuntu-latest
environment: hf
needs: tests
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'workflow_dispatch'
steps:
- uses: actions/checkout@v4

- name: Push api/ to HF Space
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
cd api
git init -b main
git config user.email "ci@github"
git config user.name "CI"
git remote add hf https://user:${HF_TOKEN}@huggingface.co/spaces/Llamore/api
git add .
if git diff --cached --quiet; then
echo "No changes to deploy — skipping push."
exit 0
fi
git commit -m "deploy from ${GITHUB_SHA}"
git push hf main --force
Comment on lines +75 to +86

rebuild-hf:
runs-on: ubuntu-latest
environment: hf
needs: [tests, deploy-api]
if: |
always()
&& (needs.tests.result == 'success'
|| needs.deploy-api.result == 'success'
|| github.event_name == 'workflow_dispatch')
steps:
- name: Trigger HF Space rebuild
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
curl --fail -X POST \
"https://huggingface.co/api/spaces/Llamore/api/restart?factory=true" \
-H "Authorization: Bearer ${HF_TOKEN}"
Comment on lines +88 to +104
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ dist/

# exclude data
data

# exclude notebook data
notebooks/data
19 changes: 19 additions & 0 deletions api/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM python:3.13

RUN useradd -m -u 1000 user

WORKDIR /app

RUN mkdir -p logs

RUN pip install uv

# RUN uv pip install --system git+https://github.com/mpilhlt/llamore.git[api]
RUN uv pip install --system "git+https://github.com/mpilhlt/llamore.git@feat/add_webservice_api#egg=llamore[api]"

COPY --chown=user api.py .

EXPOSE 7860

CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
Comment on lines +3 to +18

11 changes: 11 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: Api
emoji: 👁
colorFrom: indigo
colorTo: pink
sdk: docker
pinned: false
short_description: FastAPI for llamore
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
Loading
Loading