mirror of
https://github.com/dogkeeper886/ollama37.git
synced 2025-12-11 16:26:59 +00:00
move to contained directory
This commit is contained in:
20
template.py
20
template.py
@@ -1,20 +0,0 @@
|
||||
from difflib import SequenceMatcher
|
||||
import json
|
||||
|
||||
with open("model_prompts.json", "r") as f:
|
||||
model_prompts = json.load(f)
|
||||
|
||||
|
||||
def template(model, prompt):
|
||||
max_ratio = 0
|
||||
closest_key = ""
|
||||
model_name = model.lower()
|
||||
# Find the specialized prompt with the closest name match
|
||||
for key in model_prompts.keys():
|
||||
ratio = SequenceMatcher(None, model_name, key).ratio()
|
||||
if ratio > max_ratio:
|
||||
max_ratio = ratio
|
||||
closest_key = key
|
||||
# Return the value of the closest match
|
||||
p = model_prompts.get(closest_key) # TODO: provide a better default template
|
||||
return p.format(prompt=prompt)
|
||||
Reference in New Issue
Block a user