Skip to content

Commit 34e24aa

Browse files
Merge pull request #2 from samuellimabraz/dev
Dev
2 parents 5675cff + 1d76eb3 commit 34e24aa

Some content is hidden

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

45 files changed

+11882
-1
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
name: Deploy Demo to HuggingFace Spaces
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "src/demo/**"
9+
- ".github/workflows/hf-spaces-deploy.yml"
10+
workflow_dispatch:
11+
inputs:
12+
force_deploy:
13+
description: "Force deployment even without changes"
14+
required: false
15+
default: "false"
16+
type: boolean
17+
18+
env:
19+
HF_SPACE: samuellimabraz/quantum-assistant
20+
21+
jobs:
22+
deploy:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
lfs: true
31+
32+
- name: Setup Git LFS
33+
run: git lfs install
34+
35+
- name: Configure Git
36+
run: |
37+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
38+
git config --global user.name "github-actions[bot]"
39+
40+
- name: Prepare Space files
41+
run: |
42+
43+
mkdir -p /tmp/hf-space
44+
45+
cp -r src/demo/* /tmp/hf-space/
46+
rm -rf /tmp/hf-space/node_modules
47+
rm -rf /tmp/hf-space/.next
48+
rm -rf /tmp/hf-space/.venv
49+
rm -f /tmp/hf-space/.env.local
50+
rm -f /tmp/hf-space/.env
51+
52+
cat > /tmp/hf-space/README.md << 'EOF'
53+
---
54+
title: Quantum Assistant
55+
emoji: ♾️
56+
colorFrom: indigo
57+
colorTo: purple
58+
sdk: docker
59+
pinned: true
60+
app_port: 7860
61+
license: apache-2.0
62+
short_description: Multimodal VLM for Quantum Computing with Qiskit
63+
datasets:
64+
- samuellimabraz/quantum-assistant
65+
models:
66+
- samuellimabraz/Qwen3-VL-8B-rslora-r32-2
67+
---
68+
69+
Interactive demo for **Quantum Assistant** - A Multimodal Vision Language Model specialized for Quantum Computing with Qiskit.
70+
71+
## Features
72+
73+
- 💬 **Chat Interface**: Interact with the quantum-specialized VLM
74+
- 📊 **Dataset Explorer**: Browse examples from the quantum-assistant dataset
75+
- ⚡ **Code Execution**: Run Qiskit code directly in the browser
76+
- 🖼️ **Image Understanding**: Analyze quantum circuit diagrams, Bloch spheres, and histograms
77+
78+
## Resources
79+
80+
- 📦 [Dataset](https://huggingface.co/datasets/samuellimabraz/quantum-assistant)
81+
- 🤖 [Models](https://huggingface.co/collections/samuellimabraz/quantum-assistant)
82+
- 💻 [GitHub](https://github.com/samuellimabraz/quantum-assistant)
83+
84+
## Configuration
85+
86+
Configure the model endpoint via Space secrets:
87+
88+
- `DEMO_MODEL_URL`: VLM API endpoint (OpenAI-compatible)
89+
- `DEMO_MODEL_NAME`: Model identifier
90+
- `DEMO_API_KEY`: API authentication key
91+
92+
## Author
93+
94+
**Samuel Lima Braz** - UNIFEI (Universidade Federal de Itajubá)
95+
96+
Final Graduation Project - 2025
97+
EOF
98+
99+
sed -i 's/^ //' /tmp/hf-space/README.md
100+
101+
- name: Push to HuggingFace Spaces
102+
env:
103+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
104+
run: |
105+
cd /tmp/hf-space
106+
107+
git init -b main
108+
git remote add space https://huggingface.co/spaces/${{ env.HF_SPACE }}
109+
110+
git config http.postBuffer 524288000
111+
git lfs install
112+
git lfs track "*.png" "*.jpg" "*.jpeg" "*.gif" "*.webp" "*.ico" "*.svg"
113+
git add .gitattributes
114+
115+
git add -A
116+
git commit -m "Deploy demo from GitHub Actions - $(date +'%Y-%m-%d %H:%M:%S')" || echo "No changes to commit"
117+
118+
git push --force https://user:${HF_TOKEN}@huggingface.co/spaces/${{ env.HF_SPACE }} HEAD:main

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dist/
1010
downloads/
1111
eggs/
1212
.eggs/
13-
lib/
1413
lib64/
1514
parts/
1615
sdist/
@@ -53,3 +52,6 @@ htmlcov/
5352

5453
# HuggingFace
5554
.huggingface/
55+
56+
node_modules/
57+
.next/

src/demo/.dockerignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Dependencies
2+
node_modules/
3+
.pnp/
4+
.pnp.js
5+
6+
# Build outputs
7+
.next/
8+
out/
9+
build/
10+
11+
.env
12+
.env.local
13+
.env.development.local
14+
.env.test.local
15+
.env.production.local
16+
17+
# IDE and editors
18+
.idea/
19+
.vscode/
20+
*.swp
21+
*.swo
22+
.DS_Store
23+
24+
# Logs
25+
npm-debug.log*
26+
yarn-debug.log*
27+
yarn-error.log*
28+
29+
# Testing
30+
coverage/
31+
.nyc_output/
32+
33+
# TypeScript cache
34+
*.tsbuildinfo
35+
36+
# Misc
37+
*.md
38+
!README.md
39+
LICENSE
40+
.git/
41+
.gitignore
42+
43+
.venv/
44+
__pycache__/
45+
*.pyc
46+
*.pyo
47+

src/demo/.env.local.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
DEMO_MODEL_URL=https://server/v1
2+
DEMO_MODEL_NAME=samuellimabraz/Qwen3-VL-8B-rslora-r32-2
3+
DEMO_API_KEY=xxx
4+
DEMO_MAX_TOKENS=4096
5+
DEMO_TEMPERATURE=0.1
6+
DEMO_TIMEOUT=40
7+
DEMO_DEBUG=true

src/demo/Dockerfile

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM node:20-slim AS builder
2+
3+
WORKDIR /app
4+
5+
COPY package*.json ./
6+
7+
RUN npm ci --legacy-peer-deps
8+
9+
COPY . .
10+
11+
ENV NEXT_TELEMETRY_DISABLED=1
12+
RUN npm run build
13+
14+
FROM python:3.11-slim AS runner
15+
16+
RUN apt-get update && apt-get install -y \
17+
curl \
18+
gnupg \
19+
git \
20+
git-lfs \
21+
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
22+
&& apt-get install -y nodejs \
23+
&& apt-get clean \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
RUN useradd -m -u 1000 app
27+
WORKDIR /app
28+
29+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
30+
31+
COPY pyproject.toml ./
32+
33+
RUN uv venv .venv && \
34+
. .venv/bin/activate && \
35+
uv pip install -e . && \
36+
rm -rf /root/.cache/uv
37+
38+
COPY --from=builder --chown=app:app /app/.next/standalone ./
39+
COPY --from=builder --chown=app:app /app/.next/static ./.next/static
40+
COPY --from=builder --chown=app:app /app/public ./public
41+
42+
RUN chown -R app:app /app
43+
44+
USER app
45+
46+
ENV NODE_ENV=production
47+
ENV NEXT_TELEMETRY_DISABLED=1
48+
ENV PORT=7860
49+
ENV HOSTNAME=0.0.0.0
50+
ENV PYTHON_PATH=/app/.venv/bin/python
51+
52+
EXPOSE 7860
53+
54+
CMD ["node", "server.js"]
55+

0 commit comments

Comments
 (0)