참고소스 수정본

This commit is contained in:
LASTA_DEV01\lasta
2026-05-12 19:40:31 +09:00
parent 0f34a451fc
commit 2e9204243d
8708 changed files with 3259488 additions and 869 deletions

View File

@@ -0,0 +1,27 @@
import json
import os
from guardrails.cli.server.hub_client import get_guard_template
def get_template(template_name: str) -> tuple[dict, str]:
# if template ends in .json load file from disk relative to the execution directory
if template_name.endswith(".json"):
template_file_name = template_name
try:
file_path = os.path.join(os.getcwd(), template_name)
with open(file_path, "r") as fin:
return json.load(fin), template_file_name
except FileNotFoundError:
raise FileNotFoundError(f"Template file {template_name} not found.")
template_file_name = f"{template_name.split('/')[-1]}.json"
template = get_guard_template(template_name)
# write template to file
out_path = os.path.join(os.getcwd(), template_file_name)
with open(out_path, "wt") as file_out:
file_out.write(json.dumps(template, indent=4))
return template, template_file_name