mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-10 15:57:04 +00:00
10 lines
383 B
Python
10 lines
383 B
Python
from difflib import get_close_matches
|
|
from jinja2 import Environment, PackageLoader
|
|
|
|
|
|
def template(name, prompt):
|
|
environment = Environment(loader=PackageLoader(__name__, 'templates'))
|
|
best_templates = get_close_matches(name, environment.list_templates(), n=1, cutoff=0)
|
|
template = environment.get_template(best_templates.pop())
|
|
return template.render(prompt=prompt)
|