Download src/cli/main.py from MHamdan/SPARKNET: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/spaces/MHamdan/SPARKNET/resolve/76c3b0a8cd44eb930c2ad41fc0e95acdb3cd2bab/src/cli/main.py
- Command line
-
hf download hf://spaces/MHamdan/SPARKNET@76c3b0a8cd44eb930c2ad41fc0e95acdb3cd2bab/src/cli/main.py
-
curl -L -o main.py https://huggingface.co/spaces/MHamdan/SPARKNET/resolve/76c3b0a8cd44eb930c2ad41fc0e95acdb3cd2bab/src/cli/main.py
2.82 kB
| """ | |
| SPARKNET CLI Main Entry Point | |
| Usage: | |
| sparknet document parse <file> | |
| sparknet document extract <file> --schema <schema.yaml> | |
| sparknet rag index <file> | |
| sparknet rag ask <question> | |
| """ | |
| import typer | |
| from typing import Optional | |
| from pathlib import Path | |
| import json | |
| import sys | |
| from .document import document_app | |
| from .rag import rag_app | |
| # Create main app | |
| app = typer.Typer( | |
| name="sparknet", | |
| help="SPARKNET Document Intelligence CLI", | |
| add_completion=False, | |
| ) | |
| # Register sub-commands | |
| app.add_typer(document_app, name="document", help="Document processing commands") | |
| app.add_typer(rag_app, name="rag", help="RAG and retrieval commands") | |
| def version(): | |
| """Show SPARKNET version.""" | |
| typer.echo("SPARKNET Document Intelligence v0.1.0") | |
| def info(): | |
| """Show system information and configuration.""" | |
| from loguru import logger | |
| import platform | |
| typer.echo("SPARKNET Document Intelligence") | |
| typer.echo("=" * 40) | |
| typer.echo(f"Python: {platform.python_version()}") | |
| typer.echo(f"Platform: {platform.system()} {platform.release()}") | |
| typer.echo() | |
| # Check component availability | |
| typer.echo("Components:") | |
| # OCR | |
| try: | |
| from paddleocr import PaddleOCR | |
| typer.echo(" [β] PaddleOCR") | |
| except ImportError: | |
| typer.echo(" [β] PaddleOCR (install with: pip install paddleocr)") | |
| try: | |
| import pytesseract | |
| typer.echo(" [β] Tesseract") | |
| except ImportError: | |
| typer.echo(" [β] Tesseract (install with: pip install pytesseract)") | |
| # Vector Store | |
| try: | |
| import chromadb | |
| typer.echo(" [β] ChromaDB") | |
| except ImportError: | |
| typer.echo(" [β] ChromaDB (install with: pip install chromadb)") | |
| # Ollama | |
| try: | |
| import httpx | |
| with httpx.Client(timeout=2.0) as client: | |
| resp = client.get("http://localhost:11434/api/tags") | |
| if resp.status_code == 200: | |
| models = resp.json().get("models", []) | |
| typer.echo(f" [β] Ollama ({len(models)} models)") | |
| else: | |
| typer.echo(" [β] Ollama (not responding)") | |
| except Exception: | |
| typer.echo(" [β] Ollama (not running)") | |
| def main_callback( | |
| verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose output"), | |
| quiet: bool = typer.Option(False, "--quiet", "-q", help="Suppress output"), | |
| ): | |
| """SPARKNET Document Intelligence CLI.""" | |
| from loguru import logger | |
| import sys | |
| # Configure logging | |
| logger.remove() | |
| if verbose: | |
| logger.add(sys.stderr, level="DEBUG") | |
| elif not quiet: | |
| logger.add(sys.stderr, level="INFO") | |
| def main(): | |
| """Main entry point.""" | |
| app() | |
| if __name__ == "__main__": | |
| main() | |