Compare commits
588 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 083d73d287 | |||
| d21d1ab960 | |||
| 043dbbf24a | |||
| 3d7ec83ec9 | |||
| 70f5667adc | |||
| 8ff77d7dba | |||
| c1ede4ade8 | |||
| 5caecb887f | |||
| 4f4aa27da8 | |||
| c6cbb5d1fb | |||
| e56e2892d0 | |||
| be3837ff06 | |||
| 0cbb024411 | |||
| ada49d3491 | |||
| eebaa11bfb | |||
| 6c85d2e871 | |||
| f67219fe02 | |||
| 774ad4d820 | |||
| adcc5a1dc1 | |||
| 5d18183d82 | |||
| 2fca49b120 | |||
| b1bc83586f | |||
| d61d242f4e | |||
| 6f97f4576f | |||
| 70492235c7 | |||
| 7251a12469 | |||
| b6cf793e1b | |||
| 78169c3bc0 | |||
| db12446a68 | |||
| c151b49334 | |||
| d14cd9f3de | |||
| 121610f8d9 | |||
| de507c7bc0 | |||
| c4bdb01b21 | |||
| e027d84da4 | |||
| 9f7bc1c37a | |||
| 2c6b52f0ed | |||
| f165dc1425 | |||
| 9cd386b720 | |||
| 58431d1d8d | |||
| f3013c8509 | |||
| aecf64af27 | |||
| 17cdb6c7fd | |||
| 229eef6db1 | |||
| 9886a3a5b2 | |||
| 095df145d6 | |||
| 91f83f781c | |||
| 0361510a05 | |||
| 93006fd299 | |||
| 81ba3ae6e8 | |||
| dbd9efc8f5 | |||
| 4dbaf69a3e | |||
| 2090dd25ea | |||
| e8b26f997f | |||
| 882e31ab96 | |||
| 667e279768 | |||
| dc6081fcaf | |||
| fd28677d66 | |||
| be8333d8f3 | |||
| b47f473db6 | |||
| 8074bee4a1 | |||
| 3d441a1c76 | |||
| 63fbbe1225 | |||
| 0a18e70639 | |||
| b639291585 | |||
| 3d7d5cf684 | |||
| 42edfedb3f | |||
| 9d0f85c048 | |||
| 1379cf59cf | |||
| 3658c2888e | |||
| 86c776ce41 | |||
| ed95c447a9 | |||
| ca3e73b73a | |||
| 04e6bcb5a6 | |||
| 84d25468b9 | |||
| c508c9ed72 | |||
| 43228bd7e1 | |||
| b1bb051160 | |||
| a3a5bbdfa5 | |||
| a738b2d974 | |||
| 9b8ce5c2c7 | |||
| d55d398832 | |||
| 06a099e159 | |||
| 0b7aaee110 | |||
| c49707df0d | |||
| 66470f315b | |||
| 2ec0bc6706 | |||
| 1bb8928ab6 | |||
| d5786608f0 | |||
| 9596cec7ba | |||
| cd00a7fec5 | |||
| ab54382834 | |||
| 060edda3ae | |||
| e398595734 | |||
| 76c52f12fc | |||
| 948b0f653b | |||
| 6d138024e4 | |||
| 3ef6ccee7f | |||
| 0d5f5f4b22 | |||
| a535aa1b8d | |||
| e698e98b2c | |||
| d663184804 | |||
| e3b61689ed | |||
| 4ba6ab39a6 | |||
| bc441c1534 | |||
| 8b1efb307b | |||
| 93f041e0b3 | |||
| ae64ec9e09 | |||
| 2c476906d9 | |||
| 508ddb1488 | |||
| 4c6915d0e5 | |||
| e0e8af3ec5 | |||
| 7c7cf60a12 | |||
| 495e5e324a | |||
| 32e27971a7 | |||
| 94dd483bc6 | |||
| 3ab24e08f1 | |||
| c77d3b6766 | |||
| cf75e0c4c0 | |||
| 4f7162be4f | |||
| bd0bf6b15d | |||
| fe04c746ab | |||
| b3aabd1617 | |||
| bca83c2f26 | |||
| a621344ae8 | |||
| b83bb04496 | |||
| ea35d29f01 | |||
| 0d10466ba7 | |||
| c1e3a2012f | |||
| 3a3390a67d | |||
| 1c7e7481f6 | |||
| 007cba2bca | |||
| 7ffb45c137 | |||
| e48350e3f9 | |||
| aa621b874c | |||
| 08c2eb5c9c | |||
| 2635fdf84c | |||
| 37df95102d | |||
| e84d92d52c | |||
| fdb8d8e866 | |||
| 36c54fd5e8 | |||
| 1672a042af | |||
| c47ec64b8a | |||
| e5608c70c5 | |||
| 61b8fb3b52 | |||
| cccb0aa9b9 | |||
| 14bbae258b | |||
| 1e6226466c | |||
| b32a649496 | |||
| 036fc9f853 | |||
| 0afb90e26a | |||
| 6c95404a30 | |||
| 30ea384573 | |||
| 3285cf7696 | |||
| 1576b27528 | |||
| c55f664e47 | |||
| 1166599f70 | |||
| b4dec14f8d | |||
| e0eb7b9ce8 | |||
| 2f5e2c1314 | |||
| 0d11c60163 | |||
| ad30742374 | |||
| 1ca3eb1abe | |||
| 3399a137d8 | |||
| b331a3d0cd | |||
| d7df19e243 | |||
| 1ec094571f | |||
| a3c3ed8dc1 | |||
| 3d363e6266 | |||
| f79292f867 | |||
| 097b3721e8 | |||
| ba71daf2c4 | |||
| 15fc356666 | |||
| 65898ef71b | |||
| e1f13f485f | |||
| 162ece34f7 | |||
| 8c6a2de820 | |||
| 9e1fa0a3ff | |||
| 193af91cd7 | |||
| e0d04e242f | |||
| e987fb8119 | |||
| 8c7a5efd49 | |||
| 323fd342f1 | |||
| 4b694a1c2d | |||
| 144ec0768a | |||
| 91c4cf9dde | |||
| 6525a3fe94 | |||
| 8ce531e12a | |||
| dd09065daa | |||
| c419c07042 | |||
| acc8381ca5 | |||
| 92034e3147 | |||
| 10c238bbd9 | |||
| 2c274ecfdb | |||
| e643649323 | |||
| fa1f50d9e0 | |||
| 1aee0ce7ee | |||
| bca93c3a5d | |||
| 08f574efc5 | |||
| 676171cd64 | |||
| 8eca08c7c9 | |||
| 7963cd0223 | |||
| 50a9675513 | |||
| aa4e50f4dc | |||
| 23321376d8 | |||
| ef94fac8fa | |||
| 3890933fe1 | |||
| e95cdcc673 | |||
| 6b1345bd5a | |||
| 798c0d747b | |||
| c3b40e6f27 | |||
| 585fd8728a | |||
| a001453e91 | |||
| d52ab1104d | |||
| 2171028eff | |||
| d90430b26e | |||
| a63a9c776f | |||
| df8d2554a1 | |||
| 9823cd4328 | |||
| 10be95f7b9 | |||
| 80b2c69a4d | |||
| 80ebcd9622 | |||
| 990916e659 | |||
| 5f9ddd2d02 | |||
| efd6f4372e | |||
| fc42d5b752 | |||
| 6bac60bcf8 | |||
| 06397e5957 | |||
| 08b32e5eea | |||
| 6c705df0d9 | |||
| 0180661438 | |||
| 7c6e3af3c1 | |||
| a6b7d644b3 | |||
| c122913492 | |||
| 3ff45f983e | |||
| 6cfb4cfba6 | |||
| 9206074c12 | |||
| fbf356c950 | |||
| 90951342e1 | |||
| 020fd37b34 | |||
| f7796e5f43 | |||
| bd073ac74c | |||
| c790c6a429 | |||
| cd0eff1768 | |||
| d5e03d7096 | |||
| f371ff184b | |||
| cfe0b02a21 | |||
| dd8b911386 | |||
| 7f6b7ef060 | |||
| 7d5afba1cd | |||
| f15842e9cf | |||
| e38705e7d2 | |||
| bfa846f679 | |||
| 4a3d358b4c | |||
| 1529c021ef | |||
| 20b837ec0d | |||
| d1990e6181 | |||
| 01c4f69b4f | |||
| 782f326a34 | |||
| 83358a951d | |||
| 7d19ae4741 | |||
| 9003aa0548 | |||
| 0af9082aa9 | |||
| 63366e23c1 | |||
| e0766d22fc | |||
| d5e8968c97 | |||
| 123ae87c1a | |||
| b4e4b30b8e | |||
| be2c28b7f3 | |||
| 3ab65a698a | |||
| 33ee2d37c9 | |||
| cc4cb1f9f1 | |||
| 30b9a400ae | |||
| ac570d2114 | |||
| 05d40cc8a9 | |||
| 1f1522c5ef | |||
| 34d4025943 | |||
| 9d1f53d70b | |||
| de0aa06b15 | |||
| ecb209633a | |||
| 9cd3e20e48 | |||
| 4aa51405c5 | |||
| 25adc1017f | |||
| 96a6d79c87 | |||
| db9749df65 | |||
| 11319c0493 | |||
| 40749888e3 | |||
| 0e07ab79f6 | |||
| 8ec5fc61d8 | |||
| 5efa09a2b5 | |||
| 12390957e9 | |||
| 8ab6802bff | |||
| af028ab8f4 | |||
| db74b11e21 | |||
| 087b29dc93 | |||
| 3d54f0ba41 | |||
| 9175427006 | |||
| 74d2156007 | |||
| 5807e33653 | |||
| 23d5a49c41 | |||
| 82c400ed6c | |||
| 461bb291a0 | |||
| 72b2ba21c7 | |||
| 7f1a9f6810 | |||
| 7f6a968eb2 | |||
| edf0c3ec6d | |||
| 0558cd7615 | |||
| 04d409d2e4 | |||
| f4978cfe04 | |||
| f5c4cc829e | |||
| 7e202a1bd9 | |||
| add9a163c1 | |||
| 074a075525 | |||
| c7cda3b100 | |||
| e58d1078dd | |||
| 1f81100378 | |||
| 3ed4cb38b3 | |||
| ba18f4c403 | |||
| 4f60e7ae96 | |||
| 841de6dadb | |||
| 851be32945 | |||
| 3fbf04f8e7 | |||
| 165742d930 | |||
| a05d7e763e | |||
| 835772ba73 | |||
| 48eca7d836 | |||
| 5b76b3e647 | |||
| 6ec6a93764 | |||
| 74288a7ddd | |||
| 9088213769 | |||
| 8cd8a240b4 | |||
| 6796cce849 | |||
| eb4fd82a84 | |||
| 696ede8696 | |||
| 921bcba43a | |||
| 357e585399 | |||
| 8a736a4103 | |||
| b0244691cb | |||
| 55fcbf107d | |||
| 693bb56d7f | |||
| 953381a868 | |||
| aa6a8d9d45 | |||
| 2a422cdf6f | |||
| 40cf967347 | |||
| 1c55baad37 | |||
| 89e7a579bf | |||
| e283b477d2 | |||
| 7c54c7b7e7 | |||
| d95857dcc7 | |||
| ebee351523 | |||
| 93c8760788 | |||
| 73c59449fe | |||
| 3aaaf36ff6 | |||
| a8edc43a3f | |||
| 51c86a22f4 | |||
| 2c1618ef06 | |||
| 0fe09afdb6 | |||
| 31d1b4050f | |||
| e4b8ddab94 | |||
| c34b7b9ea0 | |||
| 9ffbfeb6c5 | |||
| 474a5bee99 | |||
| 791c782606 | |||
| e25c279eeb | |||
| 362a735a91 | |||
| d8e4033741 | |||
| 20f5974b52 | |||
| 8732c3e0a4 | |||
| 8b53384059 | |||
| 771115b42b | |||
| b5de4f6745 | |||
| e2c352d502 | |||
| d981e0a6fe | |||
| c3367b47b1 | |||
| 44ad6ac213 | |||
| 8a34dcb8f2 | |||
| 29f14e83c4 | |||
| 2bbbf1950d | |||
| b2378a219b | |||
| 9f12e835b8 | |||
| d29b4804af | |||
| ff9fb9a4ca | |||
| cce30ffacb | |||
| b8b8f2d6af | |||
| 58d80e34c6 | |||
| 906243fdc1 | |||
| 165af40f3c | |||
| 11d210ee55 | |||
| 978b2b338b | |||
| 054545bccd | |||
| 476a31ecc6 | |||
| 6d7b477b31 | |||
| efa17d4b62 | |||
| 78eb4fb8d9 | |||
| dda0b7cc7f | |||
| e2b9999cba | |||
| 7c9c3ded42 | |||
| 2466a41eb8 | |||
| 6c4c645337 | |||
| 0533248f2c | |||
| 5e6a7b7d51 | |||
| 39e9ce4c3b | |||
| 71172fa354 | |||
| e88f066d65 | |||
| 86f1fe8852 | |||
| 2e4559715b | |||
| c1e158a368 | |||
| 2b1af42d06 | |||
| 258f8c4e96 | |||
| 59ca6cdf83 | |||
| aa28bf93fb | |||
| 65da4b451a | |||
| d6f45683a0 | |||
| a3eba898e2 | |||
| 56ce009d84 | |||
| 4fc7d0cf6d | |||
| dfa515f249 | |||
| 9b6750b85e | |||
| 575623c765 | |||
| 1f71ab4e14 | |||
| 61b774ab0b | |||
| 496895422f | |||
| e1eae6a3d9 | |||
| c7690f43d2 | |||
| 5045d9f679 | |||
| 1571f675a5 | |||
| 658f509500 | |||
| d5c7fd91d9 | |||
| 8d83d9f217 | |||
| 8dada662e8 | |||
| a06973484b | |||
| 256e872fd9 | |||
| 606f4ce5be | |||
| c184711bfc | |||
| 1d3638649b | |||
| 9244dbc853 | |||
| ca8b910d59 | |||
| b52777ac03 | |||
| cd8df324be | |||
| 64f5e3f543 | |||
| 23c6f63742 | |||
| a6d705abf1 | |||
| 2117ca60b8 | |||
| 15967929ef | |||
| 3d13a06bd9 | |||
| 36a704e3d3 | |||
| c5c1b08ffd | |||
| 4d0d2204fd | |||
| 975c72eb49 | |||
| 5244386892 | |||
| e22393d577 | |||
| 8eb130959c | |||
| 1602656fb6 | |||
| 57f542fdad | |||
| d7980133e9 | |||
| 8a766799c7 | |||
| 4ca967e979 | |||
| d6653f8240 | |||
| 4c8041974a | |||
| d91ce0b4fc | |||
| 4a480f46fd | |||
| 40fc8c6a53 | |||
| d36132d93a | |||
| aab727b297 | |||
| 7272077b65 | |||
| 6081c552f6 | |||
| 85d5e1fe51 | |||
| 5d0c771a2b | |||
| 39a2cbc65b | |||
| fcdeab82e6 | |||
| 6f5d71763f | |||
| 644516769c | |||
| 52bec30c90 | |||
| 0ad6927d25 | |||
| d25b5921f7 | |||
| 29d2cc7315 | |||
| bc914ce3df | |||
| 5ec18ed520 | |||
| 70e6915246 | |||
| 7dc910e2de | |||
| 244af51edf | |||
| 2ed56b7973 | |||
| 84dda3b5bc | |||
| d0b7bfa56b | |||
| 455c6b81e6 | |||
| 3c924e1f83 | |||
| 87aa7e0c40 | |||
| 5e83ee7dac | |||
| 0d9aa7b470 | |||
| e4b8e9924c | |||
| 7635ad8d4d | |||
| b98a362de5 | |||
| 701727fd08 | |||
| 01f8b89636 | |||
| 2da0ada34a | |||
| 13abb15595 | |||
| 5a941f857c | |||
| 1ac0a144d5 | |||
| 356edb16be | |||
| 149226ff17 | |||
| bb606f52f5 | |||
| f56bdb7fbb | |||
| 3067896b0f | |||
| 146d3cedb2 | |||
| 765db8ae9f | |||
| dd63dbff9b | |||
| 27660f48e4 | |||
| e4fdbbc18a | |||
| 004ff9ad48 | |||
| 552f539bdf | |||
| 221aa4c4cc | |||
| 799ede5a0e | |||
| cb604b74ec | |||
| e91d51cc5e | |||
| 5a3f791ecd | |||
| 0b82aa875c | |||
| 465552f8b2 | |||
| 5fcd5212d5 | |||
| 53f28ac458 | |||
| 7fc4dcbddb | |||
| 96e13e40cb | |||
| 4e8c0ea5b9 | |||
| e4d6fbac50 | |||
| 78364afc51 | |||
| 5a9d4325d8 | |||
| 3035c6db5d | |||
| 28a4e9b1b8 | |||
| 3943075a9b | |||
| e2b3858b67 | |||
| bd6d108ade | |||
| d4c26deae2 | |||
| 619b056ada | |||
| 6507766ea2 | |||
| 64f29d614b | |||
| 3eabd45882 | |||
| d791d138f2 | |||
| bd7d8c77bf | |||
| 6f1a560d06 | |||
| 67caf09732 | |||
| 6cbc11efda | |||
| 615f9da2df | |||
| a2f2b7918a | |||
| 0c3f385b1f | |||
| fd2edd5736 | |||
| ecb0e9c7d0 | |||
| 4273576612 | |||
| 406b2d5524 | |||
| 4b4d37b332 | |||
| b19b1a8c46 | |||
| d20819b03b | |||
| b5e3adf5de | |||
| 4198a74002 | |||
| 21b9f500d9 | |||
| 6851cb4734 | |||
| 580c4b4017 | |||
| 9fbb4f9b48 | |||
| 074cdcdbed | |||
| 360cb991e1 | |||
| 14e886cc08 | |||
| 766a1d9a6d | |||
| e1e2da2140 | |||
| db8bb8fa95 | |||
| 70e849d3ae | |||
| 22f13eca4b | |||
| 30b252ac95 | |||
| f4de741d5b | |||
| c93b54efeb | |||
| 4ba248513e | |||
| 7e548f8b08 | |||
| bce9435823 | |||
| d0858f288a | |||
| 9e0a0227ea | |||
| d94b96d884 | |||
| 606f31f13c | |||
| 97180aa7cd | |||
| e949ac793d | |||
| 01dae66285 | |||
| 6ede2a443c | |||
| e214106d48 | |||
| 2cfcfdd1af | |||
| 0afc70fc5b | |||
| 721c343486 | |||
| c39805bb8e | |||
| 23c440104b | |||
| 2f2ccc94f7 | |||
| 3ad6f8740a | |||
| 17e4e15860 | |||
| 834b0d4865 |
@@ -0,0 +1 @@
|
||||
swiftbuild
|
||||
@@ -0,0 +1,4 @@
|
||||
Signature: 8a477f597d28d172789f06886806bc55
|
||||
# This file is a cache directory tag created by (Swift Package Manager).
|
||||
# For information about cache directory tags, see:
|
||||
#. http://www.brynosaurus.com/cachedir/
|
||||
@@ -0,0 +1,47 @@
|
||||
DATABASE_URL=postgres://accusys@localhost:5432/momentry
|
||||
DATABASE_SCHEMA=public
|
||||
MOMENTRY_DEMO_API_KEY='muser_demo_key_32chars_abcdef1234567890'
|
||||
REDIS_URL=redis://127.0.0.1:6379
|
||||
|
||||
# LLM Configuration
|
||||
# Agent Search uses Ollama (llama3.1:8b) - OpenAI-compatible endpoint
|
||||
MOMENTRY_LLM_CHAT_URL=http://localhost:8080/v1/chat/completions
|
||||
MOMENTRY_LLM_CHAT_MODEL=gemma-4-12b-it
|
||||
|
||||
# VLM uses Gemma4 12B (port 8080) - OpenAI-compatible endpoint
|
||||
# Gemma4 多模态已启用 (llama.cpp version 9590)
|
||||
MOMENTRY_LLM_VISION_URL=http://127.0.0.1:8080/v1/chat/completions
|
||||
MOMENTRY_LLM_VISION_MODEL=gemma-4-12b-it
|
||||
|
||||
# Summary LLM uses Ollama
|
||||
MOMENTRY_LLM_SUMMARY_URL=http://localhost:8080/v1/chat/completions
|
||||
MOMENTRY_LLM_SUMMARY_MODEL=gemma-4-12b-it
|
||||
MOMENTRY_LLM_SUMMARY_ENABLED=true
|
||||
|
||||
# Vector database
|
||||
QDRANT_URL=http://127.0.0.1:6333
|
||||
QDRANT_API_KEY=Test3200Test3200Test3200
|
||||
QDRANT_COLLECTION=momentry_rule1
|
||||
|
||||
# MongoDB
|
||||
MONGODB_URL=mongodb://localhost:27017
|
||||
MONGODB_DATABASE=momentry
|
||||
MONGODB_CACHE_ENABLED=true
|
||||
|
||||
# Embedding
|
||||
MOMENTRY_EMBED_URL=http://localhost:11436
|
||||
TMDB_API_KEY=e9cde52197f6f8df4d9db99da93db1fb
|
||||
MOMENTRY_TMDB_PROBE_ENABLED=false
|
||||
|
||||
# Video serve (Caddy file_server for local direct playback)
|
||||
MOMENTRY_STORAGE_ROOT=/Users/accusys/momentry/var/sftpgo/data
|
||||
MOMENTRY_SERVE_BASE_URL=https://m5wp.momentry.ddns.net/files
|
||||
MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11
|
||||
RUST_LOG=info
|
||||
|
||||
# Rust Processors (Enable Rust implementations where available)
|
||||
|
||||
# MOMENTRY_FORCE_RETRY removed - use default (false) so max_retry=3 kicks in
|
||||
MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output
|
||||
MOMENTRY_LLM_CHAT_TIMEOUT=300
|
||||
MOMENTRY_ASR_TIMEOUT=10800
|
||||
+12
-11
@@ -72,19 +72,20 @@ REDIS_CACHE_TTL_VIDEO_META=3600
|
||||
# TMDb Integration (probe phase - auto-create identities from movie metadata)
|
||||
TMDB_API_KEY=e9cde52197f6f8df4d9db99da93db1fb
|
||||
MOMENTRY_TMDB_PROBE_ENABLED=true
|
||||
# LLM for 5W1H summary (points to M5 Gemma4)
|
||||
MOMENTRY_LLM_SUMMARY_URL=http://127.0.0.1:8082/v1/chat/completions
|
||||
MOMENTRY_LLM_SUMMARY_MODEL=google_gemma-4-26B-A4B-it-Q5_K_M.gguf
|
||||
# LLM Configuration
|
||||
# Agent Search uses Ollama (llama3.1:8b) - OpenAI-compatible endpoint
|
||||
MOMENTRY_LLM_CHAT_URL=http://localhost:11434/v1/chat/completions
|
||||
MOMENTRY_LLM_CHAT_MODEL=llama3.1:8b
|
||||
|
||||
# VLM uses Ollama (llava:7b) - OpenAI-compatible endpoint
|
||||
MOMENTRY_LLM_VISION_URL=http://localhost:11434/v1/chat/completions
|
||||
MOMENTRY_LLM_VISION_MODEL=llava:7b
|
||||
|
||||
# Summary LLM uses Ollama
|
||||
MOMENTRY_LLM_SUMMARY_URL=http://localhost:11434/v1/chat/completions
|
||||
MOMENTRY_LLM_SUMMARY_MODEL=llama3.1:8b
|
||||
MOMENTRY_LLM_SUMMARY_ENABLED=true
|
||||
|
||||
# LLM Chat (A4B on port 8082)
|
||||
MOMENTRY_LLM_CHAT_URL=http://127.0.0.1:8082/v1/chat/completions
|
||||
MOMENTRY_LLM_CHAT_MODEL=google_gemma-4-26B-A4B-it-Q5_K_M.gguf
|
||||
|
||||
# LLM Vision (E4B on port 8083)
|
||||
MOMENTRY_LLM_VISION_URL=http://127.0.0.1:8083/v1/chat/completions
|
||||
MOMENTRY_LLM_VISION_MODEL=gemma-4-E4B-it-Q4_K_M.gguf
|
||||
|
||||
# Embedding (ANE CoreML server)
|
||||
MOMENTRY_EMBED_URL=http://localhost:11436
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
# Docserver Configuration
|
||||
DOCSERVER_PORT=8000
|
||||
DOCSERVER_USER=admin
|
||||
DOCSERVER_PASSWORD=admin123
|
||||
MOMENTRY_DOCS_DIR=/Users/accusys/momentry_core/docs_v1.0/doc_wasm
|
||||
+24
-4
@@ -43,10 +43,19 @@ MOMENTRY_LLM_VISION_MODEL=gemma-4-E4B-it-Q4_K_M.gguf
|
||||
MOMENTRY_LLM_VISION_TIMEOUT=120
|
||||
|
||||
# === Paths ===
|
||||
MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output_dev
|
||||
MOMENTRY_BACKUP_DIR=/Users/accusys/momentry/backup
|
||||
MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core_0.1/scripts
|
||||
MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11
|
||||
# These paths will be auto-detected if not set
|
||||
# Default: $HOME/momentry/output_dev
|
||||
# MOMENTRY_OUTPUT_DIR=/path/to/output
|
||||
|
||||
# Default: $HOME/momentry/backup
|
||||
# MOMENTRY_BACKUP_DIR=/path/to/backup
|
||||
|
||||
# Default: $PROJECT_ROOT/tools/script
|
||||
# MOMENTRY_SCRIPTS_DIR=/path/to/scripts
|
||||
|
||||
# Default: /opt/homebrew/bin/python3.11
|
||||
# MOMENTRY_PYTHON_PATH=/path/to/python
|
||||
|
||||
MOMENTRY_FFMPEG=/opt/homebrew/opt/ffmpeg-full/bin/ffmpeg
|
||||
MOMENTRY_MEDIA_BASE_URL=
|
||||
|
||||
@@ -61,3 +70,14 @@ MOMENTRY_DEFAULT_TIMEOUT=7200
|
||||
# === Server ===
|
||||
MOMENTRY_SERVER_PORT=3003
|
||||
MOMENTRY_LOG_LEVEL=info
|
||||
|
||||
# === Package Paths (init resolves @ROOT@ to install root) ===
|
||||
MOMENTRY_ENV_FILE=@ROOT@/config/.env
|
||||
MOMENTRY_SFTP_ROOT=@ROOT@/var/sftpgo/data/demo
|
||||
MOMENTRY_STORAGE_ROOT=@ROOT@/var/sftpgo/data
|
||||
MOMENTRY_OUTPUT_DIR=@ROOT@/var/output
|
||||
MOMENTRY_DATA_DIR=@ROOT@/data
|
||||
MOMENTRY_PROCESSORS_DIR=@ROOT@/processors
|
||||
|
||||
# === Init ===
|
||||
MOMENTRY_API_KEY=
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
---
|
||||
name: Cross-Project Bug
|
||||
about: 跨專案 Bug 會診
|
||||
title: ''
|
||||
labels: type:bug, cross-project
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## Bug 描述
|
||||
|
||||
## 影響專案
|
||||
- [ ] markbase
|
||||
- [ ] MarkBaseEngine
|
||||
- [ ] momentry_core
|
||||
- [ ] momentry_studio
|
||||
|
||||
## 重現步驟
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
|
||||
## 預期行為
|
||||
|
||||
## 實際行為
|
||||
|
||||
## 影響分析
|
||||
| 層級 | 影響 | 緊急度 |
|
||||
|------|------|--------|
|
||||
| 使用者 | | 🔴/🟡/🟢 |
|
||||
| 資料 | | 🔴/🟡/🟢 |
|
||||
| 服務 | | 🔴/🟡/🟢 |
|
||||
|
||||
## 會診團隊
|
||||
| 專案 | 負責人 | 狀態 |
|
||||
|------|--------|------|
|
||||
| markbase | @ | |
|
||||
| MarkBaseEngine | @ | |
|
||||
| momentry_core | @ | |
|
||||
| momentry_studio | @ | |
|
||||
|
||||
## 修復方案
|
||||
|
||||
## 驗證結果
|
||||
- [ ] Sandbox 測試通過
|
||||
- [ ] CI/CD 通過
|
||||
- [ ] 手動測試通過
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Feature Request
|
||||
about: 新功能需求
|
||||
title: ''
|
||||
labels: type:feature
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## 功能描述
|
||||
|
||||
## 使用場景
|
||||
|
||||
## 驗收標準
|
||||
- [ ] 標準 1
|
||||
- [ ] 標準 2
|
||||
|
||||
## 技術方案 (可選)
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: Requirement
|
||||
about: 跨專案需求
|
||||
title: ''
|
||||
labels: type:requirement
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
## 需求名稱
|
||||
|
||||
## 影響專案
|
||||
- [ ] markbase
|
||||
- [ ] MarkBaseEngine
|
||||
- [ ] momentry_core
|
||||
- [ ] momentry_studio
|
||||
|
||||
## 需求描述
|
||||
|
||||
## API 變更 (如適用)
|
||||
|
||||
## 資料庫變更 (如適用)
|
||||
|
||||
## 驗收標準
|
||||
- [ ] 標準 1
|
||||
- [ ] 標準 2
|
||||
|
||||
## 依賴 Issue
|
||||
- Blocks #
|
||||
- Related to #
|
||||
@@ -0,0 +1,20 @@
|
||||
name: Core Test
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
paths: ['src/**', 'Cargo.toml']
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- name: Cargo fmt
|
||||
run: cargo fmt -- --check
|
||||
- name: Cargo clippy
|
||||
run: cargo clippy -- -D warnings
|
||||
- name: Cargo test
|
||||
run: cargo test --lib
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Cross-Project Integration
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
integration:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Sandbox
|
||||
run: ./scripts/setup_sandbox.sh
|
||||
- name: Build All
|
||||
run: ./scripts/build_all.sh
|
||||
- name: Start Services
|
||||
run: ./scripts/start_services.sh
|
||||
- name: Run Integration Tests
|
||||
run: ./scripts/run_integration_tests.sh
|
||||
- name: Cleanup
|
||||
if: always()
|
||||
run: ./scripts/cleanup_sandbox.sh
|
||||
@@ -0,0 +1,22 @@
|
||||
name: Release
|
||||
on:
|
||||
push:
|
||||
tags: ['v*']
|
||||
|
||||
jobs:
|
||||
build-and-release:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build Release
|
||||
run: cargo build --release
|
||||
- name: Run Full Tests
|
||||
run: cargo test
|
||||
- name: Create Release
|
||||
run: |
|
||||
cp target/release/momentry ./momentry-${{ github.ref_name }}
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: momentry-${{ github.ref_name }}
|
||||
path: momentry-${{ github.ref_name }}
|
||||
@@ -47,3 +47,5 @@ package.json
|
||||
portal/dist/
|
||||
portal/src-tauri/icons/
|
||||
momentry_runtime/logs/
|
||||
*.bak
|
||||
*.bak_*
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE vlm_requests\n SET \n status = 'completed',\n result = $1,\n processing_time_ms = $2,\n completed_at = NOW()\n WHERE id = $3\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Int8",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "0373b02cc8de069f6e964bc023c4e29497cb66f8b0a181bafa73f175454e6903"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO command_queue (\n message_id, queue_name, queue_type,\n command_type, command_category,\n key, value, priority,\n request_id, key_id, billing_context,\n scheduled_at, max_retries,\n created_at\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Jsonb",
|
||||
"Int2",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Jsonb",
|
||||
"Timestamptz",
|
||||
"Int4",
|
||||
"Timestamptz"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "08adb7aafb3214ab7740baabcb6db8901c80dc5357008cd984f50d497fd416a2"
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT status, result, error\n FROM vlm_requests\n WHERE id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "status",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "result",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "error",
|
||||
"type_info": "Text"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "1083cb140d49eed76e1f5081b88cbdca34f59052571490635dc8b1fdca3b1bd3"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE dev.videos SET processing_status = $1 WHERE uuid = $2",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Jsonb",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "2d61eacd106ad5144c99a85c84f070924af9b29103a507e115674d1b14b77181"
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE dev.jobs SET status = 'COMPLETED', processed_frames = total_frames, updated_at = NOW() WHERE id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "345d912734b063a7b30d52c066045553964d0a55453a7e26a4d8b8d758be3857"
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT command_type, command_category, queue_name, handler, priority, billing_required\n FROM queue_routes\n WHERE active = true\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "command_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "command_category",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "queue_name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "handler",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "priority",
|
||||
"type_info": "Int2"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "billing_required",
|
||||
"type_info": "Bool"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": []
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "392a5b8ec9b3f9cf1736d47eeecaa1fe87ffa62024146c3d2c37bf028d954b3f"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE vlm_consumer_offsets\n SET current_offset = $1, last_poll_at = NOW()\n WHERE consumer_id = $2\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "3d7027dffb815b8a40e5525c9065bdd3173ff567cf8b7b299ad56f5b4cfb49de"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE command_queue\n SET status = $2,\n processing_completed_at = $3,\n token_usage = $4,\n cost_usd = $5\n WHERE message_id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Varchar",
|
||||
"Timestamptz",
|
||||
"Jsonb",
|
||||
"Float8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "4580e475bf8395911bbf9b36660094cf4483a4d4dcbe3dc7b5437904aeb86780"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO vlm_requests (request_type, priority, payload, status)\n VALUES ($1, $2, $3, 'pending')\n RETURNING id\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Int4",
|
||||
"Jsonb"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "5bc08af47af66dc518afee2939f2fb33ea3384c63226fc474043346225923fcc"
|
||||
}
|
||||
+164
@@ -0,0 +1,164 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE command_queue\n SET status = 'processing',\n consumer_group = $1,\n consumer_id = $2,\n processing_started_at = NOW(),\n timeout_at = NOW() + ($5::bigint * INTERVAL '1 second')\n WHERE message_id IN (\n SELECT message_id\n FROM command_queue\n WHERE queue_name = $3\n AND status = 'pending'\n AND (scheduled_at IS NULL OR scheduled_at <= NOW())\n ORDER BY priority ASC, created_at ASC\n LIMIT $4\n FOR UPDATE SKIP LOCKED\n )\n RETURNING\n message_id, queue_name, queue_type,\n command_type, command_category, command_action,\n key, value, priority,\n request_id, key_id, billing_context, token_usage, cost_usd,\n status, consumer_group, consumer_id,\n retry_count, max_retries, last_error,\n created_at, scheduled_at, processing_started_at, processing_completed_at\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "message_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "queue_name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "queue_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "command_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "command_category",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "command_action",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "key",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "value",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "priority",
|
||||
"type_info": "Int2"
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"name": "request_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"name": "key_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"name": "billing_context",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 12,
|
||||
"name": "token_usage",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 13,
|
||||
"name": "cost_usd",
|
||||
"type_info": "Float8"
|
||||
},
|
||||
{
|
||||
"ordinal": 14,
|
||||
"name": "status",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 15,
|
||||
"name": "consumer_group",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 16,
|
||||
"name": "consumer_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 17,
|
||||
"name": "retry_count",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 18,
|
||||
"name": "max_retries",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 19,
|
||||
"name": "last_error",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 20,
|
||||
"name": "created_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 21,
|
||||
"name": "scheduled_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 22,
|
||||
"name": "processing_started_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 23,
|
||||
"name": "processing_completed_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Text",
|
||||
"Int8",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "5f27ef47fc166a0bb8f8a26ccbd7418710e3bbb280af10935ffb2eddffcd33e4"
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "UPDATE dev.jobs SET status = 'FAILED', error_message = $2, updated_at = NOW() WHERE id = $1",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Uuid",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "60cc008705cfea3a4532b9496db8f6ed0e3023436660bdf8ee81fe78fe270971"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE vlm_requests\n SET status = 'processing', started_at = NOW()\n WHERE id = ANY($1)\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8Array"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "66ef83b7ad3fe95922fb2aa9a083ed55b14c5b4d7dd6b9ada1659d6060780533"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO vlm_requests (request_type, priority, payload, status)\n VALUES ($1, $2, $3, 'pending')\n RETURNING id\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int8"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Int4",
|
||||
"Jsonb"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "748de226872459680cdd121b4b27369b73ae2edfeb9c75c03f1b8e240cb55f0c"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO command_execution_log (\n message_id, handler, action, status,\n result, error_message,\n duration_ms, tokens_used, cost_usd,\n executed_at\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Varchar",
|
||||
"Jsonb",
|
||||
"Text",
|
||||
"Int4",
|
||||
"Int4",
|
||||
"Float8",
|
||||
"Timestamptz"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "7b3d7e7af47f2f91193229925454e22e1ef1a8fec81174092b926880ca36a118"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE vlm_requests\n SET status = 'failed', error = $1, completed_at = NOW()\n WHERE id = $2\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "7d4e34cc4505455b678b45b2f884021a6cf786e0e86d8f15f1b324e6a8bcfac9"
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE command_queue\n SET status = 'failed',\n processing_completed_at = $3,\n last_error = $2,\n retry_count = retry_count + 1\n WHERE message_id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Text",
|
||||
"Timestamptz"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "89d0f71757cf23b1a02923e97ed0c1921cafbdd69844e43c41c00222d5595f18"
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE vlm_consumer_offsets\n SET \n total_processed = total_processed + $1,\n total_succeeded = total_succeeded + $2,\n total_failed = total_failed + $3\n WHERE consumer_id = $4\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Int8",
|
||||
"Int8",
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "8fb9ba962eb0fc70bca83f7523afe081285a79aacaf5821d2e41f7539c57ced6"
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n INSERT INTO vlm_dlq (original_id, original_request_type, original_priority, original_payload, error, retry_count)\n VALUES ($1, $2, $3, $4, $5, $6)\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8",
|
||||
"Varchar",
|
||||
"Int4",
|
||||
"Jsonb",
|
||||
"Text",
|
||||
"Int4"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "961e59ccb11c4e1674573d1e55e61dea1aa9eb9c78e506ba42aa1a42b891bf27"
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT\n message_id, queue_name, queue_type,\n command_type, command_category, command_action,\n key, value, priority,\n request_id, key_id, billing_context, token_usage, cost_usd,\n status, consumer_group, consumer_id,\n retry_count, max_retries, last_error,\n created_at, scheduled_at, processing_started_at, processing_completed_at\n FROM command_queue\n WHERE message_id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "message_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "queue_name",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "queue_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "command_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "command_category",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 5,
|
||||
"name": "command_action",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 6,
|
||||
"name": "key",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 7,
|
||||
"name": "value",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 8,
|
||||
"name": "priority",
|
||||
"type_info": "Int2"
|
||||
},
|
||||
{
|
||||
"ordinal": 9,
|
||||
"name": "request_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 10,
|
||||
"name": "key_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 11,
|
||||
"name": "billing_context",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 12,
|
||||
"name": "token_usage",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 13,
|
||||
"name": "cost_usd",
|
||||
"type_info": "Float8"
|
||||
},
|
||||
{
|
||||
"ordinal": 14,
|
||||
"name": "status",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 15,
|
||||
"name": "consumer_group",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 16,
|
||||
"name": "consumer_id",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 17,
|
||||
"name": "retry_count",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 18,
|
||||
"name": "max_retries",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 19,
|
||||
"name": "last_error",
|
||||
"type_info": "Text"
|
||||
},
|
||||
{
|
||||
"ordinal": 20,
|
||||
"name": "created_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 21,
|
||||
"name": "scheduled_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 22,
|
||||
"name": "processing_started_at",
|
||||
"type_info": "Timestamptz"
|
||||
},
|
||||
{
|
||||
"ordinal": 23,
|
||||
"name": "processing_completed_at",
|
||||
"type_info": "Timestamptz"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
false,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "a09f617a37776df57c4e711b25e62075db983095764bb5f2bae1e3dfddc3b243"
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT \n id as offset,\n request_type,\n priority,\n payload\n FROM vlm_requests\n WHERE status = 'pending'\n ORDER BY priority ASC, created_at ASC\n LIMIT $1\n FOR UPDATE SKIP LOCKED\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "offset",
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "request_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "priority",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "payload",
|
||||
"type_info": "Jsonb"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
false
|
||||
]
|
||||
},
|
||||
"hash": "ab09a5b7e35daf5fa5085ce9a986c9d58de60f4b9ffc0a127a7d17694d42277a"
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n SELECT id, request_type, payload, retry_count, priority\n FROM vlm_requests\n WHERE id = $1\n ",
|
||||
"describe": {
|
||||
"columns": [
|
||||
{
|
||||
"ordinal": 0,
|
||||
"name": "id",
|
||||
"type_info": "Int8"
|
||||
},
|
||||
{
|
||||
"ordinal": 1,
|
||||
"name": "request_type",
|
||||
"type_info": "Varchar"
|
||||
},
|
||||
{
|
||||
"ordinal": 2,
|
||||
"name": "payload",
|
||||
"type_info": "Jsonb"
|
||||
},
|
||||
{
|
||||
"ordinal": 3,
|
||||
"name": "retry_count",
|
||||
"type_info": "Int4"
|
||||
},
|
||||
{
|
||||
"ordinal": 4,
|
||||
"name": "priority",
|
||||
"type_info": "Int4"
|
||||
}
|
||||
],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": [
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
true
|
||||
]
|
||||
},
|
||||
"hash": "ec65769979d98dae69f4bb8ef280bb55ec401b86eaa01e80e63833654125733d"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"db_name": "PostgreSQL",
|
||||
"query": "\n UPDATE vlm_requests\n SET \n status = 'pending',\n retry_count = retry_count + 1,\n error = $1\n WHERE id = $2\n ",
|
||||
"describe": {
|
||||
"columns": [],
|
||||
"parameters": {
|
||||
"Left": [
|
||||
"Text",
|
||||
"Int8"
|
||||
]
|
||||
},
|
||||
"nullable": []
|
||||
},
|
||||
"hash": "fff0adae6b82b647111a1d27ac7c0a9e15311a8bacd4c1a5b7229e511df45954"
|
||||
}
|
||||
@@ -14,34 +14,46 @@ Rust-based digital asset management system with video analysis and RAG capabilit
|
||||
- **🔴 DELETE / REMOVE / DROP / CLEAR 任何資料前必須先問使用者「要刪嗎?」獲得明確同意後才能執行**
|
||||
- **🔴 Qdrant collection 刪除、DB truncate、檔案刪除、資料清空 — 一律要先問**
|
||||
- **🔴 不確定是否該刪 → 先問,不要自己決定**
|
||||
- **🔴 任何會移除資料的動作(unregister、DELETE、DROP、truncate、rm 檔案)都必須先詢問確認,絕對不可自行執行**
|
||||
- **🔴 改變議題前必須先存檔紀錄**:使用 `todowrite` 工具或建立紀錄文件(如 `docs_v1.0/M4_workspace/YYYY-MM-DD_topic_handoff.md`),確保上下文不丟失
|
||||
|
||||
### 開發範圍界定
|
||||
| 範圍 | 狀態 | 說明 |
|
||||
|------|------|------|
|
||||
| `momentry_core_0.1/` | ✅ **可開發** | Momentry Core 主要開發目錄 |
|
||||
| `momentry_core_0.1/portal/` | ✅ **可開發** | Tauri Portal 前端 |
|
||||
| `momentry_core_0.1/src/` | ✅ **可開發** | Rust 後端程式碼 |
|
||||
| `/Users/accusys/wordpress/` | ❌ **禁止修改** | WordPress/Marcom 團隊負責 |
|
||||
| `~/momentry_core/` | ✅ **可開發** | Momentry Core 後端(Rust),Core team 負責 |
|
||||
| `~/momentry_core/portal/` | ⚠️ **僅供測試** | Tauri Portal 僅用於測試,非正式前端 |
|
||||
| `~/momentry_studio/` | ❌ **禁止修改** | Momentry Studio 前端,**Studio team 負責** |
|
||||
| `/Users/accusys/wordpress/` | ❌ **禁止修改** | WordPress 網站僅供參考,已被 Studio 取代 |
|
||||
| n8n 工作流 | ❌ **禁止修改** | 自動化流程,與 dev 無關 |
|
||||
| WordPress/n8n 資料庫 table | ❌ **禁止修改** | Marcom 團隊管理,與 dev 無關 |
|
||||
|
||||
### 團隊職責劃分
|
||||
| 團隊 | 負責專案 | 目錄 |
|
||||
|------|---------|------|
|
||||
| **Core team** | Momentry Core 後端 | `~/momentry_core/` |
|
||||
| **Studio team** | Momentry Studio 前端 | `~/momentry_studio/` |
|
||||
| **Marcom team** | WordPress 網站(已停用) | `/Users/accusys/wordpress/` |
|
||||
|
||||
### 開發環境
|
||||
| 服務 | Port | 用途 | 命令 |
|
||||
|------|------|------|------|
|
||||
| Playground | 3003 | **唯一開發環境** | `cargo run --bin momentry_playground -- server` |
|
||||
| Production | 3002 | ❌ 禁止修改 | `cargo run -- server` (僅 release 時) |
|
||||
| Portal (Tauri) | 1420 | 前端開發 | `npm run tauri dev` |
|
||||
| 服務 | Port | 用途 | 命令 | 狀態 |
|
||||
|------|------|------|------|------|
|
||||
| Playground | 3003 | ~~開發環境~~ (暫停) | `cargo run --bin momentry_playground -- server` | 🔴 已暫停 (節省 memory) |
|
||||
| Production | 3002 | **開發 + 生產環境** | `cargo run -- server` | 🟢 運行中 (debug binary) |
|
||||
| Portal (Tauri) | 1420 | 前端開發 | `npm run tauri dev` | - |
|
||||
|
||||
> **注意 (2026-07-25)**: Playground (3003) 已暫停服務。Production (3002) 改為直接用於開發測試。新功能可直接部署至 3002。
|
||||
> **注意 (2026-07-23)**: 為節省記憶體,Playground (3003) 已關閉。Production (3002) 目前使用 debug binary 運行(已套用 smart_search 修復)。正式 release 時需重新 build release binary。
|
||||
|
||||
### 日誌與啟動
|
||||
| 服務 | 日誌路徑 | 啟動方式 |
|
||||
|------|----------|----------|
|
||||
| Production (3002) | `logs/momentry_3002.log` | `./run-server-3002.sh` |
|
||||
| Production (3002) | `logs/momentry_3002.log` | **launchd** (`com.momentry.server` + `com.momentry.worker`) |
|
||||
| Playground (3003) | `logs/momentry_3003.log` | `./run-server-3003.sh` |
|
||||
| Worker / 歷史 | `logs/nohup_worker_*.log` | 由 worker 自動產生 |
|
||||
| Worker / 歷史 | `logs/worker_3002.log` | 由 launchd worker 寫入 |
|
||||
|
||||
> **注意**: 所有伺服器日誌統一存放於專案內 `logs/` 目錄。
|
||||
> 啟動腳本會自動 kill 舊程序、重 build(若需要)、並將日誌導向 `logs/`。
|
||||
> **Production (3002) 正式部署由 launchd 管理**(`~/Library/LaunchAgents/com.momentry.server.plist` + `com.momentry.worker.plist`),兩者皆使用 `target/release/momentry`,KeepAlive 自動重啟。`run-server-3002.sh` 僅供開發時臨時手動啟動(會與 launchd 衝突,勿與 launchd 並用)。
|
||||
> **⚠️ 啟動 launchd worker 若未註冊**:`launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.momentry.worker.plist`(不是 `load`),worker plist 的 VLM 指向 gemma 8080(8091 已停用)。
|
||||
|
||||
## ⚠️ 交叉污染防制 (Cross-Contamination Prevention)
|
||||
|
||||
@@ -204,8 +216,11 @@ cargo run -- server --host 0.0.0.0 --port 3002
|
||||
cargo run --bin momentry_playground -- server
|
||||
cargo run --bin momentry_playground -- --help
|
||||
|
||||
# Start servers (recommended — auto-build & logs to logs/)
|
||||
./run-server-3002.sh
|
||||
# Start servers (recommended — production via launchd, dev via scripts)
|
||||
# Production (3002) is managed by launchd: com.momentry.server + com.momentry.worker
|
||||
# launchctl start gui/$(id -u)/com.momentry.server
|
||||
# launchctl start gui/$(id -u)/com.momentry.worker
|
||||
# (run-server-3002.sh is dev-only and conflicts with launchd — do NOT mix)
|
||||
./run-server-3003.sh
|
||||
```
|
||||
|
||||
@@ -234,6 +249,156 @@ grep -i "error\|panic\|FAIL" logs/momentry_*.log | tail -20
|
||||
| `momentry_playground` | Development | 3003 | `momentry_dev:` | `.env.development` |
|
||||
| `momentry_player` | Video player | - | - | - |
|
||||
|
||||
## LLM Services
|
||||
|
||||
### 環境一致性原則
|
||||
|
||||
**生產環境 (port 3002) 與 Playground (port 3003) 使用相同的 LLM/VLM/Embedding 服務。**
|
||||
|
||||
### LLM Configuration
|
||||
|
||||
| 用途 | Model | 服務 | Port | API 格式 |
|
||||
|------|-------|------|------|----------|
|
||||
| **Chat / Summary / VLM** | `gemma-4-12b-it` | llama.cpp | 8080 | `/v1/chat/completions` |
|
||||
| **Embedding** | `embeddinggemma-300m` | Python | 11436 | Custom |
|
||||
|
||||
> **統一服務**:Gemma4 + mmproj 同時支援文字與視覺輸入,簡化配置並節省記憶體。
|
||||
|
||||
### ⚠️ 重要:Gemma4 多模態配置
|
||||
|
||||
**Gemma 4-12b 是多模態模型**,支援視覺輸入,需要正確配置:
|
||||
|
||||
1. **mmproj 檔案**:
|
||||
- 檔案:`/Users/accusys/models/mmproj-F16.gguf` (167MB)
|
||||
- 從 HuggingFace 下載:`https://huggingface.co/unsloth/gemma-4-12b-it-GGUF`
|
||||
- **必須載入才能處理圖片輸入**
|
||||
|
||||
2. **llama.cpp 版本要求**:
|
||||
- ✅ 需要最新版本(支援 `gemma4uv` projector type)
|
||||
- ❌ 2026年5月之前的版本不相容
|
||||
- 若遇到 "unknown projector type: gemma4uv" 錯誤 → 需更新 llama.cpp
|
||||
|
||||
3. **當前配置狀態**(M5Max128,2026-09-25 更新):
|
||||
- Chat Server (Port 8080):**已載入 mmproj** ✅
|
||||
- 統一服務:Gemma4 同時處理 Chat/Summary/VLM ✅
|
||||
- 舊 VLM Server (Port 8091):已停用(Llava 改為備用)
|
||||
|
||||
4. **思考模式特性**:
|
||||
- Gemma4 使用思考模式,會先推理再輸出最終答案
|
||||
- 文字 Chat:`max_tokens=300` 即可
|
||||
- 多模態 VLM:需要 `max_tokens=800-900` 才能完成思考
|
||||
- 若回應為空 → 增加 max_tokens
|
||||
|
||||
### LLM 模型切換系統
|
||||
|
||||
**文檔位置**:`/Users/accusys/momentry_core/docs_v1.0/OPERATIONS/LLM_SERVICES/`
|
||||
|
||||
**快速切換命令**:
|
||||
```bash
|
||||
# 安裝切換腳本
|
||||
cd ~/llm-deploy-doc
|
||||
mkdir -p ~/llm-config ~/bin
|
||||
cp models.json ~/llm-config/
|
||||
cp scripts/llm-* ~/bin/
|
||||
chmod +x ~/bin/llm-*
|
||||
|
||||
# 切換模型
|
||||
llm-7b # 快速模型(Llava 7B)
|
||||
llm-12b # 質量模型(Gemma 4 12B + mmproj)
|
||||
llm-13b # 多模態模型(Llava 13B)
|
||||
|
||||
# 查看狀態
|
||||
llms
|
||||
```
|
||||
|
||||
**部署到新機器**:
|
||||
```bash
|
||||
# 一鍵部署到 M5Max48
|
||||
cd ~/llm-deploy-doc/scripts
|
||||
./deploy-m5max48.sh user m5max48
|
||||
```
|
||||
|
||||
**詳細文檔**:
|
||||
- `README.md`:系統概述與快速開始
|
||||
- `INSTALL.md`:詳細安裝步驟
|
||||
- `USAGE.md`:使用手冊與故障排除
|
||||
- `README_M5Max48.md`:M5Max48 部署指南
|
||||
- `M5Max48_DEPLOY_CHECKLIST.md`:部署檢查清單
|
||||
|
||||
### Model 檔案位置
|
||||
|
||||
```
|
||||
/Users/accusys/models/
|
||||
├── gemma-4-12b-it-Q4_K_M.gguf (Chat/Summary LLM - 6.6GB)
|
||||
├── llava-v1.6-vicuna-13b.Q4_K_M.gguf (VLM model)
|
||||
├── mmproj-model-f16.gguf (VLM mmproj)
|
||||
└── embeddinggemma-300M-Q8_0.gguf (Embedding model)
|
||||
```
|
||||
|
||||
### 啟動命令
|
||||
|
||||
**統一 Chat/VLM Server (gemma-4-12b-it + mmproj)** - via launchd
|
||||
```bash
|
||||
# Service managed by launchd
|
||||
launchctl load ~/Library/LaunchAgents/com.momentry.chat-llamacpp.plist
|
||||
launchctl unload ~/Library/LaunchAgents/com.momentry.chat-llamacpp.plist
|
||||
|
||||
# Manual start (for testing)
|
||||
/Users/accusys/llama.cpp/build/bin/llama-server \
|
||||
-m /Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf \
|
||||
--mmproj /Users/accusys/models/mmproj-F16.gguf \
|
||||
--host 0.0.0.0 \
|
||||
--port 8080 \
|
||||
-ngl 99 \
|
||||
-c 8192 \
|
||||
--temp 0.1 \
|
||||
-b 4096 \
|
||||
-ub 4096
|
||||
|
||||
# API endpoint (supports both text and vision)
|
||||
curl http://localhost:8080/v1/chat/completions
|
||||
```
|
||||
|
||||
**備用 VLM Server (llava-v1.6-vicuna-13b)** - 已停用
|
||||
```bash
|
||||
# 舊配置(已禁用)
|
||||
# /Users/accusys/llama/bin/llama-server \
|
||||
# -m /Users/accusys/models/llava-v1.6-vicuna-13b.Q4_K_M.gguf \
|
||||
# --mmproj /Users/accusys/models/mmproj-model-f16.gguf \
|
||||
# --host 0.0.0.0 \
|
||||
# --port 8091 \
|
||||
# -ngl 99 \
|
||||
# -c 4096
|
||||
```
|
||||
|
||||
**Embedding (embeddinggemma-300m)**
|
||||
```bash
|
||||
python3 scripts/embeddinggemma_server.py --port 11436
|
||||
```
|
||||
|
||||
### VLM 用途
|
||||
|
||||
- **Face trace VLM**: 描述人物外貌(衣著、顏色、配件)
|
||||
- **Scene VLM**: 場景分析
|
||||
- **Agent `analyze_frame`**: 畫面分析工具
|
||||
|
||||
### Agent Search 語言
|
||||
|
||||
- **預設使用英文回答**(除非用戶明確要求其他語言)
|
||||
- System prompt 已明確規範 LLM 必須使用英文回應
|
||||
|
||||
### 環境變數
|
||||
|
||||
```bash
|
||||
# .env
|
||||
MOMENTRY_LLM_CHAT_URL=http://localhost:8080/v1/chat/completions
|
||||
MOMENTRY_LLM_CHAT_MODEL=gemma-4-12b-it
|
||||
MOMENTRY_LLM_VISION_URL=http://localhost:8080/v1/chat/completions
|
||||
MOMENTRY_LLM_VISION_MODEL=gemma-4-12b-it
|
||||
MOMENTRY_LLM_SUMMARY_URL=http://localhost:8080/v1/chat/completions
|
||||
MOMENTRY_LLM_SUMMARY_MODEL=gemma-4-12b-it
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
@@ -272,6 +437,8 @@ cargo check --all-features
|
||||
- Use Rust 2021 edition
|
||||
- Use tracing for logging (not println!)
|
||||
- Keep lines under 100 characters
|
||||
- **Always provide absolute paths when referencing files** — use full paths like `/Users/accusys/momentry_core/src/main.rs` instead of relative paths like `src/main.rs`
|
||||
- **All document references MUST include full paths** — when listing files to modify, API endpoints, or cross-references in docs, always use absolute paths (e.g., `/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/19_people_api.md`)
|
||||
|
||||
### Imports (order: std → external → local)
|
||||
```rust
|
||||
@@ -368,6 +535,186 @@ src/
|
||||
└── watcher/ # File system watcher
|
||||
```
|
||||
|
||||
## Tools Architecture
|
||||
|
||||
### Directory Structure
|
||||
|
||||
```
|
||||
tools/
|
||||
├── cli/ # Compiled CLI binaries
|
||||
│ ├── rust/ # Rust CLI tools
|
||||
│ │ ├── src/
|
||||
│ │ │ └── bin/ # Binary source files
|
||||
│ │ │ ├── rust_appearance.rs
|
||||
│ │ │ ├── rust_face_cluster.rs
|
||||
│ │ │ ├── rust_pose.rs
|
||||
│ │ │ └── rust_vad.rs
|
||||
│ │ ├── Cargo.toml
|
||||
│ │ └── target/ # Build output
|
||||
│ │ └── release/ # Release binaries
|
||||
│ └── swift/ # Swift CLI tools
|
||||
│ ├── Sources/
|
||||
│ ├── Package.swift
|
||||
│ └── .build/ # Build output
|
||||
│ └── release/
|
||||
└── script/ # Python scripts (organized by processor)
|
||||
├── asr/ # ASR scripts
|
||||
├── chunk/ # Chunking scripts
|
||||
├── cut/ # Cut detection scripts
|
||||
├── embedding/ # Embedding scripts
|
||||
├── face/ # Face processing scripts
|
||||
├── identity/ # Identity management scripts
|
||||
├── ocr/ # OCR scripts
|
||||
├── pose/ # Pose estimation scripts
|
||||
├── scene/ # Scene detection scripts
|
||||
├── utils/ # Utility scripts
|
||||
├── vlm/ # Vision Language Model scripts
|
||||
├── worker/ # Worker scripts
|
||||
└── yolo/ # YOLO detection scripts
|
||||
```
|
||||
|
||||
### Tool Categories
|
||||
|
||||
#### Rust CLI Tools (tools/cli/rust/)
|
||||
|
||||
| Binary | Purpose | Status |
|
||||
|--------|---------|--------|
|
||||
| `rust_appearance` | Face appearance analysis | ✅ Working |
|
||||
| `rust_face_cluster` | Face clustering | ✅ Working |
|
||||
| `rust_pose` | Pose interpolation | ✅ Working |
|
||||
| `rust_vad` | Voice Activity Detection | ✅ Working |
|
||||
|
||||
**Build**:
|
||||
```bash
|
||||
cd tools/cli/rust
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
**Usage**:
|
||||
```bash
|
||||
# Worker automatically finds binaries in tools/cli/rust/target/release/
|
||||
# Set MOMENTRY_USE_RUST_PROCESSORS=true to enable
|
||||
```
|
||||
|
||||
#### Swift CLI Tools (tools/cli/swift/)
|
||||
|
||||
| Binary | Purpose | Status |
|
||||
|--------|---------|--------|
|
||||
| `swift_pose` | Apple Vision Pose | ✅ Working |
|
||||
| `swift_face` | Apple Vision Face | ✅ Working |
|
||||
| `swift_scene` | Scene detection | ✅ Working |
|
||||
| `swift_yolo` | YOLO detection | ✅ Working |
|
||||
|
||||
**Build**:
|
||||
```bash
|
||||
cd tools/cli/swift
|
||||
swift build -c release
|
||||
```
|
||||
|
||||
#### Python Scripts (tools/script/)
|
||||
|
||||
Organized by processor type. Each directory contains related scripts.
|
||||
|
||||
| Directory | Purpose |
|
||||
|-----------|---------|
|
||||
| `asr/` | ASR (Automatic Speech Recognition) |
|
||||
| `chunk/` | Sentence chunking |
|
||||
| `cut/` | Cut detection |
|
||||
| `embedding/` | Vector embedding generation |
|
||||
| `face/` | Face detection, tracking, clustering |
|
||||
| `identity/` | Identity management |
|
||||
| `ocr/` | Optical Character Recognition |
|
||||
| `pose/` | Pose estimation (MediaPipe, YOLOv8) |
|
||||
| `scene/` | Scene detection |
|
||||
| `utils/` | Shared utilities |
|
||||
| `vlm/` | Vision Language Model (VLM) |
|
||||
| `worker/` | Worker-specific scripts |
|
||||
| `yolo/` | YOLO object detection |
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory (default: `tools/script/`)
|
||||
- `MOMENTRY_CLI_DIR` - CLI tools directory (default: `tools/cli/`)
|
||||
- `MOMENTRY_USE_RUST_PROCESSORS` - Enable Rust processors (default: `false`)
|
||||
|
||||
### Worker Integration
|
||||
|
||||
The Worker (`src/core/processor/executor.rs`) automatically locates tools:
|
||||
|
||||
1. **Python Scripts**: `tools/script/<processor>/`
|
||||
2. **Rust Binaries**: `tools/cli/rust/target/release/`
|
||||
3. **Swift Binaries**: `tools/cli/swift/.build/release/`
|
||||
|
||||
**Priority Order**:
|
||||
1. Python scripts (default)
|
||||
2. Rust binaries (if `MOMENTRY_USE_RUST_PROCESSORS=true`)
|
||||
3. Swift binaries (for Apple Vision processors)
|
||||
|
||||
### Legacy Locations (To Be Removed)
|
||||
|
||||
⚠️ The following locations are deprecated and will be removed:
|
||||
|
||||
- `scripts/rust_processors/` → Migrate to `tools/cli/rust/`
|
||||
- `scripts/swift_processors/` → Migrate to `tools/cli/swift/`
|
||||
- `scripts/*.py` (scattered) → Migrate to `tools/script/<processor>/`
|
||||
|
||||
### Migration Status
|
||||
|
||||
| Component | Current Location | Target Location | Status |
|
||||
|-----------|-----------------|-----------------|--------|
|
||||
| Rust CLI | `tools/cli/rust/` | `tools/cli/rust/` | ✅ Done |
|
||||
| Swift CLI | `tools/cli/swift/` | `tools/cli/swift/` | ✅ Done |
|
||||
| Python Scripts | `tools/script/` | `tools/script/` | ✅ Done |
|
||||
| Legacy Rust | `scripts/rust_processors/` | Remove | ⚠️ Pending |
|
||||
| Legacy Swift | `scripts/swift_processors/` | Remove | ⚠️ Pending |
|
||||
|
||||
## Processor Configuration (V3)
|
||||
|
||||
### 配置驅動的 Processor 選擇
|
||||
|
||||
Momentry Core 使用 **配置驅動的 processor 選擇系統**,支持動態選擇和優先級排序。
|
||||
|
||||
**主配置**: `config/processor_tools_v3.json`
|
||||
|
||||
### Processor 優先級政策
|
||||
|
||||
**Swift (Apple Vision + ANE) First, Rust Second, Python Backup**
|
||||
|
||||
| Priority | Tool | 用途 | 理由 |
|
||||
|----------|------|------|------|
|
||||
| 0 | Swift CLI | 標準實現 | Apple Vision + ANE 加速 |
|
||||
| 0-1 | Rust CLI | 標準實現 | 性能優秀 |
|
||||
| 2+ | Python | 備用 | 靈活性高 |
|
||||
|
||||
### 當前配置狀態
|
||||
|
||||
**Swift First (Priority 0)**: 4 個 (POSE, FACE, ASRX, OCR)
|
||||
|
||||
**Rust First (Priority 0)**: 3 個 (FACE_TRACE, CUT, SCENE_VLM)
|
||||
|
||||
**Python Only**: 2 個 (ASR, TKG)
|
||||
|
||||
### 性能基準
|
||||
|
||||
| Processor | Python | Rust | Swift | 最佳 |
|
||||
|-----------|--------|------|-------|------|
|
||||
| FACE_TRACE | ~2s | **0.1s** | - | Rust (20x) |
|
||||
| CUT | ~3s | **1s** | 6s | Rust (3x) |
|
||||
| POSE | ~5s | - | **3s** | Swift (ANE) |
|
||||
| FACE | ~8s | - | **4s** | Swift (ANE) |
|
||||
|
||||
### ⚠️ 已廢棄配置
|
||||
|
||||
- ❌ `MOMENTRY_USE_RUST_PROCESSORS` (已由 V3 配置取代)
|
||||
- ❌ `config/processor_tools.json` (V1, 已廢棄)
|
||||
|
||||
### 相關文檔
|
||||
|
||||
- `docs_v1.0/OPERATIONS/Processor_Priority_Policy.md` - 優先級政策
|
||||
- `docs_v1.0/OPERATIONS/Processor_Commands_Reference.md` - 命令參考
|
||||
- `docs_v1.0/M4_workspace/2026-09-28_processor_test_report.md` - 測試報告
|
||||
|
||||
|
||||
## Key Dependencies
|
||||
|
||||
- **Error handling**: `anyhow`, `thiserror`
|
||||
@@ -404,8 +751,43 @@ cargo run --features player --bin momentry_player -- -o
|
||||
### Paths
|
||||
- `MOMENTRY_OUTPUT_DIR` - Output directory (default: `/Users/accusys/momentry/output`)
|
||||
- `MOMENTRY_BACKUP_DIR` - Backup directory
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory (default: `tools/script/`)
|
||||
- `MOMENTRY_CLI_DIR` - CLI tools directory (default: `tools/cli/`)
|
||||
- `MOMENTRY_PYTHON_PATH` - Python path (default: `/opt/homebrew/bin/python3.11`)
|
||||
- `MOMENTRY_SCRIPTS_DIR` - Scripts directory
|
||||
|
||||
### Critical Variables for Startup Scripts
|
||||
|
||||
**IMPORTANT**: Startup scripts must explicitly `export` these variables for Python subprocess inheritance.
|
||||
|
||||
#### Production (3002)
|
||||
Required exports in `run-server-3002.sh` and `run-worker-3002.sh`:
|
||||
```bash
|
||||
export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output
|
||||
export DATABASE_SCHEMA=public
|
||||
export MOMENTRY_REDIS_PREFIX=momentry:
|
||||
export MOMENTRY_SERVER_PORT=3002
|
||||
```
|
||||
|
||||
#### Playground (3003)
|
||||
Required exports in `run-server-3003.sh`:
|
||||
```bash
|
||||
export DATABASE_SCHEMA=dev
|
||||
export MOMENTRY_SERVER_PORT=3003
|
||||
export MOMENTRY_REDIS_PREFIX=momentry_dev:
|
||||
export MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output_dev
|
||||
```
|
||||
|
||||
#### Why This Matters
|
||||
- Rust process loads `.env` via `dotenv`
|
||||
- Python subprocess inherits environment from Rust process
|
||||
- Without explicit `export`, dotenv variables are only available inside Rust
|
||||
- Python scripts like `store_traced_faces.py` will use hardcoded defaults if not exported
|
||||
|
||||
#### Config Directory
|
||||
Environment-specific configuration files:
|
||||
- `config/production.env` - Production-specific variables
|
||||
- `config/development.env` - Development-specific variables
|
||||
- `config/test.env` - Test environment (if needed)
|
||||
|
||||
### Processor Timeouts
|
||||
- `MOMENTRY_ASR_TIMEOUT` - ASR timeout in seconds (default: 3600)
|
||||
@@ -554,14 +936,19 @@ shellcheck scripts/*.sh monitor/**/*.sh
|
||||
|
||||
## Gitea Sync
|
||||
|
||||
主要 sync 管道為 Gitea:`http://192.168.110.200:3000/admin/momentry_core.git`
|
||||
主要 sync 管道為 Gitea:`http://192.168.110.210:3000/warren/momentry_core.git`(m4mini)
|
||||
|
||||
> **2026-11-05 更正**:舊文檔記載的 `http://192.168.110.200:3000/admin/momentry_core.git`
|
||||
> 已失效(主機無回應)。本機實際 remote 為 m4mini 的 `warren/momentry_core`,分支
|
||||
> `feature/dynamic-concurrency-*` 為進行中工作分支。可用測試:
|
||||
> `curl -s -u "warren:<TOKEN>" http://192.168.110.210:3000/api/v1/repos/warren/momentry_core`
|
||||
|
||||
### 產生 Access Token(首次設定)
|
||||
|
||||
```bash
|
||||
# admin 帳號密碼為 AccusysTest!
|
||||
TOKEN=$(curl -s -X POST "http://192.168.110.200:3000/api/v1/users/admin/tokens" \
|
||||
-u "admin:AccusysTest!" \
|
||||
# 登入 warren 帳號後於 API 產生 token(scopes: write:repository)
|
||||
TOKEN=$(curl -s -X POST "http://192.168.110.210:3000/api/v1/users/warren/tokens" \
|
||||
-u "warren:<PASSWORD>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"m5max128_push","scopes":["write:repository"]}' | jq -r '.sha1')
|
||||
echo $TOKEN
|
||||
@@ -571,11 +958,11 @@ echo $TOKEN
|
||||
|
||||
```bash
|
||||
# 用 token 取代密碼
|
||||
git remote add origin http://admin:TOKEN@192.168.110.200:3000/admin/momentry_core.git
|
||||
git remote add origin http://warren:TOKEN@192.168.110.210:3000/warren/momentry_core.git
|
||||
|
||||
# 同步
|
||||
git pull origin main
|
||||
git push origin main
|
||||
git pull origin feature/dynamic-concurrency-v1.3.4
|
||||
git push origin feature/dynamic-concurrency-v1.3.4
|
||||
```
|
||||
|
||||
### Token 記錄
|
||||
@@ -586,6 +973,16 @@ git push origin main
|
||||
|
||||
**注意**: Token 有 write:repository scope,勿外洩。如需新增 token 給其他機器,各自產自己的 token。
|
||||
|
||||
### 機器清單
|
||||
|
||||
| 機器名稱 | IP 地址 | 用途 |
|
||||
|----------|---------|------|
|
||||
| **m5max48** (本機) | 192.168.110.201 | Momentry Core 後端服務 (port 3002) |
|
||||
| **m4promini** | 192.168.110.203 | Studio 前端服務 |
|
||||
| **m4mini** | 192.168.110.210 | 待確認用途 |
|
||||
|
||||
---
|
||||
|
||||
## Release Workflow
|
||||
|
||||
### Release 前準備
|
||||
@@ -625,6 +1022,16 @@ git push origin main
|
||||
pg_dump -U accusys -d momentry --schema-only > "$RELEASE_DIR/schema_v0.X.X.sql"
|
||||
```
|
||||
|
||||
5. **驗證環境變數配置**
|
||||
- ✅ Startup scripts export all required environment variables
|
||||
- ✅ Python scripts don't use hardcoded paths
|
||||
- ✅ Environment variables consistent across:
|
||||
- `.env` / `.env.development`
|
||||
- Startup script `export`
|
||||
- Python script `os.environ.get()`
|
||||
- ✅ Config directory has environment-specific files
|
||||
- ✅ AGENTS.md documents all required exports
|
||||
|
||||
### 重要性
|
||||
- 避免 release binary 與 current source code 不一致
|
||||
- 方便追蹤特定 release 的程式碼狀態
|
||||
@@ -800,17 +1207,20 @@ Before creating any file in `docs_v1.0/` (API_WORKSPACE, GUIDES, REFERENCE, DESI
|
||||
| 8 | `file_uuid` not bare `uuid` | All file references use `file_uuid` (see UUID Naming Rule above) |
|
||||
| 9 | `identity_uuid` not bare `uuid` | All identity references use `identity_uuid` |
|
||||
|
||||
### P1 — Suggested (3 items)
|
||||
### P1 — Suggested (4 items)
|
||||
|
||||
| # | Check | Note |
|
||||
|---|-------|------|
|
||||
| 1 | Cross-references | Link to related docs in API_WORKSPACE/, GUIDES/, REFERENCE/, DESIGN/, OPERATIONS/ |
|
||||
| 2 | Glossary terms | Define non-obvious terms inline or link glossary |
|
||||
| 3 | Diagrams | Include Mermaid/ASCII diagram for complex topics |
|
||||
| 4 | Absolute paths | All file paths must be absolute, e.g. `/Users/accusys/momentry_core/src/...` |
|
||||
|
||||
### Exception
|
||||
|
||||
`M4_workspace/` files are exempt from this checklist (free-format reply documents).
|
||||
`M4_workspace/` files are exempt from P0 mandatory checklist items (YAML frontmatter, version history, etc.) as they are free-format reply documents.
|
||||
|
||||
**However**, `M4_workspace/` files **MUST still use absolute paths** for all file references.
|
||||
|
||||
---
|
||||
|
||||
@@ -819,3 +1229,42 @@ Before creating any file in `docs_v1.0/` (API_WORKSPACE, GUIDES, REFERENCE, DESI
|
||||
完整交付程序(M4_workspace → M5 → Release → Deploy → Public)見:
|
||||
|
||||
`docs_v1.0/OPERATIONS/DELIVERY_PROCEDURE.md`
|
||||
|
||||
## Session Summary (2026-07-01: Search Mode Fixes)
|
||||
|
||||
### Goal
|
||||
Fix search modes: Keyword BM25 ranking + People search migration to Qdrant + Qdrant scroll pagination
|
||||
|
||||
### Done
|
||||
- **Keyword/BM25 search (`search_bm25`)**: Replaced hardcoded 1.0 score with PostgreSQL FTS (`ts_rank` + `plainto_tsquery`). Now ranks results by relevance instead of flat 1.0.
|
||||
- **Smart search merge**: Passes real FTS score through instead of fixed 0.5, so keyword-only results are properly differentiated.
|
||||
- **Qdrant scroll_points**: Added `offset` parameter for pagination support; new `scroll_all_points()` method handles multi-page scroll automatically.
|
||||
- **get_identity_traces**: Fixed broken pagination loop (always fetched same first 1000 points) by switching to `scroll_all_points`.
|
||||
- **People search (`search_persons_internal`)**: Replaced `face_detections` JOIN in universal search with Qdrant `_faces` scroll + Rust aggregation (count per identity per file, frame→second via FPS).
|
||||
- **People search (`search_persons_by_query`)**: Same migration for the REST API person search endpoint.
|
||||
- **Payload field fix**: `_faces` uses `frame` (integer) not `timestamp_secs` (float). Fixed both `search_persons_internal` and `search_persons_by_query` to read `frame` and convert via `frame / fps`.
|
||||
|
||||
### Key Files Changed
|
||||
- `src/core/db/qdrant_db.rs`: `scroll_points` → offset pagination, new `scroll_all_points`
|
||||
- `src/api/identity_binding.rs`: Use `scroll_all_points` instead of broken loop
|
||||
- `src/api/universal_search.rs`: Rewrote `search_persons_internal` and `search_persons_by_query` to use Qdrant
|
||||
- `src/core/db/postgres_db.rs`: `search_bm25` → PostgreSQL FTS ranking
|
||||
- `src/api/search.rs`: Pass real FTS scores in merge, removed unused `KEYWORD_FIXED_SCORE`
|
||||
|
||||
### Done This Session
|
||||
- **Qdrant scroll pagination**: `scroll_points` now accepts `offset` param + returns `next_page_offset`; new `scroll_all_points()` handles multi-page scroll automatically
|
||||
- **get_identity_traces pagination fix**: No longer fetches same 1000 points in infinite loop
|
||||
- **Keyword BM25**: `search_bm25` replaced hardcoded 1.0 score with PostgreSQL `ts_rank` + `plainto_tsquery`; `smart_search` passes real FTS scores instead of fixed 0.5
|
||||
- **People search → Qdrant**: Both `search_persons_internal` and `search_persons_by_query` replaced `face_detections` JOIN with Qdrant `_faces` scroll + Rust aggregation (count/group/sort). Fixed `timestamp_secs` → `frame` + `frame/fps` conversion
|
||||
- **list_face_candidates → Qdrant**: `identities.rs` unbound faces query now scrolls `_faces` with `is_null: identity_id` filter, sorts by confidence DESC in Rust
|
||||
- **list_unassigned_traces → Qdrant**: `identities.rs` unbound traces query now scrolls `_faces` with `is_null: identity_id` + `trace_id > 0` filter, groups by (file_uuid, trace_id) in Rust, picks best face per trace
|
||||
- **get_identity_chunks → identity_bindings**: Replaced `face_detections` frame-range JOIN with `identity_bindings` + `chunk.metadata->>'trace_id'`
|
||||
- **postgres_db.rs 5 remaining READs → Qdrant**: `get_trace_count_by_file`, `get_trace_frame_count_distribution`, `get_identity_files`, `get_identity_faces`, `get_file_faces` all migrated to `_faces` scroll + Rust aggregation
|
||||
- **agent/tools.rs fully migrated**: `exec_find_file`, `exec_list_files`, `exec_tkg_query` (8 sub-queries), `exec_identity_text`, `exec_identities_search` — all face_detections JOINs replaced with Qdrant scroll or identity_bindings
|
||||
- **job_worker.rs + storage.rs**: Remaining face_detections READs migrated to Qdrant scroll
|
||||
|
||||
### Remaining face_detections references (all inactive/safe)
|
||||
- Schema definition (CREATE TABLE/INDEX in `postgres_db.rs`)
|
||||
- `store_face_detections_batch` — already skipped (Phase 1)
|
||||
- `workspace_sqlite.rs` — local processing DB, separate from PG
|
||||
- `bin/release.rs` — standalone release utility
|
||||
|
||||
Generated
+148
-2
@@ -636,6 +636,8 @@ dependencies = [
|
||||
"compression-core",
|
||||
"flate2",
|
||||
"memchr",
|
||||
"zstd",
|
||||
"zstd-safe",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -733,6 +735,16 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
@@ -1016,6 +1028,27 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "5.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
@@ -1736,7 +1769,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core",
|
||||
"windows-core 0.62.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2420,7 +2453,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "momentry_core"
|
||||
version = "1.0.0"
|
||||
version = "1.3.5"
|
||||
dependencies = [
|
||||
"aes-gcm",
|
||||
"anyhow",
|
||||
@@ -2433,9 +2466,11 @@ dependencies = [
|
||||
"chrono",
|
||||
"clap",
|
||||
"crossterm",
|
||||
"dirs",
|
||||
"dotenv",
|
||||
"env_logger",
|
||||
"ferrous-opencc",
|
||||
"flate2",
|
||||
"futures-util",
|
||||
"hex",
|
||||
"jieba-rs",
|
||||
@@ -2459,6 +2494,8 @@ dependencies = [
|
||||
"sha2",
|
||||
"sqlx 0.8.6",
|
||||
"subtle",
|
||||
"sysinfo",
|
||||
"tar",
|
||||
"tempfile",
|
||||
"thiserror 1.0.69",
|
||||
"tokio",
|
||||
@@ -2467,9 +2504,11 @@ dependencies = [
|
||||
"tower-http 0.5.2",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"urlencoding",
|
||||
"utoipa",
|
||||
"utoipa-swagger-ui",
|
||||
"uuid",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2604,6 +2643,15 @@ dependencies = [
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ntapi"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3b335231dfd352ffb0f8017f3b6027a4917f7df785ea2143d8af2adc66980ae"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.50.3"
|
||||
@@ -2759,6 +2807,12 @@ dependencies = [
|
||||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "parking"
|
||||
version = "2.2.1"
|
||||
@@ -3301,6 +3355,26 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redis"
|
||||
version = "1.2.0"
|
||||
@@ -3347,6 +3421,17 @@ dependencies = [
|
||||
"bitflags 2.11.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.4.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
"libredox",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.3"
|
||||
@@ -4489,6 +4574,21 @@ dependencies = [
|
||||
"syn 2.0.117",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sysinfo"
|
||||
version = "0.30.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0a5b4ddaee55fb2bea2bf0e5000747e5f5c0de765e5a5ff87f4cd106439f4bb3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
"ntapi",
|
||||
"once_cell",
|
||||
"rayon",
|
||||
"windows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration"
|
||||
version = "0.7.0"
|
||||
@@ -4528,6 +4628,17 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.46"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f6221d9a6003c78398e3b239969f352578258df48c8eb051caadae0015bc840"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"libc",
|
||||
"xattr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.27.0"
|
||||
@@ -5151,6 +5262,12 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
|
||||
|
||||
[[package]]
|
||||
name = "utf8_iter"
|
||||
version = "1.0.4"
|
||||
@@ -5482,6 +5599,25 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
|
||||
dependencies = [
|
||||
"windows-core 0.52.0",
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-core"
|
||||
version = "0.62.2"
|
||||
@@ -5907,6 +6043,16 @@ dependencies = [
|
||||
"tap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xattr"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32e45ad4206f6d2479085147f02bc2ef834ac85886624a23575ae137c8aa8156"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rustix 1.1.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xxhash-rust"
|
||||
version = "0.8.15"
|
||||
|
||||
+36
-2
@@ -1,16 +1,18 @@
|
||||
[package]
|
||||
name = "momentry_core"
|
||||
version = "1.0.0"
|
||||
version = "1.3.5"
|
||||
edition = "2021"
|
||||
authors = ["Momentry Team"]
|
||||
description = "Digital asset management system with video analysis and RAG"
|
||||
|
||||
[dependencies]
|
||||
sysinfo = "0.30"
|
||||
# Core
|
||||
anyhow = "1.0"
|
||||
thiserror = "1.0"
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
tracing = "0.1"
|
||||
dirs = "5.0"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
once_cell = "1.19"
|
||||
libc = "0.2"
|
||||
@@ -28,6 +30,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
regex = "1"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
urlencoding = "2.1"
|
||||
|
||||
# UUID
|
||||
sha2 = "0.10"
|
||||
@@ -55,7 +58,7 @@ sqlx = { version = "0.8", features = ["runtime-tokio", "postgres", "sqlite", "js
|
||||
mongodb = { version = "2", features = ["tokio-runtime"] }
|
||||
bson = { version = "2", features = ["chrono-0_4"] }
|
||||
qdrant-client = "1.7"
|
||||
reqwest = { version = "0.12", features = ["json", "gzip"] }
|
||||
reqwest = { version = "0.12", features = ["json", "gzip", "zstd"] }
|
||||
pgvector = { version = "0.3", features = ["sqlx"] }
|
||||
|
||||
# HTTP Server
|
||||
@@ -83,6 +86,9 @@ crossterm = "0.28"
|
||||
# Terminal
|
||||
atty = "0.2"
|
||||
tokio-util = { version = "0.7.18", features = ["io"] }
|
||||
walkdir = "2.5.0"
|
||||
flate2 = "1.0"
|
||||
tar = "0.4"
|
||||
|
||||
# System
|
||||
|
||||
@@ -130,6 +136,14 @@ path = "src/bin/test_bm25_simple.rs"
|
||||
name = "integrated_player"
|
||||
path = "src/bin/integrated_player.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "docserver"
|
||||
path = "src/bin/docserver/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "pipeline_worker"
|
||||
path = "src/bin/pipeline_worker.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "release"
|
||||
path = "src/bin/release.rs"
|
||||
@@ -151,3 +165,23 @@ chrono = "0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
||||
[[bin]]
|
||||
name = "backfill_trace_profiles"
|
||||
path = "src/bin/backfill_trace_profiles.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "rebuild_trace_thumbs"
|
||||
path = "src/bin/rebuild_trace_thumbs.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "backfill_trace_vlm"
|
||||
path = "src/bin/backfill_trace_vlm.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "rust_unregister"
|
||||
path = "src/bin/rust_unregister.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "rust_register"
|
||||
path = "src/bin/rust_register.rs"
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
Scene Number,Start Frame,Start Timecode,Start Time (seconds),End Frame,End Timecode,End Time (seconds),Length (frames),Length (timecode),Length (seconds)
|
||||
1,1,00:00:00.000,0.000,2800,00:01:33.333,93.333,2800,00:01:33.333,93.333
|
||||
|
@@ -0,0 +1,59 @@
|
||||
# 移除 MongoDB 依賴 — 變更說明
|
||||
|
||||
## 問題
|
||||
m5max128 (192.168.110.200) 的 `/api/v1/health` 端點掛住,因為 health check
|
||||
等待 MongoDB 連線回應,但該機器未安裝 MongoDB。
|
||||
|
||||
## 修改內容
|
||||
|
||||
### `src/api/health.rs`
|
||||
| 變更 | 說明 |
|
||||
|---|---|
|
||||
| 移除 `MongoCache` import | 不再需要 MongoDB 型別 |
|
||||
| 移除 `check_mongodb()` 函數 | 不再檢查 MongoDB 健康狀態 |
|
||||
| `health()` 函數 | `all_ok` 條件改為只檢查 PostgreSQL + Redis + Qdrant |
|
||||
| `health_detailed()` 函數 | 同上,移除 MongoDB 檢查 |
|
||||
| `ServiceHealth` struct | `mongodb` 欄位註解化 |
|
||||
|
||||
### 影響範圍
|
||||
- Health 端點不再依賴 MongoDB
|
||||
- `AppState` 中的 `mongo_cache` 欄位仍保留(供其他功能使用)
|
||||
- server.rs 中的 MongoDB 初始化(5 秒 timeout → disabled fallback)維持原樣
|
||||
|
||||
## 重新編譯
|
||||
|
||||
### 目前阻礙
|
||||
`.sqlx/` 目錄只有 3 個查詢快取檔案,缺少:
|
||||
- `command/queue.rs` 的查詢快取
|
||||
- `vlm/consumer.rs` 的查詢快取
|
||||
|
||||
### 解決步驟
|
||||
```bash
|
||||
# 方法 1: 完整 .sqlx 快取(需要連線到 DB)
|
||||
cd /Users/accusys/momentry_core
|
||||
export DATABASE_URL="postgres://accusys@localhost:5432/momentry"
|
||||
cargo sqlx prepare
|
||||
SQLX_OFFLINE=true cargo build --release
|
||||
|
||||
# 方法 2: 修復現有查詢錯誤後再編譯
|
||||
# 檢查 src/core/command/queue.rs 和 src/core/vlm/consumer.rs 的 sqlx 巨集
|
||||
|
||||
# 編譯完成後替換 binary
|
||||
cp target/release/momentry ../momentry/bin/momentry
|
||||
```
|
||||
|
||||
### 部署到 203 (m4promini)
|
||||
```bash
|
||||
scp target/release/momentry accusys@192.168.110.203:~/momentry/bin/momentry
|
||||
ssh accusys@192.168.110.203 'launchctl stop com.momentry.server && launchctl start com.momentry.server'
|
||||
```
|
||||
|
||||
## 驗證
|
||||
重啟後測試:
|
||||
```bash
|
||||
curl -s -m 10 http://localhost:3002/api/v1/health
|
||||
# 應回傳: {"status":"ok", ...} 而不是超時
|
||||
```
|
||||
|
||||
## Git commit
|
||||
`4f4aa27d` on branch `feature/dynamic-concurrency-v1.3.4`
|
||||
@@ -0,0 +1,39 @@
|
||||
Momentry Core
|
||||
Copyright (c) 2026 Momentry Team
|
||||
|
||||
---
|
||||
|
||||
LEGAL DISCLAIMER
|
||||
|
||||
This product includes software developed independently by the Momentry Team.
|
||||
|
||||
The MarkBase Queue Protocol (MQP) is an independently implemented queue protocol standard.
|
||||
|
||||
IMPORTANT:
|
||||
- This product does NOT use Apache Kafka source code
|
||||
- This product is NOT compatible with Apache Kafka protocol or API
|
||||
- This product is NOT compatible with Apache Kafka client libraries
|
||||
- This product does NOT distribute Apache Kafka software
|
||||
|
||||
The MarkBase Queue Protocol design was inspired by Apache Kafka's architecture,
|
||||
including concepts such as append-only logs, offset tracking, and consumer groups.
|
||||
However, this is an independent implementation with a different protocol (HTTP/REST + JSON)
|
||||
and is not compatible with Apache Kafka.
|
||||
|
||||
For more information about Apache Kafka, please visit:
|
||||
https://kafka.apache.org/
|
||||
|
||||
Apache Kafka is a registered trademark of the Apache Software Foundation.
|
||||
MarkBase is a product series name of the Momentry Team.
|
||||
There is NO affiliation or partnership between these entities.
|
||||
|
||||
---
|
||||
|
||||
This product uses the following open source software:
|
||||
|
||||
- Rust (MIT/Apache-2.0): https://www.rust-lang.org/
|
||||
- PostgreSQL (PostgreSQL License): https://www.postgresql.org/
|
||||
- Redis (BSD-3-Clause): https://redis.io/
|
||||
- Qdrant (Apache-2.0): https://qdrant.tech/
|
||||
|
||||
For a complete list of dependencies and their licenses, see the Cargo.toml file.
|
||||
@@ -1,3 +1,35 @@
|
||||
# momentry_core
|
||||
|
||||
Digital asset management system with video analysis and RAG - Production version with API Key authentication
|
||||
Digital asset management system with video analysis and RAG - Production version with API Key authentication
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ 重要法律声明
|
||||
|
||||
**MarkBase Queue Protocol** 是**完全独立实现**的队列协议标准。
|
||||
|
||||
- ❌ **不兼容** Apache Kafka 协议或 API
|
||||
- ❌ **未使用** Apache Kafka 源代码
|
||||
- ✅ **独立实现**,借鉴公开技术概念
|
||||
- ✅ **独立协议**,HTTP/REST + JSON
|
||||
|
||||
详细声明见: `docs_v1.0/LEGAL/MARKBASE_QUEUE_DISCLAIMER.md`
|
||||
|
||||
---
|
||||
|
||||
## 致谢
|
||||
|
||||
本项目的 VLM 队列系统设计借鉴了 Apache Kafka 的优秀设计理念,包括:
|
||||
- 追加写入日志(Append-Only Log)
|
||||
- Offset 追踪机制
|
||||
- 分区和消费者组概念
|
||||
|
||||
感谢 Apache Kafka 社区的开源贡献。
|
||||
|
||||
**声明**: Momentry Core 是完全独立实现的系统,未使用 Apache Kafka 的任何代码。
|
||||
|
||||
---
|
||||
|
||||
## 许可证
|
||||
|
||||
本项目采用专有许可证。未经授权不得使用、修改或分发。
|
||||
@@ -0,0 +1,8 @@
|
||||
# Momentry Release Manifest
|
||||
# Generated: 2026-10-04 20:43:05
|
||||
|
||||
| Binary | Size (bytes) | MD5 | SHA256 |
|
||||
|--------|--------------|-----|--------|
|
||||
| momentry | 46128592 | `3ebe21defc97d5ebd015ce8b4befdc4c` | `9e5a4b19b11343e7aae53d14e560642b70df0d07b8dba95c02ef4dde50015fbe` |
|
||||
| rust_register | 4080512 | `af4e8e08cb500e86add073ffdc3d7ebb` | `a0c9d59337bc17bb82ba404bfc0f065963e27b338d8c2fa212e0700c280356ac` |
|
||||
| rust_unregister | 9425872 | `3880e14f25701d1c08a43707b53e4899` | `3a97402961359f08bdb3627d79badfa7605c1fc3dc34d3624be531974a078af4` |
|
||||
@@ -0,0 +1,74 @@
|
||||
Timecode List:,00:00:05.239,00:00:08.075,00:00:21.822,00:00:32.032,00:00:33.400,00:00:35.002,00:00:37.070,00:00:42.209,00:00:44.411,00:00:48.382,00:00:51.318,00:01:03.497,00:01:16.109,00:01:17.911,00:01:20.314,00:01:38.165,00:01:42.536,00:01:45.672,00:01:48.442,00:02:01.655,00:02:10.631,00:02:18.805,00:02:19.506,00:02:21.742,00:02:23.110,00:02:25.045,00:02:39.660,00:02:40.327,00:02:43.330,00:02:50.037,00:02:52.406,00:02:59.446,00:03:10.123,00:03:13.193,00:03:20.534,00:03:33.547,00:03:38.151,00:03:48.161,00:03:49.563,00:03:51.898,00:04:02.042,00:04:10.951,00:04:18.191,00:04:29.069,00:04:30.203,00:04:46.319,00:04:49.623,00:04:53.160,00:04:56.630,00:05:02.702,00:05:17.284,00:05:51.284,00:05:57.424,00:05:59.092,00:06:02.696,00:06:04.831,00:06:07.767,00:06:11.538,00:06:13.273,00:06:36.129,00:06:39.032,00:06:40.800,00:06:44.337,00:06:46.906,00:06:56.283,00:07:01.288,00:07:12.432,00:07:14.301,00:07:15.835,00:07:23.109,00:07:30.684
|
||||
Scene Number,Start Frame,Start Timecode,Start Time (seconds),End Frame,End Timecode,End Time (seconds),Length (frames),Length (timecode),Length (seconds)
|
||||
1,1,00:00:00.000,0.000,157,00:00:05.239,5.239,157,00:00:05.239,5.239
|
||||
2,158,00:00:05.239,5.239,242,00:00:08.075,8.075,85,00:00:02.836,2.836
|
||||
3,243,00:00:08.075,8.075,654,00:00:21.822,21.822,412,00:00:13.747,13.747
|
||||
4,655,00:00:21.822,21.822,960,00:00:32.032,32.032,306,00:00:10.210,10.210
|
||||
5,961,00:00:32.032,32.032,1001,00:00:33.400,33.400,41,00:00:01.368,1.368
|
||||
6,1002,00:00:33.400,33.400,1049,00:00:35.002,35.002,48,00:00:01.602,1.602
|
||||
7,1050,00:00:35.002,35.002,1111,00:00:37.070,37.070,62,00:00:02.069,2.069
|
||||
8,1112,00:00:37.070,37.070,1265,00:00:42.209,42.209,154,00:00:05.138,5.138
|
||||
9,1266,00:00:42.209,42.209,1331,00:00:44.411,44.411,66,00:00:02.202,2.202
|
||||
10,1332,00:00:44.411,44.411,1450,00:00:48.382,48.382,119,00:00:03.971,3.971
|
||||
11,1451,00:00:48.382,48.382,1538,00:00:51.318,51.318,88,00:00:02.936,2.936
|
||||
12,1539,00:00:51.318,51.318,1903,00:01:03.497,63.497,365,00:00:12.179,12.179
|
||||
13,1904,00:01:03.497,63.497,2281,00:01:16.109,76.109,378,00:00:12.613,12.613
|
||||
14,2282,00:01:16.109,76.109,2335,00:01:17.911,77.911,54,00:00:01.802,1.802
|
||||
15,2336,00:01:17.911,77.911,2407,00:01:20.314,80.314,72,00:00:02.402,2.402
|
||||
16,2408,00:01:20.314,80.314,2942,00:01:38.165,98.165,535,00:00:17.851,17.851
|
||||
17,2943,00:01:38.165,98.165,3073,00:01:42.536,102.536,131,00:00:04.371,4.371
|
||||
18,3074,00:01:42.536,102.536,3167,00:01:45.672,105.672,94,00:00:03.136,3.136
|
||||
19,3168,00:01:45.672,105.672,3250,00:01:48.442,108.442,83,00:00:02.769,2.769
|
||||
20,3251,00:01:48.442,108.442,3646,00:02:01.655,121.655,396,00:00:13.213,13.213
|
||||
21,3647,00:02:01.655,121.655,3915,00:02:10.631,130.631,269,00:00:08.976,8.976
|
||||
22,3916,00:02:10.631,130.631,4160,00:02:18.805,138.805,245,00:00:08.175,8.175
|
||||
23,4161,00:02:18.805,138.805,4181,00:02:19.506,139.506,21,00:00:00.701,0.701
|
||||
24,4182,00:02:19.506,139.506,4248,00:02:21.742,141.742,67,00:00:02.236,2.236
|
||||
25,4249,00:02:21.742,141.742,4289,00:02:23.110,143.110,41,00:00:01.368,1.368
|
||||
26,4290,00:02:23.110,143.110,4347,00:02:25.045,145.045,58,00:00:01.935,1.935
|
||||
27,4348,00:02:25.045,145.045,4785,00:02:39.660,159.660,438,00:00:14.615,14.615
|
||||
28,4786,00:02:39.660,159.660,4805,00:02:40.327,160.327,20,00:00:00.667,0.667
|
||||
29,4806,00:02:40.327,160.327,4895,00:02:43.330,163.330,90,00:00:03.003,3.003
|
||||
30,4896,00:02:43.330,163.330,5096,00:02:50.037,170.037,201,00:00:06.707,6.707
|
||||
31,5097,00:02:50.037,170.037,5167,00:02:52.406,172.406,71,00:00:02.369,2.369
|
||||
32,5168,00:02:52.406,172.406,5378,00:02:59.446,179.446,211,00:00:07.040,7.040
|
||||
33,5379,00:02:59.446,179.446,5698,00:03:10.123,190.123,320,00:00:10.677,10.677
|
||||
34,5699,00:03:10.123,190.123,5790,00:03:13.193,193.193,92,00:00:03.070,3.070
|
||||
35,5791,00:03:13.193,193.193,6010,00:03:20.534,200.534,220,00:00:07.341,7.341
|
||||
36,6011,00:03:20.534,200.534,6400,00:03:33.547,213.547,390,00:00:13.013,13.013
|
||||
37,6401,00:03:33.547,213.547,6538,00:03:38.151,218.151,138,00:00:04.605,4.605
|
||||
38,6539,00:03:38.151,218.151,6838,00:03:48.161,228.161,300,00:00:10.010,10.010
|
||||
39,6839,00:03:48.161,228.161,6880,00:03:49.563,229.563,42,00:00:01.401,1.401
|
||||
40,6881,00:03:49.563,229.563,6950,00:03:51.898,231.898,70,00:00:02.336,2.336
|
||||
41,6951,00:03:51.898,231.898,7254,00:04:02.042,242.042,304,00:00:10.143,10.143
|
||||
42,7255,00:04:02.042,242.042,7521,00:04:10.951,250.951,267,00:00:08.909,8.909
|
||||
43,7522,00:04:10.951,250.951,7738,00:04:18.191,258.191,217,00:00:07.241,7.241
|
||||
44,7739,00:04:18.191,258.191,8064,00:04:29.069,269.069,326,00:00:10.878,10.878
|
||||
45,8065,00:04:29.069,269.069,8098,00:04:30.203,270.203,34,00:00:01.134,1.134
|
||||
46,8099,00:04:30.203,270.203,8581,00:04:46.319,286.319,483,00:00:16.116,16.116
|
||||
47,8582,00:04:46.319,286.319,8680,00:04:49.623,289.623,99,00:00:03.303,3.303
|
||||
48,8681,00:04:49.623,289.623,8786,00:04:53.160,293.160,106,00:00:03.537,3.537
|
||||
49,8787,00:04:53.160,293.160,8890,00:04:56.630,296.630,104,00:00:03.470,3.470
|
||||
50,8891,00:04:56.630,296.630,9072,00:05:02.702,302.702,182,00:00:06.073,6.073
|
||||
51,9073,00:05:02.702,302.702,9509,00:05:17.284,317.284,437,00:00:14.581,14.581
|
||||
52,9510,00:05:17.284,317.284,10528,00:05:51.284,351.284,1019,00:00:34.001,34.001
|
||||
53,10529,00:05:51.284,351.284,10712,00:05:57.424,357.424,184,00:00:06.139,6.139
|
||||
54,10713,00:05:57.424,357.424,10762,00:05:59.092,359.092,50,00:00:01.668,1.668
|
||||
55,10763,00:05:59.092,359.092,10870,00:06:02.696,362.696,108,00:00:03.604,3.604
|
||||
56,10871,00:06:02.696,362.696,10934,00:06:04.831,364.831,64,00:00:02.135,2.135
|
||||
57,10935,00:06:04.831,364.831,11022,00:06:07.767,367.767,88,00:00:02.936,2.936
|
||||
58,11023,00:06:07.767,367.767,11135,00:06:11.538,371.538,113,00:00:03.770,3.770
|
||||
59,11136,00:06:11.538,371.538,11187,00:06:13.273,373.273,52,00:00:01.735,1.735
|
||||
60,11188,00:06:13.273,373.273,11872,00:06:36.129,396.129,685,00:00:22.856,22.856
|
||||
61,11873,00:06:36.129,396.129,11959,00:06:39.032,399.032,87,00:00:02.903,2.903
|
||||
62,11960,00:06:39.032,399.032,12012,00:06:40.800,400.800,53,00:00:01.768,1.768
|
||||
63,12013,00:06:40.800,400.800,12118,00:06:44.337,404.337,106,00:00:03.537,3.537
|
||||
64,12119,00:06:44.337,404.337,12195,00:06:46.906,406.906,77,00:00:02.569,2.569
|
||||
65,12196,00:06:46.906,406.906,12476,00:06:56.283,416.283,281,00:00:09.376,9.376
|
||||
66,12477,00:06:56.283,416.283,12626,00:07:01.288,421.288,150,00:00:05.005,5.005
|
||||
67,12627,00:07:01.288,421.288,12960,00:07:12.432,432.432,334,00:00:11.144,11.144
|
||||
68,12961,00:07:12.432,432.432,13016,00:07:14.301,434.301,56,00:00:01.869,1.869
|
||||
69,13017,00:07:14.301,434.301,13062,00:07:15.835,435.835,46,00:00:01.535,1.535
|
||||
70,13063,00:07:15.835,435.835,13280,00:07:23.109,443.109,218,00:00:07.274,7.274
|
||||
71,13281,00:07:23.109,443.109,13507,00:07:30.684,450.684,227,00:00:07.574,7.574
|
||||
72,13508,00:07:30.684,450.684,14246,00:07:55.342,475.342,739,00:00:24.658,24.658
|
||||
|
@@ -0,0 +1,26 @@
|
||||
use sqlx::postgres::PgPoolOptions;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let pool = PgPoolOptions::new()
|
||||
.max_connections(1)
|
||||
.connect("postgres://accusys@localhost:5432/momentry")
|
||||
.await?;
|
||||
|
||||
let row: Option<(i32, String, String, Option<String>)> = sqlx::query_as(
|
||||
"SELECT id, uuid, status, processors FROM monitor_jobs WHERE uuid = 'd8acb03870f0cc9b14e01f14a7bf24d6' ORDER BY id DESC LIMIT 1"
|
||||
)
|
||||
.fetch_optional(&pool)
|
||||
.await?;
|
||||
|
||||
if let Some((id, uuid, status, processors)) = row {
|
||||
println!("Job ID: {}", id);
|
||||
println!("UUID: {}", uuid);
|
||||
println!("Status: {}", status);
|
||||
println!("Processors: {:?}", processors);
|
||||
} else {
|
||||
println!("No job found for this UUID");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
# Query PostgreSQL monitor_jobs status
|
||||
# Using Rust code to execute SQL
|
||||
|
||||
echo "Jobs in PostgreSQL:"
|
||||
cat << 'SQL' > query_jobs.sql
|
||||
SELECT uuid, status, processors, created_at::date
|
||||
FROM monitor_jobs
|
||||
ORDER BY created_at DESC
|
||||
LIMIT 10;
|
||||
SQL
|
||||
|
||||
echo "SQL query created. Need to execute via API or Rust..."
|
||||
@@ -0,0 +1,10 @@
|
||||
-- Delete failed face processor result to allow retry
|
||||
DELETE FROM processor_results
|
||||
WHERE job_id = 62
|
||||
AND processor = 'face'
|
||||
AND status = 'failed';
|
||||
|
||||
-- Check remaining processor_results for this job
|
||||
SELECT id, processor, status, retry_count
|
||||
FROM processor_results
|
||||
WHERE job_id = 62;
|
||||
@@ -0,0 +1,173 @@
|
||||
# Pipeline Configuration
|
||||
|
||||
**File**: `config/pipeline_flows.json`
|
||||
|
||||
---
|
||||
|
||||
## 📋 Purpose
|
||||
|
||||
This configuration file defines the processing pipeline for video analysis tasks. It controls:
|
||||
|
||||
- Which processors run and in what order
|
||||
- Tool selection and parameters
|
||||
- Execution conditions and dependencies
|
||||
- Failure handling and timeouts
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### View Current Configuration
|
||||
|
||||
```bash
|
||||
# View pipeline configuration
|
||||
cat config/pipeline_flows.json | jq
|
||||
|
||||
# Check specific flow
|
||||
jq '.flows.register' config/pipeline_flows.json
|
||||
```
|
||||
|
||||
### Modify Configuration
|
||||
|
||||
1. Edit `config/pipeline_flows.json`
|
||||
2. Validate JSON syntax: `jq . config/pipeline_flows.json`
|
||||
3. Restart worker: `launchctl restart gui/$(id -u)/com.momentry.worker`
|
||||
|
||||
---
|
||||
|
||||
## 📊 Configuration Structure
|
||||
|
||||
```
|
||||
pipeline_flows.json
|
||||
├── version # Schema version
|
||||
├── enabled # Global enable/disable
|
||||
├── max_concurrent_stages # Concurrency limit
|
||||
├── default_timeout_secs # Default timeout
|
||||
└── flows # Pipeline definitions
|
||||
├── register # Full registration pipeline
|
||||
├── reprocess # Selective reprocessing
|
||||
└── phase1_pack # Packaging pipeline
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Available Flows
|
||||
|
||||
### register
|
||||
|
||||
**Purpose**: Complete video processing pipeline
|
||||
|
||||
**Stages**: cut → asr → face → ocr → scene → asrx
|
||||
|
||||
**Usage**: Automatically triggered during video registration
|
||||
|
||||
---
|
||||
|
||||
### reprocess
|
||||
|
||||
**Purpose**: Selective reprocessing of specific processors
|
||||
|
||||
**Usage**: Manually triggered via Admin Panel or API
|
||||
|
||||
---
|
||||
|
||||
### phase1_pack
|
||||
|
||||
**Purpose**: Package Phase 1 results
|
||||
|
||||
**Usage**: Triggered after register completes
|
||||
|
||||
---
|
||||
|
||||
## 🔀 Execution Mode: Parallel vs Blocking
|
||||
|
||||
Each stage's `parallel` flag is the **single source of truth** for how the worker
|
||||
executes that stage. The worker reads it at runtime (via
|
||||
`src/core/pipeline_config.rs`) instead of hardcoding the mode per processor.
|
||||
|
||||
| `parallel` | Meaning | Worker behavior |
|
||||
|------------|---------|-----------------|
|
||||
| `true` | Non-blocking | Stage is dispatched to the background (pool or `tokio::spawn`); the worker poll loop continues. |
|
||||
| `false` | Blocking | Stage runs inline; the caller waits for it to finish before continuing. |
|
||||
|
||||
Unknown / missing stages default to `true` (parallel), so a missing entry never
|
||||
reintroduces blocking.
|
||||
|
||||
**Scene VLM example**: the `scene` stage is declared `"parallel": true`, so Scene
|
||||
VLM (which can run for hours on a large file) is spawned as a background task
|
||||
instead of being awaited inline. A semaphore (1 concurrent) and an in-flight set
|
||||
guard against duplicate spawns across poll cycles. Setting `"parallel": false`
|
||||
would restore the previous inline/blocking behavior.
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Tool Selection
|
||||
|
||||
### Priority System
|
||||
|
||||
- **0**: Highest priority (preferred tool)
|
||||
- **1-99**: Fallback tools
|
||||
|
||||
### Example
|
||||
|
||||
```json
|
||||
{
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift_face",
|
||||
"priority": 0,
|
||||
"description": "ANE accelerated"
|
||||
},
|
||||
{
|
||||
"name": "python_insightface",
|
||||
"priority": 1,
|
||||
"description": "CPU fallback"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 Documentation
|
||||
|
||||
- **Full Guide**: `docs_v1.0/OPERATIONS/Pipeline_Configuration_Guide.md`
|
||||
- **Processor Reference**: `docs_v1.0/OPERATIONS/Processor_Commands_Reference.md`
|
||||
- **Tool Selector**: `docs_v1.0/DESIGN/Tool_Selector_V1.0.md`
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Debugging
|
||||
|
||||
### Check Pipeline Status
|
||||
|
||||
```bash
|
||||
# View worker logs
|
||||
tail -f logs/worker_3002.log | grep -E "Pipeline|Stage"
|
||||
|
||||
# Check processor jobs
|
||||
psql -U accusys -d momentry -c "SELECT uuid, processor_type, status FROM processor_jobs ORDER BY created_at DESC LIMIT 10;"
|
||||
```
|
||||
|
||||
### Test Configuration
|
||||
|
||||
```bash
|
||||
# Validate JSON
|
||||
jq . config/pipeline_flows.json
|
||||
|
||||
# Check specific processor
|
||||
jq '.flows.register.stages[] | select(.name == "face")' config/pipeline_flows.json
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚠️ Important
|
||||
|
||||
1. **Always validate JSON** before saving
|
||||
2. **Restart worker** after configuration changes
|
||||
3. **Backup configuration** before major changes
|
||||
4. **Test changes** in development environment first
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2026-10-14
|
||||
@@ -0,0 +1,355 @@
|
||||
{
|
||||
"version": "1.3.5",
|
||||
"updated_at": "2026-11-15T12:00:00+0800",
|
||||
"updated_by": "admin",
|
||||
"vlm_prompts": {
|
||||
"scene_vlm": {
|
||||
"system_prompt": "You are a helpful assistant that analyzes video scenes.",
|
||||
"user_prompt": "Describe this scene. What is happening? What objects and people are visible?",
|
||||
"max_tokens": 200,
|
||||
"description": "Scene analysis VLM prompt"
|
||||
},
|
||||
"rust_vlm_summary": {
|
||||
"system_prompt": "You are a helpful assistant that describes people in images.",
|
||||
"user_prompt": "Describe the person in this image. Focus on clothing, accessories, and distinctive features.",
|
||||
"max_tokens": 300,
|
||||
"description": "Face trace VLM prompt for person description"
|
||||
},
|
||||
"garbled_recovery": {
|
||||
"system_prompt": "You are a helpful assistant that verifies speech transcription quality.",
|
||||
"user_prompt": "Analyze this transcript for garbled text. Is it intelligible?",
|
||||
"max_tokens": 100,
|
||||
"description": "ASR garbled text recovery prompt"
|
||||
}
|
||||
},
|
||||
"llm_config": {
|
||||
"summary": {
|
||||
"url": "http://127.0.0.1:8080/v1/chat/completions",
|
||||
"model": "gemma-4-12b-it",
|
||||
"timeout": 60,
|
||||
"fallbacks": [
|
||||
"http://127.0.0.1:8082/v1/chat/completions"
|
||||
],
|
||||
"strategy": "priority",
|
||||
"enabled": true
|
||||
},
|
||||
"vlm": {
|
||||
"url": "http://127.0.0.1:8082/v1/chat/completions",
|
||||
"model": "gemma-4-12b-it",
|
||||
"timeout": 120,
|
||||
"fallbacks": [
|
||||
"http://127.0.0.1:8080/v1/chat/completions"
|
||||
],
|
||||
"strategy": "priority",
|
||||
"enabled": false
|
||||
},
|
||||
"chat": {
|
||||
"url": "http://127.0.0.1:8080/v1/chat/completions",
|
||||
"model": "gemma-4-12b-it",
|
||||
"timeout": 30,
|
||||
"fallbacks": [
|
||||
"http://127.0.0.1:8082/v1/chat/completions"
|
||||
],
|
||||
"strategy": "priority",
|
||||
"enabled": true
|
||||
},
|
||||
"embedding": {
|
||||
"url": "http://127.0.0.1:11436/v1/embeddings",
|
||||
"model": "embeddinggemma",
|
||||
"timeout": 60,
|
||||
"fallbacks": [],
|
||||
"strategy": "priority",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"processor_config": {
|
||||
"FACE": {
|
||||
"timeout": 3600,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "swift"
|
||||
},
|
||||
"OCR": {
|
||||
"timeout": 3600,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "swift"
|
||||
},
|
||||
"CUT": {
|
||||
"timeout": 3600,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "rust"
|
||||
},
|
||||
"ASRX": {
|
||||
"timeout": 3600,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "swift"
|
||||
},
|
||||
"FACE_TRACE": {
|
||||
"timeout": 3600,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "rust"
|
||||
},
|
||||
"FACE_CLUSTER": {
|
||||
"timeout": 3600,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "rust"
|
||||
},
|
||||
"SCENE_VLM": {
|
||||
"timeout": 7200,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "python"
|
||||
},
|
||||
"POSE": {
|
||||
"timeout": 3600,
|
||||
"enabled": true,
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "mediapipe",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"min_confidence": 0.5,
|
||||
"model_complexity": 2
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_tool": "swift"
|
||||
}
|
||||
},
|
||||
"filter_config": {
|
||||
"face": {
|
||||
"min_confidence": 0.5,
|
||||
"min_size": 30,
|
||||
"min_capture_quality": 0.25
|
||||
}
|
||||
},
|
||||
"face_filter_defaults": {
|
||||
"min_confidence": 50.0,
|
||||
"min_size": 1,
|
||||
"min_capture_quality": 0.25
|
||||
},
|
||||
"paths": {
|
||||
"output_dir": "/Users/accusys/momentry/output/demo",
|
||||
"backup_dir": "/Users/accusys/momentry/var/backup",
|
||||
"scripts_dir": "/Users/accusys/momentry/scripts",
|
||||
"cli_dir": "/Users/accusys/momentry/tools/cli",
|
||||
"python_path": "/opt/homebrew/bin/python3.11",
|
||||
"ffmpeg_path": "/opt/homebrew/bin/ffmpeg"
|
||||
},
|
||||
"concurrency": {
|
||||
"max_concurrent_jobs": 2,
|
||||
"poll_interval": 5,
|
||||
"batch_size": 5,
|
||||
"processor_timeout_secs": 3600
|
||||
},
|
||||
"feature_flags": {
|
||||
"cache_enabled": true,
|
||||
"auto_pipeline_enabled": false,
|
||||
"watcher_auto_register": false,
|
||||
"summary_enabled": true
|
||||
},
|
||||
"server": {
|
||||
"port": 3002,
|
||||
"media_base_url": "http://localhost:8888",
|
||||
"serve_base_url": "http://localhost:8888",
|
||||
"storage_root": "/Users/accusys/momentry/var/sftpgo/data",
|
||||
"timezone": "Asia/Taipei"
|
||||
},
|
||||
"admin_settings": {
|
||||
"session_timeout": 3600,
|
||||
"max_login_attempts": 5,
|
||||
"api_key_expiry_days": 365,
|
||||
"system_stats_refresh_sec": 5,
|
||||
"preferred_language": "en",
|
||||
"library_default_sort": "name_asc"
|
||||
},
|
||||
"search": {
|
||||
"vlm_min_score": 0.0,
|
||||
"vlm_output_language": "ja"
|
||||
},
|
||||
"pipeline": {
|
||||
"enabled": true,
|
||||
"max_concurrent_stages": 5,
|
||||
"default_timeout_secs": 7200,
|
||||
"flows": {
|
||||
"register": {
|
||||
"name": "register",
|
||||
"description": "Full registration pipeline: all processors",
|
||||
"version": "1.0",
|
||||
"enabled": true,
|
||||
"stages": [
|
||||
{
|
||||
"name": "probe",
|
||||
"processor_type": "probe",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 300
|
||||
},
|
||||
{
|
||||
"name": "cut",
|
||||
"processor_type": "cut",
|
||||
"required": true,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
},
|
||||
{
|
||||
"name": "face",
|
||||
"processor_type": "face",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
},
|
||||
{
|
||||
"name": "ocr",
|
||||
"processor_type": "ocr",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
},
|
||||
{
|
||||
"name": "asrx",
|
||||
"processor_type": "asrx",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
},
|
||||
{
|
||||
"name": "scene_vlm",
|
||||
"processor_type": "scene_vlm",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200
|
||||
},
|
||||
{
|
||||
"name": "face_trace",
|
||||
"processor_type": "face_trace",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
},
|
||||
{
|
||||
"name": "face_cluster",
|
||||
"processor_type": "face_cluster",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
}
|
||||
]
|
||||
},
|
||||
"reindex": {
|
||||
"name": "reindex",
|
||||
"description": "Re-index pipeline: chunks + vectors + TKG",
|
||||
"version": "1.0",
|
||||
"enabled": true,
|
||||
"stages": [
|
||||
{
|
||||
"name": "chunk",
|
||||
"processor_type": "chunk",
|
||||
"required": true,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
},
|
||||
{
|
||||
"name": "vectorize",
|
||||
"processor_type": "vectorize",
|
||||
"required": true,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600
|
||||
},
|
||||
{
|
||||
"name": "tkg",
|
||||
"processor_type": "tkg",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"filter_config": {},
|
||||
"llm_config": {},
|
||||
"processor_config": {},
|
||||
"search": {
|
||||
"vlm_max_results": 5,
|
||||
"vlm_min_score": 0,
|
||||
"vlm_output_language": "ja"
|
||||
},
|
||||
"system_config": {},
|
||||
"version": "1.0.0",
|
||||
"vlm_prompts": {
|
||||
"test": "prompt"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
# Development Environment Configuration
|
||||
# Used by: momentry_playground binary on port 3003
|
||||
#
|
||||
# This file extracts development-specific variables from .env.development
|
||||
# Startup scripts must export these variables for Python subprocess inheritance
|
||||
|
||||
# Server Configuration
|
||||
MOMENTRY_SERVER_PORT=3003
|
||||
MOMENTRY_REDIS_PREFIX=momentry_dev:
|
||||
|
||||
# Database Schema
|
||||
DATABASE_SCHEMA=dev
|
||||
|
||||
# Output Directory (CRITICAL for Python scripts)
|
||||
MOMENTRY_OUTPUT_DIR=/Users/accusys/momentry/output_dev
|
||||
|
||||
# Backup Directory
|
||||
MOMENTRY_BACKUP_DIR=/Users/accusys/momentry/backup/momentry_dev
|
||||
|
||||
# Storage
|
||||
MOMENTRY_SFTP_ROOT=/Users/accusys/momentry/var/sftpgo/data/demo/
|
||||
|
||||
# Python Path (venv for development)
|
||||
MOMENTRY_PYTHON_PATH=/Users/accusys/momentry_core/venv/bin/python
|
||||
MOMENTRY_SCRIPTS_DIR=/Users/accusys/momentry_core/scripts
|
||||
|
||||
# Logging
|
||||
RUST_LOG=info
|
||||
MOMENTRY_LOG_LEVEL=info
|
||||
|
||||
# Worker Configuration
|
||||
MOMENTRY_WORKER_ENABLED=true
|
||||
MOMENTRY_MAX_CONCURRENT=6
|
||||
MOMENTRY_POLL_INTERVAL=10
|
||||
MOMENTRY_WORKER_BATCH_SIZE=5
|
||||
|
||||
# TMDb Integration
|
||||
TMDB_API_KEY=e9cde52197f6f8df4d9db99da93db1fb
|
||||
MOMENTRY_TMDB_PROBE_ENABLED=true
|
||||
|
||||
# LLM Configuration
|
||||
MOMENTRY_LLM_SUMMARY_URL=http://127.0.0.1:8000/v1/chat/completions
|
||||
MOMENTRY_LLM_SUMMARY_MODEL=gemma-4-E4B
|
||||
MOMENTRY_LLM_SUMMARY_ENABLED=true
|
||||
|
||||
# Embedding
|
||||
MOMENTRY_EMBED_URL=http://localhost:11436
|
||||
@@ -0,0 +1,356 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"updated_at": "2026-10-16T17:00:00Z",
|
||||
"updated_by": "core_team",
|
||||
"enabled": true,
|
||||
"max_concurrent_stages": 3,
|
||||
"default_timeout_secs": 3600,
|
||||
"phases": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "基础分析",
|
||||
"name_en": "Foundation",
|
||||
"description": "场景切分与分析",
|
||||
"progress_weight": 0.15,
|
||||
"color": "#4CAF50",
|
||||
"icon": "foundation",
|
||||
"parallel_strategy": "sequential",
|
||||
"processors": ["cut"]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name": "核心处理",
|
||||
"name_en": "Core Processing",
|
||||
"description": "语音识别、人脸检测、文字识别",
|
||||
"progress_weight": 0.60,
|
||||
"color": "#2196F3",
|
||||
"icon": "processing",
|
||||
"parallel_strategy": "limited_parallel",
|
||||
"max_concurrent": 3,
|
||||
"processors": ["asr_asrx", "face", "ocr"]
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "深度分析",
|
||||
"name_en": "Deep Analysis",
|
||||
"description": "说话人识别、场景描述、人脸聚类",
|
||||
"progress_weight": 0.20,
|
||||
"color": "#9C27B0",
|
||||
"icon": "analysis",
|
||||
"parallel_strategy": "limited_parallel",
|
||||
"max_concurrent": 3,
|
||||
"processors": ["scene_vlm", "face_trace", "face_cluster"]
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name": "知识构建",
|
||||
"name_en": "Knowledge Building",
|
||||
"description": "时序知识图谱构建",
|
||||
"progress_weight": 0.05,
|
||||
"color": "#FF9800",
|
||||
"icon": "knowledge",
|
||||
"parallel_strategy": "sequential",
|
||||
"processors": ["tkg"]
|
||||
}
|
||||
],
|
||||
"flows": {
|
||||
"register": {
|
||||
"name": "Video Registration Pipeline",
|
||||
"description": "Complete video processing pipeline for new video files",
|
||||
"version": "2.0.0",
|
||||
"enabled": true,
|
||||
"stages": [
|
||||
{
|
||||
"name": "cut",
|
||||
"processor_type": "cut",
|
||||
"phase": 1,
|
||||
"phase_name": "基础分析",
|
||||
"phase_name_en": "Foundation",
|
||||
"progress_weight": 1.0,
|
||||
"display_name": "场景切分",
|
||||
"display_name_en": "Scene Cut Detection",
|
||||
"description": "Scene cut detection using ffmpeg or Python scenedetect",
|
||||
"required": true,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": false,
|
||||
"estimated_time_secs": 5,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "rust_cut",
|
||||
"priority": 0,
|
||||
"description": "High-performance Rust-based scene detection",
|
||||
"parameters": {
|
||||
"min_scene_duration": 0.5,
|
||||
"threshold": 0.3
|
||||
},
|
||||
"usage_notes": "Uses ffmpeg for native detection. Falls back to Python scenedetect if unavailable."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.cut.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "asr_asrx",
|
||||
"processor_type": "asr_asrx",
|
||||
"phase": 2,
|
||||
"phase_name": "核心处理",
|
||||
"phase_name_en": "Core Processing",
|
||||
"progress_weight": 0.35,
|
||||
"display_name": "語音識別與說話人分離",
|
||||
"display_name_en": "ASR + Speaker Diarization",
|
||||
"description": "Automatic Speech Recognition with Speaker Diarization using Rust + MLX Whisper",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 25,
|
||||
"resource_type": "gpu",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "rust_asr_asrx",
|
||||
"priority": 0,
|
||||
"description": "High-performance Rust ASR + Diarization with MLX Whisper",
|
||||
"parameters": {
|
||||
"model": "/Users/accusys/models/whisper-small-mlx",
|
||||
"diarize": true
|
||||
},
|
||||
"usage_notes": "Combines ASR and Diarization in one processor. Uses verified whisper-small-mlx model."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.asrx.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "face",
|
||||
"processor_type": "face",
|
||||
"phase": 2,
|
||||
"phase_name": "核心处理",
|
||||
"phase_name_en": "Core Processing",
|
||||
"progress_weight": 0.35,
|
||||
"display_name": "人脸检测",
|
||||
"display_name_en": "Face Detection",
|
||||
"description": "Face detection and tracking",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 15,
|
||||
"resource_type": "ane",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "swift_face",
|
||||
"priority": 0,
|
||||
"description": "Apple Vision framework face detection (ANE accelerated)",
|
||||
"parameters": {
|
||||
"min_confidence": 0.5,
|
||||
"min_size": 1
|
||||
},
|
||||
"usage_notes": "Uses Apple Neural Engine for acceleration. Falls back to Python InsightFace if unavailable."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.face.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "ocr",
|
||||
"processor_type": "ocr",
|
||||
"phase": 2,
|
||||
"phase_name": "核心处理",
|
||||
"phase_name_en": "Core Processing",
|
||||
"progress_weight": 0.30,
|
||||
"display_name": "文字识别",
|
||||
"display_name_en": "OCR",
|
||||
"description": "OCR text extraction using Apple Vision Framework",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 10,
|
||||
"resource_type": "ane",
|
||||
"dependencies": [],
|
||||
"tool": {
|
||||
"name": "swift_ocr",
|
||||
"priority": 0,
|
||||
"description": "Apple Vision VNRecognizeTextRequest (ANE accelerated)",
|
||||
"parameters": {
|
||||
"recognition_level": "accurate",
|
||||
"uses_language_correction": true
|
||||
},
|
||||
"usage_notes": "Uses Apple Neural Engine for acceleration. Supports multiple languages with real-time recognition. 2.5x faster than Python (2s vs 5s)."
|
||||
},
|
||||
"condition": {
|
||||
"skip_if_exists": "*.ocr.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "scene_vlm",
|
||||
"processor_type": "scene_vlm",
|
||||
"phase": 3,
|
||||
"phase_name": "深度分析",
|
||||
"phase_name_en": "Deep Analysis",
|
||||
"progress_weight": 0.35,
|
||||
"display_name": "场景描述",
|
||||
"display_name_en": "Scene Description",
|
||||
"description": "Scene VLM analysis for scene descriptions",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 7200,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 10,
|
||||
"resource_type": "gpu",
|
||||
"dependencies": ["cut"],
|
||||
"tool": {
|
||||
"name": "gemma_vlm",
|
||||
"priority": 0,
|
||||
"description": "Gemma 4 12B with mmproj for vision-language analysis",
|
||||
"parameters": {
|
||||
"max_tokens": 900,
|
||||
"temperature": 0.1
|
||||
},
|
||||
"usage_notes": "Generates scene descriptions in multiple languages. Requires mmproj loaded."
|
||||
},
|
||||
"condition": {
|
||||
"depends_on": "cut",
|
||||
"skip_if_exists": "*.scenes.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "face_trace",
|
||||
"processor_type": "face_trace",
|
||||
"phase": 3,
|
||||
"phase_name": "深度分析",
|
||||
"phase_name_en": "Deep Analysis",
|
||||
"progress_weight": 0.20,
|
||||
"display_name": "人脸追踪",
|
||||
"display_name_en": "Face Tracing",
|
||||
"description": "Face tracking to generate face traces using IoU + Embedding Similarity",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 5,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": ["face"],
|
||||
"tool": {
|
||||
"name": "rust_face_trace",
|
||||
"priority": 0,
|
||||
"description": "Rust-based face tracking with IoU + Embedding similarity matching",
|
||||
"parameters": {
|
||||
"similarity_threshold": 0.85,
|
||||
"iou_threshold": 0.3
|
||||
},
|
||||
"usage_notes": "Uses Qdrant _faces collection for embeddings. Matches faces based on IoU (bbox overlap) and embedding similarity. Traces are continuous face sequences; same person may have multiple traces due to cuts or temporary exits."
|
||||
},
|
||||
"condition": {
|
||||
"depends_on": "face",
|
||||
"skip_if_exists": "*.face_traced.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "face_cluster",
|
||||
"processor_type": "face_cluster",
|
||||
"phase": 3,
|
||||
"phase_name": "深度分析",
|
||||
"phase_name_en": "Deep Analysis",
|
||||
"progress_weight": 0.25,
|
||||
"display_name": "人脸聚类",
|
||||
"display_name_en": "Face Clustering",
|
||||
"description": "Face clustering and grouping with improved threshold",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": true,
|
||||
"estimated_time_secs": 5,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": ["face_trace"],
|
||||
"tool": {
|
||||
"name": "rust_face_cluster",
|
||||
"priority": 0,
|
||||
"description": "Rust-based face clustering with Stage 2 merge support",
|
||||
"parameters": {
|
||||
"threshold": 0.15,
|
||||
"stage2": false,
|
||||
"method": "leader",
|
||||
"min_face_count": 20,
|
||||
"max_bbox_area": 150000
|
||||
},
|
||||
"usage_notes": "Uses Qdrant _faces collection for embeddings. Threshold=0.15 to correctly separate male/female faces. Stage 2 merge disabled to prevent over-merging. Auto-filters low-quality clusters: face_count<20 or bbox_area>150000 (hand/object detections)."
|
||||
},
|
||||
"condition": {
|
||||
"depends_on": "face_trace",
|
||||
"skip_if_exists": "*.face_cluster.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
},
|
||||
{
|
||||
"name": "tkg",
|
||||
"processor_type": "tkg",
|
||||
"phase": 4,
|
||||
"phase_name": "知识构建",
|
||||
"phase_name_en": "Knowledge Building",
|
||||
"progress_weight": 1.0,
|
||||
"display_name": "知识图谱",
|
||||
"display_name_en": "Knowledge Graph",
|
||||
"description": "Temporal knowledge graph construction",
|
||||
"required": false,
|
||||
"enabled": true,
|
||||
"timeout_secs": 3600,
|
||||
"parallel": false,
|
||||
"estimated_time_secs": 5,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": ["asr_asrx", "face_cluster"],
|
||||
"condition": {
|
||||
"depends_on": ["asr_asrx", "face_cluster"],
|
||||
"skip_if_exists": "*.tkg.json"
|
||||
},
|
||||
"on_failure": "continue"
|
||||
}
|
||||
]
|
||||
},
|
||||
"reprocess": {
|
||||
"name": "Reprocessing Pipeline",
|
||||
"description": "Selective reprocessing of specific processors",
|
||||
"version": "2.0.0",
|
||||
"enabled": true,
|
||||
"stages": []
|
||||
},
|
||||
"phase1_pack": {
|
||||
"name": "Phase 1 Packaging Pipeline",
|
||||
"description": "Package Phase 1 results for delivery",
|
||||
"version": "2.0.0",
|
||||
"enabled": true,
|
||||
"stages": [
|
||||
{
|
||||
"name": "pack",
|
||||
"processor_type": "pack",
|
||||
"phase": 4,
|
||||
"phase_name": "知识构建",
|
||||
"phase_name_en": "Knowledge Building",
|
||||
"progress_weight": 1.0,
|
||||
"display_name": "打包",
|
||||
"display_name_en": "Pack",
|
||||
"description": "Create release package with all Phase 1 outputs",
|
||||
"required": true,
|
||||
"enabled": true,
|
||||
"timeout_secs": 600,
|
||||
"parallel": false,
|
||||
"estimated_time_secs": 10,
|
||||
"resource_type": "cpu",
|
||||
"dependencies": [],
|
||||
"parameters": {
|
||||
"phase": 1,
|
||||
"include_metadata": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
{
|
||||
"processor_config": {
|
||||
"pose": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "mediapipe",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"model_complexity": 2,
|
||||
"min_confidence": 0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "yolov8",
|
||||
"priority": 3,
|
||||
"enabled": false,
|
||||
"parameters": {
|
||||
"model": "yolov8n-pose.pt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_tool": "mediapipe",
|
||||
"timeout": 3600,
|
||||
"enabled": true
|
||||
},
|
||||
"face": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "swift",
|
||||
"enabled": true
|
||||
},
|
||||
"asr": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "whisper",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"model": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "whisper",
|
||||
"enabled": true
|
||||
},
|
||||
"asrx": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "swift",
|
||||
"enabled": true
|
||||
},
|
||||
"ocr": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "swift",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "swift",
|
||||
"enabled": true
|
||||
},
|
||||
"face_trace": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"min_trace_len": 0,
|
||||
"min_confidence": 0.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "rust",
|
||||
"enabled": true
|
||||
},
|
||||
"face_deduplicate": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "python",
|
||||
"enabled": true
|
||||
},
|
||||
"scene_vlm_summary": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"model": "gemma-4-12b-it",
|
||||
"max_tokens": 300
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_tool": "python",
|
||||
"enabled": true
|
||||
},
|
||||
"tkg": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {}
|
||||
},
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "python",
|
||||
"enabled": true
|
||||
},
|
||||
"vlm_summary": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"model": "gemma-4-12b-it",
|
||||
"max_tokens": 800,
|
||||
"use_vision": true
|
||||
}
|
||||
}
|
||||
],
|
||||
"default_tool": "rust",
|
||||
"enabled": true
|
||||
},
|
||||
"cut": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "rust",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"use_ffmpeg": true,
|
||||
"min_scene_duration": 0.5
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "python",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {}
|
||||
}
|
||||
],
|
||||
"default_tool": "rust",
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
{
|
||||
"processor_config": {
|
||||
"pose": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "mediapipe",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"model_complexity": 2,
|
||||
"min_confidence": 0.5,
|
||||
"script": "pose_processor_mediapipe.py"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"binary": "rust_pose"
|
||||
},
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"binary": "swift_pose"
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "yolov8-pose",
|
||||
"priority": 3,
|
||||
"enabled": false,
|
||||
"parameters": {
|
||||
"model_file": "yolov8n-pose.pt"
|
||||
}
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "mediapipe"
|
||||
},
|
||||
"timeout": 3600,
|
||||
"enabled": true
|
||||
},
|
||||
"face": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"binary": "swift_face"
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"script": "face_detector.py"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"asr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "whisper",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"model_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx",
|
||||
"script": "asr_processor_whisper.py"
|
||||
}
|
||||
},
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "whisper",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {
|
||||
"model_size": "base"
|
||||
}
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "whisper"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"asrx": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"binary": "swift_asrx"
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"script": "asrx_processor.py"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"ocr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"binary": "swift_ocr"
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "tesseract",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"script": "ocr_processor.py"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"face_trace": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"min_trace_len": 0,
|
||||
"min_confidence": 0.0
|
||||
},
|
||||
"binary": "rust_store_traced_faces"
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {},
|
||||
"script": "store_traced_faces.py"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"face_deduplicate": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"script": "face_deduplicate.py"
|
||||
},
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {},
|
||||
"binary": "rust_face_deduplicate"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": null
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"scene_vlm_summary": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"max_tokens": 300,
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"script": "scene_vlm_summary.py"
|
||||
}
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"tkg": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {},
|
||||
"script": "build_tkg.py"
|
||||
},
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {},
|
||||
"binary": "rust_tkg"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": null
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"vlm_summary": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"max_tokens": 800,
|
||||
"use_vision": true,
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions"
|
||||
},
|
||||
"binary": "rust_vlm_summary"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": "gemma-4-12b-it"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"cut": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"parameters": {
|
||||
"use_ffmpeg": true,
|
||||
"min_scene_duration": 0.5
|
||||
},
|
||||
"binary": "rust_cut"
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"parameters": {},
|
||||
"script": "cut_detector.py"
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
},
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"version": "2.0",
|
||||
"description": "Processor configuration with tool/model separation",
|
||||
"tools": ["python", "rust", "swift"],
|
||||
"models": {
|
||||
"whisper": ["base", "small", "medium", "large", "large-v3"],
|
||||
"mediapipe": ["pose", "face"],
|
||||
"yolov8": ["pose", "detect"],
|
||||
"gemma": ["gemma-4-12b-it", "embeddinggemma-300m"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
{
|
||||
"processor_config": {
|
||||
"face": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_face",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.face.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"asr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "whisper",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_whisper",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model",
|
||||
"{model_size}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_size": "base"
|
||||
},
|
||||
"output_file": "{file_uuid}.asr.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": "whisper"
|
||||
}
|
||||
},
|
||||
"asr_asrx": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "whisper",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_asr_asrx",
|
||||
"args": [
|
||||
"--input",
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--model",
|
||||
"/Users/accusys/models/whisper-small-mlx",
|
||||
"--diarize",
|
||||
"true"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": "whisper"
|
||||
}
|
||||
},
|
||||
"asrx": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_asrx",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"ocr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_ocr",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.ocr.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"face_trace": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_store_traced_faces",
|
||||
"args": [
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--min-trace-len",
|
||||
"{min_trace_len}",
|
||||
"--min-confidence",
|
||||
"{min_confidence}",
|
||||
"--video-path",
|
||||
"{video_path}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"min_trace_len": 0,
|
||||
"min_confidence": 0.0
|
||||
},
|
||||
"output_file": "{file_uuid}.face_traced.json",
|
||||
"timeout": 600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"scene_vlm_summary": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_scene_vlm",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--llm-url",
|
||||
"{llm_url}",
|
||||
"--max-tokens",
|
||||
"{max_tokens}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"max_tokens": 900
|
||||
},
|
||||
"output_file": "{file_uuid}.scene_vlm.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"tkg": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_tkg",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.tkg.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"cut": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_cut",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--min-scene-duration",
|
||||
"{min_scene_duration}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"use_ffmpeg": true,
|
||||
"min_scene_duration": 0.5
|
||||
},
|
||||
"output_file": "{file_uuid}.cut.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"video_path": "Full path to video file",
|
||||
"output_path": "Full path to output JSON file",
|
||||
"output_dir": "Output directory (default: /Users/accusys/momentry/output)",
|
||||
"file_uuid": "Video file UUID",
|
||||
"face_json": "Path to face.json file"
|
||||
},
|
||||
"environment": {
|
||||
"MOMENTRY_OUTPUT_DIR": "/Users/accusys/momentry/output",
|
||||
"MOMENTRY_SCRIPTS_DIR": "tools/script/",
|
||||
"MOMENTRY_CLI_DIR": "tools/cli/",
|
||||
"MOMENTRY_PYTHON_PATH": "/opt/homebrew/bin/python3.11",
|
||||
"DATABASE_SCHEMA": "public",
|
||||
"DATABASE_URL": "postgres://accusys@localhost:5432/momentry",
|
||||
"REDIS_URL": "redis://:accusys@localhost:6379"
|
||||
},
|
||||
"models": {
|
||||
"whisper": {
|
||||
"description": "OpenAI Whisper ASR model",
|
||||
"sizes": [
|
||||
"tiny",
|
||||
"base",
|
||||
"small",
|
||||
"medium",
|
||||
"large",
|
||||
"large-v3"
|
||||
],
|
||||
"default_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"mediapipe": {
|
||||
"description": "MediaPipe Pose estimation",
|
||||
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task",
|
||||
"complexity_levels": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"default_complexity": 2
|
||||
},
|
||||
"facenet": {
|
||||
"description": "FaceNet 512D embedding model",
|
||||
"model_path": "/Users/accusys/models/facenet512.mlpackage"
|
||||
},
|
||||
"gemma-4-12b-it": {
|
||||
"description": "Gemma 4 12B instruct model for VLM/LLM",
|
||||
"model_path": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf",
|
||||
"mmproj_path": "/Users/accusys/models/mmproj-F16.gguf",
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions"
|
||||
},
|
||||
"embeddinggemma-300m": {
|
||||
"description": "Embedding Gemma 300M for vector embeddings",
|
||||
"model_path": "/Users/accusys/models/embeddinggemma-300M-Q8_0.gguf",
|
||||
"embedding_url": "http://localhost:11436/embed"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"version": "3.0",
|
||||
"description": "Processor configuration - CLI tools (rust/swift) prioritized",
|
||||
"priority_policy": "rust/swift CLI (priority 0) > python (priority 1+)",
|
||||
"last_updated": "2026-09-27"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,560 @@
|
||||
{
|
||||
"processor_config": {
|
||||
"pose": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_pose",
|
||||
"args": [
|
||||
"--video",
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_pose",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "mediapipe",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/pose_processor_mediapipe.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model-complexity",
|
||||
"{model_complexity}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_complexity": 2,
|
||||
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task"
|
||||
},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "yolov8-pose",
|
||||
"priority": 3,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/pose_processor_yolov8.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--model",
|
||||
"{model_file}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_file": "yolov8n-pose.pt"
|
||||
},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"face": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_face",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.face.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "facenet",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/face_detector.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model",
|
||||
"{model_name}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_name": "facenet",
|
||||
"model_path": "/Users/accusys/models/facenet512.mlpackage"
|
||||
},
|
||||
"output_file": "{file_uuid}.face.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"asr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "whisper",
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_whisper",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model",
|
||||
"{model_size}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_size": "base"
|
||||
},
|
||||
"output_file": "{file_uuid}.asr.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "whisper",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/asr_processor_simplified.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--model",
|
||||
"{model_size}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"output_file": "{file_uuid}.asr.json",
|
||||
"timeout": 7200
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "whisper"
|
||||
}
|
||||
},
|
||||
"asrx": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/asrx_swift",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/asrx_processor.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"ocr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_ocr",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.ocr.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "tesseract",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/ocr_processor.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.ocr.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"face_trace": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_store_traced_faces",
|
||||
"args": [
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--min-trace-len",
|
||||
"{min_trace_len}",
|
||||
"--min-confidence",
|
||||
"{min_confidence}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"min_trace_len": 0,
|
||||
"min_confidence": 0.0
|
||||
},
|
||||
"output_file": "{file_uuid}.face_traced.json",
|
||||
"timeout": 600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/store_traced_faces.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--face-json",
|
||||
"{face_json}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.face_traced.json",
|
||||
"timeout": 1200
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"scene_vlm_summary": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_scene_vlm",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--llm-url",
|
||||
"{llm_url}",
|
||||
"--max-tokens",
|
||||
"{max_tokens}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"max_tokens": 900
|
||||
},
|
||||
"output_file": "{file_uuid}.scene_vlm.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/scene_vlm_summary.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--llm-url",
|
||||
"{llm_url}",
|
||||
"--max-tokens",
|
||||
"{max_tokens}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"max_tokens": 900
|
||||
},
|
||||
"output_file": "{file_uuid}.scene_vlm.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it"
|
||||
}
|
||||
},
|
||||
"tkg": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_tkg",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.tkg.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/build_tkg.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.tkg.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"cut": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_cut",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--min-scene-duration",
|
||||
"{min_scene_duration}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"use_ffmpeg": true,
|
||||
"min_scene_duration": 0.5
|
||||
},
|
||||
"output_file": "{file_uuid}.cut.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/cut_detector.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.cut.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"video_path": "Full path to video file",
|
||||
"output_path": "Full path to output JSON file",
|
||||
"output_dir": "Output directory (default: /Users/accusys/momentry/output)",
|
||||
"file_uuid": "Video file UUID",
|
||||
"face_json": "Path to face.json file"
|
||||
},
|
||||
"environment": {
|
||||
"MOMENTRY_OUTPUT_DIR": "/Users/accusys/momentry/output",
|
||||
"MOMENTRY_SCRIPTS_DIR": "tools/script/",
|
||||
"MOMENTRY_CLI_DIR": "tools/cli/",
|
||||
"MOMENTRY_PYTHON_PATH": "/opt/homebrew/bin/python3.11",
|
||||
"DATABASE_SCHEMA": "public",
|
||||
"DATABASE_URL": "postgres://accusys@localhost:5432/momentry",
|
||||
"REDIS_URL": "redis://:accusys@localhost:6379"
|
||||
},
|
||||
"models": {
|
||||
"whisper": {
|
||||
"description": "OpenAI Whisper ASR model",
|
||||
"sizes": [
|
||||
"tiny",
|
||||
"base",
|
||||
"small",
|
||||
"medium",
|
||||
"large",
|
||||
"large-v3"
|
||||
],
|
||||
"default_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"mediapipe": {
|
||||
"description": "MediaPipe Pose estimation",
|
||||
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task",
|
||||
"complexity_levels": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"default_complexity": 2
|
||||
},
|
||||
"facenet": {
|
||||
"description": "FaceNet 512D embedding model",
|
||||
"model_path": "/Users/accusys/models/facenet512.mlpackage"
|
||||
},
|
||||
"gemma-4-12b-it": {
|
||||
"description": "Gemma 4 12B instruct model for VLM/LLM",
|
||||
"model_path": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf",
|
||||
"mmproj_path": "/Users/accusys/models/mmproj-F16.gguf",
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions"
|
||||
},
|
||||
"embeddinggemma-300m": {
|
||||
"description": "Embedding Gemma 300M for vector embeddings",
|
||||
"model_path": "/Users/accusys/models/embeddinggemma-300M-Q8_0.gguf",
|
||||
"embedding_url": "http://localhost:11436/embed"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"version": "3.0",
|
||||
"description": "Processor configuration - CLI tools (rust/swift) prioritized",
|
||||
"priority_policy": "rust/swift CLI (priority 0) > python (priority 1+)",
|
||||
"last_updated": "2026-09-27"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,560 @@
|
||||
{
|
||||
"processor_config": {
|
||||
"pose": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_pose",
|
||||
"args": [
|
||||
"--video",
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_pose",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "mediapipe",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/pose_processor_mediapipe.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model-complexity",
|
||||
"{model_complexity}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_complexity": 2,
|
||||
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task"
|
||||
},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "yolov8-pose",
|
||||
"priority": 3,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/pose_processor_yolov8.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--model",
|
||||
"{model_file}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_file": "yolov8n-pose.pt"
|
||||
},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"face": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_face",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.face.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "facenet",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/face_detector.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model",
|
||||
"{model_name}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_name": "facenet",
|
||||
"model_path": "/Users/accusys/models/facenet512.mlpackage"
|
||||
},
|
||||
"output_file": "{file_uuid}.face.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"asr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "whisper",
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_whisper",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model",
|
||||
"{model_size}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_size": "base"
|
||||
},
|
||||
"output_file": "{file_uuid}.asr.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "whisper",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/asr_processor_simplified.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--model",
|
||||
"{model_size}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"output_file": "{file_uuid}.asr.json",
|
||||
"timeout": 7200
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "whisper"
|
||||
}
|
||||
},
|
||||
"asrx": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/asrx_swift",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/asrx_processor.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"ocr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_ocr",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.ocr.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "tesseract",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/ocr_processor.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.ocr.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"face_trace": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_store_traced_faces",
|
||||
"args": [
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--min-trace-len",
|
||||
"{min_trace_len}",
|
||||
"--min-confidence",
|
||||
"{min_confidence}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"min_trace_len": 0,
|
||||
"min_confidence": 0.0
|
||||
},
|
||||
"output_file": "{file_uuid}.face_traced.json",
|
||||
"timeout": 600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/store_traced_faces.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--face-json",
|
||||
"{face_json}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.face_traced.json",
|
||||
"timeout": 1200
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"scene_vlm_summary": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_scene_vlm",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--llm-url",
|
||||
"{llm_url}",
|
||||
"--max-tokens",
|
||||
"{max_tokens}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"max_tokens": 900
|
||||
},
|
||||
"output_file": "{file_uuid}.scene_vlm.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/scene_vlm_summary.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--llm-url",
|
||||
"{llm_url}",
|
||||
"--max-tokens",
|
||||
"{max_tokens}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"max_tokens": 900
|
||||
},
|
||||
"output_file": "{file_uuid}.scene_vlm.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it"
|
||||
}
|
||||
},
|
||||
"tkg": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_tkg",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.tkg.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/build_tkg.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.tkg.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"cut": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_cut",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--min-scene-duration",
|
||||
"{min_scene_duration}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"use_ffmpeg": true,
|
||||
"min_scene_duration": 0.5
|
||||
},
|
||||
"output_file": "{file_uuid}.cut.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/cut_detector.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.cut.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"video_path": "Full path to video file",
|
||||
"output_path": "Full path to output JSON file",
|
||||
"output_dir": "Output directory (default: /Users/accusys/momentry/output)",
|
||||
"file_uuid": "Video file UUID",
|
||||
"face_json": "Path to face.json file"
|
||||
},
|
||||
"environment": {
|
||||
"MOMENTRY_OUTPUT_DIR": "/Users/accusys/momentry/output",
|
||||
"MOMENTRY_SCRIPTS_DIR": "tools/script/",
|
||||
"MOMENTRY_CLI_DIR": "tools/cli/",
|
||||
"MOMENTRY_PYTHON_PATH": "/opt/homebrew/bin/python3.11",
|
||||
"DATABASE_SCHEMA": "public",
|
||||
"DATABASE_URL": "postgres://accusys@localhost:5432/momentry",
|
||||
"REDIS_URL": "redis://:accusys@localhost:6379"
|
||||
},
|
||||
"models": {
|
||||
"whisper": {
|
||||
"description": "OpenAI Whisper ASR model",
|
||||
"sizes": [
|
||||
"tiny",
|
||||
"base",
|
||||
"small",
|
||||
"medium",
|
||||
"large",
|
||||
"large-v3"
|
||||
],
|
||||
"default_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"mediapipe": {
|
||||
"description": "MediaPipe Pose estimation",
|
||||
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task",
|
||||
"complexity_levels": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"default_complexity": 2
|
||||
},
|
||||
"facenet": {
|
||||
"description": "FaceNet 512D embedding model",
|
||||
"model_path": "/Users/accusys/models/facenet512.mlpackage"
|
||||
},
|
||||
"gemma-4-12b-it": {
|
||||
"description": "Gemma 4 12B instruct model for VLM/LLM",
|
||||
"model_path": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf",
|
||||
"mmproj_path": "/Users/accusys/models/mmproj-F16.gguf",
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions"
|
||||
},
|
||||
"embeddinggemma-300m": {
|
||||
"description": "Embedding Gemma 300M for vector embeddings",
|
||||
"model_path": "/Users/accusys/models/embeddinggemma-300M-Q8_0.gguf",
|
||||
"embedding_url": "http://localhost:11436/embed"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"version": "3.0",
|
||||
"description": "Processor configuration - CLI tools (rust/swift) prioritized",
|
||||
"priority_policy": "rust/swift CLI (priority 0) > python (priority 1+)",
|
||||
"last_updated": "2026-09-27"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,603 @@
|
||||
{
|
||||
"processor_config": {
|
||||
"pose": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_pose",
|
||||
"args": [
|
||||
"--video",
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_pose",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "mediapipe",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/pose_processor_mediapipe.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model-complexity",
|
||||
"{model_complexity}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_complexity": 2,
|
||||
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task"
|
||||
},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "yolov8-pose",
|
||||
"priority": 3,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/pose_processor_yolov8.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--model",
|
||||
"{model_file}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_file": "yolov8n-pose.pt"
|
||||
},
|
||||
"output_file": "{file_uuid}.pose.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"face": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_face",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.face.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "facenet",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/face_detector.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model",
|
||||
"{model_name}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_name": "facenet",
|
||||
"model_path": "/Users/accusys/models/facenet512.mlpackage"
|
||||
},
|
||||
"output_file": "{file_uuid}.face.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"asr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "whisper",
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_whisper",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--model",
|
||||
"{model_size}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_size": "base"
|
||||
},
|
||||
"output_file": "{file_uuid}.asr.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "whisper",
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/asr_processor_simplified.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--model",
|
||||
"{model_size}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"model_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"output_file": "{file_uuid}.asr.json",
|
||||
"timeout": 7200
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "whisper"
|
||||
}
|
||||
},
|
||||
"asrx": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/asrx_swift",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/asrx_processor.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.asrx.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"ocr": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "swift",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "scripts/swift_processors/.build/release/swift_ocr",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.ocr.json",
|
||||
"timeout": 3600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "tesseract",
|
||||
"priority": 2,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/ocr_processor.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.ocr.json",
|
||||
"timeout": 3600
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "swift",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"face_trace": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_store_traced_faces",
|
||||
"args": [
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--min-trace-len",
|
||||
"{min_trace_len}",
|
||||
"--min-confidence",
|
||||
"{min_confidence}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"min_trace_len": 0,
|
||||
"min_confidence": 0.0
|
||||
},
|
||||
"output_file": "{file_uuid}.face_traced.json",
|
||||
"timeout": 600
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/store_traced_faces.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--face-json",
|
||||
"{face_json}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.face_traced.json",
|
||||
"timeout": 1200
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"scene_vlm_summary": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_scene_vlm",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--llm-url",
|
||||
"{llm_url}",
|
||||
"--max-tokens",
|
||||
"{max_tokens}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"max_tokens": 900
|
||||
},
|
||||
"output_file": "{file_uuid}.scene_vlm.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it",
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/scene_vlm_summary.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}",
|
||||
"--llm-url",
|
||||
"{llm_url}",
|
||||
"--max-tokens",
|
||||
"{max_tokens}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions",
|
||||
"max_tokens": 900
|
||||
},
|
||||
"output_file": "{file_uuid}.scene_vlm.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": "gemma-4-12b-it"
|
||||
}
|
||||
},
|
||||
"tkg": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_tkg",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.tkg.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/build_tkg.py",
|
||||
"args": [
|
||||
"--file-uuid",
|
||||
"{file_uuid}",
|
||||
"--output-dir",
|
||||
"{output_dir}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.tkg.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "python",
|
||||
"model": null
|
||||
}
|
||||
},
|
||||
"cut": {
|
||||
"implementations": [
|
||||
{
|
||||
"tool": "rust",
|
||||
"model": null,
|
||||
"priority": 0,
|
||||
"enabled": true,
|
||||
"command": {
|
||||
"executable": "tools/cli/rust/target/release/rust_cut",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}",
|
||||
"--min-scene-duration",
|
||||
"{min_scene_duration}"
|
||||
]
|
||||
},
|
||||
"parameters": {
|
||||
"use_ffmpeg": true,
|
||||
"min_scene_duration": 0.5
|
||||
},
|
||||
"output_file": "{file_uuid}.cut.json",
|
||||
"timeout": 1800
|
||||
},
|
||||
{
|
||||
"tool": "python",
|
||||
"model": null,
|
||||
"priority": 1,
|
||||
"enabled": false,
|
||||
"command": {
|
||||
"executable": "/opt/homebrew/bin/python3.11",
|
||||
"script": "scripts/cut_detector.py",
|
||||
"args": [
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{file_uuid}"
|
||||
]
|
||||
},
|
||||
"parameters": {},
|
||||
"output_file": "{file_uuid}.cut.json",
|
||||
"timeout": 1800
|
||||
}
|
||||
],
|
||||
"default": {
|
||||
"tool": "rust",
|
||||
"model": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
"video_path": "Full path to video file",
|
||||
"output_path": "Full path to output JSON file",
|
||||
"output_dir": "Output directory (default: /Users/accusys/momentry/output)",
|
||||
"file_uuid": "Video file UUID",
|
||||
"face_json": "Path to face.json file"
|
||||
},
|
||||
"environment": {
|
||||
"MOMENTRY_OUTPUT_DIR": "/Users/accusys/momentry/output",
|
||||
"MOMENTRY_SCRIPTS_DIR": "tools/script/",
|
||||
"MOMENTRY_CLI_DIR": "tools/cli/",
|
||||
"MOMENTRY_PYTHON_PATH": "/opt/homebrew/bin/python3.11",
|
||||
"DATABASE_SCHEMA": "public",
|
||||
"DATABASE_URL": "postgres://accusys@localhost:5432/momentry",
|
||||
"REDIS_URL": "redis://:accusys@localhost:6379"
|
||||
},
|
||||
"models": {
|
||||
"whisper": {
|
||||
"description": "OpenAI Whisper ASR model",
|
||||
"sizes": [
|
||||
"tiny",
|
||||
"base",
|
||||
"small",
|
||||
"medium",
|
||||
"large",
|
||||
"large-v3"
|
||||
],
|
||||
"default_size": "large-v3",
|
||||
"model_dir": "/Users/accusys/models/whisper-small-mlx"
|
||||
},
|
||||
"mediapipe": {
|
||||
"description": "MediaPipe Pose estimation",
|
||||
"model_path": "/Users/accusys/models/mediapipe/pose_landmarker_heavy.task",
|
||||
"complexity_levels": [
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
"default_complexity": 2
|
||||
},
|
||||
"facenet": {
|
||||
"description": "FaceNet 512D embedding model",
|
||||
"model_path": "/Users/accusys/models/facenet512.mlpackage"
|
||||
},
|
||||
"gemma-4-12b-it": {
|
||||
"description": "Gemma 4 12B instruct model for VLM/LLM",
|
||||
"model_path": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf",
|
||||
"mmproj_path": "/Users/accusys/models/mmproj-F16.gguf",
|
||||
"llm_url": "http://localhost:8080/v1/chat/completions"
|
||||
},
|
||||
"embeddinggemma-300m": {
|
||||
"description": "Embedding Gemma 300M for vector embeddings",
|
||||
"model_path": "/Users/accusys/models/embeddinggemma-300M-Q8_0.gguf",
|
||||
"embedding_url": "http://localhost:11436/embed"
|
||||
}
|
||||
},
|
||||
"metadata": {
|
||||
"version": "3.0",
|
||||
"description": "Processor configuration - CLI tools (rust/swift) prioritized",
|
||||
"priority_policy": "rust/swift CLI (priority 0) > python (priority 1+)",
|
||||
"last_updated": "2026-09-27"
|
||||
},
|
||||
"processors": {
|
||||
"FACE": {
|
||||
"tools": [
|
||||
{
|
||||
"name": "rust_face_processor",
|
||||
"priority": 0,
|
||||
"command": "tools/cli/rust/target/release/rust_face_processor",
|
||||
"args": [
|
||||
"--video",
|
||||
"{video_path}",
|
||||
"--output",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{uuid}",
|
||||
"--sample-interval",
|
||||
"{sample_interval}",
|
||||
"--model",
|
||||
"models/facenet_vggface2.onnx"
|
||||
],
|
||||
"enabled": true
|
||||
},
|
||||
{
|
||||
"name": "python_face_processor",
|
||||
"priority": 1,
|
||||
"command": "python3",
|
||||
"args": [
|
||||
"scripts/face_processor.py",
|
||||
"{video_path}",
|
||||
"{output_path}",
|
||||
"--uuid",
|
||||
"{uuid}",
|
||||
"--sample-interval",
|
||||
"{sample_interval}",
|
||||
"--model",
|
||||
"models/facenet_vggface2.onnx",
|
||||
"--backend",
|
||||
"rust"
|
||||
],
|
||||
"enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# Production Environment Configuration
|
||||
# Used by: momentry binary on port 3002
|
||||
#
|
||||
# This file extracts production-specific variables from .env
|
||||
# Startup scripts must export these variables for Python subprocess inheritance
|
||||
#
|
||||
# ⚠️ PATH CONFIGURATION
|
||||
# All paths are relative to user home directory by default.
|
||||
# Set environment variables if you need custom paths.
|
||||
|
||||
# Server Configuration
|
||||
MOMENTRY_SERVER_PORT=3002
|
||||
MOMENTRY_REDIS_PREFIX=momentry:
|
||||
|
||||
# Database Schema
|
||||
DATABASE_SCHEMA=public
|
||||
|
||||
# Output Directory (CRITICAL for Python scripts)
|
||||
# Default: $HOME/momentry/output
|
||||
# Uncomment and set if you need a custom path:
|
||||
# MOMENTRY_OUTPUT_DIR=/custom/path/to/output
|
||||
|
||||
# Backup Directory
|
||||
# Default: $HOME/momentry/backup/momentry
|
||||
# Uncomment and set if you need a custom path:
|
||||
# MOMENTRY_BACKUP_DIR=/custom/path/to/backup
|
||||
|
||||
# Storage
|
||||
# Default: $HOME/momentry/var/sftpgo/data
|
||||
# Uncomment and set if you need a custom path:
|
||||
# MOMENTRY_STORAGE_ROOT=/custom/path/to/storage
|
||||
|
||||
# Python Path
|
||||
MOMENTRY_PYTHON_PATH=/opt/homebrew/bin/python3.11
|
||||
|
||||
# Logging
|
||||
RUST_LOG=debug
|
||||
MOMENTRY_LOG_LEVEL=debug
|
||||
|
||||
# Worker Configuration
|
||||
MOMENTRY_WORKER_ENABLED=true
|
||||
MOMENTRY_MAX_CONCURRENT=6
|
||||
MOMENTRY_POLL_INTERVAL=10
|
||||
MOMENTRY_WORKER_BATCH_SIZE=5
|
||||
MOMENTRY_FORCE_RETRY=true
|
||||
|
||||
# TMDb Integration
|
||||
TMDB_API_KEY=e9cde52197f6f8df4d9db99da93db1fb
|
||||
MOMENTRY_TMDB_PROBE_ENABLED=true
|
||||
@@ -0,0 +1,134 @@
|
||||
# Search Scoring Improvement: Score-based Merge for search/smart
|
||||
|
||||
## 發現者
|
||||
WordPress 前端專案(search-chat 頁面)
|
||||
|
||||
## 問題描述
|
||||
|
||||
### 症狀
|
||||
跨語言搜尋結果不一致:
|
||||
- 搜尋「槍」(中文)→ 回傳無關結果(如「讓T-shirt」、「靠直的後製神器」)
|
||||
- 搜尋 `gun`(英文)→ 回傳 "So where's your gun?"、"He has a gun"
|
||||
- 兩者應該找到相同語意主題的結果(武器相關片段),但實際回傳完全不同的集合
|
||||
|
||||
### 影響範圍
|
||||
`GET/POST /api/v1/search/smart` endpoint
|
||||
|
||||
## 根因分析
|
||||
|
||||
### 1. Qdrant 語意搜尋本身是正確的
|
||||
|
||||
直接查詢 Qdrant 驗證:
|
||||
|
||||
```
|
||||
cos(search_query: 槍, search_document: "So where's your gun?") = 0.6905
|
||||
cos(search_query: 槍, search_document: "這是一把槍") = 0.8256
|
||||
cos(search_query: gun, search_document: "So where's your gun?") = 0.7435
|
||||
```
|
||||
|
||||
**embedding model (EmbeddingGemma-300m) 的 cross-lingual 對齊正常。**
|
||||
|
||||
### 2. 問題在 RRF 合併邏輯
|
||||
|
||||
`search/smart` 用 **RRF (Reciprocal Rank Fusion)** 合併三組結果:
|
||||
|
||||
```rust
|
||||
let rrf_k = 60.0;
|
||||
// RRF 貢獻 = 1 / (60 + rank + 1)
|
||||
// Semantic rank 0: 貢獻 1/61 = 0.016
|
||||
// Keyword rank 0: 貢獻 1/61 = 0.016
|
||||
```
|
||||
|
||||
RRF 的權重只看**排名位置**,不看**實際相似度分數**。
|
||||
- cosine similarity = 0.69 的語意結果 → RRF 貢獻 0.016
|
||||
- ILIKE 隨便撈到的 keyword 匹配 → RRF 貢獻也是 0.016
|
||||
- 兩者在排序中權重完全相等
|
||||
|
||||
### 3. Keyword (ILIKE) 對跨語言有害
|
||||
|
||||
- `ILIKE '%槍%'` 只找到中文文字包含「槍」的 chunks
|
||||
- `ILIKE '%gun%'` 只找到英文文字包含 "gun" 的 chunks
|
||||
- 這兩組結果在語意上完全不同,卻透過 RRF 被提升到與語意結果同權重
|
||||
- 導致「槍」和 `gun` 的結果各自被自己的 ILIKE 匹配汙染
|
||||
|
||||
## 建議方案
|
||||
|
||||
### 核心原則
|
||||
向量高信心度時應該優先。
|
||||
|
||||
### 合併方式
|
||||
|
||||
將 RRF 改為 score-based merge,各來源分數定義:
|
||||
|
||||
| 來源 | 分數 | 說明 |
|
||||
|---|---|---|
|
||||
| **Semantic (Qdrant)** | `cosine_similarity` (0~1) | 原始 Qdrant 分數,不加權 |
|
||||
| **Identity** | 固定 `0.85` | 人名精準匹配,維持高度信心 |
|
||||
| **Keyword (ILIKE)** | 固定 `0.5` | 降權至低分,只作為語意找不到時的補底 |
|
||||
|
||||
最終分數 = `max(semantic, keyword, identity)`
|
||||
依最終分數降冪排序。
|
||||
|
||||
### 預期效果
|
||||
|
||||
| 情況 | 排序行為 |
|
||||
|---|---|
|
||||
| cosine > 0.5 的語意結果 | 排在 keyword 前面 ✅ |
|
||||
| cosine 在 0.3~0.5 | 與 keyword 穿插(都不太確定,合理) |
|
||||
| cosine < 0.3 | keyword 補底(語意沒找到,靠文字比對) |
|
||||
| 跨語言查詢(槍 vs gun) | 各自的高分 cross-lingual 結果優先呈現 ✅ |
|
||||
|
||||
### 不建議的方案
|
||||
|
||||
- **不要用 weight-based average**(如 `0.7*semantic + 0.3*keyword`):兩種模型的 score scale 不同,加權無法通用
|
||||
- **不要保留 RRF 只調 k 值**:k 值調再高也無法區分品質,只能稀釋影響
|
||||
|
||||
## 修改範圍
|
||||
|
||||
### 檔案
|
||||
`src/api/search.rs` 中的 `smart_search()` 函數
|
||||
|
||||
### 需要修改的區塊
|
||||
|
||||
1. **移除 RRF 常數**(`rrf_k = 60.0`)
|
||||
2. **Semantic 結果**:保留 Qdrant 回傳的 `score`(已在 `h.score as f64` 取得)
|
||||
3. **Keyword 結果**:固定設為 `0.5_f64`(忽略原本 `combined_score`)
|
||||
4. **Identity 結果**:固定設為 `0.85_f64`(忽略原本硬編碼的 `0.85` 但保留值)
|
||||
5. **排序邏輯**:改為 `max(semantic, keyword, identity)` 降冪
|
||||
6. **輸出 similarity**:改為回傳最終分數,而非 `rrf_score`
|
||||
|
||||
### 注意事項
|
||||
|
||||
- Qdrant 回傳的 `score` 是 `f32`,需 cast 為 `f64`
|
||||
- `keyword_results` 的 `combined_score` 實際上是 `1.0`(`search_bm25` 固定值),不應使用
|
||||
- 修改後需 **`cargo build --release`** 再重啟 server
|
||||
|
||||
## 驗證測試
|
||||
|
||||
### 手動測試
|
||||
|
||||
```bash
|
||||
# 1. 槍 vs gun 應該回傳相似主題
|
||||
curl -X POST 'http://localhost:3002/api/v1/search/smart' \
|
||||
-H 'X-API-Key: {KEY}' -H 'Content-Type: application/json' \
|
||||
-d '{"query":"槍","limit":10}'
|
||||
|
||||
curl -X POST 'http://localhost:3002/api/v1/search/smart' \
|
||||
-H 'X-API-Key: {KEY}' -H 'Content-Type: application/json' \
|
||||
-d '{"query":"gun","limit":10}'
|
||||
|
||||
# 2. 確認 similarity 值為實際 cosine (e.g. 0.6~0.9) 而非 RRF 值 (~0.016)
|
||||
```
|
||||
|
||||
### 預期結果
|
||||
|
||||
| Query | Top 結果應包含 |
|
||||
|---|---|
|
||||
| `槍` | gun 相關片段、「這是一把槍」、武器相關語意匹配 |
|
||||
| `gun` | 與 `槍` 主題一致(都是武器) |
|
||||
| `車` / `car` | 行車相關片段,非姓名含「車」的人物 |
|
||||
| `So where's your gun?` | 自身為 top-1(self-match cosine ≈ 1.0) |
|
||||
|
||||
## 附錄:前端處理
|
||||
|
||||
WordPress 側 (`snippet #37`) 已配合修正:`mode=semantic` 不再疊加 `search/universal`(ILIKE)結果,僅回傳 `search/smart` 的輸出。這部分無需 backend 配合。
|
||||
@@ -0,0 +1,598 @@
|
||||
# Pipeline Queue 集成分析报告
|
||||
|
||||
**日期**: 2026-10-11
|
||||
**分析范围**: Pipeline 处理流程 + Queue 系统集成
|
||||
**状态**: 分析报告
|
||||
|
||||
---
|
||||
|
||||
## 📊 当前 Pipeline 架构
|
||||
|
||||
### 1. Pipeline 端点
|
||||
|
||||
| 端点 | 功能 | 处理时间 | 状态 |
|
||||
|------|------|:---------:|:----:|
|
||||
| `/api/v1/file/:uuid/store-asrx` | 存储 ASRX chunks | ~1s | ✅ 同步 |
|
||||
| `/api/v1/file/:uuid/rule1` | Rule 1 切片 | ~2s | ✅ 同步 |
|
||||
| `/api/v1/file/:uuid/vectorize` | 向量化 | ~10-60s | ✅ 同步 |
|
||||
| `/api/v1/file/:uuid/phase1` | Phase 1 打包 | ~2s | ✅ 同步 |
|
||||
| `/api/v1/file/:uuid/complete` | 标记完成 | ~1s | ✅ 同步 |
|
||||
|
||||
---
|
||||
|
||||
### 2. 处理流程
|
||||
|
||||
```
|
||||
Video Registration
|
||||
↓
|
||||
ASR Processing (外部,~10-30min)
|
||||
↓
|
||||
ASRX Processing (~1-2min)
|
||||
↓
|
||||
store_asrx_chunks (同步,~1s)
|
||||
↓
|
||||
execute_rule1 (同步,~2s)
|
||||
↓
|
||||
vectorize_chunks (同步,~10-60s)
|
||||
↓
|
||||
phase1_pack (同步,~2s)
|
||||
↓
|
||||
mark_complete (同步,~1s)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 当前问题
|
||||
|
||||
### 1. 同步阻塞
|
||||
|
||||
**问题**:
|
||||
- 所有 pipeline 操作都是同步的
|
||||
- 长时间操作(如 vectorize)会阻塞 API
|
||||
- 用户等待时间长
|
||||
- 无法处理大量并发请求
|
||||
|
||||
**影响**:
|
||||
- API 响应时间慢(最长 60 秒)
|
||||
- 用户体验差
|
||||
- 系统吞吐量低
|
||||
|
||||
---
|
||||
|
||||
### 2. 无重试机制
|
||||
|
||||
**问题**:
|
||||
- 失败后无法自动重试
|
||||
- 需要手动重新执行
|
||||
- 无错误追踪
|
||||
|
||||
**影响**:
|
||||
- 运维成本高
|
||||
- 数据不一致
|
||||
|
||||
---
|
||||
|
||||
### 3. 无进度追踪
|
||||
|
||||
**问题**:
|
||||
- 无法追踪处理进度
|
||||
- 用户不知道任务状态
|
||||
|
||||
**影响**:
|
||||
- 用户体验差
|
||||
- 无法调试
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Queue 集成方案
|
||||
|
||||
### 方案 1: 将 Pipeline 操作转为 Command Queue
|
||||
|
||||
**架构**:
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────┐
|
||||
│ Pipeline Command Queue │
|
||||
├─────────────────────────────────────────────────┤
|
||||
│ Queue: pipeline.commands (P1 - High) │
|
||||
│ │
|
||||
│ Commands: │
|
||||
│ ├─ StoreASRX (P1, ~1s) │
|
||||
│ ├─ ExecuteRule1 (P2, ~2s) │
|
||||
│ ├─ VectorizeChunks (P3, ~10-60s) │
|
||||
│ ├─ Phase1Pack (P2, ~2s) │
|
||||
│ └─ MarkComplete (P1, ~1s) │
|
||||
└─────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────┐
|
||||
│ Pipeline Workers │
|
||||
├─────────────────────────────────────────────────┤
|
||||
│ Worker Pool: 3-5 workers │
|
||||
│ - 每个文件独立处理 │
|
||||
│ - 支持并行处理多个文件 │
|
||||
│ - 自动重试 (max 3) │
|
||||
└─────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### 方案 2: 具体实现
|
||||
|
||||
#### 2.1 Command Types
|
||||
|
||||
```typescript
|
||||
// 新增 Pipeline Command Types
|
||||
pub enum PipelineCommandType {
|
||||
StoreASRX,
|
||||
ExecuteRule1,
|
||||
VectorizeChunks,
|
||||
Phase1Pack,
|
||||
MarkComplete,
|
||||
ExecuteRule3, // 新增
|
||||
ReindexEmbeddings, // 新增
|
||||
}
|
||||
|
||||
impl PipelineCommandType {
|
||||
pub fn default_priority(&self) -> CommandPriority {
|
||||
match self {
|
||||
Self::MarkComplete => CommandPriority::Critical,
|
||||
Self::StoreASRX => CommandPriority::High,
|
||||
Self::ExecuteRule1 => CommandPriority::Normal,
|
||||
Self::VectorizeChunks => CommandPriority::Low, // 长时间任务
|
||||
Self::Phase1Pack => CommandPriority::Normal,
|
||||
Self::ExecuteRule3 => CommandPriority::Normal,
|
||||
Self::ReindexEmbeddings => CommandPriority::Low,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn estimated_duration(&self) -> std::time::Duration {
|
||||
match self {
|
||||
Self::StoreASRX => std::time::Duration::from_secs(5),
|
||||
Self::ExecuteRule1 => std::time::Duration::from_secs(10),
|
||||
Self::VectorizeChunks => std::time::Duration::from_secs(120), // 2 分钟
|
||||
Self::Phase1Pack => std::time::Duration::from_secs(10),
|
||||
Self::MarkComplete => std::time::Duration::from_secs(5),
|
||||
Self::ExecuteRule3 => std::time::Duration::from_secs(30),
|
||||
Self::ReindexEmbeddings => std::time::Duration::from_secs(120),
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 2.2 Pipeline Service
|
||||
|
||||
```rust
|
||||
// src/core/command/pipeline/mod.rs
|
||||
|
||||
use crate::core::command::error::{CommandError, CommandResult};
|
||||
use crate::core::command::queue::CommandQueue;
|
||||
use crate::core::command::types::{Command, CommandType, CommandPriority};
|
||||
use serde_json::json;
|
||||
|
||||
pub struct PipelineService {
|
||||
queue: CommandQueue,
|
||||
}
|
||||
|
||||
impl PipelineService {
|
||||
pub fn new(db: sqlx::PgPool) -> Self {
|
||||
Self {
|
||||
queue: CommandQueue::new(db),
|
||||
}
|
||||
}
|
||||
|
||||
/// 提交 ASRX 存储命令
|
||||
pub async fn store_asrx(&self, file_uuid: &str) -> CommandResult<String> {
|
||||
let command = Command::new(
|
||||
CommandType::Internal {
|
||||
category: InternalCommandCategory::PipelineStoreASRX,
|
||||
},
|
||||
json!({
|
||||
"file_uuid": file_uuid,
|
||||
}),
|
||||
)
|
||||
.with_priority(CommandPriority::High);
|
||||
|
||||
self.queue.produce(
|
||||
"pipeline.commands",
|
||||
command,
|
||||
Default::default(),
|
||||
).await
|
||||
}
|
||||
|
||||
/// 提交 Rule1 执行命令
|
||||
pub async fn execute_rule1(&self, file_uuid: &str) -> CommandResult<String> {
|
||||
let command = Command::new(
|
||||
CommandType::Internal {
|
||||
category: InternalCommandCategory::PipelineExecuteRule1,
|
||||
},
|
||||
json!({
|
||||
"file_uuid": file_uuid,
|
||||
}),
|
||||
)
|
||||
.with_priority(CommandPriority::Normal);
|
||||
|
||||
self.queue.produce(
|
||||
"pipeline.commands",
|
||||
command,
|
||||
Default::default(),
|
||||
).await
|
||||
}
|
||||
|
||||
/// 提交向量化命令
|
||||
pub async fn vectorize_chunks(&self, file_uuid: &str) -> CommandResult<String> {
|
||||
let command = Command::new(
|
||||
CommandType::Internal {
|
||||
category: InternalCommandCategory::PipelineVectorize,
|
||||
},
|
||||
json!({
|
||||
"file_uuid": file_uuid,
|
||||
}),
|
||||
)
|
||||
.with_priority(CommandPriority::Low); // 长时间任务,低优先级
|
||||
|
||||
self.queue.produce(
|
||||
"pipeline.commands",
|
||||
command,
|
||||
Default::default(),
|
||||
).await
|
||||
}
|
||||
|
||||
/// 提交完整 pipeline 流程
|
||||
pub async fn submit_full_pipeline(&self, file_uuid: &str) -> CommandResult<Vec<String>> {
|
||||
let mut command_ids = Vec::new();
|
||||
|
||||
// 按顺序提交命令(后续会按 file_uuid 分组处理)
|
||||
command_ids.push(self.store_asrx(file_uuid).await?);
|
||||
command_ids.push(self.execute_rule1(file_uuid).await?);
|
||||
command_ids.push(self.vectorize_chunks(file_uuid).await?);
|
||||
command_ids.push(self.phase1_pack(file_uuid).await?);
|
||||
command_ids.push(self.mark_complete(file_uuid).await?);
|
||||
|
||||
Ok(command_ids)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 2.3 Pipeline Worker
|
||||
|
||||
```rust
|
||||
// src/core/command/pipeline/worker.rs
|
||||
|
||||
use super::*;
|
||||
use crate::core::pipeline;
|
||||
use crate::core::db::postgres_db::PostgresDb;
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
pub struct PipelineWorker {
|
||||
worker_id: String,
|
||||
db: sqlx::PgPool,
|
||||
}
|
||||
|
||||
impl PipelineWorker {
|
||||
pub fn new(db: sqlx::PgPool) -> Self {
|
||||
Self {
|
||||
worker_id: uuid::Uuid::new_v4().to_string(),
|
||||
db,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn start(&self) -> CommandResult<()> {
|
||||
info!(worker_id = %self.worker_id, "Pipeline worker started");
|
||||
|
||||
loop {
|
||||
match self.process_commands().await {
|
||||
Ok(count) => {
|
||||
debug!(count = count, "Processed pipeline commands");
|
||||
}
|
||||
Err(e) => {
|
||||
error!(error = ?e, "Error processing pipeline commands");
|
||||
}
|
||||
}
|
||||
|
||||
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
||||
}
|
||||
}
|
||||
|
||||
async fn process_commands(&self) -> CommandResult<usize> {
|
||||
let queue = CommandQueue::new(self.db.clone());
|
||||
|
||||
let messages = queue.consume(
|
||||
"pipeline.commands",
|
||||
crate::core::command::types::ConsumeOptions {
|
||||
consumer_group: "pipeline_workers".to_string(),
|
||||
consumer_id: self.worker_id.clone(),
|
||||
max_messages: 5,
|
||||
..Default::default()
|
||||
},
|
||||
).await?;
|
||||
|
||||
let count = messages.len();
|
||||
|
||||
for message in messages {
|
||||
if let Err(e) = self.handle_command(&message).await {
|
||||
error!(error = ?e, "Pipeline command failed");
|
||||
// 记录错误但继续处理其他命令
|
||||
}
|
||||
}
|
||||
|
||||
Ok(count)
|
||||
}
|
||||
|
||||
async fn handle_command(&self, message: &crate::core::command::types::CommandMessage) -> CommandResult<()> {
|
||||
let command = &message.command;
|
||||
|
||||
// 提取 file_uuid
|
||||
let file_uuid = command.payload.get("file_uuid")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or_else(|| CommandError::MissingPayload("file_uuid".to_string()))?;
|
||||
|
||||
info!(
|
||||
command_id = %message.message_id,
|
||||
file_uuid = %file_uuid,
|
||||
"Processing pipeline command"
|
||||
);
|
||||
|
||||
let start = std::time::Instant::now();
|
||||
|
||||
// 根据命令类型执行操作
|
||||
let result = match command.command_type {
|
||||
CommandType::Internal { category: InternalCommandCategory::PipelineStoreASRX } => {
|
||||
self.execute_store_asrx(file_uuid).await
|
||||
}
|
||||
CommandType::Internal { category: InternalCommandCategory::PipelineExecuteRule1 } => {
|
||||
self.execute_rule1(file_uuid).await
|
||||
}
|
||||
CommandType::Internal { category: InternalCommandCategory::PipelineVectorize } => {
|
||||
self.execute_vectorize(file_uuid).await
|
||||
}
|
||||
CommandType::Internal { category: InternalCommandCategory::PipelinePhase1Pack } => {
|
||||
self.execute_phase1(file_uuid).await
|
||||
}
|
||||
CommandType::Internal { category: InternalCommandCategory::PipelineMarkComplete } => {
|
||||
self.execute_mark_complete(file_uuid).await
|
||||
}
|
||||
_ => {
|
||||
Err(CommandError::InvalidCommandType(format!("{:?}", command.command_type)))
|
||||
}
|
||||
};
|
||||
|
||||
let duration_ms = start.elapsed().as_millis() as i64;
|
||||
|
||||
// 记录结果
|
||||
match result {
|
||||
Ok(_) => {
|
||||
info!(
|
||||
command_id = %message.message_id,
|
||||
file_uuid = %file_uuid,
|
||||
duration_ms = duration_ms,
|
||||
"Pipeline command completed"
|
||||
);
|
||||
}
|
||||
Err(ref e) => {
|
||||
error!(
|
||||
command_id = %message.message_id,
|
||||
file_uuid = %file_uuid,
|
||||
duration_ms = duration_ms,
|
||||
error = ?e,
|
||||
"Pipeline command failed"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
async fn execute_store_asrx(&self, file_uuid: &str) -> CommandResult<()> {
|
||||
let db = PostgresDb::new(&crate::core::config::DATABASE_URL).await?;
|
||||
pipeline::store_asrx_chunks(&db, file_uuid).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn execute_rule1(&self, file_uuid: &str) -> CommandResult<()> {
|
||||
let db = PostgresDb::new(&crate::core::config::DATABASE_URL).await?;
|
||||
pipeline::execute_rule1(&db, file_uuid).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn execute_vectorize(&self, file_uuid: &str) -> CommandResult<()> {
|
||||
pipeline::vectorize_chunks(file_uuid).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn execute_phase1(&self, file_uuid: &str) -> CommandResult<()> {
|
||||
pipeline::run_phase1(file_uuid).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn execute_mark_complete(&self, file_uuid: &str) -> CommandResult<()> {
|
||||
let db = PostgresDb::new(&crate::core::config::DATABASE_URL).await?;
|
||||
pipeline::mark_complete(&db, file_uuid).await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### 2.4 更新 API 端点
|
||||
|
||||
```rust
|
||||
// src/api/pipeline.rs (修改)
|
||||
|
||||
use crate::core::command::pipeline::PipelineService;
|
||||
|
||||
async fn handle_store_asrx(
|
||||
Path(uuid): Path<String>,
|
||||
Extension(pipeline_service): Extension<Arc<PipelineService>>,
|
||||
) -> Result<Json<Value>, (axum::http::StatusCode, Json<Value>)> {
|
||||
// 提交到队列,立即返回
|
||||
let command_id = pipeline_service.store_asrx(&uuid).await.map_err(|e| {
|
||||
tracing::error!("Submit store_asrx error: {}", e);
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(json!({"error": e.to_string()})),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(Json(json!({
|
||||
"success": true,
|
||||
"message": "ASRX store command queued",
|
||||
"file_uuid": uuid,
|
||||
"command_id": command_id,
|
||||
"status": "queued"
|
||||
})))
|
||||
}
|
||||
|
||||
async fn handle_vectorize(
|
||||
Path(uuid): Path<String>,
|
||||
Extension(pipeline_service): Extension<Arc<PipelineService>>,
|
||||
) -> Result<Json<Value>, (axum::http::StatusCode, Json<Value>)> {
|
||||
// 提交到队列,立即返回
|
||||
let command_id = pipeline_service.vectorize_chunks(&uuid).await.map_err(|e| {
|
||||
tracing::error!("Submit vectorize error: {}", e);
|
||||
(
|
||||
axum::http::StatusCode::INTERNAL_SERVER_ERROR,
|
||||
Json(json!({"error": e.to_string()})),
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(Json(json!({
|
||||
"success": true,
|
||||
"message": "Vectorization command queued (long-running task)",
|
||||
"file_uuid": uuid,
|
||||
"command_id": command_id,
|
||||
"status": "queued",
|
||||
"estimated_duration_sec": 120
|
||||
})))
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 对比分析
|
||||
|
||||
### 性能对比
|
||||
|
||||
| 操作 | 之前(同步) | 之后(队列) | 改进 |
|
||||
|------|:-----------:|:-----------:|:----:|
|
||||
| StoreASRX | ~1s | ~50ms | 20x |
|
||||
| Rule1 | ~2s | ~50ms | 40x |
|
||||
| Vectorize | ~60s | ~50ms | 1200x |
|
||||
| Phase1 | ~2s | ~50ms | 40x |
|
||||
| Complete | ~1s | ~50ms | 20x |
|
||||
|
||||
---
|
||||
|
||||
### 用户体验对比
|
||||
|
||||
**之前**:
|
||||
```
|
||||
POST /api/v1/file/xxx/vectorize
|
||||
↓
|
||||
等待 60 秒
|
||||
↓
|
||||
返回结果
|
||||
```
|
||||
|
||||
**之后**:
|
||||
```
|
||||
POST /api/v1/file/xxx/vectorize
|
||||
↓
|
||||
立即返回(50ms)
|
||||
↓
|
||||
后台处理(120s)
|
||||
↓
|
||||
用户可继续其他操作
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 实施计划
|
||||
|
||||
### Phase 1: 基础队列集成(2 天)
|
||||
|
||||
- [ ] 创建 `InternalCommandCategory` 枚举(Pipeline 相关)
|
||||
- [ ] 实现 `PipelineService`
|
||||
- [ ] 实现 `PipelineWorker`
|
||||
- [ ] 修改 API 端点
|
||||
- [ ] 测试单个命令
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: 完整流程(2 天)
|
||||
|
||||
- [ ] 实现命令链式调用
|
||||
- [ ] 添加进度追踪
|
||||
- [ ] 添加错误通知
|
||||
- [ ] 测试完整 pipeline
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: 优化(1 天)
|
||||
|
||||
- [ ] 性能测试
|
||||
- [ ] 并发测试
|
||||
- [ ] 监控配置
|
||||
- [ ] 文档更新
|
||||
|
||||
---
|
||||
|
||||
## 📝 数据库更新
|
||||
|
||||
### 新增 InternalCommandCategory
|
||||
|
||||
```sql
|
||||
-- 更新 queue_routes 表
|
||||
INSERT INTO queue_routes (command_type, command_category, queue_name, handler, priority, billing_required) VALUES
|
||||
('internal', 'pipeline_store_asrx', 'pipeline.commands', 'pipeline_worker', 1, false),
|
||||
('internal', 'pipeline_execute_rule1', 'pipeline.commands', 'pipeline_worker', 2, false),
|
||||
('internal', 'pipeline_vectorize', 'pipeline.commands', 'pipeline_worker', 3, false),
|
||||
('internal', 'pipeline_phase1_pack', 'pipeline.commands', 'pipeline_worker', 2, false),
|
||||
('internal', 'pipeline_mark_complete', 'pipeline.commands', 'pipeline_worker', 1, false),
|
||||
('internal', 'pipeline_execute_rule3', 'pipeline.commands', 'pipeline_worker', 2, false),
|
||||
('internal', 'pipeline_reindex_embeddings', 'pipeline.commands', 'pipeline_worker', 3, false)
|
||||
ON CONFLICT (command_type, command_category) DO NOTHING;
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ✅ 预期效果
|
||||
|
||||
### 系统吞吐量
|
||||
|
||||
- **之前**: 1-2 个文件/分钟(同步)
|
||||
- **之后**: 10-20 个文件/分钟(并行)
|
||||
|
||||
---
|
||||
|
||||
### API 响应时间
|
||||
|
||||
- **之前**: 平均 10-60 秒
|
||||
- **之后**: 平均 50 毫秒
|
||||
|
||||
---
|
||||
|
||||
### 用户体验
|
||||
|
||||
- ✅ 立即反馈
|
||||
- ✅ 后台处理
|
||||
- ✅ 进度可追踪
|
||||
- ✅ 错误可恢复
|
||||
|
||||
---
|
||||
|
||||
## 🚀 下一步
|
||||
|
||||
1. **立即实施**: Phase 1 - 基础队列集成
|
||||
2. **测试验证**: 确保所有 pipeline 命令正常工作
|
||||
3. **性能测试**: 验证吞吐量提升
|
||||
4. **监控配置**: 添加 Prometheus 指标
|
||||
|
||||
---
|
||||
|
||||
**Pipeline Queue 集成分析完成!可立即开始实施。**
|
||||
@@ -8,6 +8,6 @@ deploy:
|
||||
@echo "Building WASM doc..."
|
||||
cd ../../md_wasm && wasm-pack build --target no-modules --no-opt 2>&1 | tail -2
|
||||
cp ../../md_wasm/pkg/md_wasm_bg.wasm ../doc_wasm/pkg/
|
||||
cp ../../docs_v1.0/API_WORKSPACE/modules/0*.md ../doc_wasm/modules/
|
||||
cp ../../docs_v1.0/API_WORKSPACE/modules/1*.md ../doc_wasm/modules/
|
||||
@echo " ✅ Updated ../doc_wasm/ (WASM docs)"
|
||||
@echo "Syncing ALL API modules..."
|
||||
cp ../../docs_v1.0/API_WORKSPACE/modules/*.md ../doc_wasm/modules/
|
||||
@echo " ✅ Updated ../doc_wasm/ (WASM docs) - ALL modules included"
|
||||
|
||||
@@ -1,60 +1,208 @@
|
||||
# API Workspace
|
||||
---
|
||||
title: API Documentation Index
|
||||
version: 1.0
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
## Purpose
|
||||
# API Documentation Index
|
||||
|
||||
This directory is the **single source of truth** for all API documentation modules.
|
||||
Generated outputs go to `../GUIDES/` as assembled deliverable documents.
|
||||
Complete API reference for Momentry Core. All endpoints are documented with request/response formats, examples, and error handling.
|
||||
|
||||
## Workflow
|
||||
---
|
||||
|
||||
## 📋 Module Overview
|
||||
|
||||
### Core APIs (01-19)
|
||||
|
||||
| Module | File | Description |
|
||||
|--------|------|-------------|
|
||||
| **01** | [auth.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/01_auth.md) | Authentication - login, logout, JWT, API key |
|
||||
| **02** | [health.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/02_health.md) | Health check endpoints |
|
||||
| **03** | [register.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/03_register.md) | File registration |
|
||||
| **04** | [lookup.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/04_lookup.md) | File lookup and metadata |
|
||||
| **05** | [process.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/05_process.md) | Video processing pipeline |
|
||||
| **06** | [search.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/06_search.md) | Search operations |
|
||||
| **07** | [identity.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/07_identity.md) | Identity management |
|
||||
| **08** | [identity_agent.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/08_identity_agent.md) | Identity agent operations |
|
||||
| **08** | [media.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/08_media.md) | Media access and proxy |
|
||||
| **09** | [tmdb.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/09_tmdb.md) | TMDb integration |
|
||||
| **10** | [pipeline.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/10_pipeline.md) | Pipeline management |
|
||||
| **11** | [error_codes.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/11_error_codes.md) | Error code reference |
|
||||
| **12** | [agent.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/12_agent.md) | Agent API |
|
||||
| **13** | [config.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/13_config.md) | Configuration management |
|
||||
| **14** | [identity_history.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/14_identity_history.md) | Identity history tracking |
|
||||
| **15** | [tkg.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/15_tkg.md) | Temporal Knowledge Graph |
|
||||
| **16** | [workspace.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/16_workspace.md) | Workspace management |
|
||||
| **17** | [progress.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/17_progress.md) | Progress tracking |
|
||||
| **18** | [profile.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/18_profile.md) | File profile and metadata |
|
||||
| **19** | [people_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/19_people_api.md) | People management API |
|
||||
|
||||
---
|
||||
|
||||
### New APIs (20-24)
|
||||
|
||||
| Module | File | Description | Status |
|
||||
|--------|------|-------------|--------|
|
||||
| **20** | [service_management_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/20_service_management_api.md) | Service start/stop/health | ✅ P0 - Critical |
|
||||
| **21** | [monitor_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/21_monitor_api.md) | Queue/Worker/Pipeline monitoring | ✅ P1 - Important |
|
||||
| **22** | [trace_agent_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/22_trace_agent_api.md) | Trace and TKG operations | ✅ P1 - Important |
|
||||
| **23** | [vlm_search_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/23_vlm_search_api.md) | Vision Language Model search | ✅ P1 - Important |
|
||||
| **24** | [pose_appearance_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/24_pose_appearance_api.md) | Pose keypoints and appearance colors | ✅ P2 - Standard |
|
||||
|
||||
---
|
||||
|
||||
### Studio Team Guides (21-26)
|
||||
|
||||
| Module | File | Description |
|
||||
|--------|------|-------------|
|
||||
| **21** | [studio_team_guide.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/21_studio_team_guide.md) | Integration guide for Studio team |
|
||||
| **22** | [studio_pipeline_changes.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/22_studio_pipeline_changes.md) | Pipeline changes documentation |
|
||||
| **23** | [studio_face_group_name_fix.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/23_studio_face_group_name_fix.md) | Face group name fix guide |
|
||||
| **24** | [studio_trace_profile_read_write_bug.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/24_studio_trace_profile_read_write_bug.md) | Trace profile bug documentation |
|
||||
| **25** | [face_filter_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/25_face_filter_api.md) | Face filtering API |
|
||||
| **26** | [trace_thumbnail_regenerate.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/26_trace_thumbnail_regenerate.md) | Thumbnail regeneration |
|
||||
|
||||
---
|
||||
|
||||
### Additional Modules
|
||||
|
||||
| File | Description |
|
||||
|------|-------------|
|
||||
| [scene_vlm_stats_api.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/scene_vlm_stats_api.md) | Scene VLM statistics API |
|
||||
| [99_incomplete.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/99_incomplete.md) | Incomplete features reference |
|
||||
| [_template.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/_template.md) | Documentation template |
|
||||
|
||||
---
|
||||
|
||||
## 🔍 Quick Reference by Category
|
||||
|
||||
### Authentication & Security
|
||||
|
||||
- [Auth API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/01_auth.md) - Login, logout, JWT tokens, API keys
|
||||
|
||||
### File Operations
|
||||
|
||||
- [Register](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/03_register.md) - Register new files
|
||||
- [Lookup](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/04_lookup.md) - File metadata and lookup
|
||||
- [Process](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/05_process.md) - Video processing
|
||||
- [Profile](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/18_profile.md) - File profile
|
||||
|
||||
### Search & Query
|
||||
|
||||
- [Search](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/06_search.md) - General search
|
||||
- [VLM Search](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/23_vlm_search_api.md) - Vision Language Model search
|
||||
- [TKG](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/15_tkg.md) - Temporal Knowledge Graph
|
||||
|
||||
### Identity & People
|
||||
|
||||
- [Identity](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/07_identity.md) - Identity management
|
||||
- [Identity Agent](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/08_identity_agent.md) - Agent operations
|
||||
- [Identity History](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/14_identity_history.md) - History tracking
|
||||
- [People API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/19_people_api.md) - People management
|
||||
- [Trace Agent](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/22_trace_agent_api.md) - Trace operations
|
||||
- [Pose & Appearance](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/24_pose_appearance_api.md) - Pose and appearance data
|
||||
|
||||
### System & Monitoring
|
||||
|
||||
- [Health](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/02_health.md) - Health checks
|
||||
- [Service Management](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/20_service_management_api.md) - Service control
|
||||
- [Monitor](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/21_monitor_api.md) - System monitoring
|
||||
- [Progress](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/17_progress.md) - Progress tracking
|
||||
- [Pipeline](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/10_pipeline.md) - Pipeline management
|
||||
|
||||
### Media & Content
|
||||
|
||||
- [Media](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/08_media.md) - Media access
|
||||
- [TMDb](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/09_tmdb.md) - TMDb integration
|
||||
|
||||
### Configuration & Management
|
||||
|
||||
- [Config](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/13_config.md) - Configuration
|
||||
- [Workspace](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/16_workspace.md) - Workspace management
|
||||
- [Agent](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/12_agent.md) - Agent API
|
||||
|
||||
---
|
||||
|
||||
## 📖 Usage Guidelines
|
||||
|
||||
### Authentication
|
||||
|
||||
Most API endpoints require authentication via API key:
|
||||
|
||||
```bash
|
||||
# 1. Edit a module
|
||||
vim modules/09_tmdb.md
|
||||
|
||||
# 2. Preview the generated output
|
||||
make _build/API_ENDPOINTS.md
|
||||
|
||||
# 3. Check diff against current GUIDES/ content
|
||||
make check
|
||||
|
||||
# 4. Deploy to GUIDES/
|
||||
make deploy
|
||||
|
||||
# 5. Regenerate all
|
||||
make all
|
||||
curl -H "X-API-Key: your-api-key" \
|
||||
http://localhost:3002/api/v1/...
|
||||
```
|
||||
|
||||
## Directory Structure
|
||||
See [Auth API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/01_auth.md) for details.
|
||||
|
||||
```
|
||||
API_WORKSPACE/
|
||||
├── modules/ ← 11 module files (01_auth ... 11_error_codes)
|
||||
├── configs/ ← 7 assembly recipies (.toml)
|
||||
├── narratives/ ← narrative intros for specific output files
|
||||
├── _build/ ← generated output (gitignored)
|
||||
├── Makefile ← build targets
|
||||
├── assemble_docs.sh ← assembly engine
|
||||
└── README.md
|
||||
```
|
||||
### Base URLs
|
||||
|
||||
## Available `make` Targets
|
||||
| Environment | Base URL |
|
||||
|------------|----------|
|
||||
| Production | `http://localhost:3002` |
|
||||
| External | `https://m5api.momentry.ddns.net` |
|
||||
| Development | `http://localhost:3003` |
|
||||
|
||||
| Target | Output |
|
||||
|--------|--------|
|
||||
| `make reference` | `_build/API_REFERENCE.md` |
|
||||
| `make endpoints` | `_build/API_ENDPOINTS.md` |
|
||||
| `make quickref` | `_build/API_QUICK_REFERENCE.md` |
|
||||
| `make errors` | `_build/API_ERROR_CODES.md` |
|
||||
| `make index` | `_build/API_INDEX.md` |
|
||||
| `make marcom` | `_build/API_TRAINING_MARCOM.md` |
|
||||
| `make tmdb` | `_build/TMDb_User_Guide.md` |
|
||||
| `make all` | All of the above |
|
||||
| `make deploy` | Copy `_build/*` → `../GUIDES/` |
|
||||
| `make check` | `diff` against existing `../GUIDES/` files |
|
||||
### Common Patterns
|
||||
|
||||
## Adding a New Endpoint
|
||||
#### File Processing
|
||||
|
||||
1. Add the endpoint to the appropriate module (e.g., `modules/XX_files.md`)
|
||||
2. Follow the template in `modules/_template.md`
|
||||
3. `make all && make check`
|
||||
4. `make deploy`
|
||||
1. Register file: `POST /api/v1/register`
|
||||
2. Process file: `POST /api/v1/process`
|
||||
3. Check progress: `GET /api/v1/progress/{file_uuid}`
|
||||
4. Search results: `GET /api/v1/search`
|
||||
|
||||
#### Identity Management
|
||||
|
||||
1. List identities: `GET /api/v1/identities`
|
||||
2. Bind faces: `POST /api/v1/identities/{identity_uuid}/bind`
|
||||
3. Search identities: `GET /api/v1/search/identities`
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Development
|
||||
|
||||
### Adding New Endpoints
|
||||
|
||||
1. Use [_template.md](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/_template.md)
|
||||
2. Follow naming convention: `NN_topic.md`
|
||||
3. Add YAML frontmatter
|
||||
4. Include complete examples
|
||||
5. Add to this index
|
||||
|
||||
### Documentation Standards
|
||||
|
||||
All modules must include:
|
||||
- ✅ YAML frontmatter
|
||||
- ✅ Module metadata (module, description, depends)
|
||||
- ✅ Endpoint documentation with examples
|
||||
- ✅ Error codes
|
||||
- ✅ Version history
|
||||
|
||||
---
|
||||
|
||||
## 📊 Statistics
|
||||
|
||||
| Metric | Count |
|
||||
|--------|-------|
|
||||
| **Total API Modules** | 31 |
|
||||
| **Core APIs** | 20 |
|
||||
| **New APIs** | 5 |
|
||||
| **Studio Guides** | 6 |
|
||||
| **Total Endpoints** | 100+ |
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial comprehensive API index |
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2026-10-24
|
||||
**Maintained By**: Core Team
|
||||
@@ -0,0 +1,428 @@
|
||||
---
|
||||
title: people api API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
# People API
|
||||
|
||||
**Version**: 2.1
|
||||
**Date**: 2026-08-12
|
||||
**Base URL**: `http://localhost:3002`
|
||||
**Auth**: Requires API key header (`Authorization: Bearer <api_key>`)
|
||||
**Doc Path**: `/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/19_people_api.md`
|
||||
|
||||
---
|
||||
|
||||
## 資料架構
|
||||
|
||||
### ⚠️ People Search 核心機制
|
||||
|
||||
**People Search 使用 TEXT 名稱匹配,不使用向量搜尋。**
|
||||
|
||||
- 資料來源: `face_cluster.json` 的 `group_name`
|
||||
- 儲存位置: SQLite `trace_profiles` 表
|
||||
- 匹配方式: PostgreSQL/SQLite `ILIKE` 模糊匹配
|
||||
- **Identity 欄位目前為佔位用途,暫無實際搜尋功能**
|
||||
- **Face 512D 向量僅供 `rust_face_cluster` 工具使用,不參與任何搜尋**
|
||||
|
||||
### trace_profiles(SQLite/PostgreSQL — People Search 專用)
|
||||
|
||||
每筆 `file_uuid + trace_id` 對應一個 face trace profile:
|
||||
|
||||
| 欄位 | 類型 | 說明 |
|
||||
|------|------|------|
|
||||
| `file_uuid` | string | 影片 UUID |
|
||||
| `trace_id` | integer | Face trace ID(8Hz 取樣追蹤) |
|
||||
| `name` | string | FS name(Face 頁面顯示 + People Search 搜尋) |
|
||||
| `start_frame` | integer | 起始 frame |
|
||||
| `end_frame` | integer | 結束 frame |
|
||||
| `frame_count` | integer | 追蹤 frame 數(8Hz 取樣,多數 > 1) |
|
||||
| `key_frame` | string | 關鍵幀圖片路徑 |
|
||||
| `key_face` | string | 關鍵人臉裁切路徑 |
|
||||
| `avg_confidence` | float | 平均偵測信心值 |
|
||||
| `status` | string | 狀態(pending/confirmed) |
|
||||
|
||||
### 可搜尋註記(metadata / VLM 欄位)
|
||||
|
||||
`trace_profiles` 包含 VLM 產生的註記,可用於進階搜尋和統計:
|
||||
|
||||
| 欄位 | 類型 | 說明 |
|
||||
|------|------|------|
|
||||
| `vlm_description` | text | VLM 人物外貌描述 |
|
||||
| `vlm_clothing` | text | VLM 衣著描述 |
|
||||
| `vlm_tags` | text[] | VLM 標籤陣列 |
|
||||
| `vlm_location` | string | VLM 地點 |
|
||||
| `vlm_setting` | string | VLM 場景設定 |
|
||||
| `vlm_lighting` | string | VLM 光線 |
|
||||
| `vlm_weather` | string | VLM 天氣 |
|
||||
| `vlm_background` | text | VLM 背景描述 |
|
||||
| `vlm_bg_tags` | text[] | VLM 背景標籤 |
|
||||
|
||||
### tkg_nodes(PostgreSQL — TKG 圖譜專用,與 profile 獨立)
|
||||
|
||||
| 欄位 | 說明 |
|
||||
|------|------|
|
||||
| `external_id` | 如 "trace_9",對應 `trace_profiles.trace_id` |
|
||||
| `label` | TKG 圖譜節點標籤(與 `trace_profiles.name` 獨立) |
|
||||
| `properties` | TKG 節點屬性 |
|
||||
|
||||
### _faces(Qdrant — Face 向量比對)
|
||||
|
||||
Face embedding 向量存在 Qdrant `_faces` collection,可用作 seed 比對:
|
||||
|
||||
| Payload 欄位 | 類型 | 說明 |
|
||||
|-------------|------|------|
|
||||
| `file_uuid` | string | 影片 UUID |
|
||||
| `trace_id` | integer | Face trace ID |
|
||||
| `identity_id` | integer \| null | 已綁定的 identity ID |
|
||||
| `frame` | integer | Frame 編號 |
|
||||
| `embedding` | vector[512] | FaceNet 512-d embedding |
|
||||
| `bbox` | object | 人臉 bbox(x, y, width, height) |
|
||||
| `confidence` | float | 偵測信心值 |
|
||||
|
||||
---
|
||||
|
||||
## 1. GET /api/v1/search/people
|
||||
|
||||
搜尋已命名的 face trace profiles。回傳符合 name 的卡片列表。
|
||||
|
||||
### Query Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------|
|
||||
| `query` | string | ✅ Yes | 搜尋關鍵字(ILIKE 模糊比對 `trace_profiles.name`) |
|
||||
| `file_uuid` | string | ❌ Optional | 限制搜尋範圍 |
|
||||
| `limit` | integer | ❌ Optional | 回傳筆數上限(預設 10) |
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
# 搜尋名字
|
||||
curl -X GET "http://localhost:3002/api/v1/search/people?query=Susan"
|
||||
|
||||
# 搜尋 VLM 註記(衣著、地點、標籤)
|
||||
curl -X GET "http://localhost:3002/api/v1/search/people?query=blue+shirt"
|
||||
|
||||
# 限定影片
|
||||
curl -X GET "http://localhost:3002/api/v1/search/people?file_uuid=abc123&query=Tom"
|
||||
```
|
||||
|
||||
### 搜尋範圍
|
||||
|
||||
People Search 會搜尋以下欄位(ILIKE 模糊比對):
|
||||
|
||||
| 欄位 | 說明 |
|
||||
|------|------|
|
||||
| `name` | FS name |
|
||||
| `vlm_description` | VLM 人物外貌描述 |
|
||||
| `vlm_clothing` | VLM 衣著描述 |
|
||||
| `vlm_tags` | VLM 標籤陣列 |
|
||||
| `vlm_location` | VLM 地點 |
|
||||
| `vlm_setting` | VLM 場景設定 |
|
||||
|
||||
### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"people": [
|
||||
{
|
||||
"file_uuid": "4655a0ab3c077e30c12b2298c2750650",
|
||||
"file_name": "",
|
||||
"trace_id": 9,
|
||||
"external_id": "trace_9",
|
||||
"name": "Susan",
|
||||
"start_frame": 118,
|
||||
"end_frame": 384,
|
||||
"frame_count": 39,
|
||||
"start_time": null,
|
||||
"end_time": null,
|
||||
"key_frame": "key_frame.jpg",
|
||||
"key_face": null,
|
||||
"avg_confidence": 0.694,
|
||||
"avg_capture_quality": 0.512,
|
||||
"best_capture_quality": 0.733
|
||||
}
|
||||
],
|
||||
"total": 18
|
||||
}
|
||||
```
|
||||
|
||||
### Response Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 影片 UUID |
|
||||
| `trace_id` | integer | Face trace ID |
|
||||
| `external_id` | string \| null | TKG node external_id(如 "trace_9") |
|
||||
| `name` | string \| null | 使用者命名的 FS name |
|
||||
| `start_frame` | integer \| null | 起始 frame |
|
||||
| `end_frame` | integer \| null | 結束 frame |
|
||||
| `frame_count` | integer \| null | 追蹤 frame 數(8Hz 取樣) |
|
||||
| `start_time` | float \| null | 起始時間(秒) |
|
||||
| `end_time` | float \| null | 結束時間(秒) |
|
||||
| `key_frame` | string \| null | 關鍵幀圖片路徑 |
|
||||
| `key_face` | string \| null | 關鍵人臉裁切路徑 |
|
||||
| `avg_confidence` | float \| null | 平均偵測信心值 |
|
||||
| `avg_capture_quality` | float \| null | 平均畫面品質分數(清晰度,0~1) |
|
||||
| `best_capture_quality` | float \| null | 該 trace 最佳畫面品質分數 |
|
||||
|
||||
---
|
||||
|
||||
## 2. POST /api/v1/search/universal
|
||||
|
||||
統一搜尋。設定 `types: ["people"]` 搜尋人物,或組合 `"chunk"`、`"frame"`。
|
||||
|
||||
People Search 會搜尋 `trace_profiles` 的 `name` + `vlm_*` 欄位:
|
||||
- `name` — FS name
|
||||
- `vlm_description` — VLM 人物外貌描述
|
||||
- `vlm_clothing` — VLM 衣著描述
|
||||
- `vlm_tags` — VLM 標籤陣列
|
||||
- `vlm_location` — VLM 地點
|
||||
- `vlm_setting` — VLM 場景設定
|
||||
|
||||
### Request Body
|
||||
|
||||
```json
|
||||
{
|
||||
"query": "Susan",
|
||||
"file_uuid": "abc123",
|
||||
"types": ["people"],
|
||||
"page": 1,
|
||||
"page_size": 20
|
||||
}
|
||||
```
|
||||
|
||||
### Request Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `query` | string | ✅ Yes | 搜尋關鍵字 |
|
||||
| `file_uuid` | string | ❌ Optional | 限制搜尋範圍 |
|
||||
| `types` | string[] | ❌ Optional | `["chunk", "frame", "people"]` — 預設全部 |
|
||||
| `page` | integer | ❌ Optional | 頁碼(預設 1) |
|
||||
| `page_size` | integer | ❌ Optional | 每頁筆數(預設 20,最大 200) |
|
||||
|
||||
### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"query": "Susan",
|
||||
"results": [
|
||||
{
|
||||
"type": "person",
|
||||
"file_uuid": "4655a0ab3c077e30c12b2298c2750650",
|
||||
"trace_id": 9,
|
||||
"external_id": "trace_9",
|
||||
"name": "Susan",
|
||||
"frame_count": 39,
|
||||
"score": 0.95,
|
||||
"start_time": null,
|
||||
"end_time": null,
|
||||
"key_frame": "key_frame.jpg",
|
||||
"key_face": null
|
||||
}
|
||||
],
|
||||
"total": 18,
|
||||
"page": 1,
|
||||
"page_size": 20,
|
||||
"has_more": false
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. PUT /api/v1/trace-profile(單筆改名)
|
||||
|
||||
更新單一 face trace profile 的 name 和 metadata。
|
||||
|
||||
### Request Body
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "4655a0ab3c077e30c12b2298c2750650",
|
||||
"trace_id": 9,
|
||||
"name": "Susan",
|
||||
"properties": { "custom_key": "custom_value" },
|
||||
"key_frame": "path/to/key_frame.jpg",
|
||||
"key_face": "path/to/key_face.jpg",
|
||||
"aliases": ["Susie", "Sue"]
|
||||
}
|
||||
```
|
||||
|
||||
### Request Fields
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | ✅ Yes | 影片 UUID |
|
||||
| `trace_id` | integer | ✅ Yes | Face trace ID |
|
||||
| `name` | string | ❌ Optional | 新的 FS name |
|
||||
| `properties` | object | ❌ Optional | 自訂屬性(合併更新) |
|
||||
| `key_frame` | string | ❌ Optional | 關鍵幀路徑 |
|
||||
| `key_face` | string | ❌ Optional | 關鍵人臉路徑 |
|
||||
| `aliases` | string[] | ❌ Optional | 別名列表 |
|
||||
|
||||
---
|
||||
|
||||
## 4. PUT /api/v1/trace-profile/group(批次改名)
|
||||
|
||||
批次更新多個 face trace profiles 的 name。
|
||||
|
||||
### Request Body
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "4655a0ab3c077e30c12b2298c2750650",
|
||||
"trace_ids": [9, 22, 5],
|
||||
"name": "Susan"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. POST /api/v1/groups/merge(合併群組)
|
||||
|
||||
將多個 group 的 traces 合併為一個 group name。
|
||||
|
||||
### Request Body
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "4655a0ab3c077e30c12b2298c2750650",
|
||||
"source_groups": ["Person_0", "Person_1"],
|
||||
"target_group_name": "Susan"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Responses
|
||||
|
||||
### 400 Bad Request
|
||||
```json
|
||||
{ "error": "name is required" }
|
||||
```
|
||||
|
||||
### 401 Unauthorized
|
||||
```
|
||||
HTTP 401 (no body) — Missing or invalid API key
|
||||
```
|
||||
|
||||
### 404 Not Found
|
||||
```json
|
||||
{ "error": "Profile not found" }
|
||||
```
|
||||
|
||||
### 500 Internal Server Error
|
||||
```json
|
||||
{ "error": "DB error: connection refused" }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 如何命名 Face Trace
|
||||
|
||||
使用 profile API 為 face trace 命名:
|
||||
|
||||
```bash
|
||||
curl -X PUT "http://localhost:3002/api/v1/trace-profile" \
|
||||
-H "Authorization: Bearer <api_key>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "4655a0ab3c077e30c12b2298c2750650",
|
||||
"trace_id": 9,
|
||||
"name": "Susan"
|
||||
}'
|
||||
```
|
||||
|
||||
命名後即可透過 People Search API 搜尋:
|
||||
|
||||
```bash
|
||||
curl "http://localhost:3002/api/v1/search/people?query=Susan" \
|
||||
-H "Authorization: Bearer <api_key>"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pipeline 狀態定義
|
||||
|
||||
所有檔案的 status 由 `/api/v1/file/{file_uuid}/sync-status` 自動更新,依據 processor outputs 和功能就緒狀態判定。
|
||||
|
||||
| Status | 前端顯示 | 條件 | 啟用功能 |
|
||||
|--------|---------|------|---------|
|
||||
| `registered` | 📋 已註冊 | 0 processor outputs | 檔案註冊 |
|
||||
| `scanning` | 🔍 掃描中 | 1-4/5 processor outputs | — |
|
||||
| `keyword_ready` | 🔎 關鍵字可用 | sentence chunks > 0 | Smart Search |
|
||||
| `semantic_ready` | 🧠 語意可用 | embedded chunks > 0 | Semantic Search |
|
||||
| `face_mgmt_ready` | 🎭 臉部管理可用 | face_trace + trace_profiles + tkg_nodes(face_track) | People Search, Face Profile 讀寫, Face Group |
|
||||
| `agent_ready` | 🤖 Agent 可用 | face_mgmt_ready + tkg_edges | Agent TKG Tools |
|
||||
| `completed` | ✅ 完成 | 5/5 processors + 全部功能就緒 | — |
|
||||
|
||||
### Face Management Ready 明確定義
|
||||
|
||||
`face_mgmt_ready` 表示檔案已具備完整臉部管理功能,需同時滿足以下四個條件:
|
||||
|
||||
| 依賴項 | 檢查條件 | 說明 | 提供功能 |
|
||||
|--------|---------|------|---------|
|
||||
| **Face Qdrant Ready** | `_faces` collection 有 face points | Face embeddings 已存入 Qdrant | 臉部比對、相似度搜尋 |
|
||||
| **Face Trace Ready** | `face_traced.json` 存在且有 traces | Face tracking 已完成 | 人臉軌跡資料 |
|
||||
| **Face Profile Ready** | `trace_profiles` 有紀錄 | Profile 資料已建立 | 名字、VLM 註記、key_frame/key_face |
|
||||
| **Face TKG Node Ready** | `tkg_nodes` 有 `face_track` nodes | TKG 圖譜節點已建立 | 臉部群組合併、關係查詢 |
|
||||
|
||||
#### 檢查 SQL
|
||||
|
||||
```sql
|
||||
-- Face Qdrant Ready
|
||||
SELECT COUNT(*) FROM _faces WHERE file_uuid = $1; -- > 0
|
||||
|
||||
-- Face Trace Ready
|
||||
-- 檢查 face_traced.json 檔案存在且有 traces
|
||||
|
||||
-- Face Profile Ready
|
||||
SELECT COUNT(*) FROM trace_profiles WHERE file_uuid = $1; -- > 0
|
||||
|
||||
-- Face TKG Node Ready
|
||||
SELECT COUNT(*) FROM tkg_nodes WHERE file_uuid = $1 AND node_type = 'face_track'; -- > 0
|
||||
```
|
||||
|
||||
#### 啟用功能清單
|
||||
|
||||
| 功能 | API Endpoint | 說明 |
|
||||
|------|-------------|------|
|
||||
| People Search | `GET /api/v1/search/people` | 搜尋已命名人臉 |
|
||||
| Face Profile 讀寫 | `PUT /api/v1/trace-profile` | 更新名字、VLM 註記 |
|
||||
| Face Group 合併 | `POST /api/v1/groups/merge` | 合併多個群組 |
|
||||
| Face Trace 改名 | `PUT /api/v1/trace-profile` | 為單個 trace 命名 |
|
||||
| Agent Face Search | Agent Tool: `face_profile_search` | Agent 搜尋人臉 |
|
||||
|
||||
---
|
||||
|
||||
### 狀態依賴關係
|
||||
|
||||
```
|
||||
registered → scanning → keyword_ready → semantic_ready
|
||||
↓
|
||||
face_mgmt_ready → agent_ready → completed
|
||||
```
|
||||
|
||||
### 每個階段對應的 Processor
|
||||
|
||||
| 階段 | 必要 Processor | 產出 |
|
||||
|------|---------------|------|
|
||||
| `keyword_ready` | ASR, ASRX | sentence chunks |
|
||||
| `semantic_ready` | keyword_ready + Vectorize | embedded chunks |
|
||||
| `face_mgmt_ready` | Face, FaceCluster | trace_profiles (People Search + Face Management) |
|
||||
| `agent_ready` | face_mgmt_ready + TKG Edges | tkg_edges |
|
||||
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,301 @@
|
||||
---
|
||||
title: Auth API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: auth -->
|
||||
<!-- description: Authentication — login, logout, JWT, session cookie, API key -->
|
||||
<!-- depends: -->
|
||||
|
||||
## Base URL
|
||||
|
||||
| Environment | URL | Purpose |
|
||||
|-------------|-----|---------|
|
||||
| Production | `http://localhost:3002` | Production deployment |
|
||||
| External (M5) | `https://m5api.momentry.ddns.net` | Remote access |
|
||||
|
||||
## Variables
|
||||
|
||||
All examples in this documentation use these environment variables:
|
||||
|
||||
```bash
|
||||
API="http://localhost:3002"
|
||||
KEY="your-api-key-here"
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
All endpoints under `/api/v1/*` require authentication.
|
||||
The following endpoints are public (no auth needed):
|
||||
|
||||
- `GET /health`
|
||||
- `POST /api/v1/auth/login`
|
||||
- `POST /api/v1/auth/logout`
|
||||
|
||||
### Three Authentication Modes
|
||||
|
||||
The system supports three authentication methods, checked in **priority order** by the middleware:
|
||||
|
||||
```
|
||||
Middleware priority:
|
||||
1. Session Cookie (Portal/browser)
|
||||
2. JWT Bearer (API clients, CLI)
|
||||
3. API Key Header (legacy compatibility)
|
||||
4. API Key Query Param (?api_key=)
|
||||
```
|
||||
|
||||
| Mode | Transport | Expiry | Scope | Best for |
|
||||
|------|-----------|--------|-------|----------|
|
||||
| **Session Cookie** | `Cookie: session_id=<session_id>` | 24h | per-browser session | Portal (browser) |
|
||||
| **JWT** | `Authorization: Bearer <token>` | 1h | per-login token | API clients, CLI, scripts |
|
||||
| **API Key** | `X-API-Key: <key>` | 90d | fixed key for automation | Legacy scripts, WordPress |
|
||||
|
||||
---
|
||||
|
||||
### Login
|
||||
|
||||
**Default accounts & API keys:**
|
||||
|
||||
| Username | Password | API Key | Role |
|
||||
|----------|----------|---------|------|
|
||||
| `admin` | `admin` | — | admin |
|
||||
| `demo` | `demo` | `muser_demo_key_32chars_abcdef1234567890` | user |
|
||||
|
||||
The demo API key is set via `MOMENTRY_DEMO_API_KEY` env var and can be used in place of JWT for marcom integrations:
|
||||
|
||||
```bash
|
||||
# Using API key instead of JWT
|
||||
curl -s "$API/api/v1/files/scan" -H "X-API-Key: muser_demo_key_32chars_abcdef1234567890"
|
||||
```
|
||||
|
||||
```bash
|
||||
# Login as admin
|
||||
curl -s -X POST "$API/api/v1/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username": "admin", "password": "admin"}'
|
||||
|
||||
# Login as demo user
|
||||
curl -s -X POST "$API/api/v1/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username": "demo", "password": "demo"}'
|
||||
```
|
||||
|
||||
#### Success Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"jwt": "eyJhbGciOiJIUzI1NiIs...",
|
||||
"api_key": "muser_...",
|
||||
"user": {
|
||||
"username": "admin",
|
||||
"role": "admin"
|
||||
},
|
||||
"expires_at": "2026-05-18T13:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `jwt` | string | JWT access token. Use as `Authorization: Bearer <jwt>`. Expires in 1 hour. |
|
||||
| `api_key` | string | Legacy API key. Use as `X-API-Key: <key>`. Good for 90 days. |
|
||||
| `user.username` | string | Username |
|
||||
| `user.role` | string | Role: `admin`, `user`, or `readonly` |
|
||||
| `expires_at` | string | ISO8601 timestamp of JWT expiration |
|
||||
|
||||
The login endpoint also sets a `Set-Cookie` header for browser-based clients:
|
||||
|
||||
```
|
||||
Set-Cookie: session_id=<session_id>; Path=/; HttpOnly; SameSite=Strict; Max-Age=86400
|
||||
```
|
||||
|
||||
#### Error Response (401)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"message": "Invalid username or password"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Using JWT
|
||||
|
||||
JWT is preferred for API clients (CLI scripts, WordPress). It is validated by the middleware without a database lookup (stateless).
|
||||
|
||||
```bash
|
||||
# Login and capture JWT
|
||||
JWT=$(curl -s -X POST "$API/api/v1/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"admin","password":"admin"}' | python3 -c "import json,sys;print(json.load(sys.stdin)['jwt'])")
|
||||
|
||||
# Use JWT for all subsequent requests
|
||||
curl -H "Authorization: Bearer $JWT" "$API/api/v1/files/scan"
|
||||
curl -H "Authorization: Bearer $JWT" "$API/api/v1/resource/tmdb"
|
||||
```
|
||||
|
||||
JWT is short-lived (1 hour). When it expires, request a new one via login.
|
||||
|
||||
---
|
||||
|
||||
### Using Session Cookie (Browser)
|
||||
|
||||
Browser-based clients (Portal) get a session cookie automatically after login. The browser sends the cookie with every request—no manual header needed.
|
||||
|
||||
```bash
|
||||
# Login captures the session cookie from Set-Cookie header
|
||||
curl -v -X POST "$API/api/v1/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"admin","password":"admin"}' 2>&1 | grep "Set-Cookie"
|
||||
|
||||
# Browser automatically sends: Cookie: session_id=<session_id>
|
||||
# No manual header needed for subsequent requests
|
||||
```
|
||||
|
||||
The session cookie is HttpOnly (not accessible from JavaScript) and SameSite=Strict (protected against CSRF).
|
||||
|
||||
---
|
||||
|
||||
### Using Legacy API Key
|
||||
|
||||
```bash
|
||||
curl -H "X-API-Key: $KEY" "$API/api/v1/files/scan"
|
||||
|
||||
# Also accepted via Bearer header (non-JWT format) or query parameter:
|
||||
curl -H "Authorization: Bearer $KEY" "$API/api/v1/files/scan"
|
||||
curl "$API/api/v1/files/scan?api_key=$KEY"
|
||||
```
|
||||
|
||||
API keys are validated via SHA256 hash lookup in the database. They are long-lived (90 days) and intended for automation.
|
||||
|
||||
### Obtaining an API Key (CLI)
|
||||
|
||||
```bash
|
||||
momentry api-key create "My API Key" --key-type user
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Logout
|
||||
|
||||
```bash
|
||||
# Logout using the session cookie (browser)
|
||||
curl -X POST "$API/api/v1/auth/logout" \
|
||||
-H "Cookie: session_id=<uuid>"
|
||||
```
|
||||
|
||||
#### What logout does
|
||||
|
||||
| Auth mode | Effect |
|
||||
|-----------|--------|
|
||||
| **Session Cookie** | Session deleted from database. Same cookie returns 401 on subsequent requests. |
|
||||
| **JWT** | JWT remains valid until expiry. (JWT is stateless — logout adds JWT to a blacklist only if API key mode is used.) |
|
||||
| **API Key** | API key remains valid. (Legacy keys are shared across sessions — revoking would break other clients.) |
|
||||
|
||||
#### Example: full session lifecycle
|
||||
|
||||
```bash
|
||||
# 1. Login
|
||||
SESSION_ID=$(curl -s -D - -X POST "$API/api/v1/auth/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"admin","password":"admin"}' | grep "Set-Cookie" | sed 's/.*session_id=\([^;]*\).*/\1/')
|
||||
|
||||
# 2. Use session (works)
|
||||
curl -s -o /dev/null -w "HTTP %{http_code}\n" "$API/api/v1/resource/tmdb" \
|
||||
-H "Cookie: session_id=$SESSION_ID"
|
||||
# → HTTP 200
|
||||
|
||||
# 3. Logout
|
||||
curl -s -X POST "$API/api/v1/auth/logout" \
|
||||
-H "Cookie: session_id=$SESSION_ID"
|
||||
# → {"success": true}
|
||||
|
||||
# 4. Use session again (rejected)
|
||||
curl -s -o /dev/null -w "HTTP %{http_code}\n" "$API/api/v1/resource/tmdb" \
|
||||
-H "Cookie: session_id=$SESSION_ID"
|
||||
# → HTTP 401
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Authentication Flow Summary
|
||||
|
||||
```
|
||||
Login Request
|
||||
│
|
||||
▼
|
||||
┌──────────────────┐
|
||||
│ 1. Check users │ ← users table (argon2 password verify)
|
||||
│ table │
|
||||
└──────┬───────────┘
|
||||
│
|
||||
┌───┴───┐
|
||||
│ match │
|
||||
└───┬───┘
|
||||
│
|
||||
▼
|
||||
┌──────────────────┐
|
||||
│ 2. Create JWT │ ← 1h expiry, signed with JWT_SECRET
|
||||
├──────────────────┤
|
||||
│ 3. Create │ ← 24h expiry, stored in sessions table
|
||||
│ session │
|
||||
├──────────────────┤
|
||||
│ 4. Set-Cookie │ ← HttpOnly, SameSite=Strict, Path=/
|
||||
├──────────────────┤
|
||||
│ 5. Return │ ← JWT + api_key + user info to client
|
||||
└──────────────────┘
|
||||
```
|
||||
|
||||
```
|
||||
Protected Request
|
||||
│
|
||||
▼
|
||||
┌──────────────────────┐
|
||||
│ Middleware checks: │
|
||||
│ │
|
||||
│ 1. Cookie session? │ → DB lookup session → get api_key → verify
|
||||
│ │
|
||||
│ 2. JWT Bearer? │ → verify JWT signature → decode claims
|
||||
│ │
|
||||
│ 3. X-API-Key? │ → SHA256 hash → DB lookup → verify
|
||||
│ │
|
||||
│ 4. ?api_key=? │ → same as #3
|
||||
│ │
|
||||
│ 5. None → 401 │
|
||||
└──────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `401` | Missing or invalid authentication |
|
||||
| `401` | Session expired or logged out |
|
||||
| `401` | JWT expired |
|
||||
| `401` | API key revoked or inactive |
|
||||
|
||||
---
|
||||
|
||||
### Related
|
||||
|
||||
- `POST /api/v1/resource/tmdb/check` — test authentication + TMDb API connectivity
|
||||
- `GET /health/detailed` — view auth status (integrations section)
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 12:49:24*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,208 @@
|
||||
---
|
||||
title: health API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: health -->
|
||||
<!-- description: Health check endpoints -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## Health Check
|
||||
|
||||
### `GET /health`
|
||||
|
||||
**Auth**: Public
|
||||
**Scope**: system-level
|
||||
|
||||
Returns basic server health status — used by load balancers and monitoring.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl "$API/health" | jq '{status, version}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"version": "1.0.0",
|
||||
"build_git_hash": "3a6c1865",
|
||||
"build_timestamp": "2026-05-16T13:38:15Z",
|
||||
"uptime_ms": 3015
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `status` | string | `ok` or `degraded` |
|
||||
| `version` | string | Semver version |
|
||||
| `build_git_hash` | string | Git commit hash |
|
||||
| `build_timestamp` | string | Binary build time |
|
||||
| `uptime_ms` | integer | Milliseconds since server start |
|
||||
|
||||
---
|
||||
|
||||
### `GET /health/detailed`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Returns full system health including each service status, resource utilization, pipeline readiness, schema migration status, identity file sync status, and external integrations.
|
||||
|
||||
> Requires authentication (JWT, session cookie, or API key). The basic `/health` endpoint remains public for load balancer checks.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl "$API/health/detailed" | jq '{status, services, resources: {cpu: .resources.cpu_used_percent, memory: .resources.memory_used_percent}}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"version": "1.0.0",
|
||||
"services": {
|
||||
"postgres": {"status": "ok", "latency_ms": 3},
|
||||
"redis": {"status": "ok", "latency_ms": 1},
|
||||
"qdrant": {"status": "ok", "latency_ms": 5}
|
||||
},
|
||||
"resources": {
|
||||
"cpu_used_percent": 12.5,
|
||||
"memory_available_mb": 32768,
|
||||
"memory_used_percent": 31.7
|
||||
},
|
||||
"pipeline": {
|
||||
"scripts_ready": true,
|
||||
"scripts_count": 345,
|
||||
"processors": {
|
||||
"asr": true,
|
||||
"yolo": true,
|
||||
"face": true,
|
||||
"pose": true,
|
||||
"ocr": true,
|
||||
"cut": true,
|
||||
"scene": true,
|
||||
"asrx": true,
|
||||
"visual_chunk": true
|
||||
},
|
||||
"models_ready": true,
|
||||
"models_count": 42,
|
||||
"scripts_integrity": {"matched": 332, "total": 345, "ok": false},
|
||||
"ffmpeg": true
|
||||
},
|
||||
"schema": {
|
||||
"table_exists": true,
|
||||
"applied": [{"filename": "migrate_add_users_table.sql"}],
|
||||
"required": [],
|
||||
"ok": true
|
||||
},
|
||||
"identities": {
|
||||
"directory_exists": true,
|
||||
"files_count": 3481,
|
||||
"index_ok": true,
|
||||
"db_count": 3481,
|
||||
"synced": true
|
||||
},
|
||||
"integrations": {
|
||||
"tmdb": {
|
||||
"api_key_configured": false,
|
||||
"enabled": false,
|
||||
"api_reachable": null
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Response Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `status` | string | `ok` if all essential services healthy |
|
||||
| `services` | object | Per-service status (postgres, redis, qdrant) |
|
||||
| `services.*.status` | string | `ok`, `error`, or `degraded` |
|
||||
| `services.*.latency_ms` | int | Response time in milliseconds |
|
||||
| `resources` | object | CPU, memory usage |
|
||||
| `pipeline.scripts_ready` | boolean | Scripts directory accessible |
|
||||
| `pipeline.scripts_count` | int | Number of Python processor scripts |
|
||||
| `pipeline.processors` | object | Per-processor availability |
|
||||
| `pipeline.models_ready` | boolean | Models directory accessible |
|
||||
| `pipeline.scripts_integrity` | object | SHA256 checksum verification results |
|
||||
| `schema.ok` | boolean | All required migrations applied |
|
||||
| `identities.synced` | boolean | Identity file count matches DB count |
|
||||
| `config` | object | Runtime toggle states (cache, auto-pipeline, watcher) |
|
||||
| `integrations.tmdb` | object | TMDB API key config and reachability |
|
||||
|
||||
### `GET /health/consistency`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Scans the database for data consistency issues. Reports anomalies without modifying any data.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/health/consistency" -H "X-API-Key: $KEY" | jq '.checks[] | {check, severity, count}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "degraded",
|
||||
"checked_at": "2026-05-18T17:30:00Z",
|
||||
"checks": [
|
||||
{
|
||||
"check": "stale_processing",
|
||||
"severity": "warn",
|
||||
"count": 3,
|
||||
"files": [
|
||||
{"file_name": "video.mp4", "file_uuid": "abc123...", "status": "processing", "detail": "job_id is null"}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Check | Description | Severity |
|
||||
|-------|-------------|---------|
|
||||
| `stale_processing` | Status=processing but job_id is null | `warn` |
|
||||
| `orphaned_processing` | Status=processing but no active monitor_job | `warn` |
|
||||
| `processing_job_done` | Status=processing but job already completed | `warn` |
|
||||
| `unregistered_with_uuid` | Status=unregistered but row still in DB (migration residue) | `info` |
|
||||
|
||||
#### Health status rules
|
||||
|
||||
| Condition | status |
|
||||
|-----------|--------|
|
||||
| All services ok | `ok` |
|
||||
| Any service error | `degraded` |
|
||||
| Postgres or Redis error | `degraded` (server still responds) |
|
||||
|
||||
---
|
||||
|
||||
### Stats Endpoints
|
||||
|
||||
| Method | Endpoint | Auth | Description |
|
||||
|--------|----------|------|-------------|
|
||||
| GET | `/api/v1/stats/sftpgo` | No | SFTPGo service status |
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 12:49:24*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,206 @@
|
||||
---
|
||||
title: register API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: register -->
|
||||
<!-- description: File registration — register, scan -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## File Registration
|
||||
|
||||
### `POST /api/v1/files/register`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Register a video file for processing. Returns the file's metadata and UUID.
|
||||
|
||||
Registration can **automatically trigger the processing pipeline** if the
|
||||
[auto-pipeline toggle](/api/v1/config/auto-pipeline) is enabled (disabled by default). The system will:
|
||||
1. Register the file and run ffprobe
|
||||
2. Auto-run offline TMDb probe (reads local identity files, no API calls)
|
||||
3. Create a monitor job for the worker
|
||||
4. Worker starts all 10 processors (Cut → ASR → ASRX → YOLO → OCR → Face → Pose → VisualChunk → Story → 5W1H)
|
||||
|
||||
If the file already exists (same content hash), returns the existing record with `already_exists: true`.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `file_path` | string | Yes | — | Path to video file on disk |
|
||||
| `pattern` | string | No | — | Regex pattern for batch register (requires `file_path` to be a directory) |
|
||||
| `user_id` | integer | No | — | User ID to associate with registration |
|
||||
| `content_hash` | string | No | — | Pre-computed SHA-256 hash (skips computation) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Register a single file
|
||||
curl -s -X POST "$API/api/v1/files/register" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_path": "/path/to/video.mp4"}'
|
||||
|
||||
# Batch register files matching a pattern in a directory
|
||||
curl -s -X POST "$API/api/v1/files/register" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_path": "/path/to/dir", "pattern": ".*\\.mp4$"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "3a6c1865...",
|
||||
"file_name": "video.mp4",
|
||||
"file_path": "/path/to/video.mp4",
|
||||
"file_type": "video",
|
||||
"duration": 120.5,
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"fps": 24.0,
|
||||
"total_frames": 2892,
|
||||
"already_exists": false,
|
||||
"message": "File registered successfully"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `file_uuid` | string | 32-char hex UUID of the registered file |
|
||||
| `file_name` | string | File name (auto-renamed if name conflict) |
|
||||
| `file_path` | string | Canonical path on disk |
|
||||
| `file_type` | string | `"video"`, `"audio"`, or `"unknown"` |
|
||||
| `duration` | float | Duration in seconds |
|
||||
| `width` | integer | Video width in pixels |
|
||||
| `height` | integer | Video height in pixels |
|
||||
| `fps` | float | Frames per second |
|
||||
| `total_frames` | integer | Total frame count |
|
||||
| `already_exists` | boolean | True if same content was already registered |
|
||||
| `message` | string | Human-readable status |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `401` | Missing or invalid API key |
|
||||
| `400` | Invalid request body |
|
||||
| `404` | File path does not exist |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/files/scan`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Scan the filesystem directory and list all media files, showing which are registered, processing, or unregistered.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `page` | integer | No | 1 | Page number (1-based) |
|
||||
| `page_size` | integer | No | all | Items per page (alias: `limit`) |
|
||||
| `limit` | integer | No | all | Max items (alias for `page_size`) |
|
||||
| `pattern` | string | No | — | Regex filter on file name (e.g., `.*\\.mp4$`) |
|
||||
| `sort_by` | string | No | `name` | Sort field: `name`, `size`, `modified`, `status` |
|
||||
| `sort_order` | string | No | `asc` | Sort direction: `asc` or `desc` |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Full scan
|
||||
curl -s "$API/api/v1/files/scan" -H "X-API-Key: $KEY" | jq '{total, registered_count, unregistered_count}'
|
||||
|
||||
# Paginated (page 1, 5 per page)
|
||||
curl -s "$API/api/v1/files/scan?page=1&page_size=5" -H "X-API-Key: $KEY" | jq '{page, total_pages, files: [.files[].file_name]}'
|
||||
|
||||
# Regex filter: only mp4 files
|
||||
curl -s "$API/api/v1/files/scan?pattern=.*\\.mp4$" -H "X-API-Key: $KEY" | jq '{filtered_total, files: [.files[].file_name]}'
|
||||
|
||||
# Sort by file size (largest first)
|
||||
curl -s "$API/api/v1/files/scan?sort_by=size&sort_order=desc&page_size=5" -H "X-API-Key: $KEY" | jq '[.files[] | {file_name, file_size}]'
|
||||
|
||||
# Sort by modified time (most recent first)
|
||||
curl -s "$API/api/v1/files/scan?sort_by=modified&sort_order=desc&page_size=5" -H "X-API-Key: $KEY" | jq '[.files[] | {file_name, modified_time}]'
|
||||
|
||||
# Sort by status
|
||||
curl -s "$API/api/v1/files/scan?sort_by=status&page_size=5" -H "X-API-Key: $KEY" | jq '[.files[] | {file_name, status}]'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"files": [
|
||||
{
|
||||
"file_name": "video.mp4",
|
||||
"file_size": 12345678,
|
||||
"is_registered": true,
|
||||
"file_uuid": "3a6c1865...",
|
||||
"status": "completed",
|
||||
"registration_time": "2026-05-16T12:00:00Z",
|
||||
"job_id": 42
|
||||
}
|
||||
],
|
||||
"total": 107,
|
||||
"filtered_total": 80,
|
||||
"page": 1,
|
||||
"page_size": 20,
|
||||
"total_pages": 4,
|
||||
"registered_count": 26,
|
||||
"unregistered_count": 81
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `files` | array | Array of file info objects (paginated) |
|
||||
| `files[].file_name` | string | File name |
|
||||
| `files[].relative_path` | string | Path relative to scan root |
|
||||
| `files[].file_path` | string | Absolute path on disk |
|
||||
| `files[].file_size` | integer | File size in bytes |
|
||||
| `files[].modified_time` | string | Last modified timestamp (ISO8601) |
|
||||
| `files[].is_registered` | boolean | Whether file is registered in DB |
|
||||
| `files[].file_uuid` | string | 32-char hex UUID (only if registered) |
|
||||
| `files[].status` | string | `"completed"`, `"processing"`, `"registered"`, `"unregistered"`, or `null` |
|
||||
| `files[].registration_time` | string | DB registration timestamp (only if registered) |
|
||||
| `files[].job_id` | integer | Processing job ID (only if a job exists) |
|
||||
| `total` | integer | Total files found on disk (unfiltered) |
|
||||
| `filtered_total` | integer | Files matching regex filter |
|
||||
| `page` | integer | Current page number |
|
||||
| `page_size` | integer | Items per page |
|
||||
| `total_pages` | integer | Total pages |
|
||||
| `registered_count` | integer | Files registered in DB |
|
||||
| `unregistered_count` | integer | Files not yet registered |
|
||||
|
||||
#### Notes
|
||||
|
||||
| Feature | Behavior |
|
||||
|---------|----------|
|
||||
| **Regex** | Case-insensitive (`(?i)` prefix auto-applied). Applied to `file_name`. |
|
||||
| **Sort order** | Default (`sort_by=name`): registered files first, then alphabetically. `sort_by=status`: alphabetical by status string. |
|
||||
| **Pagination** | `page_size` and `limit` are aliases. Default: show all results. |
|
||||
| **Processing order** | `pattern` regex filter → `sort_by`/`sort_order` → `page`/`page_size` slice. |
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 12:49:24*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,438 @@
|
||||
---
|
||||
title: lookup API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: lookup -->
|
||||
<!-- description: File listing, lookup by name, file detail, faces, identities, JSON download, unregistration -->
|
||||
<!-- depends: 01_auth, 03_register -->
|
||||
|
||||
## File Lookup
|
||||
|
||||
### `GET /api/v1/files/lookup`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Search registered files by file name. Performs a case-insensitive LIKE search on the file name column. Returns basic info about matching files.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_name` | string | Yes | File name to search for (partial matches supported) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Look up a specific file
|
||||
curl -s "$API/api/v1/files/lookup?file_name=video.mp4" \
|
||||
-H "X-API-Key: $KEY"
|
||||
|
||||
# Partial name search
|
||||
curl -s "$API/api/v1/files/lookup?file_name=charade" \
|
||||
-H "X-API-Key: $KEY" | jq '.matches[].file_name'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_name": "video.mp4",
|
||||
"exists": true,
|
||||
"matches": [
|
||||
{
|
||||
"file_uuid": "a03485a40b2df2d3",
|
||||
"file_name": "video.mp4",
|
||||
"file_type": "video",
|
||||
"status": "completed"
|
||||
}
|
||||
],
|
||||
"next_name": "video (2).mp4"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_name` | string | Searched name |
|
||||
| `exists` | boolean | Exact name match exists |
|
||||
| `matches` | array | Array of matching registered files |
|
||||
| `matches[].file_uuid` | string | 32-char hex UUID |
|
||||
| `matches[].file_name` | string | Registered file name |
|
||||
| `matches[].file_type` | string | `"video"`, `"audio"`, or `null` |
|
||||
| `matches[].status` | string | Registration/processing status |
|
||||
| `next_name` | string | Suggested name for avoiding conflicts |
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
|
||||
## File Listing
|
||||
|
||||
### `GET /api/v1/files`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
List all registered files with pagination. Optionally filter by status or fetch a specific file by UUID.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 20 | Items per page |
|
||||
| `status` | string | No | — | Filter by status: `registered`, `processing`, `completed`, `failed`, `indexed`, `checked_out` |
|
||||
| `file_uuid` | string | No | — | Fetch a specific file (returns as single-item list) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# List all files (paginated)
|
||||
curl -s "$API/api/v1/files?page=1&page_size=10" \
|
||||
-H "X-API-Key: $KEY"
|
||||
|
||||
# Filter by status
|
||||
curl -s "$API/api/v1/files?status=completed" \
|
||||
-H "X-API-Key: $KEY"
|
||||
|
||||
# Fetch specific file
|
||||
curl -s "$API/api/v1/files?file_uuid=$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"total": 42,
|
||||
"page": 1,
|
||||
"page_size": 10,
|
||||
"data": [
|
||||
{
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"file_name": "video.mp4",
|
||||
"file_path": "/path/to/video.mp4",
|
||||
"status": "completed"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `total` | integer | Total file count |
|
||||
| `page` | integer | Current page |
|
||||
| `page_size` | integer | Items per page |
|
||||
| `data` | array | Array of file items |
|
||||
| `data[].file_uuid` | string | 32-char hex UUID |
|
||||
| `data[].file_name` | string | Registered file name |
|
||||
| `data[].file_path` | string | Full filesystem path |
|
||||
| `data[].status` | string | Processing status |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get detailed info for a specific registered file including metadata, duration, FPS, and probe data.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"file_name": "video.mp4",
|
||||
"file_path": "/path/to/video.mp4",
|
||||
"status": "completed",
|
||||
"duration": 120.5,
|
||||
"fps": 24.0,
|
||||
"metadata": {
|
||||
"format": {"duration": "120.5", "size": "794863677"},
|
||||
"streams": [{"codec_name": "h264", "width": 1920, "height": 1080}]
|
||||
},
|
||||
"created_at": "2026-05-16T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `file_name` | string | Registered file name |
|
||||
| `file_path` | string | Full filesystem path |
|
||||
| `status` | string | Processing status |
|
||||
| `duration` | float | Duration in seconds |
|
||||
| `fps` | float | Frames per second |
|
||||
| `metadata` | object | Full ffprobe metadata (probe.json) |
|
||||
| `created_at` | string | Registration timestamp (ISO 8601) |
|
||||
|
||||
#### Error Codes
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | File UUID not found |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/identities`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get all identities present in a specific file with pagination.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 20 | Items per page |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/identities?page=1&page_size=50" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"fps": 24.0,
|
||||
"total": 5,
|
||||
"page": 1,
|
||||
"page_size": 20,
|
||||
"data": [
|
||||
{
|
||||
"identity_id": 1,
|
||||
"identity_uuid": "a9a90105-6d6b-46ff-92da-0c3c1a57dff4",
|
||||
"name": "Audrey Hepburn",
|
||||
"metadata": {"source": "tmdb", "tmdb_id": 1234},
|
||||
"face_count": 142,
|
||||
"speaker_count": 8,
|
||||
"start_frame": 100,
|
||||
"end_frame": 5000,
|
||||
"start_time": 4.17,
|
||||
"end_time": 208.33,
|
||||
"confidence": 0.87
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `data[].identity_id` | integer | Database identity ID |
|
||||
| `data[].identity_uuid` | string/null | Global identity UUID (null if unbound) |
|
||||
| `data[].name` | string | Identity name |
|
||||
| `data[].metadata` | object | Source metadata (TMDb, etc.) |
|
||||
| `data[].face_count` | integer/null | Number of face detections |
|
||||
| `data[].speaker_count` | integer/null | Number of speaker segments |
|
||||
| `data[].start_frame` | integer/null | First appearance frame |
|
||||
| `data[].end_frame` | integer/null | Last appearance frame |
|
||||
| `data[].start_time` | float/null | First appearance time (seconds) |
|
||||
| `data[].end_time` | float/null | Last appearance time (seconds) |
|
||||
| `data[].confidence` | float/null | Average detection confidence |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/faces`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
List all face detections in a specific file with pagination.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 50 | Items per page |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/faces?page=1&page_size=100" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"total": 1420,
|
||||
"page": 1,
|
||||
"page_size": 50,
|
||||
"data": [
|
||||
{
|
||||
"face_id": "face_100",
|
||||
"frame_number": 1200,
|
||||
"timestamp": 50.0,
|
||||
"bbox": [100, 50, 300, 400],
|
||||
"confidence": 0.95,
|
||||
"identity_id": 1,
|
||||
"identity_uuid": "a9a90105-6d6b-46ff-92da-0c3c1a57dff4",
|
||||
"trace_id": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `data[].face_id` | string | Face detection ID |
|
||||
| `data[].frame_number` | integer | Frame number in video |
|
||||
| `data[].timestamp` | float | Timestamp in seconds |
|
||||
| `data[].bbox` | array | Bounding box `[x1, y1, x2, y2]` |
|
||||
| `data[].confidence` | float | Detection confidence |
|
||||
| `data[].identity_id` | integer/null | Bound identity ID (null if unbound) |
|
||||
| `data[].identity_uuid` | string/null | Bound identity UUID (null if unbound) |
|
||||
| `data[].trace_id` | integer/null | Face trace ID (null if not traced) |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/json/:processor`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Download raw JSON output for a specific processor.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `processor` | string | Yes | Processor name: `cut`, `asrx`, `yolo`, `ocr`, `face`, `pose`, `story`, etc. |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/json/face" \
|
||||
-H "X-API-Key: $KEY" | jq '.frames | length'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
Returns the raw JSON output of the specified processor. Structure varies by processor type.
|
||||
|
||||
#### Error Codes
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | JSON file not found |
|
||||
| `500` | Failed to parse JSON |
|
||||
|
||||
---
|
||||
|
||||
## Unregister
|
||||
|
||||
### `POST /api/v1/unregister`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Delete a registered file from the system. Supports single file by UUID, or batch by directory + regex pattern.
|
||||
|
||||
#### What gets deleted
|
||||
|
||||
| Removed (default) | Not removed |
|
||||
|---------|-------------|
|
||||
| Database records (videos, chunks, embeddings, processor_results, pre_chunks) | The original source video file on disk |
|
||||
| Processor output JSON files (`{uuid}.*.json`) — unless `delete_output_files: false` | Temp/working directories |
|
||||
| In-memory cache entries | |
|
||||
| MongoDB cached lists | |
|
||||
|
||||
> ⚠️ Database deletion is **irreversible**. To keep output files, set `"delete_output_files": false`.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
At least one mode must be specified: either `file_uuid` alone, or `file_path` + `pattern` together.
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `file_uuid` | string | * | — | Single file UUID to delete |
|
||||
| `file_path` | string | * | — | Directory path (for batch delete) |
|
||||
| `pattern` | string | * | — | Regex pattern (requires `file_path`) |
|
||||
| `delete_output_files` | boolean | No | `true` | If `true`, also delete processor output JSON files (`{uuid}.*.json`). Set to `false` to keep them. |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Delete a single file by UUID (default: also deletes output JSON files)
|
||||
curl -s -X POST "$API/api/v1/unregister" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'"}'
|
||||
|
||||
# Keep output JSON files, only delete DB records
|
||||
curl -s -X POST "$API/api/v1/unregister" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "delete_output_files": false}'
|
||||
|
||||
# Batch delete all mp4 files in a directory
|
||||
curl -s -X POST "$API/api/v1/unregister" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_path": "/path/to/dir", "pattern": ".*\\.mp4$"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "a03485a40b2df2d3",
|
||||
"message": "Video unregistered successfully"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | True if deletion succeeded |
|
||||
| `file_uuid` | string | UUID of the deleted file (single mode) |
|
||||
| `message` | string | Human-readable status |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | Neither `file_uuid` nor `file_path`+`pattern` provided |
|
||||
| `404` | File UUID not found |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
*Updated: 2026-06-20 — Added file listing, file detail, file identities, file faces, and JSON download endpoints*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,542 @@
|
||||
---
|
||||
title: process API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: process -->
|
||||
<!-- description: Processing pipeline — trigger, probe, progress, jobs -->
|
||||
<!-- depends: 01_auth, 03_register -->
|
||||
|
||||
## Processing Pipeline
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/process`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Trigger the processing pipeline for a registered file. Creates a monitor job that the worker picks up and processes sequentially. Returns immediately with the job info—processing runs asynchronously in the background.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `processors` | string[] | No | all | Specific processors to run: `["cut","asr","asrx","yolo","ocr","face","pose","visual_chunk","story","5w1h"]` |
|
||||
| `rules` | string[] | No | all | Rule names to apply (currently unused) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Run all processors
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/process" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" -d '{}'
|
||||
|
||||
# Run specific processors only
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/process" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"processors": ["asr", "face", "yolo"]}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Processing triggered",
|
||||
"file_uuid": "3a6c1865..."
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `message` | string | Human-readable status message |
|
||||
| `file_uuid` | string | 32-char hex UUID of the file |
|
||||
|
||||
**Note**: Processing runs asynchronously in the background. Use `/api/v1/job/:uuid` to track job status and `/api/v1/progress/:file_uuid` for real-time progress.
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | File UUID not found |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/probe`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get ffprobe metadata for a registered file. Returns video/audio stream info, codec details, duration, resolution, and frame rate.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/probe" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"file_name": "video.mp4",
|
||||
"file_size": 794863677,
|
||||
"duration": 120.5,
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"fps": 24.0,
|
||||
"total_frames": 2892,
|
||||
"cached": true,
|
||||
"format": {
|
||||
"filename": "/path/to/video.mp4",
|
||||
"format_name": "mov,mp4,m4a,3gp",
|
||||
"duration": "120.5",
|
||||
"size": "12345678",
|
||||
"bit_rate": "819200"
|
||||
},
|
||||
"streams": [
|
||||
{
|
||||
"index": 0,
|
||||
"codec_name": "h264",
|
||||
"codec_type": "video",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"r_frame_rate": "24/1",
|
||||
"duration": "120.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `file_name` | string | File name |
|
||||
| `file_size` | integer | File size in bytes (from filesystem) |
|
||||
| `duration` | float | Duration in seconds |
|
||||
| `width` | integer | Video width in pixels |
|
||||
| `height` | integer | Video height in pixels |
|
||||
| `fps` | float | Frames per second |
|
||||
| `total_frames` | integer | Estimated total frames |
|
||||
| `cached` | boolean | True if result was from cached probe JSON |
|
||||
| `format` | object | Container format info (ffprobe format section) |
|
||||
| `streams` | array | Array of stream info objects |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/progress/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get real-time processing progress for a file via Redis pub/sub. Includes per-processor status, current/total frames, ETA, and system resource stats.
|
||||
|
||||
**Note**: This endpoint uses **POST** method, not GET. The progress data is stored in Redis as a hash, and POST is used to retrieve the latest state.
|
||||
|
||||
#### Pipeline Order
|
||||
|
||||
| Order | Processor | Dependencies | Description |
|
||||
|-------|-----------|-------------|-------------|
|
||||
| 1 | `cut` | — | Scene detection |
|
||||
| 2 | `asr` | cut | Speech-to-text (per scene) |
|
||||
| 3 | `asrx` | asr | Speaker diarization |
|
||||
| 4 | `yolo` | — | Object detection |
|
||||
| 5 | `ocr` | — | Text recognition |
|
||||
| 6 | `face` | — | Face detection & embedding (8Hz sampling) |
|
||||
| 7 | `face_trace` | face | Face tracking (IoU + embedding, assigns trace_id) |
|
||||
| 8 | `pose` | face_trace | Pose expansion from face traces, inherits trace_id |
|
||||
| 9 | `appearance` | pose | Appearance expansion from pose traces, inherits trace_id |
|
||||
|
||||
**Key Concepts:**
|
||||
- **Face** = Identity anchor (who is this person?) — requires high-quality embedding
|
||||
- **Pose** = Tracking (where is this person?) — extends tracking when face is occluded
|
||||
- **Appearance** = Tracking (what do they look like?) — extends tracking when pose is occluded
|
||||
|
||||
**Trace ID Inheritance:**
|
||||
```
|
||||
Face trace (identity anchor)
|
||||
↓ inherits trace_id
|
||||
Pose expansion (tracking continuity)
|
||||
↓ inherits trace_id
|
||||
Appearance expansion (tracking continuity)
|
||||
```
|
||||
|
||||
**Frame Count Relationship:**
|
||||
```
|
||||
face frames ≤ pose frames ≤ appearance frames
|
||||
```
|
||||
(Each level expands outward from the previous level's traces)
|
||||
|
||||
All processors except `story` and `5w1h` run concurrently when their dependencies are met. Story and 5W1H run sequentially after their prerequisites.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/progress/$FILE_UUID" -H "X-API-Key: $KEY" | jq '{overall_progress, processors: [.processors[] | {name, status}]}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"overall_progress": 71,
|
||||
"cpu_percent": 45.2,
|
||||
"gpu_percent": 30.1,
|
||||
"memory_percent": 62.4,
|
||||
"processors": [
|
||||
{"processor_type": "asr", "status": "complete", "progress": 100},
|
||||
{"processor_type": "yolo", "status": "running", "progress": 65},
|
||||
{"processor_type": "face", "status": "pending", "progress": 0}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `overall_progress` | integer | Overall progress percentage (0–100) |
|
||||
| `processors` | array | Per-processor status list |
|
||||
| `processors[].processor_type` | string | Processor name (`asr`, `cut`, `yolo`, etc.) |
|
||||
| `processors[].status` | string | `"pending"`, `"running"`, `"complete"`, or `"failed"` |
|
||||
| `processors[].progress` | integer | Per-processor progress (0–100) |
|
||||
| `processors[].eta_seconds` | integer | Estimated seconds remaining (running processors) |
|
||||
| `processors[].current` | integer | Current frame count |
|
||||
| `processors[].total` | integer | Total frame count |
|
||||
| `cpu_percent` | float | Current CPU usage |
|
||||
| `gpu_percent` | float | Current GPU utilization |
|
||||
| `memory_percent` | float | Current memory usage |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/jobs`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
List all processing jobs (monitor jobs) in the system. Shows job status, which file each job is processing, and current processor info.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/jobs" -H "X-API-Key: $KEY" | jq '{count, jobs: [.jobs[] | {uuid, status}]}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"id": 42,
|
||||
"uuid": "3a6c1865...",
|
||||
"status": "running",
|
||||
"current_processor": "yolo",
|
||||
"created_at": "2026-05-16T12:00:00Z",
|
||||
"started_at": "2026-05-16T12:01:00Z"
|
||||
}
|
||||
],
|
||||
"count": 15,
|
||||
"page": 1,
|
||||
"page_size": 20
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `jobs` | array | Array of job info objects |
|
||||
| `jobs[].id` | integer | Job ID |
|
||||
| `jobs[].uuid` | string | File UUID being processed |
|
||||
| `jobs[].status` | string | `"pending"`, `"running"`, `"completed"`, `"failed"` |
|
||||
| `jobs[].current_processor` | string | Currently active processor, or null |
|
||||
| `count` | integer | Total job count |
|
||||
| `page` | integer | Current page number |
|
||||
| `page_size` | integer | Jobs per page |
|
||||
|
||||
### `GET /api/v1/job/:uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get detailed information about a specific processing job, including its queue position.
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 51,
|
||||
"uuid": "c36f35685177c981aa139b66bbbccc5b",
|
||||
"status": "queued",
|
||||
"current_processor": null,
|
||||
"progress_current": 0,
|
||||
"progress_total": 0,
|
||||
"processors": [],
|
||||
"created_at": "2026-06-22 23:08:48.497018",
|
||||
"started_at": null,
|
||||
"updated_at": null,
|
||||
"queue_position": 3
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `id` | integer | Monitor job ID |
|
||||
| `uuid` | string | File UUID |
|
||||
| `status` | string | `"pending"`, `"queued"`, `"running"`, `"completed"`, `"failed"` |
|
||||
| `current_processor` | string | Currently active processor, or null |
|
||||
| `progress_current` | integer | Current progress count |
|
||||
| `progress_total` | integer | Total progress count |
|
||||
| `processors` | array | Processor list |
|
||||
| `created_at` | string | Job creation timestamp |
|
||||
| `started_at` | string | Processing start timestamp, or null |
|
||||
| `updated_at` | string | Last update timestamp, or null |
|
||||
| `queue_position` | integer | Position in FIFO queue (null if not pending/queued) |
|
||||
|
||||
---
|
||||
|
||||
### Status Lifecycle
|
||||
|
||||
```
|
||||
register ──→ pending
|
||||
│
|
||||
trigger (POST /process)
|
||||
│
|
||||
queued ←── queue_position counts jobs ahead
|
||||
│
|
||||
worker picks up
|
||||
│
|
||||
processing
|
||||
│
|
||||
┌────────┴────────┐
|
||||
▼ ▼
|
||||
completed failed
|
||||
│
|
||||
checkin ──→ indexed
|
||||
checkout ──→ checked_out
|
||||
```
|
||||
|
||||
| Status | Meaning |
|
||||
|--------|---------|
|
||||
| `pending` | File registered, not yet triggered |
|
||||
| `queued` | Triggered, waiting for worker in FIFO queue |
|
||||
| `processing` | Worker actively processing |
|
||||
| `completed` | All processors finished successfully |
|
||||
| `failed` | One or more essential processors failed |
|
||||
| `indexed` | Post-processing checkin complete |
|
||||
| `checked_out` | User checked out the file |
|
||||
|
||||
Queue order is FIFO (`created_at ASC`). The `GET /api/v1/job/:uuid` endpoint returns `queue_position` showing how many jobs are ahead.
|
||||
|
||||
### Frontend Status Mapping
|
||||
|
||||
When displaying file status in the frontend list (e.g. after `GET /api/v1/files/scan`), map the `status` field as follows:
|
||||
|
||||
| DB Status | Status Label | Filter: 待處理 | Filter: 處理中 | Count: pendingCount | Count: processingCount |
|
||||
|-----------|-------------|----------------|----------------|---------------------|-----------------------|
|
||||
| `unregistered` | 未註冊 | No | No | No | No |
|
||||
| `registered` | 待處理 | **Yes** | No | **Yes** | No |
|
||||
| `pending` | 待處理 | **Yes** | No | **Yes** | No |
|
||||
| `queued` | 排隊中 | **Yes** | **Yes** | **Yes** | **Yes** |
|
||||
| `processing` | 處理中 | No | **Yes** | No | **Yes** |
|
||||
| `completed` | 已完成 | No | No | No | No |
|
||||
| `failed` | 處理失敗 | No | No | No | No |
|
||||
| `indexed` | 已入庫 | No | No | No | No |
|
||||
|
||||
**`queued` 的特殊處理**:
|
||||
- `statusLabel` → 顯示「排隊中」,加 `ms-badge-warn` 樣式(黃色)
|
||||
- `filterPending` → 應包含 `queued`,讓它在「待處理」filter 可見
|
||||
- `pendingCount` + `processingCount` → 兩者都應包含 `queued`,因它既是「待處理」也是「正在排隊」
|
||||
- 在 `refreshAllStatus` / `loadFiles` 中,如果檔案狀態是 `queued`,應顯示簡單的排隊訊息(無需 polling progress)
|
||||
- 當 worker pickup 後,狀態會變為 `processing`,此時 `refreshAllStatus` 會自動偵測到並開始 polling progress
|
||||
- 也可以提供一個「queue_position」顯示:呼叫 `GET /api/v1/job/:uuid` 取得排在第幾位
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/processor-counts`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get counts of processor JSON output files. See `15_tkg.md` for full documentation.
|
||||
|
||||
---
|
||||
|
||||
## Pipeline Steps (Manual)
|
||||
|
||||
These endpoints execute individual pipeline steps. They are typically called by the worker automatically, but can be invoked manually for debugging or re-processing.
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/store-asrx`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Store ASRX diarization results as chunk records in the database. Converts ASRX segments into searchable chunk entries.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/store-asrx" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "ASRX chunks stored",
|
||||
"file_uuid": "3a6c1865..."
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/rule1`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Execute Rule 1 pipeline step. Applies rule-based chunking to create structured chunk records from processor outputs.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/rule1" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Rule 1 complete: 45 chunks",
|
||||
"file_uuid": "3a6c1865...",
|
||||
"chunks": 45
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `message` | string | Human-readable completion message |
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `chunks` | integer | Number of chunks produced |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/vectorize`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Generate vector embeddings for all chunks of a file and store them in Qdrant for semantic search.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/vectorize" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Vectorization complete",
|
||||
"file_uuid": "3a6c1865..."
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/phase1`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Execute Phase 1 of the post-processing pipeline. Combines store-asrx, rule1, and vectorize into a single step.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/phase1" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Phase 1 complete",
|
||||
"file_uuid": "3a6c1865..."
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/complete`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Mark a video as fully processed. Updates the video status to `completed` and finalizes all pipeline state.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/complete" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Video marked as completed",
|
||||
"file_uuid": "3a6c1865..."
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Pipeline Step Order
|
||||
|
||||
```
|
||||
process (trigger)
|
||||
│
|
||||
├─→ cut, yolo, ocr, face, pose, asrx (parallel processors)
|
||||
│
|
||||
├─→ store-asrx (store diarization as chunks)
|
||||
│
|
||||
├─→ rule1 (rule-based chunking)
|
||||
│
|
||||
├─→ vectorize (embed chunks to Qdrant)
|
||||
│
|
||||
└─→ complete (mark done)
|
||||
```
|
||||
|
||||
Phase 1 (`/phase1`) combines store-asrx + rule1 + vectorize into one call.
|
||||
|
||||
---
|
||||
*Updated: 2026-06-23 — Added queued status, FIFO queue order, queue_position in job detail, frontend status mapping table*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,146 @@
|
||||
---
|
||||
title: pipeline API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: pipeline -->
|
||||
<!-- description: Pipeline processors, ingestion status, stats endpoints -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## Pipeline
|
||||
|
||||
### Pipeline Completion Flow
|
||||
|
||||
The pipeline is **not complete** until both the 10 processors AND the 入庫 (ingestion) steps have finished. The worker polls every 3 seconds and only marks the job as `completed` when all ingestion steps verify OK.
|
||||
|
||||
```
|
||||
10 processors done
|
||||
↓ (job status stays "running")
|
||||
Algorithm 1 Trigger: Rule 1 + Vectorize + Phase 1 Pack
|
||||
↓ (job runs in parallel)
|
||||
Algorithm 2 Trigger: Face Trace → TKG, Scene Metadata, Identity Agent, 5W1H Agent
|
||||
↓ (poll checks every 3s)
|
||||
Ingestion verification: rule1 ✓ vectorize ✓ rule3 ✓ face_trace ✓ tkg ✓ scene_meta ✓ 5w1h ✓
|
||||
↓
|
||||
job status = "completed"
|
||||
```
|
||||
|
||||
### 10 Processor Stages
|
||||
|
||||
| # | Processor | Depends On | Description |
|
||||
|---|-----------|------------|-------------|
|
||||
| 1 | `Cut` | — | Scene boundary detection (PySceneDetect) |
|
||||
| 2 | `ASR` | Cut | Automatic speech recognition (faster-whisper) |
|
||||
| 3 | `ASRX` | ASR | Speaker diarization + ASR refinement |
|
||||
| 4 | `YOLO` | — | Object detection (YOLOv8) |
|
||||
| 5 | `OCR` | — | Optical character recognition |
|
||||
| 6 | `Face` | — | Face detection + recognition (InsightFace + CoreML) |
|
||||
| 7 | `Pose` | — | Pose estimation |
|
||||
| 8 | `VisualChunk` | YOLO | Visual object chunking |
|
||||
| 9 | `Story` | ASRX + Cut + YOLO + Face | Narrative scene summarization (LLM, with embedding) |
|
||||
| 10 | `5W1H` | Story | Who/What/When/Where/Why extraction (LLM, with embedding) |
|
||||
|
||||
### 入庫 (Post-Processing / Ingestion)
|
||||
|
||||
These steps run after the 10 processors and are **required for pipeline completion**. The worker checks all of them before marking the job as done.
|
||||
|
||||
| # | Step | Triggers When | Verification |
|
||||
|---|------|--------------|-------------|
|
||||
| 1 | **Rule 1 Sentence Chunking** | ASR + ASRX done | `chunk` table has rows with `chunk_type = 'sentence'` |
|
||||
| 1.1 | **Rule 1 OCR Chunks** | OCR done | OCR pre_chunks grouped into sentence chunks |
|
||||
| 2 | **Auto-Vectorize** | Rule 1 done | `chunk.embedding` IS NOT NULL for sentence chunks |
|
||||
| 3 | **Phase 1 Pack** | Rule 1 done | `release_pack.py --phase 1` executed |
|
||||
| 4 | **Rule 3 Scene Chunking** | All 10 processors done + Cut + ASR | `chunk` table has rows with `chunk_type = 'cut'` |
|
||||
| 5 | **Face Trace** | All 10 processors done + Face | `face_detections.trace_id` IS NOT NULL |
|
||||
| 6 | **Qdrant Face Sync** | Face Trace done | Qdrant face_embedding collection populated |
|
||||
| 7 | **Trace Chunks** | Face Trace done | `chunk` table has rows with `chunk_type = 'trace'` |
|
||||
| 8 | **TKG Builder** | Face Trace done | `tkg_nodes` + `tkg_edges` tables have rows |
|
||||
| 9 | **TMDb Face Matching** | TMDb enabled + Face done | `face_detections.identity_id` IS NOT NULL |
|
||||
| 10 | **Heuristic Scene Metadata** | Face + YOLO done | `{file_uuid}.scene_meta.json` exists on disk |
|
||||
| 11 | **Template 5W1H Story Summary (PG)** | Story done | `chunk.embedding` IS NOT NULL for story chunks |
|
||||
| 12 | **LLM 5W1H Summary (PG)** | 5W1H done | `chunk.embedding` IS NOT NULL for llm chunks |
|
||||
| 13 | **Voice Embedding (Qdrant)** | ASRX done | Qdrant voice collection populated |
|
||||
| 14 | **Face Embedding (Qdrant)** | Face done | Qdrant face collection populated |
|
||||
| 15 | **Identity Agent** | Face + ASRX done | `identities` with `source = 'identity_agent'` |
|
||||
| 16 | **5W1H Agent** | Cut + ASR done | `chunk.summary_text` IS NOT NULL for cut chunks |
|
||||
| 17 | **Release Pack** | 5W1H Agent done | `release_pack.py --phase 2` executed |
|
||||
|
||||
### Ingestion Status
|
||||
|
||||
Check real-time ingestion status for a file:
|
||||
|
||||
```bash
|
||||
curl "$API/api/v1/stats/ingestion-status/{file_uuid}"
|
||||
```
|
||||
|
||||
Returns per-step `done` / `pending` status with detail counts.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl "$API/api/v1/stats/ingestion-status/bd80fec9c42afb0307eb28f22c64c76a" | jq '.steps[] | {name, status, detail}'
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "bd80fec9c42afb0307eb28f22c64c76a",
|
||||
"steps": [
|
||||
{ "name": "rule1_sentence", "status": "done", "detail": "35 sentence chunks" },
|
||||
{ "name": "rule1_ocr", "status": "done", "detail": "30 OCR frames" },
|
||||
{ "name": "rule1_ocr_chunks", "status": "done", "detail": "3 OCR-only chunks" },
|
||||
{ "name": "auto_vectorize", "status": "pending", "detail": "0 embedded" },
|
||||
{ "name": "rule3_scene", "status": "pending", "detail": "0 scene chunks" },
|
||||
{ "name": "face_trace", "status": "pending", "detail": "0 traces" },
|
||||
{ "name": "trace_chunks", "status": "pending", "detail": "0 trace chunks" },
|
||||
{ "name": "tkg", "status": "pending", "detail": "0 nodes, 0 edges" },
|
||||
{ "name": "identity_match", "status": "pending", "detail": "0 identities" },
|
||||
{ "name": "scene_metadata", "status": "pending", "detail": null },
|
||||
{ "name": "5w1h", "status": "pending", "detail": "0 scenes with 5W1H" }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Stats Endpoints
|
||||
|
||||
| Method | Endpoint | Auth | Description |
|
||||
|--------|----------|------|-------------|
|
||||
| GET | `/api/v1/stats/sftpgo` | No | SFTPGo service status |
|
||||
| GET | `/api/v1/stats/ingestion-status/:file_uuid` | No | Per-file ingestion checklist |
|
||||
|
||||
### Configuration
|
||||
|
||||
See [13_config.md](13_config.md) for runtime configuration endpoints:
|
||||
|
||||
| Endpoint | Description |
|
||||
|----------|-------------|
|
||||
| `POST /api/v1/config/cache` | Toggle Redis cache |
|
||||
| `POST /api/v1/config/auto-pipeline` | Toggle auto-pipeline on register |
|
||||
| `POST /api/v1/config/watcher-auto-register` | Toggle watcher auto-register |
|
||||
|
||||
### Unmounted Routes
|
||||
|
||||
The following routes are defined in source code but are **NOT** currently mounted in the router:
|
||||
|
||||
| Endpoint | Source file |
|
||||
|----------|-------------|
|
||||
| `/api/v1/search/people` | `universal_search.rs` (mounted) |
|
||||
| `/api/v1/who` | `who.rs` |
|
||||
| `/api/v1/who/candidates` | `who.rs` |
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 23:21:51*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,563 @@
|
||||
---
|
||||
title: progress API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: progress -->
|
||||
<!-- description: Real-time progress tracking for processing pipeline, TKG build, and identity agent -->
|
||||
<!-- depends: 01_auth, 03_register, 05_process -->
|
||||
|
||||
# Progress Tracking — API Workspace Module
|
||||
|
||||
## Overview
|
||||
|
||||
The progress tracking system provides real-time visibility into all processing stages:
|
||||
|
||||
| System | Redis Key | Coverage |
|
||||
|--------|-----------|----------|
|
||||
| **Processor Progress** | `{prefix}progress:{file_uuid}` | 7 main processors (cut, asr, asrx, ocr, face, pose, appearance) |
|
||||
| **TKG Progress** | `{prefix}progress:{file_uuid}:tkg` | 18 TKG build phases (9 node types + 8 edge types + face_tracing) |
|
||||
| **Agent Progress** | `{prefix}progress:{file_uuid}:agent` | 5 Identity Agent phases |
|
||||
|
||||
---
|
||||
|
||||
## `POST /api/v1/progress/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get real-time processing progress including processor status, TKG build phases, and identity agent phases.
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/progress/$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY" | jq '.'
|
||||
```
|
||||
|
||||
### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"overall_progress": 71,
|
||||
"cpu_percent": 45.2,
|
||||
"gpu_percent": 30.1,
|
||||
"memory_percent": 62.4,
|
||||
"processors": [
|
||||
{"name": "asr", "status": "complete", "progress": 100, "current": 0, "total": 0, "message": "done"},
|
||||
{"name": "face", "status": "complete", "progress": 100, "current": 0, "total": 0, "message": "done"},
|
||||
{"name": "pose", "status": "complete", "progress": 100, "current": 0, "total": 0, "message": "done"}
|
||||
],
|
||||
"tkg_progress": {
|
||||
"file_uuid": "3a6c1865...",
|
||||
"phase": "mutual_gaze_edges",
|
||||
"phase_index": 13,
|
||||
"total_phases": 18,
|
||||
"phase_progress": 0.8,
|
||||
"overall_progress": 0.72,
|
||||
"stats": {
|
||||
"total_faces": 1250,
|
||||
"traced_faces": 1250,
|
||||
"total_traces": 45,
|
||||
"face_track_nodes": 45,
|
||||
"gaze_track_nodes": 45,
|
||||
"lip_track_nodes": 12,
|
||||
"text_region_nodes": 8,
|
||||
"appearance_nodes": 38,
|
||||
"accessory_nodes": 5,
|
||||
"object_nodes": 156,
|
||||
"hand_nodes": 22,
|
||||
"speaker_nodes": 14,
|
||||
"co_occurrence_edges": 890,
|
||||
"speaker_face_edges": 120,
|
||||
"face_face_edges": 234,
|
||||
"mutual_gaze_edges": 67,
|
||||
"total_nodes": 345,
|
||||
"total_edges": 1311
|
||||
},
|
||||
"message": "67 mutual gaze edges",
|
||||
"updated_at": "2026-07-02T10:30:00Z"
|
||||
},
|
||||
"agent_progress": {
|
||||
"file_uuid": "3a6c1865...",
|
||||
"phase": "completed",
|
||||
"phase_index": 5,
|
||||
"total_phases": 5,
|
||||
"phase_progress": 1.0,
|
||||
"overall_progress": 1.0,
|
||||
"stats": {
|
||||
"total_faces": 1250,
|
||||
"total_traces": 45,
|
||||
"clusters": 18,
|
||||
"identities_created": 18,
|
||||
"tmdb_matches": 5,
|
||||
"speaker_bindings": 12,
|
||||
"confirmations": 18
|
||||
},
|
||||
"message": "Identity Agent processing completed",
|
||||
"updated_at": "2026-07-02T10:28:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Field Descriptions
|
||||
|
||||
#### Top Level
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `overall_progress` | integer | Overall processor progress (0–100) |
|
||||
| `processors` | array | Per-processor status |
|
||||
| `tkg_progress` | object | TKG build progress (null if not started) |
|
||||
| `agent_progress` | object | Identity Agent progress (null if not started) |
|
||||
|
||||
#### TKG Progress Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `phase` | string | Current phase name (see TKG Phases below) |
|
||||
| `phase_index` | integer | Current phase index (0–17) |
|
||||
| `total_phases` | integer | Total phases: 18 |
|
||||
| `phase_progress` | float | Progress within current phase (0.0–1.0) |
|
||||
| `overall_progress` | float | Overall TKG progress (0.0–1.0) |
|
||||
| `stats` | object | Counts for all node and edge types |
|
||||
| `message` | string | Human-readable status message |
|
||||
|
||||
#### TKG Phases (18 total)
|
||||
|
||||
| Index | Phase | Description |
|
||||
|-------|-------|-------------|
|
||||
| 0 | `face_tracing` | Populate trace_id from face.json |
|
||||
| 1 | `face_track_nodes` | Build face_track nodes |
|
||||
| 2 | `gaze_track_nodes` | Build gaze_track nodes |
|
||||
| 3 | `lip_track_nodes` | Build lip_track nodes |
|
||||
| 4 | `text_region_nodes` | Build text_region nodes |
|
||||
| 5 | `appearance_nodes` | Build appearance_trace nodes |
|
||||
| 6 | `accessory_nodes` | Build accessory nodes |
|
||||
| 7 | `object_nodes` | Build yolo_object nodes |
|
||||
| 8 | `hand_nodes` | Build hand nodes |
|
||||
| 9 | `speaker_nodes` | Build speaker nodes |
|
||||
| 10 | `co_occurrence_edges` | Build co_occurrence edges |
|
||||
| 11 | `speaker_face_edges` | Build speaker_face edges |
|
||||
| 12 | `face_face_edges` | Build face_face edges |
|
||||
| 13 | `mutual_gaze_edges` | Build mutual_gaze edges |
|
||||
| 14 | `lip_sync_edges` | Build lip_sync edges |
|
||||
| 15 | `has_appearance_edges` | Build has_appearance edges |
|
||||
| 16 | `wears_edges` | Build wears edges |
|
||||
| 17 | `hand_object_edges` | Build hand_object edges |
|
||||
|
||||
#### TKG Stats Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `total_faces` | integer | Total face detections |
|
||||
| `traced_faces` | integer | Faces with trace_id assigned |
|
||||
| `total_traces` | integer | Unique trace count |
|
||||
| `face_track_nodes` | integer | Face track nodes created |
|
||||
| `gaze_track_nodes` | integer | Gaze track nodes created |
|
||||
| `lip_track_nodes` | integer | Lip track nodes created |
|
||||
| `text_region_nodes` | integer | Text region nodes created |
|
||||
| `appearance_nodes` | integer | Appearance trace nodes created |
|
||||
| `accessory_nodes` | integer | Accessory nodes created |
|
||||
| `object_nodes` | integer | YOLO object nodes created |
|
||||
| `hand_nodes` | integer | Hand nodes created |
|
||||
| `speaker_nodes` | integer | Speaker nodes created |
|
||||
| `co_occurrence_edges` | integer | Co-occurrence edges created |
|
||||
| `speaker_face_edges` | integer | Speaker-face edges created |
|
||||
| `face_face_edges` | integer | Face-face edges created |
|
||||
| `mutual_gaze_edges` | integer | Mutual gaze edges created |
|
||||
| `lip_sync_edges` | integer | Lip sync edges created |
|
||||
| `has_appearance_edges` | integer | Has-appearance edges created |
|
||||
| `wears_edges` | integer | Wears edges created |
|
||||
| `hand_object_edges` | integer | Hand-object edges created |
|
||||
| `total_nodes` | integer | Total nodes (sum of all node types) |
|
||||
| `total_edges` | integer | Total edges (sum of all edge types) |
|
||||
|
||||
---
|
||||
|
||||
## `GET /api/v1/stats/ingestion-status/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get detailed ingestion status showing completion of all 24 processing steps.
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/stats/ingestion-status/$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY" | jq '.steps[] | {name, status, detail}'
|
||||
```
|
||||
|
||||
### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"steps": [
|
||||
{"name": "rule1_sentence", "status": "done", "detail": "156 sentence chunks"},
|
||||
{"name": "auto_vectorize", "status": "done", "detail": "156 embedded"},
|
||||
{"name": "face_track", "status": "done", "detail": "45 traces / 1250 detections"},
|
||||
{"name": "trace_chunks", "status": "done", "detail": "45 trace chunks"},
|
||||
{"name": "tkg_face_track", "status": "done", "detail": "45 nodes"},
|
||||
{"name": "tkg_gaze_track", "status": "done", "detail": "45 nodes"},
|
||||
{"name": "tkg_lip_track", "status": "done", "detail": "12 nodes"},
|
||||
{"name": "tkg_text_region", "status": "done", "detail": "8 nodes"},
|
||||
{"name": "tkg_appearance", "status": "done", "detail": "38 nodes"},
|
||||
{"name": "tkg_accessory", "status": "done", "detail": "5 nodes"},
|
||||
{"name": "tkg_object", "status": "done", "detail": "156 nodes"},
|
||||
{"name": "tkg_hand", "status": "done", "detail": "22 nodes"},
|
||||
{"name": "tkg_speaker", "status": "done", "detail": "14 nodes"},
|
||||
{"name": "tkg_co_occurrence", "status": "done", "detail": "890 edges"},
|
||||
{"name": "tkg_speaker_face", "status": "done", "detail": "120 edges"},
|
||||
{"name": "tkg_face_face", "status": "done", "detail": "234 edges"},
|
||||
{"name": "tkg_mutual_gaze", "status": "done", "detail": "67 edges"},
|
||||
{"name": "tkg_lip_sync", "status": "done", "detail": "12 edges"},
|
||||
{"name": "tkg_has_appearance", "status": "done", "detail": "38 edges"},
|
||||
{"name": "tkg_wears", "status": "done", "detail": "22 edges"},
|
||||
{"name": "tkg_hand_object", "status": "done", "detail": "18 edges"},
|
||||
{"name": "rule2_relationship", "status": "done", "detail": "1331 relationship chunks"},
|
||||
{"name": "identity_match", "status": "done", "detail": "18 identities matched"},
|
||||
{"name": "scene_metadata", "status": "done", "detail": null}
|
||||
],
|
||||
"related_identities": [
|
||||
{"uuid": "a9a901056d6b46ff92da0c3c1a57dff4", "name": "John Smith"}
|
||||
],
|
||||
"strangers": 3
|
||||
}
|
||||
```
|
||||
|
||||
### Step Descriptions
|
||||
|
||||
| Step | Status When Done |
|
||||
|------|-----------------|
|
||||
| `rule1_sentence` | sentence_count > 0 |
|
||||
| `auto_vectorize` | sentence_embedded > 0 |
|
||||
| `face_track` | trace_count > 0 |
|
||||
| `trace_chunks` | trace_chunks > 0 |
|
||||
| `tkg_face_track` → `tkg_speaker` | Node count > 0 (9 steps) |
|
||||
| `tkg_co_occurrence` → `tkg_hand_object` | Edge count > 0 (8 steps) |
|
||||
| `rule2_relationship` | relationship_chunks > 0 |
|
||||
| `identity_match` | identity_count > 0 |
|
||||
| `scene_metadata` | scene_meta.json exists |
|
||||
|
||||
---
|
||||
|
||||
## `POST /api/v1/file/:file_uuid/tkg/rebuild`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Manually trigger TKG rebuild. Automatically triggers Rule 2 ingestion after TKG completes.
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/rebuild" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" -d '{}'
|
||||
```
|
||||
|
||||
### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "TKG rebuild started",
|
||||
"nodes": 345,
|
||||
"edges": 1311
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## `POST /api/v1/file/:file_uuid/rule2`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Manually trigger Rule 2 ingestion (TKG edges → relationship chunks).
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/rule2" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" -d '{}'
|
||||
```
|
||||
|
||||
### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Rule 2 ingestion: 1331 relationship chunks created",
|
||||
"rule2_count": 1331
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Processing Pipeline Flow
|
||||
|
||||
```
|
||||
1. Processors (concurrent)
|
||||
├── cut, asr, ocr, face, pose, appearance → complete
|
||||
└── asrx → after cut+asr
|
||||
|
||||
2. Post-Processor Triggers (automatic)
|
||||
├── Rule 1 Ingestion (ASR+OCR → sentence chunks)
|
||||
├── Face Trace + DB Store (face_traced.json → Qdrant trace_id)
|
||||
├── TMDb Face Matching (if enabled)
|
||||
├── Heuristic Scene Metadata
|
||||
├── Identity Agent (face + ASRX)
|
||||
└── TKG Build (automatic after processors complete)
|
||||
└── Rule 2 Ingestion (automatic after TKG)
|
||||
└── Relationship chunks vectorized
|
||||
|
||||
3. Completion
|
||||
└── Job marked completed when all ingestion steps done
|
||||
```
|
||||
|
||||
## Error Codes
|
||||
|
||||
| Code | HTTP | When |
|
||||
|------|------|------|
|
||||
| E001 | 400 | Invalid file_uuid format |
|
||||
| E002 | 404 | File not found |
|
||||
| E003 | 404 | No TKG data available |
|
||||
| E010 | 500 | Qdrant connection failed |
|
||||
| E011 | 500 | Database connection failed |
|
||||
|
||||
---
|
||||
|
||||
## `GET /api/v1/stats/pipeline/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get segmented pipeline progress with weighted stage breakdown. Shows overall progress as weighted sum of all pipeline stages.
|
||||
|
||||
### Pipeline Stages and Weights
|
||||
|
||||
| Stage | Weight | Description |
|
||||
|-------|--------|-------------|
|
||||
| `processors` | 30% | 7 concurrent processors (cut, asr, asrx, ocr, face, pose, appearance) |
|
||||
| `rule1_ingestion` | 5% | ASR+OCR → sentence chunks |
|
||||
| `face_tracing` | 5% | Face trace_id assignment |
|
||||
| `identity_agent` | 10% | Identity creation, TMDb matching, speaker binding |
|
||||
| `tkg_nodes` | 20% | TKG node building (9 node types) |
|
||||
| `tkg_edges` | 15% | TKG edge building (8 edge types) |
|
||||
| `rule2_ingestion` | 15% | TKG edges → relationship chunks |
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/stats/pipeline/$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY" | jq '.'
|
||||
```
|
||||
|
||||
### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"overall_progress": 0.65,
|
||||
"stages": [
|
||||
{"name": "processors", "weight": 0.30, "progress": 1.0, "status": "completed", "detail": "7/7 complete"},
|
||||
{"name": "rule1_ingestion", "weight": 0.05, "progress": 1.0, "status": "completed", "detail": "156 chunks"},
|
||||
{"name": "face_tracing", "weight": 0.05, "progress": 1.0, "status": "completed", "detail": "45 traces"},
|
||||
{"name": "identity_agent", "weight": 0.10, "progress": 1.0, "status": "completed", "detail": "18 identities"},
|
||||
{"name": "tkg_nodes", "weight": 0.20, "progress": 1.0, "status": "completed", "detail": "345 nodes"},
|
||||
{"name": "tkg_edges", "weight": 0.15, "progress": 0.5, "status": "running", "detail": "mutual_gaze_edges: 67/8 expected"},
|
||||
{"name": "rule2_ingestion", "weight": 0.15, "progress": 0.0, "status": "pending", "detail": null}
|
||||
],
|
||||
"updated_at": "2026-07-02T10:30:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Field Descriptions
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `overall_progress` | float | Weighted sum of all stage progress (0.0–1.0) |
|
||||
| `stages` | array | Per-stage progress breakdown |
|
||||
| `stages[].name` | string | Stage name |
|
||||
| `stages[].weight` | float | Stage weight in overall progress |
|
||||
| `stages[].progress` | float | Stage completion (0.0–1.0) |
|
||||
| `stages[].status` | string | `"pending"`, `"running"`, `"completed"`, `"failed"` |
|
||||
| `stages[].detail` | string | Human-readable detail (optional) |
|
||||
| `updated_at` | string | ISO 8601 timestamp |
|
||||
|
||||
### Overall Progress Calculation
|
||||
|
||||
```
|
||||
overall_progress = Σ(stage.weight × stage.progress) for all stages
|
||||
```
|
||||
|
||||
Example calculation:
|
||||
- processors: 0.30 × 1.0 = 0.30
|
||||
- rule1_ingestion: 0.05 × 1.0 = 0.05
|
||||
- face_tracing: 0.05 × 1.0 = 0.05
|
||||
- identity_agent: 0.10 × 1.0 = 0.10
|
||||
- tkg_nodes: 0.20 × 1.0 = 0.20
|
||||
- tkg_edges: 0.15 × 0.5 = 0.075
|
||||
- rule2_ingestion: 0.15 × 0.0 = 0.0
|
||||
- **Total: 0.775 (77.5%)**
|
||||
|
||||
---
|
||||
|
||||
## `GET /api/v1/stats/file/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get comprehensive file statistics from all data sources: JSON processing status, PostgreSQL counts, Qdrant collections, TKG nodes/edges, and Identity Agent stats.
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/stats/file/$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY" | jq '.'
|
||||
```
|
||||
|
||||
### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"file_name": "video.mp4",
|
||||
"status": "processing",
|
||||
"processors": [
|
||||
{"name": "asr", "status": "complete", "progress": 100, "message": "done"},
|
||||
{"name": "face", "status": "complete", "progress": 100, "message": "done"}
|
||||
],
|
||||
"postgres": {
|
||||
"sentence_chunks": 156,
|
||||
"trace_chunks": 45,
|
||||
"relationship_chunks": 1331,
|
||||
"identities": 18,
|
||||
"file_identities": 18
|
||||
},
|
||||
"qdrant": {
|
||||
"faces": 1250,
|
||||
"face_traces": 45,
|
||||
"face_identities": 18,
|
||||
"text_chunks": 4562,
|
||||
"speakers": 434
|
||||
},
|
||||
"tkg": {
|
||||
"total_nodes": 345,
|
||||
"total_edges": 1311,
|
||||
"face_track_nodes": 45,
|
||||
"gaze_track_nodes": 45,
|
||||
"lip_track_nodes": 12,
|
||||
"text_region_nodes": 8,
|
||||
"appearance_nodes": 38,
|
||||
"accessory_nodes": 5,
|
||||
"object_nodes": 156,
|
||||
"hand_nodes": 22,
|
||||
"speaker_nodes": 14,
|
||||
"co_occurrence_edges": 890,
|
||||
"speaker_face_edges": 120,
|
||||
"face_face_edges": 234,
|
||||
"mutual_gaze_edges": 67,
|
||||
"lip_sync_edges": 12,
|
||||
"has_appearance_edges": 38,
|
||||
"wears_edges": 22,
|
||||
"hand_object_edges": 18
|
||||
},
|
||||
"identity_agent": {
|
||||
"clusters": 18,
|
||||
"identities_created": 18,
|
||||
"tmdb_matches": 5,
|
||||
"speaker_bindings": 12,
|
||||
"confirmations": 18
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Field Descriptions
|
||||
|
||||
#### Top Level
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `file_name` | string | Original filename |
|
||||
| `status` | string | File status: `registered`, `processing`, `completed`, `failed` |
|
||||
| `processors` | array | Per-processor status from processing_status JSONB |
|
||||
| `postgres` | object | PostgreSQL table counts |
|
||||
| `qdrant` | object | Qdrant collection point counts |
|
||||
| `tkg` | object | TKG node and edge counts by type |
|
||||
| `identity_agent` | object | Identity Agent statistics |
|
||||
|
||||
#### PostgreSQL Stats
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `sentence_chunks` | integer | Rule 1 sentence chunks count |
|
||||
| `trace_chunks` | integer | Face trace chunks count |
|
||||
| `relationship_chunks` | integer | Rule 2 relationship chunks count |
|
||||
| `identities` | integer | Unique identities bound to this file |
|
||||
| `file_identities` | integer | File-identity mapping records |
|
||||
|
||||
#### Qdrant Stats
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `faces` | integer | Total face points in `_faces` collection |
|
||||
| `face_traces` | integer | Unique trace IDs in `_faces` |
|
||||
| `face_identities` | integer | Unique identity IDs bound in `_faces` |
|
||||
| `text_chunks` | integer | Text chunk vectors in `momentry_*_rule1_v2` |
|
||||
| `speakers` | integer | Speaker segments in `momentry_*_speaker` |
|
||||
|
||||
#### TKG Stats
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `total_nodes` | integer | Sum of all node types |
|
||||
| `total_edges` | integer | Sum of all edge types |
|
||||
| `face_track_nodes` | integer | Face track nodes |
|
||||
| `gaze_track_nodes` | integer | Gaze track nodes |
|
||||
| `lip_track_nodes` | integer | Lip track nodes |
|
||||
| `text_region_nodes` | integer | Text region nodes |
|
||||
| `appearance_nodes` | integer | Appearance trace nodes |
|
||||
| `accessory_nodes` | integer | Accessory nodes |
|
||||
| `object_nodes` | integer | YOLO object nodes |
|
||||
| `hand_nodes` | integer | Hand nodes |
|
||||
| `speaker_nodes` | integer | Speaker nodes |
|
||||
| `co_occurrence_edges` | integer | Co-occurrence edges |
|
||||
| `speaker_face_edges` | integer | Speaker-face edges |
|
||||
| `face_face_edges` | integer | Face-face edges |
|
||||
| `mutual_gaze_edges` | integer | Mutual gaze edges |
|
||||
| `lip_sync_edges` | integer | Lip sync edges |
|
||||
| `has_appearance_edges` | integer | Has-appearance edges |
|
||||
| `wears_edges` | integer | Wears edges |
|
||||
| `hand_object_edges` | integer | Hand-object edges |
|
||||
|
||||
#### Identity Agent Stats
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `clusters` | integer | Face clusters from face_clustered.json |
|
||||
| `identities_created` | integer | Identities created from clusters |
|
||||
| `tmdb_matches` | integer | TMDb identity matches |
|
||||
| `speaker_bindings` | integer | Speaker-to-identity bindings |
|
||||
| `confirmations` | integer | Confirmed identity bindings |
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,281 @@
|
||||
---
|
||||
title: Job Management API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-25
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: job_management -->
|
||||
<!-- description: Job pause/resume and status management -->
|
||||
<!-- depends: 01_auth, 05_process -->
|
||||
|
||||
## Job Management
|
||||
|
||||
Control job execution with pause/resume functionality. Useful for managing system load and prioritizing jobs.
|
||||
|
||||
### `POST /api/v1/jobs/:uuid/pause`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: job-level
|
||||
|
||||
Pause a running or pending job. The worker will skip this job during polling until resumed.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `uuid` | string | Job UUID (file_uuid) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/jobs/$JOB_UUID/pause" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Job 3a6c1865... paused",
|
||||
"uuid": "3a6c1865..."
|
||||
}
|
||||
```
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | Job not found |
|
||||
| `400` | Job already completed or failed |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
**Note**: Cannot pause jobs with status `completed` or `failed`.
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/jobs/:uuid/resume`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: job-level
|
||||
|
||||
Resume a paused job. The job will be picked up by the worker in the next polling cycle.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `uuid` | string | Job UUID (file_uuid) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/jobs/$JOB_UUID/resume" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Job 3a6c1865... resumed",
|
||||
"uuid": "3a6c1865..."
|
||||
}
|
||||
```
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | Job not found |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/jobs/paused`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: user-level
|
||||
|
||||
List all currently paused jobs with file names and pause timestamps.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/jobs/paused" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"uuid": "3a6c1865...",
|
||||
"file_name": "video1.mp4",
|
||||
"status": "paused",
|
||||
"paused_at": "2026-10-25T10:30:00Z"
|
||||
},
|
||||
{
|
||||
"uuid": "4b7d2976...",
|
||||
"file_name": "video2.mp4",
|
||||
"status": "paused",
|
||||
"paused_at": "2026-10-25T11:15:00Z"
|
||||
}
|
||||
],
|
||||
"total": 2
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `jobs` | array | Array of paused job objects |
|
||||
| `uuid` | string | Job UUID (file_uuid) |
|
||||
| `file_name` | string | Original file name |
|
||||
| `status` | string | Always `"paused"` |
|
||||
| `paused_at` | string \| null | ISO 8601 timestamp when paused |
|
||||
| `total` | integer | Total number of paused jobs |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/jobs/:uuid/status`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: job-level
|
||||
|
||||
Get the current status of a specific job. Returns detailed status including processor progress.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `uuid` | string | Job UUID (file_uuid) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/jobs/$JOB_UUID/status" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"uuid": "3a6c1865...",
|
||||
"status": "paused",
|
||||
"current_processor": "face",
|
||||
"progress_current": 1500,
|
||||
"progress_total": 2892,
|
||||
"created_at": "2026-10-25T09:00:00Z",
|
||||
"started_at": "2026-10-25T09:05:00Z",
|
||||
"paused_at": "2026-10-25T10:30:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `uuid` | string | Job UUID |
|
||||
| `status` | string | Current status (pending, running, paused, completed, failed) |
|
||||
| `current_processor` | string \| null | Currently running processor |
|
||||
| `progress_current` | integer | Current progress value |
|
||||
| `progress_total` | integer | Total progress units |
|
||||
| `created_at` | string | Job creation timestamp |
|
||||
| `started_at` | string \| null | Job start timestamp |
|
||||
| `paused_at` | string \| null | Pause timestamp (if paused) |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/admin/sync-status`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Synchronize job statuses between database and Redis. Used for maintenance and consistency checks.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/admin/sync-status" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Status sync completed",
|
||||
"synced_count": 15
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Job Status Lifecycle
|
||||
|
||||
```
|
||||
pending → running → completed
|
||||
↓ ↓
|
||||
paused failed
|
||||
↓
|
||||
pending (resumed)
|
||||
```
|
||||
|
||||
| Status | Description | Actions Available |
|
||||
|--------|-------------|-------------------|
|
||||
| `pending` | Waiting in queue | Pause |
|
||||
| `running` | Currently processing | Pause |
|
||||
| `paused` | Paused by user | Resume |
|
||||
| `completed` | Finished successfully | None |
|
||||
| `failed` | Error occurred | None |
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
### 1. Pause Heavy Processing Job
|
||||
|
||||
```bash
|
||||
# Pause a running job to free up resources
|
||||
curl -X POST "$API/api/v1/jobs/$UUID/pause" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
### 2. Resume Previously Paused Job
|
||||
|
||||
```bash
|
||||
# Resume a paused job
|
||||
curl -X POST "$API/api/v1/jobs/$UUID/resume" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
### 3. List All Paused Jobs
|
||||
|
||||
```bash
|
||||
# Get all paused jobs
|
||||
curl -s "$API/api/v1/jobs/paused" -H "X-API-Key: $KEY" | jq '.jobs[]'
|
||||
```
|
||||
|
||||
### 4. Check Job Status
|
||||
|
||||
```bash
|
||||
# Check if a job is paused or running
|
||||
curl -s "$API/api/v1/jobs/$UUID/status" -H "X-API-Key: $KEY" | jq '.status'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
- **Redis Set**: Paused job UUIDs are stored in a Redis set (`jobs:paused`)
|
||||
- **Worker Behavior**: Worker checks Redis set before picking up jobs
|
||||
- **Persistence**: Pause state persists in both database and Redis
|
||||
- **Resume Priority**: Resumed jobs enter the queue with normal priority
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-25 | Initial documentation |
|
||||
@@ -0,0 +1,228 @@
|
||||
---
|
||||
title: Checkin API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-25
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: checkin -->
|
||||
<!-- description: Workspace checkin/checkout for file isolation -->
|
||||
<!-- depends: 01_auth, 03_register, 16_workspace -->
|
||||
|
||||
## Workspace Checkin/Checkout
|
||||
|
||||
Manage isolated workspace databases for files. Allows safe concurrent processing without conflicts.
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/checkin`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Check in a file from its isolated workspace database to the main database. Moves pre-chunks, speaker detections, and vectors from workspace to main tables.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `file_uuid` | string | File UUID (32-char hex) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/checkin" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"pre_chunks_moved": 152,
|
||||
"speaker_detections_moved": 45,
|
||||
"vectors_moved": 152,
|
||||
"status": "completed"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `pre_chunks_moved` | integer | Number of pre-chunks moved |
|
||||
| `speaker_detections_moved` | integer | Number of speaker detections moved |
|
||||
| `vectors_moved` | integer | Number of vectors moved |
|
||||
| `status` | string | Always `"completed"` |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `401` | Missing or invalid API key |
|
||||
| `500` | Checkin failed (database error) |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/checkout`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Check out a file from the main database. Deletes workspace data for the file.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `file_uuid` | string | File UUID (32-char hex) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/checkout" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"rows_deleted": 197,
|
||||
"status": "checked_out"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `rows_deleted` | integer | Total rows deleted from workspace |
|
||||
| `status` | string | Always `"checked_out"` |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/workspace`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Check if a workspace database exists for a file.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `file_uuid` | string | File UUID (32-char hex) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/workspace" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"exists": true
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `exists` | boolean | Whether workspace database exists |
|
||||
|
||||
---
|
||||
|
||||
## Workspace Architecture
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────┐
|
||||
│ Main Database │
|
||||
│ (PostgreSQL + Qdrant vectors) │
|
||||
│ │
|
||||
│ videos, identities, chunk, ... │
|
||||
└─────────────────────────────────────────┘
|
||||
↑ checkin
|
||||
↓ checkout
|
||||
┌─────────────────────────────────────────┐
|
||||
│ Isolated Workspace Database │
|
||||
│ (SQLite per file) │
|
||||
│ │
|
||||
│ pre_chunks, speaker_detections │
|
||||
│ vectors (Qdrant _workspace collection) │
|
||||
└─────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### Workspace Benefits
|
||||
|
||||
1. **Concurrent Processing**: Multiple files can be processed simultaneously without lock conflicts
|
||||
2. **Isolation**: Processing errors don't affect main database
|
||||
3. **Rollback**: Failed processing can be discarded without cleanup
|
||||
4. **Performance**: SQLite workspace is faster for bulk inserts
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
### 1. Complete Processing and Check In
|
||||
|
||||
```bash
|
||||
# After processing completes successfully
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/checkin" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
### 2. Discard Failed Processing
|
||||
|
||||
```bash
|
||||
# If processing failed, checkout to clean up
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/checkout" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
### 3. Check Workspace Status
|
||||
|
||||
```bash
|
||||
# Before checkin, verify workspace exists
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/workspace" -H "X-API-Key: $KEY" | jq '.exists'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Workflow
|
||||
|
||||
### Normal Processing Flow
|
||||
|
||||
```
|
||||
1. Register file → status: REGISTERED
|
||||
2. Start processing → workspace created → status: PROCESSING
|
||||
3. Processing complete → workspace populated
|
||||
4. Checkin → move to main DB → status: COMPLETED
|
||||
5. Workspace deleted automatically
|
||||
```
|
||||
|
||||
### Error Recovery Flow
|
||||
|
||||
```
|
||||
1. Processing failed → workspace contains partial data
|
||||
2. Checkout → delete workspace → status: COMPLETED
|
||||
3. Re-trigger processing if needed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
- **Workspace Location**: `{output_dir}/{file_uuid}.workspace.db`
|
||||
- **Vector Collection**: `qdrant://_workspace_{file_uuid}`
|
||||
- **Auto-cleanup**: Workspace deleted after successful checkin
|
||||
- **Idempotency**: Checkin/checkout can be called multiple times safely
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-25 | Initial documentation |
|
||||
@@ -0,0 +1,390 @@
|
||||
---
|
||||
title: search API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: search -->
|
||||
<!-- description: Vector search, BM25, smart search, universal search, LLM reranked search, frame search -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## Search APIs
|
||||
|
||||
### `POST /api/v1/search/smart`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: global / file-level
|
||||
|
||||
Semantic vector search using EmbeddingGemma-300m. Generates a query embedding via EmbeddingGemma (port 11436), then searches pgvector `story_parent` and `llm_parent` chunks by cosine similarity.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `query` | string | Yes | — | Search text |
|
||||
| `file_uuid` | string | No | — | File UUID to search within. If omitted, searches all files (global search) |
|
||||
| `limit` | integer | No | 5 | Max results to return |
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 5 | Items per page |
|
||||
|
||||
#### Example (Global Search)
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/search/smart" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $JWT" \
|
||||
-d '{"query": "Audrey Hepburn"}'
|
||||
```
|
||||
|
||||
#### Example (File-specific Search)
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/search/smart" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $JWT" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "query": "Audrey Hepburn"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"query": "Audrey Hepburn",
|
||||
"results": [
|
||||
{
|
||||
"file_uuid": "a6fb22eebefaef17e62af874997c5944",
|
||||
"parent_id": 1087822,
|
||||
"scene_order": 1087822,
|
||||
"start_frame": 104438,
|
||||
"end_frame": 104538,
|
||||
"fps": 24.0,
|
||||
"start_time": 4351.6,
|
||||
"end_time": 4355.76,
|
||||
"summary": "[4352s-4356s, 4s] Cast: Audrey Hepburn. Total: 2 lines, 10 words. Speakers: Audrey Hepburn (2 lines)",
|
||||
"similarity": 0.67
|
||||
}
|
||||
],
|
||||
"page": 1,
|
||||
"page_size": 5,
|
||||
"strategy": "semantic_vector_search"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `results[].file_uuid` | string | File UUID where result was found |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/search/universal`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: global / file-level
|
||||
|
||||
Multi-type BM25 full-text search across chunks, frames, and persons. Uses PostgreSQL `tsvector`.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `query` | string | Yes | — | Search text |
|
||||
| `file_uuid` | string | No | — | Restrict to specific file. If omitted, searches all files (global search) |
|
||||
| `types` | string[] | No | `["chunk","frame","person"]` | Search types |
|
||||
| `limit` | integer | No | 10 | Max results per type |
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 20 | Items per page |
|
||||
|
||||
#### Example (Global Search)
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/search/universal" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $JWT" \
|
||||
-d '{"query": "Cary Grant"}'
|
||||
```
|
||||
|
||||
#### Example (File-specific Search)
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/search/universal" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer $JWT" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "query": "Cary Grant"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"type": "chunk",
|
||||
"file_uuid": "a6fb22eebefaef17e62af874997c5944",
|
||||
"chunk_id": "bd80fec92b0b6963d177a2c55bf713e2_2",
|
||||
"chunk_type": "story_child",
|
||||
"start_frame": 5103,
|
||||
"end_frame": 5127,
|
||||
"start_time": 212.64,
|
||||
"end_time": 213.64,
|
||||
"text": "[213s-214s] Cary Grant: \"Olá!\"",
|
||||
"score": 0.9
|
||||
},
|
||||
{
|
||||
"type": "frame",
|
||||
"file_uuid": "a6fb22eebefaef17e62af874997c5944",
|
||||
"frame_number": 5105,
|
||||
"timestamp": 212.72,
|
||||
"score": 0.7,
|
||||
"objects": null,
|
||||
"ocr_texts": null,
|
||||
"faces": null
|
||||
},
|
||||
{
|
||||
"type": "person",
|
||||
"file_uuid": "a6fb22eebefaef17e62af874997c5944",
|
||||
"identity_id": 12,
|
||||
"identity_uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"name": "Cary Grant",
|
||||
"appearance_count": 542,
|
||||
"score": 0.95
|
||||
}
|
||||
],
|
||||
"total": 20,
|
||||
"took_ms": 18
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `results[].type` | string | Result type: `chunk`, `frame`, or `person` |
|
||||
| `results[].file_uuid` | string | File UUID where result was found (all types) |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/search/frames`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: global / file-level
|
||||
|
||||
Search frames by YOLO objects, OCR text, face IDs, or pose detections. Filters frames based on visual content detected during processing.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `file_uuid` | string | No | — | Restrict to specific file |
|
||||
| `object_class` | string | No | — | Filter by YOLO object class (e.g., `person`, `car`, `dog`) |
|
||||
| `ocr_text` | string | No | — | Filter by OCR text content (ILIKE match) |
|
||||
| `face_id` | string | No | — | Filter by face detection ID |
|
||||
| `time_range` | [float, float] | No | — | Filter by time range `[start_secs, end_secs]` |
|
||||
| `limit` | integer | No | 100 | Max results |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Search for frames containing "person" objects
|
||||
curl -s -X POST "$API/api/v1/search/frames" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "object_class": "person", "limit": 20}'
|
||||
|
||||
# Search for frames with specific OCR text
|
||||
curl -s -X POST "$API/api/v1/search/frames" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "ocr_text": "hello", "time_range": [10.0, 30.0]}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"frames": [
|
||||
{
|
||||
"frame_number": 1200,
|
||||
"timestamp": 50.0,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"objects": [{"class": "person", "confidence": 0.95, "bbox": [100, 50, 300, 400]}],
|
||||
"ocr_texts": ["Hello World"],
|
||||
"faces": [{"face_id": "face_42", "confidence": 0.88}],
|
||||
"pose_persons": [{"trace_id": 2, "bbox": [120, 60, 280, 380]}]
|
||||
}
|
||||
],
|
||||
"total": 15
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `frames` | array | Array of matching frame objects |
|
||||
| `frames[].frame_number` | integer | Frame number in video |
|
||||
| `frames[].timestamp` | float | Timestamp in seconds |
|
||||
| `frames[].file_uuid` | string | File UUID |
|
||||
| `frames[].objects` | array/null | YOLO detections in this frame |
|
||||
| `frames[].ocr_texts` | array/null | OCR text strings in this frame |
|
||||
| `frames[].faces` | array/null | Face detections in this frame |
|
||||
| `frames[].pose_persons` | array/null | Pose-detected persons in this frame |
|
||||
| `total` | integer | Total matching frame count |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/search/llm-smart`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: global / file-level
|
||||
|
||||
Smart search with LLM re-ranking. First fetches candidate results via RRF (Reciprocal Rank Fusion) using the existing smart search, then uses an LLM (Gemma4 on port 8000) to re-rank candidates by relevance to the query.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `query` | string | Yes | — | Search text |
|
||||
| `file_uuid` | string | No | — | File UUID to search within |
|
||||
| `limit` | integer | No | 10 | Max results to return |
|
||||
|
||||
#### Pipeline
|
||||
|
||||
```
|
||||
1. smart_search → fetch N candidates (limit × 3, clamped 10-20)
|
||||
2. LLM rerank → re-order by relevance using Gemma4
|
||||
3. trim → return top `limit` results
|
||||
```
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/search/llm-smart" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"query": "two people having a conversation about business", "limit": 5}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"query": "two people having a conversation about business",
|
||||
"results": [
|
||||
{
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"parent_id": 1234,
|
||||
"scene_order": 1234,
|
||||
"start_frame": 5000,
|
||||
"end_frame": 5200,
|
||||
"fps": 24.0,
|
||||
"start_time": 208.3,
|
||||
"end_time": 216.7,
|
||||
"summary": "[208s-217s, 9s] Two people discussing project timeline...",
|
||||
"similarity": 0.72
|
||||
}
|
||||
],
|
||||
"page": 1,
|
||||
"page_size": 5,
|
||||
"strategy": "llm_reranked"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `strategy` | string | Always `"llm_reranked"` for this endpoint |
|
||||
| `results` | array | Re-ranked search results (same format as smart search) |
|
||||
|
||||
#### Fallback
|
||||
|
||||
If LLM reranking fails (model unavailable, timeout), falls back to RRF order without error.
|
||||
|
||||
---
|
||||
|
||||
### Visual Search
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: global / file-level
|
||||
|
||||
Search text chunks → find associated identities. Returns chunks where face detections overlap with text content.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `q` | string | Yes | — | Search text (ILIKE match) |
|
||||
| `file_uuid` | string | No | — | Restrict to specific file. If omitted, searches all files (global search) |
|
||||
| `limit` | integer | No | 50 | Max results |
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 50 | Items per page |
|
||||
|
||||
#### Example (Global Search)
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/search/identity_text?q=love" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Example (File-specific Search)
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/search/identity_text?file_uuid=$FILE_UUID&q=love" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"total": 5,
|
||||
"results": [
|
||||
{
|
||||
"file_uuid": "a6fb22eebefaef17e62af874997c5944",
|
||||
"chunk_id": "llm_parent_..._256_270",
|
||||
"start_time": 256.256,
|
||||
"end_time": 270.228,
|
||||
"text_content": "...lack of affection...",
|
||||
"identity_id": 9,
|
||||
"identity_name": "Audrey Hepburn",
|
||||
"identity_source": "tmdb",
|
||||
"trace_id": 94
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `results[].file_uuid` | string | File UUID where chunk was found |
|
||||
| `results[].identity_id` | integer | Identity ID if face was detected |
|
||||
| `results[].trace_id` | integer | Face trace ID |
|
||||
|
||||
---
|
||||
|
||||
### Visual Search (Planned)
|
||||
|
||||
| Method | Endpoint | Status | Description |
|
||||
|--------|----------|--------|-------------|
|
||||
| POST | `/api/v1/search/visual` | Not implemented | Search visual chunks |
|
||||
| POST | `/api/v1/search/visual/class` | Not implemented | Search by object class |
|
||||
| POST | `/api/v1/search/visual/density` | Not implemented | Search by object density |
|
||||
| POST | `/api/v1/search/visual/combination` | Not implemented | Search by object combination |
|
||||
| POST | `/api/v1/search/visual/stats` | Not implemented | Visual chunk statistics |
|
||||
|
||||
#### Embedding Model
|
||||
|
||||
| Detail | Value |
|
||||
|--------|-------|
|
||||
| **Model** | EmbeddingGemma-300m |
|
||||
| **Endpoint** | `POST /api/v1/embeddings` on port 11436 |
|
||||
| **Dimension** | 768 |
|
||||
| **Storage** | pgvector (`chunk.embedding` column) |
|
||||
|
||||
---
|
||||
*Updated: 2026-06-20 — Added llm-smart search, completed frames search documentation, marked visual search as planned*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,385 @@
|
||||
---
|
||||
title: VLM Search API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: vlm_search -->
|
||||
<!-- description: Vision Language Model search for scenes and traces -->
|
||||
<!-- depends: search, profile -->
|
||||
|
||||
# VLM Search API
|
||||
|
||||
Search video scenes and traces using Vision Language Model (VLM) descriptions and tags.
|
||||
|
||||
## Overview
|
||||
|
||||
VLM Search API provides endpoints for searching video scenes and face traces using Vision Language Model (VLM) descriptions and vector embeddings.
|
||||
|
||||
### VLM Dual-Source Architecture
|
||||
|
||||
VLM processing analyzes **two distinct sources**, each producing separate Qdrant collections for semantic vector search:
|
||||
|
||||
| VLM Source | Analysis Target | Qdrant Collection | Search Endpoint |
|
||||
|------------|-----------------|-------------------|-----------------|
|
||||
| **Scene VLM** | 10-second scene frames | `_scenes` | `POST /api/v1/search/vlm/scenes` |
|
||||
| **Trace VLM** | Face trace FS keyframes | `_vlm` | `POST /api/v1/search/vlm/traces` |
|
||||
|
||||
Both use **EmbeddingGemma-300m** (768D vectors) and **cosine similarity** for semantic search.
|
||||
|
||||
### VLM Data Flow
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ VLM Processing │
|
||||
├──────────────────────────┬──────────────────────────────────────┤
|
||||
│ Scene VLM │ Trace VLM │
|
||||
│ - Analyzes 10s scenes │ - Analyzes face trace FS keyframes │
|
||||
│ - Generates descriptions │ - Generates person descriptions │
|
||||
│ - Embeds to Qdrant │ - Embeds to Qdrant │
|
||||
│ `_scenes` collection │ `_vlm` collection │
|
||||
└──────────────────────────┴──────────────────────────────────────┘
|
||||
│ │
|
||||
└──────────────┬───────────────────────┘
|
||||
▼
|
||||
Qdrant Vector Search
|
||||
(Cosine similarity on 768D embeddings)
|
||||
```
|
||||
|
||||
### Implementation Files
|
||||
|
||||
- **Scene VLM**: `/Users/accusys/momentry_core/src/core/processor/scene_vlm.rs`
|
||||
- **Trace VLM**: `/Users/accusys/momentry_core/src/core/processor/vlm_summary.rs`
|
||||
- **Qdrant Upsert**: `/Users/accusys/momentry_core/src/core/db/qdrant_db.rs`
|
||||
- `upsert_scene_embedding()` → `_scenes` collection
|
||||
- `upsert_vlm_embedding()` → `_vlm` collection
|
||||
- **Search Endpoints**: `/Users/accusys/momentry_core/src/api/vlm_search.rs`
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `POST /api/v1/search/vlm/scenes`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level or global
|
||||
|
||||
Search scenes using VLM-generated content and metadata.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `query` | string | Yes | — | Search query text |
|
||||
| `file_uuid` | string | No | — | Limit to specific file |
|
||||
| `filters` | object | No | — | Search filters |
|
||||
| `page` | number | No | 1 | Page number |
|
||||
| `page_size` | number | No | 20 | Results per page |
|
||||
| `min_score` | number | No | 0.0 | Minimum relevance score |
|
||||
|
||||
#### Filters Object
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `vlm_objects` | array | Filter by detected objects |
|
||||
| `vlm_tags` | array | Filter by VLM tags |
|
||||
| `time_range` | object | Filter by time range |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Search scenes for "dog playing"
|
||||
curl -s -X POST "$API/api/v1/search/vlm/scenes" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"query": "dog playing in the park",
|
||||
"page": 1,
|
||||
"page_size": 20,
|
||||
"min_score": 0.5
|
||||
}'
|
||||
```
|
||||
|
||||
```bash
|
||||
# Search scenes with filters
|
||||
curl -s -X POST "$API/api/v1/search/vlm/scenes" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"query": "outdoor scene",
|
||||
"file_uuid": "384b0ff44aaaa1f1",
|
||||
"filters": {
|
||||
"vlm_objects": ["dog", "tree"],
|
||||
"time_range": {
|
||||
"start_sec": 60.0,
|
||||
"end_sec": 120.0
|
||||
}
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"file_uuid": "384b0ff44aaaa1f1",
|
||||
"file_name": "video.mp4",
|
||||
"scene_index": 5,
|
||||
"timestamp_sec": 125.5,
|
||||
"frame_number": 3750,
|
||||
"thumbnail_url": "/api/v1/media/384b0ff44aaaa1f1/scene/5/thumbnail",
|
||||
"vlm_description": "A dog playing in a sunny park",
|
||||
"vlm_description_localized": "陽光下的公園裡有隻狗在玩耍",
|
||||
"vlm_objects": ["dog", "grass", "tree", "park"],
|
||||
"vlm_tags": [
|
||||
{"en": "dog", "local": "犬"},
|
||||
{"en": "outdoor", "local": "戶外"},
|
||||
{"en": "sunny", "local": "晴天"}
|
||||
],
|
||||
"score": 0.92,
|
||||
"source": "vlm"
|
||||
}
|
||||
],
|
||||
"total": 15,
|
||||
"page": 1,
|
||||
"page_size": 20
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `results` | array | Search results |
|
||||
| `results[].file_uuid` | string | File UUID |
|
||||
| `results[].file_name` | string | File name |
|
||||
| `results[].scene_index` | number | Scene index |
|
||||
| `results[].timestamp_sec` | number | Scene timestamp |
|
||||
| `results[].frame_number` | number | Frame number |
|
||||
| `results[].thumbnail_url` | string | Thumbnail URL |
|
||||
| `results[].vlm_description` | string | VLM-generated description |
|
||||
| `results[].vlm_description_localized` | string | Localized description (optional) |
|
||||
| `results[].vlm_objects` | array | Detected objects |
|
||||
| `results[].vlm_tags` | array | VLM tags (bilingual) |
|
||||
| `results[].score` | number | Relevance score (0-1) |
|
||||
| `results[].source` | string | Search source (`"vlm"`) |
|
||||
| `total` | number | Total results |
|
||||
| `page` | number | Current page |
|
||||
| `page_size` | number | Page size |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/search/vlm/traces`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level or global
|
||||
|
||||
Search face traces using VLM descriptions.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `query` | string | Yes | — | Search query text |
|
||||
| `file_uuid` | string | No | — | Limit to specific file |
|
||||
| `filters` | object | No | — | Search filters |
|
||||
| `page` | number | No | 1 | Page number |
|
||||
| `page_size` | number | No | 20 | Results per page |
|
||||
| `min_score` | number | No | 0.0 | Minimum relevance score |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Search traces for "person wearing red shirt"
|
||||
curl -s -X POST "$API/api/v1/search/vlm/traces" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"query": "person wearing red shirt",
|
||||
"page": 1,
|
||||
"page_size": 20
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"results": [
|
||||
{
|
||||
"file_uuid": "384b0ff44aaaa1f1",
|
||||
"trace_id": 2,
|
||||
"identity_uuid": "a9a90105-...",
|
||||
"vlm_description": "A person wearing a red t-shirt and blue jeans",
|
||||
"vlm_tags": [
|
||||
{"en": "red shirt", "local": "紅色上衣"},
|
||||
{"en": "blue jeans", "local": "藍色牛仔褲"}
|
||||
],
|
||||
"score": 0.88
|
||||
}
|
||||
],
|
||||
"total": 3,
|
||||
"page": 1,
|
||||
"page_size": 20
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/search/vlm/debug`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: system-level
|
||||
|
||||
Debug VLM search functionality (for development).
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Debug VLM search
|
||||
curl -s -X POST "$API/api/v1/search/vlm/debug" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"query": "test query"
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/vlm_search.rs` (773 lines)
|
||||
|
||||
**Data Structures**:
|
||||
- `SceneSearchRequest` - Scene search parameters
|
||||
- `TraceSearchRequest` - Trace search parameters
|
||||
- `VlmTagValue` - Bilingual tag structure
|
||||
|
||||
**VLM Tags Structure**:
|
||||
```json
|
||||
{
|
||||
"en": "dog",
|
||||
"local": "犬"
|
||||
}
|
||||
```
|
||||
|
||||
**Search Process**:
|
||||
1. Parse query and filters
|
||||
2. Generate embedding for query text
|
||||
3. Search Qdrant for matching scenes/traces
|
||||
4. Apply filters (objects, tags, time range)
|
||||
5. Sort by relevance score
|
||||
6. Return paginated results
|
||||
|
||||
---
|
||||
|
||||
## VLM Integration
|
||||
|
||||
### Description Generation
|
||||
|
||||
VLM descriptions are generated during file processing:
|
||||
- **Scene VLM**: Analyzes scene frames
|
||||
- **Trace VLM**: Analyzes face trace appearances
|
||||
|
||||
### Tag Structure
|
||||
|
||||
Bilingual tags enable multilingual search:
|
||||
- **English tag**: Primary search key
|
||||
- **Local tag**: Native language display
|
||||
|
||||
### Objects vs Tags
|
||||
|
||||
- **Objects**: Detected physical objects (dog, car, tree)
|
||||
- **Tags**: Semantic concepts (outdoor, sunny, daytime)
|
||||
|
||||
---
|
||||
|
||||
## Search Tips
|
||||
|
||||
### Effective Queries
|
||||
|
||||
✅ **Good**:
|
||||
- "dog playing in the park"
|
||||
- "person wearing red shirt"
|
||||
- "outdoor sunny scene"
|
||||
|
||||
❌ **Less Effective**:
|
||||
- "video" (too generic)
|
||||
- "frame 100" (technical reference)
|
||||
|
||||
### Filter Usage
|
||||
|
||||
Use filters to narrow results:
|
||||
- `vlm_objects`: Specific objects
|
||||
- `vlm_tags`: Specific concepts
|
||||
- `time_range`: Specific time period
|
||||
|
||||
### Score Thresholds
|
||||
|
||||
- `> 0.8`: Highly relevant
|
||||
- `0.5-0.8`: Moderately relevant
|
||||
- `< 0.5`: Low relevance
|
||||
|
||||
---
|
||||
|
||||
## Error Codes
|
||||
|
||||
| Code | HTTP | When |
|
||||
|------|------|------|
|
||||
| E401 | 401 | Missing or invalid API key |
|
||||
| E400 | 400 | Invalid query or parameters |
|
||||
| E500 | 500 | Search failed |
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [Search API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/06_search.md)
|
||||
- [Profile API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/18_profile.md)
|
||||
- [Scene VLM Stats](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/scene_vlm_stats_api.md)
|
||||
|
||||
---
|
||||
|
||||
## Common Issues
|
||||
|
||||
### No Results Found
|
||||
|
||||
**Symptoms**: Empty results array
|
||||
|
||||
**Possible Causes**:
|
||||
1. Query too specific
|
||||
2. Low `min_score` threshold
|
||||
3. No matching scenes/traces
|
||||
|
||||
**Solution**:
|
||||
- Simplify query
|
||||
- Lower `min_score`
|
||||
- Check file processing status
|
||||
|
||||
### Low Relevance Scores
|
||||
|
||||
**Symptoms**: All results have low scores (< 0.5)
|
||||
|
||||
**Possible Causes**:
|
||||
1. Query doesn't match content
|
||||
2. VLM descriptions not generated
|
||||
3. Embedding quality issue
|
||||
|
||||
**Solution**:
|
||||
- Rephrase query
|
||||
- Verify VLM processing completed
|
||||
- Check VLM model configuration
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,220 @@
|
||||
---
|
||||
title: Scene VLM Stats API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-14
|
||||
author: Core Team
|
||||
status: active
|
||||
---
|
||||
|
||||
# Scene VLM Stats API
|
||||
|
||||
**Endpoint**: `/api/v1/file/{file_uuid}/scene-vlm-stats`
|
||||
**Method**: `GET`
|
||||
**Purpose**: 快速获取文件的 Scene VLM 统计数据
|
||||
|
||||
---
|
||||
|
||||
## Overview
|
||||
|
||||
**Scope**: File processing statistics
|
||||
**Status**: Active
|
||||
**Applicable to**: All registered files with Scene VLM processing
|
||||
|
||||
---
|
||||
|
||||
## Request
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Location | Required | Description |
|
||||
|-----------|------|----------|----------|-------------|
|
||||
| `file_uuid` | String | Path | Yes | File UUID |
|
||||
|
||||
### Example
|
||||
|
||||
```bash
|
||||
curl http://localhost:3002/api/v1/file/dac75694ee550ff57d74f26391fcc751/scene-vlm-stats
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Response
|
||||
|
||||
### Success (200 OK)
|
||||
|
||||
```json
|
||||
{
|
||||
"total_scenes": 2,
|
||||
"status": "completed",
|
||||
"vlm_done": 2,
|
||||
"vlm_total": 2
|
||||
}
|
||||
```
|
||||
|
||||
### Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `total_scenes` | i64 | Total number of scenes detected |
|
||||
| `status` | String | Scene VLM processing status (`pending`, `processing`, `completed`) |
|
||||
| `vlm_done` | i64 | Number of scenes with VLM descriptions completed |
|
||||
| `vlm_total` | i64 | Total scenes needing VLM processing |
|
||||
|
||||
### Default Response
|
||||
|
||||
If the file has no scenes file:
|
||||
|
||||
```json
|
||||
{
|
||||
"total_scenes": 0,
|
||||
"status": "",
|
||||
"vlm_done": 0,
|
||||
"vlm_total": 0
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Performance
|
||||
|
||||
**Response Time**: < 10ms
|
||||
|
||||
**Why Fast**:
|
||||
- Directly reads `{file_uuid}.scenes.json`
|
||||
- No database queries
|
||||
- No complex calculations
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
### 1. UI Display
|
||||
|
||||
Display Scene VLM progress in Library view:
|
||||
```typescript
|
||||
const stats = await loadSceneVlmStats(fileUuid)
|
||||
console.log(`${stats.vlm_done}/${stats.vlm_total} scenes completed`)
|
||||
```
|
||||
|
||||
### 2. Performance Optimization
|
||||
|
||||
Replace expensive `get_file_stats` call:
|
||||
- **Old**: `get_file_stats` - 100-500ms
|
||||
- **New**: `scene-vlm-stats` - < 10ms
|
||||
- **Improvement**: 10-50x faster
|
||||
|
||||
### 3. Real-time Updates
|
||||
|
||||
Poll for Scene VLM progress without heavy API load:
|
||||
```typescript
|
||||
setInterval(() => {
|
||||
loadSceneVlmStats(fileUuid)
|
||||
}, 5000)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### Backend
|
||||
|
||||
**File**: `src/api/scan.rs:1647`
|
||||
|
||||
**Logic**:
|
||||
1. Check if `{file_uuid}.scenes.json` exists
|
||||
2. Read JSON file
|
||||
3. Parse and count scenes
|
||||
4. Return statistics
|
||||
|
||||
**Code**:
|
||||
```rust
|
||||
async fn get_scene_vlm_stats(
|
||||
Path(file_uuid): Path<String>,
|
||||
) -> Result<Json<SceneVlmStats>, StatusCode> {
|
||||
let scenes_path = format!("{}/{}.scenes.json", output_dir, file_uuid);
|
||||
|
||||
if !Path::new(&scenes_path).exists() {
|
||||
return Ok(Json(SceneVlmStats::default()));
|
||||
}
|
||||
|
||||
let scenes_json = std::fs::read_to_string(&scenes_path)?;
|
||||
let scenes_data: Value = serde_json::from_str(&scenes_json)?;
|
||||
|
||||
// ... parse and return stats
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
### File Not Found
|
||||
|
||||
**Status**: 200 OK
|
||||
**Response**: Default values (all zeros)
|
||||
|
||||
### Parse Error
|
||||
|
||||
**Status**: 500 Internal Server Error
|
||||
|
||||
**Note**: Rare case, indicates corrupted JSON file
|
||||
|
||||
---
|
||||
|
||||
## Related APIs
|
||||
|
||||
- `GET /api/v1/file/{file_uuid}` - Full file info (slower)
|
||||
- `GET /api/v1/file/{file_uuid}/processor-counts` - Processor counts
|
||||
- `GET /api/v1/stats/file/{file_uuid}` - Detailed stats (slower)
|
||||
|
||||
---
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Use for Scene VLM Progress
|
||||
|
||||
**Recommended**: Use this API for Scene VLM progress display
|
||||
**Avoid**: Using `get_file_stats` for simple Scene VLM stats
|
||||
|
||||
### 2. Caching
|
||||
|
||||
Frontend should cache results:
|
||||
```typescript
|
||||
if (fileStatsCache.value[fileUuid].scene_vlm) {
|
||||
return fileStatsCache.value[fileUuid].scene_vlm
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Error Handling
|
||||
|
||||
Always handle failures gracefully:
|
||||
```typescript
|
||||
try {
|
||||
const stats = await loadSceneVlmStats(fileUuid)
|
||||
} catch (e) {
|
||||
console.warn('Scene VLM stats failed:', e)
|
||||
// Use cached data or show 'Unknown'
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0.0 | 2026-10-14 | Initial API endpoint |
|
||||
|
||||
---
|
||||
|
||||
## Cross-References
|
||||
|
||||
- **Frontend Integration**: Studio team commit 3e7eba0
|
||||
- **Test Script**: `momentry_studio/scripts/test_scene_vlm_api.sh`
|
||||
- **Backend Code**: `src/api/scan.rs:1647`
|
||||
|
||||
---
|
||||
|
||||
**Last Updated**: 2026-10-14
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,145 @@
|
||||
---
|
||||
title: identity agent API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: identity_agent -->
|
||||
<!-- description: Identity agent — match from photo, match from trace -->
|
||||
<!-- depends: 01_auth, 07_identity -->
|
||||
|
||||
## Identity Agent
|
||||
|
||||
### `POST /api/v1/agents/identity/match-from-photo`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Upload a face photo to match against known identities. Detects face via InsightFace, extracts 512D embedding via CoreML FaceNet, then searches pgvector for the closest identity.
|
||||
|
||||
#### Request
|
||||
|
||||
`multipart/form-data` with field `image` (JPEG/PNG) and optional `file_uuid`.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/agents/identity/match-from-photo" \
|
||||
-H "Authorization: Bearer $JWT" \
|
||||
-F "image=@/path/to/face.jpg" \
|
||||
-F "file_uuid=$FILE_UUID"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"matches": [
|
||||
{
|
||||
"identity_uuid": "a9a90105...",
|
||||
"name": "Cary Grant",
|
||||
"similarity": 0.87
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/agents/identity/match-from-trace`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Match a face trace (tracked face across frames) against known identities. Samples 3 angles from the trace, generates embeddings, and searches pgvector.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File containing the trace |
|
||||
| `trace_id` | integer | Yes | Face trace ID to match |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/agents/identity/match-from-trace" \
|
||||
-H "Authorization: Bearer $JWT" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "trace_id": 10}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/agents/identity/confirm`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Confirm identity binding for a trace. This marks the trace as confirmed in TKG, updates face_detections, adds to _seeds, and optionally triggers Round 2 propagation.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | Video file UUID |
|
||||
| `trace_id` | integer | Yes | Face trace ID to confirm |
|
||||
| `identity_id` | integer | Yes | Identity internal ID |
|
||||
| `identity_uuid` | string | Yes | Identity UUID |
|
||||
| `name` | string | Yes | Identity name |
|
||||
| `propagate` | boolean | No | Auto-trigger Round 2 matching (default: true) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/agents/identity/confirm" \
|
||||
-H "Authorization: Bearer $JWT" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "trace_id": 10, "identity_id": 42, "identity_uuid": "'"$IDENTITY_UUID"'", "name": "Cary Grant", "propagate": false}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "384b0ff44aaaa1f1",
|
||||
"trace_id": 10,
|
||||
"identity_uuid": "a9a90105...",
|
||||
"name": "Cary Grant",
|
||||
"steps": {
|
||||
"tkg_updated": true,
|
||||
"qdrant_updated": 150,
|
||||
"pg_updated": 150,
|
||||
"seed_added": true
|
||||
},
|
||||
"propagation": {
|
||||
"matched": 5,
|
||||
"message": "Propagation completed"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Side Effects
|
||||
|
||||
1. TKG face_track node status → 'confirmed'
|
||||
2. Qdrant _faces: identity_uuid added to payload
|
||||
3. PG face_detections: identity_id set
|
||||
4. Trace centroid added to _seeds (source='propagation')
|
||||
5. Round 2 matching triggered (if propagate=true)
|
||||
|
||||
---
|
||||
*Updated: 2026-06-26 00:30:00*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,714 @@
|
||||
---
|
||||
title: identity history API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: identity_history -->
|
||||
<!-- description: Identity operation history, undo, and redo (PATCH, bind, unbind, bind_trace, mergeinto) -->
|
||||
<!-- depends: 01_auth, 07_identity -->
|
||||
|
||||
## Identity Operation History
|
||||
|
||||
Every mutation on an identity automatically records a before/after snapshot. Use undo/redo to revert or reapply changes, and history to inspect the operation log.
|
||||
|
||||
Three independent undo/redo systems exist:
|
||||
|
||||
| System | Storage | Operations Covered |
|
||||
|--------|---------|-------------------|
|
||||
| **PATCH** | PostgreSQL `identity_history` | `update` |
|
||||
| **Bind** | PostgreSQL `identity_history` | `bind`, `unbind`, `bind_trace` |
|
||||
| **Merge** | MongoDB `identity_merge_history` | mergeinto |
|
||||
| **Delete** | PostgreSQL `identity_history` | `delete` |
|
||||
|
||||
---
|
||||
|
||||
### 1. PATCH History & Undo/Redo
|
||||
|
||||
#### Overview
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Storage | PostgreSQL `identity_history` table |
|
||||
| Snapshot | Full identity record (all fields) before and after each PATCH |
|
||||
| Max records | 256 per identity (oldest auto-deleted when limit exceeded) |
|
||||
| Undo steps | Unlimited (no expiry, no step limit) |
|
||||
| Redo stack | Cleared on new PATCH (`is_undone=true` + `operation='update'` records are deleted) |
|
||||
|
||||
##### Stack Model
|
||||
|
||||
```
|
||||
PATCH 1 → PATCH 2 → PATCH 3 (undo stack, is_undone=false)
|
||||
↓ undo
|
||||
PATCH 1 → PATCH 2 (undo stack)
|
||||
PATCH 3 (redo stack, is_undone=true)
|
||||
↓ redo
|
||||
PATCH 1 → PATCH 2 → PATCH 3 (undo stack)
|
||||
```
|
||||
|
||||
A new PATCH after undo clears only the operation='update' redo stack (PATCH 3 is lost). Bind/merge redo stacks are not affected.
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/identity/:identity_uuid/undo`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: identity-level
|
||||
|
||||
Undo the most recent PATCH operations. Restores the identity's `before_snapshot` and marks the history records as undone.
|
||||
|
||||
##### Request (JSON)
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `steps` | integer | No | `1` | Number of undo steps to apply (max records undone in one call) |
|
||||
|
||||
##### Behavior
|
||||
|
||||
- Queries `is_undone=false` records with `operation='update'`, ordered by `created_at DESC`
|
||||
- Restores `name`, `identity_type`, `source`, `status`, `metadata`, `tmdb_id`, `tmdb_profile` from the last record's `before_snapshot`
|
||||
- Marks the undone records as `is_undone=true` with `undone_at=NOW()`
|
||||
- Syncs `identity.json` to disk
|
||||
- Updates `_index.json` if name changed
|
||||
|
||||
##### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/identity/$IDENTITY_UUID/undo" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"steps": 1}'
|
||||
```
|
||||
|
||||
##### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"identity_uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"undone_count": 1,
|
||||
"current_state": {
|
||||
"id": 9,
|
||||
"uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"name": "Cary Grant",
|
||||
"identity_type": "people",
|
||||
"source": "tmdb",
|
||||
"status": "confirmed",
|
||||
"metadata": {},
|
||||
"tmdb_id": 112,
|
||||
"tmdb_profile": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `undone_count` | integer | Number of history records undone |
|
||||
| `current_state` | object | Full identity state after undo |
|
||||
|
||||
##### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | No undo operations available |
|
||||
| `404` | Identity not found |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/identity/:identity_uuid/redo`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: identity-level
|
||||
|
||||
Redo previously undone PATCH operations. Restores the identity's `after_snapshot` and marks the history records as no longer undone.
|
||||
|
||||
##### Request (JSON)
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `steps` | integer | No | `1` | Number of redo steps to apply |
|
||||
|
||||
##### Behavior
|
||||
|
||||
- Queries `is_undone=true` records with `operation='update'`, ordered by `created_at DESC`
|
||||
- Restores all identity fields from the last record's `after_snapshot`
|
||||
- Marks records as `is_undone=false` with `undone_at=NULL`
|
||||
- Syncs `identity.json` to disk
|
||||
- Updates `_index.json` if name changed
|
||||
|
||||
##### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/identity/$IDENTITY_UUID/redo" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"steps": 1}'
|
||||
```
|
||||
|
||||
##### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"identity_uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"redone_count": 1,
|
||||
"current_state": {
|
||||
"id": 9,
|
||||
"uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"name": "John Smith",
|
||||
"identity_type": "people",
|
||||
"source": "tmdb",
|
||||
"status": "confirmed",
|
||||
"metadata": { "aliases": [...] },
|
||||
"tmdb_id": 112,
|
||||
"tmdb_profile": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `redone_count` | integer | Number of history records redone |
|
||||
| `current_state` | object | Full identity state after redo |
|
||||
|
||||
##### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | No redo operations available |
|
||||
| `404` | Identity not found |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
#### `GET /api/v1/identity/:identity_uuid/history`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: identity-level
|
||||
|
||||
Query the PATCH operation history for an identity. Returns paginated records with undo/redo stack counts (filtered to `operation='update'`).
|
||||
|
||||
##### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `page` | integer | No | `1` | Page number (1-indexed) |
|
||||
| `limit` | integer | No | `20` | Items per page (max 100) |
|
||||
|
||||
##### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"identity_uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"total": 5,
|
||||
"undo_stack_count": 3,
|
||||
"redo_stack_count": 2,
|
||||
"results": [
|
||||
{
|
||||
"history_id": 42,
|
||||
"operation": "update",
|
||||
"is_undone": false,
|
||||
"created_at": "2026-05-27T12:00:00Z",
|
||||
"undone_at": null
|
||||
},
|
||||
{
|
||||
"history_id": 41,
|
||||
"operation": "update",
|
||||
"is_undone": true,
|
||||
"created_at": "2026-05-27T11:30:00Z",
|
||||
"undone_at": "2026-05-27T13:00:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `total` | integer | Total PATCH history records for this identity |
|
||||
| `undo_stack_count` | integer | Records available for undo (`is_undone=false`) |
|
||||
| `redo_stack_count` | integer | Records available for redo (`is_undone=true`) |
|
||||
| `results[].history_id` | integer | History record ID |
|
||||
| `results[].operation` | string | Operation type (`"update"` for PATCH) |
|
||||
| `results[].is_undone` | boolean | Whether the operation has been undone |
|
||||
| `results[].created_at` | string | When the PATCH was applied |
|
||||
| `results[].undone_at` | string | When the undo occurred (null if not undone) |
|
||||
|
||||
##### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/identity/$IDENTITY_UUID/history?page=1&limit=10" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
##### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | Identity not found |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
### 2. Bind/Unbind/Trace History & Undo/Redo
|
||||
|
||||
All three operations (`bind`, `unbind`, `bind_trace`) share a single history table and undo/redo stack.
|
||||
|
||||
#### Bind Operation Overview
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Storage | PostgreSQL `identity_history` table (same table as PATCH) |
|
||||
| Snapshot | `{"file_uuid", "face_id" (or "trace_id"), "identity_id_before/after"}` |
|
||||
| Max records | 256 per identity (shared limit across all operation types) |
|
||||
| Undo steps | Unlimited (`steps` param) |
|
||||
| Redo stack | Cleared on new bind/unbind/bind_trace (`operation IN ('bind','unbind','bind_trace')` + `is_undone=true` records deleted) |
|
||||
| Stack isolation | Bind redo stack is **independent** from PATCH redo stack — clearing one does not affect the other |
|
||||
|
||||
##### Stack Model
|
||||
|
||||
```
|
||||
bind face_1 (to id=9) → unbind face_1 → bind trace 906 (to id=9)
|
||||
(undo stack, is_undone=false) (undo stack) (undo stack)
|
||||
↓ undo (first undone: bind_trace)
|
||||
bind trace 906 (is_undone=true)
|
||||
(redo stack)
|
||||
↓ redo
|
||||
bind face_1 → unbind face_1 → bind trace 906
|
||||
(undo stack)
|
||||
```
|
||||
|
||||
A new bind/unbind/trace after undo clears only the bind redo stack (operations with `IN ('bind','unbind','bind_trace')`).
|
||||
|
||||
##### Snapshot Format
|
||||
|
||||
**Before (bind):**
|
||||
```json
|
||||
{
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"face_id": "1_5",
|
||||
"identity_id_before": null
|
||||
}
|
||||
```
|
||||
|
||||
**After (bind):**
|
||||
```json
|
||||
{
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"face_id": "1_5",
|
||||
"identity_id_after": 9
|
||||
}
|
||||
```
|
||||
|
||||
**Before (unbind) — binding existed before:**
|
||||
```json
|
||||
{
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"face_id": "1_5",
|
||||
"identity_id_before": 9
|
||||
}
|
||||
```
|
||||
|
||||
**After (unbind):**
|
||||
```json
|
||||
{
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"face_id": "1_5",
|
||||
"identity_id_after": null
|
||||
}
|
||||
```
|
||||
|
||||
For `bind_trace`, the snapshot uses `trace_id` instead of `face_id`, with `identity_id_before` capturing the first face's identity in that trace.
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/identity/:identity_uuid/bind/undo`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: identity-level
|
||||
|
||||
Undo the most recent bind/unbind/bind_trace operations. Restores `identity_id_before` from the snapshot and marks records as undone.
|
||||
|
||||
##### Request (JSON)
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `steps` | integer | No | `1` | Number of undo steps to apply |
|
||||
|
||||
##### Behavior
|
||||
|
||||
- Queries `is_undone=false` records with `operation IN ('bind','unbind','bind_trace')`, ordered by `created_at DESC`
|
||||
- Restores `identity_id_before` — for bind this is `null` (face was unbound), for unbind this is the original identity (face goes back), for bind_trace this is the trace's previous identity
|
||||
- Marks the undone records as `is_undone=true` with `undone_at=NOW()`
|
||||
|
||||
##### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/identity/$IDENTITY_UUID/bind/undo" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"steps": 1}'
|
||||
```
|
||||
|
||||
##### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"identity_uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"operation": "bind",
|
||||
"undone_count": 1,
|
||||
"affected_rows": 53
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `operation` | string | The actual operation undone (`bind`, `unbind`, or `bind_trace`) |
|
||||
| `undone_count` | integer | Number of history records undone |
|
||||
| `affected_rows` | integer | Number of `face_detections` rows updated |
|
||||
|
||||
##### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | No bind undo operations available |
|
||||
| `404` | Identity not found |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/identity/:identity_uuid/bind/redo`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: identity-level
|
||||
|
||||
Redo previously undone bind/unbind/bind_trace operations. Restores `identity_id_after` from the snapshot.
|
||||
|
||||
##### Request (JSON)
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `steps` | integer | No | `1` | Number of redo steps to apply |
|
||||
|
||||
##### Behavior
|
||||
|
||||
- Queries `is_undone=true` records with `operation IN ('bind','unbind','bind_trace')`, ordered by `created_at DESC`
|
||||
- Restores `identity_id_after` — for bind this is the identity the face was bound to, for unbind this is `null`
|
||||
- Marks records as `is_undone=false` with `undone_at=NULL`
|
||||
|
||||
##### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/identity/$IDENTITY_UUID/bind/redo" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"steps": 1}'
|
||||
```
|
||||
|
||||
##### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"identity_uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"operation": "unbind",
|
||||
"redone_count": 1,
|
||||
"affected_rows": 1
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `operation` | string | The actual operation redone (`bind`, `unbind`, or `bind_trace`) |
|
||||
| `redone_count` | integer | Number of history records redone |
|
||||
| `affected_rows` | integer | Number of `face_detections` rows updated |
|
||||
|
||||
##### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | No bind redo operations available |
|
||||
| `404` | Identity not found |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
#### `GET /api/v1/identity/:identity_uuid/bind/history`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: identity-level
|
||||
|
||||
Query the bind/unbind/bind_trace operation history for an identity. Returns paginated records with undo/redo stack counts.
|
||||
|
||||
##### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `page` | integer | No | `1` | Page number (1-indexed) |
|
||||
| `limit` | integer | No | `20` | Items per page (max 100) |
|
||||
|
||||
##### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"identity_uuid": "a9a901056d6b46ff92da0c3c1a57dff4",
|
||||
"total": 3,
|
||||
"undo_stack_count": 2,
|
||||
"redo_stack_count": 1,
|
||||
"results": [
|
||||
{
|
||||
"history_id": 52,
|
||||
"operation": "bind_trace",
|
||||
"is_undone": false,
|
||||
"created_at": "2026-05-27T14:00:00Z",
|
||||
"undone_at": null
|
||||
},
|
||||
{
|
||||
"history_id": 51,
|
||||
"operation": "unbind",
|
||||
"is_undone": true,
|
||||
"created_at": "2026-05-27T13:00:00Z",
|
||||
"undone_at": "2026-05-27T14:30:00Z"
|
||||
},
|
||||
{
|
||||
"history_id": 50,
|
||||
"operation": "bind",
|
||||
"is_undone": false,
|
||||
"created_at": "2026-05-27T12:00:00Z",
|
||||
"undone_at": null
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `total` | integer | Total bind history records for this identity |
|
||||
| `undo_stack_count` | integer | Records available for undo (`is_undone=false`) |
|
||||
| `redo_stack_count` | integer | Records available for redo (`is_undone=true`) |
|
||||
| `results[].history_id` | integer | History record ID |
|
||||
| `results[].operation` | string | Operation type (`bind`, `unbind`, or `bind_trace`) |
|
||||
| `results[].is_undone` | boolean | Whether the operation has been undone |
|
||||
| `results[].created_at` | string | When the operation was applied |
|
||||
| `results[].undone_at` | string | When the undo occurred (null if not undone) |
|
||||
|
||||
##### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/identity/$IDENTITY_UUID/bind/history?page=1&limit=10" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
##### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | Identity not found |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
### 3. Merge History & Undo/Redo
|
||||
|
||||
Merge operations use MongoDB for richer record-keeping, with a 24-hour undo deadline.
|
||||
|
||||
#### Merge Operation Overview
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Storage | MongoDB `identity_merge_history` collection |
|
||||
| Snapshot | Full source identity state + target identity state + aliases/metadata diffs |
|
||||
| Trigger | Every mergeinto with `keep_history=true` |
|
||||
| Undo deadline | 24 hours (renewed on redo) |
|
||||
| Redo support | Yes — restores undone merges with new 24hr deadline |
|
||||
| Max records | Unlimited |
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/identity/merge/:merge_id/undo`
|
||||
|
||||
Already documented in [`07_identity.md`](07_identity.md#post-apiv1identitymergemerge_idundo). See that document for full details.
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/identity/merge/:merge_id/redo`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: identity-level
|
||||
|
||||
Redo a previously undone merge operation within the renewed 24-hour deadline.
|
||||
|
||||
##### Request
|
||||
|
||||
No body required. The merge ID is taken from the URL path.
|
||||
|
||||
##### Behavior
|
||||
|
||||
1. Validates the merge record exists and `undone=true` (not already active)
|
||||
2. Checks the 24-hour undo deadline (if expired, the redo is rejected)
|
||||
3. Restores face bindings: moves all faces from `target_identity` back to `source_identity`
|
||||
4. Re-adds aliases that were removed by the undo (aliases with `source: "merge"` tag)
|
||||
5. Re-adds metadata fields that were removed by the undo
|
||||
6. If `keep_history=true`: sets `source_identity.status = 'merged'` again
|
||||
7. If `keep_history=false`: recreates source identity from the `undone_snapshot` stored at undo time
|
||||
8. Syncs both identity JSON files to disk
|
||||
9. Sets `undone=false`, clears `undone_snapshot`, renews `undo_deadline = NOW() + 24h`
|
||||
10. Records `redone_by` user for audit
|
||||
|
||||
##### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/identity/merge/550e8400-e29b-41d4-a716-446655440000/redo" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
##### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Redo merge completed: merged 'stranger_13894' into 'Louis Viret' (52 faces transferred)",
|
||||
"data": {
|
||||
"merge_id": "550e8400-e29b-41d4-a716-446655440000",
|
||||
"faces_transferred": 52,
|
||||
"aliases_re_added": 1,
|
||||
"metadata_fields_re_added": 2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `merge_id` | string | The merge operation ID |
|
||||
| `faces_transferred` | integer | Number of faces transferred from source to target |
|
||||
| `aliases_re_added` | integer | Number of aliases restored to target |
|
||||
| `metadata_fields_re_added` | integer | Number of metadata fields restored to target |
|
||||
|
||||
##### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | Merge not undone, deadline expired, or cannot redo |
|
||||
| `404` | Merge record not found |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
### 4. Delete History & Undo/Redo
|
||||
|
||||
#### Delete Operation Overview
|
||||
|
||||
| Property | Value |
|
||||
|----------|-------|
|
||||
| Storage | PostgreSQL `identity_history` table |
|
||||
| Snapshot | `{"identity": {...full row...}, "unbound_faces": [{file_uuid, face_id, trace_id}, ...]}` |
|
||||
| Max records | 1 active delete record per identity (redo stack cleared on new delete) |
|
||||
| Undo support | Yes — recreates identity row, re-binds faces |
|
||||
| Redo support | Yes — re-deletes the identity |
|
||||
| Identity file | Deleted on delete, recreated on undo |
|
||||
|
||||
#### Snapshot Format
|
||||
|
||||
```json
|
||||
{
|
||||
"identity": {
|
||||
"id": 9,
|
||||
"uuid": "a9a90105-6d6b-46ff-92da-0c3c1a57dff4",
|
||||
"name": "Cary Grant",
|
||||
"identity_type": "people",
|
||||
"source": "tmdb",
|
||||
"status": "confirmed",
|
||||
"metadata": {},
|
||||
"tmdb_id": 112,
|
||||
"tmdb_profile": null
|
||||
},
|
||||
"unbound_faces": [
|
||||
{
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"face_id": "1_5",
|
||||
"trace_id": null
|
||||
},
|
||||
{
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"face_id": "1_6",
|
||||
"trace_id": 906
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Stack Model
|
||||
|
||||
```
|
||||
DELETE identity (undo stack, is_undone=false)
|
||||
↓ undo
|
||||
Identity recreated, faces re-bound
|
||||
→ delete history marked is_undone=true
|
||||
↓ redo (re-delete)
|
||||
Identity deleted again, faces unbound
|
||||
→ delete history marked is_undone=false
|
||||
```
|
||||
|
||||
A new delete after an undo clears the delete redo stack (no redo possible for the old delete).
|
||||
|
||||
#### Undo Behavior (via existing `POST /api/v1/identity/:identity_uuid/undo`)
|
||||
|
||||
1. Normal identity lookup fails (row was deleted)
|
||||
2. Checks `identity_history` for `operation='delete' AND is_undone=false` matching the UUID in the snapshot
|
||||
3. Recreates the identity row (new internal `id`, same UUID)
|
||||
4. Re-binds all faces listed in `unbound_faces` to the new identity
|
||||
5. Deletes the `identity_history` delete record as `is_undone=true` with `undone_at=NOW()`
|
||||
6. Syncs `identity.json` to disk
|
||||
7. Updates `_index.json`
|
||||
|
||||
#### Redo Behavior (via existing `POST /api/v1/identity/:identity_uuid/redo`)
|
||||
|
||||
1. Identity lookup succeeds (identity was restored by prior undo)
|
||||
2. Checks `identity_history` for `operation='delete' AND is_undone=true` matching the identity_id
|
||||
3. Deletes `identity.json` from disk
|
||||
4. Unbinds all faces (`identity_id = NULL`)
|
||||
5. Deletes the identity row
|
||||
6. Marks the delete history record as `is_undone=false`
|
||||
7. Returns success
|
||||
|
||||
#### Error Responses (delete undo/redo)
|
||||
|
||||
| HTTP | Scenario |
|
||||
|------|----------|
|
||||
| `400` | No delete history available (either no delete or already undone/redone) |
|
||||
| `404` | Identity not found (for redo — identity wasn't restored) |
|
||||
| `500` | Database error |
|
||||
|
||||
---
|
||||
|
||||
### Comparison: PATCH vs Bind vs Merge vs Delete Undo/Redo
|
||||
|
||||
| Aspect | PATCH Undo/Redo | Bind Undo/Redo | Merge Undo/Redo | Delete Undo/Redo |
|
||||
|--------|----------------|----------------|-----------------|------------------|
|
||||
| Storage | PostgreSQL `identity_history` | PostgreSQL `identity_history` | MongoDB `identity_merge_history` | PostgreSQL `identity_history` |
|
||||
| Operation filter | `operation='update'` | `operation IN ('bind','unbind','bind_trace')` | — | `operation='delete'` |
|
||||
| Trigger | Every PATCH | Every bind/unbind/bind_trace | Every mergeinto with `keep_history=true` | Every DELETE |
|
||||
| Undo deadline | None (unlimited) | None (unlimited) | 24 hours (renewed on redo) | None (unlimited) |
|
||||
| Redo support | Yes | Yes | Yes | Yes |
|
||||
| Step undo | Yes (`steps` param) | Yes (`steps` param) | No (full undo/redo only) | No (single record) |
|
||||
| Max records | 256 per identity | 256 per identity (shared) | Unlimited | 256 per identity (shared) |
|
||||
| User tracking | `user_id` + `user_source` | `user_id` + `user_source` | `performed_by_user` + `undone_by` / `redone_by` | `user_id` + `user_source` |
|
||||
|
||||
---
|
||||
|
||||
*Updated: 2026-05-28*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,345 @@
|
||||
---
|
||||
title: Face Filter API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-25
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: face_filter -->
|
||||
<!-- description: Face detection filtering and quality management -->
|
||||
<!-- depends: 01_auth, 03_register -->
|
||||
|
||||
## Face Filter API
|
||||
|
||||
Face filtering functionality for Studio frontend to manage face detection quality across multiple detection sources.
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/faces`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get filtered face detection list for a file with pagination and source filtering.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Parameter | Type | Required | Default | Description |
|
||||
|-----------|------|----------|---------|-------------|
|
||||
| `source` | string | No | "all" | Detection source: "all", "apple_vision", "mediapipe" |
|
||||
| `page` | integer | No | 1 | Page number (1-indexed) |
|
||||
| `page_size` | integer | No | 50 | Items per page |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/faces?source=apple_vision&page=1&page_size=50" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"faces": [
|
||||
{
|
||||
"face_id": "face_001",
|
||||
"frame": 671,
|
||||
"primary_source": "apple_vision",
|
||||
"primary_confidence": 0.84,
|
||||
"detection_sources": [
|
||||
{"source_type": "apple_vision", "confidence": 0.84},
|
||||
{"source_type": "mediapipe", "confidence": 0.92}
|
||||
]
|
||||
}
|
||||
],
|
||||
"total": 1523,
|
||||
"page": 1,
|
||||
"page_size": 50
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/faces/:face_id/filter`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get detailed filter report for a specific face detection.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `face_id` | string | Face detection ID |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/faces/face_001/filter" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"face_id": "face_001",
|
||||
"frame": 671,
|
||||
"passed_filter": true,
|
||||
"filter_rules": {
|
||||
"min_confidence": 0.5,
|
||||
"min_size": 30,
|
||||
"source_priority": ["apple_vision", "mediapipe"]
|
||||
},
|
||||
"quality_metrics": {
|
||||
"confidence": 0.84,
|
||||
"size": 120,
|
||||
"blurriness": 0.15
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/faces/apply-filter`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Apply filter rules to all faces in a file. Returns statistics on filtered faces.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `min_confidence` | float | No | Minimum confidence threshold (0.0-1.0) |
|
||||
| `min_size` | integer | No | Minimum face size in pixels |
|
||||
| `source_priority` | string[] | No | Preferred detection sources in order |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/faces/apply-filter" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{
|
||||
"min_confidence": 0.6,
|
||||
"min_size": 40,
|
||||
"source_priority": ["apple_vision", "mediapipe"]
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"statistics": {
|
||||
"total_faces": 1523,
|
||||
"passed_faces": 1245,
|
||||
"filtered_faces": 278,
|
||||
"by_source": {
|
||||
"apple_vision": 985,
|
||||
"mediapipe": 260
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/faces/filter-stats`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get face filter statistics for a file without applying changes.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/faces/filter-stats" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"data": {
|
||||
"total_faces": 1523,
|
||||
"detection_sources": {
|
||||
"apple_vision": 985,
|
||||
"mediapipe": 538
|
||||
},
|
||||
"confidence_distribution": {
|
||||
"high": 1245,
|
||||
"medium": 200,
|
||||
"low": 78
|
||||
},
|
||||
"size_distribution": {
|
||||
"large": 500,
|
||||
"medium": 700,
|
||||
"small": 323
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/faces/rules`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Create or update face filter rules for a file.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `rules` | array | Yes | Array of filter rules |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/faces/rules" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{
|
||||
"rules": [
|
||||
{
|
||||
"name": "high_quality",
|
||||
"conditions": {
|
||||
"min_confidence": 0.7,
|
||||
"min_size": 50
|
||||
},
|
||||
"action": "accept"
|
||||
}
|
||||
]
|
||||
}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/faces/rules`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get all face filter rules configured for a file.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/faces/rules" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"rules": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "high_quality",
|
||||
"conditions": {
|
||||
"min_confidence": 0.7,
|
||||
"min_size": 50
|
||||
},
|
||||
"action": "accept",
|
||||
"created_at": "2026-08-09T10:00:00Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `DELETE /api/v1/file/:file_uuid/faces/rules/:rule_id`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Delete a specific filter rule.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `rule_id` | integer | Rule ID |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X DELETE "$API/api/v1/file/$FILE_UUID/faces/rules/1" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Detection Sources
|
||||
|
||||
| Source | Description | Quality | Speed |
|
||||
|--------|-------------|---------|-------|
|
||||
| `apple_vision` | Apple Vision Framework | High (ANE accelerated) | Fast |
|
||||
| `mediapipe` | MediaPipe Face Detection | Medium | Medium |
|
||||
|
||||
---
|
||||
|
||||
## Quality Metrics
|
||||
|
||||
| Metric | Description | Range |
|
||||
|--------|-------------|-------|
|
||||
| `confidence` | Detection confidence | 0.0-1.0 |
|
||||
| `size` | Face bounding box diagonal (pixels) | 0-∞ |
|
||||
| `blurriness` | Laplacian variance (lower = clearer) | 0.0-1.0 |
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
### 1. Filter Low-Quality Faces
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/faces/apply-filter" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"min_confidence": 0.7, "min_size": 50}'
|
||||
```
|
||||
|
||||
### 2. Prioritize Apple Vision Detections
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/faces/apply-filter" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"source_priority": ["apple_vision"]}'
|
||||
```
|
||||
|
||||
### 3. Check Filter Statistics
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/faces/filter-stats" \
|
||||
-H "X-API-Key: $KEY" | jq '.data'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-25 | Rewrote documentation in English, added YAML frontmatter |
|
||||
@@ -1,141 +0,0 @@
|
||||
<!-- module: lookup -->
|
||||
<!-- description: File lookup by name and unregistration -->
|
||||
<!-- depends: 01_auth, 03_register -->
|
||||
|
||||
## File Lookup
|
||||
|
||||
### `GET /api/v1/files/lookup`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Search registered files by file name. Performs a case-insensitive LIKE search on the file name column. Returns basic info about matching files.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_name` | string | Yes | File name to search for (partial matches supported) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Look up a specific file
|
||||
curl -s "$API/api/v1/files/lookup?file_name=video.mp4" \
|
||||
-H "X-API-Key: $KEY"
|
||||
|
||||
# Partial name search
|
||||
curl -s "$API/api/v1/files/lookup?file_name=charade" \
|
||||
-H "X-API-Key: $KEY" | jq '.matches[].file_name'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_name": "video.mp4",
|
||||
"exists": true,
|
||||
"matches": [
|
||||
{
|
||||
"file_uuid": "a03485a40b2df2d3",
|
||||
"file_name": "video.mp4",
|
||||
"file_type": "video",
|
||||
"status": "completed"
|
||||
}
|
||||
],
|
||||
"next_name": "video (2).mp4"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_name` | string | Searched name |
|
||||
| `exists` | boolean | Exact name match exists |
|
||||
| `matches` | array | Array of matching registered files |
|
||||
| `matches[].file_uuid` | string | 32-char hex UUID |
|
||||
| `matches[].file_name` | string | Registered file name |
|
||||
| `matches[].file_type` | string | `"video"`, `"audio"`, or `null` |
|
||||
| `matches[].status` | string | Registration/processing status |
|
||||
| `next_name` | string | Suggested name for avoiding conflicts |
|
||||
|
||||
---
|
||||
|
||||
## Unregister
|
||||
|
||||
### `POST /api/v1/unregister`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Delete a registered file from the system. Supports single file by UUID, or batch by directory + regex pattern.
|
||||
|
||||
#### What gets deleted
|
||||
|
||||
| Removed (default) | Not removed |
|
||||
|---------|-------------|
|
||||
| Database records (videos, chunks, embeddings, processor_results, pre_chunks) | The original source video file on disk |
|
||||
| Processor output JSON files (`{uuid}.*.json`) — unless `delete_output_files: false` | Temp/working directories |
|
||||
| In-memory cache entries | |
|
||||
| MongoDB cached lists | |
|
||||
|
||||
> ⚠️ Database deletion is **irreversible**. To keep output files, set `"delete_output_files": false`.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
At least one mode must be specified: either `file_uuid` alone, or `file_path` + `pattern` together.
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `file_uuid` | string | * | — | Single file UUID to delete |
|
||||
| `file_path` | string | * | — | Directory path (for batch delete) |
|
||||
| `pattern` | string | * | — | Regex pattern (requires `file_path`) |
|
||||
| `delete_output_files` | boolean | No | `true` | If `true`, also delete processor output JSON files (`{uuid}.*.json`). Set to `false` to keep them. |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Delete a single file by UUID (default: also deletes output JSON files)
|
||||
curl -s -X POST "$API/api/v1/unregister" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'"}'
|
||||
|
||||
# Keep output JSON files, only delete DB records
|
||||
curl -s -X POST "$API/api/v1/unregister" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'", "delete_output_files": false}'
|
||||
|
||||
# Batch delete all mp4 files in a directory
|
||||
curl -s -X POST "$API/api/v1/unregister" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_path": "/path/to/dir", "pattern": ".*\\.mp4$"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "a03485a40b2df2d3",
|
||||
"message": "Video unregistered successfully"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | True if deletion succeeded |
|
||||
| `file_uuid` | string | UUID of the deleted file (single mode) |
|
||||
| `message` | string | Human-readable status |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | Neither `file_uuid` nor `file_path`+`pattern` provided |
|
||||
| `404` | File UUID not found |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 12:49:24*
|
||||
@@ -0,0 +1,555 @@
|
||||
---
|
||||
title: Media API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: media -->
|
||||
<!-- description: Video streaming & frame extraction -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## Video Streaming & Frame Extraction
|
||||
|
||||
All video streaming endpoints support the following common query parameters:
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `mode` | string | No | `normal` | `normal` or `debug` (draws detection overlays) |
|
||||
| `audio` | string | No | `on` | `on` or `off` |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/video`
|
||||
|
||||
Stream the full video file with range support for seeking.
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
#### Response
|
||||
|
||||
- **200**: Video stream (`Content-Type` based on file extension)
|
||||
- **206**: Partial content (range request)
|
||||
- Supports `Range` header for seeking
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/trace/:trace_id/video`
|
||||
|
||||
Stream video with highlights for a specific face trace (follows a single person across frames with bounding box overlay).
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/trace/:trace_id/representative-face`
|
||||
|
||||
Find the best single face to represent this trace. Uses a two-stage selection: SQL (area × confidence → top 10) then FFmpeg `blurdetect` (sharpness → pick the least blurry).
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/trace/1939/representative-face" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"trace_id": 1939,
|
||||
"face_count": 538,
|
||||
"representative": {
|
||||
"frame_number": 68193,
|
||||
"timestamp_secs": 2727.72,
|
||||
"bbox": { "x": 347, "y": 378, "width": 427, "height": 427 },
|
||||
"confidence": 0.760,
|
||||
"quality_score": 138516,
|
||||
"blur_score": 9.46
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Response Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `trace_id` | integer | Face trace ID |
|
||||
| `face_count` | integer | Total face detections in this trace |
|
||||
| `representative.frame_number` | integer | Frame number of the selected face (primary coordinate) |
|
||||
| `representative.timestamp_secs` | float | Time in seconds (derived from `frame_number / fps`) |
|
||||
| `representative.bbox` | object | Bounding box `{x, y, width, height}` |
|
||||
| `representative.confidence` | float | Detection confidence (0.0–1.0) |
|
||||
| `representative.quality_score` | float | Pre-selection score (`area × confidence`) |
|
||||
| `representative.blur_score` | float | FFmpeg blurdetect result (lower = sharper) |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/trace/:trace_id/thumbnail`
|
||||
|
||||
Extract the best face image for a trace as JPEG (320×320). Internally selects the face using the same two-stage algorithm as `representative-face`, then crops via FFmpeg. The result is cacheable for 24 hours.
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/trace/1939/thumbnail" \
|
||||
-H "X-API-Key: $KEY" -o trace_1939_face.jpg
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
- **200**: `image/jpeg` binary data (320×320 cropped face)
|
||||
- **404**: File, trace not found, or no suitable face
|
||||
- **500**: FFmpeg or database error
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/identities/:identity_uuid_a/co-occur-with/:identity_uuid_b`
|
||||
|
||||
Find the first frame where two identities appear together, with representative face thumbnails for both.
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Audrey Hepburn & Cary Grant 第一次同框
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/identities/$AUDREY_UUID/co-occur-with/$CARY_UUID" \
|
||||
-H "X-API-Key: $KEY" | jq '{identity_a: .identity_a.name, identity_b: .identity_b.name, first_frame: .first_cooccurrence.frame_number}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"identity_a": {
|
||||
"identity_uuid": "c3545906-c82d-4b66-aa1d-150bc02decce",
|
||||
"name": "Audrey Hepburn",
|
||||
"trace_id": 920
|
||||
},
|
||||
"identity_b": {
|
||||
"identity_uuid": "2b0ddefe-e2a9-4533-9308-b375594604d5",
|
||||
"name": "Cary Grant",
|
||||
"trace_id": 919
|
||||
},
|
||||
"first_cooccurrence": {
|
||||
"frame_number": 38165,
|
||||
"timestamp_secs": 1526.60,
|
||||
"total_cooccurrence_frames": 3136,
|
||||
"representative_face_a": {
|
||||
"frame_number": 38199,
|
||||
"bbox": { "x": 122, "y": 339, "width": 176, "height": 176 },
|
||||
"confidence": 0.832,
|
||||
"thumbnail_url": "/api/v1/file/aeed71342.../trace/920/thumbnail"
|
||||
},
|
||||
"representative_face_b": {
|
||||
"frame_number": 38291,
|
||||
"bbox": { "x": 511, "y": 315, "width": 192, "height": 192 },
|
||||
"confidence": 0.791,
|
||||
"thumbnail_url": "/api/v1/file/aeed71342.../trace/919/thumbnail"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### Response Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `identity_a.name` | string | First identity name |
|
||||
| `identity_b.name` | string | Second identity name |
|
||||
| `first_cooccurrence.frame_number` | int | First frame where both appear |
|
||||
| `first_cooccurrence.timestamp_secs` | float | Time in seconds |
|
||||
| `first_cooccurrence.total_cooccurrence_frames` | int | Total frames with both present |
|
||||
| `first_cooccurrence.representative_face_a/b` | object | Best face thumbnail data for each identity |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | File or identity not found |
|
||||
| `404` | The two identities never co-occur in this file |
|
||||
| `500` | Database or FFmpeg error |
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/video/bbox`
|
||||
|
||||
Stream video with bounding box overlay for all detected objects/faces.
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Uses a built-in 5×7 bitmap font renderer to draw labels directly on video frames via FFmpeg `drawtext` filter.
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/thumbnail`
|
||||
|
||||
Extract a single frame from a video as JPEG image. Uses FFmpeg `select` filter.
|
||||
|
||||
When `frame` is omitted, the system automatically selects the best representative frame using the TKG bridge (see algorithm below).
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `frame` | integer | No | auto-detect | Zero-based frame number to extract. Omit for auto-detect. |
|
||||
| `x` | integer | No | — | Crop start X (left edge). Requires `y`, `w`, `h`. |
|
||||
| `y` | integer | No | — | Crop start Y (top edge). Requires `x`, `w`, `h`. |
|
||||
| `w` | integer | No | — | Crop width in pixels. Requires `x`, `y`, `h`. |
|
||||
| `h` | integer | No | — | Crop height in pixels. Requires `x`, `y`, `w`. |
|
||||
|
||||
All four crop params (`x`, `y`, `w`, `h`) must be provided together or omitted.
|
||||
|
||||
#### Auto-detect Algorithm
|
||||
|
||||
When `frame` is not provided, the endpoint finds the best frame using this fallback chain:
|
||||
|
||||
1. **Main characters**: find the two identities with the most face detections (TMDb source)
|
||||
2. **Mutual gaze**: if their face traces have a TKG `CO_OCCURS_WITH` edge with `mutual_gaze=true`, take `first_frame`
|
||||
3. **Co-occurrence**: fallback to the first frame where both identities appear together
|
||||
4. **Single identity**: if only one main identity exists, take its highest-quality face frame
|
||||
5. **Any identity**: fallback to the best-quality face frame across all identities
|
||||
6. **Error**: if no face exists, returns `404`
|
||||
|
||||
The selected frame is constrained to the **first half of the video** (`total_frames / 2`).
|
||||
|
||||
#### Examples
|
||||
|
||||
```bash
|
||||
# Auto-detect best representative frame
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/thumbnail" \
|
||||
-H "X-API-Key: $KEY" -o representative.jpg
|
||||
|
||||
# Extract frame 1000 (full frame)
|
||||
curl -s "$API/api/v1/file/bd80fec92b0b6963d177a2c55bf713e2/thumbnail?frame=1000" \
|
||||
-H "Authorization: Bearer $JWT" -o frame_1000.jpg
|
||||
|
||||
# Extract and crop face region (x=320, y=240, w=160, h=160)
|
||||
curl -s "$API/api/v1/file/bd80fec92b0b6963d177a2c55bf713e2/thumbnail?frame=1000&x=320&y=240&w=160&h=160" \
|
||||
-H "Authorization: Bearer $JWT" -o face_crop.jpg
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
- **200**: `image/jpeg` binary data
|
||||
- **404**: File not found / No faces in file (auto-detect)
|
||||
- **500**: FFmpeg error (e.g., frame number exceeds video duration)
|
||||
|
||||
#### Technical Details
|
||||
|
||||
| Detail | Value |
|
||||
|--------|-------|
|
||||
| **Backend** | FFmpeg (`ffmpeg-full`) |
|
||||
| **Filter** | `select=eq(n\,FRAME)` to select frame, optional `crop=W:H:X:Y` |
|
||||
| **Output** | Single JPEG via pipe (`image2pipe`, `mjpeg` codec) |
|
||||
| **Cache** | `Cache-Control: public, max-age=86400` (24h) |
|
||||
| **Frame number** | Zero-based (`frame=0` = first frame of video) |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/representative-frame`
|
||||
|
||||
Return JSON metadata about the best representative frame for the video. Uses the same auto-detect algorithm as `GET /thumbnail` (without crop support).
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/representative-frame" \
|
||||
-H "X-API-Key: $KEY" | jq '.'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "aeed71342a899fe4b4c57b7d41bcb692",
|
||||
"frame_number": 38165,
|
||||
"timestamp_secs": 1526.6,
|
||||
"face_quality": 37292.97,
|
||||
"main_identities": [
|
||||
{
|
||||
"identity_uuid": "c3545906-c82d-4b66-aa1d-150bc02decce",
|
||||
"name": "Audrey Hepburn",
|
||||
"face_count": 16456
|
||||
},
|
||||
{
|
||||
"identity_uuid": "2b0ddefe-e2a9-4533-9308-b375594604d5",
|
||||
"name": "Cary Grant",
|
||||
"face_count": 10643
|
||||
}
|
||||
],
|
||||
"traces": [
|
||||
{
|
||||
"trace_id": 919,
|
||||
"identity_uuid": "2b0ddefe-e2a9-4533-9308-b375594604d5",
|
||||
"name": "Cary Grant",
|
||||
"x": 764,
|
||||
"y": 237,
|
||||
"width": 199,
|
||||
"height": 199,
|
||||
"confidence": 0.8426
|
||||
},
|
||||
{
|
||||
"trace_id": 920,
|
||||
"identity_uuid": "c3545906-c82d-4b66-aa1d-150bc02decce",
|
||||
"name": "Audrey Hepburn",
|
||||
"x": 1143,
|
||||
"y": 312,
|
||||
"width": 215,
|
||||
"height": 215,
|
||||
"confidence": 0.8068
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Response Fields
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `frame_number` | integer | Selected representative frame number (primary coordinate) |
|
||||
| `timestamp_secs` | float | Time in seconds (derived from `frame_number / fps`) |
|
||||
| `face_quality` | float | Quality score `area × confidence` of the best face at this frame |
|
||||
| `main_identities` | array | Top 2 most frequent TMDb identities in the file |
|
||||
| `main_identities[].name` | string | Identity display name |
|
||||
| `main_identities[].face_count` | integer | Total face detections count |
|
||||
| `traces` | array | All face traces present at the selected frame |
|
||||
| `traces[].trace_id` | integer | Face trace ID |
|
||||
| `traces[].identity_uuid` | string or null | Matched identity UUID |
|
||||
| `traces[].name` | string or null | Identity name |
|
||||
| `traces[].x, y, width, height` | integer | Bounding box coordinates |
|
||||
| `traces[].confidence` | float | Detection confidence (0.0–1.0) |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | File not found / No faces in file |
|
||||
| `500` | Database error |
|
||||
|
||||
Extract a video clip (time range) as MPEG-TS stream. Uses FFmpeg `-ss` fast seek.
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `start_frame` | integer | No* | — | Start frame (zero-based). **Frame-accurate** — use this for precision. |
|
||||
| `end_frame` | integer | No* | — | End frame (zero-based, inclusive). Requires `start_frame`. |
|
||||
| `start_time` | float | No* | — | Start time in seconds. Approximate (FPS-dependent). Fallback if frames not given. |
|
||||
| `end_time` | float | No* | — | End time in seconds. Approximate (FPS-dependent). Fallback if frames not given. |
|
||||
| `fps` | float | No | video FPS | Override frames-per-second for frame↔time calculation. Defaults to video's detected FPS. |
|
||||
| `mode` | string | No | `normal` | `normal` or `debug` (draws "CLIP" overlay) |
|
||||
| `audio` | string | No | `on` | `on` or `off` |
|
||||
|
||||
Either (`start_frame`+`end_frame`) OR (`start_time`+`end_time`) must be provided.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Clip by frame range (primary)
|
||||
curl -s "$API/api/v1/file/bd80fec92b0b6963d177a2c55bf713e2/clip?start_frame=0&end_frame=47" \
|
||||
-H "Authorization: Bearer $JWT" -o clip.ts
|
||||
|
||||
# Clip by time range (fallback)
|
||||
curl -s "$API/api/v1/file/bd80fec92b0b6963d177a2c55bf713e2/clip?start_time=30&end_time=45" \
|
||||
-H "Authorization: Bearer $JWT" -o clip.ts
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
- **200**: `video/mp2t` MPEG-TS stream
|
||||
- **400**: Missing/invalid range parameters
|
||||
- **404**: File not found
|
||||
- **500**: FFmpeg error
|
||||
|
||||
#### Technical Notes
|
||||
|
||||
| Detail | Value |
|
||||
|--------|-------|
|
||||
| **Backend** | FFmpeg (`ffmpeg-full`) |
|
||||
| **Seek** | `-ss` before `-i` (fast keyframe seek) |
|
||||
| **Format** | MPEG-TS (`mpegts` muxer, pipe-safe) |
|
||||
| **Codec** | H.264 + AAC |
|
||||
| **Cache** | `Cache-Control: public, max-age=86400` (24h) |
|
||||
|
||||
### Video vs Clip: Quality & Format Comparison
|
||||
|
||||
Both endpoints support time range extraction, but serve different use cases:
|
||||
|
||||
| Feature | `/video` | `/clip` |
|
||||
|---------|----------|---------|
|
||||
| **No params** | Streams full file (Range seek) | Returns 400 (params required) |
|
||||
| **HTTP Range** | ✅ Supported | ❌ Not supported |
|
||||
| **Encoding** | `-c copy` (zero encoding) | `-c:v libx264 -c:a aac` (re-encode) |
|
||||
| **Quality** | Original (bit-exact, zero loss) | Compressed (default CRF ≈ 23) |
|
||||
| **Format** | `video/mp4` | `video/mp2t` (MPEG-TS) |
|
||||
| **Speed** | Fast (no computation) | Slower (encoding required) |
|
||||
| **Frame control** | Time-based (`dur = (ef-sf)/fps`) | Precise (`-vframes`) |
|
||||
| **Debug mode** | ❌ | ✅ `mode=debug` overlay |
|
||||
| **Cache** | ❌ | ✅ `max-age=86400` |
|
||||
|
||||
#### Usage Recommendation
|
||||
|
||||
| Scenario | Use |
|
||||
|----------|-----|
|
||||
| Full video streaming / player seek | `/video` |
|
||||
| Quick preview clip (zero quality loss) | `/video?start_frame=...&end_frame=...` |
|
||||
| Debug frame verification / text overlay | `/clip?mode=debug` |
|
||||
| Precise frame count control | `/clip` |
|
||||
| CDN cacheable clip | `/clip` |
|
||||
|
||||
---
|
||||
|
||||
| Detail | Value |
|
||||
|--------|-------|
|
||||
| **Backend** | FFmpeg (`ffmpeg-full`) |
|
||||
| **Filter** | `select=eq(n\,FRAME)` to select frame, optional `crop=W:H:X:Y` |
|
||||
| **Output** | Single JPEG via pipe (`image2pipe`, `mjpeg` codec) |
|
||||
| **Cache** | `Cache-Control: public, max-age=86400` (24h) |
|
||||
| **Frame number** | Zero-based (`frame=0` = first frame of video) |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/stranger/:stranger_id/representative-face`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get the representative face for a stranger (unidentified face trace).
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/stranger/1/representative-face" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"stranger_id": 1,
|
||||
"face_count": 85,
|
||||
"representative": {
|
||||
"frame_number": 5000,
|
||||
"timestamp_secs": 208.33,
|
||||
"bbox": {"x": 200, "y": 100, "width": 150, "height": 150},
|
||||
"confidence": 0.92,
|
||||
"quality_score": 20700,
|
||||
"blur_score": 8.5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/stranger/:stranger_id/thumbnail`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Extract the best face image for a stranger as JPEG (320×320).
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/stranger/1/thumbnail" \
|
||||
-H "X-API-Key: $KEY" -o stranger_1_face.jpg
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
- **200**: `image/jpeg` binary data (320×320 cropped face)
|
||||
- **404**: File or stranger not found
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/chunk/:chunk_id/thumbnail`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get thumbnail for a specific chunk. Extracts the representative frame for the chunk's time range.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/chunk/chunk_1/thumbnail" \
|
||||
-H "X-API-Key: $KEY" -o chunk_1.jpg
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
- **200**: `image/jpeg` binary data
|
||||
- **404**: File or chunk not found
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/media-proxy`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Proxy request to fetch media from external URLs. Useful for loading profile images or thumbnails from external services (TMDb, etc.) without exposing the external URL to the client.
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `url` | string | Yes | External URL to proxy |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/media-proxy?url=https://image.tmdb.org/t/p/w500/abc123.jpg" \
|
||||
-H "X-API-Key: $KEY" -o tmdb_profile.jpg
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
- **200**: Proxied media data (Content-Type from external source)
|
||||
- **400**: Missing or invalid URL parameter
|
||||
- **500**: External request failed
|
||||
|
||||
---
|
||||
|
||||
---
|
||||
*Updated: 2026-06-20 — Added stranger endpoints, chunk thumbnail, and media proxy*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,494 @@
|
||||
---
|
||||
title: profile API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: profile -->
|
||||
<!-- description: Trace profile and file profile management — read/update face trace names, key frames, aliases, and file paths -->
|
||||
<!-- depends: 01_auth, 07_identity, 15_tkg -->
|
||||
|
||||
## Profile Management
|
||||
|
||||
Endpoints for managing trace profiles (face track metadata stored in TKG) and file profiles (video metadata stored in PostgreSQL).
|
||||
|
||||
---
|
||||
|
||||
## Terminology
|
||||
|
||||
### Core Concepts
|
||||
|
||||
| Term | Definition | Identifier | Display Format |
|
||||
|------|------------|------------|----------------|
|
||||
| **Face** | A single human face detection on one frame | `face_id` | Usually not displayed |
|
||||
| **Face Sequence (Trace)** | A collection of faces across multiple frames representing the same person | `trace_id` | `FS#233` |
|
||||
| **Face Group** | A collection of traces sharing the same name/label | `label` (string) | `"Person A"` |
|
||||
|
||||
### Data Model Hierarchy
|
||||
|
||||
```
|
||||
Video
|
||||
└── Frame (F#233, F#234, ...) ← Single frame number
|
||||
└── Face ← Single detection (bbox + confidence)
|
||||
└── Face Sequence / Trace ← Same person across frames (FS#233)
|
||||
└── Face Group ← Multiple traces with same name
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```
|
||||
Video: "interview.mp4"
|
||||
├── Frame F#100
|
||||
│ └── Face (bbox: {100, 200, 50, 50}, confidence: 0.95)
|
||||
├── Frame F#105
|
||||
│ └── Face (bbox: {110, 205, 48, 48}, confidence: 0.92)
|
||||
├── Frame F#110
|
||||
│ └── Face (bbox: {115, 210, 52, 52}, confidence: 0.88)
|
||||
...
|
||||
|
||||
Face Sequence FS#233 = [Face@F#100, Face@F#105, Face@F#110, ...]
|
||||
↓
|
||||
Face Group "Person A" = [FS#233, FS#234, FS#235]
|
||||
```
|
||||
|
||||
### Storage
|
||||
|
||||
| Entity | Storage | Table/Collection |
|
||||
|--------|---------|------------------|
|
||||
| Face | Qdrant | `_faces` collection |
|
||||
| Face Sequence / Trace | PostgreSQL (TKG) | `tkg_nodes` where `node_type='face_track'` |
|
||||
| Face Group | PostgreSQL (TKG) | `tkg_nodes.label` field |
|
||||
|
||||
### Operations
|
||||
|
||||
| Operation | Level | API |
|
||||
|-----------|-------|-----|
|
||||
| View faces | Face | Internal (embedded in trace data) |
|
||||
| Merge traces | Trace | `POST /api/v1/trace/:file_uuid/merge` |
|
||||
| Rename group | Group | `PUT /api/v1/trace-profile/group` |
|
||||
| Merge groups | Group | `POST /api/v1/file/:file_uuid/groups/merge` |
|
||||
|
||||
### Naming Convention
|
||||
|
||||
- **Frame**: `F#{number}` — e.g., `F#233`
|
||||
- **Face Sequence / Trace**: `FS#{number}` — e.g., `FS#233`
|
||||
- **Face Group**: String name — e.g., `"Person A"`, `"Speaker 1"`
|
||||
|
||||
### `GET /api/v1/trace-profile`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Read a single face trace's profile including name, key frame, key face, and multi-language aliases.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `trace_id` | integer | Yes | Trace ID (numeric) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/trace-profile?file_uuid=$FILE_UUID&trace_id=7" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"trace_id": 7,
|
||||
"name": "John Doe",
|
||||
"key_frame": 640,
|
||||
"key_face": "face_12345",
|
||||
"aliases": {
|
||||
"en": "John Doe",
|
||||
"zh": "約翰"
|
||||
},
|
||||
"properties": {
|
||||
"status": "bound",
|
||||
"avg_bbox": {"x": 899, "y": 212, "width": 342, "height": 342},
|
||||
"start_frame": 624,
|
||||
"end_frame": 669,
|
||||
"frame_count": 5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `trace_id` | integer | Trace ID |
|
||||
| `name` | string | Display name (from `tkg_nodes.label`) |
|
||||
| `key_frame` | integer | Representative frame number, or null |
|
||||
| `key_face` | string | Representative face ID, or null |
|
||||
| `aliases` | object | Multi-language name aliases |
|
||||
| `properties` | object | Full TKG node properties (bbox, frames, etc.) |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | Trace not found |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
### `PUT /api/v1/trace-profile`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Update a single face trace's profile fields. Only provided fields are updated; others remain unchanged.
|
||||
|
||||
#### Request Body
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `trace_id` | integer | Yes | Trace ID to update |
|
||||
| `name` | string | No | New display name |
|
||||
| `key_frame` | integer | No | Representative frame number |
|
||||
| `key_face` | string | No | Representative face ID |
|
||||
| `aliases` | object | No | Multi-language aliases `{"en": "...", "zh": "..."}` |
|
||||
| `properties` | object | No | Additional properties to merge into existing JSONB |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X PUT "$API/api/v1/trace-profile" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"trace_id": 7,
|
||||
"name": "John Doe",
|
||||
"key_frame": 640,
|
||||
"key_face": "face_12345",
|
||||
"aliases": {"en": "John Doe", "zh": "約翰"}
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Trace profile updated",
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"trace_id": 7
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `PUT /api/v1/trace-profile/group`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Batch update the `name` (label) for multiple traces in a face group. Used when renaming a group.
|
||||
|
||||
#### Request Body
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `trace_ids` | integer[] | Yes | List of trace IDs to update |
|
||||
| `name` | string | Yes | New group name for all traces |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X PUT "$API/api/v1/trace-profile/group" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"trace_ids": [7, 2, 13],
|
||||
"name": "Group A"
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Updated 3 traces in group",
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"updated_count": 3
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/groups/merge`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Merge multiple face groups into one target group. All traces from source groups are reassigned to the target group name.
|
||||
|
||||
#### Request Body
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `source_groups` | string[] | Yes | List of group names to merge from |
|
||||
| `target_group_name` | string | Yes | Target group name to merge into |
|
||||
|
||||
#### Examples
|
||||
|
||||
**Merge 2 groups**:
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/groups/merge" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "c36f35685177c981aa139b66bbbccc5b",
|
||||
"source_groups": ["Person A"],
|
||||
"target_group_name": "Person B"
|
||||
}'
|
||||
```
|
||||
|
||||
**Merge 4 groups**:
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/groups/merge" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "c36f35685177c981aa139b66bbbccc5b",
|
||||
"source_groups": ["Person A", "Person C", "Person D"],
|
||||
"target_group_name": "Person B"
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "c36f35685177c981aa139b66bbbccc5b",
|
||||
"source_groups": ["Person A", "Person C", "Person D"],
|
||||
"target_group_name": "Person B",
|
||||
"traces_merged": 12,
|
||||
"message": "Merged 3 group(s) into 'Person B'"
|
||||
}
|
||||
```
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | Condition |
|
||||
|------|-----------|
|
||||
| `400` | Target group in source_groups list |
|
||||
| `400` | Empty source_groups array |
|
||||
| `500` | Database error |
|
||||
|
||||
#### Behavior
|
||||
|
||||
1. Find all traces with `label IN (source_groups)`
|
||||
2. Update their labels to `target_group_name`
|
||||
3. All source groups disappear (no traces left)
|
||||
4. Target group contains all traces from merged groups
|
||||
|
||||
---
|
||||
|
||||
### Merging Groups: Two Methods
|
||||
|
||||
#### Method 1: Use Merge Groups API (Recommended)
|
||||
|
||||
```bash
|
||||
POST /api/v1/file/:file_uuid/groups/merge
|
||||
{
|
||||
"file_uuid": "...",
|
||||
"source_groups": ["Person A", "Person C"],
|
||||
"target_group_name": "Person B"
|
||||
}
|
||||
```
|
||||
|
||||
**Pros**: Simple, only requires group names, supports multi-group merge
|
||||
**Cons**: New API (requires backend update)
|
||||
|
||||
#### Method 2: Use Batch Update API (Existing)
|
||||
|
||||
```bash
|
||||
PUT /api/v1/trace-profile/group
|
||||
{
|
||||
"file_uuid": "...",
|
||||
"trace_ids": [13, 14, 15, 43, 44],
|
||||
"name": "Person B"
|
||||
}
|
||||
```
|
||||
|
||||
**Pros**: Works with existing API
|
||||
**Cons**: Frontend must collect all trace_ids from both groups
|
||||
|
||||
#### Example: Merge Group A and C into Group B
|
||||
|
||||
**Before**:
|
||||
```
|
||||
Group A: [13, 14, 15]
|
||||
Group B: [43, 44]
|
||||
Group C: [67, 68]
|
||||
```
|
||||
|
||||
**Method 1 (Recommended)**:
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/groups/merge" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "c36f35685177c981aa139b66bbbccc5b",
|
||||
"source_groups": ["Person A", "Person C"],
|
||||
"target_group_name": "Person B"
|
||||
}'
|
||||
```
|
||||
|
||||
**Method 2 (Existing API)**:
|
||||
```bash
|
||||
curl -X PUT "$API/api/v1/trace-profile/group" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "c36f35685177c981aa139b66bbbccc5b",
|
||||
"trace_ids": [13, 14, 15, 43, 44, 67, 68],
|
||||
"name": "Person B"
|
||||
}'
|
||||
```
|
||||
|
||||
**After**:
|
||||
```
|
||||
Group A: [] (disappeared)
|
||||
Group B: [43, 44, 13, 14, 15, 67, 68]
|
||||
Group C: [] (disappeared)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file-profile`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Read a file's metadata including path, name, status, and technical details.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file-profile?file_uuid=$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "49884ce1c341953d1ad7bf67a77c30cc",
|
||||
"file_name": "Dedicatoria.mp4",
|
||||
"file_path": "/Users/accusys/momentry/var/sftpgo/data/demo/Dedicatoria.mp4",
|
||||
"status": "completed",
|
||||
"duration": 93.33,
|
||||
"width": 1280,
|
||||
"height": 720,
|
||||
"fps": 30.0,
|
||||
"total_frames": 0
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `file_name` | string | File name |
|
||||
| `file_path` | string | Full filesystem path |
|
||||
| `status` | string | `pending`, `processing`, `completed`, `failed` |
|
||||
| `duration` | float | Duration in seconds |
|
||||
| `width` | integer | Video width in pixels |
|
||||
| `height` | integer | Video height in pixels |
|
||||
| `fps` | float | Frames per second |
|
||||
| `total_frames` | integer | Total frame count |
|
||||
|
||||
---
|
||||
|
||||
### `PUT /api/v1/file-profile`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Update file metadata, typically used when a file is moved to a new location.
|
||||
|
||||
#### Request Body
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `file_path` | string | No | New filesystem path |
|
||||
| `file_name` | string | No | New file name |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X PUT "$API/api/v1/file-profile" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"file_uuid": "49884ce1c341953d1ad7bf67a77c30cc",
|
||||
"file_path": "/new/location/Dedicatoria.mp4"
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "File profile updated",
|
||||
"file_uuid": "49884ce1c341953d1ad7bf67a77c30cc"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Data Storage
|
||||
|
||||
| Profile Type | Storage | Table |
|
||||
|-------------|---------|-------|
|
||||
| **trace_profile** | PostgreSQL (TKG) | `tkg_nodes` where `node_type='face_track'` |
|
||||
| **file_profile** | PostgreSQL | `videos` |
|
||||
|
||||
### Trace Profile Fields
|
||||
|
||||
| Field | TKG Column | Description |
|
||||
|-------|-----------|-------------|
|
||||
| `name` | `label` | Display name for the trace |
|
||||
| `key_frame` | `properties->'key_frame'` | Representative frame number |
|
||||
| `key_face` | `properties->'key_face'` | Representative face ID |
|
||||
| `aliases` | `properties->'aliases'` | Multi-language name aliases |
|
||||
|
||||
---
|
||||
*Updated: 2026-07-25 — Added Merge Groups API (POST /groups/merge), added Terminology section (Face, Face Sequence, Face Group)*
|
||||
*Updated: 2026-07-21 — Fixed external_id matching (trace_N + face_track_N formats), fixed parameter ordering in UPDATE query*
|
||||
*Updated: 2026-07-18 — New profile module: trace-profile (GET, PUT, PUT group) and file-profile (GET, PUT)*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,184 @@
|
||||
---
|
||||
title: Pose & Appearance API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: pose_appearance -->
|
||||
<!-- description: Pose skeleton and appearance color endpoints for face detail display -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## Pose & Appearance
|
||||
|
||||
Endpoints for retrieving pose keypoints and appearance color data for face detail modal display.
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/pose`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get pose keypoints for a specific frame. Returns 17 COCO keypoints with deduplication (highest confidence selected for each keypoint name).
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `frame` | integer | Yes | Frame number |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/pose?frame=303" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"frame": 303,
|
||||
"keypoints": [
|
||||
{"name": "nose", "x": 315.91, "y": 364.25, "confidence": 0.616},
|
||||
{"name": "left_eye", "x": 312.45, "y": 362.80, "confidence": 0.616},
|
||||
{"name": "right_eye", "x": 316.21, "y": 361.38, "confidence": 0.616},
|
||||
{"name": "left_ear", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "right_ear", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "left_shoulder", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "right_shoulder", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "left_elbow", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "right_elbow", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "left_wrist", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "right_wrist", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "left_hip", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "right_hip", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "left_knee", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "right_knee", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "left_ankle", "x": 0.0, "y": 0.0, "confidence": 0.0},
|
||||
{"name": "right_ankle", "x": 0.0, "y": 0.0, "confidence": 0.0}
|
||||
],
|
||||
"pose_class": "unknown",
|
||||
"confidence": null
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `frame` | integer | Frame number |
|
||||
| `keypoints` | array | 17 COCO keypoints (deduplicated) |
|
||||
| `keypoints[].name` | string | Keypoint name |
|
||||
| `keypoints[].x` | float | X coordinate in pixels |
|
||||
| `keypoints[].y` | float | Y coordinate in pixels |
|
||||
| `keypoints[].confidence` | float | Detection confidence 0-1 (0 means not detected) |
|
||||
| `pose_class` | string | Always `"unknown"` in POC |
|
||||
| `confidence` | null | Always `null` in POC |
|
||||
|
||||
#### COCO-17 Keypoint Names
|
||||
|
||||
```
|
||||
nose, left_eye, right_eye, left_ear, right_ear,
|
||||
left_shoulder, right_shoulder, left_elbow, right_elbow,
|
||||
left_wrist, right_wrist, left_hip, right_hip,
|
||||
left_knee, right_knee, left_ankle, right_ankle
|
||||
```
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| 404 | Frame not found or pose.json not found |
|
||||
| 401 | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/appearance`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get appearance color data for a specific frame. Returns HSV histogram for color analysis.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
|
||||
#### Query Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `frame` | integer | Yes | Frame number |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/appearance?frame=303" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"frame": 303,
|
||||
"dominant_colors": [],
|
||||
"hsv_histogram": [
|
||||
[0.59, 0.0, 0.0, ...],
|
||||
[0.97, 0.02, 0.01, ...],
|
||||
[0.004, 0.02, 0.03, ...]
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `frame` | integer | Frame number |
|
||||
| `dominant_colors` | array | Empty array in POC (`[]`) |
|
||||
| `hsv_histogram` | array | 3x30 HSV histogram bins (H, S, V channels) |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| 404 | Frame not found or appearance.json not found |
|
||||
| 401 | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
## Data Source
|
||||
|
||||
| Processor | File | Location |
|
||||
|-----------|------|----------|
|
||||
| Pose | `{file_uuid}.pose.json` | `{OUTPUT_DIR}/` |
|
||||
| Appearance | `{file_uuid}.appearance.json` | `{OUTPUT_DIR}/` |
|
||||
|
||||
---
|
||||
|
||||
## POC Limitations
|
||||
|
||||
| Feature | POC Status | Future |
|
||||
|---------|------------|--------|
|
||||
| Pose classification | `"unknown"` | ML model for standing/sitting/etc. |
|
||||
| Dominant colors | Empty array `[]` | HSV extraction algorithm |
|
||||
| Multiple persons | First person only | Match by trace_id |
|
||||
| Confidence | `null` | Aggregated confidence score |
|
||||
|
||||
---
|
||||
*Updated: 2026-07-19 — New pose and appearance endpoints for face detail display*
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,114 @@
|
||||
# Trace Thumbnail Regenerate API 使用指南 — Studio 團隊參考
|
||||
|
||||
**版本**: v1.0
|
||||
**日期**: 2026-08-12
|
||||
**狀態**: 已實作(Core)
|
||||
|
||||
---
|
||||
|
||||
## 概述
|
||||
|
||||
修復「key_frame 正常、key_face bbox 正常、但 key_face 縮圖異常」之現象。
|
||||
|
||||
**根因**: bbox 部分越過 frame 邊界(如 trace 355b 案例)時,crop 未 clamp 到 frame 尺寸,ffmpeg 靜默 clamp/位移,導致縮圖內容錯位。由於縮圖端點優先回傳 `key_face.jpg` cache,異常內容被持久化顯示。
|
||||
|
||||
**修復**: 本端點重新選取該 trace 之 best-confidence face,將 bbox clamp 至影片尺寸後重新裁切,覆寫 `key_face.jpg`,並同步更新 `.faces` cache。
|
||||
|
||||
---
|
||||
|
||||
## API 端點
|
||||
|
||||
### POST `/api/v1/file/{file_uuid}/trace/{trace_id}/regenerate-thumbnail`
|
||||
|
||||
**功能**: 重新產生單一 trace 的 face thumbnail(覆寫 cache)
|
||||
**Auth**: Required
|
||||
**Body**: 可為空。
|
||||
|
||||
**Response 200**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "...",
|
||||
"trace_id": 355,
|
||||
"frame": 1835,
|
||||
"bbox": { "x": 65, "y": 301, "width": 70, "height": 59 }
|
||||
}
|
||||
```
|
||||
- `frame` / `bbox` 為重新裁切使用的(clamp 後)frame 與 bbox。
|
||||
|
||||
**Error Responses**:
|
||||
| Status | 說明 |
|
||||
|--------|------|
|
||||
| 404 | Video not found(該 file_uuid 無影片)或 No face found for this trace(該 trace 無 face 資料) |
|
||||
| 400 | Video width/height unavailable — 影片未記錄尺寸,無法 clamp,拒絕重切 |
|
||||
|
||||
---
|
||||
|
||||
## 行為說明
|
||||
|
||||
1. 讀取該 trace 最高 confidence 的 frame + bbox(**不**重跑 blur 優化,取既有 best face 復原同一區域)
|
||||
2. 將 bbox clamp 到影片 width/height 內(`clamp_crop`)
|
||||
3. ffmpeg 自影片以 decoded frame index 切出該 frame → crop face 區域
|
||||
4. 覆寫 `{OUTPUT_DIR}/{file_uuid}/trace_{trace_id}/key_face.jpg`
|
||||
5. 若 `.faces/{file_uuid}/{trace_id}/{frame}.jpg` 已存在則同步覆寫
|
||||
|
||||
**不影響**: Qdrant、`trace_profiles` DB、`tkg_nodes`、影片檔 — 僅重寫縮圖 cache。
|
||||
|
||||
---
|
||||
|
||||
## Studio 整合步驟
|
||||
|
||||
### 1. apiCall (`src/api/index.ts`)
|
||||
|
||||
新增 case:
|
||||
```ts
|
||||
case 'regenerate_trace_thumbnail': {
|
||||
return { url: `/api/v1/file/${a.fileUuid}/trace/${a.traceId}/regenerate-thumbnail`, method: 'POST' }
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Face detail modal 加「Re-gen」按鈕 (`src/views/PeopleView.vue`)
|
||||
|
||||
於 `ms-face-detail-thumb` 附近加入按鈕,呼叫上方 apiCall,in-flight 時 disabled。
|
||||
|
||||
### 3. 觸發後 refresh(重要)
|
||||
|
||||
Face detail 縮圖顯示的是 `faceThumbsCache`(key = `${file_uuid}-${trace_id}`)。`loadTraceThumb` 對已有 cache 的 key 會直接 return,**單獨 `bumpThumbCacheBust()` 無法刷新 face detail 縮圖**。正確順序:
|
||||
|
||||
```ts
|
||||
await apiCall('regenerate_trace_thumbnail', { fileUuid, traceId }) // 1. 呼叫 regenerate
|
||||
delete faceThumbsCache.value[`${fileUuid}-${traceId}`] // 2. 清除該 key 的 blob cache
|
||||
bumpThumbCacheBust() // 3. bump 版本(避 HTTP cache)
|
||||
loadTraceThumb({ file_uuid: fileUuid, trace_id: traceId }) // 4. 重新載入縮圖
|
||||
```
|
||||
|
||||
> `candidateThumbs` 即 `faceThumbsCache` 的 alias(PeopleView.vue:722),delete 後無需額外處理。
|
||||
> 若想一次清空全部縮圖可用 `clearFaceThumbs()`(較重,不建議單一 trace 場景)。
|
||||
|
||||
---
|
||||
|
||||
## 測試指示
|
||||
|
||||
```bash
|
||||
# 使用已知越界案例(trace 355b 一類)驗證:
|
||||
# 1) regenerate 前:GET thumbnail 顯示位移內容
|
||||
# 2) 呼叫 regenerate → 回 success,含 clamp 後 bbox
|
||||
# 3) 再次 GET thumbnail → 內容正確對齊 bbox
|
||||
curl -X POST "http://localhost:3002/api/v1/file/<FILE_UUID>/trace/<TRACE_ID>/regenerate-thumbnail" \
|
||||
-H "X-API-Key: <KEY>"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 參考
|
||||
|
||||
- 根因 crop 修正:`src/core/thumbnail/validator.rs::clamp_crop`、`src/core/processor/tkg.rs`
|
||||
- 端點 handler:`src/api/trace_agent_api.rs::regenerate_trace_thumbnail`
|
||||
|
||||
---
|
||||
|
||||
## 版本歷史
|
||||
|
||||
| 版本 | 日期 | 變更 |
|
||||
|------|------|------|
|
||||
| v1.0 | 2026-08-12 | 初版 |
|
||||
@@ -1,239 +0,0 @@
|
||||
<!-- module: process -->
|
||||
<!-- description: Processing pipeline — trigger, probe, progress, jobs -->
|
||||
<!-- depends: 01_auth, 03_register -->
|
||||
|
||||
## Processing Pipeline
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/process`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Trigger the processing pipeline for a registered file. Creates a monitor job that the worker picks up and processes sequentially. Returns immediately with the job info—processing runs asynchronously in the background.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `processors` | string[] | No | all | Specific processors to run: `["cut","asr","asrx","yolo","ocr","face","pose","visual_chunk","story","5w1h"]` |
|
||||
| `rules` | string[] | No | all | Rule names to apply (currently unused) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Run all processors
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/process" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" -d '{}'
|
||||
|
||||
# Run specific processors only
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/process" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"processors": ["asr", "face", "yolo"]}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"job_id": 42,
|
||||
"file_uuid": "3a6c1865...",
|
||||
"status": "processing",
|
||||
"pids": [12345, 12346],
|
||||
"message": "Processing triggered for video.mp4"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `job_id` | integer | Monitor job ID (for job tracking) |
|
||||
| `file_uuid` | string | 32-char hex UUID of the file |
|
||||
| `status` | string | `"processing"` |
|
||||
| `pids` | integer[] | Process IDs of started processors |
|
||||
| `message` | string | Human-readable status |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | File UUID not found |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/probe`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get ffprobe metadata for a registered file. Returns video/audio stream info, codec details, duration, resolution, and frame rate.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/probe" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"file_name": "video.mp4",
|
||||
"file_size": 794863677,
|
||||
"duration": 120.5,
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"fps": 24.0,
|
||||
"total_frames": 2892,
|
||||
"cached": true,
|
||||
"format": {
|
||||
"filename": "/path/to/video.mp4",
|
||||
"format_name": "mov,mp4,m4a,3gp",
|
||||
"duration": "120.5",
|
||||
"size": "12345678",
|
||||
"bit_rate": "819200"
|
||||
},
|
||||
"streams": [
|
||||
{
|
||||
"index": 0,
|
||||
"codec_name": "h264",
|
||||
"codec_type": "video",
|
||||
"width": 1920,
|
||||
"height": 1080,
|
||||
"r_frame_rate": "24/1",
|
||||
"duration": "120.5"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `file_name` | string | File name |
|
||||
| `file_size` | integer | File size in bytes (from filesystem) |
|
||||
| `duration` | float | Duration in seconds |
|
||||
| `width` | integer | Video width in pixels |
|
||||
| `height` | integer | Video height in pixels |
|
||||
| `fps` | float | Frames per second |
|
||||
| `total_frames` | integer | Estimated total frames |
|
||||
| `cached` | boolean | True if result was from cached probe JSON |
|
||||
| `format` | object | Container format info (ffprobe format section) |
|
||||
| `streams` | array | Array of stream info objects |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/progress/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get real-time processing progress for a file via Redis pub/sub. Includes per-processor status, current/total frames, ETA, and system resource stats.
|
||||
|
||||
#### Pipeline Order
|
||||
|
||||
| Order | Processor | Dependencies | Description |
|
||||
|-------|-----------|-------------|-------------|
|
||||
| 1 | `cut` | — | Scene detection |
|
||||
| 2 | `asr` | cut | Speech-to-text (per scene) |
|
||||
| 3 | `asrx` | asr | Speaker diarization |
|
||||
| 4 | `yolo` | — | Object detection |
|
||||
| 5 | `ocr` | — | Text recognition |
|
||||
| 6 | `face` | — | Face detection & embedding |
|
||||
| 7 | `pose` | — | Pose estimation |
|
||||
| 8 | `visual_chunk` | yolo | Visual scene chunks |
|
||||
| 9 | `story` | asr, asrx, cut, yolo, face | Scene summaries (template) |
|
||||
| 10 | `5w1h` | story | 5W1H analysis (Gemma4 LLM) |
|
||||
|
||||
All processors except `story` and `5w1h` run concurrently when their dependencies are met. Story and 5W1H run sequentially after their prerequisites.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/progress/$FILE_UUID" -H "X-API-Key: $KEY" | jq '{overall_progress, processors: [.processors[] | {processor_type, status}]}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3a6c1865...",
|
||||
"overall_progress": 71,
|
||||
"cpu_percent": 45.2,
|
||||
"gpu_percent": 30.1,
|
||||
"memory_percent": 62.4,
|
||||
"processors": [
|
||||
{"processor_type": "asr", "status": "complete", "progress": 100},
|
||||
{"processor_type": "yolo", "status": "running", "progress": 65},
|
||||
{"processor_type": "face", "status": "pending", "progress": 0}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `overall_progress` | integer | Overall progress percentage (0–100) |
|
||||
| `processors` | array | Per-processor status list |
|
||||
| `processors[].processor_type` | string | Processor name (`asr`, `cut`, `yolo`, etc.) |
|
||||
| `processors[].status` | string | `"pending"`, `"running"`, `"complete"`, or `"failed"` |
|
||||
| `processors[].progress` | integer | Per-processor progress (0–100) |
|
||||
| `processors[].eta_seconds` | integer | Estimated seconds remaining (running processors) |
|
||||
| `processors[].current` | integer | Current frame count |
|
||||
| `processors[].total` | integer | Total frame count |
|
||||
| `cpu_percent` | float | Current CPU usage |
|
||||
| `gpu_percent` | float | Current GPU utilization |
|
||||
| `memory_percent` | float | Current memory usage |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/jobs`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
List all processing jobs (monitor jobs) in the system. Shows job status, which file each job is processing, and current processor info.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/jobs" -H "X-API-Key: $KEY" | jq '{count, jobs: [.jobs[] | {uuid, status}]}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"id": 42,
|
||||
"uuid": "3a6c1865...",
|
||||
"status": "running",
|
||||
"current_processor": "yolo",
|
||||
"created_at": "2026-05-16T12:00:00Z",
|
||||
"started_at": "2026-05-16T12:01:00Z"
|
||||
}
|
||||
],
|
||||
"count": 15,
|
||||
"page": 1,
|
||||
"page_size": 20
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `jobs` | array | Array of job info objects |
|
||||
| `jobs[].id` | integer | Job ID |
|
||||
| `jobs[].uuid` | string | File UUID being processed |
|
||||
| `jobs[].status` | string | `"pending"`, `"running"`, `"completed"`, `"failed"` |
|
||||
| `jobs[].current_processor` | string | Currently active processor, or null |
|
||||
| `count` | integer | Total job count |
|
||||
| `page` | integer | Current page number |
|
||||
| `page_size` | integer | Jobs per page |
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 12:49:24*
|
||||
@@ -0,0 +1,219 @@
|
||||
---
|
||||
title: tmdb API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: tmdb -->
|
||||
<!-- description: TMDb enrichment endpoints — prefetch, probe, resource, check -->
|
||||
<!-- depends: 01_auth, 03_register -->
|
||||
|
||||
## TMDb Enrichment
|
||||
|
||||
> **Offline operation**: TMDb prefetch now checks local identity files first (`identities/_index.json` + `*.tmdb.json`).
|
||||
> If local files exist, no external API call is made. Internet is only needed for initial data seeding.
|
||||
|
||||
### Overview
|
||||
|
||||
TMDb enrichment is an optional identity enrichment step that can be run after Pipeline face detection completes. The workflow is:
|
||||
|
||||
1. **Prefetch** (requires internet): Download movie cast data from TMDb API → cache to `{file_uuid}.tmdb.json`
|
||||
2. **Probe**: Read local cache → create identities for **all** cast members (`source='tmdb'`) + save `identity.json` + download profile image to `{OUTPUT}/identities/{uuid}/profile.jpg`
|
||||
3. **Match**: The worker automatically matches video faces against TMDb identities when `MOMENTRY_TMDB_PROBE_ENABLED=true`
|
||||
|
||||
### `POST /api/v1/agents/tmdb/prefetch`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Fetch TMDb cast data for a registered file and cache it locally. This is the only step requiring internet access.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID to enrich |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/agents/tmdb/prefetch" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"file_uuid": "'"$FILE_UUID"'"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{"success": true, "file_uuid": "...", "cache_path": "/output/...tmdb.json"}
|
||||
```
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/tmdb-probe`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Read local TMDb cache and create/update identities. Requires prefetch to have been run first.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tmdb-probe" \
|
||||
-H "X-API-Key: $KEY" | jq '{identities_created, movie_title}'
|
||||
```
|
||||
|
||||
#### Response (200 — identities created)
|
||||
|
||||
```json
|
||||
{"success": true, "identities_created": 15, "movie_title": "Charade"}
|
||||
```
|
||||
|
||||
#### Response (200 — no cache)
|
||||
|
||||
```json
|
||||
{"success": false, "message": "No TMDb cache found. Run tmdb-prefetch first."}
|
||||
```
|
||||
|
||||
### `GET /api/v1/resource/tmdb`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
View TMDb resource status including configuration, identity counts, and cache file count.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/resource/tmdb" -H "X-API-Key: $KEY" \
|
||||
| jq '{identities_seeded, cache_files}'
|
||||
```
|
||||
|
||||
### `POST /api/v1/resource/tmdb/check`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Ping the TMDb API to verify connectivity and measure latency.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/resource/tmdb/check" \
|
||||
-H "X-API-Key: $KEY" | jq '.status'
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"api_key_configured": true,
|
||||
"enabled": false,
|
||||
"api_reachable": true,
|
||||
"api_latency_ms": 120
|
||||
}
|
||||
```
|
||||
|
||||
### `POST /api/v1/tmdb/fetch`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Fetch TMDb data by filename, create identities with profile images and embeddings. Similar to prefetch+probe combined, but also downloads profile images and generates embeddings.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `filename` | string | Yes | Movie filename to search TMDb for |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/tmdb/fetch" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"filename": "charade.mp4"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"movie_title": "Charade (1963)",
|
||||
"tmdb_id": 1234,
|
||||
"identities_created": 15,
|
||||
"profile_images_downloaded": 12
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/agents/tmdb/match/:file_uuid`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Match TMDb identities to face traces using Qdrant vector similarity. Compares face embeddings against TMDb identity embeddings to find the best matches.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/agents/tmdb/match/$FILE_UUID" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"matches": [
|
||||
{
|
||||
"trace_id": 0,
|
||||
"identity_uuid": "a9a90105-6d6b-46ff-92da-0c3c1a57dff4",
|
||||
"identity_name": "Audrey Hepburn",
|
||||
"confidence": 0.92,
|
||||
"tmdb_id": 1234
|
||||
}
|
||||
],
|
||||
"total_matches": 5
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `matches[].trace_id` | integer | Face trace ID |
|
||||
| `matches[].identity_uuid` | string | Matched TMDb identity UUID |
|
||||
| `matches[].identity_name` | string | Identity display name |
|
||||
| `matches[].confidence` | float | Cosine similarity score (0.0–1.0) |
|
||||
| `matches[].tmdb_id` | integer | TMDb person ID |
|
||||
| `total_matches` | integer | Total successful matches |
|
||||
|
||||
---
|
||||
|
||||
### TMDb Auto-Match
|
||||
|
||||
When `MOMENTRY_TMDB_PROBE_ENABLED=true`, the worker automatically runs TMDb matching during the post-process phase:
|
||||
|
||||
1. **Register phase**: Searches TMDb by filename, creates identities with `tmdb_id`/`tmdb_profile`
|
||||
2. **Post-process phase**: Matches detected faces against TMDb identities via cosine similarity using Qdrant
|
||||
|
||||
No manual API call needed if auto-match is enabled.
|
||||
|
||||
---
|
||||
*Updated: 2026-06-20 — Added tmdb/fetch and tmdb/match endpoints*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,229 @@
|
||||
---
|
||||
title: agent API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
# Agent Endpoints
|
||||
|
||||
Agent endpoints provide AI-powered capabilities including translation, identity analysis, and 5W1H extraction.
|
||||
|
||||
## POST /api/v1/agents/translate
|
||||
|
||||
Translate text between languages using Gemma4 (llama.cpp, port 8082).
|
||||
|
||||
### Request
|
||||
|
||||
```json
|
||||
{
|
||||
"text": "Hello, welcome to Momentry Core.",
|
||||
"target_language": "Traditional Chinese",
|
||||
"source_language": "English"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `text` | string | ✅ | Text to translate |
|
||||
| `target_language` | string | ✅ | Target language name (e.g. "Traditional Chinese", "Japanese") |
|
||||
| `source_language` | string | ❌ | Source language (default: "auto") |
|
||||
|
||||
### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"translated_text": "您好,歡迎使用 Momentry Core。",
|
||||
"source_language_detected": "English",
|
||||
"model_used": "google_gemma-4-26B-A4B-it-Q5_K_M.gguf"
|
||||
}
|
||||
```
|
||||
|
||||
### Supported Language Pairs (tested)
|
||||
|
||||
| Source | Target | Quality |
|
||||
|--------|--------|---------|
|
||||
| English | Traditional Chinese | ✅ |
|
||||
| English | Japanese | ✅ |
|
||||
| Chinese | English | ✅ |
|
||||
| English | French | ✅ |
|
||||
| Chinese | Japanese | ✅ |
|
||||
|
||||
### Model
|
||||
|
||||
- **Model**: Gemma4 26B (Q5_K_M)
|
||||
- **Engine**: llama.cpp at `localhost:8082`
|
||||
- **Endpoint**: `/v1/chat/completions` (OpenAI-compatible)
|
||||
- **Temperature**: 0.1
|
||||
- **Max tokens**: 1024
|
||||
|
||||
### Errors
|
||||
|
||||
| Status | Condition |
|
||||
|--------|-----------|
|
||||
| 500 | LLM unreachable or response parse failure |
|
||||
| 401 | Missing/invalid auth |
|
||||
|
||||
---
|
||||
|
||||
## POST /api/v1/agents/5w1h/analyze
|
||||
|
||||
Extract 5W1H (Who, What, When, Where, Why, How) from a scene. Uses Gemma4 LLM on port 8082.
|
||||
|
||||
### Request
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3abeee81d94597629ed8cb943f182e94",
|
||||
"scene_id": 42
|
||||
}
|
||||
```
|
||||
|
||||
### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"5w1h": {
|
||||
"who": ["Cary Grant"],
|
||||
"what": ["discussing plans"],
|
||||
"when": ["1963"],
|
||||
"where": ["Paris"],
|
||||
"why": ["vacation"],
|
||||
"how": ["in person"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## POST /api/v1/agents/5w1h/batch
|
||||
|
||||
Batch analyze all scenes in a file for 5W1H extraction. Uses the pipeline's `parent_chunk_5w1h.py --mode llm`.
|
||||
|
||||
### Request
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "3abeee81d94597629ed8cb943f182e94"
|
||||
}
|
||||
```
|
||||
|
||||
## GET /api/v1/agents/5w1h/status
|
||||
|
||||
Get status of the 5W1H agent pipeline for a file.
|
||||
|
||||
---
|
||||
|
||||
## Embedding Model
|
||||
|
||||
| Detail | Value |
|
||||
|--------|-------|
|
||||
| **Model** | EmbeddingGemma-300m |
|
||||
| **Endpoint** | `POST /v1/embeddings` on port 11436 |
|
||||
| **Dimension** | 768 |
|
||||
| **Used by** | `parent_chunk_5w1h.py --embed`, story, 5W1H, search |
|
||||
|
||||
---
|
||||
|
||||
## POST /api/v1/agents/search
|
||||
|
||||
Conversational search assistant. Uses Gemma4 function calling to automatically decide which tools to call based on the user's natural language query. Supports multi-turn conversation.
|
||||
|
||||
### Request
|
||||
|
||||
```json
|
||||
{
|
||||
"query": "Audrey Hepburn 和 Cary Grant 第一次同框在哪個 frame?",
|
||||
"conversation_id": null,
|
||||
"file_uuid": null
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `query` | string | ✅ | 自然語言查詢 |
|
||||
| `conversation_id` | string | ❌ | 延續對話時傳入;新對話不傳 |
|
||||
| `file_uuid` | string | ❌ | Portal 有選中檔案時可指定 |
|
||||
|
||||
### Response
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"conversation_id": "conv_abc123",
|
||||
"answer": "在 Charade (1963) 中,Audrey Hepburn 與 Cary Grant 第一次同框在第 38619 幀(約 1544.76 秒)。",
|
||||
"need_input": false,
|
||||
"sources": [
|
||||
{
|
||||
"tool": "tkg_query",
|
||||
"result": "{\"first_cooccurrence\":{\"frame\":38619,\"timestamp_secs\":1544.76}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `conversation_id` | string | 後續對話需要傳入此 ID |
|
||||
| `answer` | string | Agent 的自然語言回答(或反問) |
|
||||
| `need_input` | boolean | `true` 表示 agent 需要更多資訊才能回答 |
|
||||
| `suggestions` | string[] | 建議用戶提供的線索(當 `need_input=true`) |
|
||||
| `sources` | array | 引用的工具執行結果 |
|
||||
|
||||
### Conversation Flow
|
||||
|
||||
```
|
||||
Round 1: POST /agents/search { query: "我想看男女主角同框" }
|
||||
→ need_input: true, suggestions: ["片名", "演員", "年代"]
|
||||
→ answer: "請問是哪部電影?請提供更多線索"
|
||||
|
||||
Round 2: POST /agents/search { query: "奧黛麗赫本", conversation_id: "..." }
|
||||
→ need_input: false
|
||||
→ answer: "找到 Charade (1963),Audrey Hepburn 和 Cary Grant..."
|
||||
```
|
||||
|
||||
### Available Tools
|
||||
|
||||
Agent 內部使用 Gemma4 function calling 自動調用以下工具:
|
||||
|
||||
| Tool | Description |
|
||||
|------|-------------|
|
||||
| `find_file` | 透過片名/演員/年份關鍵字搜尋影片,回傳 file_uuid + has_data 狀態 |
|
||||
| `list_files` | 列出近期註冊的影片 |
|
||||
| `tkg_query` | 查詢人物互動資料(7 種子類型:top_identities、first_cooccurrence、identity_details、mutual_gaze、interaction_network、identity_traces、file_info) |
|
||||
| `smart_search` | 文字內容 ILIKE 搜尋 chunk(可指定 file_uuid 限制範圍) |
|
||||
| `get_identity_detail` | 查詢單一身份的詳細資料(角色、TMDb 資訊) |
|
||||
| `get_file_info` | 查詢影片基本資訊(片長、解析度) |
|
||||
| `get_representative_frame` | 查詢影片最具代表性的 frame 資訊 |
|
||||
|
||||
### Design Principles
|
||||
|
||||
- **用戶不需要知道 file_uuid** — Agent 會自動用 `find_file` 搜尋或反問
|
||||
- **不推薦無資料的影片** — `has_data=false` 的影片不會被推薦給用戶
|
||||
- **多輪對話** — 透過 `conversation_id` 延續上下文,agent 會記得之前的交流
|
||||
- **並行工具呼叫** — Gemma4 可以一次呼叫多個工具再綜合回答
|
||||
|
||||
### Model
|
||||
|
||||
| Detail | Value |
|
||||
|--------|-------|
|
||||
| **LLM** | Gemma4 26B (Q5_K_M) |
|
||||
| **Engine** | llama.cpp at `localhost:8082` |
|
||||
| **Endpoint** | `/v1/chat/completions` (OpenAI-compatible) |
|
||||
| **Temperature** | 0.1 |
|
||||
| **Max rounds** | 5 (tool call iterations) |
|
||||
| **Conversation TTL** | 30 minutes |
|
||||
|
||||
---
|
||||
*Updated: 2026-05-22*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,552 @@
|
||||
---
|
||||
title: tkg API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: tkg -->
|
||||
<!-- description: Temporal Knowledge Graph — rebuild, nodes, edges, processor counts -->
|
||||
<!-- depends: 05_process, 07_identity -->
|
||||
|
||||
## Temporal Knowledge Graph (TKG)
|
||||
|
||||
TKG is a time-aligned knowledge graph built from multi-processor outputs (face, yolo, ocr, pose, asrx, gaze, lip, appearance). It produces 9 node types and 14 edge types stored in `dev.tkg_nodes` and `dev.tkg_edges`.
|
||||
|
||||
**Node naming convention:** All trace types use `_track` suffix. Text uses `_region` (non-temporal).
|
||||
|
||||
**See also:** `docs_v1.0/DESIGN/TKG_FORMATION_V1.0.md` for formation phases, flow diagrams, and query examples.
|
||||
|
||||
### Node Types
|
||||
|
||||
| Node Type | External ID Format | Description | Key Properties |
|
||||
|-----------|-------------------|-------------|----------------|
|
||||
| `face_track` | `trace_{trace_id}` | A tracked face identity over time | `trace_id`, `frame_count`, `status`, `avg_bbox`, `avg_yaw`, `avg_pitch`, `avg_roll`, `start_frame`, `end_frame`, `pose_count` |
|
||||
| `gaze_track` | `gaze_track_{id}` | Gaze direction over time | `direction` (frontal/left/right/up/down + diagonals) |
|
||||
| `lip_track` | `lip_track_{id}` | Lip movement synced with speech | `speaker_id`, `lip_area_range` |
|
||||
| `text_region` | `text_region_{id}` | Spoken text aligned to time | `speaker_id`, `text`, `start_time`, `end_time` |
|
||||
| `appearance_trace` | `appearance_{trace_id}` | Human appearance (clothing) over time | `clothing_color`, `upper_cloth`, `lower_cloth` |
|
||||
| `accessory` | `accessory_{id}` | Detected accessories | `type` (glasses/hat/etc.), `confidence` |
|
||||
| `object` | `object_{class}_{id}` | YOLO-detected object | `class`, `confidence`, `frame_count` |
|
||||
| `speaker` | `speaker_{speaker_id}` | ASRX speaker segment | `speaker_id`, `segment_count`, `total_duration` |
|
||||
|
||||
---
|
||||
|
||||
### Identity Agent Integration (face_track nodes)
|
||||
|
||||
Identity Agent marks face_track nodes with identity binding status.
|
||||
|
||||
#### face_track Status Values
|
||||
|
||||
| Status | Description | Properties |
|
||||
|--------|-------------|------------|
|
||||
| `pending` | No identity suggestion | Default state |
|
||||
| `suggested` | Identity Agent suggested | `pending_identity_name`, `pending_identity_uuid`, `suggested_by`, `confidence` |
|
||||
| `confirmed` | User confirmed binding | `identity_uuid`, `identity_id`, `identity_ref`, `identity_name` |
|
||||
| `stranger` | Stranger cluster member | `stranger_id`, `stranger_ref` |
|
||||
|
||||
#### Suggested By Values
|
||||
|
||||
| Value | Description |
|
||||
|-------|-------------|
|
||||
| `tmdb` | TMDb seed matched |
|
||||
| `propagation` | Confirmed trace propagation |
|
||||
| `manual` | User manual selection |
|
||||
|
||||
#### Example face_track Node
|
||||
|
||||
```json
|
||||
{
|
||||
"node_type": "face_track",
|
||||
"external_id": "face_track_1",
|
||||
"label": "Face Track 1",
|
||||
"properties": {
|
||||
"trace_id": 1,
|
||||
"frame_count": 45,
|
||||
"start_frame": 100,
|
||||
"end_frame": 300,
|
||||
"avg_bbox": {"x": 100, "y": 200, "width": 80, "height": 100},
|
||||
"status": "suggested",
|
||||
"pending_identity_name": "Tom Hanks",
|
||||
"pending_identity_uuid": "xxx-xxx",
|
||||
"suggested_by": "tmdb",
|
||||
"confidence": 0.91
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Edge Types
|
||||
|
||||
| Edge Type | Storage Name | Source → Target | Description |
|
||||
|-----------|--------------|-----------------|-------------|
|
||||
| `co_occurs` | `CO_OCCURS_WITH` | object ↔ object | Two objects appear together in same frame |
|
||||
| `speaker_face` | `SPEAKS_AS` | speaker → face_track | Speaker matched to face track via lip sync |
|
||||
| `face_face` | `INTERACTS_WITH` | face_track ↔ face_track | Two face tracks interact (mutual gaze) |
|
||||
| `mutual_gaze` | `MUTUAL_GAZE` | gaze_track ↔ gaze_track | Two people looking at each other |
|
||||
| `lip_sync` | `LIP_SYNC` | lip_track → text_region | Lip movement aligned with spoken text |
|
||||
| `has_appearance` | `HAS_APPEARANCE` | face_track → appearance_trace | Face has specific appearance |
|
||||
| `wears` | `WEARS` | face_track → accessory | Face wears an accessory |
|
||||
| `hand_object` | `HOLDS` | hand → object | Hand holding object |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/tkg/rebuild`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Rebuild the Temporal Knowledge Graph for a file. Reads processor JSON outputs (face, yolo, ocr, pose, asrx, gaze, lip, appearance) and generates TKG nodes and edges. Clears existing nodes/edges for the file first, then rebuilds from scratch.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/rebuild" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"result": {
|
||||
"face_track_nodes": 16,
|
||||
"gaze_track_nodes": 16,
|
||||
"lip_track_nodes": 12,
|
||||
"text_region_nodes": 24,
|
||||
"appearance_trace_nodes": 8,
|
||||
"skin_tone_trace_nodes": 5,
|
||||
"accessory_nodes": 3,
|
||||
"object_nodes": 26,
|
||||
"speaker_nodes": 4,
|
||||
"co_occurrence_edges": 94,
|
||||
"speaker_face_edges": 12,
|
||||
"face_face_edges": 8,
|
||||
"mutual_gaze_edges": 2,
|
||||
"lip_sync_edges": 10,
|
||||
"has_appearance_edges": 16,
|
||||
"wears_edges": 3
|
||||
},
|
||||
"error": null
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | True if rebuild completed |
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `result` | object | Node and edge counts by type |
|
||||
| `error` | string/null | Error message if failed |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/tkg/nodes`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Query TKG nodes with pagination and optional type filter.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `node_type` | string | No | all | Filter by node type: `face_track`, `gaze_track`, `lip_track`, `text_region`, `appearance_trace`, `skin_tone_trace`, `accessory`, `object`, `speaker` |
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 100 | Items per page (max 500) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get all face_track nodes
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/nodes" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"node_type": "face_track", "page": 1, "page_size": 50}'
|
||||
|
||||
# Get all nodes
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/nodes" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"total": 16,
|
||||
"page": 1,
|
||||
"page_size": 50,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 1,
|
||||
"node_type": "face_track",
|
||||
"external_id": "face_track_0",
|
||||
"label": "Face Track 0",
|
||||
"properties": {
|
||||
"trace_id": 0,
|
||||
"frame_count": 142,
|
||||
"avg_confidence": 0.87,
|
||||
"best_confidence": 0.92,
|
||||
"avg_capture_quality": 0.61,
|
||||
"best_capture_quality": 0.78,
|
||||
"key_frame": 120,
|
||||
"key_face": "tkg:face/0:point_xyz",
|
||||
"avg_bbox": {"x": 200, "y": 150, "width": 60, "height": 60},
|
||||
"best_bbox": {"x": 210, "y": 155, "width": 62, "height": 60}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `total` | integer | Total matching node count |
|
||||
| `page` | integer | Current page |
|
||||
| `page_size` | integer | Items per page |
|
||||
| `nodes` | array | Array of node objects |
|
||||
| `nodes[].id` | integer | Database primary key |
|
||||
| `nodes[].node_type` | string | Node type (see table above) |
|
||||
| `nodes[].external_id` | string | External identifier (e.g., `trace_0`, `gaze_1`) |
|
||||
| `nodes[].label` | string | Human-readable label |
|
||||
| `nodes[].properties` | object | Type-specific properties as JSON |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/tkg/edges`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Query TKG edges with pagination and optional filters.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `edge_type` | string | No | all | Filter by edge type: `co_occurs`, `speaker_face`, `face_face`, `mutual_gaze`, `lip_sync`, `has_appearance`, `wears` |
|
||||
| `source_type` | string | No | — | Filter by source node type |
|
||||
| `target_type` | string | No | — | Filter by target node type |
|
||||
| `page` | integer | No | 1 | Page number |
|
||||
| `page_size` | integer | No | 100 | Items per page (max 500) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get all co_occurs edges
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/edges" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"edge_type": "co_occurs"}'
|
||||
|
||||
# Get edges between face_track and speaker nodes
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/edges" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"source_type": "speaker", "target_type": "face_track"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"total": 94,
|
||||
"page": 1,
|
||||
"page_size": 100,
|
||||
"edges": [
|
||||
{
|
||||
"id": 1,
|
||||
"edge_type": "co_occurs",
|
||||
"source_node_id": 10,
|
||||
"target_node_id": 15,
|
||||
"properties": {
|
||||
"frame_count": 45,
|
||||
"confidence": 0.92
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `total` | integer | Total matching edge count |
|
||||
| `page` | integer | Current page |
|
||||
| `page_size` | integer | Items per page |
|
||||
| `edges` | array | Array of edge objects |
|
||||
| `edges[].id` | integer | Database primary key |
|
||||
| `edges[].edge_type` | string | Edge type |
|
||||
| `edges[].source_node_id` | integer | Source node ID (FK to tkg_nodes) |
|
||||
| `edges[].target_node_id` | integer | Target node ID (FK to tkg_nodes) |
|
||||
| `edges[].properties` | object | Edge-specific properties as JSON |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/tkg/node/:node_id`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get detail for a specific TKG node including its connected edges.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/tkg/node/1" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"node": {
|
||||
"id": 1,
|
||||
"node_type": "face_track",
|
||||
"external_id": "face_track_0",
|
||||
"label": "Face Track 0",
|
||||
"properties": {
|
||||
"trace_id": 0,
|
||||
"frame_count": 142,
|
||||
"avg_confidence": 0.87
|
||||
}
|
||||
},
|
||||
"connected_edges": [
|
||||
{
|
||||
"id": 5,
|
||||
"edge_type": "co_occurs",
|
||||
"source_node_id": 1,
|
||||
"target_node_id": 10,
|
||||
"properties": {"frame_count": 45}
|
||||
}
|
||||
],
|
||||
"edge_count": 3
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 200 |
|
||||
| `node` | object | Node detail (same format as nodes query) |
|
||||
| `connected_edges` | array | Edges connected to this node |
|
||||
| `edge_count` | integer | Total connected edge count |
|
||||
|
||||
#### Error Codes
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | Node not found |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/processor-counts`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Get counts of processor JSON output files for a file. Scans the output directory for `{file_uuid}.{processor}.json` files and extracts frame counts, segment counts, and chunk counts from each file.
|
||||
|
||||
Supports short UUID prefix matching (e.g., `d3f9ae8e` → resolves to full `d3f9ae8e471a1fc4d47022c66091b920`).
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/processor-counts" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"output_dir": "/Users/accusys/momentry/output_dev",
|
||||
"processors": [
|
||||
{
|
||||
"processor": "cut",
|
||||
"has_json": true,
|
||||
"frame_count": 5391,
|
||||
"segment_count": null,
|
||||
"chunk_count": null,
|
||||
"last_modified": "2026-06-16T18:48:01.987241061+00:00"
|
||||
},
|
||||
{
|
||||
"processor": "face",
|
||||
"has_json": true,
|
||||
"frame_count": 1112,
|
||||
"segment_count": null,
|
||||
"chunk_count": null,
|
||||
"last_modified": "2026-06-18T17:21:37.408383765+00:00"
|
||||
},
|
||||
{
|
||||
"processor": "asrx",
|
||||
"has_json": true,
|
||||
"frame_count": null,
|
||||
"segment_count": 6,
|
||||
"chunk_count": null,
|
||||
"last_modified": "2026-06-18T17:21:40.872063642+00:00"
|
||||
},
|
||||
{
|
||||
"processor": "story",
|
||||
"has_json": true,
|
||||
"frame_count": null,
|
||||
"segment_count": null,
|
||||
"chunk_count": 12,
|
||||
"last_modified": "2026-06-18T17:22:00.000000000+00:00"
|
||||
},
|
||||
{
|
||||
"processor": "mediapipe",
|
||||
"has_json": false,
|
||||
"frame_count": null,
|
||||
"segment_count": null,
|
||||
"chunk_count": null,
|
||||
"last_modified": null
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | Full 32-char hex UUID (resolved from prefix) |
|
||||
| `output_dir` | string | Output directory scanned |
|
||||
| `processors` | array | Per-processor output info |
|
||||
| `processors[].processor` | string | Processor name |
|
||||
| `processors[].has_json` | boolean | Whether JSON file exists |
|
||||
| `processors[].frame_count` | integer/null | Total frames processed (frame-based processors) |
|
||||
| `processors[].segment_count` | integer/null | Segment count (ASRX segments, etc.) |
|
||||
| `processors[].chunk_count` | integer/null | Chunk count (Story chunks, etc.) |
|
||||
| `processors[].last_modified` | string/null | ISO 8601 timestamp of last modification |
|
||||
|
||||
#### Error Codes
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | File UUID not found in database |
|
||||
|
||||
---
|
||||
|
||||
### Trace Management
|
||||
|
||||
Endpoints for managing face traces: list, delete, restore, and merge.
|
||||
|
||||
#### `DELETE /api/v1/file/:file_uuid/trace/:trace_id`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
Soft-delete a face trace (default) or hard-delete with `{"hard_delete": true}`.
|
||||
|
||||
Soft delete marks Qdrant points with `status: "deleted"` and TKG nodes with `status: "deleted"` in properties. Deleted traces are excluded from the traces list.
|
||||
|
||||
Hard delete permanently removes Qdrant points and TKG nodes.
|
||||
|
||||
**Request Body** (optional):
|
||||
|
||||
| Field | Type | Default | Description |
|
||||
|-------|------|---------|-------------|
|
||||
| `hard_delete` | boolean | `false` | Permanently delete instead of marking |
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
# Soft delete
|
||||
curl -X DELETE "$API/api/v1/file/$FILE_UUID/trace/8" \
|
||||
-H "X-API-Key: $KEY" -H "Content-Type: application/json" -d '{}'
|
||||
|
||||
# Hard delete
|
||||
curl -X DELETE "$API/api/v1/file/$FILE_UUID/trace/8" \
|
||||
-H "X-API-Key: $KEY" -H "Content-Type: application/json" \
|
||||
-d '{"hard_delete": true}'
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"trace_id": 8,
|
||||
"hard_delete": false,
|
||||
"qdrant_marked": true,
|
||||
"tkg_nodes_marked": 1
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/file/:file_uuid/trace/:trace_id/restore`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
Undo a soft-deleted trace. Clears `status: "deleted"` from Qdrant points and TKG node properties.
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/trace/8/restore" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"trace_id": 8,
|
||||
"qdrant_restored": true,
|
||||
"tkg_nodes_restored": 1
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
#### `POST /api/v1/file/:file_uuid/trace/:source_trace_id/merge/:target_trace_id`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
Merge all face points from source trace into target trace. Updates Qdrant `trace_id` and deletes source TKG node.
|
||||
|
||||
**Example**:
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/trace/16/merge/3" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"file_uuid": "9f6a9cd55a5809f977f5a6589b9045c5",
|
||||
"source_trace_id": 16,
|
||||
"target_trace_id": 3,
|
||||
"points_moved": 58,
|
||||
"tkg_nodes_deleted": 1
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
*Updated: 2026-07-21 01:00:00*
|
||||
*Updated: 2026-08-12 — face_track node properties now include capture_quality fields (avg/best) and key_frame/key_face are selected by best capture quality*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,375 @@
|
||||
---
|
||||
title: Trace Agent API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: trace_agent -->
|
||||
<!-- description: Face trace and TKG (Temporal Knowledge Graph) operations -->
|
||||
<!-- depends: identity, profile -->
|
||||
|
||||
# Trace Agent API
|
||||
|
||||
Manage face traces, temporal knowledge graphs, and trace-related operations.
|
||||
|
||||
## Overview
|
||||
|
||||
Trace Agent API provides endpoints for:
|
||||
- **Trace Management**: List, query, and analyze face traces
|
||||
- **Face Retrieval**: Get faces from traces, representative faces
|
||||
- **Thumbnails**: Generate and retrieve trace thumbnails
|
||||
- **TKG Operations**: Build, query, and manage Temporal Knowledge Graphs
|
||||
- **Co-occurrence**: Analyze identity co-occurrence in videos
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/traces`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
List all traces for a file, sorted by various criteria.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `file_uuid` | string | Yes | — | File UUID (path parameter) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# List traces for a file
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/traces" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"traces": [
|
||||
{
|
||||
"trace_id": 1,
|
||||
"face_count": 50,
|
||||
"first_frame": 100,
|
||||
"last_frame": 1500,
|
||||
"identity_uuid": "a9a90105-..."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/trace/:trace_id/faces`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get all faces for a specific trace.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `trace_id` | number | Yes | Trace ID |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get faces for trace 1
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/trace/1/faces" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/trace/:trace_id/representative-face`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get the representative (best quality) face for a trace.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get representative face
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/trace/1/representative-face" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/trace/:trace_id/thumbnail`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get thumbnail for a trace.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get trace thumbnail
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/trace/1/thumbnail" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/stranger/:stranger_id/representative-face`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get representative face for a stranger (unidentified person).
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get stranger representative face
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/stranger/1/representative-face" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/stranger/:stranger_id/thumbnail`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get thumbnail for a stranger.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get stranger thumbnail
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/stranger/1/thumbnail" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/identities/:identity_uuid_a/co-occur-with/:identity_uuid_b`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get co-occurrence information between two identities in a file.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `file_uuid` | string | Yes | File UUID |
|
||||
| `identity_uuid_a` | string | Yes | First identity UUID |
|
||||
| `identity_uuid_b` | string | Yes | Second identity UUID |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Check co-occurrence
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/identities/$IDENTITY_UUID_A/co-occur-with/$IDENTITY_UUID_B" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/tkg/rebuild`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Rebuild Temporal Knowledge Graph for a file.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Rebuild TKG
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/rebuild" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/tkg`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get TKG operations for a file.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get TKG operations
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/tkg" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `DELETE /api/v1/file/:file_uuid/tkg`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Delete TKG for a file.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Delete TKG
|
||||
curl -s -X DELETE "$API/api/v1/file/$FILE_UUID/tkg" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/rule2`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Ingest Rule 2 for TKG.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Ingest Rule 2
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/rule2" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/representative-frame`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Get representative frame for a file.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get representative frame
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/representative-frame" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/tkg/nodes`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Query TKG nodes.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Query TKG nodes
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/nodes" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/tkg/edges`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: file-level
|
||||
|
||||
Query TKG edges.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Query TKG edges
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/tkg/edges" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/trace_agent_api.rs` (2918 lines)
|
||||
|
||||
**Data Structures**:
|
||||
- `Trace` - Face trace object
|
||||
- `Face` - Single face detection
|
||||
- `TKG` - Temporal Knowledge Graph
|
||||
- `Stranger` - Unidentified person
|
||||
|
||||
**Database Tables**:
|
||||
- `face_detections` - Face detection records
|
||||
- `traces` - Trace metadata
|
||||
- `tkg_nodes` - TKG nodes
|
||||
- `tkg_edges` - TKG edges
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [Identity API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/07_identity.md)
|
||||
- [Profile API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/18_profile.md)
|
||||
- [TKG API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/15_tkg.md)
|
||||
|
||||
---
|
||||
|
||||
## Common Issues
|
||||
|
||||
### Trace Not Found
|
||||
|
||||
**Symptoms**: 404 error when accessing trace
|
||||
|
||||
**Solution**: Check if trace exists in database or re-process the file
|
||||
|
||||
### TKG Build Failed
|
||||
|
||||
**Symptoms**: TKG rebuild returns error
|
||||
|
||||
**Solution**: Check file processing status and logs
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation (summary) |
|
||||
|
||||
**Note**: This is a summary documentation. Full endpoint details require additional work.
|
||||
@@ -0,0 +1,245 @@
|
||||
---
|
||||
title: Cluster Agent API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-25
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: cluster_agent -->
|
||||
<!-- description: Asynchronous face clustering agent -->
|
||||
<!-- depends: 01_auth, 03_register, 07_identity -->
|
||||
|
||||
## Cluster Agent
|
||||
|
||||
Asynchronous face clustering agent that automatically groups similar faces into identities. Runs as a background job.
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/cluster-agent`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Trigger asynchronous face clustering for a file. Returns immediately with a job ID. Clustering runs in the background.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `file_uuid` | string | File UUID (32-char hex) |
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `confirm` | boolean | Yes | false | Must be `true` to trigger clustering |
|
||||
| `min_confidence` | float | No | 0.6 | Minimum face confidence to include |
|
||||
| `algorithm` | string | No | "dbscan" | Clustering algorithm ("dbscan", "kmeans") |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/cluster-agent" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"confirm": true, "min_confidence": 0.6}'
|
||||
```
|
||||
|
||||
#### Response (202 Accepted)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"job_id": "cluster_abc123",
|
||||
"file_uuid": "3a6c1865...",
|
||||
"status": "queued",
|
||||
"message": "Cluster job queued for processing"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `success` | boolean | Always true on 202 |
|
||||
| `job_id` | string | Job ID for status tracking |
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `status` | string | Job status ("queued", "running", "completed", "failed") |
|
||||
| `message` | string | Human-readable status |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `400` | `confirm` not set to `true` |
|
||||
| `404` | File not found |
|
||||
| `409` | Job already running for this file |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/cluster-job/:job_id`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: job-level
|
||||
|
||||
Get status of a cluster job. Returns progress, statistics, and results if completed.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `job_id` | string | Job ID returned from trigger endpoint |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/cluster-job/cluster_abc123" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"job_id": "cluster_abc123",
|
||||
"file_uuid": "3a6c1865...",
|
||||
"status": "completed",
|
||||
"progress": {
|
||||
"total_faces": 1523,
|
||||
"processed": 1523,
|
||||
"percentage": 100
|
||||
},
|
||||
"result": {
|
||||
"clusters_found": 12,
|
||||
"identities_created": 8,
|
||||
"identities_updated": 4
|
||||
},
|
||||
"started_at": "2026-10-25T10:00:00Z",
|
||||
"completed_at": "2026-10-25T10:05:30Z"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `job_id` | string | Job ID |
|
||||
| `file_uuid` | string | File UUID |
|
||||
| `status` | string | "running", "completed", "failed", "cancelled" |
|
||||
| `progress` | object | Progress information |
|
||||
| `result` | object | Final results (if completed) |
|
||||
| `error` | string | Error message (if failed) |
|
||||
| `started_at` | string | ISO 8601 timestamp |
|
||||
| `completed_at` | string | ISO 8601 timestamp (if completed) |
|
||||
|
||||
---
|
||||
|
||||
### `DELETE /api/v1/cluster-job/:job_id`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: job-level
|
||||
|
||||
Cancel a running cluster job. Cannot cancel completed or failed jobs.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `job_id` | string | Job ID |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X DELETE "$API/api/v1/cluster-job/cluster_abc123" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"job_id": "cluster_abc123",
|
||||
"status": "cancelled",
|
||||
"message": "Job cancelled successfully"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Clustering Process
|
||||
|
||||
### How It Works
|
||||
|
||||
1. **Face Collection**: Gather all face detections from the file
|
||||
2. **Embedding Extraction**: Get face embeddings (512-dim vectors)
|
||||
3. **Similarity Clustering**: Group similar faces using DBSCAN
|
||||
4. **Identity Assignment**: Create or update identities for clusters
|
||||
5. **Face Binding**: Bind faces to their cluster identity
|
||||
|
||||
### Clustering Algorithm
|
||||
|
||||
**DBSCAN Parameters**:
|
||||
- `eps`: 0.3 (distance threshold)
|
||||
- `min_samples`: 5 (minimum cluster size)
|
||||
|
||||
**Quality Metrics**:
|
||||
- Intra-cluster similarity: Average pairwise similarity within cluster
|
||||
- Inter-cluster separation: Average distance to nearest cluster
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
### 1. Automatic Identity Creation
|
||||
|
||||
```bash
|
||||
# After processing, trigger clustering
|
||||
curl -X POST "$API/api/v1/file/$FILE_UUID/cluster-agent" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"confirm": true}'
|
||||
```
|
||||
|
||||
### 2. Monitor Clustering Progress
|
||||
|
||||
```bash
|
||||
# Poll job status
|
||||
curl -s "$API/api/v1/cluster-job/$JOB_ID" -H "X-API-Key: $KEY" | jq '.status'
|
||||
```
|
||||
|
||||
### 3. Cancel Slow Clustering
|
||||
|
||||
```bash
|
||||
# If clustering takes too long
|
||||
curl -X DELETE "$API/api/v1/cluster-job/$JOB_ID" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Performance
|
||||
|
||||
| File Size | Face Count | Processing Time |
|
||||
|-----------|------------|-----------------|
|
||||
| 10 min video | 500 faces | ~30 seconds |
|
||||
| 30 min video | 1500 faces | ~2 minutes |
|
||||
| 90 min video | 4500 faces | ~8 minutes |
|
||||
|
||||
**Notes**:
|
||||
- Processing time scales linearly with face count
|
||||
- Uses in-memory job registry (cleared on server restart)
|
||||
- Concurrent jobs are supported but resource-intensive
|
||||
|
||||
---
|
||||
|
||||
## Error Handling
|
||||
|
||||
| Error | Cause | Solution |
|
||||
|-------|-------|----------|
|
||||
| `400 Bad Request` | `confirm` not set | Add `"confirm": true` to request body |
|
||||
| `404 Not Found` | File not found | Verify file_uuid |
|
||||
| `409 Conflict` | Job already running | Wait for current job to complete or cancel it |
|
||||
| `500 Internal Error` | Clustering failed | Check server logs for details |
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-25 | Initial documentation |
|
||||
@@ -0,0 +1,78 @@
|
||||
---
|
||||
title: error codes API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: error_codes -->
|
||||
<!-- description: Standard API error codes -->
|
||||
<!-- depends: -->
|
||||
|
||||
## Error Response Format
|
||||
|
||||
All API errors follow this JSON structure:
|
||||
|
||||
```json
|
||||
{
|
||||
"success": false,
|
||||
"error": {
|
||||
"code": "E001_NOT_FOUND",
|
||||
"message": "Resource not found",
|
||||
"details": {"resource": "file_uuid", "value": "abc"}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Error Code List
|
||||
|
||||
### Generic Errors (E0xx)
|
||||
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `E001_NOT_FOUND` | 404 | Resource not found (file, identity, chunk) |
|
||||
| `E002_DUPLICATE` | 409 | Resource already exists |
|
||||
| `E003_VALIDATION` | 400 | Request parameter validation failed |
|
||||
| `E004_UNAUTHORIZED` | 401 | Invalid API key or token |
|
||||
| `E005_INTERNAL` | 500 | Internal server error |
|
||||
|
||||
### Processor Errors (E1xx)
|
||||
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `E101_PROCESSOR_FAIL` | 500 | Python script execution failed |
|
||||
| `E102_TIMEOUT` | 504 | Processing timeout |
|
||||
| `E103_RESUME_FAIL` | 500 | Resume failed (checkpoint not found) |
|
||||
| `E104_NO_VIDEO` | 400 | Video file path not found |
|
||||
|
||||
### Identity Errors (E2xx)
|
||||
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `E201_FACE_NOT_FOUND` | 404 | Face detection not found |
|
||||
| `E202_MERGE_CONFLICT` | 409 | Identity merge conflict |
|
||||
| `E203_CANDIDATE_EMPTY` | 404 | No candidates available for confirmation |
|
||||
|
||||
### TMDb Errors (E3xx)
|
||||
|
||||
| Code | HTTP | Description |
|
||||
|------|------|-------------|
|
||||
| `E301_TMDB_NO_KEY` | 400 | `TMDB_API_KEY` environment variable not set |
|
||||
| `E302_TMDB_UNREACHABLE` | 502 | TMDb API unreachable or timed out |
|
||||
| `E303_TMDB_CACHE_NOT_FOUND` | 200 | No local TMDb cache; run prefetch first |
|
||||
| `E304_TMDB_PROBE_FAILED` | 500 | TMDb probe execution failed |
|
||||
| `E305_TMDB_MOVIE_NOT_FOUND` | 404 | No matching TMDb movie found from filename |
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 12:49:24*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,108 @@
|
||||
---
|
||||
title: config API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: config -->
|
||||
<!-- description: System configuration — cache, auto-pipeline, watcher-auto-register toggles -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## System Configuration
|
||||
|
||||
Runtime configuration toggles for system behavior. All endpoints require authentication and system-level scope.
|
||||
|
||||
### `POST /api/v1/config/cache`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Toggle the Redis cache on or off.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `enabled` | boolean | Yes | `true` to enable, `false` to disable |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/config/cache" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"enabled": false}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/config/auto-pipeline`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Toggle automatic processing pipeline trigger on file registration (disabled by default).
|
||||
When enabled, registering a video file automatically creates a monitor job and starts processing.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `enabled` | boolean | Yes | `true` to enable auto-pipeline, `false` to disable |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Enable auto-pipeline
|
||||
curl -s -X POST "$API/api/v1/config/auto-pipeline" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"enabled": true}'
|
||||
|
||||
# Disable auto-pipeline
|
||||
curl -s -X POST "$API/api/v1/config/auto-pipeline" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"enabled": false}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/config/watcher-auto-register`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: system-level
|
||||
|
||||
Toggle automatic registration of newly detected files in the watcher (disabled by default).
|
||||
When enabled, the file watcher automatically pre-processes and registers new files into the database.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `enabled` | boolean | Yes | `true` to enable watcher auto-register, `false` to disable |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Enable watcher auto-register
|
||||
curl -s -X POST "$API/api/v1/config/watcher-auto-register" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{"enabled": true}'
|
||||
```
|
||||
|
||||
---
|
||||
*Updated: 2026-05-19 12:49:24*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,166 @@
|
||||
---
|
||||
title: workspace API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: workspace -->
|
||||
<!-- description: Workspace checkout/checkin — lock, clear, restore file data -->
|
||||
<!-- depends: 04_lookup, 05_process -->
|
||||
|
||||
## Workspace Checkin/Checkout
|
||||
|
||||
Workspace checkin/checkout provides a transactional editing model for file data:
|
||||
- **Checkout**: Clears PG tables (face_detections, speaker_detections, pre_chunks) and Qdrant vectors, creating an isolated workspace SQLite for editing.
|
||||
- **Checkin**: Restores data from the workspace SQLite back to PG and Qdrant, marking the file as `Indexed`.
|
||||
|
||||
This allows safe concurrent editing — while a file is checked out, its main database records are cleared, preventing conflicts.
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/checkout`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Checkout a file workspace. Clears face detections, speaker detections, pre_chunks from PostgreSQL, deletes Qdrant vectors, and creates a workspace SQLite database for isolated editing.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/checkout" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"rows_deleted": 1523,
|
||||
"status": "checked_out"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `rows_deleted` | integer | Total rows cleared from PG tables |
|
||||
| `status` | string | `"checked_out"` |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `500` | Checkout failed (DB error, workspace creation error) |
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/file/:file_uuid/checkin`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Checkin a file workspace. Restores face detections, speaker detections, pre_chunks from workspace SQLite back to PostgreSQL, re-indexes vectors to Qdrant, and sets video status to `Indexed`.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s -X POST "$API/api/v1/file/$FILE_UUID/checkin" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"pre_chunks_moved": 45,
|
||||
"face_detections_moved": 1200,
|
||||
"speaker_detections_moved": 320,
|
||||
"vectors_moved": 45,
|
||||
"status": "indexed"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `pre_chunks_moved` | integer | Pre-chunks restored from workspace |
|
||||
| `face_detections_moved` | integer | Face detections restored from workspace |
|
||||
| `speaker_detections_moved` | integer | Speaker detections restored from workspace |
|
||||
| `vectors_moved` | integer | Vectors re-indexed to Qdrant |
|
||||
| `status` | string | `"indexed"` |
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `500` | Checkin failed (DB error, workspace not found, vector index error) |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/file/:file_uuid/workspace`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: file-level
|
||||
|
||||
Check if a workspace SQLite database exists for a file.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/file/$FILE_UUID/workspace" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"file_uuid": "d3f9ae8e471a1fc4d47022c66091b920",
|
||||
"exists": true
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `file_uuid` | string | 32-char hex UUID |
|
||||
| `exists` | boolean | True if workspace SQLite exists |
|
||||
|
||||
---
|
||||
|
||||
### Workflow
|
||||
|
||||
```
|
||||
REGISTERED ──→ CHECKED_OUT ──→ INDEXED
|
||||
│ │ │
|
||||
│ checkout checkin
|
||||
│ │ │
|
||||
│ clear PG + Qdrant restore from SQLite
|
||||
│ create workspace re-index vectors
|
||||
│ set status set status
|
||||
```
|
||||
|
||||
1. **Register** file → status: `REGISTERED`
|
||||
2. **Process** file → processors run, data stored in PG + Qdrant
|
||||
3. **Checkout** file → clear editable data, create workspace SQLite → status: `CHECKED_OUT`
|
||||
4. **Edit** workspace via Agent Search / identity binding
|
||||
5. **Checkin** file → restore from workspace SQLite → status: `INDEXED`
|
||||
6. **Rebuild TKG** if needed after checkin
|
||||
|
||||
---
|
||||
|
||||
*Updated: 2026-06-20 12:00:00*
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,389 @@
|
||||
---
|
||||
title: Service Management API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: service_management -->
|
||||
<!-- description: Service lifecycle management endpoints -->
|
||||
<!-- depends: health -->
|
||||
|
||||
# Service Management API
|
||||
|
||||
Manage Momentry core services, including start, stop, and health check operations.
|
||||
|
||||
## Overview
|
||||
|
||||
Service Management API provides endpoints for:
|
||||
- **Start Service**: Launch inference services (e.g., MBE)
|
||||
- **Stop Service**: Terminate running services
|
||||
- **Health Check**: Monitor service status
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `POST /api/v2/service/start`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: system-level
|
||||
|
||||
Start a Momentry service.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `name` | string | Yes | — | Service name (e.g., `"mbe"`) |
|
||||
| `model` | string | No | — | Model path or name |
|
||||
| `port` | number | No | 8080 | Service port |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Start MBE service with default model
|
||||
curl -s -X POST "$API/api/v2/service/start" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe"}'
|
||||
```
|
||||
|
||||
```bash
|
||||
# Start MBE service with custom model and port
|
||||
curl -s -X POST "$API/api/v2/service/start" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"name": "mbe",
|
||||
"model": "/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf",
|
||||
"port": 8080
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"result": "started",
|
||||
"pid": 12345
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `result` | string | `"started"` or `"failed"` |
|
||||
| `pid` | number | Process ID if successful |
|
||||
| `error` | string | Error message if failed |
|
||||
|
||||
#### Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/service_management.rs`
|
||||
|
||||
**Process**:
|
||||
1. Validates service name (currently only `"mbe"` supported)
|
||||
2. Checks if port is already in use
|
||||
3. Stops existing process on that port
|
||||
4. Spawns llama-server with specified model
|
||||
5. Waits up to 60 seconds for service to be ready
|
||||
6. Returns process ID on success
|
||||
|
||||
**Supported Services**:
|
||||
- `"mbe"` - MarkBase Engine (llama.cpp server)
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v2/service/stop`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: system-level
|
||||
|
||||
Stop a running service.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Default | Description |
|
||||
|-------|------|----------|---------|-------------|
|
||||
| `name` | string | Yes | — | Service name (e.g., `"mbe"`) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Stop MBE service
|
||||
curl -s -X POST "$API/api/v2/service/stop" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe"}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
**Success**:
|
||||
```json
|
||||
{
|
||||
"result": "stopped"
|
||||
}
|
||||
```
|
||||
|
||||
**Failure**:
|
||||
```json
|
||||
{
|
||||
"result": "failed",
|
||||
"error": "No service running on port 8080"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `result` | string | `"stopped"` or `"failed"` |
|
||||
| `error` | string | Error message if failed |
|
||||
|
||||
#### Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/service_management.rs`
|
||||
|
||||
**Process**:
|
||||
1. Validates service name
|
||||
2. Finds process ID by port (8080)
|
||||
3. Sends kill signal
|
||||
4. Returns success/failure
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/mbe/health`
|
||||
|
||||
**Auth**: Public
|
||||
|
||||
**Scope**: system-level
|
||||
|
||||
Check MBE (MarkBase Engine) health status.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
None
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Check MBE health
|
||||
curl -s "$API/api/v1/mbe/health"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
**Online**:
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"model": "gemma-4-12b-it-Q4_K_M.gguf",
|
||||
"uptime": 3600
|
||||
}
|
||||
```
|
||||
|
||||
**Offline**:
|
||||
```json
|
||||
{
|
||||
"status": "offline"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `status` | string | `"ok"` or `"offline"` |
|
||||
| `model` | string | Model name if online |
|
||||
| `uptime` | number | Uptime in seconds (currently always 0) |
|
||||
|
||||
#### Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/service_management.rs`
|
||||
|
||||
**Process**:
|
||||
1. Checks if port 8080 is in use
|
||||
2. Calls `/v1/models` endpoint
|
||||
3. Extracts model name from response
|
||||
4. Returns health status
|
||||
|
||||
**Health Check Endpoint**: `http://127.0.0.1:8080/v1/models`
|
||||
|
||||
---
|
||||
|
||||
## Error Codes
|
||||
|
||||
| Code | HTTP | When |
|
||||
|------|------|------|
|
||||
| E401 | 401 | Missing or invalid API key |
|
||||
| E400 | 400 | Invalid service name |
|
||||
| E500 | 500 | Service start/stop failed |
|
||||
|
||||
---
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
### Start Service → Check Health
|
||||
|
||||
```bash
|
||||
# Start MBE
|
||||
curl -s -X POST "$API/api/v2/service/start" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe"}'
|
||||
|
||||
# Wait a few seconds
|
||||
sleep 5
|
||||
|
||||
# Check health
|
||||
curl -s "$API/api/v1/mbe/health"
|
||||
```
|
||||
|
||||
### Stop Service → Verify Stopped
|
||||
|
||||
```bash
|
||||
# Stop MBE
|
||||
curl -s -X POST "$API/api/v2/service/stop" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe"}'
|
||||
|
||||
# Check health (should be offline)
|
||||
curl -s "$API/api/v1/mbe/health"
|
||||
```
|
||||
|
||||
### Restart Service
|
||||
|
||||
```bash
|
||||
# Stop if running
|
||||
curl -s -X POST "$API/api/v2/service/stop" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe"}'
|
||||
|
||||
# Wait for cleanup
|
||||
sleep 3
|
||||
|
||||
# Start with new configuration
|
||||
curl -s -X POST "$API/api/v2/service/start" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe", "port": 8080}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
### Default Settings
|
||||
|
||||
**MBE (llama-server)**:
|
||||
- **Port**: 8080
|
||||
- **Model**: `/Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf`
|
||||
- **mmproj**: `/Users/accusys/models/mmproj-F16.gguf`
|
||||
- **Binary**: `/Users/accusys/llama.cpp/build/bin/llama-server`
|
||||
|
||||
**Launch Parameters**:
|
||||
```bash
|
||||
llama-server \
|
||||
-m <model_path> \
|
||||
--mmproj <mmproj_path> \
|
||||
--host 0.0.0.0 \
|
||||
--port 8080 \
|
||||
-ngl 99 \
|
||||
-c 8192 \
|
||||
--temp 0.1 \
|
||||
-b 4096 \
|
||||
-ub 4096
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
The start process sets:
|
||||
- `PATH=/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin`
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [Health API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/02_health.md)
|
||||
- [MarkBase Documentation](/Users/accusys/markbase/README.md)
|
||||
- [LLM Services Guide](/Users/accusys/momentry_core/docs_v1.0/OPERATIONS/LLM_SERVICES/)
|
||||
|
||||
---
|
||||
|
||||
## Common Issues
|
||||
|
||||
### Service Fails to Start
|
||||
|
||||
**Symptoms**: `{"result": "failed", "error": "..."}`
|
||||
|
||||
**Possible Causes**:
|
||||
1. Model file not found
|
||||
2. Port already in use by another process
|
||||
3. Insufficient permissions
|
||||
4. Binary not found
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check model file exists
|
||||
ls -la /Users/accusys/models/gemma-4-12b-it-Q4_K_M.gguf
|
||||
|
||||
# Check port availability
|
||||
lsof -i :8080
|
||||
|
||||
# Check binary exists
|
||||
ls -la /Users/accusys/llama.cpp/build/bin/llama-server
|
||||
```
|
||||
|
||||
### Health Check Returns "offline"
|
||||
|
||||
**Symptoms**: `{"status": "offline"}`
|
||||
|
||||
**Possible Causes**:
|
||||
1. Service not started
|
||||
2. Service crashed after startup
|
||||
3. Network/firewall issue
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Start service
|
||||
curl -s -X POST "$API/api/v2/service/start" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe"}'
|
||||
|
||||
# Check process status
|
||||
ps aux | grep llama-server
|
||||
|
||||
# Check logs
|
||||
tail -f ~/momentry_core/logs/momentry_3002.log
|
||||
```
|
||||
|
||||
### Service Keeps Restarting
|
||||
|
||||
**Symptoms**: PID changes frequently, service unstable
|
||||
|
||||
**Possible Causes**:
|
||||
1. Out of memory
|
||||
2. Model too large
|
||||
3. Hardware issue
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check memory usage
|
||||
top -pid $(pgrep -f llama-server)
|
||||
|
||||
# Try smaller model or reduce parameters
|
||||
curl -s -X POST "$API/api/v2/service/start" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name": "mbe", "model": "<smaller_model_path>"}'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,399 @@
|
||||
---
|
||||
title: Monitor API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-24
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: monitor -->
|
||||
<!-- description: Queue/Worker/Pipeline monitoring endpoints -->
|
||||
<!-- depends: health -->
|
||||
|
||||
# Monitor API
|
||||
|
||||
Monitor Momentry's job queue, worker status, and processing pipeline in real-time.
|
||||
|
||||
## Overview
|
||||
|
||||
Monitor API provides endpoints for:
|
||||
- **Queue Statistics**: Job counts by status
|
||||
- **Running Jobs**: Detailed view of active jobs with processor progress
|
||||
- **Worker Status**: System resources and worker process health
|
||||
|
||||
## Endpoints
|
||||
|
||||
### `GET /api/v1/monitor/queue_stats`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: system-level
|
||||
|
||||
Get job queue statistics grouped by status.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
None
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get queue statistics
|
||||
curl -s "$API/api/v1/monitor/queue_stats" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"pending": 5,
|
||||
"running": 2,
|
||||
"completed": 150,
|
||||
"failed": 3
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `pending` | number | Jobs waiting to be processed |
|
||||
| `running` | number | Jobs currently being processed |
|
||||
| `completed` | number | Jobs successfully completed |
|
||||
| `failed` | number | Jobs that failed |
|
||||
|
||||
#### Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/monitor.rs`
|
||||
|
||||
**Database Query**:
|
||||
```sql
|
||||
SELECT status, COUNT(*) as count
|
||||
FROM monitor_jobs
|
||||
GROUP BY status
|
||||
```
|
||||
|
||||
**Status Values**:
|
||||
- `"pending"` - Queued for processing
|
||||
- `"running"` - Currently being processed
|
||||
- `"completed"` - Successfully finished
|
||||
- `"failed"` - Processing failed
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/monitor/running_jobs`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: system-level
|
||||
|
||||
Get detailed information about currently running jobs, including processor progress.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
None
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get running jobs
|
||||
curl -s "$API/api/v1/monitor/running_jobs" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"job_id": 123,
|
||||
"file_uuid": "384b0ff44aaaa1f1",
|
||||
"file_name": "video.mp4",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-24T15:30:00Z",
|
||||
"duration_secs": 120,
|
||||
"processors": [
|
||||
{
|
||||
"name": "asr",
|
||||
"phase": 2,
|
||||
"status": "running",
|
||||
"progress": 75,
|
||||
"duration": 45.3
|
||||
},
|
||||
{
|
||||
"name": "face",
|
||||
"phase": 2,
|
||||
"status": "pending",
|
||||
"progress": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `jobs` | array | List of running jobs |
|
||||
| `jobs[].job_id` | number | Job ID |
|
||||
| `jobs[].file_uuid` | string | File UUID |
|
||||
| `jobs[].file_name` | string | File name |
|
||||
| `jobs[].status` | string | Job status (`"running"`) |
|
||||
| `jobs[].started_at` | string | ISO 8601 timestamp |
|
||||
| `jobs[].duration_secs` | number | Duration in seconds |
|
||||
| `jobs[].processors` | array | List of processors for this job |
|
||||
| `jobs[].processors[].name` | string | Processor type |
|
||||
| `jobs[].processors[].phase` | number | Processing phase (1-4) |
|
||||
| `jobs[].processors[].status` | string | Processor status |
|
||||
| `jobs[].processors[].progress` | number | Progress percentage (0-100) |
|
||||
| `jobs[].processors[].duration` | number | Duration in seconds (optional) |
|
||||
|
||||
#### Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/monitor.rs`
|
||||
|
||||
**Database Query**:
|
||||
```sql
|
||||
SELECT j.id, j.uuid, j.status, j.started_at, v.file_name
|
||||
FROM monitor_jobs j
|
||||
LEFT JOIN videos v ON v.file_uuid = j.uuid
|
||||
WHERE j.status = 'running'
|
||||
ORDER BY j.started_at DESC
|
||||
```
|
||||
|
||||
**Processor Phases**:
|
||||
| Phase | Processors | Description |
|
||||
|-------|-----------|-------------|
|
||||
| 1 | `cut` | Video segmentation |
|
||||
| 2 | `asr`, `asr_asrx`, `face`, `ocr` | Core processing |
|
||||
| 3 | `scene`, `face_trace`, `face_cluster` | Analysis & clustering |
|
||||
| 4 | `tkg` | Knowledge graph |
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/monitor/worker_status`
|
||||
|
||||
**Auth**: Required
|
||||
|
||||
**Scope**: system-level
|
||||
|
||||
Get worker process status and system resource usage.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
None
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
# Get worker status
|
||||
curl -s "$API/api/v1/monitor/worker_status" \
|
||||
-H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"cpu_percent": 45.5,
|
||||
"gpu_percent": 60.0,
|
||||
"memory_mb": 8192,
|
||||
"memory_percent": 52.3,
|
||||
"active_processors": 3,
|
||||
"max_processors": 6,
|
||||
"processors": [
|
||||
{
|
||||
"name": "asr",
|
||||
"job_id": 123,
|
||||
"status": "running"
|
||||
},
|
||||
{
|
||||
"name": "face",
|
||||
"job_id": 124,
|
||||
"status": "running"
|
||||
}
|
||||
],
|
||||
"worker_pid": 12345,
|
||||
"uptime_secs": 3600,
|
||||
"last_poll_at": "2026-10-24T15:30:00Z",
|
||||
"poll_interval_secs": 5,
|
||||
"is_alive": true
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| `cpu_percent` | number | CPU usage percentage |
|
||||
| `gpu_percent` | number | GPU utilization percentage |
|
||||
| `memory_mb` | number | Memory used in MB |
|
||||
| `memory_percent` | number | Memory usage percentage |
|
||||
| `active_processors` | number | Number of active processors |
|
||||
| `max_processors` | number | Maximum concurrent processors |
|
||||
| `processors` | array | List of active processors |
|
||||
| `processors[].name` | string | Processor type |
|
||||
| `processors[].job_id` | number | Job ID being processed |
|
||||
| `processors[].status` | string | Processor status |
|
||||
| `worker_pid` | number | Worker process ID |
|
||||
| `uptime_secs` | number | Worker uptime in seconds |
|
||||
| `last_poll_at` | string | Last activity timestamp (optional) |
|
||||
| `poll_interval_secs` | number | Expected poll interval |
|
||||
| `is_alive` | boolean | Worker process is running |
|
||||
|
||||
#### Implementation Details
|
||||
|
||||
**File**: `/Users/accusys/momentry_core/src/api/monitor.rs`
|
||||
|
||||
**Data Sources**:
|
||||
- System resources: `SystemResources::check()`
|
||||
- Worker PID: `pgrep -f "momentry worker"`
|
||||
- Active processors: `processor_results` table
|
||||
- Last activity: `monitor_jobs` table
|
||||
|
||||
**Resource Monitoring**:
|
||||
- CPU: System-wide usage
|
||||
- GPU: Metal/ANE utilization (macOS)
|
||||
- Memory: Used vs total memory
|
||||
|
||||
---
|
||||
|
||||
## Usage Patterns
|
||||
|
||||
### Dashboard Monitoring
|
||||
|
||||
```bash
|
||||
# Get all monitoring data
|
||||
curl -s "$API/api/v1/monitor/queue_stats" -H "X-API-Key: $KEY" | jq
|
||||
curl -s "$API/api/v1/monitor/running_jobs" -H "X-API-Key: $KEY" | jq
|
||||
curl -s "$API/api/v1/monitor/worker_status" -H "X-API-Key: $KEY" | jq
|
||||
```
|
||||
|
||||
### Real-time Updates
|
||||
|
||||
```bash
|
||||
# Poll every 5 seconds
|
||||
watch -n 5 'curl -s "$API/api/v1/monitor/queue_stats" -H "X-API-Key: $KEY" | jq'
|
||||
```
|
||||
|
||||
### Health Check
|
||||
|
||||
```bash
|
||||
# Check if worker is alive
|
||||
curl -s "$API/api/v1/monitor/worker_status" -H "X-API-Key: $KEY" | jq '.is_alive'
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Error Codes
|
||||
|
||||
| Code | HTTP | When |
|
||||
|------|------|------|
|
||||
| E401 | 401 | Missing or invalid API key |
|
||||
| E500 | 500 | Database query failed |
|
||||
|
||||
---
|
||||
|
||||
## Database Tables
|
||||
|
||||
### `monitor_jobs`
|
||||
|
||||
Primary job queue table.
|
||||
|
||||
| Column | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `id` | integer | Job ID |
|
||||
| `uuid` | string | File UUID |
|
||||
| `status` | string | Job status |
|
||||
| `started_at` | timestamp | Start time |
|
||||
| `updated_at` | timestamp | Last update |
|
||||
|
||||
### `processor_results`
|
||||
|
||||
Processor execution results.
|
||||
|
||||
| Column | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `job_id` | integer | Job ID |
|
||||
| `processor_type` | string | Processor name |
|
||||
| `status` | string | Processor status |
|
||||
| `progress_current` | integer | Current progress |
|
||||
| `progress_total` | integer | Total steps |
|
||||
| `duration_secs` | float | Duration in seconds |
|
||||
|
||||
---
|
||||
|
||||
## Related Documentation
|
||||
|
||||
- [Health API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/02_health.md)
|
||||
- [Pipeline API](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/10_pipeline.md)
|
||||
- [Job Management](/Users/accusys/momentry_core/docs_v1.0/API_WORKSPACE/modules/17_progress.md)
|
||||
|
||||
---
|
||||
|
||||
## Common Issues
|
||||
|
||||
### Worker Shows as Not Alive
|
||||
|
||||
**Symptoms**: `is_alive: false`
|
||||
|
||||
**Possible Causes**:
|
||||
1. Worker process not running
|
||||
2. Worker crashed
|
||||
3. `pgrep` command failed
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check worker process
|
||||
ps aux | grep momentry
|
||||
|
||||
# Start worker
|
||||
momentry worker
|
||||
|
||||
# Check logs
|
||||
tail -f ~/momentry_core/logs/worker_3002.log
|
||||
```
|
||||
|
||||
### Queue Has Stuck Jobs
|
||||
|
||||
**Symptoms**: Jobs stuck in "running" status
|
||||
|
||||
**Possible Causes**:
|
||||
1. Worker crashed
|
||||
2. Processor timeout
|
||||
3. Database lock
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check running jobs
|
||||
curl -s "$API/api/v1/monitor/running_jobs" -H "X-API-Key: $KEY"
|
||||
|
||||
# Reset stuck jobs (requires database access)
|
||||
# UPDATE monitor_jobs SET status = 'pending' WHERE status = 'running' AND updated_at < NOW() - INTERVAL '1 hour';
|
||||
```
|
||||
|
||||
### High Resource Usage
|
||||
|
||||
**Symptoms**: `cpu_percent` or `memory_percent` very high
|
||||
|
||||
**Possible Causes**:
|
||||
1. Too many concurrent jobs
|
||||
2. Large video files
|
||||
3. Memory leak
|
||||
|
||||
**Solution**:
|
||||
```bash
|
||||
# Check active processors
|
||||
curl -s "$API/api/v1/monitor/worker_status" -H "X-API-Key: $KEY" | jq '.processors'
|
||||
|
||||
# Reduce max_processors if needed
|
||||
# Restart worker
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-24 | Initial documentation |
|
||||
@@ -0,0 +1,310 @@
|
||||
---
|
||||
title: Admin Config API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-25
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: admin_config -->
|
||||
<!-- description: System configuration management -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## Admin Configuration
|
||||
|
||||
Admin configuration management for system-wide settings, VLM prompts, and runtime parameters.
|
||||
|
||||
### `GET /api/v1/admin/config`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Get the full system configuration. Returns all configuration parameters including VLM prompts, processing settings, and system defaults.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/admin/config" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"vlm_prompts": {
|
||||
"face_trace": {
|
||||
"system_prompt": "Analyze the person's appearance...",
|
||||
"user_prompt_template": "Describe this person..."
|
||||
}
|
||||
},
|
||||
"processing": {
|
||||
"default_processors": ["cut", "asr", "face"],
|
||||
"face_min_confidence": 0.5,
|
||||
"face_min_size": 30
|
||||
},
|
||||
"system": {
|
||||
"max_concurrent_jobs": 3,
|
||||
"output_dir": "/Users/accusys/momentry/output"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/admin/config`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Partially update system configuration. Only provided fields are modified; others remain unchanged.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `processing` | object | No | Processing configuration |
|
||||
| `system` | object | No | System configuration |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/admin/config" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{
|
||||
"processing": {
|
||||
"face_min_confidence": 0.6
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Config updated"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/admin/config/vlm_prompts`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Get all VLM (Vision Language Model) prompts used for image analysis.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/admin/config/vlm_prompts" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"face_trace": {
|
||||
"system_prompt": "You are an expert in person appearance analysis...",
|
||||
"user_prompt_template": "Describe the person in this image..."
|
||||
},
|
||||
"scene": {
|
||||
"system_prompt": "You are a scene description expert...",
|
||||
"user_prompt_template": "Describe the scene..."
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/admin/config/vlm_prompts/:key`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Get a specific VLM prompt by key.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `key` | string | Prompt key (e.g., "face_trace", "scene") |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -s "$API/api/v1/admin/config/vlm_prompts/face_trace" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"system_prompt": "You are an expert in person appearance analysis...",
|
||||
"user_prompt_template": "Describe the person in this image..."
|
||||
}
|
||||
```
|
||||
|
||||
#### Error Responses
|
||||
|
||||
| HTTP | When |
|
||||
|------|------|
|
||||
| `404` | Prompt key not found |
|
||||
| `401` | Missing or invalid API key |
|
||||
|
||||
---
|
||||
|
||||
### `PUT /api/v1/admin/config/vlm_prompts/:key`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Update a specific VLM prompt. This affects all subsequent VLM analysis operations.
|
||||
|
||||
#### Request Parameters
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|-------|------|----------|-------------|
|
||||
| `system_prompt` | string | Yes | System prompt for the LLM |
|
||||
| `user_prompt_template` | string | Yes | User prompt template (may include placeholders) |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X PUT "$API/api/v1/admin/config/vlm_prompts/face_trace" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{
|
||||
"system_prompt": "You are an expert in fashion and appearance analysis...",
|
||||
"user_prompt_template": "Analyze the person'\''s clothing and accessories in detail..."
|
||||
}'
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Prompt 'face_trace' updated"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `POST /api/v1/admin/config/reload`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Reload configuration from disk. Useful when the configuration file has been manually edited.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/admin/config/reload" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
```json
|
||||
{
|
||||
"success": true,
|
||||
"message": "Config reloaded"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `GET /api/v1/admin/settings`
|
||||
|
||||
**Auth**: Required
|
||||
**Scope**: admin-level
|
||||
|
||||
Alias for `/api/v1/admin/config`. Provided for frontend compatibility.
|
||||
|
||||
---
|
||||
|
||||
## Configuration Structure
|
||||
|
||||
### VLM Prompts
|
||||
|
||||
VLM prompts control how the system analyzes images and video frames:
|
||||
|
||||
| Prompt Key | Purpose | Used By |
|
||||
|------------|---------|---------|
|
||||
| `face_trace` | Person appearance description | Face trace processor |
|
||||
| `scene` | Scene description | Scene VLM processor |
|
||||
| `appearance` | Detailed appearance analysis | Appearance processor |
|
||||
|
||||
### Processing Settings
|
||||
|
||||
| Field | Type | Default | Description |
|
||||
|-------|------|---------|-------------|
|
||||
| `default_processors` | string[] | all | Default processors for new files |
|
||||
| `face_min_confidence` | float | 0.5 | Minimum face detection confidence |
|
||||
| `face_min_size` | integer | 30 | Minimum face size in pixels |
|
||||
|
||||
### System Settings
|
||||
|
||||
| Field | Type | Default | Description |
|
||||
|-------|------|---------|-------------|
|
||||
| `max_concurrent_jobs` | integer | 3 | Maximum parallel processing jobs |
|
||||
| `output_dir` | string | - | Output directory path |
|
||||
|
||||
---
|
||||
|
||||
## Use Cases
|
||||
|
||||
### 1. Adjust Face Detection Sensitivity
|
||||
|
||||
```bash
|
||||
curl -X POST "$API/api/v1/admin/config" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{
|
||||
"processing": {
|
||||
"face_min_confidence": 0.7,
|
||||
"face_min_size": 50
|
||||
}
|
||||
}'
|
||||
```
|
||||
|
||||
### 2. Customize VLM Prompts
|
||||
|
||||
```bash
|
||||
curl -X PUT "$API/api/v1/admin/config/vlm_prompts/face_trace" \
|
||||
-H "X-API-Key: $KEY" \
|
||||
-d '{
|
||||
"system_prompt": "Focus on clothing colors and patterns",
|
||||
"user_prompt_template": "Describe the person'\''s outfit..."
|
||||
}'
|
||||
```
|
||||
|
||||
### 3. Reload Configuration After Manual Edit
|
||||
|
||||
```bash
|
||||
# Edit config file on disk
|
||||
vim /path/to/config.json
|
||||
|
||||
# Reload into running system
|
||||
curl -X POST "$API/api/v1/admin/config/reload" -H "X-API-Key: $KEY"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Security Notes
|
||||
|
||||
- **Admin-only access**: All endpoints require admin-level authentication
|
||||
- **Persistent changes**: Configuration changes persist across server restarts
|
||||
- **Hot reload**: Changes take effect immediately without server restart
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-25 | Initial documentation |
|
||||
@@ -0,0 +1,120 @@
|
||||
---
|
||||
title: Docs API
|
||||
version: 1.3.5
|
||||
api_version: 1.3.5
|
||||
git_tag: v1.3.5
|
||||
date: 2026-10-25
|
||||
author: Core Team
|
||||
status: Active
|
||||
---
|
||||
|
||||
<!-- module: docs -->
|
||||
<!-- description: API documentation web server -->
|
||||
<!-- depends: 01_auth -->
|
||||
|
||||
## Documentation Web Server
|
||||
|
||||
Web-based API documentation served by the server. Supports both static HTML and WASM-based interactive documentation.
|
||||
|
||||
### `GET /doc`
|
||||
|
||||
**Auth**: Not required
|
||||
|
||||
Redirect to WASM documentation.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl -L http://localhost:3002/doc
|
||||
```
|
||||
|
||||
#### Response
|
||||
|
||||
301 Redirect → `/doc-wasm`
|
||||
|
||||
---
|
||||
|
||||
### `GET /doc-wasm`
|
||||
|
||||
**Auth**: Not required
|
||||
|
||||
Serve WASM-based interactive documentation.
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl http://localhost:3002/doc-wasm
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
HTML page with WASM documentation viewer.
|
||||
|
||||
---
|
||||
|
||||
### `GET /doc-wasm/*file`
|
||||
|
||||
**Auth**: Not required
|
||||
|
||||
Serve WASM binary files and static assets for documentation.
|
||||
|
||||
#### Path Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `file` | string | File path (e.g., "pkg/md_wasm_bg.wasm") |
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
curl http://localhost:3002/doc-wasm/pkg/md_wasm_bg.wasm --output md_wasm_bg.wasm
|
||||
```
|
||||
|
||||
#### Response (200)
|
||||
|
||||
Binary file with appropriate MIME type:
|
||||
- `.wasm` → `application/wasm`
|
||||
- `.js` → `application/javascript`
|
||||
- `.css` → `text/css`
|
||||
- `.md` → `text/markdown`
|
||||
|
||||
---
|
||||
|
||||
## Documentation Types
|
||||
|
||||
### WASM Documentation (Default)
|
||||
|
||||
- **Location**: `docs_v1.0/doc_wasm/`
|
||||
- **Technology**: Rust WASM + pulldown-cmark
|
||||
- **Features**: Interactive search, Mermaid diagrams, Material Design
|
||||
- **Authentication**: Optional (configurable)
|
||||
|
||||
### Static Documentation
|
||||
|
||||
- **Location**: `docs_v1.0/API_WORKSPACE/` and `docs_v1.0/CLI_WORKSPACE/`
|
||||
- **Format**: Markdown files
|
||||
- **Served via**: WASM renderer
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
| Variable | Default | Description |
|
||||
|----------|---------|-------------|
|
||||
| `MOMENTRY_DOCS_DIR` | `{binary_dir}/docs_v1.0/doc_wasm` | Documentation root directory |
|
||||
|
||||
---
|
||||
|
||||
## Security
|
||||
|
||||
- **Path Traversal Protection**: Rejects paths containing `..` or `//`
|
||||
- **Directory Restriction**: Only serves files within `MOMENTRY_DOCS_DIR`
|
||||
- **No Authentication**: Documentation is public (unless protected by reverse proxy)
|
||||
|
||||
---
|
||||
|
||||
## Version History
|
||||
|
||||
| Version | Date | Changes |
|
||||
|---------|------|---------|
|
||||
| 1.0 | 2026-10-25 | Initial documentation |
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user