Skip to content

Commit

Permalink
Fix tools template loader (Jinja 2 Template not found) (#25)
Browse files Browse the repository at this point in the history
* fix tools loader

* bump version
  • Loading branch information
Blaizzy authored Aug 10, 2024
1 parent 2216143 commit 4f7abbe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fastmlx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__author__ = """Prince Canuma"""
__email__ = "[email protected]"
__version__ = "0.2.0"
__version__ = "0.2.1"

from .fastmlx import *
9 changes: 5 additions & 4 deletions fastmlx/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
print("Warning: mlx or mlx_lm not available. Some functionality will be limited.")


TOOLS_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "tools"))


def get_model_type_list(models, type="vlm"):

# Get the directory path of the models package
Expand Down Expand Up @@ -73,8 +76,7 @@ def working_directory(path):


def load_tools_config():
tools_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "tools"))
with working_directory(tools_path):
with working_directory(TOOLS_PATH):
with open("config.json", "r") as file:
return json.load(file)

Expand All @@ -99,8 +101,7 @@ def get_tool_prompt(model_name, tools, prompt):
model_config = tool_config["models"].get(
model_type, tool_config["models"]["default"]
)
templates_dir = os.path.abspath("./fastmlx/tools")
env = Environment(loader=FileSystemLoader(templates_dir))
env = Environment(loader=FileSystemLoader(TOOLS_PATH))
template = env.get_template(model_config["prompt_template"])
if model_config.get("query", False):
return (
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "fastmlx"
version = "0.2.0"
version = "0.2.1"
dynamic = [
"dependencies",
]
Expand Down Expand Up @@ -56,7 +56,7 @@ universal = true


[tool.bumpversion]
current_version = "0.1.0"
current_version = "0.2.1"
commit = true
tag = true

Expand Down

0 comments on commit 4f7abbe

Please sign in to comment.