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

Fix tools template loader (Jinja 2 Template not found) #25

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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__ = "prince.gdt@gmail.com"
__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
Loading