From 4f7abbe835105834c0b2d4a058ca77aedba067c0 Mon Sep 17 00:00:00 2001 From: Prince Canuma Date: Sat, 10 Aug 2024 22:34:38 +0200 Subject: [PATCH] Fix tools template loader (Jinja 2 Template not found) (#25) * fix tools loader * bump version --- fastmlx/__init__.py | 2 +- fastmlx/utils.py | 9 +++++---- pyproject.toml | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fastmlx/__init__.py b/fastmlx/__init__.py index f0af708d..15e297c1 100644 --- a/fastmlx/__init__.py +++ b/fastmlx/__init__.py @@ -2,6 +2,6 @@ __author__ = """Prince Canuma""" __email__ = "prince.gdt@gmail.com" -__version__ = "0.2.0" +__version__ = "0.2.1" from .fastmlx import * diff --git a/fastmlx/utils.py b/fastmlx/utils.py index c79caec1..79c680c7 100644 --- a/fastmlx/utils.py +++ b/fastmlx/utils.py @@ -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 @@ -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) @@ -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 ( diff --git a/pyproject.toml b/pyproject.toml index 16c1e79a..a5498824 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "fastmlx" -version = "0.2.0" +version = "0.2.1" dynamic = [ "dependencies", ] @@ -56,7 +56,7 @@ universal = true [tool.bumpversion] -current_version = "0.1.0" +current_version = "0.2.1" commit = true tag = true