Files
group_xinghuo_jinrong/scripts/sync/sync_template_vectors.py
T
zhanghongyu_0626 64c5db73a9 refactor(kyc): Remove ApiResponse response model from KYC session endpoints
- Updated KYC session endpoints to remove the ApiResponse response model, simplifying the API structure.
- Enhanced clarity in the KYC session creation, retrieval, chat, and completion methods by focusing on the payload and response data directly.
- Improved code readability and maintainability by streamlining the endpoint definitions.
2026-09-12 16:48:25 +08:00

37 lines
1.2 KiB
Python

"""Rebuild Milvus vectors for approved script templates."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
from app.repository.script_template_repository import ScriptTemplateRepository
from app.service.script_template_vector_service import ScriptTemplateVectorService
def main() -> None:
parser = argparse.ArgumentParser(description="Sync approved script templates to Milvus.")
parser.add_argument("--dry-run", action="store_true", help="Only count approved active templates.")
parser.add_argument("--created-by", default=None, help="Optional created_by filter for development checks.")
args = parser.parse_args()
repository = ScriptTemplateRepository()
if args.dry_run:
total = len(repository.list_vector_candidates(created_by=args.created_by))
print(f"Template vector sync dry run: total={total}")
return
result = ScriptTemplateVectorService(repository=repository).sync_approved_templates(created_by=args.created_by)
print(
"Template vector sync: "
f"total={result.total}, upserted={result.upserted}, skipped={result.skipped}"
)
if __name__ == "__main__":
main()