BonusLockSMith commited on
Commit
906220b
·
verified ·
1 Parent(s): 34eb8dc

Upload spine_agent.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. spine_agent.py +94 -0
spine_agent.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # D:\AI-Hub\ComicPipeline\spine_agent.py
2
+ # CLI entry point — imports SpineAgent from the spine/ package.
3
+
4
+ import json
5
+ import argparse
6
+ from spine import SpineAgent
7
+
8
+
9
+ def main():
10
+ parser = argparse.ArgumentParser(description="Spine Agent - Multi-tool AI orchestrator")
11
+ parser.add_argument("prompt", help="Command prompt")
12
+ parser.add_argument("--server", choices=["rig1", "spark", "rig1_network"], default="rig1")
13
+ args = parser.parse_args()
14
+
15
+ agent = SpineAgent()
16
+ result = agent.run(args.prompt, args.server)
17
+
18
+ if result["status"] == "success":
19
+ op = result.get("operation", "")
20
+
21
+ if op == "generate_image":
22
+ print(f"Image generated: {result['filepath']}")
23
+ print(f"Model: {result['model']}, Seed: {result['seed']}")
24
+
25
+ elif op == "generate_characters":
26
+ print(f"Characters generated: {result['success_count']}/{result['total_characters']}")
27
+ print(f"Output: {result['characters_dir']}")
28
+ for r in result['results']:
29
+ if r['status'] == 'success':
30
+ print(f" {r['character_id']}: {r['filepath']}")
31
+
32
+ elif op == "generate_scene":
33
+ print(f"Scene generated: {result['filepath']}")
34
+ print(f"Story: {result['story']}, Page: {result['page_number']}")
35
+ print(f"Characters: {result['characters']}, Seed: {result['seed']}")
36
+
37
+ elif op == "create_story":
38
+ print(f"Story created: {result['title']}")
39
+ print(f"Format: {result['format']}, ID: {result['story_id']}")
40
+ print(f"Characters: {result['characters']}, Pages: {result['pages']}")
41
+ print(f"Saved: {result['filepath']}")
42
+ print(f"Duration: {result['duration_seconds']}s")
43
+
44
+ elif op == "render_comic":
45
+ print(f"Comic rendered: {result['story']}")
46
+ print(f"Pages: {result['pages']}")
47
+ print(f"Output: {result['filepath']}")
48
+
49
+ elif op == "render_coloring_book":
50
+ print(f"Coloring book rendered: {result['story']}")
51
+ print(f"Pages: {result['pages']}")
52
+ print(f"Output: {result['filepath']}")
53
+
54
+ elif op == "render_children_book":
55
+ print(f"Children's book rendered: {result['story']}")
56
+ print(f"Output: {result['filepath']}")
57
+
58
+ elif op == "render_story":
59
+ print(f"Story rendered: {result['story_id']}")
60
+ print(f"Duration: {result['duration_seconds']}s")
61
+
62
+ elif op == "retry_failures":
63
+ print(f"Retry complete: {result['recovered']}/{result['retried']} recovered")
64
+ if result['still_failed'] > 0:
65
+ print(f"Still failing: {result['still_failed']}")
66
+
67
+ elif op == "batch_generate":
68
+ print(f"Batch generated: {result['success_count']}/{result['count']} images")
69
+ print(f"Output: {result['output_dir']}")
70
+ if result['seeds']:
71
+ print(f"Seeds: {result['seeds']}")
72
+
73
+ elif op == "memory_stats":
74
+ print(f"Memory stats: {json.dumps(result['data'], indent=2)}")
75
+
76
+ elif op == "recall":
77
+ print(f"Recall results: {json.dumps(result['data'], indent=2)}")
78
+
79
+ elif op == "rag_query":
80
+ print(f"Answer: {result['answer']}")
81
+
82
+ elif op == "read_json":
83
+ print(f"Read: {result['filepath']}")
84
+ print(json.dumps(result['data'], indent=2)[:500])
85
+
86
+ else:
87
+ print(json.dumps(result, indent=2))
88
+
89
+ else:
90
+ print(f"Error: {result.get('error', 'unknown')}")
91
+
92
+
93
+ if __name__ == "__main__":
94
+ main()