Spaces:
Running
Running
| # src/app/__main__.py | |
| import argparse | |
| import sys | |
| import json | |
| import dataclasses | |
| # Deferred import | |
| # from .gradio_app import main | |
| from prompts.store import get_template_store | |
| def handle_prompts(args): | |
| try: | |
| store = get_template_store() | |
| except Exception as e: | |
| print(json.dumps({"error": f"Failed to load templates: {str(e)}"}), file=sys.stderr) | |
| sys.exit(1) | |
| if args.list_prompts: | |
| templates = [] | |
| if args.category: | |
| templates = store.list_by_category(args.category) | |
| else: | |
| templates = store.list_templates() | |
| output = {"count": len(templates), "templates": [dataclasses.asdict(t) for t in templates]} | |
| print(json.dumps(output, indent=2)) | |
| sys.exit(0) | |
| if args.get_prompt: | |
| template = store.get_template(args.get_prompt) | |
| if not template: | |
| print(json.dumps({"error": f"Template not found: {args.get_prompt}"}), file=sys.stderr) | |
| sys.exit(1) | |
| print(json.dumps(dataclasses.asdict(template), indent=2)) | |
| sys.exit(0) | |
| if __name__ == "__main__": | |
| parser = argparse.ArgumentParser(description="Runner Agentic Intelligence") | |
| parser.add_argument("--list-prompts", action="store_true", help="List all prompt templates") | |
| parser.add_argument("--category", type=str, help="Filter templates by category") | |
| parser.add_argument("--get-prompt", type=str, help="Get a specific prompt template by ID") | |
| # Parse known args to avoid conflict with Gradio or other potential subcommands | |
| args, unknown = parser.parse_known_args() | |
| if args.list_prompts or args.get_prompt: | |
| handle_prompts(args) | |
| else: | |
| from .gradio_app import launch_app | |
| launch_app() | |