🐛 fix bug with ollama and templated sys msg
This commit is contained in:
parent
47467d0442
commit
3e387e0fdb
2 changed files with 9 additions and 2 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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] = ""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue