Skip to content

Commit dfe9491

Browse files
committed
Apply proper solution to function name detection from ggml-org#19785; fix Apertus template to require proper OpenAI compatible paths to tools
1 parent 8f40cfc commit dfe9491

2 files changed

Lines changed: 8 additions & 10 deletions

File tree

common/jinja/caps.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ caps caps_get(jinja::program & prog) {
224224
},
225225
});
226226
},
227-
[&](bool success, value & messages, value & tools, const std::string & res) {
227+
[&](bool success, value & messages, value & tools, const std::string &/*res*/) {
228228
if (!success) {
229229
result.supports_tool_calls = false;
230230
result.supports_tools = false;
@@ -235,9 +235,7 @@ caps caps_get(jinja::program & prog) {
235235
caps_print_stats(tool_name, "tools[0].function.name");
236236
caps_print_stats(tools, "tools");
237237
if (!tool_name->stats.used) {
238-
if (!tools->stats.used && res.find(tool_name->as_string().str()) == std::string::npos) {
239-
result.supports_tools = false;
240-
}
238+
result.supports_tools = false;
241239
}
242240

243241
auto & tool_calls = messages->at(1)->at("tool_calls");;

models/templates/Apertus-8B-Instruct.jinja

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,20 @@
9797

9898
{%- macro render_tools(tools) -%}
9999
{%- for tool in tools %}
100-
{{- "// " + tool.description + "\n" }}
101-
{{- "type "+ tool.name + " = " }}
102-
{%- if tool.parameters and tool.parameters.properties %}
100+
{{- "// " + tool.function.description + "\n" }}
101+
{{- "type "+ tool.function.name + " = " }}
102+
{%- if tool.function.parameters and tool.function.parameters.properties %}
103103
{{- "(_: {\n" }}
104-
{%- for param_name, param_spec in tool.parameters.properties.items() %}
104+
{%- for param_name, param_spec in tool.function.parameters.properties.items() %}
105105
{%- if param_spec.description %}
106106
{{- "// " + param_spec.description + "\n" }}
107107
{%- endif %}
108108
{{- param_name }}
109-
{%- if param_name not in (tool.parameters.required or []) -%}
109+
{%- if param_name not in (tool.function.parameters.required or []) -%}
110110
{{- "?" }}
111111
{%- endif -%}
112112
{{- ": " }}
113-
{{- render_typescript_type(param_spec, tool.parameters.required or []) }}
113+
{{- render_typescript_type(param_spec, tool.function.parameters.required or []) }}
114114
{%- if param_spec.default is defined -%}
115115
{%- if param_spec.enum %}
116116
{{- ", // default: " + param_spec.default }}

0 commit comments

Comments
 (0)