File size: 1,735 Bytes
d64fd55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# 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()