Skip to content

Commit

Permalink
fix(prompt_path): path issue if pandasai used outside of pandas env (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanSaleem authored Jan 30, 2024
1 parent d626b27 commit ebeb9f2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pandasai/prompts/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re
from jinja2 import Environment, FileSystemLoader
from typing import Optional
import os
from pathlib import Path


class BasePrompt:
Expand All @@ -20,7 +22,10 @@ def __init__(self, **kwargs):
env = Environment()
self.prompt = env.from_string(self.template)
elif self.template_path:
env = Environment(loader=FileSystemLoader("pandasai/prompts/templates"))
# find path to template file
current_dir_path = Path(__file__).parent
path_to_template = os.path.join(current_dir_path, "templates")
env = Environment(loader=FileSystemLoader(path_to_template))
self.prompt = env.get_template(self.template_path)

def render(self):
Expand Down

0 comments on commit ebeb9f2

Please sign in to comment.