""" SPARKNET CLI Main Entry Point Usage: sparknet document parse sparknet document extract --schema sparknet rag index sparknet rag ask """ 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") @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() # 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)") @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 # 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()