| """ |
| 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 |
|
|
| |
| app = typer.Typer( |
| name="sparknet", |
| help="SPARKNET Document Intelligence CLI", |
| add_completion=False, |
| ) |
|
|
| |
| app.add_typer(document_app, name="document", help="Document processing commands") |
| app.add_typer(rag_app, name="rag", help="RAG and retrieval commands") |
|
|
|
|
| @app.command() |
| def version(): |
| """Show SPARKNET version.""" |
| typer.echo("SPARKNET Document Intelligence v0.1.0") |
|
|
|
|
| @app.command() |
| 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() |
|
|
| |
| typer.echo("Components:") |
|
|
| |
| 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)") |
|
|
| |
| try: |
| import chromadb |
| typer.echo(" [β] ChromaDB") |
| except ImportError: |
| typer.echo(" [β] ChromaDB (install with: pip install chromadb)") |
|
|
| |
| 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)") |
|
|
|
|
| @app.callback() |
| 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 |
|
|
| |
| 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() |
|
|