Spaces:
Running
Running
fix: add missing meeting_summarizer module to Dockerfile for HF Spaces deployment
Browse files- AGENTS.md +26 -74
- Dockerfile +1 -0
- app.py +1 -2
AGENTS.md
CHANGED
|
@@ -22,7 +22,6 @@ python app.py # Starts on port 7860
|
|
| 22 |
**Linting (if ruff installed):**
|
| 23 |
```bash
|
| 24 |
ruff check .
|
| 25 |
-
ruff check --select I . # Import sorting
|
| 26 |
ruff format . # Auto-format code
|
| 27 |
```
|
| 28 |
|
|
@@ -32,20 +31,24 @@ mypy summarize_transcript.py
|
|
| 32 |
mypy app.py
|
| 33 |
```
|
| 34 |
|
| 35 |
-
**Running tests:**
|
| 36 |
```bash
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
```
|
| 41 |
|
| 42 |
-
**
|
| 43 |
```bash
|
| 44 |
-
|
| 45 |
-
cd llama-cpp-python && pytest tests/test_llama.py::test_function_name -v
|
| 46 |
|
| 47 |
-
# Run
|
| 48 |
-
cd llama-cpp-python && pytest
|
| 49 |
```
|
| 50 |
|
| 51 |
## Code Style Guidelines
|
|
@@ -53,13 +56,13 @@ cd llama-cpp-python && pytest --full-trace -v
|
|
| 53 |
**Formatting:**
|
| 54 |
- Use 4 spaces for indentation
|
| 55 |
- Line length: 100 characters max
|
| 56 |
-
- Use double quotes for docstrings
|
| 57 |
- Two blank lines before function definitions
|
| 58 |
- One blank line after docstrings
|
| 59 |
|
| 60 |
-
**Imports:**
|
| 61 |
```python
|
| 62 |
-
# Standard library
|
| 63 |
import os
|
| 64 |
import argparse
|
| 65 |
import re
|
|
@@ -73,9 +76,9 @@ import gradio as gr
|
|
| 73 |
```
|
| 74 |
|
| 75 |
**Type Hints:**
|
| 76 |
-
- Use type hints for
|
| 77 |
- Use `Optional[]` for nullable types
|
| 78 |
-
- Use `Generator[str, None, None]` for
|
| 79 |
- Example: `def load_model(repo_id: str, filename: str, cpu_only: bool = False) -> Llama:`
|
| 80 |
|
| 81 |
**Naming Conventions:**
|
|
@@ -86,8 +89,8 @@ import gradio as gr
|
|
| 86 |
|
| 87 |
**Docstrings:**
|
| 88 |
- Use triple quotes for all public functions
|
|
|
|
| 89 |
- Include Args/Returns sections for complex functions
|
| 90 |
-
- Keep first line as a brief summary
|
| 91 |
|
| 92 |
**Error Handling:**
|
| 93 |
- Use explicit error messages with f-strings
|
|
@@ -113,15 +116,13 @@ import gradio as gr
|
|
| 113 |
```
|
| 114 |
tiny-scribe/
|
| 115 |
βββ summarize_transcript.py # Main CLI script
|
| 116 |
-
βββ app.py # Gradio web app
|
| 117 |
βββ requirements.txt # Python dependencies
|
| 118 |
-
βββ Dockerfile # HF Spaces deployment config
|
| 119 |
βββ transcripts/ # Input transcript files
|
| 120 |
-
|
| 121 |
-
|
|
|
|
| 122 |
βββ llama-cpp-python/ # Git submodule
|
| 123 |
-
β βββ tests/ # Test suite
|
| 124 |
-
β βββ vendor/llama.cpp/ # Core C++ library
|
| 125 |
βββ README.md # Project documentation
|
| 126 |
```
|
| 127 |
|
|
@@ -148,63 +149,14 @@ stream = llm.create_chat_completion(
|
|
| 148 |
)
|
| 149 |
```
|
| 150 |
|
| 151 |
-
**Thinking Block Parsing:**
|
| 152 |
-
```python
|
| 153 |
-
# Extract thinking/reasoning blocks from model output
|
| 154 |
-
THINKING_PATTERN = re.compile(r'<think(?:ing)?>(.*?)</think(?:ing)?>', re.DOTALL)
|
| 155 |
-
|
| 156 |
-
for chunk in stream:
|
| 157 |
-
delta = chunk["choices"][0]["delta"]
|
| 158 |
-
if content := delta.get("content", ""):
|
| 159 |
-
buffer += content
|
| 160 |
-
thinking_match = THINKING_PATTERN.search(buffer)
|
| 161 |
-
if thinking_match:
|
| 162 |
-
thinking = thinking_match.group(1).strip()
|
| 163 |
-
buffer = buffer[:thinking_match.start()] + buffer[thinking_match.end():]
|
| 164 |
-
```
|
| 165 |
-
|
| 166 |
-
**Chinese Text Conversion (zh-TW mode only):**
|
| 167 |
-
```python
|
| 168 |
-
# Convert Simplified Chinese to Traditional Chinese (Taiwan)
|
| 169 |
-
converter = OpenCC('s2twp') # s2twp = Simplified to Traditional (Taiwan)
|
| 170 |
-
# Only apply when output_language == "zh-TW"
|
| 171 |
-
if output_language == "zh-TW":
|
| 172 |
-
traditional_text = converter.convert(simplified_text)
|
| 173 |
-
else:
|
| 174 |
-
traditional_text = simplified_text # Skip conversion for English
|
| 175 |
-
```
|
| 176 |
-
|
| 177 |
## Notes for AI Agents
|
| 178 |
|
| 179 |
-
- This is a simple utility project; no formal CI/CD or test suite in root
|
| 180 |
-
- When modifying, maintain the existing streaming output pattern
|
| 181 |
- Always call `llm.reset()` after completion to ensure state isolation
|
| 182 |
- Model format: `repo_id:quant` (e.g., `unsloth/Qwen3-1.7B-GGUF:Q2_K_L`)
|
| 183 |
-
- Default language output is English (zh-TW available via `-l zh-TW`
|
| 184 |
- OpenCC conversion only applied when output_language is "zh-TW"
|
| 185 |
- HuggingFace cache at `~/.cache/huggingface/hub/` - clean periodically
|
| 186 |
- HF Spaces runs on CPU tier with 2 vCPUs, 16GB RAM
|
| 187 |
- Keep model sizes under 4GB for reasonable performance on free tier
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
```bash
|
| 192 |
-
# Initialize/update submodules
|
| 193 |
-
git submodule update --init --recursive
|
| 194 |
-
|
| 195 |
-
# Update llama-cpp-python to latest
|
| 196 |
-
cd llama-cpp-python && git pull origin main && cd .. && git add llama-cpp-python
|
| 197 |
-
```
|
| 198 |
-
|
| 199 |
-
## Docker/HuggingFace Spaces Deployment
|
| 200 |
-
|
| 201 |
-
```bash
|
| 202 |
-
# Build locally
|
| 203 |
-
docker build -t tiny-scribe .
|
| 204 |
-
|
| 205 |
-
# Run locally
|
| 206 |
-
docker run -p 7860:7860 tiny-scribe
|
| 207 |
-
|
| 208 |
-
# Deploy script
|
| 209 |
-
./deploy.sh # Commits, pushes, and triggers HF Spaces rebuild
|
| 210 |
-
```
|
|
|
|
| 22 |
**Linting (if ruff installed):**
|
| 23 |
```bash
|
| 24 |
ruff check .
|
|
|
|
| 25 |
ruff format . # Auto-format code
|
| 26 |
```
|
| 27 |
|
|
|
|
| 31 |
mypy app.py
|
| 32 |
```
|
| 33 |
|
| 34 |
+
**Running tests (root project tests):**
|
| 35 |
```bash
|
| 36 |
+
# Run E2E test
|
| 37 |
+
python test_e2e.py
|
| 38 |
+
|
| 39 |
+
# Run advanced mode test
|
| 40 |
+
python test_advanced_mode.py
|
| 41 |
+
|
| 42 |
+
# Run LFM2 extraction test
|
| 43 |
+
python test_lfm2_extract.py
|
| 44 |
```
|
| 45 |
|
| 46 |
+
**llama-cpp-python submodule tests:**
|
| 47 |
```bash
|
| 48 |
+
cd llama-cpp-python && pip install ".[test]" && pytest tests/test_llama.py -v
|
|
|
|
| 49 |
|
| 50 |
+
# Run specific test
|
| 51 |
+
cd llama-cpp-python && pytest tests/test_llama.py::test_function_name -v
|
| 52 |
```
|
| 53 |
|
| 54 |
## Code Style Guidelines
|
|
|
|
| 56 |
**Formatting:**
|
| 57 |
- Use 4 spaces for indentation
|
| 58 |
- Line length: 100 characters max
|
| 59 |
+
- Use double quotes for docstrings
|
| 60 |
- Two blank lines before function definitions
|
| 61 |
- One blank line after docstrings
|
| 62 |
|
| 63 |
+
**Imports (ordered):**
|
| 64 |
```python
|
| 65 |
+
# Standard library
|
| 66 |
import os
|
| 67 |
import argparse
|
| 68 |
import re
|
|
|
|
| 76 |
```
|
| 77 |
|
| 78 |
**Type Hints:**
|
| 79 |
+
- Use type hints for parameters and return values
|
| 80 |
- Use `Optional[]` for nullable types
|
| 81 |
+
- Use `Generator[str, None, None]` for generators
|
| 82 |
- Example: `def load_model(repo_id: str, filename: str, cpu_only: bool = False) -> Llama:`
|
| 83 |
|
| 84 |
**Naming Conventions:**
|
|
|
|
| 89 |
|
| 90 |
**Docstrings:**
|
| 91 |
- Use triple quotes for all public functions
|
| 92 |
+
- Keep first line as brief summary
|
| 93 |
- Include Args/Returns sections for complex functions
|
|
|
|
| 94 |
|
| 95 |
**Error Handling:**
|
| 96 |
- Use explicit error messages with f-strings
|
|
|
|
| 116 |
```
|
| 117 |
tiny-scribe/
|
| 118 |
βββ summarize_transcript.py # Main CLI script
|
| 119 |
+
βββ app.py # Gradio web app
|
| 120 |
βββ requirements.txt # Python dependencies
|
|
|
|
| 121 |
βββ transcripts/ # Input transcript files
|
| 122 |
+
βββ test_e2e.py # E2E test
|
| 123 |
+
βββ test_advanced_mode.py # Advanced mode test
|
| 124 |
+
βββ test_lfm2_extract.py # LFM2 extraction test
|
| 125 |
βββ llama-cpp-python/ # Git submodule
|
|
|
|
|
|
|
| 126 |
βββ README.md # Project documentation
|
| 127 |
```
|
| 128 |
|
|
|
|
| 149 |
)
|
| 150 |
```
|
| 151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
## Notes for AI Agents
|
| 153 |
|
|
|
|
|
|
|
| 154 |
- Always call `llm.reset()` after completion to ensure state isolation
|
| 155 |
- Model format: `repo_id:quant` (e.g., `unsloth/Qwen3-1.7B-GGUF:Q2_K_L`)
|
| 156 |
+
- Default language output is English (zh-TW available via `-l zh-TW` or web UI)
|
| 157 |
- OpenCC conversion only applied when output_language is "zh-TW"
|
| 158 |
- HuggingFace cache at `~/.cache/huggingface/hub/` - clean periodically
|
| 159 |
- HF Spaces runs on CPU tier with 2 vCPUs, 16GB RAM
|
| 160 |
- Keep model sizes under 4GB for reasonable performance on free tier
|
| 161 |
+
- Tests exist in root (test_e2e.py, test_advanced_mode.py, test_lfm2_extract.py)
|
| 162 |
+
- Submodule tests in llama-cpp-python/tests/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
CHANGED
|
@@ -19,6 +19,7 @@ RUN pip install --no-cache-dir -r requirements.txt
|
|
| 19 |
|
| 20 |
# Copy application files
|
| 21 |
COPY app.py .
|
|
|
|
| 22 |
|
| 23 |
# Pre-download model on build (optional, speeds up first run)
|
| 24 |
# RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='unsloth/Qwen3-0.6B-GGUF', filename='Qwen3-0.6B-Q4_K_M.gguf', local_dir='./models')"
|
|
|
|
| 19 |
|
| 20 |
# Copy application files
|
| 21 |
COPY app.py .
|
| 22 |
+
COPY meeting_summarizer/ meeting_summarizer/
|
| 23 |
|
| 24 |
# Pre-download model on build (optional, speeds up first run)
|
| 25 |
# RUN python -c "from huggingface_hub import hf_hub_download; hf_hub_download(repo_id='unsloth/Qwen3-0.6B-GGUF', filename='Qwen3-0.6B-Q4_K_M.gguf', local_dir='./models')"
|
app.py
CHANGED
|
@@ -3417,6 +3417,5 @@ if __name__ == "__main__":
|
|
| 3417 |
server_name="0.0.0.0",
|
| 3418 |
server_port=7860,
|
| 3419 |
share=False,
|
| 3420 |
-
show_error=True
|
| 3421 |
-
css=custom_css
|
| 3422 |
)
|
|
|
|
| 3417 |
server_name="0.0.0.0",
|
| 3418 |
server_port=7860,
|
| 3419 |
share=False,
|
| 3420 |
+
show_error=True
|
|
|
|
| 3421 |
)
|