Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
72ac35d
Add tools to system message if not supported by template
Jan 28, 2025
6e03694
Revamp capabilities detection
Jan 28, 2025
12771d4
Fix array typos in capabilities detection
Jan 28, 2025
73c96f1
Delete tool_use_code_interpreter.json
Jan 28, 2025
bf166d0
Fix CWD of test-capabilities
Jan 28, 2025
8d428eb
Fix most tool-related capabilities
Jan 28, 2025
affda86
Write capabilities of templates as .jinja.caps.json companion files
Jan 28, 2025
3527e3d
Fix requires_object_arguments cap detection
Jan 28, 2025
1bd0311
Ensure capabilities detectors are in sync between c++ & Python
Jan 28, 2025
42522c7
Fix typo in python golden gen
Jan 28, 2025
a72e535
Explode on operations w/ Nones
Jan 28, 2025
3e0a197
Add requires_non_null_content capability to c++
Jan 28, 2025
2689d6c
Revert null content in tool_use context
Jan 28, 2025
b3b97c0
Disable check on requires_non_null_content (mismatch c++ / python)
Jan 28, 2025
99e2051
Merge branch 'nones' into tools-system
Jan 28, 2025
edc6a6c
Merge remote-tracking branch 'origin/main' into tools-system
Jan 28, 2025
0611927
nits
Jan 28, 2025
ab0c766
normalize lines of files on windows
Jan 28, 2025
9282689
Backtrack on disruptive None explosions
Jan 29, 2025
cd362d2
Skip caps golden tests on win32
Jan 29, 2025
1f4b928
Update test-syntax.cpp
Jan 29, 2025
30a1000
Revert "Explode on operations w/ Nones"
ochafik Jan 29, 2025
21820ab
Merge remote-tracking branch 'origin/revert-32-nones' into tools-system
Jan 29, 2025
81e9949
Update test-chat-template.cpp
Jan 29, 2025
a45b474
Create analyze_capabilities.py
Jan 29, 2025
e67ae5c
Create __init__.py
Jan 29, 2025
57529c8
Test caps after template output
Jan 29, 2025
66a5c6e
Disable deepseek tests on win32
Jan 29, 2025
cdd93c1
Async scripts/fetch_templates_and_goldens.py (3x faster)
Jan 29, 2025
782aaf6
Disable deepseek caps test on win32
Jan 29, 2025
b643433
Fix n/a case in golden gen
Jan 29, 2025
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist/
.DS_Store
Testing/
.vscode/
__pycache__/
255 changes: 174 additions & 81 deletions include/minja/chat-template.hpp

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions include/minja/minja.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,11 +1270,6 @@ class BinaryOpExpr : public Expression {
}

auto r = right->evaluate(context);
if (op != Op::Eq && op != Op::Ne) {
if (r.is_null() || (l.is_null() && (op != Op::In && op != Op::NotIn))) {
throw std::runtime_error("unsupported operand type(s)");
}
}
switch (op) {
case Op::StrConcat: return l.to_str() + r.to_str();
case Op::Add: return l + r;
Expand Down Expand Up @@ -2152,11 +2147,11 @@ class Parser {
}

std::runtime_error unexpected(const TemplateToken & token) const {
return std::runtime_error("Encountered unknown tag '" + TemplateToken::typeToString(token.type) + "'"
return std::runtime_error("Unexpected " + TemplateToken::typeToString(token.type)
+ error_location_suffix(*template_str, token.location.pos));
}
std::runtime_error unterminated(const TemplateToken & token) const {
return std::runtime_error("Unexpected end of template. Jinja was looking for the following tags: '" + TemplateToken::typeToString(token.type) + "'"
return std::runtime_error("Unterminated " + TemplateToken::typeToString(token.type)
+ error_location_suffix(*template_str, token.location.pos));
}

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
aiofiles
aiohttp
huggingface_hub
jinja2
Empty file added scripts/__init__.py
Empty file.
69 changes: 69 additions & 0 deletions scripts/analyze_capabilities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env python3
import json
import os
from pathlib import Path
from typing import Dict, List


def generate_markdown_table(files_data: List[tuple[str, Dict]]) -> str:
"""Generate a markdown table from the capabilities data."""
if not files_data:
return "No capability files found."

all_caps = set()
for _, data in files_data:
all_caps.update(data.keys())
all_caps = sorted(all_caps)

lines = [
"| Model | " + " | ".join(c.replace('_', ' ') for c in all_caps) + " |",
"|" + "|".join("-" * (len(cap) + 2) for cap in ["Model"] + list(all_caps)) + "|",
]

# Sort data by most supports and least requires
def sort_key(item):
model, data = item
supports_count = sum(1 for k, v in data.items()
if k.startswith("supports_") and str(v).lower() == "true")
requires_count = sum(1 for k, v in data.items()
if k.startswith("requires_") and str(v).lower() == "true")
return (-supports_count, requires_count) # negative for descending supports

for model, data in sorted(files_data, key=sort_key):
model_name = os.path.basename(model).replace(".caps.json", "")
row = [model_name]
for cap in all_caps:
raw_value = str(data.get(cap, "N/A")).lower()
if raw_value == "true":
if cap.startswith("supports_"):
value = "✅"
elif cap.startswith("requires_"):
value = "⚠️"
else:
value = raw_value
elif raw_value == "false":
value = ""
else:
value = raw_value
row.append(value)
lines.append("| " + " | ".join(row) + " |")

return "\n".join(lines)

def main():
script_dir = Path(__file__).parent
build_dir = script_dir.parent / "build"

files_data = [
(str(f), json.loads(f.read_text()))
for f in list((build_dir / "tests").rglob("*.caps.json"))
]

markdown = generate_markdown_table(files_data)

(build_dir / "capabilities.md").write_text(markdown)

print(markdown)

if __name__ == "__main__":
main()
Loading