Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unable to load custom system template #22

Open
JasonLo opened this issue Mar 15, 2024 · 0 comments
Open

[Bug] Unable to load custom system template #22

JasonLo opened this issue Mar 15, 2024 · 0 comments

Comments

@JasonLo
Copy link

JasonLo commented Mar 15, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant