Skill站外收录 @skilllib/skill-2117939930272412986
common-skills
提供跨服务共享的 Python 工具集,统一管理 GGUF 模型文件的解析、筛选与下载,集成 HuggingFace Hub 的安全访问与高速传输能力,并支持进程标识文件的安全读写,确保多服务间基础功能的一致性与可靠性。
数据与分析 AI 技能
Skills.MD
# Common Skills for LlamaFarm
Best practices and code review checklists for the `common/` package - shared Python utilities used across all LlamaFarm services.
## Component Overview
| Attribute | Value |
|-----------|-------|
| Path | `common/` |
| Package | `llamafarm-common` |
| Python | 3.10+ |
| Key Dependencies | huggingface_hub, hf-transfer |
## Purpose
The `common/` package provides shared functionality that needs to be consistent across multiple Python services:
- Model file utilities (GGUF selection, quantization parsing)
- HuggingFace Hub integration (listing, downloading)
- Process management (PID files)
## Shared Python Skills
This skill inherits all patterns from the shared Python skills:
| Topic | File | Relevance |
|-------|------|-----------|
| Patterns | [../python-skills/patterns.md](../python-skills/patterns.md) | Dataclasses, type hints, comprehensions |
| Typing | [../python-skills/typing.md](../python-skills/typing.md) | Type annotations, modern syntax |
| Testing | [../python-skills/testing.md](../python-skills/testing.md) | Pytest fixtures, mocking HuggingFace APIs |
| Errors | [../python-skills/error-handling.md](../python-skills/error-handling.md) | Custom exceptions, logging |
| Security | [../python-skills/security.md](../python-skills/security.md) | Path validation, safe file handling |
## Framework-Specific Checklists
| Topic | File | Key Points |
|-------|------|------------|
| HuggingFace | [huggingface.md](huggingface.md) | Hub API, model download, caching, authentication |
## Module Structure
```
common/
├── pyproject.toml # UV-managed dependencies
├── llamafarm_common/
│ ├── __init__.py # Public API exports
│ ├── model_utils.py # GGUF file utilities
│ └── pidfile.py # PID file management
└── tests/
└── test_model_utils.py # Unit tests with mocking
```
## Public API
### Model Utilities
```python
from llamafarm_common import (
# Parse model:quantization syntax
parse_model_with_quantization,
# Extract quantization from filename
parse_quantization_from_filename,
# Select best GGUF file from list
select_gguf_file,
select_gguf_file_with_logging,
# List GGUF files in HF repo
list_gguf_files,
# Download and get path to GGUF file
get_gguf_file_path,
# Default quantization preference order
GGUF_QUANTIZATION_PREFERENCE_ORDER,
)
```
### PID File Management
```python
from llamafarm_common.pidfile import write_pid, get_pid_file
```
## Review Checklist Summary
When reviewing code in `common/`:
1. **HuggingFace Integration** (High priority)
- Proper error handling for network failures
- Authentication token passed correctly
- High-speed transfer enabled appropriately
2. **Model Selection** (Medium priority)
- Quantization preference order maintained
- Case-insensitive matching
- Graceful fallback when preferred not available
3. **Testing** (High priority)
- HuggingFace API calls mocked
- Network isolation in tests
- Edge cases covered (empty lists, missing files)
4. **Security** (Medium priority)
- No token exposure in logs
- Safe file path handling
- Environment variable protection
See [huggingface.md](huggingface.md) for detailed HuggingFace-specific checklists.
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「common-skills」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次