Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kugesan1105 committed Nov 12, 2024
1 parent 9d0ae28 commit aeca6db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions jac-mtllm/mtllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def extract_template_placeholders(template: str) -> list:
def format_template_section(template_section: str, values_dict: dict) -> str:
"""Format a template section with given values."""
placeholders = extract_template_placeholders(template_section)
filtered_values = {
key: values_dict[key] for key in placeholders if key in values_dict
}
return template_section.format(**filtered_values).strip()
formatted_sections = []
for placeholder in placeholders:
if placeholder in values_dict and values_dict[placeholder]:
section_template = f"[{placeholder.title()}]\n{values_dict[placeholder]}"
formatted_sections.append(section_template)
return "\n\n".join(formatted_sections).strip()

0 comments on commit aeca6db

Please sign in to comment.