mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-13 01:07:12 +00:00
12
python/ollama/prompt.py
Normal file
12
python/ollama/prompt.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from os import path
|
||||
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(
|
||||
path.basename(name), environment.list_templates(), n=1, cutoff=0
|
||||
)
|
||||
template = environment.get_template(best_templates.pop())
|
||||
return template.render(prompt=prompt)
|
||||
Reference in New Issue
Block a user