bananaml/fructose

[Bug] Unable to load custom system template

Opened this issue · 0 comments

I installed fructorse==0.0.11 from pip and ran the followings:

ai = Fructose(model="gpt-3.5-turbo")
@ai(system_template_path="custom_sys_prompt.jinja")  # template file is in the same directory
def generate(text: str) -> list[str]:
    """genearte some words."""
    ...

this error occur:

---------------------------------------------------------------------------
TemplateNotFound                          Traceback (most recent call last)
[<ipython-input-7-cde3627a0796>](https://localhost:8080/#) in <cell line: 2>()
      1 ai = Fructose(model="gpt-3.5-turbo")
----> 2 @ai(system_template_path="custom_sys_prompt.jinja")  # template file is in the same directory
      3 def generate(text: str) -> list[str]:
      4     """genearte some words."""
      5     ...

4 frames
[/usr/local/lib/python3.10/dist-packages/jinja2/loaders.py](https://localhost:8080/#) in get_source(self, environment, template)
    202                 break
    203         else:
--> 204             raise TemplateNotFound(template)
    205 
    206         with open(filename, encoding=self.encoding) as f:

TemplateNotFound: custom_sys_prompt.jinja

I believe the loader specifies the path to the installed package, not the current working directory. Could this be the cause of the problem?

def get_base_template_env():
p = Path(__file__).parent / 'templates'
loader = FileSystemLoader(p)