🐛 fix bug with ollama and templated sys msg

This commit is contained in:
Nate Sesti 2023-11-04 21:51:44 -07:00
parent 47467d0442
commit 3e387e0fdb
2 changed files with 9 additions and 2 deletions

View file

@ -5,6 +5,7 @@ from typing import Any, Callable, Coroutine, Dict, Generator, List, Optional, Un
import aiohttp
import certifi
from ..util.templating import render_templated_string
from pydantic import Field, validator
from ...core.main import ChatMessage
@ -298,7 +299,13 @@ Settings:
msgs = [{"role": "user", "content": prompt}]
if self.get_system_message() is not None:
msgs.insert(0, {"role": "system", "content": self.get_system_message()})
msgs.insert(
0,
{
"role": "system",
"content": render_templated_string(self.get_system_message()),
},
)
return self.template_messages(msgs)

View file

@ -38,7 +38,7 @@ def render_templated_string(template: str) -> str:
escaped_var = escape_var(var)
template = template.replace(var, escaped_var)
if os.path.exists(var):
if os.path.exists(var) and os.path.isfile(var):
args[escaped_var] = open(var, "r").read()
else:
args[escaped_var] = ""