toolcall-lint / app.py
Meryem Sakin
Initial ToolCall Lint prototype and 20-model baseline
9d3e347
Raw History Blame Contribute Delete
2.02 kB
"""Hugging Face Space entry point."""
from __future__ import annotations
import json
import sys
from pathlib import Path
import gradio as gr
sys.path.insert(0, str(Path(__file__).parent / "src"))
from toolcall_lint import TransformersRenderer, lint_renderer # noqa: E402
from toolcall_lint.report import to_markdown # noqa: E402
def inspect_model(
model_id: str,
template_name: str,
trust_remote_code: bool,
) -> tuple[str, str]:
model_id = model_id.strip()
if not model_id:
raise gr.Error("Enter a Hugging Face model id.")
renderer = TransformersRenderer(
model_id,
template_name=template_name.strip() or None,
trust_remote_code=trust_remote_code,
)
report = lint_renderer(renderer)
return to_markdown(report), json.dumps(report.to_dict(), indent=2, ensure_ascii=False)
with gr.Blocks(title="ToolCall Lint") as demo:
gr.Markdown(
"""
# ToolCall Lint
Test a Hugging Face chat template against deterministic tool-calling contracts.
The Space downloads tokenizer/template assets only — **not model weights**.
"""
)
with gr.Row():
model_id = gr.Textbox(
label="Model repository",
value="Qwen/Qwen3-8B",
placeholder="organization/model",
)
template_name = gr.Textbox(
label="Named template (optional)",
placeholder="tool_use",
)
trust_remote_code = gr.Checkbox(
label="Trust remote tokenizer code",
value=False,
info="Leave disabled unless you have audited the repository.",
)
run_button = gr.Button("Run contract checks", variant="primary")
report_markdown = gr.Markdown()
report_json = gr.Code(label="Machine-readable report", language="json")
run_button.click(
fn=inspect_model,
inputs=[model_id, template_name, trust_remote_code],
outputs=[report_markdown, report_json],
)
if __name__ == "__main__":
demo.launch()