Templates: Switch to Jinja2

Jinja2 is a lightweight template parser that's used in Transformers
for parsing chat completions. It's much more efficient than Fastchat
and can be imported as part of requirements.

Also allows for unblocking Pydantic's version.

Users now have to provide their own template if needed. A separate
repo may be usable for common prompt template storage.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri
2023-12-17 00:41:42 -05:00
committed by Brian Dashore
parent 95fd0f075e
commit f631dd6ff7
14 changed files with 115 additions and 74 deletions

View File

@@ -25,12 +25,12 @@ else:
print("Torch is not found in your environment.")
errored_packages.append("torch")
if find_spec("fastchat") is not None:
print(f"Fastchat on version {version('fschat')} successfully imported")
successful_packages.append("fastchat")
if find_spec("jinja2") is not None:
print(f"Jinja2 on version {version('jinja2')} successfully imported")
successful_packages.append("jinja2")
else:
print("Fastchat is not found in your environment. It isn't needed unless you're using chat completions with message arrays.")
errored_packages.append("fastchat")
print("Jinja2 is not found in your environment.")
errored_packages.append("jinja2")
print(
f"\nSuccessful imports: {', '.join(successful_packages)}",